@eyevinn/web-player
Version:
[](https://www.jsdelivr.com/package/npm/@eyevinn/web-player)
2 lines • 1.92 MB
JavaScript
/*! For license information please see webplayer.min.js.LICENSE.txt */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.webplayer=t():e.webplayer=t()}(this,(()=>(()=>{var e={557:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>a});var r=n(790),i=n(357),a=function(e){function t(t){var n;return(n=e.call(this,t)||this).mediaPlayer=void 0,n.mediaPlayer=(0,i.MediaPlayer)().create(),n.mediaPlayer.initialize(),n.mediaPlayer.attachView(n.video),n}(0,r._)(t,e);var n=t.prototype;return n.load=function(t){var n=this;return e.prototype.setDefaultState.call(this),new Promise((function(e,r){n.mediaPlayer.attachSource(t),n.mediaPlayer.on(i.MediaPlayer.events.MANIFEST_LOADED,(function(){e()})),n.mediaPlayer.on(i.MediaPlayer.events.ERROR,(function(e){r("Failed to load Mss Player")}))}))},n.destroy=function(){this.mediaPlayer&&(this.mediaPlayer.reset(),this.mediaPlayer=null),e.prototype.destroy.call(this)},(0,r.a)(t,[{key:"isLive",get:function(){return this.mediaPlayer.isDynamic()}}])}(r.B)},275:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>Ko});var r=n(790);const i=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},a=Number.isSafeInteger||function(e){return"number"==typeof e&&Math.abs(e)<=s},s=Number.MAX_SAFE_INTEGER||9007199254740991;let o=function(e){return e.NETWORK_ERROR="networkError",e.MEDIA_ERROR="mediaError",e.KEY_SYSTEM_ERROR="keySystemError",e.MUX_ERROR="muxError",e.OTHER_ERROR="otherError",e}({}),l=function(e){return e.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",e.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",e.KEY_SYSTEM_NO_SESSION="keySystemNoSession",e.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",e.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",e.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",e.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",e.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",e.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR="keySystemDestroyMediaKeysError",e.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR="keySystemDestroyCloseSessionError",e.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR="keySystemDestroyRemoveSessionError",e.MANIFEST_LOAD_ERROR="manifestLoadError",e.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",e.MANIFEST_PARSING_ERROR="manifestParsingError",e.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",e.LEVEL_EMPTY_ERROR="levelEmptyError",e.LEVEL_LOAD_ERROR="levelLoadError",e.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",e.LEVEL_PARSING_ERROR="levelParsingError",e.LEVEL_SWITCH_ERROR="levelSwitchError",e.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",e.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",e.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",e.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",e.FRAG_LOAD_ERROR="fragLoadError",e.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",e.FRAG_DECRYPT_ERROR="fragDecryptError",e.FRAG_PARSING_ERROR="fragParsingError",e.FRAG_GAP="fragGap",e.REMUX_ALLOC_ERROR="remuxAllocError",e.KEY_LOAD_ERROR="keyLoadError",e.KEY_LOAD_TIMEOUT="keyLoadTimeOut",e.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",e.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",e.BUFFER_APPEND_ERROR="bufferAppendError",e.BUFFER_APPENDING_ERROR="bufferAppendingError",e.BUFFER_STALLED_ERROR="bufferStalledError",e.BUFFER_FULL_ERROR="bufferFullError",e.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",e.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",e.ASSET_LIST_LOAD_ERROR="assetListLoadError",e.ASSET_LIST_LOAD_TIMEOUT="assetListLoadTimeout",e.ASSET_LIST_PARSING_ERROR="assetListParsingError",e.INTERSTITIAL_ASSET_ITEM_ERROR="interstitialAssetItemError",e.INTERNAL_EXCEPTION="internalException",e.INTERNAL_ABORTED="aborted",e.ATTACH_MEDIA_ERROR="attachMediaError",e.UNKNOWN="unknown",e}({}),u=function(e){return e.MEDIA_ATTACHING="hlsMediaAttaching",e.MEDIA_ATTACHED="hlsMediaAttached",e.MEDIA_DETACHING="hlsMediaDetaching",e.MEDIA_DETACHED="hlsMediaDetached",e.MEDIA_ENDED="hlsMediaEnded",e.STALL_RESOLVED="hlsStallResolved",e.BUFFER_RESET="hlsBufferReset",e.BUFFER_CODECS="hlsBufferCodecs",e.BUFFER_CREATED="hlsBufferCreated",e.BUFFER_APPENDING="hlsBufferAppending",e.BUFFER_APPENDED="hlsBufferAppended",e.BUFFER_EOS="hlsBufferEos",e.BUFFERED_TO_END="hlsBufferedToEnd",e.BUFFER_FLUSHING="hlsBufferFlushing",e.BUFFER_FLUSHED="hlsBufferFlushed",e.MANIFEST_LOADING="hlsManifestLoading",e.MANIFEST_LOADED="hlsManifestLoaded",e.MANIFEST_PARSED="hlsManifestParsed",e.LEVEL_SWITCHING="hlsLevelSwitching",e.LEVEL_SWITCHED="hlsLevelSwitched",e.LEVEL_LOADING="hlsLevelLoading",e.LEVEL_LOADED="hlsLevelLoaded",e.LEVEL_UPDATED="hlsLevelUpdated",e.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",e.LEVELS_UPDATED="hlsLevelsUpdated",e.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",e.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",e.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",e.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",e.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",e.AUDIO_TRACK_UPDATED="hlsAudioTrackUpdated",e.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",e.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",e.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",e.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",e.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",e.SUBTITLE_TRACK_UPDATED="hlsSubtitleTrackUpdated",e.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",e.CUES_PARSED="hlsCuesParsed",e.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",e.INIT_PTS_FOUND="hlsInitPtsFound",e.FRAG_LOADING="hlsFragLoading",e.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",e.FRAG_LOADED="hlsFragLoaded",e.FRAG_DECRYPTED="hlsFragDecrypted",e.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",e.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",e.FRAG_PARSING_METADATA="hlsFragParsingMetadata",e.FRAG_PARSED="hlsFragParsed",e.FRAG_BUFFERED="hlsFragBuffered",e.FRAG_CHANGED="hlsFragChanged",e.FPS_DROP="hlsFpsDrop",e.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",e.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",e.ERROR="hlsError",e.DESTROYING="hlsDestroying",e.KEY_LOADING="hlsKeyLoading",e.KEY_LOADED="hlsKeyLoaded",e.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",e.BACK_BUFFER_REACHED="hlsBackBufferReached",e.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",e.ASSET_LIST_LOADING="hlsAssetListLoading",e.ASSET_LIST_LOADED="hlsAssetListLoaded",e.INTERSTITIALS_UPDATED="hlsInterstitialsUpdated",e.INTERSTITIALS_BUFFERED_TO_BOUNDARY="hlsInterstitialsBufferedToBoundary",e.INTERSTITIAL_ASSET_PLAYER_CREATED="hlsInterstitialAssetPlayerCreated",e.INTERSTITIAL_STARTED="hlsInterstitialStarted",e.INTERSTITIAL_ASSET_STARTED="hlsInterstitialAssetStarted",e.INTERSTITIAL_ASSET_ENDED="hlsInterstitialAssetEnded",e.INTERSTITIAL_ASSET_ERROR="hlsInterstitialAssetError",e.INTERSTITIAL_ENDED="hlsInterstitialEnded",e.INTERSTITIALS_PRIMARY_RESUMED="hlsInterstitialsPrimaryResumed",e.PLAYOUT_LIMIT_REACHED="hlsPlayoutLimitReached",e.EVENT_CUE_ENTER="hlsEventCueEnter",e}({});var c="manifest",d="level",f="audioTrack",h="subtitleTrack",g="main",p="audio",m="subtitle";class v{constructor(e,t=0,n=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_=n}sample(e,t){const n=Math.pow(this.alpha_,e);this.estimate_=t*(1-n)+n*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 y{constructor(e,t,n,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_=n,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new v(e),this.fast_=new v(t),this.defaultTTFB_=r,this.ttfb_=new v(e)}update(e,t){const{slow_:n,fast_:r,ttfb_:i}=this;n.halfLife!==e&&(this.slow_=new v(e,n.getEstimate(),n.getTotalWeight())),r.halfLife!==t&&(this.fast_=new v(t,r.getEstimate(),r.getTotalWeight())),i.halfLife!==e&&(this.ttfb_=new v(e,i.getEstimate(),i.getTotalWeight()))}sample(e,t){const n=(e=Math.max(e,this.minDelayMs_))/1e3,r=8*t/n;this.fast_.sample(n,r),this.slow_.sample(n,r)}sampleTTFB(e){const t=e/1e3,n=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(n,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 E(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function T(){return T=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},T.apply(null,arguments)}function b(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function S(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?b(Object(n),!0).forEach((function(t){E(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):b(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}class _{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 n=`[${e}]:`;this.trace=A,this.debug=t.debug.bind(null,n),this.log=t.log.bind(null,n),this.warn=t.warn.bind(null,n),this.info=t.info.bind(null,n),this.error=t.error.bind(null,n)}}const A=function(){},I={trace:A,debug:A,log:A,warn:A,info:A,error:A};function R(){return T({},I)}function w(e,t,n){return t[e]?t[e].bind(t):function(e,t){const n=self.console[e];return n?n.bind(self.console,`${t?"["+t+"] ":""}[${e}] >`):A}(e,n)}const C=R(),D=C;function L(e=!0){if("undefined"!=typeof self)return(e||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function k(e,t){const n=Object.keys(e),r=Object.keys(t),i=n.length,a=r.length;return!i||!a||i===a&&!n.some((e=>-1===r.indexOf(e)))}function P(e,t=!1){if("undefined"!=typeof TextDecoder){const n=new TextDecoder("utf-8").decode(e);if(t){const e=n.indexOf("\0");return-1!==e?n.substring(0,e):n}return n.replace(/\0/g,"")}const n=e.length;let r,i,a,s="",o=0;for(;o<n;){if(r=e[o++],0===r&&t)return s;if(0!==r&&3!==r)switch(r>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:s+=String.fromCharCode(r);break;case 12:case 13:i=e[o++],s+=String.fromCharCode((31&r)<<6|63&i);break;case 14:i=e[o++],a=e[o++],s+=String.fromCharCode((15&r)<<12|(63&i)<<6|(63&a)<<0)}}return s}function M(e){let t="";for(let n=0;n<e.length;n++){let r=e[n].toString(16);r.length<2&&(r="0"+r),t+=r}return t}function N(e){return Uint8Array.from(e.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}function x(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var O,F={exports:{}},U=(O||(O=1,function(e,t){var n,r,i,a,s;n=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,r=/^(?=([^\/?#]*))\1([^]*)$/,i=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,s={buildAbsoluteURL:function(e,t,n){if(n=n||{},e=e.trim(),!(t=t.trim())){if(!n.alwaysNormalize)return e;var i=s.parseURL(e);if(!i)throw new Error("Error trying to parse base URL.");return i.path=s.normalizePath(i.path),s.buildURLFromParts(i)}var a=s.parseURL(t);if(!a)throw new Error("Error trying to parse relative URL.");if(a.scheme)return n.alwaysNormalize?(a.path=s.normalizePath(a.path),s.buildURLFromParts(a)):t;var o=s.parseURL(e);if(!o)throw new Error("Error trying to parse base URL.");if(!o.netLoc&&o.path&&"/"!==o.path[0]){var l=r.exec(o.path);o.netLoc=l[1],o.path=l[2]}o.netLoc&&!o.path&&(o.path="/");var u={scheme:o.scheme,netLoc:a.netLoc,path:null,params:a.params,query:a.query,fragment:a.fragment};if(!a.netLoc&&(u.netLoc=o.netLoc,"/"!==a.path[0]))if(a.path){var c=o.path,d=c.substring(0,c.lastIndexOf("/")+1)+a.path;u.path=s.normalizePath(d)}else u.path=o.path,a.params||(u.params=o.params,a.query||(u.query=o.query));return null===u.path&&(u.path=n.alwaysNormalize?s.normalizePath(a.path):a.path),s.buildURLFromParts(u)},parseURL:function(e){var t=n.exec(e);return t?{scheme:t[1]||"",netLoc:t[2]||"",path:t[3]||"",params:t[4]||"",query:t[5]||"",fragment:t[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace(i,"");e.length!==(e=e.replace(a,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}},e.exports=s}(F)),F.exports);class B{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 j="audio",G="video",H="audiovideo";class V{constructor(e){this._byteRange=null,this._url=null,this._stats=null,this._streams=null,this.base=void 0,this.relurl=void 0,"string"==typeof e&&(e={url:e}),this.base=e,function(e,t){const n=$(e,t);n&&(n.enumerable=!0,Object.defineProperty(e,t,n))}(this,"stats")}setByteRange(e,t){const n=e.split("@",2);let r;r=1===n.length?(null==t?void 0:t.byteRangeEndOffset)||0:parseInt(n[1]),this._byteRange=[r,parseInt(n[0])+r]}get baseurl(){return this.base.url}get byteRange(){return null===this._byteRange?[]:this._byteRange}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get elementaryStreams(){return null===this._streams&&(this._streams={[j]:null,[G]:null,[H]:null}),this._streams}set elementaryStreams(e){this._streams=e}get hasStats(){return null!==this._stats}get hasStreams(){return null!==this._streams}get stats(){return null===this._stats&&(this._stats=new B),this._stats}set stats(e){this._stats=e}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=U.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}clearElementaryStreamInfo(){const{elementaryStreams:e}=this;e.audio=null,e.video=null,e.audiovideo=null}}function K(e){return"initSegment"!==e.sn}class q extends V{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(i(e)&&i(t))return t-e}return null}get bitrate(){return this.byteLength?8*this.byteLength/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(null==(e=this._decryptdata)||!e.keyId){const e=Object.keys(t);if(1===e.length){const n=this._decryptdata=t[e[0]]||null;n&&(this._decryptdata=n.getDecryptData(this.sn,t))}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(null===this.programDateTime)return null;const e=i(this.duration)?this.duration:0;return this.programDateTime+1e3*e}get encrypted(){var e;if(null!=(e=this._decryptdata)&&e.encrypted)return!0;if(this.levelkeys){var t;const e=Object.keys(this.levelkeys),n=e.length;if(n>1||1===n&&null!=(t=this.levelkeys[e[0]])&&t.encrypted)return!0}return!1}get programDateTime(){return null===this._programDateTime&&this.rawProgramDateTime&&(this.programDateTime=Date.parse(this.rawProgramDateTime)),this._programDateTime}set programDateTime(e){i(e)?this._programDateTime=e:this._programDateTime=this.rawProgramDateTime=null}get ref(){return K(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 n;const r=t[e];!r||null!=(n=this._decryptdata)&&n.keyId||(this._decryptdata=r.getDecryptData(this.sn,t))}}abortRequests(){var e,t;null==(e=this.loader)||e.abort(),null==(t=this.keyLoader)||t.abort()}setElementaryStreamInfo(e,t,n,r,i,a=!1){const{elementaryStreams:s}=this,o=s[e];o?(o.startPTS=Math.min(o.startPTS,t),o.endPTS=Math.max(o.endPTS,n),o.startDTS=Math.min(o.startDTS,r),o.endDTS=Math.max(o.endDTS,i)):s[e]={startPTS:t,endPTS:n,startDTS:r,endDTS:i,partial:a}}}class Y extends V{constructor(e,t,n,r,i){super(n),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=r;const a=e.enumeratedString("BYTERANGE");a&&this.setByteRange(a,i),i&&(this.fragOffset=i.fragOffset+i.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 $(e,t){const n=Object.getPrototypeOf(e);if(n){return Object.getOwnPropertyDescriptor(n,t)||$(n,t)}}const W=Math.pow(2,32)-1,z=[].push,X={video:1,audio:2,id3:3,text:4};function Q(e){return String.fromCharCode.apply(null,e)}function J(e,t){const n=e[t]<<8|e[t+1];return n<0?65536+n:n}function Z(e,t){const n=te(e,t);return n<0?4294967296+n:n}function ee(e,t){let n=Z(e,t);return n*=Math.pow(2,32),n+=Z(e,t+4),n}function te(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function ne(e,t){const n=[];if(!t.length)return n;const r=e.byteLength;for(let i=0;i<r;){const a=Z(e,i),s=a>1?i+a:r;if(Q(e.subarray(i+4,i+8))===t[0])if(1===t.length)n.push(e.subarray(i+8,s));else{const r=ne(e.subarray(i+8,s),t.slice(1));r.length&&z.apply(n,r)}i=s}return n}function re(e){const t=[],n=e[0];let r=8;const i=Z(e,r);r+=4;let a=0,s=0;0===n?(a=Z(e,r),s=Z(e,r+4),r+=8):(a=ee(e,r),s=ee(e,r+8),r+=16),r+=2;let o=e.length+s;const l=J(e,r);r+=2;for(let n=0;n<l;n++){let n=r;const a=Z(e,n);n+=4;const s=2147483647&a;if(1==(2147483648&a)>>>31)return D.warn("SIDX has hierarchical references (not supported)"),null;const l=Z(e,n);n+=4,t.push({referenceSize:s,subsegmentDuration:l,info:{duration:l/i,start:o,end:o+s-1}}),o+=s,n+=4,r=n}return{earliestPresentationTime:a,timescale:i,version:n,referencesCount:l,references:t}}function ie(e){const t=[],n=ne(e,["moov","trak"]);for(let e=0;e<n.length;e++){const r=n[e],i=ne(r,["tkhd"])[0];if(i){let e=i[0];const n=Z(i,0===e?12:20),a=ne(r,["mdia","mdhd"])[0];if(a){e=a[0];const i=Z(a,0===e?12:20),s=ne(r,["mdia","hdlr"])[0];if(s){const e=Q(s.subarray(8,12)),a={soun:j,vide:G}[e],o=ae(ne(r,["mdia","minf","stbl","stsd"])[0]);a?(t[n]={timescale:i,type:a,stsd:o},t[a]=S({timescale:i,id:n},o)):t[n]={timescale:i,type:e,stsd:o}}}}}return ne(e,["moov","mvex","trex"]).forEach((e=>{const n=Z(e,4),r=t[n];r&&(r.default={duration:Z(e,12),flags:Z(e,20)})})),t}function ae(e){const t=e.subarray(8),n=t.subarray(86),r=Q(t.subarray(4,8));let i,a=r;const s="enca"===r||"encv"===r;if(s){const e=ne(t,[r])[0];ne(e.subarray("enca"===r?28:78),["sinf"]).forEach((e=>{const t=ne(e,["schm"])[0];if(t){const n=Q(t.subarray(4,8));if("cbcs"===n||"cenc"===n){const t=ne(e,["frma"])[0];t&&(a=Q(t))}}}))}const o=a;switch(a){case"avc1":case"avc2":case"avc3":case"avc4":{const e=ne(n,["avcC"])[0];e&&e.length>3&&(a+="."+le(e[1])+le(e[2])+le(e[3]),i=se("avc1"===o?"dva1":"dvav",n));break}case"mp4a":{const e=ne(t,[r])[0],n=ne(e.subarray(28),["esds"])[0];if(n&&n.length>7){let e=4;if(3!==n[e++])break;e=oe(n,e),e+=2;const t=n[e++];if(128&t&&(e+=2),64&t&&(e+=n[e++]),4!==n[e++])break;e=oe(n,e);const r=n[e++];if(64!==r)break;if(a+="."+le(r),e+=12,5!==n[e++])break;e=oe(n,e);const i=n[e++];let s=(248&i)>>3;31===s&&(s+=1+((7&i)<<3)+((224&n[e])>>5)),a+="."+s}break}case"hvc1":case"hev1":{const e=ne(n,["hvcC"])[0];if(e&&e.length>12){const t=e[1],n=["","A","B","C"][t>>6],r=31&t,i=Z(e,2),s=(32&t)>>5?"H":"L",o=e[12],l=e.subarray(6,12);a+="."+n+r,a+="."+function(e){let t=0;for(let n=0;n<32;n++)t|=(e>>n&1)<<31-n;return t>>>0}(i).toString(16).toUpperCase(),a+="."+s+o;let u="";for(let e=l.length;e--;){const t=l[e];(t||u)&&(u="."+t.toString(16).toUpperCase()+u)}a+=u}i=se("hev1"==o?"dvhe":"dvh1",n);break}case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":a=se(a,n)||a;break;case"vp09":{const e=ne(n,["vpcC"])[0];if(e&&e.length>6){const t=e[4],n=e[5],r=e[6]>>4&15;a+="."+ue(t)+"."+ue(n)+"."+ue(r)}break}case"av01":{const e=ne(n,["av1C"])[0];if(e&&e.length>2){const t=e[1]>>>5,r=31&e[1],s=e[2]>>>7?"H":"M",o=(64&e[2])>>6,l=(32&e[2])>>5,u=2===t&&o?l?12:10:o?10:8,c=(16&e[2])>>4,d=(8&e[2])>>3,f=(4&e[2])>>2,h=3&e[2],g=1,p=1,m=1,v=0;a+="."+t+"."+ue(r)+s+"."+ue(u)+"."+c+"."+d+f+h+"."+ue(g)+"."+ue(p)+"."+ue(m)+"."+v,i=se("dav1",n)}break}}return{codec:a,encrypted:s,supplemental:i}}function se(e,t){const n=ne(t,["dvvC"]),r=n.length?n[0]:ne(t,["dvcC"])[0];if(r){const t=r[2]>>1&127,n=r[2]<<5&32|r[3]>>3&31;return e+"."+ue(t)+"."+ue(n)}}function oe(e,t){const n=t+5;for(;128&e[t++]&&t<n;);return t}function le(e){return("0"+e.toString(16).toUpperCase()).slice(-2)}function ue(e){return(e<10?"0":"")+e}function ce(e,t){ne(e,["moov","trak"]).forEach((e=>{const n=ne(e,["mdia","minf","stbl","stsd"])[0];if(!n)return;const r=n.subarray(8);let i=ne(r,["enca"]);const a=i.length>0;a||(i=ne(r,["encv"])),i.forEach((e=>{ne(a?e.subarray(28):e.subarray(78),["sinf"]).forEach((e=>{const n=de(e);n&&t(n,a)}))}))}))}function de(e){const t=ne(e,["schm"])[0];if(t){const n=Q(t.subarray(4,8));if("cbcs"===n||"cenc"===n){const t=ne(e,["schi","tenc"])[0];if(t)return t}}}function fe(e,t){const n=new Uint8Array(e.length+t.length);return n.set(e),n.set(t,e.length),n}function he(e,t){const n=[],r=t.samples,i=t.timescale,a=t.id;let s=!1;return ne(r,["moof"]).map((o=>{const l=o.byteOffset-8;ne(o,["traf"]).map((o=>{const u=ne(o,["tfdt"]).map((e=>{const t=e[0];let n=Z(e,4);return 1===t&&(n*=Math.pow(2,32),n+=Z(e,8)),n/i}))[0];return void 0!==u&&(e=u),ne(o,["tfhd"]).map((u=>{const c=Z(u,4),d=16777215&Z(u,0);let f=0;const h=0!=(16&d);let g=0;const p=0!=(32&d);let m=8;c===a&&(0!=(1&d)&&(m+=8),0!=(2&d)&&(m+=4),0!=(8&d)&&(f=Z(u,m),m+=4),h&&(g=Z(u,m),m+=4),p&&(m+=4),"video"===t.type&&(s=ge(t.codec)),ne(o,["trun"]).map((a=>{const o=a[0],u=16777215&Z(a,0),c=0!=(1&u);let d=0;const h=0!=(4&u),p=0!=(256&u);let m=0;const v=0!=(512&u);let y=0;const E=0!=(1024&u),T=0!=(2048&u);let b=0;const S=Z(a,4);let _=8;c&&(d=Z(a,_),_+=4),h&&(_+=4);let A=d+l;for(let l=0;l<S;l++){if(p?(m=Z(a,_),_+=4):m=f,v?(y=Z(a,_),_+=4):y=g,E&&(_+=4),T&&(b=0===o?Z(a,_):te(a,_),_+=4),t.type===G){let t=0;for(;t<y;){const a=Z(r,A);A+=4,pe(s,r[A])&&me(r.subarray(A,A+a),s?2:1,e+b/i,n),A+=a,t+=a+4}}e+=m/i}})))}))}))})),n}function ge(e){if(!e)return!1;const t=e.substring(0,4);return"hvc1"===t||"hev1"===t||"dvh1"===t||"dvhe"===t}function pe(e,t){if(e){const e=t>>1&63;return 39===e||40===e}return 6==(31&t)}function me(e,t,n,r){const i=ve(e);let a=0;a+=t;let s=0,o=0,l=0;for(;a<i.length;){s=0;do{if(a>=i.length)break;l=i[a++],s+=l}while(255===l);o=0;do{if(a>=i.length)break;l=i[a++],o+=l}while(255===l);const e=i.length-a;let t=a;if(o<e)a+=o;else if(o>e){D.error(`Malformed SEI payload. ${o} is too small, only ${e} bytes left to parse.`);break}if(4===s){if(181===i[t++]){const e=J(i,t);if(t+=2,49===e){const e=Z(i,t);if(t+=4,1195456820===e){const e=i[t++];if(3===e){const a=i[t++],o=31&a,l=64&a,u=l?2+3*o:0,c=new Uint8Array(u);if(l){c[0]=a;for(let e=1;e<u;e++)c[e]=i[t++]}r.push({type:e,payloadType:s,pts:n,bytes:c})}}}}}else if(5===s&&o>16){const e=[];for(let n=0;n<16;n++){const r=i[t++].toString(16);e.push(1==r.length?"0"+r:r),3!==n&&5!==n&&7!==n&&9!==n||e.push("-")}const a=o-16,l=new Uint8Array(a);for(let e=0;e<a;e++)l[e]=i[t++];r.push({payloadType:s,pts:n,uuid:e.join(""),userData:P(l),userDataBytes:l})}}}function ve(e){const t=e.byteLength,n=[];let r=1;for(;r<t-2;)0===e[r]&&0===e[r+1]&&3===e[r+2]?(n.push(r+2),r+=2):r++;if(0===n.length)return e;const i=t-n.length,a=new Uint8Array(i);let s=0;for(r=0;r<i;s++,r++)s===n[0]&&(s++,n.shift()),a[r]=e[s];return a}function ye(e){const t=e.getUint32(0),n=e.byteOffset,r=e.byteLength;if(r<t)return{offset:n,size:r};if(1886614376!==e.getUint32(4))return{offset:n,size:t};const i=e.getUint32(8)>>>24;if(0!==i&&1!==i)return{offset:n,size:t};const a=e.buffer,s=M(new Uint8Array(a,n+12,16));let o=null,l=null,u=0;if(0===i)u=28;else{const i=e.getUint32(28);if(!i||r<32+16*i)return{offset:n,size:t};o=[];for(let e=0;e<i;e++)o.push(new Uint8Array(a,n+32+16*e,16));u=32+16*i}if(!u)return{offset:n,size:t};const c=e.getUint32(u);return t-32<c?{offset:n,size:t}:(l=new Uint8Array(a,n+u+4,c),{version:i,systemId:s,kids:o,data:l,offset:n,size:t})}const Ee=()=>/\(Windows.+Firefox\//i.test(navigator.userAgent),Te={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 be(e,t){const n=Te[t];return!!n&&!!n[e.slice(0,4)]}function Se(e,t,n=!0){return!e.split(",").some((e=>!_e(e,t,n)))}function _e(e,t,n=!0){var r;const i=L(n);return null!=(r=null==i?void 0:i.isTypeSupported(Ae(e,t)))&&r}function Ae(e,t){return`${t}/mp4;codecs=${e}`}function Ie(e){if(e){const t=e.substring(0,4);return Te.video[t]}return 2}function Re(e){const t=Ee();return e.split(",").reduce(((e,n)=>{const r=t&&ge(n)?9:Te.video[n];return r?(2*r+e)/(e?3:2):(Te.audio[n]+e)/(e?2:1)}),0)}const we={},Ce=/flac|opus|mp4a\.40\.34/i;function De(e,t=!0){return e.replace(Ce,(e=>function(e,t=!0){if(we[e])return we[e];const n={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[e];for(let i=0;i<n.length;i++){var r;if(_e(n[i],"audio",t))return we[e]=n[i],n[i];if("mp3"===n[i]&&null!=(r=L(t))&&r.isTypeSupported("audio/mpeg"))return""}return e}(e.toLowerCase(),t)))}function Le(e,t){if(e&&(e.length>4||-1!==["ac-3","ec-3","alac","fLaC","Opus"].indexOf(e))&&(ke(e,"audio")||ke(e,"video")))return e;if(t){const n=t.split(",");if(n.length>1){if(e)for(let t=n.length;t--;)if(n[t].substring(0,4)===e.substring(0,4))return n[t];return n[0]}}return t||e}function ke(e,t){return be(e,t)&&_e(e,t)}function Pe(e){if(e.startsWith("av01.")){const t=e.split("."),n=["0","111","01","01","01","0"];for(let e=t.length;e>4&&e<10;e++)t[e]=n[e-4];return t.join(".")}return e}function Me(e){const t=L(e)||{isTypeSupported:()=>!1};return{mpeg:t.isTypeSupported("audio/mpeg"),mp3:t.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:t.isTypeSupported('audio/mp4; codecs="ac-3"')}}function Ne(e){return e.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}const xe={supported:!1,smooth:!1,powerEfficient:!1},Oe={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]};function Fe(e,t){return{supported:!1,configurations:t,decodingInfoResults:[xe],error:e}}function Ue(e,t,n,r,a,s){const o=e.videoCodec,l=e.audioCodec?e.audioGroups:null,u=null==s?void 0:s.audioCodec,c=null==s?void 0:s.channels,d=c?parseInt(c):u?1/0:2;let f=null;if(null!=l&&l.length)try{f=1===l.length&&l[0]?t.groups[l[0]].channels:l.reduce(((e,n)=>{if(n){const r=t.groups[n];if(!r)throw new Error(`Audio track group ${n} not found`);Object.keys(r.channels).forEach((t=>{e[t]=(e[t]||0)+r.channels[t]}))}return e}),{2:0})}catch(e){return!0}return void 0!==o&&(o.split(",").some((e=>ge(e)))||e.width>1920&&e.height>1088||e.height>1920&&e.width>1088||e.frameRate>Math.max(r,30)||"SDR"!==e.videoRange&&e.videoRange!==n||e.bitrate>Math.max(a,8e6))||!!f&&i(d)&&Object.keys(f).some((e=>parseInt(e)>d))}function Be(e,t,n,r={}){const i=e.videoCodec;if(!i&&!e.audioCodec||!n)return Promise.resolve(Oe);const a=[],s=function(e){var t;const n=null==(t=e.videoCodec)?void 0:t.split(","),r=Ge(e),i=e.width||640,a=e.height||480,s=e.frameRate||30,o=e.videoRange.toLowerCase();return n?n.map((e=>{const t={contentType:Ae(Pe(e),"video"),width:i,height:a,bitrate:r,framerate:s};return"sdr"!==o&&(t.transferFunction=o),t})):[]}(e),o=s.length,l=function(e,t,n){var r;const i=null==(r=e.audioCodec)?void 0:r.split(","),a=Ge(e);return i&&e.audioGroups?e.audioGroups.reduce(((e,r)=>{var s;const o=r?null==(s=t.groups[r])?void 0:s.tracks:null;return o?o.reduce(((e,t)=>{if(t.groupId===r){const r=parseFloat(t.channels||"");i.forEach((t=>{const i={contentType:Ae(t,"audio"),bitrate:n?je(t,a):a};r&&(i.channels=""+r),e.push(i)}))}return e}),e):e}),[]):[]}(e,t,o>0),u=l.length;for(let e=o||1*u||1;e--;){const t={type:"media-source"};if(o&&(t.video=s[e%o]),u){t.audio=l[e%u];const n=t.audio.bitrate;t.video&&n&&(t.video.bitrate-=n)}a.push(t)}if(i){const e=navigator.userAgent;if(i.split(",").some((e=>ge(e)))&&Ee())return Promise.resolve(Fe(new Error(`Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent string: (${e})`),a))}return Promise.all(a.map((e=>{const t=function(e){let t="";const{audio:n,video:r}=e;return r&&(t+=`${Ne(r.contentType)}_r${r.height}x${r.width}f${Math.ceil(r.framerate)}${r.transferFunction||"sd"}_${Math.ceil(r.bitrate/1e5)}`),n&&(t+=`${r?"_":""}${Ne(n.contentType)}_c${n.channels}`),t}(e);return r[t]||(r[t]=n.decodingInfo(e))}))).then((e=>({supported:!e.some((e=>!e.supported)),configurations:a,decodingInfoResults:e}))).catch((e=>({supported:!1,configurations:a,decodingInfoResults:[],error:e})))}function je(e,t){if(t<=1)return 1;let n=128e3;return"ec-3"===e?n=768e3:"ac-3"===e&&(n=64e4),Math.min(t/2,n)}function Ge(e){return 1e3*Math.ceil(Math.max(.9*e.bitrate,e.averageBitrate)/1e3)||1}const He=["NONE","TYPE-0","TYPE-1",null],Ve=["SDR","PQ","HLG"];function Ke(e){const{canSkipUntil:t,canSkipDateRanges:n,age:r}=e;return t&&r<t/2?n?"v2":"YES":""}class qe{constructor(e,t,n){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=n}addDirectives(e){const t=new self.URL(e);return void 0!==this.msn&&t.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href}}class Ye{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((e=>!!e)).map((e=>e.substring(0,4))).join(","),"supplemental"in e){var t;this.supplemental=e.supplemental;const n=null==(t=e.supplemental)?void 0:t.videoCodec;n&&n!==e.videoCodec&&(this.codecSet+=`,${n.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 $e(this._audioGroups,e)}hasSubtitleGroup(e){return $e(this._subtitleGroups,e)}get audioGroups(){return this._audioGroups}get subtitleGroups(){return this._subtitleGroups}addGroupId(e,t){if(t)if("audio"===e){let e=this._audioGroups;e||(e=this._audioGroups=[]),-1===e.indexOf(t)&&e.push(t)}else if("text"===e){let e=this._subtitleGroups;e||(e=this._subtitleGroups=[]),-1===e.indexOf(t)&&e.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 null==(e=this.audioGroups)?void 0:e[0]}get textGroupId(){var e;return null==(e=this.subtitleGroups)?void 0:e[0]}addFallback(){}}function $e(e,t){return!(!t||!e)&&-1!==e.indexOf(t)}const We=(e,t)=>JSON.stringify(e,(e=>{const t=new WeakSet;return(n,r)=>{if(e&&(r=e(n,r)),"object"==typeof r&&null!==r){if(t.has(r))return;t.add(r)}return r}})(t));function ze(e,t){D.log(`[abr] start candidates with "${e}" ignored because ${t}`)}function Xe(e){return e.reduce(((e,t)=>{let n=e.groups[t.groupId];n||(n=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),n.tracks.push(t);const r=t.channels||"2";return n.channels[r]=(n.channels[r]||0)+1,n.hasDefault=n.hasDefault||t.default,n.hasAutoSelect=n.hasAutoSelect||t.autoselect,n.hasDefault&&(e.hasDefaultAudio=!0),n.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e}),{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function Qe(e){if(!e)return e;const{lang:t,assocLang:n,characteristics:r,channels:i,audioCodec:a}=e;return{lang:t,assocLang:n,characteristics:r,channels:i,audioCodec:a}}function Je(e,t,n){if("attrs"in e){const n=t.indexOf(e);if(-1!==n)return n}for(let r=0;r<t.length;r++)if(Ze(e,t[r],n))return r;return-1}function Ze(e,t,n){const{groupId:r,name:i,lang:a,assocLang:s,default:o}=e,l=e.forced;return(void 0===r||t.groupId===r)&&(void 0===i||t.name===i)&&(void 0===a||function(e,t="--"){return e.length===t.length?e===t:e.startsWith(t)||t.startsWith(e)}(a,t.lang))&&(void 0===a||t.assocLang===s)&&(void 0===o||t.default===o)&&(void 0===l||t.forced===l)&&(!("characteristics"in e)||function(e,t=""){const n=e.split(","),r=t.split(",");return n.length===r.length&&!n.some((e=>-1===r.indexOf(e)))}(e.characteristics||"",t.characteristics))&&(void 0===n||n(e,t))}function et(e,t){const{audioCodec:n,channels:r}=e;return!(void 0!==n&&(t.audioCodec||"").substring(0,4)!==n.substring(0,4)||void 0!==r&&r!==(t.channels||"2"))}function tt(e,t,n){for(let r=t;r>-1;r--)if(n(e[r]))return r;for(let r=t+1;r<e.length;r++)if(n(e[r]))return r;return-1}function nt(e,t){var n;return!!e&&e!==(null==(n=t.loadLevelObj)?void 0:n.uri)}const rt=function(e,t){let n=0,r=e.length-1,i=null,a=null;for(;n<=r;){i=(n+r)/2|0,a=e[i];const s=t(a);if(s>0)n=i+1;else{if(!(s<0))return a;r=i-1}}return null};function it(e,t,n=0,r=0,i=.005){let a=null;if(e){a=t[1+e.sn-t[0].sn]||null;const r=e.endDTS-n;r>0&&r<15e-7&&(n+=15e-7),a&&e.level!==a.level&&a.end<=e.end&&(a=t[2+e.sn-t[0].sn]||null)}else 0===n&&0===t[0].start&&(a=t[0]);if(a&&((!e||e.level===a.level)&&0===at(n,r,a)||function(e,t,n){if(t&&0===t.start&&t.level<e.level&&(t.endPTS||0)>0){const r=t.tagList.reduce(((e,t)=>("INF"===t[0]&&(e+=parseFloat(t[1])),e)),n);return e.start<=r}return!1}(a,e,Math.min(i,r))))return a;const s=rt(t,at.bind(null,n,r));return!s||s===e&&a?a:s}function at(e=0,t=0,n){if(n.start<=e&&n.start+n.duration>e)return 0;const r=Math.min(t,n.duration+(n.deltaPTS?n.deltaPTS:0));return n.start+n.duration-r<=e?1:n.start-r>e&&n.start?-1:0}function st(e,t,n){const r=1e3*Math.min(t,n.duration+(n.deltaPTS?n.deltaPTS:0));return(n.endProgramDateTime||0)-r>e}function ot(e,t,n){if(e&&e.startCC<=t&&e.endCC>=t){let r=e.fragments;const{fragmentHint:i}=e;let a;return i&&(r=r.concat(i)),rt(r,(e=>e.cc<t?1:e.cc>t?-1:(a=e,e.end<=n?1:e.start>n?-1:0))),a||null}return null}function lt(e){switch(e.details){case l.FRAG_LOAD_TIMEOUT:case l.KEY_LOAD_TIMEOUT:case l.LEVEL_LOAD_TIMEOUT:case l.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function ut(e){return e.details.startsWith("key")}function ct(e){return ut(e)&&!!e.frag&&!e.frag.decryptdata}function dt(e,t){const n=lt(t);return e.default[(n?"timeout":"error")+"Retry"]}function ft(e,t){const n="linear"===e.backoff?1:Math.pow(2,t);return Math.min(n*e.retryDelayMs,e.maxRetryDelayMs)}function ht(e){return S(S({},e),{errorRetry:null,timeoutRetry:null})}function gt(e,t,n,r){if(!e)return!1;const i=null==r?void 0:r.code,a=t<e.maxNumRetry&&(function(e){return pt(e)||!!e&&(e<400||e>499)}(i)||!!n);return e.shouldRetry?e.shouldRetry(e,t,n,r,a):a}function pt(e){return 0===e&&!1===navigator.onLine}function mt(e){const t={action:0,flags:0};return e&&(t.resolved=!0),t}var vt="NOT_LOADED",yt="APPENDING",Et="PARTIAL",Tt="OK";class bt{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(u.MANIFEST_LOADING,this.onManifestLoading,this),e.on(u.BUFFER_APPENDED,this.onBufferAppended,this),e.on(u.FRAG_BUFFERED,this.onFragBuffered,this),e.on(u.FRAG_LOADED,this.onFragLoaded,this))}_unregisterListeners(){const{hls:e}=this;e&&(e.off(u.MANIFEST_LOADING,this.onManifestLoading,this),e.off(u.BUFFER_APPENDED,this.onBufferAppended,this),e.off(u.FRAG_BUFFERED,this.onFragBuffered,this),e.off(u.FRAG_LOADED,this.onFragLoaded,this))}destroy(){this._unregisterListeners(),this.hls=this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){const n=this.activePartLists[t];if(n)for(let t=n.length;t--;){const r=n[t];if(!r)break;if(r.start<=e&&e<=r.end&&r.loaded)return r}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){return this.getFragAtPos(e,t,!0)}getFragAtPos(e,t,n){const{fragments:r}=this,i=Object.keys(r);for(let a=i.length;a--;){const s=r[i[a]];if((null==s?void 0:s.body.type)===t&&(!n||s.buffered)){const t=s.body;if(t.start<=e&&e<=t.end)return t}}return null}detectEvictedFragments(e,t,n,r,i){this.timeRanges&&(this.timeRanges[e]=t);const a=(null==r?void 0:r.fragment.sn)||-1;Object.keys(this.fragments).forEach((r=>{const s=this.fragments[r];if(!s)return;if(a>=s.body.sn)return;if(!s.buffered&&(!s.loaded||i))return void(s.body.type===n&&this.removeFragment(s.body));const o=s.range[e];o&&(0!==o.time.length?o.time.some((e=>{const n=!this.isTimeBuffered(e.startPTS,e.endPTS,t);return n&&this.removeFragment(s.body),n})):this.removeFragment(s.body))}))}detectPartialFragments(e){const t=this.timeRanges;if(!t||"initSegment"===e.frag.sn)return;const n=e.frag,r=_t(n),i=this.fragments[r];if(!i||i.buffered&&n.gap)return;const a=!n.relurl;Object.keys(t).forEach((r=>{const s=n.elementaryStreams[r];if(!s)return;const o=t[r],l=a||!0===s.partial;i.range[r]=this.getBufferedTimes(n,e.part,l,o)})),i.loaded=null,Object.keys(i.range).length?(this.bufferedEnd(i,n),St(i)||this.removeParts(n.sn-1,n.type)):this.removeFragment(i.body)}bufferedEnd(e,t){e.buffered=!0,(e.body.endList=t.endList||e.body.endList)&&(this.endListFragments[e.body.type]=e)}removeParts(e,t){const n=this.activePartLists[t];n&&(this.activePartLists[t]=At(n,(t=>t.fragment.sn>=e)))}fragBuffered(e,t){const n=_t(e);let r=this.fragments[n];!r&&t&&(r=this.fragments[n]={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))}getBufferedTimes(e,t,n,r){const i={time:[],partial:n},a=e.start,s=e.end,o=e.minEndPTS||s,l=e.maxStartPTS||a;for(let e=0;e<r.length;e++){const t=r.start(e)-this.bufferPadding,n=r.end(e)+this.bufferPadding;if(l>=t&&o<=n){i.time.push({startPTS:Math.max(a,r.start(e)),endPTS:Math.min(s,r.end(e))});break}if(a<n&&s>t){const t=Math.max(a,r.start(e)),n=Math.min(s,r.end(e));n>t&&(i.partial=!0,i.time.push({startPTS:t,endPTS:n}))}else if(s<=t)break}return i}getPartialFragment(e){let t,n,r,i=null,a=0;const{bufferPadding:s,fragments:o}=this;return Object.keys(o).forEach((l=>{const u=o[l];u&&St(u)&&(n=u.body.start-s,r=u.body.end+s,e>=n&&e<=r&&(t=Math.min(e-n,r-e),a<=t&&(i=u.body,a=t)))})),i}isEndListAppended(e){const t=this.endListFragments[e];return void 0!==t&&(t.buffered||St(t))}getState(e){const t=_t(e),n=this.fragments[t];return n?n.buffered?St(n)?Et:Tt:yt:vt}isTimeBuffered(e,t,n){let r,i;for(let a=0;a<n.length;a++){if(r=n.start(a)-this.bufferPadding,i=n.end(a)+this.bufferPadding,e>=r&&t<=i)return!0;if(t<=r)return!1}return!1}onManifestLoading(){this.removeAllFragments()}onFragLoaded(e,t){if("initSegment"===t.frag.sn||t.frag.bitrateTest)return;const n=t.frag,r=t.part?null:t,i=_t(n);this.fragments[i]={body:n,appendedPTS:null,loaded:r,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){const{frag:n,part:r,timeRanges:i,type:a}=t;if("initSegment"===n.sn)return;const s=n.type;if(r){let e=this.activePartLists[s];e||(this.activePartLists[s]=e=[]),e.push(r)}this.timeRanges=i;const o=i[a];this.detectEvictedFragments(a,o,s,r)}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){const t=_t(e);return!!this.fragments[t]}hasFragments(e){const{fragments:t}=this,n=Object.keys(t);if(!e)return n.length>0;for(let r=n.length;r--;){const i=t[n[r]];if((null==i?void 0:i.body.type)===e)return!0}return!1}hasParts(e){var t;return!(null==(t=this.activePartLists[e])||!t.length)}removeFragmentsInRange(e,t,n,r,i){r&&!this.hasGaps||Object.keys(this.fragments).forEach((a=>{const s=this.fragments[a];if(!s)return;const o=s.body;o.type!==n||r&&!o.gap||o.start<t&&o.end>e&&(s.buffered||i)&&this.removeFragment(o)}))}removeFragment(e){const t=_t(e);e.clearElementaryStreamInfo();const n=this.activePartLists[e.type];if(n){const t=e.sn;this.activePartLists[e.type]=At(n,(e=>e.fragment.sn!==t))}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=null==(e=this.hls)||null==(e=e.latestLevelDetails)?void 0:e.partList;t&&t.forEach((e=>e.clearElementaryStreamInfo()))}}function St(e){var t,n,r;return e.buffered&&!!(e.body.gap||null!=(t=e.range.video)&&t.partial||null!=(n=e.range.audio)&&n.partial||null!=(r=e.range.audiovideo)&&r.partial)}function _t(e){return`${e.type}_${e.level}_${e.sn}`}function At(e,t){return e.filter((e=>{const n=t(e);return n||e.clearElementaryStreamInfo(),n}))}class It{constructor(e,t,n){this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=e,this.aesIV=t,this.aesMode=n}decrypt(e,t){switch(this.aesMode){case 0:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e);case 1:return this.subtle.decrypt({name:"AES-CTR",counter:this.aesIV,length:64},t,e);default:throw new Error(`[AESCrypto] invalid aes mode ${this.aesMode}`)}}}class Rt{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),n=new Uint32Array(4);for(let e=0;e<4;e++)n[e]=t.getUint32(4*e);return n}initTable(){const e=this.sBox,t=this.invSBox,n=this.subMix,r=n[0],i=n[1],a=n[2],s=n[3],o=this.invSubMix,l=o[0],u=o[1],c=o[2],d=o[3],f=new Uint32Array(256);let h=0,g=0,p=0;for(p=0;p<256;p++)f[p]=p<128?p<<1:p<<1^283;for(p=0;p<256;p++){let n=g^g<<1^g<<2^g<<3^g<<4;n=n>>>8^255&n^99,e[h]=n,t[n]=h;const o=f[h],p=f[o],m=f[p];let v=257*f[n]^16843008*n;r[h]=v<<24|v>>>8,i[h]=v<<16|v>>>16,a[h]=v<<8|v>>>24,s[h]=v,v=16843009*m^65537*p^257*o^16843008*h,l[n]=v<<24|v>>>8,u[n]=v<<16|v>>>16,c[n]=v<<8|v>>>24,d[n]=v,h?(h=o^f[f[f[m^o]]],g^=f[f[g]]):h=g=1}}expandKey(e){const t=this.uint8ArrayToUint32Array_(e);let n=!0,r=0;for(;r<t.length&&n;)n=t[r]===this.key[r],r++;if(n)return;this.key=t;const i=this.keySize=t.length;if(4!==i&&6!==i&&8!==i)throw new Error("Invalid aes key size="+i);const a=this.ksRows=4*(i+6+1);let s,o;const l=this.keySchedule=new Uint32Array(a),u=this.invKeySchedule=new Uint32Array(a),c=this.sBox,d=this.rcon,f=this.invSubMix,h=f[0],g=f[1],p=f[2],m=f[3];let v,y;for(s=0;s<a;s++)s<i?v=l[s]=t[s]:(y=v,s%i==0?(y=y<<8|y>>>24,y=c[y>>>24]<<24|c[y>>>16&255]<<16|c[y>>>8&255]<<8|c[255&y],y^=d[s/i|0]<<24):i>6&&s%i==4&&(y=c[y>>>24]<<24|c[y>>>16&255]<<16|c[y>>>8&255]<<8|c[255&y]),l[s]=v=(l[s-i]^y)>>>0);for(o=0;o<a;o++)s=a-o,y=3&o?l[s]:l[s-4],u[o]=o<4||s<=4?y:h[c[y>>>24]]^g[c[y>>>16&255]]^p[c[y>>>8&255]]^m[c[255&y]],u[o]=u[o]>>>0}networkToHostOrderSwap(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24}decrypt(e,t,n){const r=this.keySize+6,i=this.invKeySchedule,a=this.invSBox,s=this.invSubMix,o=s[0],l=s[1],u=s[2],c=s[3],d=this.uint8ArrayToUint32Array_(n);let f=d[0],h=d[1],g=d[2],p=d[3];const m=new Int32Array(e),v=new Int32Array(m.length);let y,E,T,b,S,_,A,I,R,w,C,D,L,k;const P=this.networkToHostOrderSwap;for(;t<m.length;){for(R=P(m[t]),w=P(m[t+1]),C=P(m[t+2]),D=P(m[t+3]),S=R^i[0],_=D^i[1],A=C^i[2],I=w^i[3],L=4,k=1;k<r;k++)y=o[S>>>24]^l[_>>16&255]^u[A>>8&255]^c[255&I]^i[L],E=o[_>>>24]^l[A>>16&255]^u[I>>8&255]^c[255&S]^i[L+1],T=o[A>>>24]^l[I>>16&255]^u[S>>8&255]^c[255&_]^i[L+2],b=o[I>>>24]^l[S>>16&255]^u[_>>8&255]^c[255&A]^i[L+3],S=y,_=E,A=T,I=b,L+=4;y=a[S>>>24]<<24^a[_>>16&255]<<16^a[A>>8&255]<<8^a[255&I]^i[L],E=a[_>>>24]<<24^a[A>>16&255]<<16^a[I>>8&255]<<8^a[255&S]^i[L+1],T=a[A>>>24]<<24^a[I>>16&255]<<16^a[S>>8&255]<<8^a[255&_]^i[L+2],b=a[I>>>24]<<24^a[S>>16&255]<<16^a[_>>8&255]<<8^a[255&A]^i[L+3],v[t]=P(y^f),v[t+1]=P(b^h),v[t+2]=P(T^g),v[t+3]=P(E^p),f=R,h=w,g=C,p=D,t+=4}return v.buffer}}class wt{constructor(e,t,n){this.subtle=void 0,this.key=void 0,this.aesMode=void 0,this.subtle=e,this.key=t,this.aesMode=n}expandKey(){const e=function(e){switch(e){case 0:return"AES-CBC";case 1:return"AES-CTR";default:throw new Error(`[FastAESKey] invalid aes mode ${e}`)}}(this.aesMode);return this.subtle.importKey("raw",this.key,{name:e},!1,["encrypt","decrypt"])}}class Ct{constructor(e,{removePKCS7Padding:t=!0}={}){if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.enableSoftwareAES=void 0,this.enableSoftwareAES=e.enableSoftwareAES,this.removePKCS7Padding=t,t)try{const e=self.crypto;e&&(this.subtle=e.subtle||e.webkitSubtle)}catch(e){}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 n=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?function(e){const t=e.byteLength,n=t&&new DataView(e.buffer).getUint8(t-1);return n?e.slice(0,t-n):e}(n):n}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,t,n,r){return this.useSoftware?new Promise(((i,a)=>{const s=ArrayBuffer.isView(e)?e:new Uint8Array(e);this.softwareDecrypt(s,t,n,r);const o=this.flush();o?i(o.buffer):a(new Error("[softwareDecrypt] Failed to decrypt data"))})):this.webCryptoDecrypt(new Uint8Array(e),t,n,r)}softwareDecrypt(e,t,n,r){const{currentIV:i,currentResult:a,remainderData:s}=this;if(0!==r||16!==t.byteLength)return D.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),s&&(e=fe(s,e),this.remainderData=null);const o=this.getValidChunk(e);if(!o.length)return null;i&&(n=i);let l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new Rt),l.expandKey(t);const u=a;return this.currentResult=l.decrypt(o.buffer,0,n),this.currentIV=o.slice(-16).buffer,u||null}webCryptoDecrypt(e,t,n,r){if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,n,r));this.key=t,this.fastAesKey=new wt(this.subtle,t,r)}return this.fastAesKey.expandKey().then((t=>this.subtle?(this.logOnce("WebCrypto AES decrypt"),new It(this.subtle,new Uint8Array(n),r).decrypt(e.buffer,