radiolise
Version:
Radiolise is a web app that lets you enjoy your favorite TV and radio stations.
11 lines • 504 kB
JavaScript
const F=Number.isFinite||function(a){return typeof a=="number"&&isFinite(a)},ha=Number.isSafeInteger||function(a){return typeof a=="number"&&Math.abs(a)<=ua},ua=Number.MAX_SAFE_INTEGER||9007199254740991;let U=function(a){return a.NETWORK_ERROR="networkError",a.MEDIA_ERROR="mediaError",a.KEY_SYSTEM_ERROR="keySystemError",a.MUX_ERROR="muxError",a.OTHER_ERROR="otherError",a}({}),R=function(a){return a.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",a.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",a.KEY_SYSTEM_NO_SESSION="keySystemNoSession",a.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",a.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",a.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",a.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",a.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",a.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",a.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",a.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR="keySystemDestroyMediaKeysError",a.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR="keySystemDestroyCloseSessionError",a.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR="keySystemDestroyRemoveSessionError",a.MANIFEST_LOAD_ERROR="manifestLoadError",a.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",a.MANIFEST_PARSING_ERROR="manifestParsingError",a.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",a.LEVEL_EMPTY_ERROR="levelEmptyError",a.LEVEL_LOAD_ERROR="levelLoadError",a.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",a.LEVEL_PARSING_ERROR="levelParsingError",a.LEVEL_SWITCH_ERROR="levelSwitchError",a.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",a.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",a.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",a.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",a.FRAG_LOAD_ERROR="fragLoadError",a.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",a.FRAG_DECRYPT_ERROR="fragDecryptError",a.FRAG_PARSING_ERROR="fragParsingError",a.FRAG_GAP="fragGap",a.REMUX_ALLOC_ERROR="remuxAllocError",a.KEY_LOAD_ERROR="keyLoadError",a.KEY_LOAD_TIMEOUT="keyLoadTimeOut",a.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",a.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",a.BUFFER_APPEND_ERROR="bufferAppendError",a.BUFFER_APPENDING_ERROR="bufferAppendingError",a.BUFFER_STALLED_ERROR="bufferStalledError",a.BUFFER_FULL_ERROR="bufferFullError",a.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",a.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",a.ASSET_LIST_LOAD_ERROR="assetListLoadError",a.ASSET_LIST_LOAD_TIMEOUT="assetListLoadTimeout",a.ASSET_LIST_PARSING_ERROR="assetListParsingError",a.INTERSTITIAL_ASSET_ITEM_ERROR="interstitialAssetItemError",a.INTERNAL_EXCEPTION="internalException",a.INTERNAL_ABORTED="aborted",a.ATTACH_MEDIA_ERROR="attachMediaError",a.UNKNOWN="unknown",a}({}),m=function(a){return a.MEDIA_ATTACHING="hlsMediaAttaching",a.MEDIA_ATTACHED="hlsMediaAttached",a.MEDIA_DETACHING="hlsMediaDetaching",a.MEDIA_DETACHED="hlsMediaDetached",a.MEDIA_ENDED="hlsMediaEnded",a.STALL_RESOLVED="hlsStallResolved",a.BUFFER_RESET="hlsBufferReset",a.BUFFER_CODECS="hlsBufferCodecs",a.BUFFER_CREATED="hlsBufferCreated",a.BUFFER_APPENDING="hlsBufferAppending",a.BUFFER_APPENDED="hlsBufferAppended",a.BUFFER_EOS="hlsBufferEos",a.BUFFERED_TO_END="hlsBufferedToEnd",a.BUFFER_FLUSHING="hlsBufferFlushing",a.BUFFER_FLUSHED="hlsBufferFlushed",a.MANIFEST_LOADING="hlsManifestLoading",a.MANIFEST_LOADED="hlsManifestLoaded",a.MANIFEST_PARSED="hlsManifestParsed",a.LEVEL_SWITCHING="hlsLevelSwitching",a.LEVEL_SWITCHED="hlsLevelSwitched",a.LEVEL_LOADING="hlsLevelLoading",a.LEVEL_LOADED="hlsLevelLoaded",a.LEVEL_UPDATED="hlsLevelUpdated",a.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",a.LEVELS_UPDATED="hlsLevelsUpdated",a.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",a.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",a.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",a.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",a.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",a.AUDIO_TRACK_UPDATED="hlsAudioTrackUpdated",a.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",a.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",a.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",a.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",a.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",a.SUBTITLE_TRACK_UPDATED="hlsSubtitleTrackUpdated",a.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",a.CUES_PARSED="hlsCuesParsed",a.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",a.INIT_PTS_FOUND="hlsInitPtsFound",a.FRAG_LOADING="hlsFragLoading",a.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",a.FRAG_LOADED="hlsFragLoaded",a.FRAG_DECRYPTED="hlsFragDecrypted",a.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",a.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",a.FRAG_PARSING_METADATA="hlsFragParsingMetadata",a.FRAG_PARSED="hlsFragParsed",a.FRAG_BUFFERED="hlsFragBuffered",a.FRAG_CHANGED="hlsFragChanged",a.FPS_DROP="hlsFpsDrop",a.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",a.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",a.ERROR="hlsError",a.DESTROYING="hlsDestroying",a.KEY_LOADING="hlsKeyLoading",a.KEY_LOADED="hlsKeyLoaded",a.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",a.BACK_BUFFER_REACHED="hlsBackBufferReached",a.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",a.ASSET_LIST_LOADING="hlsAssetListLoading",a.ASSET_LIST_LOADED="hlsAssetListLoaded",a.INTERSTITIALS_UPDATED="hlsInterstitialsUpdated",a.INTERSTITIALS_BUFFERED_TO_BOUNDARY="hlsInterstitialsBufferedToBoundary",a.INTERSTITIAL_ASSET_PLAYER_CREATED="hlsInterstitialAssetPlayerCreated",a.INTERSTITIAL_STARTED="hlsInterstitialStarted",a.INTERSTITIAL_ASSET_STARTED="hlsInterstitialAssetStarted",a.INTERSTITIAL_ASSET_ENDED="hlsInterstitialAssetEnded",a.INTERSTITIAL_ASSET_ERROR="hlsInterstitialAssetError",a.INTERSTITIAL_ENDED="hlsInterstitialEnded",a.INTERSTITIALS_PRIMARY_RESUMED="hlsInterstitialsPrimaryResumed",a.PLAYOUT_LIMIT_REACHED="hlsPlayoutLimitReached",a.EVENT_CUE_ENTER="hlsEventCueEnter",a}({});var z={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},N={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};class st{constructor(e,t=0,s=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_=s}sample(e,t){const s=Math.pow(this.alpha_,e);this.estimate_=t*(1-s)+s*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 da{constructor(e,t,s,i=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_=s,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new st(e),this.fast_=new st(t),this.defaultTTFB_=i,this.ttfb_=new st(e)}update(e,t){const{slow_:s,fast_:i,ttfb_:r}=this;s.halfLife!==e&&(this.slow_=new st(e,s.getEstimate(),s.getTotalWeight())),i.halfLife!==t&&(this.fast_=new st(t,i.getEstimate(),i.getTotalWeight())),r.halfLife!==e&&(this.ttfb_=new st(e,r.getEstimate(),r.getTotalWeight()))}sample(e,t){e=Math.max(e,this.minDelayMs_);const s=8*t,i=e/1e3,r=s/i;this.fast_.sample(i,r),this.slow_.sample(i,r)}sampleTTFB(e){const t=e/1e3,s=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(s,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(){}}function fa(a,e,t){return(e=ma(e))in a?Object.defineProperty(a,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):a[e]=t,a}function re(){return re=Object.assign?Object.assign.bind():function(a){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var s in t)({}).hasOwnProperty.call(t,s)&&(a[s]=t[s])}return a},re.apply(null,arguments)}function bi(a,e){var t=Object.keys(a);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(a);e&&(s=s.filter(function(i){return Object.getOwnPropertyDescriptor(a,i).enumerable})),t.push.apply(t,s)}return t}function te(a){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?bi(Object(t),!0).forEach(function(s){fa(a,s,t[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(t)):bi(Object(t)).forEach(function(s){Object.defineProperty(a,s,Object.getOwnPropertyDescriptor(t,s))})}return a}function ga(a,e){if(typeof a!="object"||!a)return a;var t=a[Symbol.toPrimitive];if(t!==void 0){var s=t.call(a,e);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(a)}function ma(a){var e=ga(a,"string");return typeof e=="symbol"?e:e+""}class $e{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 s=`[${e}]:`;this.trace=He,this.debug=t.debug.bind(null,s),this.log=t.log.bind(null,s),this.warn=t.warn.bind(null,s),this.info=t.info.bind(null,s),this.error=t.error.bind(null,s)}}const He=function(){},pa={trace:He,debug:He,log:He,warn:He,info:He,error:He};function Fs(){return re({},pa)}function Ea(a,e){const t=self.console[a];return t?t.bind(self.console,`${e?"["+e+"] ":""}[${a}] >`):He}function _i(a,e,t){return e[a]?e[a].bind(e):Ea(a,t)}const Ms=Fs();function ya(a,e,t){const s=Fs();if(typeof console=="object"&&a===!0||typeof a=="object"){const i=["debug","log","info","warn","error"];i.forEach(r=>{s[r]=_i(r,a,t)});try{s.log(`Debug logs enabled for "${e}" in hls.js version 1.6.0`)}catch(r){return Fs()}i.forEach(r=>{Ms[r]=_i(r,a)})}else re(Ms,s);return s}const Q=Ms;function We(a=!0){return typeof self=="undefined"?void 0:(a||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function Ta(a){return typeof self!="undefined"&&a===self.ManagedMediaSource}function $r(a,e){const t=Object.keys(a),s=Object.keys(e),i=t.length,r=s.length;return!i||!r||i===r&&!t.some(n=>s.indexOf(n)===-1)}function Te(a,e=!1){if(typeof TextDecoder!="undefined"){const l=new TextDecoder("utf-8").decode(a);if(e){const h=l.indexOf("\0");return h!==-1?l.substring(0,h):l}return l.replace(/\0/g,"")}const t=a.length;let s,i,r,n="",o=0;for(;o<t;){if(s=a[o++],s===0&&e)return n;if(s===0||s===3)continue;switch(s>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:n+=String.fromCharCode(s);break;case 12:case 13:i=a[o++],n+=String.fromCharCode((s&31)<<6|i&63);break;case 14:i=a[o++],r=a[o++],n+=String.fromCharCode((s&15)<<12|(i&63)<<6|(r&63)<<0);break}}return n}const De={hexDump:function(a){let e="";for(let t=0;t<a.length;t++){let s=a[t].toString(16);s.length<2&&(s="0"+s),e+=s}return e}};function Sa(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var us={exports:{}},Di;function va(){return Di||(Di=1,function(a,e){(function(t){var s=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,i=/^(?=([^\/?#]*))\1([^]*)$/,r=/(?:\/|^)\.(?=\/)/g,n=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(c,l,h){if(h=h||{},c=c.trim(),l=l.trim(),!l){if(!h.alwaysNormalize)return c;var u=o.parseURL(c);if(!u)throw new Error("Error trying to parse base URL.");return u.path=o.normalizePath(u.path),o.buildURLFromParts(u)}var d=o.parseURL(l);if(!d)throw new Error("Error trying to parse relative URL.");if(d.scheme)return h.alwaysNormalize?(d.path=o.normalizePath(d.path),o.buildURLFromParts(d)):l;var g=o.parseURL(c);if(!g)throw new Error("Error trying to parse base URL.");if(!g.netLoc&&g.path&&g.path[0]!=="/"){var f=i.exec(g.path);g.netLoc=f[1],g.path=f[2]}g.netLoc&&!g.path&&(g.path="/");var p={scheme:g.scheme,netLoc:d.netLoc,path:null,params:d.params,query:d.query,fragment:d.fragment};if(!d.netLoc&&(p.netLoc=g.netLoc,d.path[0]!=="/"))if(!d.path)p.path=g.path,d.params||(p.params=g.params,d.query||(p.query=g.query));else{var E=g.path,y=E.substring(0,E.lastIndexOf("/")+1)+d.path;p.path=o.normalizePath(y)}return p.path===null&&(p.path=h.alwaysNormalize?o.normalizePath(d.path):d.path),o.buildURLFromParts(p)},parseURL:function(c){var l=s.exec(c);return l?{scheme:l[1]||"",netLoc:l[2]||"",path:l[3]||"",params:l[4]||"",query:l[5]||"",fragment:l[6]||""}:null},normalizePath:function(c){for(c=c.split("").reverse().join("").replace(r,"");c.length!==(c=c.replace(n,"")).length;);return c.split("").reverse().join("")},buildURLFromParts:function(c){return c.scheme+c.netLoc+c.path+c.params+c.query+c.fragment}};a.exports=o})()}(us)),us.exports}var Js=va();class ei{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 ie={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"};class Gr{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,Aa(this,"stats")}setByteRange(e,t){const s=e.split("@",2);let i;s.length===1?i=(t==null?void 0:t.byteRangeEndOffset)||0:i=parseInt(s[1]),this._byteRange=[i,parseInt(s[0])+i]}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={[ie.AUDIO]:null,[ie.VIDEO]:null,[ie.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 ei),this._stats}set stats(e){this._stats=e}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Js.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}clearElementaryStreamInfo(){const{elementaryStreams:e}=this;e[ie.AUDIO]=null,e[ie.VIDEO]=null,e[ie.AUDIOVIDEO]=null}}function de(a){return a.sn!=="initSegment"}class ds extends Gr{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){const e=this.byteRange[0],t=this.byteRange[1];if(F(e)&&F(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(){const{levelkeys:e}=this;if(!e&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){const t=this.levelkeys.identity;if(t)this._decryptdata=t.getDecryptData(this.sn);else{const s=Object.keys(this.levelkeys);if(s.length===1)return this._decryptdata=this.levelkeys[s[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null)return null;const e=F(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){const t=Object.keys(this.levelkeys),s=t.length;if(s>1||s===1&&this.levelkeys[t[0]].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(!F(e)){this._programDateTime=this.rawProgramDateTime=null;return}this._programDateTime=e}get ref(){return de(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){if(this.levelkeys){const t=this.levelkeys[e];t&&!this._decryptdata&&(this._decryptdata=t.getDecryptData(this.sn))}}abortRequests(){var e,t;(e=this.loader)==null||e.abort(),(t=this.keyLoader)==null||t.abort()}setElementaryStreamInfo(e,t,s,i,r,n=!1){const{elementaryStreams:o}=this,c=o[e];if(!c){o[e]={startPTS:t,endPTS:s,startDTS:i,endDTS:r,partial:n};return}c.startPTS=Math.min(c.startPTS,t),c.endPTS=Math.max(c.endPTS,s),c.startDTS=Math.min(c.startDTS,i),c.endDTS=Math.max(c.endDTS,r)}}class xa extends Gr{constructor(e,t,s,i,r){super(s),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=t,this.index=i;const n=e.enumeratedString("BYTERANGE");n&&this.setByteRange(n,r),r&&(this.fragOffset=r.fragOffset+r.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)}}function Kr(a,e){const t=Object.getPrototypeOf(a);if(t){const s=Object.getOwnPropertyDescriptor(t,e);return s||Kr(t,e)}}function Aa(a,e){const t=Kr(a,e);t&&(t.enumerable=!0,Object.defineProperty(a,e,t))}const zt=Math.pow(2,32)-1,La=[].push,Vr={video:1,audio:2,id3:3,text:4};function le(a){return String.fromCharCode.apply(null,a)}function Hr(a,e){const t=a[e]<<8|a[e+1];return t<0?65536+t:t}function K(a,e){const t=Yr(a,e);return t<0?4294967296+t:t}function Ci(a,e){let t=K(a,e);return t*=Math.pow(2,32),t+=K(a,e+4),t}function Yr(a,e){return a[e]<<24|a[e+1]<<16|a[e+2]<<8|a[e+3]}function fs(a,e,t){a[e]=t>>24,a[e+1]=t>>16&255,a[e+2]=t>>8&255,a[e+3]=t&255}function Ia(a){const e=a.byteLength;for(let t=0;t<e;){const s=K(a,t);if(s>8&&a[t+4]===109&&a[t+5]===111&&a[t+6]===111&&a[t+7]===102)return!0;t=s>1?t+s:e}return!1}function W(a,e){const t=[];if(!e.length)return t;const s=a.byteLength;for(let i=0;i<s;){const r=K(a,i),n=le(a.subarray(i+4,i+8)),o=r>1?i+r:s;if(n===e[0])if(e.length===1)t.push(a.subarray(i+8,o));else{const c=W(a.subarray(i+8,o),e.slice(1));c.length&&La.apply(t,c)}i=o}return t}function Ra(a){const e=[],t=a[0];let s=8;const i=K(a,s);s+=4;let r=0,n=0;t===0?(r=K(a,s),n=K(a,s+4),s+=8):(r=Ci(a,s),n=Ci(a,s+8),s+=16),s+=2;let o=a.length+n;const c=Hr(a,s);s+=2;for(let l=0;l<c;l++){let h=s;const u=K(a,h);h+=4;const d=u&2147483647;if((u&2147483648)>>>31===1)return Q.warn("SIDX has hierarchical references (not supported)"),null;const f=K(a,h);h+=4,e.push({referenceSize:d,subsegmentDuration:f,info:{duration:f/i,start:o,end:o+d-1}}),o+=d,h+=4,s=h}return{earliestPresentationTime:r,timescale:i,version:t,referencesCount:c,references:e}}function Wr(a){const e=[],t=W(a,["moov","trak"]);for(let i=0;i<t.length;i++){const r=t[i],n=W(r,["tkhd"])[0];if(n){let o=n[0];const c=K(n,o===0?12:20),l=W(r,["mdia","mdhd"])[0];if(l){o=l[0];const h=K(l,o===0?12:20),u=W(r,["mdia","hdlr"])[0];if(u){const d=le(u.subarray(8,12)),g={soun:ie.AUDIO,vide:ie.VIDEO}[d],f=W(r,["mdia","minf","stbl","stsd"])[0],p=ba(f);g?(e[c]={timescale:h,type:g,stsd:p},e[g]=te({timescale:h,id:c},p)):e[c]={timescale:h,type:d,stsd:p}}}}}return W(a,["moov","mvex","trex"]).forEach(i=>{const r=K(i,4),n=e[r];n&&(n.default={duration:K(i,12),flags:K(i,20)})}),e}function ba(a){const e=a.subarray(8),t=e.subarray(8+78),s=le(e.subarray(4,8));let i=s,r;const n=s==="enca"||s==="encv";if(n){const l=W(e,[s])[0].subarray(s==="enca"?28:78);W(l,["sinf"]).forEach(u=>{const d=W(u,["schm"])[0];if(d){const g=le(d.subarray(4,8));if(g==="cbcs"||g==="cenc"){const f=W(u,["frma"])[0];f&&(i=le(f))}}})}const o=i;switch(i){case"avc1":case"avc2":case"avc3":case"avc4":{const c=W(t,["avcC"])[0];i+="."+Ct(c[1])+Ct(c[2])+Ct(c[3]),r=Dt(o==="avc1"?"dva1":"dvav",t);break}case"mp4a":{const c=W(e,[s])[0],l=W(c.subarray(28),["esds"])[0];if(l&&l.length>7){let h=4;if(l[h++]!==3)break;h=gs(l,h),h+=2;const u=l[h++];if(u&128&&(h+=2),u&64&&(h+=l[h++]),l[h++]!==4)break;h=gs(l,h);const d=l[h++];if(d===64)i+="."+Ct(d);else break;if(h+=12,l[h++]!==5)break;h=gs(l,h);const g=l[h++];let f=(g&248)>>3;f===31&&(f+=1+((g&7)<<3)+((l[h]&224)>>5)),i+="."+f}break}case"hvc1":case"hev1":{const c=W(t,["hvcC"]);if(c){const l=c[0],h=l[1],u=["","A","B","C"][h>>6],d=h&31,g=K(l,2),f=(h&32)>>5?"H":"L",p=l[12],E=l.subarray(6,12);i+="."+u+d,i+="."+g.toString(16).toUpperCase(),i+="."+f+p;let y="";for(let S=E.length;S--;){const T=E[S];(T||y)&&(y="."+T.toString(16).toUpperCase()+y)}i+=y}r=Dt(o=="hev1"?"dvhe":"dvh1",t);break}case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":{i=Dt(i,t)||i;break}case"vp09":{const c=W(t,["vpcC"])[0],l=c[4],h=c[5],u=c[6]>>4&15;i+="."+_e(l)+"."+_e(h)+"."+_e(u);break}case"av01":{const c=W(t,["av1C"])[0],l=c[1]>>>5,h=c[1]&31,u=c[2]>>>7?"H":"M",d=(c[2]&64)>>6,g=(c[2]&32)>>5,f=l===2&&d?g?12:10:d?10:8,p=(c[2]&16)>>4,E=(c[2]&8)>>3,y=(c[2]&4)>>2,S=c[2]&3,T=1,v=1,x=1,_=0;i+="."+l+"."+_e(h)+u+"."+_e(f)+"."+p+"."+E+y+S+"."+_e(T)+"."+_e(v)+"."+_e(x)+"."+_,r=Dt("dav1",t);break}}return{codec:i,encrypted:n,supplemental:r}}function Dt(a,e){const t=W(e,["dvvC"]),s=t.length?t[0]:W(e,["dvcC"])[0];if(s){const i=s[2]>>1&127,r=s[2]<<5&32|s[3]>>3&31;return a+"."+_e(i)+"."+_e(r)}}function gs(a,e){const t=e+5;for(;a[e++]&128&&e<t;);return e}function Ct(a){return("0"+a.toString(16).toUpperCase()).slice(-2)}function _e(a){return(a<10?"0":"")+a}function _a(a,e){if(!a||!e)return a;const t=e.keyId;return t&&e.isCommonEncryption&&W(a,["moov","trak"]).forEach(i=>{const n=W(i,["mdia","minf","stbl","stsd"])[0].subarray(8);let o=W(n,["enca"]);const c=o.length>0;c||(o=W(n,["encv"])),o.forEach(l=>{const h=c?l.subarray(28):l.subarray(78);W(h,["sinf"]).forEach(d=>{const g=qr(d);if(g){const f=g.subarray(8,24);f.some(p=>p!==0)||(Q.log(`[eme] Patching keyId in 'enc${c?"a":"v"}>sinf>>tenc' box: ${De.hexDump(f)} -> ${De.hexDump(t)}`),g.set(t,8))}})})}),a}function qr(a){const e=W(a,["schm"])[0];if(e){const t=le(e.subarray(4,8));if(t==="cbcs"||t==="cenc")return W(a,["schi","tenc"])[0]}return null}function Da(a,e){return W(e,["moof","traf"]).reduce((t,s)=>{const i=W(s,["tfdt"])[0],r=i[0],n=W(s,["tfhd"]).reduce((o,c)=>{const l=K(c,4),h=a[l];if(h){let u=K(i,4);if(r===1){if(u===zt)return Q.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),o;u*=zt+1,u+=K(i,8)}const d=h.timescale||9e4,g=u/d;if(F(g)&&(o===null||g<o))return g}return o},null);return n!==null&&F(n)&&(t===null||n<t)?n:t},null)}function Ca(a,e){let t=0,s=0,i=0;const r=W(a,["moof","traf"]);for(let n=0;n<r.length;n++){const o=r[n],c=W(o,["tfhd"])[0],l=K(c,4),h=e[l];if(!h)continue;const u=h.default,d=K(c,0)|(u==null?void 0:u.flags);let g=u==null?void 0:u.duration;d&8&&(d&2?g=K(c,12):g=K(c,8));const f=h.timescale||9e4,p=W(o,["trun"]);for(let E=0;E<p.length;E++){if(t=Pa(p[E]),!t&&g){const y=K(p[E],4);t=g*y}h.type===ie.VIDEO?s+=t/f:h.type===ie.AUDIO&&(i+=t/f)}}if(s===0&&i===0){let n=1/0,o=0,c=0;const l=W(a,["sidx"]);for(let h=0;h<l.length;h++){const u=Ra(l[h]);if(u!=null&&u.references){n=Math.min(n,u.earliestPresentationTime/u.timescale);const d=u.references.reduce((g,f)=>g+f.info.duration||0,0);o=Math.max(o,d+u.earliestPresentationTime/u.timescale),c=o-n}}if(c&&F(c))return c}return s||i}function Pa(a){const e=K(a,0);let t=8;e&1&&(t+=4),e&4&&(t+=4);let s=0;const i=K(a,4);for(let r=0;r<i;r++){if(e&256){const n=K(a,t);s+=n,t+=4}e&512&&(t+=4),e&1024&&(t+=4),e&2048&&(t+=4)}return s}function ka(a,e,t){W(e,["moof","traf"]).forEach(s=>{W(s,["tfhd"]).forEach(i=>{const r=K(i,4),n=a[r];if(!n)return;const o=n.timescale||9e4;W(s,["tfdt"]).forEach(c=>{const l=c[0],h=t*o;if(h){let u=K(c,4);if(l===0)u-=h,u=Math.max(u,0),fs(c,4,u);else{u*=Math.pow(2,32),u+=K(c,8),u-=h,u=Math.max(u,0);const d=Math.floor(u/(zt+1)),g=Math.floor(u%(zt+1));fs(c,4,d),fs(c,8,g)}}})})})}function wa(a){const e={valid:null,remainder:null},t=W(a,["moof"]);if(t.length<2)return e.remainder=a,e;const s=t[t.length-1];return e.valid=a.slice(0,s.byteOffset-8),e.remainder=a.slice(s.byteOffset-8),e}function Ae(a,e){const t=new Uint8Array(a.length+e.length);return t.set(a),t.set(e,a.length),t}function Pi(a,e){const t=[],s=e.samples,i=e.timescale,r=e.id;let n=!1;return W(s,["moof"]).map(c=>{const l=c.byteOffset-8;W(c,["traf"]).map(u=>{const d=W(u,["tfdt"]).map(g=>{const f=g[0];let p=K(g,4);return f===1&&(p*=Math.pow(2,32),p+=K(g,8)),p/i})[0];return d!==void 0&&(a=d),W(u,["tfhd"]).map(g=>{const f=K(g,4),p=K(g,0)&16777215,E=(p&1)!==0,y=(p&2)!==0,S=(p&8)!==0;let T=0;const v=(p&16)!==0;let x=0;const _=(p&32)!==0;let A=8;f===r&&(E&&(A+=8),y&&(A+=4),S&&(T=K(g,A),A+=4),v&&(x=K(g,A),A+=4),_&&(A+=4),e.type==="video"&&(n=os(e.codec)),W(u,["trun"]).map(b=>{const D=b[0],L=K(b,0)&16777215,P=(L&1)!==0;let O=0;const X=(L&4)!==0,V=(L&256)!==0;let G=0;const M=(L&512)!==0;let $=0;const B=(L&1024)!==0,k=(L&2048)!==0;let w=0;const Y=K(b,4);let H=8;P&&(O=K(b,H),H+=4),X&&(H+=4);let j=O+l;for(let Z=0;Z<Y;Z++){if(V?(G=K(b,H),H+=4):G=T,M?($=K(b,H),H+=4):$=x,B&&(H+=4),k&&(D===0?w=K(b,H):w=Yr(b,H),H+=4),e.type===ie.VIDEO){let ee=0;for(;ee<$;){const ne=K(s,j);if(j+=4,Oa(n,s[j])){const ge=s.subarray(j,j+ne);ti(ge,n?2:1,a+w/i,t)}j+=ne,ee+=ne+4}}a+=G/i}}))})})}),t}function os(a){if(!a)return!1;const e=a.substring(0,4);return e==="hvc1"||e==="hev1"||e==="dvh1"||e==="dvhe"}function Oa(a,e){if(a){const t=e>>1&63;return t===39||t===40}else return(e&31)===6}function ti(a,e,t,s){const i=jr(a);let r=0;r+=e;let n=0,o=0,c=0;for(;r<i.length;){n=0;do{if(r>=i.length)break;c=i[r++],n+=c}while(c===255);o=0;do{if(r>=i.length)break;c=i[r++],o+=c}while(c===255);const l=i.length-r;let h=r;if(o<l)r+=o;else if(o>l){Q.error(`Malformed SEI payload. ${o} is too small, only ${l} bytes left to parse.`);break}if(n===4){if(i[h++]===181){const d=Hr(i,h);if(h+=2,d===49){const g=K(i,h);if(h+=4,g===1195456820){const f=i[h++];if(f===3){const p=i[h++],E=31&p,y=64&p,S=y?2+E*3:0,T=new Uint8Array(S);if(y){T[0]=p;for(let v=1;v<S;v++)T[v]=i[h++]}s.push({type:f,payloadType:n,pts:t,bytes:T})}}}}}else if(n===5&&o>16){const u=[];for(let f=0;f<16;f++){const p=i[h++].toString(16);u.push(p.length==1?"0"+p:p),(f===3||f===5||f===7||f===9)&&u.push("-")}const d=o-16,g=new Uint8Array(d);for(let f=0;f<d;f++)g[f]=i[h++];s.push({payloadType:n,pts:t,uuid:u.join(""),userData:Te(g),userDataBytes:g})}}}function jr(a){const e=a.byteLength,t=[];let s=1;for(;s<e-2;)a[s]===0&&a[s+1]===0&&a[s+2]===3?(t.push(s+2),s+=2):s++;if(t.length===0)return a;const i=e-t.length,r=new Uint8Array(i);let n=0;for(s=0;s<i;n++,s++)n===t[0]&&(n++,t.shift()),r[s]=a[n];return r}function Fa(a){const e=a[0];let t="",s="",i=0,r=0,n=0,o=0,c=0,l=0;if(e===0){for(;le(a.subarray(l,l+1))!=="\0";)t+=le(a.subarray(l,l+1)),l+=1;for(t+=le(a.subarray(l,l+1)),l+=1;le(a.subarray(l,l+1))!=="\0";)s+=le(a.subarray(l,l+1)),l+=1;s+=le(a.subarray(l,l+1)),l+=1,i=K(a,12),r=K(a,16),o=K(a,20),c=K(a,24),l=28}else if(e===1){l+=4,i=K(a,l),l+=4;const u=K(a,l);l+=4;const d=K(a,l);for(l+=4,n=2**32*u+d,ha(n)||(n=Number.MAX_SAFE_INTEGER,Q.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=K(a,l),l+=4,c=K(a,l),l+=4;le(a.subarray(l,l+1))!=="\0";)t+=le(a.subarray(l,l+1)),l+=1;for(t+=le(a.subarray(l,l+1)),l+=1;le(a.subarray(l,l+1))!=="\0";)s+=le(a.subarray(l,l+1)),l+=1;s+=le(a.subarray(l,l+1)),l+=1}const h=a.subarray(l,a.byteLength);return{schemeIdUri:t,value:s,timeScale:i,presentationTime:n,presentationTimeDelta:r,eventDuration:o,id:c,payload:h}}function Ma(a,...e){const t=e.length;let s=8,i=t;for(;i--;)s+=e[i].byteLength;const r=new Uint8Array(s);for(r[0]=s>>24&255,r[1]=s>>16&255,r[2]=s>>8&255,r[3]=s&255,r.set(a,4),i=0,s=8;i<t;i++)r.set(e[i],s),s+=e[i].byteLength;return r}function Na(a,e,t){if(a.byteLength!==16)throw new RangeError("Invalid system id");let s,i;s=0,i=new Uint8Array;let r;s>0?(r=new Uint8Array(4),e.length>0&&new DataView(r.buffer).setUint32(0,e.length,!1)):r=new Uint8Array;const n=new Uint8Array(4);return t&&t.byteLength>0&&new DataView(n.buffer).setUint32(0,t.byteLength,!1),Ma([112,115,115,104],new Uint8Array([s,0,0,0]),a,r,i,n,t||new Uint8Array)}function Ba(a){const e=[];if(a instanceof ArrayBuffer){const t=a.byteLength;let s=0;for(;s+32<t;){const i=new DataView(a,s),r=Ua(i);e.push(r),s+=r.size}}return e}function Ua(a){const e=a.getUint32(0),t=a.byteOffset,s=a.byteLength;if(s<e)return{offset:t,size:s};if(a.getUint32(4)!==1886614376)return{offset:t,size:e};const r=a.getUint32(8)>>>24;if(r!==0&&r!==1)return{offset:t,size:e};const n=a.buffer,o=De.hexDump(new Uint8Array(n,t+12,16)),c=a.getUint32(28);let l=null,h=null;if(r===0){if(e-32<c||c<22)return{offset:t,size:e};h=new Uint8Array(n,t+32,c)}else if(r===1){if(!c||s<t+32+c*16+16)return{offset:t,size:e};l=[];for(let u=0;u<c;u++)l.push(new Uint8Array(n,t+32+u*16,16))}return{version:r,systemId:o,kids:l,data:h,offset:t,size:e}}const Xr=()=>/\(Windows.+Firefox\//i.test(navigator.userAgent),ht={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}};function zr(a,e){const t=ht[e];return!!t&&!!t[a.slice(0,4)]}function Ns(a,e,t=!0){return!a.split(",").some(s=>!Qr(s,e,t))}function Qr(a,e,t=!0){var s;const i=We(t);return(s=i==null?void 0:i.isTypeSupported(St(a,e)))!=null?s:!1}function St(a,e){return`${e}/mp4;codecs=${a}`}function ki(a){if(a){const e=a.substring(0,4);return ht.video[e]}return 2}function Qt(a){const e=Xr();return a.split(",").reduce((t,s)=>{const r=e&&os(s)?9:ht.video[s];return r?(r*2+t)/(t?3:2):(ht.audio[s]+t)/(t?2:1)},0)}const ms={};function $a(a,e=!0){if(ms[a])return ms[a];const t={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[a];for(let i=0;i<t.length;i++){var s;if(Qr(t[i],"audio",e))return ms[a]=t[i],t[i];if(t[i]==="mp3"&&(s=We(e))!=null&&s.isTypeSupported("audio/mpeg"))return""}return a}const Ga=/flac|opus|mp4a\.40\.34/i;function Zt(a,e=!0){return a.replace(Ga,t=>$a(t.toLowerCase(),e))}function Ka(a,e){const t=[];if(a){const s=a.split(",");for(let i=0;i<s.length;i++)zr(s[i],"video")||t.push(s[i])}return e&&t.push(e),t.join(",")}function Vt(a,e){if(a&&(a.length>4||["ac-3","ec-3","alac","fLaC","Opus"].indexOf(a)!==-1))return a;if(e){const t=e.split(",");if(t.length>1){if(a){for(let s=t.length;s--;)if(t[s].substring(0,4)===a.substring(0,4))return t[s]}return t[0]}}return e||a}function Va(a){const e=a.split(",");for(let t=0;t<e.length;t++){const s=e[t].split(".");if(s.length>2){let i=s.shift()+".";i+=parseInt(s.shift()).toString(16),i+=("000"+parseInt(s.shift()).toString(16)).slice(-4),e[t]=i}}return e.join(",")}function Ha(a){if(a.startsWith("av01.")){const e=a.split("."),t=["0","111","01","01","01","0"];for(let s=e.length;s>4&&s<10;s++)e[s]=t[s-4];return e.join(".")}return a}function wi(a){const e=We(a)||{isTypeSupported:()=>!1};return{mpeg:e.isTypeSupported("audio/mpeg"),mp3:e.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:e.isTypeSupported('audio/mp4; codecs="ac-3"')}}function Zr(a){return a.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}const Jr={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]};function en(a,e){return{supported:!1,configurations:e,decodingInfoResults:[{supported:!1,smooth:!1,powerEfficient:!1}],error:a}}const Oi={};function Ya(a,e,t,s,i,r){const n=a.audioCodec?a.audioGroups:null,o=r==null?void 0:r.audioCodec,c=r==null?void 0:r.channels,l=c?parseInt(c):o?1/0:2;let h=null;if(n!=null&&n.length)try{n.length===1&&n[0]?h=e.groups[n[0]].channels:h=n.reduce((u,d)=>{if(d){const g=e.groups[d];if(!g)throw new Error(`Audio track group ${d} not found`);Object.keys(g.channels).forEach(f=>{u[f]=(u[f]||0)+g.channels[f]})}return u},{2:0})}catch(u){return!0}return a.videoCodec!==void 0&&(a.width>1920&&a.height>1088||a.height>1920&&a.width>1088||a.frameRate>Math.max(s,30)||a.videoRange!=="SDR"&&a.videoRange!==t||a.bitrate>Math.max(i,8e6))||!!h&&F(l)&&Object.keys(h).some(u=>parseInt(u)>l)}function tn(a,e,t){const s=a.videoCodec,i=a.audioCodec;if(!s&&!i||!t)return Promise.resolve(Jr);const r=[];if(s){const n={width:a.width,height:a.height,bitrate:Math.ceil(Math.max(a.bitrate*.9,a.averageBitrate)),framerate:a.frameRate||30},o=a.videoRange;o!=="SDR"&&(n.transferFunction=o.toLowerCase());const c=s.split(","),l=navigator.userAgent;if(c.some(h=>os(h))&&Xr())return Promise.resolve(en(new Error(`Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent sting: (${l})`),r));r.push.apply(r,c.map(h=>({type:"media-source",video:te(te({},n),{},{contentType:St(Ha(h),"video")})})))}return i&&a.audioGroups&&a.audioGroups.forEach(n=>{var o;n&&((o=e.groups[n])==null||o.tracks.forEach(c=>{if(c.groupId===n){const l=c.channels||"",h=parseFloat(l);F(h)&&h>2&&r.push.apply(r,i.split(",").map(u=>({type:"media-source",audio:{contentType:St(u,"audio"),channels:""+h}})))}}))}),Promise.all(r.map(n=>{const o=Wa(n);return Oi[o]||(Oi[o]=t.decodingInfo(n))})).then(n=>({supported:!n.some(o=>!o.supported),configurations:r,decodingInfoResults:n})).catch(n=>({supported:!1,configurations:r,decodingInfoResults:[],error:n}))}function Wa(a){const{audio:e,video:t}=a,s=t||e;if(s){const i=Zr(s.contentType);if(t)return`r${t.height}x${t.width}f${Math.ceil(t.framerate)}${t.transferFunction||"sd"}_${i}_${Math.ceil(t.bitrate/1e5)}`;if(e)return`c${e.channels}${e.spatialRendering?"s":"n"}_${i}`}return""}const Bs=["NONE","TYPE-0","TYPE-1",null];function qa(a){return Bs.indexOf(a)>-1}const Jt=["SDR","PQ","HLG"];function ja(a){return!!a&&Jt.indexOf(a)>-1}var Ht={No:"",Yes:"YES",v2:"v2"};function Fi(a){const{canSkipUntil:e,canSkipDateRanges:t,age:s}=a,i=s<e/2;return e&&i?t?Ht.v2:Ht.Yes:Ht.No}class Mi{constructor(e,t,s){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=s}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 vt{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.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.frameRate=e.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=e.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.codecSet=[e.videoCodec,e.audioCodec].filter(s=>!!s).map(s=>s.substring(0,4)).join(","),"supplemental"in e){var t;this.supplemental=e.supplemental;const s=(t=e.supplemental)==null?void 0:t.videoCodec;s&&s!==e.videoCodec&&(this.codecSet+=`,${s.substring(0,4)}`)}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 Ni(this._audioGroups,e)}hasSubtitleGroup(e){return Ni(this._subtitleGroups,e)}get audioGroups(){return this._audioGroups}get subtitleGroups(){return this._subtitleGroups}addGroupId(e,t){if(t){if(e==="audio"){let s=this._audioGroups;s||(s=this._audioGroups=[]),s.indexOf(t)===-1&&s.push(t)}else if(e==="text"){let s=this._subtitleGroups;s||(s=this._subtitleGroups=[]),s.indexOf(t)===-1&&s.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 Ni(a,e){return!e||!a?!1:a.indexOf(e)!==-1}function Xa(){if(typeof matchMedia=="function"){const a=matchMedia("(dynamic-range: high)"),e=matchMedia("bad query");if(a.media!==e.media)return a.matches===!0}return!1}function za(a,e){let t=!1,s=[];if(a&&(t=a!=="SDR",s=[a]),e){s=e.allowedVideoRanges||Jt.slice(0);const i=s.join("")!=="SDR"&&!e.videoCodec;t=e.preferHDR!==void 0?e.preferHDR:i&&Xa(),t||(s=["SDR"])}return{preferHDR:t,allowedVideoRanges:s}}const Qa=a=>{const e=new WeakSet;return(t,s)=>{if(a&&(s=a(t,s)),typeof s=="object"&&s!==null){if(e.has(s))return;e.add(s)}return s}},ae=(a,e)=>JSON.stringify(a,Qa(e));function Za(a,e,t,s,i){const r=Object.keys(a),n=s==null?void 0:s.channels,o=s==null?void 0:s.audioCodec,c=i==null?void 0:i.videoCodec,l=n&&parseInt(n)===2;let h=!1,u=!1,d=1/0,g=1/0,f=1/0,p=1/0,E=0,y=[];const{preferHDR:S,allowedVideoRanges:T}=za(e,i);for(let b=r.length;b--;){const D=a[r[b]];h||(h=D.channels[2]>0),d=Math.min(d,D.minHeight),g=Math.min(g,D.minFramerate),f=Math.min(f,D.minBitrate),T.filter(P=>D.videoRanges[P]>0).length>0&&(u=!0)}d=F(d)?d:0,g=F(g)?g:0;const v=Math.max(1080,d),x=Math.max(30,g);f=F(f)?f:t,t=Math.max(f,t),u||(e=void 0);const _=r.length>1;return{codecSet:r.reduce((b,D)=>{const L=a[D];if(D===b)return b;if(y=u?T.filter(P=>L.videoRanges[P]>0):[],_){if(L.minBitrate>t)return be(D,`min bitrate of ${L.minBitrate} > current estimate of ${t}`),b;if(!L.hasDefaultAudio)return be(D,"no renditions with default or auto-select sound found"),b;if(o&&D.indexOf(o.substring(0,4))%5!==0)return be(D,`audio codec preference "${o}" not found`),b;if(n&&!l){if(!L.channels[n])return be(D,`no renditions with ${n} channel sound found (channels options: ${Object.keys(L.channels)})`),b}else if((!o||l)&&h&&L.channels[2]===0)return be(D,"no renditions with stereo sound found"),b;if(L.minHeight>v)return be(D,`min resolution of ${L.minHeight} > maximum of ${v}`),b;if(L.minFramerate>x)return be(D,`min framerate of ${L.minFramerate} > maximum of ${x}`),b;if(!y.some(P=>L.videoRanges[P]>0))return be(D,`no variants with VIDEO-RANGE of ${ae(y)} found`),b;if(c&&D.indexOf(c.substring(0,4))%5!==0)return be(D,`video codec preference "${c}" not found`),b;if(L.maxScore<E)return be(D,`max score of ${L.maxScore} < selected max of ${E}`),b}return b&&(Qt(D)>=Qt(b)||L.fragmentError>a[b].fragmentError)?b:(p=L.minIndex,E=L.maxScore,D)},void 0),videoRanges:y,preferHDR:S,minFramerate:g,minBitrate:f,minIndex:p}}function be(a,e){Q.log(`[abr] start candidates with "${a}" ignored because ${e}`)}function sn(a){return a.reduce((e,t)=>{let s=e.groups[t.groupId];s||(s=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),s.tracks.push(t);const i=t.channels||"2";return s.channels[i]=(s.channels[i]||0)+1,s.hasDefault=s.hasDefault||t.default,s.hasAutoSelect=s.hasAutoSelect||t.autoselect,s.hasDefault&&(e.hasDefaultAudio=!0),s.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function Ja(a,e,t,s){return a.slice(t,s+1).reduce((i,r,n)=>{if(!r.codecSet)return i;const o=r.audioGroups;let c=i[r.codecSet];c||(i[r.codecSet]=c={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:n,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!o,fragmentError:0}),c.minBitrate=Math.min(c.minBitrate,r.bitrate);const l=Math.min(r.height,r.width);return c.minHeight=Math.min(c.minHeight,l),c.minFramerate=Math.min(c.minFramerate,r.frameRate),c.minIndex=Math.min(c.minIndex,n),c.maxScore=Math.max(c.maxScore,r.score),c.fragmentError+=r.fragmentError,c.videoRanges[r.videoRange]=(c.videoRanges[r.videoRange]||0)+1,o&&o.forEach(h=>{if(!h)return;const u=e.groups[h];u&&(c.hasDefaultAudio=c.hasDefaultAudio||e.hasDefaultAudio?u.hasDefault:u.hasAutoSelect||!e.hasDefaultAudio&&!e.hasAutoSelectAudio,Object.keys(u.channels).forEach(d=>{c.channels[d]=(c.channels[d]||0)+u.channels[d]}))}),i},{})}function Bi(a){if(!a)return a;const{lang:e,assocLang:t,characteristics:s,channels:i,audioCodec:r}=a;return{lang:e,assocLang:t,characteristics:s,channels:i,audioCodec:r}}function Pe(a,e,t){if("attrs"in a){const s=e.indexOf(a);if(s!==-1)return s}for(let s=0;s<e.length;s++){const i=e[s];if(Je(a,i,t))return s}return-1}function Je(a,e,t){const{groupId:s,name:i,lang:r,assocLang:n,default:o}=a,c=a.forced;return(s===void 0||e.groupId===s)&&(i===void 0||e.name===i)&&(r===void 0||eo(r,e.lang))&&(r===void 0||e.assocLang===n)&&(o===void 0||e.default===o)&&(c===void 0||e.forced===c)&&(!("characteristics"in a)||to(a.characteristics||"",e.characteristics))&&(t===void 0||t(a,e))}function eo(a,e="--"){return a.length===e.length?a===e:a.startsWith(e)||e.startsWith(a)}function to(a,e=""){const t=a.split(","),s=e.split(",");return t.length===s.length&&!t.some(i=>s.indexOf(i)===-1)}function Qe(a,e){const{audioCodec:t,channels:s}=a;return(t===void 0||(e.audioCodec||"").substring(0,4)===t.substring(0,4))&&(s===void 0||s===(e.channels||"2"))}function so(a,e,t,s,i){const r=e[s],o=e.reduce((d,g,f)=>{const p=g.uri;return(d[p]||(d[p]=[])).push(f),d},{})[r.uri];o.length>1&&(s=Math.max.apply(Math,o));const c=r.videoRange,l=r.frameRate,h=r.codecSet.substring(0,4),u=Ui(e,s,d=>{if(d.videoRange!==c||d.frameRate!==l||d.codecSet.substring(0,4)!==h)return!1;const g=d.audioGroups,f=t.filter(p=>!g||g.indexOf(p.groupId)!==-1);return Pe(a,f,i)>-1});return u>-1?u:Ui(e,s,d=>{const g=d.audioGroups,f=t.filter(p=>!g||g.indexOf(p.groupId)!==-1);return Pe(a,f,i)>-1})}function Ui(a,e,t){for(let s=e;s>-1;s--)if(t(a[s]))return s;for(let s=e+1;s<a.length;s++)if(t(a[s]))return s;return-1}function es(a,e){var t;return!!a&&a!==((t=e.loadLevelObj)==null?void 0:t.uri)}class io extends $e{constructor(e){super("abr",e.logger),this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.codecTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.rebufferNotice=-1,this.bwEstimator=void 0,this._abandonRulesCheck=t=>{var s;const{fragCurrent:i,partCurrent:r,hls:n}=this,{autoLevelEnabled:o,media:c}=n;if(!i||!c)return;const l=performance.now(),h=r?r.stats:i.stats,u=r?r.duration:i.duration,d=l-h.loading.start,g=n.minAutoLevel,f=i.level,p=this._nextAutoLevel;if(h.aborted||h.loaded&&h.loaded===h.total||f<=g){this.clearTimer(),this._nextAutoLevel=-1;return}if(!o)return;const E=p>-1&&p!==f,y=!!t||E;if(!y&&(c.paused||!c.playbackRate||!c.readyState))return;const S=n.mainForwardBufferInfo;if(!y&&S===null)return;const T=this.bwEstimator.getEstimateTTFB(),v=Math.abs(c.playbackRate);if(d<=Math.max(T,1e3*(u/(v*2))))return;const x=S?S.len/v:0,_=h.loading.first?h.loading.first-h.loading.start:-1,A=h.loaded&&_>-1,b=this.getBwEstimate(),D=n.levels,L=D[f],P=Math.max(h.loaded,Math.round(u*(i.bitrate||L.averageBitrate)/8));let O=A?d-_:d;O<1&&A&&(O=Math.min(d,h.loaded*8/b));const X=A?h.loaded*1e3/O:0,V=T/1e3,G=X?(P-h.loaded)/X:P*8/b+V;if(G<=x)return;const M=X?X*8:b,$=((s=(t==null?void 0:t.details)||this.hls.latestLevelDetails)==null?void 0:s.live)===!0,B=this.hls.config.abrBandWidthUpFactor;let k=Number.POSITIVE_INFINITY,w;for(w=f-1;w>g;w--){const Z=D[w].maxBitrate,ee=!D[w].details||$;if(k=this.getTimeToLoadFrag(V,M,u*Z,ee),k<Math.min(x,u+V))break}if(k>=G||k>u*10)return;A?this.bwEstimator.sample(d-Math.min(T,_),h.loaded):this.bwEstimator.sampleTTFB(d);const Y=D[w].maxBitrate;this.getBwEstimate()*B>Y&&this.resetEstimator(Y);const H=this.findBestLevel(Y,g,w,0,x,1,1);H>-1&&(w=H),this.warn(`Fragment ${i.sn}${r?" part "+r.index:""} of level ${f} is loading too slowly;
Fragment duration: ${i.duration.toFixed(3)}
Time to underbuffer: ${x.toFixed(3)} s
Estimated load time for current fragment: ${G.toFixed(3)} s
Estimated load time for down switch fragment: ${k.toFixed(3)} s
TTFB estimate: ${_|0} ms
Current BW estimate: ${F(b)?b|0:"Unknown"} bps
New BW estimate: ${this.getBwEstimate()|0} bps
Switching to level ${w} @ ${Y|0} bps`),n.nextLoadLevel=n.nextAutoLevel=w,this.clearTimer();const j=()=>{if(this.clearTimer(),this.fragCurrent===i&&this.hls.loadLevel===w&&w>0){const Z=this.getStarvationDelay();if(this.warn(`Aborting inflight request ${w>0?"and switching down":""}
Fragment duration: ${i.duration.toFixed(3)} s
Time to underbuffer: ${Z.toFixed(3)} s`),i.abortRequests(),this.fragCurrent=this.partCurrent=null,w>g){let ee=this.findBestLevel(this.hls.levels[g].bitrate,g,w,0,Z,1,1);ee===-1&&(ee=g),this.hls.nextLoadLevel=this.hls.nextAutoLevel=ee,this.resetEstimator(this.hls.levels[ee].bitrate)}}};E||G>k*2?j():this.timer=self.setInterval(j,k*1e3),n.trigger(m.FRAG_LOAD_EMERGENCY_ABORTED,{frag:i,part:r,stats:h})},this.hls=e,this.bwEstimator=this.initEstimator(),this.registerListeners()}resetEstimator(e){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 da(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}registerListeners(){const{hls:e}=this;e.on(m.MANIFEST_LOADING,this.onManifestLoading,this),e.on(m.FRAG_LOADING,this.onFragLoading,this),e.on(m.FRAG_LOADED,this.onFragLoaded,this),e.on(m.FRAG_BUFFERED,this.onFragBuffered,this),e.on(m.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(m.LEVEL_LOADED,this.onLevelLoaded,this),e.on(m.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(m.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(m.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e&&(e.off(m.MANIFEST_LOADING,this.onManifestLoading,this),e.off(m.FRAG_LOADING,this.onFragLoading,this),e.off(m.FRAG_LOADED,this.onFragLoaded,this),e.off(m.FRAG_BUFFERED,this.onFragBuffered,this),e.off(m.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(m.LEVEL_LOADED,this.onLevelLoaded,this),e.off(m.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(m.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(m.ERROR,this.onError,this))}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null}onManifestLoading(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()}onLevelsUpdated(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null}onMaxAutoLevelUpdated(){this.firstSelection=-1,this.nextAutoLevelKey=""}onFragLoading(e,t){const s=t.frag;if(!this.ignoreFragment(s)){if(!s.bitrateTest){var i;this.fragCurrent=s,this.partCurrent=(i=t.part)!=null?i: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 R.BUFFER_ADD_CODEC_ERROR:case R.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case R.FRAG_LOAD_TIMEOUT:{const s=t.frag,{fragCurrent:i,partCurrent:r}=this;if(s&&i&&s.sn===i.sn&&s.level===i.level){const n=performance.now(),o=r?r.stats:s.stats,c=n-o.loading.start,l=o.loading.first?o.loading.first-o.loading.start:-1;if(o.loaded&&l>-1){const u=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(c-Math.min(u,l),o.loaded)}else this.bwEstimator.sampleTTFB(c)}break}}}getTimeToLoadFrag(e,t,s,i){const r=e+s/t,n=i?e+this.lastLevelLoadSec:0;return r+n}onLevelLoaded(e,t){const s=this.hls.config,{loading:i}=t.stats,r=i.end-i.first;F(r)&&(this.lastLevelLoadSec=r/1e3),t.details.live?this.bwEstimator.update(s.abrEwmaSlowLive,s.abrEwmaFastLive):this.bwEstimator.update(s.abrEwmaSlowVoD,s.abrEwmaFastVoD),this.timer>-1&&this._abandonRulesCheck(t.levelInfo)}onFragLoaded(e,{frag:t,part:s}){const i=s?s.stats:t.stats;if(t.type===N.MAIN&&this.bwEstimator.sampleTTFB(i.loading.first-i.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),t.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){const r=s?s.duration:t.duration,n=this.hls.levels[t.level],o=(n.loaded?n.loaded.bytes:0)+i.loaded,c=(n.loaded?n.loaded.duration:0)+r;n.loaded={bytes:o,duration:c},n.realBitrate=Math.round(8*o/c)}if(t.bitrateTest){const r={stats:i,frag:t,part:s,id:t.type};this.onFragBuffered(m.FRAG_BUFFERED,r),t.bitrateTest=!1}else this.lastLoadedFragLevel=t.level}}onFra