@eyevinn/web-player
Version:
[](https://www.jsdelivr.com/package/npm/@eyevinn/web-player)
2 lines • 1.74 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={989:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>a});var r=n(671),i=n(357);const a=function(e){function t(t){var n;return(n=e.call(this,t)||this).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.b)(t,[{key:"isLive",get:function(){return this.mediaPlayer.isDynamic()}}]),t}(r.B)},30:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>ta});var r=n(671);function i(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var a={exports:{}};!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}(a);var s=a.exports;function o(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 l(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach((function(t){u(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function u(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===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:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(){return c=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},c.apply(this,arguments)}const d=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)};let f=function(e){return e.MEDIA_ATTACHING="hlsMediaAttaching",e.MEDIA_ATTACHED="hlsMediaAttached",e.MEDIA_DETACHING="hlsMediaDetaching",e.MEDIA_DETACHED="hlsMediaDetached",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.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.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_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.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}({}),h=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}({}),g=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.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.INTERNAL_EXCEPTION="internalException",e.INTERNAL_ABORTED="aborted",e.UNKNOWN="unknown",e}({});const p=function(){},m={trace:p,debug:p,log:p,warn:p,info:p,error:p};let v=m;const y=v,E=/^(\d+)x(\d+)$/,T=/(.+?)=(".*?"|.*?)(?:,|$)/g;class b{constructor(e){"string"==typeof e&&(e=b.parseAttrList(e));for(const t in e)e.hasOwnProperty(t)&&("X-"===t.substring(0,2)&&(this.clientAttrs=this.clientAttrs||[],this.clientAttrs.push(t)),this[t]=e[t])}decimalInteger(e){const t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}hexadecimalInteger(e){if(this[e]){let t=(this[e]||"0x").slice(2);t=(1&t.length?"0":"")+t;const n=new Uint8Array(t.length/2);for(let e=0;e<t.length/2;e++)n[e]=parseInt(t.slice(2*e,2*e+2),16);return n}return null}hexadecimalIntegerAsNumber(e){const t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,t){const n=this[e];return n?parseFloat(n):t}enumeratedString(e){return this[e]}bool(e){return"YES"===this[e]}decimalResolution(e){const t=E.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e){let t;const n={};for(T.lastIndex=0;null!==(t=T.exec(e));){let e=t[2];0===e.indexOf('"')&&e.lastIndexOf('"')===e.length-1&&(e=e.slice(1,-1)),n[t[1].trim()]=e}return n}}function S(e){return"SCTE35-OUT"===e||"SCTE35-IN"===e}class _{constructor(e,t){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,t){const n=t.attr;for(const t in n)if(Object.prototype.hasOwnProperty.call(e,t)&&e[t]!==n[t]){y.warn(`DATERANGE tag attribute: "${t}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=t;break}e=c(new b({}),n,e)}if(this.attr=e,this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){const e=new Date(this.attr["END-DATE"]);d(e.getTime())&&(this._endDate=e)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get startDate(){return this._startDate}get endDate(){if(this._endDate)return this._endDate;const e=this.duration;return null!==e?new Date(this._startDate.getTime()+1e3*e):null}get duration(){if("DURATION"in this.attr){const e=this.attr.decimalFloatingPoint("DURATION");if(d(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isValid(){return!!this.id&&!this._badValueForSameId&&d(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)}}class A{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 w="audio",R="video",I="audiovideo";class C{constructor(e){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[w]:null,[R]:null,[I]:null},this.baseurl=e}setByteRange(e,t){const n=e.split("@",2),r=[];1===n.length?r[0]=t?t.byteRangeEndOffset:0:r[0]=parseInt(n[1]),r[1]=parseInt(n[0])+r[0],this._byteRange=r}get byteRange(){return this._byteRange?this._byteRange:[]}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=s.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}}class D extends C{constructor(e,t){super(t),this._decryptdata=null,this.rawProgramDateTime=null,this.programDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.stats=new A,this.urlId=0,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.type=e}get decryptdata(){const{levelkeys:e}=this;if(!e&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){const e=this.levelkeys.identity;if(e)this._decryptdata=e.getDecryptData(this.sn);else{const e=Object.keys(this.levelkeys);if(1===e.length)return this._decryptdata=this.levelkeys[e[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(null===this.programDateTime)return null;if(!d(this.programDateTime))return null;const e=d(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){const e=Object.keys(this.levelkeys),t=e.length;if(t>1||1===t&&this.levelkeys[e[0]].encrypted)return!0}return!1}setKeyFormat(e){if(this.levelkeys){const t=this.levelkeys[e];t&&!this._decryptdata&&(this._decryptdata=t.getDecryptData(this.sn))}}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}}clearElementaryStreamInfo(){const{elementaryStreams:e}=this;e.audio=null,e.video=null,e.audiovideo=null}}class L extends C{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.stats=new A,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)}}class k{constructor(e){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}reloaded(e){if(!e)return this.advanced=!0,void(this.updated=!0);const t=this.lastPartSn-e.lastPartSn,n=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!n||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||0===t&&n>0,this.updated||this.advanced?this.misses=Math.floor(.6*e.misses):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay}get hasProgramDateTime(){return!!this.fragments.length&&d(this.fragments[this.fragments.length-1].programDateTime)}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||10}get drift(){const e=this.driftEndTime-this.driftStartTime;return e>0?1e3*(this.driftEnd-this.driftStart)/e:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){var e;return null!=(e=this.fragments)&&e.length?this.fragments[this.fragments.length-1].end:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].index:-1}get lastPartSn(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}function N(e){return Uint8Array.from(atob(e),(e=>e.charCodeAt(0)))}function M(e){return Uint8Array.from(unescape(encodeURIComponent(e)),(e=>e.charCodeAt(0)))}var x={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},O="org.w3.clearkey",P="com.apple.streamingkeydelivery",F="com.microsoft.playready",U="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function j(e){switch(e){case P:return x.FAIRPLAY;case F:return x.PLAYREADY;case U:return x.WIDEVINE;case O:return x.CLEARKEY}}var B="edef8ba979d64acea3c827dcd51d21ed";function G(e){switch(e){case x.FAIRPLAY:return P;case x.PLAYREADY:return F;case x.WIDEVINE:return U;case x.CLEARKEY:return O}}function H(e){const{drmSystems:t,widevineLicenseUrl:n}=e,r=t?[x.FAIRPLAY,x.WIDEVINE,x.PLAYREADY,x.CLEARKEY].filter((e=>!!t[e])):[];return!r[x.WIDEVINE]&&n&&r.push(x.WIDEVINE),r}const V="undefined"!=typeof self&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;function K(e,t,n){return Uint8Array.prototype.slice?e.slice(t,n):new Uint8Array(Array.prototype.slice.call(e,t,n))}const q=(e,t)=>t+10<=e.length&&73===e[t]&&68===e[t+1]&&51===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128,Y=(e,t)=>t+10<=e.length&&51===e[t]&&68===e[t+1]&&73===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128,z=(e,t)=>{const n=t;let r=0;for(;q(e,t);)r+=10,r+=W(e,t+6),Y(e,t+10)&&(r+=10),t+=r;if(r>0)return e.subarray(n,n+r)},W=(e,t)=>{let n=0;return n=(127&e[t])<<21,n|=(127&e[t+1])<<14,n|=(127&e[t+2])<<7,n|=127&e[t+3],n},$=(e,t)=>q(e,t)&&W(e,t+6)+10<=e.length-t,X=e=>e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info,Q=e=>{const t=String.fromCharCode(e[0],e[1],e[2],e[3]),n=W(e,4);return{type:t,size:n,data:e.subarray(10,10+n)}},J=e=>{let t=0;const n=[];for(;q(e,t);){const r=W(e,t+6);t+=10;const i=t+r;for(;t+8<i;){const r=Q(e.subarray(t)),i=Z(r);i&&n.push(i),t+=r.size+10}Y(e,t)&&(t+=10)}return n},Z=e=>"PRIV"===e.type?ee(e):"W"===e.type[0]?ne(e):te(e),ee=e=>{if(e.size<2)return;const t=ie(e.data,!0),n=new Uint8Array(e.data.subarray(t.length+1));return{key:e.type,info:t,data:n.buffer}},te=e=>{if(e.size<2)return;if("TXXX"===e.type){let t=1;const n=ie(e.data.subarray(t),!0);t+=n.length+1;const r=ie(e.data.subarray(t));return{key:e.type,info:n,data:r}}const t=ie(e.data.subarray(1));return{key:e.type,data:t}},ne=e=>{if("WXXX"===e.type){if(e.size<2)return;let t=1;const n=ie(e.data.subarray(t),!0);t+=n.length+1;const r=ie(e.data.subarray(t));return{key:e.type,info:n,data:r}}const t=ie(e.data);return{key:e.type,data:t}},re=e=>{if(8===e.data.byteLength){const t=new Uint8Array(e.data),n=1&t[3];let r=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return r/=45,n&&(r+=47721858.84),Math.round(r)}},ie=(e,t=!1)=>{const n=se();if(n){const r=n.decode(e);if(t){const e=r.indexOf("\0");return-1!==e?r.substring(0,e):r}return r.replace(/\0/g,"")}const r=e.length;let i,a,s,o="",l=0;for(;l<r;){if(i=e[l++],0===i&&t)return o;if(0!==i&&3!==i)switch(i>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:o+=String.fromCharCode(i);break;case 12:case 13:a=e[l++],o+=String.fromCharCode((31&i)<<6|63&a);break;case 14:a=e[l++],s=e[l++],o+=String.fromCharCode((15&i)<<12|(63&a)<<6|(63&s)<<0)}}return o};let ae;function se(){return ae||void 0===self.TextDecoder||(ae=new self.TextDecoder("utf-8")),ae}const oe=function(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},le=Math.pow(2,32)-1,ue=[].push,ce={video:1,audio:2,id3:3,text:4};function de(e){return String.fromCharCode.apply(null,e)}function fe(e,t){const n=e[t]<<8|e[t+1];return n<0?65536+n:n}function he(e,t){const n=ge(e,t);return n<0?4294967296+n:n}function ge(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function pe(e,t,n){e[t]=n>>24,e[t+1]=n>>16&255,e[t+2]=n>>8&255,e[t+3]=255&n}function me(e,t){const n=[];if(!t.length)return n;const r=e.byteLength;for(let i=0;i<r;){const a=he(e,i),s=a>1?i+a:r;if(de(e.subarray(i+4,i+8))===t[0])if(1===t.length)n.push(e.subarray(i+8,s));else{const r=me(e.subarray(i+8,s),t.slice(1));r.length&&ue.apply(n,r)}i=s}return n}function ve(e){const t=[],n=e[0];let r=8;const i=he(e,r);r+=4,r+=0===n?8:16,r+=2;let a=e.length+0;const s=fe(e,r);r+=2;for(let n=0;n<s;n++){let n=r;const s=he(e,n);n+=4;const o=2147483647&s;if(1==(2147483648&s)>>>31)return y.warn("SIDX has hierarchical references (not supported)"),null;const l=he(e,n);n+=4,t.push({referenceSize:o,subsegmentDuration:l,info:{duration:l/i,start:a,end:a+o-1}}),a+=o,n+=4,r=n}return{earliestPresentationTime:0,timescale:i,version:n,referencesCount:s,references:t}}function ye(e){const t=[],n=me(e,["moov","trak"]);for(let e=0;e<n.length;e++){const r=n[e],i=me(r,["tkhd"])[0];if(i){let e=i[0],n=0===e?12:20;const a=he(i,n),s=me(r,["mdia","mdhd"])[0];if(s){e=s[0],n=0===e?12:20;const i=he(s,n),o=me(r,["mdia","hdlr"])[0];if(o){const e=de(o.subarray(8,12)),n={soun:w,vide:R}[e];if(n){const e=me(r,["mdia","minf","stbl","stsd"])[0];let s;e&&(s=de(e.subarray(12,16))),t[a]={timescale:i,type:n},t[n]={timescale:i,id:a,codec:s}}}}}}return me(e,["moov","mvex","trex"]).forEach((e=>{const n=he(e,4),r=t[n];r&&(r.default={duration:he(e,12),flags:he(e,20)})})),t}function Ee(e){const t=me(e,["schm"])[0];if(t){const n=de(t.subarray(4,8));if("cbcs"===n||"cenc"===n)return me(e,["schi","tenc"])[0]}return y.error("[eme] missing 'schm' box"),null}function Te(e){const t=he(e,0);let n=8;1&t&&(n+=4),4&t&&(n+=4);let r=0;const i=he(e,4);for(let a=0;a<i;a++)256&t&&(r+=he(e,n),n+=4),512&t&&(n+=4),1024&t&&(n+=4),2048&t&&(n+=4);return r}function be(e,t){const n=new Uint8Array(e.length+t.length);return n.set(e),n.set(t,e.length),n}function Se(e,t){const n=[],r=t.samples,i=t.timescale,a=t.id;let s=!1;return me(r,["moof"]).map((o=>{const l=o.byteOffset-8;me(o,["traf"]).map((o=>{const u=me(o,["tfdt"]).map((e=>{const t=e[0];let n=he(e,4);return 1===t&&(n*=Math.pow(2,32),n+=he(e,8)),n/i}))[0];return void 0!==u&&(e=u),me(o,["tfhd"]).map((u=>{const c=he(u,4),d=16777215&he(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=he(u,m),m+=4),h&&(g=he(u,m),m+=4),p&&(m+=4),"video"===t.type&&(s=function(e){if(!e)return!1;const t=e.indexOf("."),n=t<0?e:e.substring(0,t);return"hvc1"===n||"hev1"===n||"dvh1"===n||"dvhe"===n}(t.codec)),me(o,["trun"]).map((a=>{const o=a[0],u=16777215&he(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=he(a,4);let _=8;c&&(d=he(a,_),_+=4),h&&(_+=4);let A=d+l;for(let l=0;l<S;l++){if(p?(m=he(a,_),_+=4):m=f,v?(y=he(a,_),_+=4):y=g,E&&(_+=4),T&&(b=0===o?he(a,_):ge(a,_),_+=4),t.type===R){let t=0;for(;t<y;){const a=he(r,A);A+=4,_e(s,r[A])&&Ae(r.subarray(A,A+a),s?2:1,e+b/i,n),A+=a,t+=a+4}}e+=m/i}})))}))}))})),n}function _e(e,t){if(e){const e=t>>1&63;return 39===e||40===e}return 6==(31&t)}function Ae(e,t,n,r){const i=we(e);let a=0;a+=t;let s=0,o=0,l=!1,u=0;for(;a<i.length;){s=0;do{if(a>=i.length)break;u=i[a++],s+=u}while(255===u);o=0;do{if(a>=i.length)break;u=i[a++],o+=u}while(255===u);const e=i.length-a;if(!l&&4===s&&a<i.length){if(l=!0,181===i[a++]){const e=fe(i,a);if(a+=2,49===e){const e=he(i,a);if(a+=4,1195456820===e){const e=i[a++];if(3===e){const t=i[a++],o=31&t,l=64&t,u=l?2+3*o:0,c=new Uint8Array(u);if(l){c[0]=t;for(let e=1;e<u;e++)c[e]=i[a++]}r.push({type:e,payloadType:s,pts:n,bytes:c})}}}}}else if(5===s&&o<e){if(l=!0,o>16){const e=[];for(let t=0;t<16;t++){const n=i[a++].toString(16);e.push(1==n.length?"0"+n:n),3!==t&&5!==t&&7!==t&&9!==t||e.push("-")}const t=o-16,l=new Uint8Array(t);for(let e=0;e<t;e++)l[e]=i[a++];r.push({payloadType:s,pts:n,uuid:e.join(""),userData:ie(l),userDataBytes:l})}}else if(o<e)a+=o;else if(o>e)break}}function we(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}let Re={};class Ie{static clearKeyUriToKeyIdMap(){Re={}}constructor(e,t,n,r=[1],i=null){this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=e,this.uri=t,this.keyFormat=n,this.keyFormatVersions=r,this.iv=i,this.encrypted=!!e&&"NONE"!==e,this.isCommonEncryption=this.encrypted&&"AES-128"!==e}isSupported(){if(this.method){if("AES-128"===this.method||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method;switch(this.keyFormat){case P:case U:case F:case O:return-1!==["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)}}return!1}getDecryptData(e){if(!this.encrypted||!this.uri)return null;if("AES-128"===this.method&&this.uri&&!this.iv){"number"!=typeof e&&("AES-128"!==this.method||this.iv||y.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0);const t=function(e){const t=new Uint8Array(16);for(let n=12;n<16;n++)t[n]=e>>8*(15-n)&255;return t}(e);return new Ie(this.method,this.uri,"identity",this.keyFormatVersions,t)}const t=function(e){const t=e.split(":");let n=null;if("data"===t[0]&&2===t.length){const e=t[1].split(";"),r=e[e.length-1].split(",");if(2===r.length){const t="base64"===r[0],i=r[1];t?(e.splice(-1,1),n=N(i)):n=function(e){const t=M(e).subarray(0,16),n=new Uint8Array(16);return n.set(t,16-t.length),n}(i)}}return n}(this.uri);if(t)switch(this.keyFormat){case U:this.pssh=t,t.length>=22&&(this.keyId=t.subarray(t.length-22,t.length-6));break;case F:{const e=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=function(e,t,n){if(16!==e.byteLength)throw new RangeError("Invalid system id");let r,i,a;if(t){r=1,i=new Uint8Array(16*t.length);for(let e=0;e<t.length;e++){const n=t[e];if(16!==n.byteLength)throw new RangeError("Invalid key");i.set(n,16*e)}}else r=0,i=new Uint8Array;r>0?(a=new Uint8Array(4),t.length>0&&new DataView(a.buffer).setUint32(0,t.length,!1)):a=new Uint8Array;const s=new Uint8Array(4);return n&&n.byteLength>0&&new DataView(s.buffer).setUint32(0,n.byteLength,!1),function(e,...t){const n=t.length;let r=8,i=n;for(;i--;)r+=t[i].byteLength;const a=new Uint8Array(r);for(a[0]=r>>24&255,a[1]=r>>16&255,a[2]=r>>8&255,a[3]=255&r,a.set(e,4),i=0,r=8;i<n;i++)a.set(t[i],r),r+=t[i].byteLength;return a}([112,115,115,104],new Uint8Array([r,0,0,0]),e,a,i,s,n||new Uint8Array)}(e,null,t);const n=new Uint16Array(t.buffer,t.byteOffset,t.byteLength/2),r=String.fromCharCode.apply(null,Array.from(n)),i=r.substring(r.indexOf("<"),r.length),a=(new DOMParser).parseFromString(i,"text/xml").getElementsByTagName("KID")[0];if(a){const e=a.childNodes[0]?a.childNodes[0].nodeValue:a.getAttribute("VALUE");if(e){const t=N(e).subarray(0,16);!function(e){const t=function(e,t,n){const r=e[t];e[t]=e[n],e[n]=r};t(e,0,3),t(e,1,2),t(e,4,5),t(e,6,7)}(t),this.keyId=t}}break}default:{let e=t.subarray(0,16);if(16!==e.length){const t=new Uint8Array(16);t.set(e,16-e.length),e=t}this.keyId=e;break}}if(!this.keyId||16!==this.keyId.byteLength){let e=Re[this.uri];if(!e){const t=Object.keys(Re).length%Number.MAX_SAFE_INTEGER;e=new Uint8Array(16),new DataView(e.buffer,12,4).setUint32(0,t),Re[this.uri]=e}this.keyId=e}return this}}const Ce=/\{\$([a-zA-Z0-9-_]+)\}/g;function De(e){return Ce.test(e)}function Le(e,t,n){if(null!==e.variableList||e.hasVariableRefs)for(let r=n.length;r--;){const i=n[r],a=t[i];a&&(t[i]=ke(e,a))}}function ke(e,t){if(null!==e.variableList||e.hasVariableRefs){const n=e.variableList;return t.replace(Ce,(t=>{const r=t.substring(2,t.length-1),i=null==n?void 0:n[r];return void 0===i?(e.playlistParsingError||(e.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${r}"`)),t):i}))}return t}function Ne(e,t,n){let r,i,a=e.variableList;if(a||(e.variableList=a={}),"QUERYPARAM"in t){r=t.QUERYPARAM;try{const e=new self.URL(n).searchParams;if(!e.has(r))throw new Error(`"${r}" does not match any query parameter in URI: "${n}"`);i=e.get(r)}catch(t){e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${t.message}`))}}else r=t.NAME,i=t.VALUE;r in a?e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${r}"`)):a[r]=i||""}function Me(e,t,n){const r=t.IMPORT;if(n&&r in n){let t=e.variableList;t||(e.variableList=t={}),t[r]=n[r]}else e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${r}"`))}function xe(){if("undefined"!=typeof self)return self.MediaSource||self.WebKitMediaSource}const Oe={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dva1:!0,dvav:!0,dvh1:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}},Pe=xe();function Fe(e,t){var n;return null!=(n=null==Pe?void 0:Pe.isTypeSupported(`${t||"video"}/mp4;codecs="${e}"`))&&n}const Ue=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,je=/#EXT-X-MEDIA:(.*)/g,Be=/^#EXT(?:INF|-X-TARGETDURATION):/m,Ge=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),He=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|"));class Ve{static findGroup(e,t){for(let n=0;n<e.length;n++){const r=e[n];if(r.id===t)return r}}static convertAVC1ToAVCOTI(e){const t=e.split(".");if(t.length>2){let e=t.shift()+".";return e+=parseInt(t.shift()).toString(16),e+=("000"+parseInt(t.shift()).toString(16)).slice(-4),e}return e}static resolve(e,t){return s.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return Be.test(e)}static parseMasterPlaylist(e,t){const n={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:De(e)},r=[];let i;for(Ue.lastIndex=0;null!=(i=Ue.exec(e));)if(i[1]){var a;const e=new b(i[1]);Le(n,e,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);const s=ke(n,i[2]),o={attrs:e,bitrate:e.decimalInteger("AVERAGE-BANDWIDTH")||e.decimalInteger("BANDWIDTH"),name:e.NAME,url:Ve.resolve(s,t)},l=e.decimalResolution("RESOLUTION");l&&(o.width=l.width,o.height=l.height),Ye((e.CODECS||"").split(/[ ,]+/).filter((e=>e)),o),o.videoCodec&&-1!==o.videoCodec.indexOf("avc1")&&(o.videoCodec=Ve.convertAVC1ToAVCOTI(o.videoCodec)),null!=(a=o.unknownCodecs)&&a.length||r.push(o),n.levels.push(o)}else if(i[3]){const e=i[3],r=i[4];switch(e){case"SESSION-DATA":{const e=new b(r);Le(n,e,["DATA-ID","LANGUAGE","VALUE","URI"]);const t=e["DATA-ID"];t&&(null===n.sessionData&&(n.sessionData={}),n.sessionData[t]=e);break}case"SESSION-KEY":{const e=Ke(r,t,n);e.encrypted&&e.isSupported()?(null===n.sessionKeys&&(n.sessionKeys=[]),n.sessionKeys.push(e)):y.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${r}"`);break}case"DEFINE":{const e=new b(r);Le(n,e,["NAME","VALUE","QUERYPARAM"]),Ne(n,e,t)}break;case"CONTENT-STEERING":{const e=new b(r);Le(n,e,["SERVER-URI","PATHWAY-ID"]),n.contentSteering={uri:Ve.resolve(e["SERVER-URI"],t),pathwayId:e["PATHWAY-ID"]||"."};break}case"START":n.startTimeOffset=qe(r)}}const s=r.length>0&&r.length<n.levels.length;return n.levels=s?r:n.levels,0===n.levels.length&&(n.playlistParsingError=new Error("no levels found in manifest")),n}static parseMasterPlaylistMedia(e,t,n){let r;const i={},a=n.levels,s={AUDIO:a.map((e=>({id:e.attrs.AUDIO,audioCodec:e.audioCodec}))),SUBTITLES:a.map((e=>({id:e.attrs.SUBTITLES,textCodec:e.textCodec}))),"CLOSED-CAPTIONS":[]};let o=0;for(je.lastIndex=0;null!==(r=je.exec(e));){const e=new b(r[1]),a=e.TYPE;if(a){const r=s[a],l=i[a]||[];i[a]=l,Le(n,e,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);const u={attrs:e,bitrate:0,id:o++,groupId:e["GROUP-ID"]||"",instreamId:e["INSTREAM-ID"],name:e.NAME||e.LANGUAGE||"",type:a,default:e.bool("DEFAULT"),autoselect:e.bool("AUTOSELECT"),forced:e.bool("FORCED"),lang:e.LANGUAGE,url:e.URI?Ve.resolve(e.URI,t):""};if(null!=r&&r.length){const e=Ve.findGroup(r,u.groupId)||r[0];ze(u,e,"audioCodec"),ze(u,e,"textCodec")}l.push(u)}}return i}static parseLevelPlaylist(e,t,n,r,i,a){const s=new k(t),o=s.fragments;let l,u,f,h=null,g=0,p=0,m=0,v=0,E=null,T=new D(r,t),S=-1,A=!1;for(Ge.lastIndex=0,s.m3u8=e,s.hasVariableRefs=De(e);null!==(l=Ge.exec(e));){A&&(A=!1,T=new D(r,t),T.start=m,T.sn=g,T.cc=v,T.level=n,h&&(T.initSegment=h,T.rawProgramDateTime=h.rawProgramDateTime,h.rawProgramDateTime=null));const e=l[1];if(e){T.duration=parseFloat(e);const t=(" "+l[2]).slice(1);T.title=t||null,T.tagList.push(t?["INF",e,t]:["INF",e])}else if(l[3]){if(d(T.duration)){T.start=m,f&&Xe(T,f,s),T.sn=g,T.level=n,T.cc=v,T.urlId=i,o.push(T);const e=(" "+l[3]).slice(1);T.relurl=ke(s,e),We(T,E),E=T,m+=T.duration,g++,p=0,A=!0}}else if(l[4]){const e=(" "+l[4]).slice(1);E?T.setByteRange(e,E):T.setByteRange(e)}else if(l[5])T.rawProgramDateTime=(" "+l[5]).slice(1),T.tagList.push(["PROGRAM-DATE-TIME",T.rawProgramDateTime]),-1===S&&(S=o.length);else{if(l=l[0].match(He),!l){y.warn("No matches on slow regex match for level playlist!");continue}for(u=1;u<l.length&&void 0===l[u];u++);const e=(" "+l[u]).slice(1),i=(" "+l[u+1]).slice(1),m=l[u+2]?(" "+l[u+2]).slice(1):"";switch(e){case"PLAYLIST-TYPE":s.type=i.toUpperCase();break;case"MEDIA-SEQUENCE":g=s.startSN=parseInt(i);break;case"SKIP":{const e=new b(i);Le(s,e,["RECENTLY-REMOVED-DATERANGES"]);const t=e.decimalInteger("SKIPPED-SEGMENTS");if(d(t)){s.skippedSegments=t;for(let e=t;e--;)o.unshift(null);g+=t}const n=e.enumeratedString("RECENTLY-REMOVED-DATERANGES");n&&(s.recentlyRemovedDateranges=n.split("\t"));break}case"TARGETDURATION":s.targetduration=Math.max(parseInt(i),1);break;case"VERSION":s.version=parseInt(i);break;case"EXTM3U":break;case"ENDLIST":s.live=!1;break;case"#":(i||m)&&T.tagList.push(m?[i,m]:[i]);break;case"DISCONTINUITY":v++,T.tagList.push(["DIS"]);break;case"GAP":T.gap=!0,T.tagList.push([e]);break;case"BITRATE":T.tagList.push([e,i]);break;case"DATERANGE":{const e=new b(i);Le(s,e,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),Le(s,e,e.clientAttrs);const t=new _(e,s.dateRanges[e.ID]);t.isValid||s.skippedSegments?s.dateRanges[t.id]=t:y.warn(`Ignoring invalid DATERANGE tag: "${i}"`),T.tagList.push(["EXT-X-DATERANGE",i]);break}case"DEFINE":{const e=new b(i);Le(s,e,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in e?Me(s,e,a):Ne(s,e,t)}break;case"DISCONTINUITY-SEQUENCE":v=parseInt(i);break;case"KEY":{const e=Ke(i,t,s);if(e.isSupported()){if("NONE"===e.method){f=void 0;break}f||(f={}),f[e.keyFormat]&&(f=c({},f)),f[e.keyFormat]=e}else y.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${i}"`);break}case"START":s.startTimeOffset=qe(i);break;case"MAP":{const e=new b(i);if(Le(s,e,["BYTERANGE","URI"]),T.duration){const i=new D(r,t);$e(i,e,n,f),h=i,T.initSegment=h,h.rawProgramDateTime&&!T.rawProgramDateTime&&(T.rawProgramDateTime=h.rawProgramDateTime)}else $e(T,e,n,f),h=T,A=!0;break}case"SERVER-CONTROL":{const e=new b(i);s.canBlockReload=e.bool("CAN-BLOCK-RELOAD"),s.canSkipUntil=e.optionalFloat("CAN-SKIP-UNTIL",0),s.canSkipDateRanges=s.canSkipUntil>0&&e.bool("CAN-SKIP-DATERANGES"),s.partHoldBack=e.optionalFloat("PART-HOLD-BACK",0),s.holdBack=e.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{const e=new b(i);s.partTarget=e.decimalFloatingPoint("PART-TARGET");break}case"PART":{let e=s.partList;e||(e=s.partList=[]);const n=p>0?e[e.length-1]:void 0,r=p++,a=new b(i);Le(s,a,["BYTERANGE","URI"]);const o=new L(a,T,t,r,n);e.push(o),T.duration+=o.duration;break}case"PRELOAD-HINT":{const e=new b(i);Le(s,e,["URI"]),s.preloadHint=e;break}case"RENDITION-REPORT":{const e=new b(i);Le(s,e,["URI"]),s.renditionReports=s.renditionReports||[],s.renditionReports.push(e);break}default:y.warn(`line parsed but not handled: ${l}`)}}}E&&!E.relurl?(o.pop(),m-=E.duration,s.partList&&(s.fragmentHint=E)):s.partList&&(We(T,E),T.cc=v,s.fragmentHint=T,f&&Xe(T,f,s));const w=o.length,R=o[0],I=o[w-1];if(m+=s.skippedSegments*s.targetduration,m>0&&w&&I){s.averagetargetduration=m/w;const e=I.sn;s.endSN="initSegment"!==e?e:0,s.live||(I.endList=!0),R&&(s.startCC=R.cc)}else s.endSN=0,s.startCC=0;return s.fragmentHint&&(m+=s.fragmentHint.duration),s.totalduration=m,s.endCC=v,S>0&&function(e,t){let n=e[t];for(let r=t;r--;){const t=e[r];if(!t)return;t.programDateTime=n.programDateTime-1e3*t.duration,n=t}}(o,S),s}}function Ke(e,t,n){var r,i;const a=new b(e);Le(n,a,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);const s=null!=(r=a.METHOD)?r:"",o=a.URI,l=a.hexadecimalInteger("IV"),u=a.KEYFORMATVERSIONS,c=null!=(i=a.KEYFORMAT)?i:"identity";o&&a.IV&&!l&&y.error(`Invalid IV: ${a.IV}`);const d=o?Ve.resolve(o,t):"",f=(u||"1").split("/").map(Number).filter(Number.isFinite);return new Ie(s,d,c,f,l)}function qe(e){const t=new b(e).decimalFloatingPoint("TIME-OFFSET");return d(t)?t:null}function Ye(e,t){["video","audio","text"].forEach((n=>{const r=e.filter((e=>function(e,t){const n=Oe[t];return!!n&&!0===n[e.slice(0,4)]}(e,n)));if(r.length){const i=r.filter((e=>0===e.lastIndexOf("avc1",0)||0===e.lastIndexOf("mp4a",0)));t[`${n}Codec`]=i.length>0?i[0]:r[0],e=e.filter((e=>-1===r.indexOf(e)))}})),t.unknownCodecs=e}function ze(e,t,n){const r=t[n];r&&(e[n]=r)}function We(e,t){e.rawProgramDateTime?e.programDateTime=Date.parse(e.rawProgramDateTime):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime),d(e.programDateTime)||(e.programDateTime=null,e.rawProgramDateTime=null)}function $e(e,t,n,r){e.relurl=t.URI,t.BYTERANGE&&e.setByteRange(t.BYTERANGE),e.level=n,e.sn="initSegment",r&&(e.levelkeys=r),e.initSegment=null}function Xe(e,t,n){e.levelkeys=t;const{encryptedFragments:r}=n;r.length&&r[r.length-1].levelkeys===t||!Object.keys(t).some((e=>t[e].isCommonEncryption))||r.push(e)}var Qe="manifest",Je="level",Ze="audioTrack",et="subtitleTrack",tt="main",nt="audio",rt="subtitle";function it(e){const{type:t}=e;switch(t){case Ze:return nt;case et:return rt;default:return tt}}function at(e,t){let n=e.url;return void 0!==n&&0!==n.indexOf("data:")||(n=t.url),n}class st{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){const{hls:e}=this;e.on(f.MANIFEST_LOADING,this.onManifestLoading,this),e.on(f.LEVEL_LOADING,this.onLevelLoading,this),e.on(f.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(f.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){const{hls:e}=this;e.off(f.MANIFEST_LOADING,this.onManifestLoading,this),e.off(f.LEVEL_LOADING,this.onLevelLoading,this),e.off(f.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(f.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(e){const t=this.hls.config,n=t.pLoader,r=t.loader,i=new(n||r)(t);return this.loaders[e.type]=i,i}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e]}destroyInternalLoaders(){for(const e in this.loaders){const t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(e,t){const{url:n}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Qe,url:n,deliveryDirectives:null})}onLevelLoading(e,t){const{id:n,level:r,url:i,deliveryDirectives:a}=t;this.load({id:n,level:r,responseType:"text",type:Je,url:i,deliveryDirectives:a})}onAudioTrackLoading(e,t){const{id:n,groupId:r,url:i,deliveryDirectives:a}=t;this.load({id:n,groupId:r,level:null,responseType:"text",type:Ze,url:i,deliveryDirectives:a})}onSubtitleTrackLoading(e,t){const{id:n,groupId:r,url:i,deliveryDirectives:a}=t;this.load({id:n,groupId:r,level:null,responseType:"text",type:et,url:i,deliveryDirectives:a})}load(e){var t;const n=this.hls.config;let r,i=this.getInternalLoader(e);if(i){const t=i.context;if(t&&t.url===e.url)return void y.trace("[playlist-loader]: playlist request ongoing");y.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),i.abort()}if(r=e.type===Qe?n.manifestLoadPolicy.default:c({},n.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),i=this.createInternalLoader(e),null!=(t=e.deliveryDirectives)&&t.part){let t;if(e.type===Je&&null!==e.level?t=this.hls.levels[e.level].details:e.type===Ze&&null!==e.id?t=this.hls.audioTracks[e.id].details:e.type===et&&null!==e.id&&(t=this.hls.subtitleTracks[e.id].details),t){const e=t.partTarget,n=t.targetduration;if(e&&n){const t=1e3*Math.max(3*e,.8*n);r=c({},r,{maxTimeToFirstByteMs:Math.min(t,r.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(t,r.maxTimeToFirstByteMs)})}}}const a=r.errorRetry||r.timeoutRetry||{},s={loadPolicy:r,timeout:r.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},o={onSuccess:(e,t,n,r)=>{const i=this.getInternalLoader(n);this.resetInternalLoader(n.type);const a=e.data;0===a.indexOf("#EXTM3U")?(t.parsing.start=performance.now(),Ve.isMediaPlaylist(a)?this.handleTrackOrLevelPlaylist(e,t,n,r||null,i):this.handleMasterPlaylist(e,t,n,r)):this.handleManifestParsingError(e,n,new Error("no EXTM3U delimiter"),r||null,t)},onError:(e,t,n,r)=>{this.handleNetworkError(t,n,!1,e,r)},onTimeout:(e,t,n)=>{this.handleNetworkError(t,n,!0,void 0,e)}};i.load(e,s,o)}handleMasterPlaylist(e,t,n,r){const i=this.hls,a=e.data,s=at(e,n),o=Ve.parseMasterPlaylist(a,s);if(o.playlistParsingError)return void this.handleManifestParsingError(e,n,o.playlistParsingError,r,t);const{contentSteering:l,levels:u,sessionData:c,sessionKeys:d,startTimeOffset:h,variableList:g}=o;this.variableList=g;const{AUDIO:p=[],SUBTITLES:m,"CLOSED-CAPTIONS":v}=Ve.parseMasterPlaylistMedia(a,s,o);p.length&&(p.some((e=>!e.url))||!u[0].audioCodec||u[0].attrs.AUDIO||(y.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),p.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new b({}),bitrate:0,url:""}))),i.trigger(f.MANIFEST_LOADED,{levels:u,audioTracks:p,subtitles:m,captions:v,contentSteering:l,url:s,stats:t,networkDetails:r,sessionData:c,sessionKeys:d,startTimeOffset:h,variableList:g})}handleTrackOrLevelPlaylist(e,t,n,r,i){const a=this.hls,{id:s,level:o,type:l}=n,u=at(e,n),c=d(s)?s:0,h=d(o)?o:c,g=it(n),p=Ve.parseLevelPlaylist(e.data,u,h,g,c,this.variableList);if(l===Qe){const e={attrs:new b({}),bitrate:0,details:p,name:"",url:u};a.trigger(f.MANIFEST_LOADED,{levels:[e],audioTracks:[],url:u,stats:t,networkDetails:r,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),n.levelDetails=p,this.handlePlaylistLoaded(p,e,t,n,r,i)}handleManifestParsingError(e,t,n,r,i){this.hls.trigger(f.ERROR,{type:h.NETWORK_ERROR,details:g.MANIFEST_PARSING_ERROR,fatal:t.type===Qe,url:e.url,err:n,error:n,reason:n.message,response:e,context:t,networkDetails:r,stats:i})}handleNetworkError(e,t,n=!1,r,i){let a=`A network ${n?"timeout":"error"+(r?" (status "+r.code+")":"")} occurred while loading ${e.type}`;e.type===Je?a+=`: ${e.level} id: ${e.id}`:e.type!==Ze&&e.type!==et||(a+=` id: ${e.id} group-id: "${e.groupId}"`);const s=new Error(a);y.warn(`[playlist-loader]: ${a}`);let o=g.UNKNOWN,u=!1;const c=this.getInternalLoader(e);switch(e.type){case Qe:o=n?g.MANIFEST_LOAD_TIMEOUT:g.MANIFEST_LOAD_ERROR,u=!0;break;case Je:o=n?g.LEVEL_LOAD_TIMEOUT:g.LEVEL_LOAD_ERROR,u=!1;break;case Ze:o=n?g.AUDIO_TRACK_LOAD_TIMEOUT:g.AUDIO_TRACK_LOAD_ERROR,u=!1;break;case et:o=n?g.SUBTITLE_TRACK_LOAD_TIMEOUT:g.SUBTITLE_LOAD_ERROR,u=!1}c&&this.resetInternalLoader(e.type);const d={type:h.NETWORK_ERROR,details:o,fatal:u,url:e.url,loader:c,context:e,error:s,networkDetails:t,stats:i};if(r){const n=(null==t?void 0:t.url)||e.url;d.response=l({url:n,data:void 0},r)}this.hls.trigger(f.ERROR,d)}handlePlaylistLoaded(e,t,n,r,i,a){const s=this.hls,{type:o,level:l,id:u,groupId:c,deliveryDirectives:d}=r,p=at(t,r),m=it(r),v="number"==typeof r.level&&m===tt?l:void 0;if(!e.fragments.length){const e=new Error("No Segments found in Playlist");return void s.trigger(f.ERROR,{type:h.NETWORK_ERROR,details:g.LEVEL_EMPTY_ERROR,fatal:!1,url:p,error:e,reason:e.message,response:t,context:r,level:v,parent:m,networkDetails:i,stats:n})}e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));const y=e.playlistParsingError;if(y)s.trigger(f.ERROR,{type:h.NETWORK_ERROR,details:g.LEVEL_PARSING_ERROR,fatal:!1,url:p,error:y,reason:y.message,response:t,context:r,level:v,parent:m,networkDetails:i,stats:n});else switch(e.live&&a&&(a.getCacheAge&&(e.ageHeader=a.getCacheAge()||0),a.getCacheAge&&!isNaN(e.ageHeader)||(e.ageHeader=0)),o){case Qe:case Je:s.trigger(f.LEVEL_LOADED,{details:e,level:v||0,id:u||0,stats:n,networkDetails:i,deliveryDirectives:d});break;case Ze:s.trigger(f.AUDIO_TRACK_LOADED,{details:e,id:u||0,groupId:c||"",stats:n,networkDetails:i,deliveryDirectives:d});break;case et:s.trigger(f.SUBTITLE_TRACK_LOADED,{details:e,id:u||0,groupId:c||"",stats:n,networkDetails:i,deliveryDirectives:d})}}}function ot(e,t){let n;try{n=new Event("addtrack")}catch(e){n=document.createEvent("Event"),n.initEvent("addtrack",!1,!1)}n.track=e,t.dispatchEvent(n)}function lt(e,t){const n=e.mode;if("disabled"===n&&(e.mode="hidden"),e.cues&&!e.cues.getCueById(t.id))try{if(e.addCue(t),!e.cues.getCueById(t.id))throw new Error(`addCue is failed for: ${t}`)}catch(n){y.debug(`[texttrack-utils]: ${n}`);try{const n=new self.TextTrackCue(t.startTime,t.endTime,t.text);n.id=t.id,e.addCue(n)}catch(e){y.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${e}`)}}"disabled"===n&&(e.mode=n)}function ut(e){const t=e.mode;if("disabled"===t&&(e.mode="hidden"),e.cues)for(let t=e.cues.length;t--;)e.removeCue(e.cues[t]);"disabled"===t&&(e.mode=t)}function ct(e,t,n,r){const i=e.mode;if("disabled"===i&&(e.mode="hidden"),e.cues&&e.cues.length>0){const i=function(e,t,n){const r=[],i=function(e,t){if(t<e[0].startTime)return 0;const n=e.length-1;if(t>e[n].endTime)return-1;let r=0,i=n;for(;r<=i;){const a=Math.floor((i+r)/2);if(t<e[a].startTime)i=a-1;else{if(!(t>e[a].startTime&&r<n))return a;r=a+1}}return e[r].startTime-t<t-e[i].startTime?r:i}(e,t);if(i>-1)for(let a=i,s=e.length;a<s;a++){const i=e[a];if(i.startTime>=t&&i.endTime<=n)r.push(i);else if(i.startTime>n)return r}return r}(e.cues,t,n);for(let t=0;t<i.length;t++)r&&!r(i[t])||e.removeCue(i[t])}"disabled"===i&&(e.mode=i)}var dt="org.id3",ft="https://aomedia.org/emsg/ID3";function ht(){if("undefined"!=typeof self)return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}const gt=(()=>{const e=ht();try{new e(0,Number.POSITIVE_INFINITY,"")}catch(e){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function pt(e,t){return e.getTime()/1e3-t}class mt{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null}_registerListeners(){const{hls:e}=this;e.on(f.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(f.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(f.MANIFEST_LOADING,this.onManifestLoading,this),e.on(f.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(f.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(f.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){const{hls:e}=this;e.off(f.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(f.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(f.MANIFEST_LOADING,this.onManifestLoading,this),e.off(f.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(f.BUFFER_FLUS