lcny-admin-mobile-vue/dist/build/h5/static/js/pages-basics-profile-detail...

141 lines
608 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["pages-basics-profile-detail~pages-index-monitor"],{"1d2a":function(e,t,r){"use strict";var i;r.d(t,"b",(function(){return s})),r.d(t,"c",(function(){return n})),r.d(t,"a",(function(){return i}));var s=function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("v-uni-view",{staticClass:"h-full w-full"},[e.address?r("LiveVideo",{key:e.address,attrs:{url:e.address,type:e.type}}):e._e()],1)},n=[]},2222:function(e,t,r){"use strict";r.r(t);var i=r("e2e5"),s=r.n(i);for(var n in i)["default"].indexOf(n)<0&&function(e){r.d(t,e,(function(){return i[e]}))}(n);t["default"]=s.a},2931:function(e,t,r){"use strict";r.r(t);var i=r("1d2a"),s=r("e52e");for(var n in s)["default"].indexOf(n)<0&&function(e){r.d(t,e,(function(){return s[e]}))}(n);var a,o=r("f0c5"),l=Object(o["a"])(s["default"],i["b"],i["c"],!1,null,null,null,!1,i["a"],a);t["default"]=l.exports},"2cb3":function(e,t,r){"use strict";r.r(t);var i=r("d4f6"),s=r("2222");for(var n in s)["default"].indexOf(n)<0&&function(e){r.d(t,e,(function(){return s[e]}))}(n);r("75f3");var a,o=r("f0c5"),l=Object(o["a"])(s["default"],i["b"],i["c"],!1,null,"4c4d4f71",null,!1,i["a"],a);t["default"]=l.exports},3315:function(e,t,r){var i=r("ae74");i.__esModule&&(i=i.default),"string"===typeof i&&(i=[[e.i,i,""]]),i.locals&&(e.exports=i.locals);var s=r("4f06").default;s("89233f1a",i,!0,{sourceMap:!1,shadowMode:!1})},"3c35":function(e,t){(function(t){e.exports=t}).call(this,{})},4362:function(e,t,r){t.nextTick=function(e){var t=Array.prototype.slice.call(arguments);t.shift(),setTimeout((function(){e.apply(null,t)}),0)},t.platform=t.arch=t.execPath=t.title="browser",t.pid=1,t.browser=!0,t.env={},t.argv=[],t.binding=function(e){throw new Error("No such module. (Possibly not yet loaded)")},function(){var e,i="/";t.cwd=function(){return i},t.chdir=function(t){e||(e=r("df7c")),i=e.resolve(t,i)}}(),t.exit=t.kill=t.umask=t.dlopen=t.uptime=t.memoryUsage=t.uvCounters=function(){},t.features={}},"5926e":function(e,t,r){var i=r("6181");i.__esModule&&(i=i.default),"string"===typeof i&&(i=[[e.i,i,""]]),i.locals&&(e.exports=i.locals);var s=r("4f06").default;s("28e5fb73",i,!0,{sourceMap:!1,shadowMode:!1})},6181:function(e,t,r){var i=r("24fb");t=i(!1),t.push([e.i,'@charset "UTF-8";\n/**\n * 这里是uni-app内置的常用样式变量\n *\n * uni-app 官方扩展插件及插件市场https://ext.dcloud.net.cn上很多三方插件均使用了这些样式变量\n * 如果你是插件开发者建议你使用scss预处理并在插件代码中直接使用这些变量无需 import 这个文件方便用户通过搭积木的方式开发整体风格一致的App\n *\n */\n/**\n * 如果你是App开发者插件使用者你可以通过修改这些变量来定制自己的插件主题实现自定义主题功能\n *\n * 如果你的项目同样使用了scss预处理你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件\n */\n/* 颜色变量 */\n/* 行为相关颜色 */\n/* 文字基本颜色 */\n/* 背景颜色 */\n/* 边框颜色 */\n/* 尺寸变量 */\n/* 文字尺寸 */\n/* 图片尺寸 */\n/* Border Radius */\n/* 水平间距 */\n/* 垂直间距 */\n/* 透明度 */\n/* 文章场景相关 */.video-box[data-v-4c4d4f71]{width:100%;padding-top:56.2%}',""]),e.exports=t},"75f3":function(e,t,r){"use strict";var i=r("5926e"),s=r.n(i);s.a},a567:function(e,t,r){"use strict";function i(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e["default"]:e}r.r(t),r.d(t,"default",(function(){return Fa}));var s={exports:{}};(function(e,t){(function(t){var r=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,i=/^(?=([^\/?#]*))\1([^]*)$/,s=/(?:\/|^)\.(?=\/)/g,n=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,a={buildAbsoluteURL:function(e,t,r){if(r=r||{},e=e.trim(),t=t.trim(),!t){if(!r.alwaysNormalize)return e;var s=a.parseURL(e);if(!s)throw new Error("Error trying to parse base URL.");return s.path=a.normalizePath(s.path),a.buildURLFromParts(s)}var n=a.parseURL(t);if(!n)throw new Error("Error trying to parse relative URL.");if(n.scheme)return r.alwaysNormalize?(n.path=a.normalizePath(n.path),a.buildURLFromParts(n)):t;var o=a.parseURL(e);if(!o)throw new Error("Error trying to parse base URL.");if(!o.netLoc&&o.path&&"/"!==o.path[0]){var l=i.exec(o.path);o.netLoc=l[1],o.path=l[2]}o.netLoc&&!o.path&&(o.path="/");var d={scheme:o.scheme,netLoc:n.netLoc,path:null,params:n.params,query:n.query,fragment:n.fragment};if(!n.netLoc&&(d.netLoc=o.netLoc,"/"!==n.path[0]))if(n.path){var h=o.path,c=h.substring(0,h.lastIndexOf("/")+1)+n.path;d.path=a.normalizePath(c)}else d.path=o.path,n.params||(d.params=o.params,n.query||(d.query=o.query));return null===d.path&&(d.path=r.alwaysNormalize?a.normalizePath(n.path):n.path),a.buildURLFromParts(d)},parseURL:function(e){var t=r.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){e=e.split("").reverse().join("").replace(s,"");while(e.length!==(e=e.replace(n,"")).length);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}};e.exports=a})()})(s);var n=s.exports;function a(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function o(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?a(Object(r),!0).forEach((function(t){l(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):a(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function l(e,t,r){return t=c(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function d(){return d=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},d.apply(this,arguments)}function h(e,t){if("object"!==typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!==typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function c(e){var t=h(e,"string");return"symbol"===typeof t?t:String(t)}const u=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}({}),p=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}({}),m=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 g=function(){},y={trace:g,debug:g,log:g,warn:g,info:g,error:g};let v=y;function _(e){const t=self.console[e];return t?t.bind(self.console,`[${e}] >`):g}function E(e,...t){t.forEach((function(t){v[t]=e[t]?e[t].bind(e):_(t)}))}function b(e,t){if(self.console&&!0===e||"object"===typeof e){E(e,"debug","log","info","warn","error");try{v.log(`Debug logs enabled for "${t}" in hls.js version 1.4.12`)}catch(r){v=y}}else v=y}const T=v,S=/^(\d+)x(\d+)$/,L=/(.+?)=(".*?"|.*?)(?:,|$)/g;class A{constructor(e){"string"===typeof e&&(e=A.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 r=new Uint8Array(t.length/2);for(let e=0;e<t.length/2;e++)r[e]=parseInt(t.slice(2*e,2*e+2),16);return r}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 r=this[e];return r?parseFloat(r):t}enumeratedString(e){return this[e]}bool(e){return"YES"===this[e]}decimalResolution(e){const t=S.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e){let t;const r={},i='"';L.lastIndex=0;while(null!==(t=L.exec(e))){let e=t[2];0===e.indexOf(i)&&e.lastIndexOf(i)===e.length-1&&(e=e.slice(1,-1));const s=t[1].trim();r[s]=e}return r}}function w(e){return"ID"!==e&&"CLASS"!==e&&"START-DATE"!==e&&"DURATION"!==e&&"END-DATE"!==e&&"END-ON-NEXT"!==e}function R(e){return"SCTE35-OUT"===e||"SCTE35-IN"===e}class k{constructor(e,t){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,t){const r=t.attr;for(const t in r)if(Object.prototype.hasOwnProperty.call(e,t)&&e[t]!==r[t]){T.warn(`DATERANGE tag attribute: "${t}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=t;break}e=d(new A({}),r,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"]);u(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(u(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&&u(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)}}class I{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 D={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"};class x{constructor(e){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[D.AUDIO]:null,[D.VIDEO]:null,[D.AUDIOVIDEO]:null},this.baseurl=e}setByteRange(e,t){const r=e.split("@",2),i=[];1===r.length?i[0]=t?t.byteRangeEndOffset:0:i[0]=parseInt(r[1]),i[1]=parseInt(r[0])+i[0],this._byteRange=i}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=n.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}}class C extends x{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 I,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(!u(this.programDateTime))return null;const e=u(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,r,i,s,n=!1){const{elementaryStreams:a}=this,o=a[e];o?(o.startPTS=Math.min(o.startPTS,t),o.endPTS=Math.max(o.endPTS,r),o.startDTS=Math.min(o.startDTS,i),o.endDTS=Math.max(o.endDTS,s)):a[e]={startPTS:t,endPTS:r,startDTS:i,endDTS:s,partial:n}}clearElementaryStreamInfo(){const{elementaryStreams:e}=this;e[D.AUDIO]=null,e[D.VIDEO]=null,e[D.AUDIOVIDEO]=null}}class P extends x{constructor(e,t,r,i,s){super(r),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.stats=new I,this.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=t,this.index=i;const n=e.enumeratedString("BYTERANGE");n&&this.setByteRange(n,s),s&&(this.fragOffset=s.fragOffset+s.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)}}const O=10;class M{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,r=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!r||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||0===t&&r>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&&u(this.fragments[this.fragments.length-1].programDateTime)}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||O}get drift(){const e=this.driftEndTime-this.driftStartTime;if(e>0){const t=this.driftEnd-this.driftStart;return 1e3*t/e}return 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 F(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0))}function N(e){const t=$(e).subarray(0,16),r=new Uint8Array(16);return r.set(t,16-t.length),r}function U(e){const t=function(e,t,r){const i=e[t];e[t]=e[r],e[r]=i};t(e,0,3),t(e,1,2),t(e,4,5),t(e,6,7)}function B(e){const t=e.split(":");let r=null;if("data"===t[0]&&2===t.length){const e=t[1].split(";"),i=e[e.length-1].split(",");if(2===i.length){const t="base64"===i[0],s=i[1];t?(e.splice(-1,1),r=F(s)):r=N(s)}}return r}function $(e){return Uint8Array.from(unescape(encodeURIComponent(e)),e=>e.charCodeAt(0))}var G={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},j={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function K(e){switch(e){case j.FAIRPLAY:return G.FAIRPLAY;case j.PLAYREADY:return G.PLAYREADY;case j.WIDEVINE:return G.WIDEVINE;case j.CLEARKEY:return G.CLEARKEY}}var V={WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function H(e){if(e===V.WIDEVINE)return G.WIDEVINE}function Y(e){switch(e){case G.FAIRPLAY:return j.FAIRPLAY;case G.PLAYREADY:return j.PLAYREADY;case G.WIDEVINE:return j.WIDEVINE;case G.CLEARKEY:return j.CLEARKEY}}function z(e){const{drmSystems:t,widevineLicenseUrl:r}=e,i=t?[G.FAIRPLAY,G.WIDEVINE,G.PLAYREADY,G.CLEARKEY].filter(e=>!!t[e]):[];return!i[G.WIDEVINE]&&r&&i.push(G.WIDEVINE),i}const W=function(){return"undefined"!==typeof self&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function q(e,t,r,i){let s;switch(e){case G.FAIRPLAY:s=["cenc","sinf"];break;case G.WIDEVINE:case G.PLAYREADY:s=["cenc"];break;case G.CLEARKEY:s=["cenc","keyids"];break;default:throw new Error("Unknown key-system: "+e)}return X(s,t,r,i)}function X(e,t,r,i){const s={initDataTypes:e,persistentState:i.persistentState||"not-allowed",distinctiveIdentifier:i.distinctiveIdentifier||"not-allowed",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:t.map(e=>({contentType:`audio/mp4; codecs="${e}"`,robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null})),videoCapabilities:r.map(e=>({contentType:`video/mp4; codecs="${e}"`,robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null}))};return[s]}function Q(e,t,r){return Uint8Array.prototype.slice?e.slice(t,r):new Uint8Array(Array.prototype.slice.call(e,t,r))}const Z=(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,J=(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,ee=(e,t)=>{const r=t;let i=0;while(Z(e,t)){i+=10;const r=te(e,t+6);i+=r,J(e,t+10)&&(i+=10),t+=i}if(i>0)return e.subarray(r,r+i)},te=(e,t)=>{let r=0;return r=(127&e[t])<<21,r|=(127&e[t+1])<<14,r|=(127&e[t+2])<<7,r|=127&e[t+3],r},re=(e,t)=>Z(e,t)&&te(e,t+6)+10<=e.length-t,ie=e=>{const t=ae(e);for(let r=0;r<t.length;r++){const e=t[r];if(se(e))return ce(e)}},se=e=>e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info,ne=e=>{const t=String.fromCharCode(e[0],e[1],e[2],e[3]),r=te(e,4),i=10;return{type:t,size:r,data:e.subarray(i,i+r)}},ae=e=>{let t=0;const r=[];while(Z(e,t)){const i=te(e,t+6);t+=10;const s=t+i;while(t+8<s){const i=ne(e.subarray(t)),s=oe(i);s&&r.push(s),t+=i.size+10}J(e,t)&&(t+=10)}return r},oe=e=>"PRIV"===e.type?le(e):"W"===e.type[0]?he(e):de(e),le=e=>{if(e.size<2)return;const t=ue(e.data,!0),r=new Uint8Array(e.data.subarray(t.length+1));return{key:e.type,info:t,data:r.buffer}},de=e=>{if(e.size<2)return;if("TXXX"===e.type){let t=1;const r=ue(e.data.subarray(t),!0);t+=r.length+1;const i=ue(e.data.subarray(t));return{key:e.type,info:r,data:i}}const t=ue(e.data.subarray(1));return{key:e.type,data:t}},he=e=>{if("WXXX"===e.type){if(e.size<2)return;let t=1;const r=ue(e.data.subarray(t),!0);t+=r.length+1;const i=ue(e.data.subarray(t));return{key:e.type,info:r,data:i}}const t=ue(e.data);return{key:e.type,data:t}},ce=e=>{if(8===e.data.byteLength){const t=new Uint8Array(e.data),r=1&t[3];let i=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return i/=45,r&&(i+=47721858.84),Math.round(i)}},ue=(e,t=!1)=>{const r=pe();if(r){const i=r.decode(e);if(t){const e=i.indexOf("\0");return-1!==e?i.substring(0,e):i}return i.replace(/\0/g,"")}const i=e.length;let s,n,a,o="",l=0;while(l<i){if(s=e[l++],0===s&&t)return o;if(0!==s&&3!==s)switch(s>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:o+=String.fromCharCode(s);break;case 12:case 13:n=e[l++],o+=String.fromCharCode((31&s)<<6|63&n);break;case 14:n=e[l++],a=e[l++],o+=String.fromCharCode((15&s)<<12|(63&n)<<6|(63&a)<<0);break}}return o};let fe;function pe(){return fe||"undefined"===typeof self.TextDecoder||(fe=new self.TextDecoder("utf-8")),fe}const me={hexDump:function(e){let t="";for(let r=0;r<e.length;r++){let i=e[r].toString(16);i.length<2&&(i="0"+i),t+=i}return t}},ge=Math.pow(2,32)-1,ye=[].push,ve={video:1,audio:2,id3:3,text:4};function _e(e){return String.fromCharCode.apply(null,e)}function Ee(e,t){const r=e[t]<<8|e[t+1];return r<0?65536+r:r}function be(e,t){const r=Te(e,t);return r<0?4294967296+r:r}function Te(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function Se(e,t,r){e[t]=r>>24,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r}function Le(e,t){const r=[];if(!t.length)return r;const i=e.byteLength;for(let s=0;s<i;){const n=be(e,s),a=_e(e.subarray(s+4,s+8)),o=n>1?s+n:i;if(a===t[0])if(1===t.length)r.push(e.subarray(s+8,o));else{const i=Le(e.subarray(s+8,o),t.slice(1));i.length&&ye.apply(r,i)}s=o}return r}function Ae(e){const t=[],r=e[0];let i=8;const s=be(e,i);i+=4;const n=0,a=0;i+=0===r?8:16,i+=2;let o=e.length+a;const l=Ee(e,i);i+=2;for(let d=0;d<l;d++){let r=i;const n=be(e,r);r+=4;const a=2147483647&n,l=(2147483648&n)>>>31;if(1===l)return T.warn("SIDX has hierarchical references (not supported)"),null;const d=be(e,r);r+=4,t.push({referenceSize:a,subsegmentDuration:d,info:{duration:d/s,start:o,end:o+a-1}}),o+=a,r+=4,i=r}return{earliestPresentationTime:n,timescale:s,version:r,referencesCount:l,references:t}}function we(e){const t=[],r=Le(e,["moov","trak"]);for(let s=0;s<r.length;s++){const e=r[s],i=Le(e,["tkhd"])[0];if(i){let r=i[0],s=0===r?12:20;const n=be(i,s),a=Le(e,["mdia","mdhd"])[0];if(a){r=a[0],s=0===r?12:20;const i=be(a,s),o=Le(e,["mdia","hdlr"])[0];if(o){const r=_e(o.subarray(8,12)),s={soun:D.AUDIO,vide:D.VIDEO}[r];if(s){const r=Le(e,["mdia","minf","stbl","stsd"])[0];let a;r&&(a=_e(r.subarray(12,16))),t[n]={timescale:i,type:s},t[s]={timescale:i,id:n,codec:a}}}}}}const i=Le(e,["moov","mvex","trex"]);return i.forEach(e=>{const r=be(e,4),i=t[r];i&&(i.default={duration:be(e,12),flags:be(e,20)})}),t}function Re(e,t){if(!e||!t)return e;const r=t.keyId;if(r&&t.isCommonEncryption){const t=Le(e,["moov","trak"]);t.forEach(e=>{const t=Le(e,["mdia","minf","stbl","stsd"])[0],i=t.subarray(8);let s=Le(i,["enca"]);const n=s.length>0;n||(s=Le(i,["encv"])),s.forEach(e=>{const t=n?e.subarray(28):e.subarray(78),i=Le(t,["sinf"]);i.forEach(e=>{const t=ke(e);if(t){const e=t.subarray(8,24);e.some(e=>0!==e)||(T.log(`[eme] Patching keyId in 'enc${n?"a":"v"}>sinf>>tenc' box: ${me.hexDump(e)} -> ${me.hexDump(r)}`),t.set(r,8))}})})})}return e}function ke(e){const t=Le(e,["schm"])[0];if(t){const r=_e(t.subarray(4,8));if("cbcs"===r||"cenc"===r)return Le(e,["schi","tenc"])[0]}return T.error("[eme] missing 'schm' box"),null}function Ie(e,t){return Le(t,["moof","traf"]).reduce((t,r)=>{const i=Le(r,["tfdt"])[0],s=i[0],n=Le(r,["tfhd"]).reduce((t,r)=>{const n=be(r,4),a=e[n];if(a){let e=be(i,4);if(1===s){if(e===ge)return T.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),t;e*=ge+1,e+=be(i,8)}const r=a.timescale||9e4,n=e/r;if(isFinite(n)&&(null===t||n<t))return n}return t},null);return null!==n&&isFinite(n)&&(null===t||n<t)?n:t},null)}function De(e,t){let r=0,i=0,s=0;const n=Le(e,["moof","traf"]);for(let a=0;a<n.length;a++){const e=n[a],o=Le(e,["tfhd"])[0],l=be(o,4),d=t[l];if(!d)continue;const h=d.default,c=be(o,0)|(null==h?void 0:h.flags);let u=null==h?void 0:h.duration;8&c&&(u=be(o,2&c?12:8));const f=d.timescale||9e4,p=Le(e,["trun"]);for(let t=0;t<p.length;t++){if(r=xe(p[t]),!r&&u){const e=be(p[t],4);r=u*e}d.type===D.VIDEO?i+=r/f:d.type===D.AUDIO&&(s+=r/f)}}if(0===i&&0===s){let t=0;const r=Le(e,["sidx"]);for(let e=0;e<r.length;e++){const i=Ae(r[e]);null!=i&&i.references&&(t+=i.references.reduce((e,t)=>e+t.info.duration||0,0))}return t}return i||s}function xe(e){const t=be(e,0);let r=8;1&t&&(r+=4),4&t&&(r+=4);let i=0;const s=be(e,4);for(let n=0;n<s;n++){if(256&t){const t=be(e,r);i+=t,r+=4}512&t&&(r+=4),1024&t&&(r+=4),2048&t&&(r+=4)}return i}function Ce(e,t,r){Le(t,["moof","traf"]).forEach(t=>{Le(t,["tfhd"]).forEach(i=>{const s=be(i,4),n=e[s];if(!n)return;const a=n.timescale||9e4;Le(t,["tfdt"]).forEach(e=>{const t=e[0];let i=be(e,4);if(0===t)i-=r*a,i=Math.max(i,0),Se(e,4,i);else{i*=Math.pow(2,32),i+=be(e,8),i-=r*a,i=Math.max(i,0);const t=Math.floor(i/(ge+1)),s=Math.floor(i%(ge+1));Se(e,4,t),Se(e,8,s)}})})})}function Pe(e){const t={valid:null,remainder:null},r=Le(e,["moof"]);if(!r)return t;if(r.length<2)return t.remainder=e,t;const i=r[r.length-1];return t.valid=Q(e,0,i.byteOffset-8),t.remainder=Q(e,i.byteOffset-8),t}function Oe(e,t){const r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}function Me(e,t){const r=[],i=t.samples,s=t.timescale,n=t.id;let a=!1;const o=Le(i,["moof"]);return o.map(o=>{const l=o.byteOffset-8,d=Le(o,["traf"]);d.map(o=>{const d=Le(o,["tfdt"]).map(e=>{const t=e[0];let r=be(e,4);return 1===t&&(r*=Math.pow(2,32),r+=be(e,8)),r/s})[0];return void 0!==d&&(e=d),Le(o,["tfhd"]).map(d=>{const h=be(d,4),c=16777215&be(d,0),u=0!==(1&c),f=0!==(2&c),p=0!==(8&c);let m=0;const g=0!==(16&c);let y=0;const v=0!==(32&c);let _=8;h===n&&(u&&(_+=8),f&&(_+=4),p&&(m=be(d,_),_+=4),g&&(y=be(d,_),_+=4),v&&(_+=4),"video"===t.type&&(a=Fe(t.codec)),Le(o,["trun"]).map(n=>{const o=n[0],d=16777215&be(n,0),h=0!==(1&d);let c=0;const u=0!==(4&d),f=0!==(256&d);let p=0;const g=0!==(512&d);let v=0;const _=0!==(1024&d),E=0!==(2048&d);let b=0;const T=be(n,4);let S=8;h&&(c=be(n,S),S+=4),u&&(S+=4);let L=c+l;for(let l=0;l<T;l++){if(f?(p=be(n,S),S+=4):p=m,g?(v=be(n,S),S+=4):v=y,_&&(S+=4),E&&(b=0===o?be(n,S):Te(n,S),S+=4),t.type===D.VIDEO){let t=0;while(t<v){const n=be(i,L);if(L+=4,Ne(a,i[L])){const t=i.subarray(L,L+n);Ue(t,a?2:1,e+b/s,r)}L+=n,t+=n+4}}e+=p/s}}))})})}),r}function Fe(e){if(!e)return!1;const t=e.indexOf("."),r=t<0?e:e.substring(0,t);return"hvc1"===r||"hev1"===r||"dvh1"===r||"dvhe"===r}function Ne(e,t){if(e){const e=t>>1&63;return 39===e||40===e}{const e=31&t;return 6===e}}function Ue(e,t,r,i){const s=Be(e);let n=0;n+=t;let a=0,o=0,l=!1,d=0;while(n<s.length){a=0;do{if(n>=s.length)break;d=s[n++],a+=d}while(255===d);o=0;do{if(n>=s.length)break;d=s[n++],o+=d}while(255===d);const e=s.length-n;if(!l&&4===a&&n<s.length){l=!0;const e=s[n++];if(181===e){const e=Ee(s,n);if(n+=2,49===e){const e=be(s,n);if(n+=4,1195456820===e){const e=s[n++];if(3===e){const t=s[n++],o=31&t,l=64&t,d=l?2+3*o:0,h=new Uint8Array(d);if(l){h[0]=t;for(let e=1;e<d;e++)h[e]=s[n++]}i.push({type:e,payloadType:a,pts:r,bytes:h})}}}}}else if(5===a&&o<e){if(l=!0,o>16){const e=[];for(let r=0;r<16;r++){const t=s[n++].toString(16);e.push(1==t.length?"0"+t:t),3!==r&&5!==r&&7!==r&&9!==r||e.push("-")}const t=o-16,l=new Uint8Array(t);for(let r=0;r<t;r++)l[r]=s[n++];i.push({payloadType:a,pts:r,uuid:e.join(""),userData:ue(l),userDataBytes:l})}}else if(o<e)n+=o;else if(o>e)break}}function Be(e){const t=e.byteLength,r=[];let i=1;while(i<t-2)0===e[i]&&0===e[i+1]&&3===e[i+2]?(r.push(i+2),i+=2):i++;if(0===r.length)return e;const s=t-r.length,n=new Uint8Array(s);let a=0;for(i=0;i<s;a++,i++)a===r[0]&&(a++,r.shift()),n[i]=e[a];return n}function $e(e){const t=e[0];let r="",i="",s=0,n=0,a=0,o=0,l=0,d=0;if(0===t){while("\0"!==_e(e.subarray(d,d+1)))r+=_e(e.subarray(d,d+1)),d+=1;r+=_e(e.subarray(d,d+1)),d+=1;while("\0"!==_e(e.subarray(d,d+1)))i+=_e(e.subarray(d,d+1)),d+=1;i+=_e(e.subarray(d,d+1)),d+=1,s=be(e,12),n=be(e,16),o=be(e,20),l=be(e,24),d=28}else if(1===t){d+=4,s=be(e,d),d+=4;const t=be(e,d);d+=4;const n=be(e,d);d+=4,a=2**32*t+n,Number.isSafeInteger(a)||(a=Number.MAX_SAFE_INTEGER,T.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=be(e,d),d+=4,l=be(e,d),d+=4;while("\0"!==_e(e.subarray(d,d+1)))r+=_e(e.subarray(d,d+1)),d+=1;r+=_e(e.subarray(d,d+1)),d+=1;while("\0"!==_e(e.subarray(d,d+1)))i+=_e(e.subarray(d,d+1)),d+=1;i+=_e(e.subarray(d,d+1)),d+=1}const h=e.subarray(d,e.byteLength);return{schemeIdUri:r,value:i,timeScale:s,presentationTime:a,presentationTimeDelta:n,eventDuration:o,id:l,payload:h}}function Ge(e,...t){const r=t.length;let i=8,s=r;while(s--)i+=t[s].byteLength;const n=new Uint8Array(i);for(n[0]=i>>24&255,n[1]=i>>16&255,n[2]=i>>8&255,n[3]=255&i,n.set(e,4),s=0,i=8;s<r;s++)n.set(t[s],i),i+=t[s].byteLength;return n}function je(e,t,r){if(16!==e.byteLength)throw new RangeError("Invalid system id");let i,s,n;if(t){i=1,s=new Uint8Array(16*t.length);for(let e=0;e<t.length;e++){const r=t[e];if(16!==r.byteLength)throw new RangeError("Invalid key");s.set(r,16*e)}}else i=0,s=new Uint8Array;i>0?(n=new Uint8Array(4),t.length>0&&new DataView(n.buffer).setUint32(0,t.length,!1)):n=new Uint8Array;const a=new Uint8Array(4);return r&&r.byteLength>0&&new DataView(a.buffer).setUint32(0,r.byteLength,!1),Ge([112,115,115,104],new Uint8Array([i,0,0,0]),e,n,s,a,r||new Uint8Array)}function Ke(e){if(!(e instanceof ArrayBuffer)||e.byteLength<32)return null;const t={version:0,systemId:"",kids:null,data:null},r=new DataView(e),i=r.getUint32(0);if(e.byteLength!==i&&i>44)return null;const s=r.getUint32(4);if(1886614376!==s)return null;if(t.version=r.getUint32(8)>>>24,t.version>1)return null;t.systemId=me.hexDump(new Uint8Array(e,12,16));const n=r.getUint32(28);if(0===t.version){if(i-32<n)return null;t.data=new Uint8Array(e,32,n)}else if(1===t.version){t.kids=[];for(let r=0;r<n;r++)t.kids.push(new Uint8Array(e,32+16*r,16))}return t}let Ve={};class He{static clearKeyUriToKeyIdMap(){Ve={}}constructor(e,t,r,i=[1],s=null){this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=e,this.uri=t,this.keyFormat=r,this.keyFormatVersions=i,this.iv=s,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 j.FAIRPLAY:case j.WIDEVINE:case j.PLAYREADY:case j.CLEARKEY: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||T.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0);const t=Ye(e),r=new He(this.method,this.uri,"identity",this.keyFormatVersions,t);return r}const t=B(this.uri);if(t)switch(this.keyFormat){case j.WIDEVINE:this.pssh=t,t.length>=22&&(this.keyId=t.subarray(t.length-22,t.length-6));break;case j.PLAYREADY:{const e=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=je(e,null,t);const r=new Uint16Array(t.buffer,t.byteOffset,t.byteLength/2),i=String.fromCharCode.apply(null,Array.from(r)),s=i.substring(i.indexOf("<"),i.length),n=new DOMParser,a=n.parseFromString(s,"text/xml"),o=a.getElementsByTagName("KID")[0];if(o){const e=o.childNodes[0]?o.childNodes[0].nodeValue:o.getAttribute("VALUE");if(e){const t=F(e).subarray(0,16);U(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=Ve[this.uri];if(!e){const t=Object.keys(Ve).length%Number.MAX_SAFE_INTEGER;e=new Uint8Array(16);const r=new DataView(e.buffer,12,4);r.setUint32(0,t),Ve[this.uri]=e}this.keyId=e}return this}}function Ye(e){const t=new Uint8Array(16);for(let r=12;r<16;r++)t[r]=e>>8*(15-r)&255;return t}const ze=/\{\$([a-zA-Z0-9-_]+)\}/g;function We(e){return ze.test(e)}function qe(e,t,r){if(null!==e.variableList||e.hasVariableRefs)for(let i=r.length;i--;){const s=r[i],n=t[s];n&&(t[s]=Xe(e,n))}}function Xe(e,t){if(null!==e.variableList||e.hasVariableRefs){const r=e.variableList;return t.replace(ze,t=>{const i=t.substring(2,t.length-1),s=null==r?void 0:r[i];return void 0===s?(e.playlistParsingError||(e.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${i}"`)),t):s})}return t}function Qe(e,t,r){let i,s,n=e.variableList;if(n||(e.variableList=n={}),"QUERYPARAM"in t){i=t.QUERYPARAM;try{const e=new self.URL(r).searchParams;if(!e.has(i))throw new Error(`"${i}" does not match any query parameter in URI: "${r}"`);s=e.get(i)}catch(a){e.playlistParsingError||(e.playlistParsingError=new Error("EXT-X-DEFINE QUERYPARAM: "+a.message))}}else i=t.NAME,s=t.VALUE;i in n?e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${i}"`)):n[i]=s||""}function Ze(e,t,r){const i=t.IMPORT;if(r&&i in r){let t=e.variableList;t||(e.variableList=t={}),t[i]=r[i]}else e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${i}"`))}function Je(){if("undefined"!==typeof self)return self.MediaSource||self.WebKitMediaSource}const et={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}},tt=Je();function rt(e,t){const r=et[t];return!!r&&!0===r[e.slice(0,4)]}function it(e,t){var r;return null!=(r=null==tt?void 0:tt.isTypeSupported(`${t||"video"}/mp4;codecs="${e}"`))&&r}const st=/#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,nt=/#EXT-X-MEDIA:(.*)/g,at=/^#EXT(?:INF|-X-TARGETDURATION):/m,ot=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),lt=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 dt{static findGroup(e,t){for(let r=0;r<e.length;r++){const i=e[r];if(i.id===t)return i}}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 n.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return at.test(e)}static parseMasterPlaylist(e,t){const r=We(e),i={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:r},s=[];let n;st.lastIndex=0;while(null!=(n=st.exec(e)))if(n[1]){var a;const e=new A(n[1]);qe(i,e,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);const r=Xe(i,n[2]),o={attrs:e,bitrate:e.decimalInteger("AVERAGE-BANDWIDTH")||e.decimalInteger("BANDWIDTH"),name:e.NAME,url:dt.resolve(r,t)},l=e.decimalResolution("RESOLUTION");l&&(o.width=l.width,o.height=l.height),ut((e.CODECS||"").split(/[ ,]+/).filter(e=>e),o),o.videoCodec&&-1!==o.videoCodec.indexOf("avc1")&&(o.videoCodec=dt.convertAVC1ToAVCOTI(o.videoCodec)),null!=(a=o.unknownCodecs)&&a.length||s.push(o),i.levels.push(o)}else if(n[3]){const e=n[3],r=n[4];switch(e){case"SESSION-DATA":{const e=new A(r);qe(i,e,["DATA-ID","LANGUAGE","VALUE","URI"]);const t=e["DATA-ID"];t&&(null===i.sessionData&&(i.sessionData={}),i.sessionData[t]=e);break}case"SESSION-KEY":{const e=ht(r,t,i);e.encrypted&&e.isSupported()?(null===i.sessionKeys&&(i.sessionKeys=[]),i.sessionKeys.push(e)):T.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${r}"`);break}case"DEFINE":{const e=new A(r);qe(i,e,["NAME","VALUE","QUERYPARAM"]),Qe(i,e,t)}break;case"CONTENT-STEERING":{const e=new A(r);qe(i,e,["SERVER-URI","PATHWAY-ID"]),i.contentSteering={uri:dt.resolve(e["SERVER-URI"],t),pathwayId:e["PATHWAY-ID"]||"."};break}case"START":i.startTimeOffset=ct(r);break}}const o=s.length>0&&s.length<i.levels.length;return i.levels=o?s:i.levels,0===i.levels.length&&(i.playlistParsingError=new Error("no levels found in manifest")),i}static parseMasterPlaylistMedia(e,t,r){let i;const s={},n=r.levels,a={AUDIO:n.map(e=>({id:e.attrs.AUDIO,audioCodec:e.audioCodec})),SUBTITLES:n.map(e=>({id:e.attrs.SUBTITLES,textCodec:e.textCodec})),"CLOSED-CAPTIONS":[]};let o=0;nt.lastIndex=0;while(null!==(i=nt.exec(e))){const e=new A(i[1]),n=e.TYPE;if(n){const i=a[n],l=s[n]||[];s[n]=l,qe(r,e,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);const d={attrs:e,bitrate:0,id:o++,groupId:e["GROUP-ID"]||"",instreamId:e["INSTREAM-ID"],name:e.NAME||e.LANGUAGE||"",type:n,default:e.bool("DEFAULT"),autoselect:e.bool("AUTOSELECT"),forced:e.bool("FORCED"),lang:e.LANGUAGE,url:e.URI?dt.resolve(e.URI,t):""};if(null!=i&&i.length){const e=dt.findGroup(i,d.groupId)||i[0];ft(d,e,"audioCodec"),ft(d,e,"textCodec")}l.push(d)}}return s}static parseLevelPlaylist(e,t,r,i,s,n){const a=new M(t),o=a.fragments;let l,h,c,f=null,p=0,m=0,g=0,y=0,v=null,_=new C(i,t),E=-1,b=!1;ot.lastIndex=0,a.m3u8=e,a.hasVariableRefs=We(e);while(null!==(l=ot.exec(e))){b&&(b=!1,_=new C(i,t),_.start=g,_.sn=p,_.cc=y,_.level=r,f&&(_.initSegment=f,_.rawProgramDateTime=f.rawProgramDateTime,f.rawProgramDateTime=null));const e=l[1];if(e){_.duration=parseFloat(e);const t=(" "+l[2]).slice(1);_.title=t||null,_.tagList.push(t?["INF",e,t]:["INF",e])}else if(l[3]){if(u(_.duration)){_.start=g,c&&yt(_,c,a),_.sn=p,_.level=r,_.cc=y,_.urlId=s,o.push(_);const e=(" "+l[3]).slice(1);_.relurl=Xe(a,e),mt(_,v),v=_,g+=_.duration,p++,m=0,b=!0}}else if(l[4]){const e=(" "+l[4]).slice(1);v?_.setByteRange(e,v):_.setByteRange(e)}else if(l[5])_.rawProgramDateTime=(" "+l[5]).slice(1),_.tagList.push(["PROGRAM-DATE-TIME",_.rawProgramDateTime]),-1===E&&(E=o.length);else{if(l=l[0].match(lt),!l){T.warn("No matches on slow regex match for level playlist!");continue}for(h=1;h<l.length;h++)if("undefined"!==typeof l[h])break;const e=(" "+l[h]).slice(1),s=(" "+l[h+1]).slice(1),g=l[h+2]?(" "+l[h+2]).slice(1):"";switch(e){case"PLAYLIST-TYPE":a.type=s.toUpperCase();break;case"MEDIA-SEQUENCE":p=a.startSN=parseInt(s);break;case"SKIP":{const e=new A(s);qe(a,e,["RECENTLY-REMOVED-DATERANGES"]);const t=e.decimalInteger("SKIPPED-SEGMENTS");if(u(t)){a.skippedSegments=t;for(let e=t;e--;)o.unshift(null);p+=t}const r=e.enumeratedString("RECENTLY-REMOVED-DATERANGES");r&&(a.recentlyRemovedDateranges=r.split("\t"));break}case"TARGETDURATION":a.targetduration=Math.max(parseInt(s),1);break;case"VERSION":a.version=parseInt(s);break;case"EXTM3U":break;case"ENDLIST":a.live=!1;break;case"#":(s||g)&&_.tagList.push(g?[s,g]:[s]);break;case"DISCONTINUITY":y++,_.tagList.push(["DIS"]);break;case"GAP":_.gap=!0,_.tagList.push([e]);break;case"BITRATE":_.tagList.push([e,s]);break;case"DATERANGE":{const e=new A(s);qe(a,e,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),qe(a,e,e.clientAttrs);const t=new k(e,a.dateRanges[e.ID]);t.isValid||a.skippedSegments?a.dateRanges[t.id]=t:T.warn(`Ignoring invalid DATERANGE tag: "${s}"`),_.tagList.push(["EXT-X-DATERANGE",s]);break}case"DEFINE":{const e=new A(s);qe(a,e,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in e?Ze(a,e,n):Qe(a,e,t)}break;case"DISCONTINUITY-SEQUENCE":y=parseInt(s);break;case"KEY":{const e=ht(s,t,a);if(e.isSupported()){if("NONE"===e.method){c=void 0;break}c||(c={}),c[e.keyFormat]&&(c=d({},c)),c[e.keyFormat]=e}else T.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${s}"`);break}case"START":a.startTimeOffset=ct(s);break;case"MAP":{const e=new A(s);if(qe(a,e,["BYTERANGE","URI"]),_.duration){const s=new C(i,t);gt(s,e,r,c),f=s,_.initSegment=f,f.rawProgramDateTime&&!_.rawProgramDateTime&&(_.rawProgramDateTime=f.rawProgramDateTime)}else gt(_,e,r,c),f=_,b=!0;break}case"SERVER-CONTROL":{const e=new A(s);a.canBlockReload=e.bool("CAN-BLOCK-RELOAD"),a.canSkipUntil=e.optionalFloat("CAN-SKIP-UNTIL",0),a.canSkipDateRanges=a.canSkipUntil>0&&e.bool("CAN-SKIP-DATERANGES"),a.partHoldBack=e.optionalFloat("PART-HOLD-BACK",0),a.holdBack=e.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{const e=new A(s);a.partTarget=e.decimalFloatingPoint("PART-TARGET");break}case"PART":{let e=a.partList;e||(e=a.partList=[]);const r=m>0?e[e.length-1]:void 0,i=m++,n=new A(s);qe(a,n,["BYTERANGE","URI"]);const o=new P(n,_,t,i,r);e.push(o),_.duration+=o.duration;break}case"PRELOAD-HINT":{const e=new A(s);qe(a,e,["URI"]),a.preloadHint=e;break}case"RENDITION-REPORT":{const e=new A(s);qe(a,e,["URI"]),a.renditionReports=a.renditionReports||[],a.renditionReports.push(e);break}default:T.warn("line parsed but not handled: "+l);break}}}v&&!v.relurl?(o.pop(),g-=v.duration,a.partList&&(a.fragmentHint=v)):a.partList&&(mt(_,v),_.cc=y,a.fragmentHint=_,c&&yt(_,c,a));const S=o.length,L=o[0],w=o[S-1];if(g+=a.skippedSegments*a.targetduration,g>0&&S&&w){a.averagetargetduration=g/S;const e=w.sn;a.endSN="initSegment"!==e?e:0,a.live||(w.endList=!0),L&&(a.startCC=L.cc)}else a.endSN=0,a.startCC=0;return a.fragmentHint&&(g+=a.fragmentHint.duration),a.totalduration=g,a.endCC=y,E>0&&pt(o,E),a}}function ht(e,t,r){var i,s;const n=new A(e);qe(r,n,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);const a=null!=(i=n.METHOD)?i:"",o=n.URI,l=n.hexadecimalInteger("IV"),d=n.KEYFORMATVERSIONS,h=null!=(s=n.KEYFORMAT)?s:"identity";o&&n.IV&&!l&&T.error("Invalid IV: "+n.IV);const c=o?dt.resolve(o,t):"",u=(d||"1").split("/").map(Number).filter(Number.isFinite);return new He(a,c,h,u,l)}function ct(e){const t=new A(e),r=t.decimalFloatingPoint("TIME-OFFSET");return u(r)?r:null}function ut(e,t){["video","audio","text"].forEach(r=>{const i=e.filter(e=>rt(e,r));if(i.length){const s=i.filter(e=>0===e.lastIndexOf("avc1",0)||0===e.lastIndexOf("mp4a",0));t[r+"Codec"]=s.length>0?s[0]:i[0],e=e.filter(e=>-1===i.indexOf(e))}}),t.unknownCodecs=e}function ft(e,t,r){const i=t[r];i&&(e[r]=i)}function pt(e,t){let r=e[t];for(let i=t;i--;){const t=e[i];if(!t)return;t.programDateTime=r.programDateTime-1e3*t.duration,r=t}}function mt(e,t){e.rawProgramDateTime?e.programDateTime=Date.parse(e.rawProgramDateTime):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime),u(e.programDateTime)||(e.programDateTime=null,e.rawProgramDateTime=null)}function gt(e,t,r,i){e.relurl=t.URI,t.BYTERANGE&&e.setByteRange(t.BYTERANGE),e.level=r,e.sn="initSegment",i&&(e.levelkeys=i),e.initSegment=null}function yt(e,t,r){e.levelkeys=t;const{encryptedFragments:i}=r;i.length&&i[i.length-1].levelkeys===t||!Object.keys(t).some(e=>t[e].isCommonEncryption)||i.push(e)}var vt={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},_t={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function Et(e){const{type:t}=e;switch(t){case vt.AUDIO_TRACK:return _t.AUDIO;case vt.SUBTITLE_TRACK:return _t.SUBTITLE;default:return _t.MAIN}}function bt(e,t){let r=e.url;return void 0!==r&&0!==r.indexOf("data:")||(r=t.url),r}class Tt{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,r=t.pLoader,i=t.loader,s=r||i,n=new s(t);return this.loaders[e.type]=n,n}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:r}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:vt.MANIFEST,url:r,deliveryDirectives:null})}onLevelLoading(e,t){const{id:r,level:i,url:s,deliveryDirectives:n}=t;this.load({id:r,level:i,responseType:"text",type:vt.LEVEL,url:s,deliveryDirectives:n})}onAudioTrackLoading(e,t){const{id:r,groupId:i,url:s,deliveryDirectives:n}=t;this.load({id:r,groupId:i,level:null,responseType:"text",type:vt.AUDIO_TRACK,url:s,deliveryDirectives:n})}onSubtitleTrackLoading(e,t){const{id:r,groupId:i,url:s,deliveryDirectives:n}=t;this.load({id:r,groupId:i,level:null,responseType:"text",type:vt.SUBTITLE_TRACK,url:s,deliveryDirectives:n})}load(e){var t;const r=this.hls.config;let i,s=this.getInternalLoader(e);if(s){const t=s.context;if(t&&t.url===e.url)return void T.trace("[playlist-loader]: playlist request ongoing");T.log("[playlist-loader]: aborting previous loader for type: "+e.type),s.abort()}if(i=e.type===vt.MANIFEST?r.manifestLoadPolicy.default:d({},r.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(e),null!=(t=e.deliveryDirectives)&&t.part){let t;if(e.type===vt.LEVEL&&null!==e.level?t=this.hls.levels[e.level].details:e.type===vt.AUDIO_TRACK&&null!==e.id?t=this.hls.audioTracks[e.id].details:e.type===vt.SUBTITLE_TRACK&&null!==e.id&&(t=this.hls.subtitleTracks[e.id].details),t){const e=t.partTarget,r=t.targetduration;if(e&&r){const t=1e3*Math.max(3*e,.8*r);i=d({},i,{maxTimeToFirstByteMs:Math.min(t,i.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(t,i.maxTimeToFirstByteMs)})}}}const n=i.errorRetry||i.timeoutRetry||{},a={loadPolicy:i,timeout:i.maxLoadTimeMs,maxRetry:n.maxNumRetry||0,retryDelay:n.retryDelayMs||0,maxRetryDelay:n.maxRetryDelayMs||0},o={onSuccess:(e,t,r,i)=>{const s=this.getInternalLoader(r);this.resetInternalLoader(r.type);const n=e.data;0===n.indexOf("#EXTM3U")?(t.parsing.start=performance.now(),dt.isMediaPlaylist(n)?this.handleTrackOrLevelPlaylist(e,t,r,i||null,s):this.handleMasterPlaylist(e,t,r,i)):this.handleManifestParsingError(e,r,new Error("no EXTM3U delimiter"),i||null,t)},onError:(e,t,r,i)=>{this.handleNetworkError(t,r,!1,e,i)},onTimeout:(e,t,r)=>{this.handleNetworkError(t,r,!0,void 0,e)}};s.load(e,a,o)}handleMasterPlaylist(e,t,r,i){const s=this.hls,n=e.data,a=bt(e,r),o=dt.parseMasterPlaylist(n,a);if(o.playlistParsingError)return void this.handleManifestParsingError(e,r,o.playlistParsingError,i,t);const{contentSteering:l,levels:d,sessionData:h,sessionKeys:c,startTimeOffset:u,variableList:p}=o;this.variableList=p;const{AUDIO:m=[],SUBTITLES:g,"CLOSED-CAPTIONS":y}=dt.parseMasterPlaylistMedia(n,a,o);if(m.length){const e=m.some(e=>!e.url);e||!d[0].audioCodec||d[0].attrs.AUDIO||(T.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),m.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new A({}),bitrate:0,url:""}))}s.trigger(f.MANIFEST_LOADED,{levels:d,audioTracks:m,subtitles:g,captions:y,contentSteering:l,url:a,stats:t,networkDetails:i,sessionData:h,sessionKeys:c,startTimeOffset:u,variableList:p})}handleTrackOrLevelPlaylist(e,t,r,i,s){const n=this.hls,{id:a,level:o,type:l}=r,d=bt(e,r),h=u(a)?a:0,c=u(o)?o:h,p=Et(r),m=dt.parseLevelPlaylist(e.data,d,c,p,h,this.variableList);if(l===vt.MANIFEST){const e={attrs:new A({}),bitrate:0,details:m,name:"",url:d};n.trigger(f.MANIFEST_LOADED,{levels:[e],audioTracks:[],url:d,stats:t,networkDetails:i,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),r.levelDetails=m,this.handlePlaylistLoaded(m,e,t,r,i,s)}handleManifestParsingError(e,t,r,i,s){this.hls.trigger(f.ERROR,{type:p.NETWORK_ERROR,details:m.MANIFEST_PARSING_ERROR,fatal:t.type===vt.MANIFEST,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:i,stats:s})}handleNetworkError(e,t,r=!1,i,s){let n=`A network ${r?"timeout":"error"+(i?" (status "+i.code+")":"")} occurred while loading ${e.type}`;e.type===vt.LEVEL?n+=`: ${e.level} id: ${e.id}`:e.type!==vt.AUDIO_TRACK&&e.type!==vt.SUBTITLE_TRACK||(n+=` id: ${e.id} group-id: "${e.groupId}"`);const a=new Error(n);T.warn("[playlist-loader]: "+n);let l=m.UNKNOWN,d=!1;const h=this.getInternalLoader(e);switch(e.type){case vt.MANIFEST:l=r?m.MANIFEST_LOAD_TIMEOUT:m.MANIFEST_LOAD_ERROR,d=!0;break;case vt.LEVEL:l=r?m.LEVEL_LOAD_TIMEOUT:m.LEVEL_LOAD_ERROR,d=!1;break;case vt.AUDIO_TRACK:l=r?m.AUDIO_TRACK_LOAD_TIMEOUT:m.AUDIO_TRACK_LOAD_ERROR,d=!1;break;case vt.SUBTITLE_TRACK:l=r?m.SUBTITLE_TRACK_LOAD_TIMEOUT:m.SUBTITLE_LOAD_ERROR,d=!1;break}h&&this.resetInternalLoader(e.type);const c={type:p.NETWORK_ERROR,details:l,fatal:d,url:e.url,loader:h,context:e,error:a,networkDetails:t,stats:s};if(i){const r=(null==t?void 0:t.url)||e.url;c.response=o({url:r,data:void 0},i)}this.hls.trigger(f.ERROR,c)}handlePlaylistLoaded(e,t,r,i,s,n){const a=this.hls,{type:o,level:l,id:d,groupId:h,deliveryDirectives:c}=i,u=bt(t,i),g=Et(i),y="number"===typeof i.level&&g===_t.MAIN?l:void 0;if(!e.fragments.length){const e=new Error("No Segments found in Playlist");return void a.trigger(f.ERROR,{type:p.NETWORK_ERROR,details:m.LEVEL_EMPTY_ERROR,fatal:!1,url:u,error:e,reason:e.message,response:t,context:i,level:y,parent:g,networkDetails:s,stats:r})}e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));const v=e.playlistParsingError;if(v)a.trigger(f.ERROR,{type:p.NETWORK_ERROR,details:m.LEVEL_PARSING_ERROR,fatal:!1,url:u,error:v,reason:v.message,response:t,context:i,level:y,parent:g,networkDetails:s,stats:r});else switch(e.live&&n&&(n.getCacheAge&&(e.ageHeader=n.getCacheAge()||0),n.getCacheAge&&!isNaN(e.ageHeader)||(e.ageHeader=0)),o){case vt.MANIFEST:case vt.LEVEL:a.trigger(f.LEVEL_LOADED,{details:e,level:y||0,id:d||0,stats:r,networkDetails:s,deliveryDirectives:c});break;case vt.AUDIO_TRACK:a.trigger(f.AUDIO_TRACK_LOADED,{details:e,id:d||0,groupId:h||"",stats:r,networkDetails:s,deliveryDirectives:c});break;case vt.SUBTITLE_TRACK:a.trigger(f.SUBTITLE_TRACK_LOADED,{details:e,id:d||0,groupId:h||"",stats:r,networkDetails:s,deliveryDirectives:c});break}}}function St(e,t){let r;try{r=new Event("addtrack")}catch(i){r=document.createEvent("Event"),r.initEvent("addtrack",!1,!1)}r.track=e,t.dispatchEvent(r)}function Lt(e,t){const r=e.mode;if("disabled"===r&&(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(i){T.debug("[texttrack-utils]: "+i);try{const r=new self.TextTrackCue(t.startTime,t.endTime,t.text);r.id=t.id,e.addCue(r)}catch(s){T.debug("[texttrack-utils]: Legacy TextTrackCue fallback failed: "+s)}}"disabled"===r&&(e.mode=r)}function At(e){const t=e.mode;if("disabled"===t&&(e.mode="hidden"),e.cues)for(let r=e.cues.length;r--;)e.removeCue(e.cues[r]);"disabled"===t&&(e.mode=t)}function wt(e,t,r,i){const s=e.mode;if("disabled"===s&&(e.mode="hidden"),e.cues&&e.cues.length>0){const s=kt(e.cues,t,r);for(let t=0;t<s.length;t++)i&&!i(s[t])||e.removeCue(s[t])}"disabled"===s&&(e.mode=s)}function Rt(e,t){if(t<e[0].startTime)return 0;const r=e.length-1;if(t>e[r].endTime)return-1;let i=0,s=r;while(i<=s){const n=Math.floor((s+i)/2);if(t<e[n].startTime)s=n-1;else{if(!(t>e[n].startTime&&i<r))return n;i=n+1}}return e[i].startTime-t<t-e[s].startTime?i:s}function kt(e,t,r){const i=[],s=Rt(e,t);if(s>-1)for(let n=s,a=e.length;n<a;n++){const s=e[n];if(s.startTime>=t&&s.endTime<=r)i.push(s);else if(s.startTime>r)return i}return i}var It={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"};const Dt=.25;function xt(){if("undefined"!==typeof self)return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}const Ct=(()=>{const e=xt();try{new e(0,Number.POSITIVE_INFINITY,"")}catch(t){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function Pt(e,t){return e.getTime()/1e3-t}function Ot(e){return Uint8Array.from(e.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}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_FLUSHING,this.onBufferFlushing,this),e.off(f.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(e,t){this.media=t.media}onMediaDetaching(){this.id3Track&&(At(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(e){const t=this.getID3Track(e.textTracks);return t.mode="hidden",t}getID3Track(e){if(this.media){for(let t=0;t<e.length;t++){const r=e[t];if("metadata"===r.kind&&"id3"===r.label)return St(r,this.media),r}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media)return;const{hls:{config:{enableEmsgMetadataCues:r,enableID3MetadataCues:i}}}=this;if(!r&&!i)return;const{samples:s}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));const n=xt();for(let a=0;a<s.length;a++){const e=s[a].type;if(e===It.emsg&&!r||!i)continue;const t=ae(s[a].data);if(t){const r=s[a].pts;let i=r+s[a].duration;i>Ct&&(i=Ct);const o=i-r;o<=0&&(i=r+Dt);for(let s=0;s<t.length;s++){const a=t[s];if(!se(a)){this.updateId3CueEnds(r,e);const t=new n(r,i,"");t.value=a,e&&(t.type=e),this.id3Track.addCue(t)}}}}}updateId3CueEnds(e,t){var r;const i=null==(r=this.id3Track)?void 0:r.cues;if(i)for(let s=i.length;s--;){const r=i[s];r.type===t&&r.startTime<e&&r.endTime===Ct&&(r.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:r,type:i}){const{id3Track:s,hls:n}=this;if(!n)return;const{config:{enableEmsgMetadataCues:a,enableID3MetadataCues:o}}=n;if(s&&(a||o)){let e;e="audio"===i?e=>e.type===It.audioId3&&o:"video"===i?e=>e.type===It.emsg&&a:e=>e.type===It.audioId3&&o||e.type===It.emsg&&a,wt(s,t,r,e)}}onLevelUpdated(e,{details:t}){if(!this.media||!t.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;const{dateRangeCuesAppended:r,id3Track:i}=this,{dateRanges:s}=t,n=Object.keys(s);if(i){const e=Object.keys(r).filter(e=>!n.includes(e));for(let t=e.length;t--;){const s=e[t];Object.keys(r[s].cues).forEach(e=>{i.removeCue(r[s].cues[e])}),delete r[s]}}const a=t.fragments[t.fragments.length-1];if(0===n.length||!u(null==a?void 0:a.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));const o=a.programDateTime/1e3-a.start,l=xt();for(let d=0;d<n.length;d++){const e=n[d],t=s[e],i=r[e],a=(null==i?void 0:i.cues)||{};let h=(null==i?void 0:i.durationKnown)||!1;const c=Pt(t.startDate,o);let u=Ct;const f=t.endDate;if(f)u=Pt(f,o),h=!0;else if(t.endOnNext&&!h){const e=n.reduce((e,r)=>{const i=s[r];return i.class===t.class&&i.id!==r&&i.startDate>t.startDate&&e.push(i),e},[]).sort((e,t)=>e.startDate.getTime()-t.startDate.getTime())[0];e&&(u=Pt(e.startDate,o),h=!0)}const p=Object.keys(t.attr);for(let r=0;r<p.length;r++){const s=p[r];if(!w(s))continue;let n=a[s];if(n)h&&!i.durationKnown&&(n.endTime=u);else{let r=t.attr[s];n=new l(c,u,""),R(s)&&(r=Ot(r)),n.value={key:s,data:r},n.type=It.dateRange,n.id=e,this.id3Track.addCue(n),a[s]=n}}r[e]={cues:a,dateRange:t,durationKnown:h}}}}class Ft{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=()=>this.timeupdate(),this.hls=e,this.config=e.config,this.registerListeners()}get latency(){return this._latency||0}get maxLatency(){const{config:e,levelDetails:t}=this;return void 0!==e.liveMaxLatencyDuration?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){const{levelDetails:e}=this;if(null===e)return null;const{holdBack:t,partHoldBack:r,targetduration:i}=e,{liveSyncDuration:s,liveSyncDurationCount:n,lowLatencyMode:a}=this.config,o=this.hls.userConfig;let l=a&&r||t;(o.liveSyncDuration||o.liveSyncDurationCount||0===l)&&(l=void 0!==s?s:n*i);const d=i,h=1;return l+Math.min(this.stallCount*h,d)}get liveSyncPosition(){const e=this.estimateLiveEdge(),t=this.targetLatency,r=this.levelDetails;if(null===e||null===t||null===r)return null;const i=r.edge,s=e-t-this.edgeStalled,n=i-r.totalduration,a=i-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(n,s),a)}get drift(){const{levelDetails:e}=this;return null===e?1:e.drift}get edgeStalled(){const{levelDetails:e}=this;if(null===e)return 0;const t=3*(this.config.lowLatencyMode&&e.partTarget||e.targetduration);return Math.max(e.age-t,0)}get forwardBufferLength(){const{media:e,levelDetails:t}=this;if(!e||!t)return 0;const r=e.buffered.length;return(r?e.buffered.end(r-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(f.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(f.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(f.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(f.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(f.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(f.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(f.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(f.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(f.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(f.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)}onManifestLoading(){this.levelDetails=null,this._latency=null,this.stallCount=0}onLevelUpdated(e,{details:t}){this.levelDetails=t,t.advanced&&this.timeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)}onError(e,t){var r;t.details===m.BUFFER_STALLED_ERROR&&(this.stallCount++,null!=(r=this.levelDetails)&&r.live&&T.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))}timeupdate(){const{media:e,levelDetails:t}=this;if(!e||!t)return;this.currentTime=e.currentTime;const r=this.computeLatency();if(null===r)return;this._latency=r;const{lowLatencyMode:i,maxLiveSyncPlaybackRate:s}=this.config;if(!i||1===s)return;const n=this.targetLatency;if(null===n)return;const a=r-n,o=Math.min(this.maxLatency,n+t.targetduration),l=a<o;if(t.live&&l&&a>.05&&this.forwardBufferLength>1){const t=Math.min(2,Math.max(1,s)),r=Math.round(2/(1+Math.exp(-.75*a-this.edgeStalled))*20)/20;e.playbackRate=Math.min(t,Math.max(1,r))}else 1!==e.playbackRate&&0!==e.playbackRate&&(e.playbackRate=1)}estimateLiveEdge(){const{levelDetails:e}=this;return null===e?null:e.edge+e.age}computeLatency(){const e=this.estimateLiveEdge();return null===e?null:e-this.currentTime}}const Nt=["NONE","TYPE-0","TYPE-1",null];var Ut={No:"",Yes:"YES",v2:"v2"};function Bt(e,t){const{canSkipUntil:r,canSkipDateRanges:i,endSN:s}=e,n=void 0!==t?t-s:0;return r&&n<r?i?Ut.v2:Ut.Yes:Ut.No}class $t{constructor(e,t,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=r}addDirectives(e){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 Gt{constructor(e){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=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.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.unknownCodecs=e.unknownCodecs,this.codecSet=[e.videoCodec,e.audioCodec].filter(e=>e).join(",").replace(/\.[^.,]+/g,"")}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get attrs(){return this._attrs[this._urlId]}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get uri(){return this.url[this._urlId]||""}get urlId(){return this._urlId}set urlId(e){const t=e%this.url.length;this._urlId!==t&&(this.fragmentError=0,this.loadError=0,this.details=void 0,this._urlId=t)}get audioGroupId(){var e;return null==(e=this.audioGroupIds)?void 0:e[this.urlId]}get textGroupId(){var e;return null==(e=this.textGroupIds)?void 0:e[this.urlId]}addFallback(e){this.url.push(e.url),this._attrs.push(e.attrs)}}function jt(e,t){const r=t.startPTS;if(u(r)){let i,s=0;t.sn>e.sn?(s=r-e.start,i=e):(s=e.start-r,i=t),i.duration!==s&&(i.duration=s)}else if(t.sn>e.sn){const r=e.cc===t.cc;r&&e.minEndPTS?t.start=e.start+(e.minEndPTS-e.start):t.start=e.start+e.duration}else t.start=Math.max(e.start-t.duration,0)}function Kt(e,t,r,i,s,n){const a=i-r;a<=0&&(T.warn("Fragment should have a positive duration",t),i=r+t.duration,n=s+t.duration);let o=r,l=i;const d=t.startPTS,h=t.endPTS;if(u(d)){const e=Math.abs(d-r);u(t.deltaPTS)?t.deltaPTS=Math.max(e,t.deltaPTS):t.deltaPTS=e,o=Math.max(r,d),r=Math.min(r,d),s=Math.min(s,t.startDTS),l=Math.min(i,h),i=Math.max(i,h),n=Math.max(n,t.endDTS)}const c=r-t.start;0!==t.start&&(t.start=r),t.duration=i-t.start,t.startPTS=r,t.maxStartPTS=o,t.startDTS=s,t.endPTS=i,t.minEndPTS=l,t.endDTS=n;const f=t.sn;if(!e||f<e.startSN||f>e.endSN)return 0;let p;const m=f-e.startSN,g=e.fragments;for(g[m]=t,p=m;p>0;p--)jt(g[p],g[p-1]);for(p=m;p<g.length-1;p++)jt(g[p],g[p+1]);return e.fragmentHint&&jt(g[g.length-1],e.fragmentHint),e.PTSKnown=e.alignedSliding=!0,c}function Vt(e,t){let r=null;const i=e.fragments;for(let l=i.length-1;l>=0;l--){const e=i[l].initSegment;if(e){r=e;break}}e.fragmentHint&&delete e.fragmentHint.endPTS;let s,n=0;if(zt(e,t,(e,i)=>{e.relurl&&(n=e.cc-i.cc),u(e.startPTS)&&u(e.endPTS)&&(i.start=i.startPTS=e.startPTS,i.startDTS=e.startDTS,i.maxStartPTS=e.maxStartPTS,i.endPTS=e.endPTS,i.endDTS=e.endDTS,i.minEndPTS=e.minEndPTS,i.duration=e.endPTS-e.startPTS,i.duration&&(s=i),t.PTSKnown=t.alignedSliding=!0),i.elementaryStreams=e.elementaryStreams,i.loader=e.loader,i.stats=e.stats,i.urlId=e.urlId,e.initSegment&&(i.initSegment=e.initSegment,r=e.initSegment)}),r){const e=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments;e.forEach(e=>{var t;e.initSegment&&e.initSegment.relurl!==(null==(t=r)?void 0:t.relurl)||(e.initSegment=r)})}if(t.skippedSegments)if(t.deltaUpdateFailed=t.fragments.some(e=>!e),t.deltaUpdateFailed){T.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let e=t.skippedSegments;e--;)t.fragments.shift();t.startSN=t.fragments[0].sn,t.startCC=t.fragments[0].cc}else t.canSkipDateRanges&&(t.dateRanges=Ht(e.dateRanges,t.dateRanges,t.recentlyRemovedDateranges));const a=t.fragments;if(n){T.warn("discontinuity sliding from playlist, take drift into account");for(let e=0;e<a.length;e++)a[e].cc+=n}t.skippedSegments&&(t.startCC=t.fragments[0].cc),Yt(e.partList,t.partList,(e,t)=>{t.elementaryStreams=e.elementaryStreams,t.stats=e.stats}),s?Kt(t,s,s.startPTS,s.endPTS,s.startDTS,s.endDTS):Wt(e,t),a.length&&(t.totalduration=t.edge-a[0].start),t.driftStartTime=e.driftStartTime,t.driftStart=e.driftStart;const o=t.advancedDateTime;if(t.advanced&&o){const e=t.edge;t.driftStart||(t.driftStartTime=o,t.driftStart=e),t.driftEndTime=o,t.driftEnd=e}else t.driftEndTime=e.driftEndTime,t.driftEnd=e.driftEnd,t.advancedDateTime=e.advancedDateTime}function Ht(e,t,r){const i=d({},e);return r&&r.forEach(e=>{delete i[e]}),Object.keys(t).forEach(e=>{const r=new k(t[e].attr,i[e]);r.isValid?i[e]=r:T.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(t[e].attr)}"`)}),i}function Yt(e,t,r){if(e&&t){let i=0;for(let s=0,n=e.length;s<=n;s++){const n=e[s],a=t[s+i];n&&a&&n.index===a.index&&n.fragment.sn===a.fragment.sn?r(n,a):i--}}}function zt(e,t,r){const i=t.skippedSegments,s=Math.max(e.startSN,t.startSN)-t.startSN,n=(e.fragmentHint?1:0)+(i?t.endSN:Math.min(e.endSN,t.endSN))-t.startSN,a=t.startSN-e.startSN,o=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,l=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments;for(let d=s;d<=n;d++){const e=l[a+d];let s=o[d];i&&!s&&d<i&&(s=t.fragments[d]=e),e&&s&&r(e,s)}}function Wt(e,t){const r=t.startSN+t.skippedSegments-e.startSN,i=e.fragments;r<0||r>=i.length||qt(t,i[r].start)}function qt(e,t){if(t){const r=e.fragments;for(let i=e.skippedSegments;i<r.length;i++)r[i].start+=t;e.fragmentHint&&(e.fragmentHint.start+=t)}}function Xt(e,t=1/0){let r=1e3*e.targetduration;if(e.updated){const i=e.fragments,s=4;if(i.length&&r*s>t){const e=1e3*i[i.length-1].duration;e<r&&(r=e)}}else r/=2;return Math.round(r)}function Qt(e,t,r){if(null==e||!e.details)return null;const i=e.details;let s=i.fragments[t-i.startSN];return s||(s=i.fragmentHint,s&&s.sn===t?s:t<i.startSN&&r&&r.sn===t?r:null)}function Zt(e,t,r){var i;return null!=e&&e.details?Jt(null==(i=e.details)?void 0:i.partList,t,r):null}function Jt(e,t,r){if(e)for(let i=e.length;i--;){const s=e[i];if(s.index===r&&s.fragment.sn===t)return s}return null}function er(e){switch(e.details){case m.FRAG_LOAD_TIMEOUT:case m.KEY_LOAD_TIMEOUT:case m.LEVEL_LOAD_TIMEOUT:case m.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function tr(e,t){const r=er(t);return e.default[(r?"timeout":"error")+"Retry"]}function rr(e,t){const r="linear"===e.backoff?1:Math.pow(2,t);return Math.min(r*e.retryDelayMs,e.maxRetryDelayMs)}function ir(e){return o(o({},e),{errorRetry:null,timeoutRetry:null})}function sr(e,t,r,i){return!!e&&t<e.maxNumRetry&&(nr(i)||!!r)}function nr(e){return 0===e&&!1===navigator.onLine||!!e&&(e<400||e>499)}const ar={search:function(e,t){let r=0,i=e.length-1,s=null,n=null;while(r<=i){s=(r+i)/2|0,n=e[s];const a=t(n);if(a>0)r=s+1;else{if(!(a<0))return n;i=s-1}}return null}};function or(e,t,r){if(null===t||!Array.isArray(e)||!e.length||!u(t))return null;const i=e[0].programDateTime;if(t<(i||0))return null;const s=e[e.length-1].endProgramDateTime;if(t>=(s||0))return null;r=r||0;for(let n=0;n<e.length;++n){const i=e[n];if(hr(t,r,i))return i}return null}function lr(e,t,r=0,i=0){let s=null;if(e?s=t[e.sn-t[0].sn+1]||null:0===r&&0===t[0].start&&(s=t[0]),s&&0===dr(r,i,s))return s;const n=ar.search(t,dr.bind(null,r,i));return!n||n===e&&s?s:n}function dr(e=0,t=0,r){if(r.start<=e&&r.start+r.duration>e)return 0;const i=Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return r.start+r.duration-i<=e?1:r.start-i>e&&r.start?-1:0}function hr(e,t,r){const i=1e3*Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0)),s=r.endProgramDateTime||0;return s-i>e}function cr(e,t){return ar.search(e,e=>e.cc<t?1:e.cc>t?-1:0)}const ur=3e5;var fr={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},pr={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4};class mr{constructor(e){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=e,this.log=T.log.bind(T,"[info]:"),this.warn=T.warn.bind(T,"[warning]:"),this.error=T.error.bind(T,"[error]:"),this.registerListeners()}registerListeners(){const e=this.hls;e.on(f.ERROR,this.onError,this),e.on(f.MANIFEST_LOADING,this.onManifestLoading,this),e.on(f.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const e=this.hls;e&&(e.off(f.ERROR,this.onError,this),e.off(f.ERROR,this.onErrorOut,this),e.off(f.MANIFEST_LOADING,this.onManifestLoading,this),e.off(f.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(e){this.playlistError=0}stopLoad(){}getVariantLevelIndex(e){return(null==e?void 0:e.type)===_t.MAIN?e.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(e,t){var r,i;if(t.fatal)return;const s=this.hls,n=t.context;switch(t.details){case m.FRAG_LOAD_ERROR:case m.FRAG_LOAD_TIMEOUT:case m.KEY_LOAD_ERROR:case m.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case m.FRAG_PARSING_ERROR:if(null!=(r=t.frag)&&r.gap)return void(t.errorAction={action:fr.DoNothing,flags:pr.None});case m.FRAG_GAP:case m.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=fr.SendAlternateToPenaltyBox);case m.LEVEL_EMPTY_ERROR:case m.LEVEL_PARSING_ERROR:{var a,o;const e=t.parent===_t.MAIN?t.level:s.loadLevel;t.details===m.LEVEL_EMPTY_ERROR&&null!=(a=t.context)&&null!=(o=a.levelDetails)&&o.live?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,e):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,e))}return;case m.LEVEL_LOAD_ERROR:case m.LEVEL_LOAD_TIMEOUT:return void("number"===typeof(null==n?void 0:n.level)&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.level)));case m.AUDIO_TRACK_LOAD_ERROR:case m.AUDIO_TRACK_LOAD_TIMEOUT:case m.SUBTITLE_LOAD_ERROR:case m.SUBTITLE_TRACK_LOAD_TIMEOUT:if(n){const e=s.levels[s.loadLevel];if(e&&(n.type===vt.AUDIO_TRACK&&n.groupId===e.audioGroupId||n.type===vt.SUBTITLE_TRACK&&n.groupId===e.textGroupId))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,s.loadLevel),t.errorAction.action=fr.SendAlternateToPenaltyBox,void(t.errorAction.flags=pr.MoveAllAlternatesMatchingHost)}return;case m.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{const e=s.levels[s.loadLevel],r=null==e?void 0:e.attrs["HDCP-LEVEL"];r&&(t.errorAction={action:fr.SendAlternateToPenaltyBox,flags:pr.MoveAllAlternatesMatchingHDCP,hdcpLevel:r})}return;case m.BUFFER_ADD_CODEC_ERROR:case m.REMUX_ALLOC_ERROR:return void(t.errorAction=this.getLevelSwitchAction(t,null!=(i=t.level)?i:s.loadLevel));case m.INTERNAL_EXCEPTION:case m.BUFFER_APPENDING_ERROR:case m.BUFFER_APPEND_ERROR:case m.BUFFER_FULL_ERROR:case m.LEVEL_SWITCH_ERROR:case m.BUFFER_STALLED_ERROR:case m.BUFFER_SEEK_OVER_HOLE:case m.BUFFER_NUDGE_ON_STALL:return void(t.errorAction={action:fr.DoNothing,flags:pr.None})}if(t.type===p.KEY_SYSTEM_ERROR){const e=this.getVariantLevelIndex(t.frag);return t.levelRetry=!1,void(t.errorAction=this.getLevelSwitchAction(t,e))}}getPlaylistRetryOrSwitchAction(e,t){var r;const i=this.hls,s=tr(i.config.playlistLoadPolicy,e),n=this.playlistError++,a=null==(r=e.response)?void 0:r.code,o=sr(s,n,er(e),a);if(o)return{action:fr.RetryRequest,flags:pr.None,retryConfig:s,retryCount:n};const l=this.getLevelSwitchAction(e,t);return s&&(l.retryConfig=s,l.retryCount=n),l}getFragRetryOrSwitchAction(e){const t=this.hls,r=this.getVariantLevelIndex(e.frag),i=t.levels[r],{fragLoadPolicy:s,keyLoadPolicy:n}=t.config,a=tr(e.details.startsWith("key")?n:s,e),o=t.levels.reduce((e,t)=>e+t.fragmentError,0);if(i){var l;e.details!==m.FRAG_GAP&&i.fragmentError++;const t=null==(l=e.response)?void 0:l.code,r=sr(a,o,er(e),t);if(r)return{action:fr.RetryRequest,flags:pr.None,retryConfig:a,retryCount:o}}const d=this.getLevelSwitchAction(e,r);return a&&(d.retryConfig=a,d.retryCount=o),d}getLevelSwitchAction(e,t){const r=this.hls;null!==t&&void 0!==t||(t=r.loadLevel);const i=this.hls.levels[t];if(i&&(i.loadError++,r.autoLevelEnabled)){var s,n;let t=-1;const{levels:a,loadLevel:o,minAutoLevel:l,maxAutoLevel:d}=r,h=null==(s=e.frag)?void 0:s.type,{type:c,groupId:u}=null!=(n=e.context)?n:{};for(let r=a.length;r--;){const s=(r+o)%a.length;if(s!==o&&s>=l&&s<=d&&0===a[s].loadError){const r=a[s];if(e.details===m.FRAG_GAP&&e.frag){const t=a[s].details;if(t){const r=lr(e.frag,t.fragments,e.frag.start);if(null!=r&&r.gap)continue}}else{if(c===vt.AUDIO_TRACK&&u===r.audioGroupId||c===vt.SUBTITLE_TRACK&&u===r.textGroupId)continue;if(h===_t.AUDIO&&i.audioGroupId===r.audioGroupId||h===_t.SUBTITLE&&i.textGroupId===r.textGroupId)continue}t=s;break}}if(t>-1&&r.loadLevel!==t)return e.levelRetry=!0,this.playlistError=0,{action:fr.SendAlternateToPenaltyBox,flags:pr.None,nextAutoLevel:t}}return{action:fr.SendAlternateToPenaltyBox,flags:pr.MoveAllAlternatesMatchingHost}}onErrorOut(e,t){var r;switch(null==(r=t.errorAction)?void 0:r.action){case fr.DoNothing:break;case fr.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===m.FRAG_GAP||(t.fatal=!0);break}t.fatal&&this.hls.stopLoad()}sendAlternateToPenaltyBox(e){const t=this.hls,r=e.errorAction;if(!r)return;const{flags:i,hdcpLevel:s,nextAutoLevel:n}=r;switch(i){case pr.None:this.switchLevel(e,n);break;case pr.MoveAllAlternatesMatchingHost:r.resolved||(r.resolved=this.redundantFailover(e));break;case pr.MoveAllAlternatesMatchingHDCP:s&&(t.maxHdcpLevel=Nt[Nt.indexOf(s)-1],r.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}r.resolved||this.switchLevel(e,n)}switchLevel(e,t){void 0!==t&&e.errorAction&&(this.warn(`switching to level ${t} after ${e.details}`),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)}redundantFailover(e){const{hls:t,penalizedRenditions:r}=this,i=e.parent===_t.MAIN?e.level:t.loadLevel,s=t.levels[i],n=s.url.length,a=e.frag?e.frag.urlId:s.urlId;s.urlId!==a||e.frag&&!s.details||this.penalizeRendition(s,e);for(let o=1;o<n;o++){const l=(a+o)%n,d=r[l];if(!d||gr(d,e,r[a]))return this.warn(`Switching to Redundant Stream ${l+1}/${n}: "${s.url[l]}" after ${e.details}`),this.playlistError=0,t.levels.forEach(e=>{e.urlId=l}),t.nextLoadLevel=i,!0}return!1}penalizeRendition(e,t){const{penalizedRenditions:r}=this,i=r[e.urlId]||{lastErrorPerfMs:0,errors:[],details:void 0};i.lastErrorPerfMs=performance.now(),i.errors.push(t),i.details=e.details,r[e.urlId]=i}}function gr(e,t,r){if(performance.now()-e.lastErrorPerfMs>ur)return!0;const i=e.details;if(t.details===m.FRAG_GAP&&i&&t.frag){const e=t.frag.start,r=lr(null,i.fragments,e);if(r&&!r.gap)return!0}if(r&&e.errors.length<r.errors.length){const r=e.errors[e.errors.length-1];if(i&&r.frag&&t.frag&&Math.abs(r.frag.start-t.frag.start)>3*i.targetduration)return!0}return!1}class yr{constructor(e,t){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=T.log.bind(T,t+":"),this.warn=T.warn.bind(T,t+":"),this.hls=e}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){clearTimeout(this.timer),this.timer=-1}startLoad(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(e,t){const r=null==t?void 0:t.renditionReports;if(r){let s=-1;for(let n=0;n<r.length;n++){const a=r[n];let o;try{o=new self.URL(a.URI,t.url).href}catch(i){T.warn("Could not construct new URL for Rendition Report: "+i),o=a.URI||""}if(o===e){s=n;break}o===e.substring(0,o.length)&&(s=n)}if(-1!==s){const e=r[s],i=parseInt(e["LAST-MSN"])||(null==t?void 0:t.lastPartSn);let n=parseInt(e["LAST-PART"])||(null==t?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){const e=Math.min(t.age-t.partTarget,t.targetduration);n>=0&&e>t.partTarget&&(n+=1)}return new $t(i,n>=0?n:void 0,Ut.No)}}}loadPlaylist(e){-1===this.requestScheduled&&(this.requestScheduled=self.performance.now())}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}shouldReloadPlaylist(e){return-1===this.timer&&-1===this.requestScheduled&&this.shouldLoadPlaylist(e)}playlistLoaded(e,t,r){const{details:i,stats:s}=t,n=self.performance.now(),a=s.loading.first?Math.max(0,n-s.loading.first):0;if(i.advancedDateTime=Date.now()-a,i.live||null!=r&&r.live){if(i.reloaded(r),r&&this.log(`live playlist ${e} ${i.advanced?"REFRESHED "+i.lastPartSn+"-"+i.lastPartIndex:i.updated?"UPDATED":"MISSED"}`),r&&i.fragments.length>0&&Vt(r,i),!this.canLoad||!i.live)return;let a,o=void 0,l=void 0;if(i.canBlockReload&&i.endSN&&i.advanced){const e=this.hls.config.lowLatencyMode,s=i.lastPartSn,n=i.endSN,d=i.lastPartIndex,h=-1!==d,c=s===n,u=e?0:d;h?(o=c?n+1:s,l=c?u:d+1):o=n+1;const f=i.age,p=f+i.ageHeader;let m=Math.min(p-i.partTarget,1.5*i.targetduration);if(m>0){if(r&&m>r.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${r.tuneInGoal} to: ${m} with playlist age: ${i.age}`),m=0;else{const e=Math.floor(m/i.targetduration);if(o+=e,void 0!==l){const e=Math.round(m%i.targetduration/i.partTarget);l+=e}this.log(`CDN Tune-in age: ${i.ageHeader}s last advanced ${f.toFixed(2)}s goal: ${m} skip sn ${e} to part ${l}`)}i.tuneInGoal=m}if(a=this.getDeliveryDirectives(i,t.deliveryDirectives,o,l),e||!c)return void this.loadPlaylist(a)}else(i.canBlockReload||i.canSkipUntil)&&(a=this.getDeliveryDirectives(i,t.deliveryDirectives,o,l));const d=this.hls.mainForwardBufferInfo,h=d?d.end-d.len:0,c=1e3*(i.edge-h),u=Xt(i,c);i.updated&&n>this.requestScheduled+u&&(this.requestScheduled=s.loading.start),void 0!==o&&i.canBlockReload?this.requestScheduled=s.loading.first+u-(1e3*i.partTarget||1e3):-1===this.requestScheduled||this.requestScheduled+u<n?this.requestScheduled=n:this.requestScheduled-n<=0&&(this.requestScheduled+=u);let f=this.requestScheduled-n;f=Math.max(0,f),this.log(`reload live playlist ${e} in ${Math.round(f)} ms`),this.timer=self.setTimeout(()=>this.loadPlaylist(a),f)}else this.clearTimer()}getDeliveryDirectives(e,t,r,i){let s=Bt(e,r);return null!=t&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,i=t.part,s=Ut.No),new $t(r,i,s)}checkRetry(e){const t=e.details,r=er(e),i=e.errorAction,{action:s,retryCount:n=0,retryConfig:a}=i||{},o=!!i&&!!a&&(s===fr.RetryRequest||!i.resolved&&s===fr.SendAlternateToPenaltyBox);if(o){var l;if(this.requestScheduled=-1,n>=a.maxNumRetry)return!1;if(r&&null!=(l=e.context)&&l.deliveryDirectives)this.warn(`Retrying playlist loading ${n+1}/${a.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{const e=rr(a,n);this.timer=self.setTimeout(()=>this.loadPlaylist(),e),this.warn(`Retrying playlist loading ${n+1}/${a.maxNumRetry} after "${t}" in ${e}ms`)}e.levelRetry=!0,i.resolved=!0}return o}}let vr;class _r extends yr{constructor(e,t){super(e,"[level-controller]"),this._levels=[],this._firstLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=t,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(f.MANIFEST_LOADING,this.onManifestLoading,this),e.on(f.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(f.LEVEL_LOADED,this.onLevelLoaded,this),e.on(f.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(f.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(f.FRAG_LOADED,this.onFragLoaded,this),e.on(f.ERROR,this.onError,this)}_unregisterListeners(){const{hls:e}=this;e.off(f.MANIFEST_LOADING,this.onManifestLoading,this),e.off(f.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(f.LEVEL_LOADED,this.onLevelLoaded,this),e.off(f.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(f.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(f.FRAG_LOADED,this.onFragLoaded,this),e.off(f.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}startLoad(){const e=this._levels;e.forEach(e=>{e.loadError=0,e.fragmentError=0}),super.startLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[]}onManifestLoading(e,t){this.resetLevels()}onManifestLoaded(e,t){const r=[],i={};let s;t.levels.forEach(e=>{var t;const n=e.attrs;-1!==(null==(t=e.audioCodec)?void 0:t.indexOf("mp4a.40.34"))&&(vr||(vr=/chrome|firefox/i.test(navigator.userAgent)),vr&&(e.audioCodec=void 0));const{AUDIO:a,CODECS:o,"FRAME-RATE":l,"PATHWAY-ID":d,RESOLUTION:h,SUBTITLES:c}=n,u=(d||".")+"-",f=`${u}${e.bitrate}-${h}-${l}-${o}`;s=i[f],s?s.addFallback(e):(s=new Gt(e),i[f]=s,r.push(s)),Er(s,"audio",a),Er(s,"text",c)}),this.filterAndSortMediaOptions(r,t)}filterAndSortMediaOptions(e,t){let r=[],i=[],s=!1,n=!1,a=!1,o=e.filter(({audioCodec:e,videoCodec:t,width:r,height:i,unknownCodecs:o})=>(s||(s=!(!r||!i)),n||(n=!!t),a||(a=!!e),!(null!=o&&o.length)&&(!e||it(e,"audio"))&&(!t||it(t,"video"))));if((s||n)&&a&&(o=o.filter(({videoCodec:e,width:t,height:r})=>!!e||!(!t||!r))),0===o.length)return void Promise.resolve().then(()=>{if(this.hls){const e=new Error("no level with compatible codecs found in manifest");this.hls.trigger(f.ERROR,{type:p.MEDIA_ERROR,details:m.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:e,reason:e.message})}});t.audioTracks&&(r=t.audioTracks.filter(e=>!e.audioCodec||it(e.audioCodec,"audio")),br(r)),t.subtitles&&(i=t.subtitles,br(i));const l=o.slice(0);o.sort((e,t)=>e.attrs["HDCP-LEVEL"]!==t.attrs["HDCP-LEVEL"]?(e.attrs["HDCP-LEVEL"]||"")>(t.attrs["HDCP-LEVEL"]||"")?1:-1:e.bitrate!==t.bitrate?e.bitrate-t.bitrate:e.attrs["FRAME-RATE"]!==t.attrs["FRAME-RATE"]?e.attrs.decimalFloatingPoint("FRAME-RATE")-t.attrs.decimalFloatingPoint("FRAME-RATE"):e.attrs.SCORE!==t.attrs.SCORE?e.attrs.decimalFloatingPoint("SCORE")-t.attrs.decimalFloatingPoint("SCORE"):s&&e.height!==t.height?e.height-t.height:0);let d=l[0];if(this.steering&&(o=this.steering.filterParsedLevels(o),o.length!==l.length))for(let u=0;u<l.length;u++)if(l[u].pathwayId===o[0].pathwayId){d=l[u];break}this._levels=o;for(let u=0;u<o.length;u++)if(o[u]===d){this._firstLevel=u,this.log(`manifest loaded, ${o.length} level(s) found, first bitrate: ${d.bitrate}`);break}const h=a&&!n,c={levels:o,audioTracks:r,subtitleTracks:i,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:a,video:n,altAudio:!h&&r.some(e=>!!e.url)};this.hls.trigger(f.MANIFEST_PARSED,c),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}get levels(){return 0===this._levels.length?null:this._levels}get level(){return this.currentLevelIndex}set level(e){const t=this._levels;if(0===t.length)return;if(e<0||e>=t.length){const r=new Error("invalid level idx"),i=e<0;if(this.hls.trigger(f.ERROR,{type:p.OTHER_ERROR,details:m.LEVEL_SWITCH_ERROR,level:e,fatal:i,error:r,reason:r.message}),i)return;e=Math.min(e,t.length-1)}const r=this.currentLevelIndex,i=this.currentLevel,s=i?i.attrs["PATHWAY-ID"]:void 0,n=t[e],a=n.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=n,r===e&&n.details&&i&&s===a)return;this.log(`Switching to level ${e}${a?" with Pathway "+a:""} from level ${r}${s?" with Pathway "+s:""}`);const o=d({},n,{level:e,maxBitrate:n.maxBitrate,attrs:n.attrs,uri:n.uri,urlId:n.urlId});delete o._attrs,delete o._urlId,this.hls.trigger(f.LEVEL_SWITCHING,o);const l=n.details;if(!l||l.live){const e=this.switchParams(n.uri,null==i?void 0:i.details);this.loadPlaylist(e)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}get firstLevel(){return this._firstLevel}set firstLevel(e){this._firstLevel=e}get startLevel(){if(void 0===this._startLevel){const e=this.hls.config.startLevel;return void 0!==e?e:this._firstLevel}return this._startLevel}set startLevel(e){this._startLevel=e}onError(e,t){!t.fatal&&t.context&&t.context.type===vt.LEVEL&&t.context.level===this.level&&this.checkRetry(t)}onFragLoaded(e,{frag:t}){if(void 0!==t&&t.type===_t.MAIN){const e=this._levels[t.level];void 0!==e&&(e.loadError=0)}}onLevelLoaded(e,t){var r;const{level:i,details:s}=t,n=this._levels[i];var a;if(!n)return this.warn("Invalid level index "+i),void(null!=(a=t.deliveryDirectives)&&a.skip&&(s.deltaUpdateFailed=!0));i===this.currentLevelIndex?(0===n.fragmentError&&(n.loadError=0),this.playlistLoaded(i,t,n.details)):null!=(r=t.deliveryDirectives)&&r.skip&&(s.deltaUpdateFailed=!0)}onAudioTrackSwitched(e,t){const r=this.currentLevel;if(!r)return;const i=this.hls.audioTracks[t.id].groupId;if(r.audioGroupIds&&r.audioGroupId!==i){let e=-1;for(let t=0;t<r.audioGroupIds.length;t++)if(r.audioGroupIds[t]===i){e=t;break}-1!==e&&e!==r.urlId&&(r.urlId=e,this.canLoad&&this.startLoad())}}loadPlaylist(e){super.loadPlaylist();const t=this.currentLevelIndex,r=this.currentLevel;if(r&&this.shouldLoadPlaylist(r)){const s=r.urlId;let n=r.uri;if(e)try{n=e.addDirectives(n)}catch(i){this.warn("Could not construct new URL with HLS Delivery Directives: "+i)}const a=r.attrs["PATHWAY-ID"];this.log(`Loading level index ${t}${void 0!==(null==e?void 0:e.msn)?" at sn "+e.msn+" part "+e.part:""} with${a?" Pathway "+a:""} URI ${s+1}/${r.url.length} ${n}`),this.clearTimer(),this.hls.trigger(f.LEVEL_LOADING,{url:n,level:t,id:s,deliveryDirectives:e||null})}}get nextLoadLevel(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}removeLevel(e,t){const r=(e,r)=>r!==t,i=this._levels.filter((i,s)=>s!==e||(i.url.length>1&&void 0!==t?(i.url=i.url.filter(r),i.audioGroupIds&&(i.audioGroupIds=i.audioGroupIds.filter(r)),i.textGroupIds&&(i.textGroupIds=i.textGroupIds.filter(r)),i.urlId=0,!0):(this.steering&&this.steering.removeLevel(i),!1)));this.hls.trigger(f.LEVELS_UPDATED,{levels:i})}onLevelsUpdated(e,{levels:t}){t.forEach((e,t)=>{const{details:r}=e;null!=r&&r.fragments&&r.fragments.forEach(e=>{e.level=t})}),this._levels=t}}function Er(e,t,r){r&&("audio"===t?(e.audioGroupIds||(e.audioGroupIds=[]),e.audioGroupIds[e.url.length-1]=r):"text"===t&&(e.textGroupIds||(e.textGroupIds=[]),e.textGroupIds[e.url.length-1]=r))}function br(e){const t={};e.forEach(e=>{const r=e.groupId||"";e.id=t[r]=t[r]||0,t[r]++})}var Tr={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};class Sr{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.on(f.BUFFER_APPENDED,this.onBufferAppended,this),e.on(f.FRAG_BUFFERED,this.onFragBuffered,this),e.on(f.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){const{hls:e}=this;e.off(f.BUFFER_APPENDED,this.onBufferAppended,this),e.off(f.FRAG_BUFFERED,this.onFragBuffered,this),e.off(f.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){const r=this.activePartLists[t];if(r)for(let i=r.length;i--;){const t=r[i];if(!t)break;const s=t.end;if(t.start<=e&&null!==s&&e<=s)return t}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){const{fragments:r}=this,i=Object.keys(r);for(let s=i.length;s--;){const n=r[i[s]];if((null==n?void 0:n.body.type)===t&&n.buffered){const t=n.body;if(t.start<=e&&e<=t.end)return t}}return null}detectEvictedFragments(e,t,r,i){this.timeRanges&&(this.timeRanges[e]=t);const s=(null==i?void 0:i.fragment.sn)||-1;Object.keys(this.fragments).forEach(i=>{const n=this.fragments[i];if(!n)return;if(s>=n.body.sn)return;if(!n.buffered&&!n.loaded)return void(n.body.type===r&&this.removeFragment(n.body));const a=n.range[e];a&&a.time.some(e=>{const r=!this.isTimeBuffered(e.startPTS,e.endPTS,t);return r&&this.removeFragment(n.body),r})})}detectPartialFragments(e){const t=this.timeRanges,{frag:r,part:i}=e;if(!t||"initSegment"===r.sn)return;const s=Ar(r),n=this.fragments[s];if(!n||n.buffered&&r.gap)return;const a=!r.relurl;if(Object.keys(t).forEach(e=>{const s=r.elementaryStreams[e];if(!s)return;const o=t[e],l=a||!0===s.partial;n.range[e]=this.getBufferedTimes(r,i,l,o)}),n.loaded=null,Object.keys(n.range).length){n.buffered=!0;const e=n.body.endList=r.endList||n.body.endList;e&&(this.endListFragments[n.body.type]=n),Lr(n)||this.removeParts(r.sn-1,r.type)}else this.removeFragment(n.body)}removeParts(e,t){const r=this.activePartLists[t];r&&(this.activePartLists[t]=r.filter(t=>t.fragment.sn>=e))}fragBuffered(e,t){const r=Ar(e);let i=this.fragments[r];!i&&t&&(i=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),i&&(i.loaded=null,i.buffered=!0)}getBufferedTimes(e,t,r,i){const s={time:[],partial:r},n=e.start,a=e.end,o=e.minEndPTS||a,l=e.maxStartPTS||n;for(let d=0;d<i.length;d++){const e=i.start(d)-this.bufferPadding,t=i.end(d)+this.bufferPadding;if(l>=e&&o<=t){s.time.push({startPTS:Math.max(n,i.start(d)),endPTS:Math.min(a,i.end(d))});break}if(n<t&&a>e)s.partial=!0,s.time.push({startPTS:Math.max(n,i.start(d)),endPTS:Math.min(a,i.end(d))});else if(a<=e)break}return s}getPartialFragment(e){let t,r,i,s=null,n=0;const{bufferPadding:a,fragments:o}=this;return Object.keys(o).forEach(l=>{const d=o[l];d&&Lr(d)&&(r=d.body.start-a,i=d.body.end+a,e>=r&&e<=i&&(t=Math.min(e-r,i-e),n<=t&&(s=d.body,n=t)))}),s}isEndListAppended(e){const t=this.endListFragments[e];return void 0!==t&&(t.buffered||Lr(t))}getState(e){const t=Ar(e),r=this.fragments[t];return r?r.buffered?Lr(r)?Tr.PARTIAL:Tr.OK:Tr.APPENDING:Tr.NOT_LOADED}isTimeBuffered(e,t,r){let i,s;for(let n=0;n<r.length;n++){if(i=r.start(n)-this.bufferPadding,s=r.end(n)+this.bufferPadding,e>=i&&t<=s)return!0;if(t<=i)return!1}return!1}onFragLoaded(e,t){const{frag:r,part:i}=t;if("initSegment"===r.sn||r.bitrateTest)return;const s=i?null:t,n=Ar(r);this.fragments[n]={body:r,appendedPTS:null,loaded:s,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){const{frag:r,part:i,timeRanges:s}=t;if("initSegment"===r.sn)return;const n=r.type;if(i){let e=this.activePartLists[n];e||(this.activePartLists[n]=e=[]),e.push(i)}this.timeRanges=s,Object.keys(s).forEach(e=>{const t=s[e];this.detectEvictedFragments(e,t,n,i)})}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){const t=Ar(e);return!!this.fragments[t]}hasParts(e){var t;return!(null==(t=this.activePartLists[e])||!t.length)}removeFragmentsInRange(e,t,r,i,s){i&&!this.hasGaps||Object.keys(this.fragments).forEach(n=>{const a=this.fragments[n];if(!a)return;const o=a.body;o.type!==r||i&&!o.gap||o.start<t&&o.end>e&&(a.buffered||s)&&this.removeFragment(o)})}removeFragment(e){const t=Ar(e);e.stats.loaded=0,e.clearElementaryStreamInfo();const r=this.activePartLists[e.type];if(r){const t=e.sn;this.activePartLists[e.type]=r.filter(e=>e.fragment.sn!==t)}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1}}function Lr(e){var t,r,i;return e.buffered&&(e.body.gap||(null==(t=e.range.video)?void 0:t.partial)||(null==(r=e.range.audio)?void 0:r.partial)||(null==(i=e.range.audiovideo)?void 0:i.partial))}function Ar(e){return`${e.type}_${e.level}_${e.urlId}_${e.sn}`}const wr=Math.pow(2,17);class Rr{constructor(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(e,t){const r=e.url;if(!r)return Promise.reject(new Dr({type:p.NETWORK_ERROR,details:m.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error("Fragment does not have a "+(r?"part list":"url")),networkDetails:null}));this.abort();const i=this.config,s=i.fLoader,n=i.loader;return new Promise((a,l)=>{if(this.loader&&this.loader.destroy(),e.gap){if(e.tagList.some(e=>"GAP"===e[0]))return void l(Ir(e));e.gap=!1}const d=this.loader=e.loader=s?new s(i):new n(i),h=kr(e),c=ir(i.fragLoadPolicy.default),u={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===e.sn?1/0:wr};e.stats=d.stats,d.load(h,u,{onSuccess:(t,r,i,s)=>{this.resetLoader(e,d);let n=t.data;i.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(n.slice(0,16)),n=n.slice(16)),a({frag:e,part:null,payload:n,networkDetails:s})},onError:(t,i,s,n)=>{this.resetLoader(e,d),l(new Dr({type:p.NETWORK_ERROR,details:m.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:o({url:r,data:void 0},t),error:new Error(`HTTP Error ${t.code} ${t.text}`),networkDetails:s,stats:n}))},onAbort:(t,r,i)=>{this.resetLoader(e,d),l(new Dr({type:p.NETWORK_ERROR,details:m.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:i,stats:t}))},onTimeout:(t,r,i)=>{this.resetLoader(e,d),l(new Dr({type:p.NETWORK_ERROR,details:m.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${u.timeout}ms`),networkDetails:i,stats:t}))},onProgress:(r,i,s,n)=>{t&&t({frag:e,part:null,payload:s,networkDetails:n})}})})}loadPart(e,t,r){this.abort();const i=this.config,s=i.fLoader,n=i.loader;return new Promise((a,l)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap)return void l(Ir(e,t));const d=this.loader=e.loader=s?new s(i):new n(i),h=kr(e,t),c=ir(i.fragLoadPolicy.default),u={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:wr};t.stats=d.stats,d.load(h,u,{onSuccess:(i,s,n,o)=>{this.resetLoader(e,d),this.updateStatsFromPart(e,t);const l={frag:e,part:t,payload:i.data,networkDetails:o};r(l),a(l)},onError:(r,i,s,n)=>{this.resetLoader(e,d),l(new Dr({type:p.NETWORK_ERROR,details:m.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:o({url:h.url,data:void 0},r),error:new Error(`HTTP Error ${r.code} ${r.text}`),networkDetails:s,stats:n}))},onAbort:(r,i,s)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,d),l(new Dr({type:p.NETWORK_ERROR,details:m.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:s,stats:r}))},onTimeout:(r,i,s)=>{this.resetLoader(e,d),l(new Dr({type:p.NETWORK_ERROR,details:m.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${u.timeout}ms`),networkDetails:s,stats:r}))}})})}updateStatsFromPart(e,t){const r=e.stats,i=t.stats,s=i.total;if(r.loaded+=i.loaded,s){const i=Math.round(e.duration/t.duration),n=Math.min(Math.round(r.loaded/s),i),a=i-n,o=a*Math.round(r.loaded/n);r.total=r.loaded+o}else r.total=Math.max(r.loaded,r.total);const n=r.loading,a=i.loading;n.start?n.first+=a.first-a.start:(n.start=a.start,n.first=a.first),n.end=a.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}function kr(e,t=null){const r=t||e,i={frag:e,part:t,responseType:"arraybuffer",url:r.url,headers:{},rangeStart:0,rangeEnd:0},s=r.byteRangeStartOffset,n=r.byteRangeEndOffset;if(u(s)&&u(n)){var a;let t=s,r=n;if("initSegment"===e.sn&&"AES-128"===(null==(a=e.decryptdata)?void 0:a.method)){const e=n-s;e%16&&(r=n+(16-e%16)),0!==s&&(i.resetIV=!0,t=s-16)}i.rangeStart=t,i.rangeEnd=r}return i}function Ir(e,t){const r=new Error(`GAP ${e.gap?"tag":"attribute"} found`),i={type:p.MEDIA_ERROR,details:m.FRAG_GAP,fatal:!1,frag:e,error:r,networkDetails:null};return t&&(i.part=t),(t||e).stats.aborted=!0,new Dr(i)}class Dr extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}}class xr{constructor(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(const t in this.keyUriToKeyInfo){const r=this.keyUriToKeyInfo[t].loader;if(r){if(e&&e!==r.context.frag.type)return;r.abort()}}}detach(){for(const e in this.keyUriToKeyInfo){const t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}}destroy(){this.detach();for(const e in this.keyUriToKeyInfo){const t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(e,t=m.KEY_LOAD_ERROR,r,i,s){return new Dr({type:p.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:s,error:r,networkDetails:i})}loadClear(e,t){if(this.emeController&&this.config.emeEnabled){const{sn:r,cc:i}=e;for(let e=0;e<t.length;e++){const s=t[e];if(i<=s.cc&&("initSegment"===r||"initSegment"===s.sn||r<s.sn)){this.emeController.selectKeySystemFormat(s).then(e=>{s.setKeyFormat(e)});break}}}}load(e){return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}loadInternal(e,t){var r,i;t&&e.setKeyFormat(t);const s=e.decryptdata;if(!s){const r=new Error(t?"Expected frag.decryptdata to be defined after setting format "+t:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(e,m.KEY_LOAD_ERROR,r))}const n=s.uri;if(!n)return Promise.reject(this.createKeyLoadError(e,m.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${n}"`)));let a=this.keyUriToKeyInfo[n];if(null!=(r=a)&&r.decryptdata.key)return s.key=a.decryptdata.key,Promise.resolve({frag:e,keyInfo:a});var o;if(null!=(i=a)&&i.keyLoadPromise)switch(null==(o=a.mediaKeySessionContext)?void 0:o.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return a.keyLoadPromise.then(t=>(s.key=t.keyInfo.decryptdata.key,{frag:e,keyInfo:a}))}switch(a=this.keyUriToKeyInfo[n]={decryptdata:s,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},s.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===s.keyFormat?this.loadKeyHTTP(a,e):this.loadKeyEME(a,e);case"AES-128":return this.loadKeyHTTP(a,e);default:return Promise.reject(this.createKeyLoadError(e,m.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${s.method}"`)))}}loadKeyEME(e,t){const r={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){const t=this.emeController.loadKey(r);if(t)return(e.keyLoadPromise=t.then(t=>(e.mediaKeySessionContext=t,r))).catch(t=>{throw e.keyLoadPromise=null,t})}return Promise.resolve(r)}loadKeyHTTP(e,t){const r=this.config,i=r.loader,s=new i(r);return t.keyLoader=e.loader=s,e.keyLoadPromise=new Promise((i,n)=>{const a={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},l=r.keyLoadPolicy.default,d={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},h={onSuccess:(e,t,r,s)=>{const{frag:a,keyInfo:o,url:l}=r;if(!a.decryptdata||o!==this.keyUriToKeyInfo[l])return n(this.createKeyLoadError(a,m.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),s));o.decryptdata.key=a.decryptdata.key=new Uint8Array(e.data),a.keyLoader=null,o.loader=null,i({frag:a,keyInfo:o})},onError:(e,r,i,s)=>{this.resetLoader(r),n(this.createKeyLoadError(t,m.KEY_LOAD_ERROR,new Error(`HTTP Error ${e.code} loading key ${e.text}`),i,o({url:a.url,data:void 0},e)))},onTimeout:(e,r,i)=>{this.resetLoader(r),n(this.createKeyLoadError(t,m.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),i))},onAbort:(e,r,i)=>{this.resetLoader(r),n(this.createKeyLoadError(t,m.INTERNAL_ABORTED,new Error("key loading aborted"),i))}};s.load(a,d,h)})}resetLoader(e){const{frag:t,keyInfo:r,url:i}=e,s=r.loader;t.keyLoader===s&&(t.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[i],s&&s.destroy()}}class Cr{constructor(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(e){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)}clearInterval(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)}clearNextTick(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)}tick(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}const Pr={length:0,start:()=>0,end:()=>0};class Or{static isBuffered(e,t){try{if(e){const r=Or.getBuffered(e);for(let e=0;e<r.length;e++)if(t>=r.start(e)&&t<=r.end(e))return!0}}catch(r){}return!1}static bufferInfo(e,t,r){try{if(e){const i=Or.getBuffered(e),s=[];let n;for(n=0;n<i.length;n++)s.push({start:i.start(n),end:i.end(n)});return this.bufferedInfo(s,t,r)}}catch(i){}return{len:0,start:t,end:t,nextStart:void 0}}static bufferedInfo(e,t,r){t=Math.max(0,t),e.sort((function(e,t){const r=e.start-t.start;return r||t.end-e.end}));let i=[];if(r)for(let l=0;l<e.length;l++){const t=i.length;if(t){const s=i[t-1].end;e[l].start-s<r?e[l].end>s&&(i[t-1].end=e[l].end):i.push(e[l])}else i.push(e[l])}else i=e;let s,n=0,a=t,o=t;for(let l=0;l<i.length;l++){const e=i[l].start,d=i[l].end;if(t+r>=e&&t<d)a=e,o=d,n=o-t;else if(t+r<e){s=e;break}}return{len:n,start:a||0,end:o||0,nextStart:s}}static getBuffered(e){try{return e.buffered}catch(t){return T.log("failed to get media.buffered",t),Pr}}}class Mr{constructor(e,t,r,i=0,s=-1,n=!1){this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=Fr(),this.buffering={audio:Fr(),video:Fr(),audiovideo:Fr()},this.level=e,this.sn=t,this.id=r,this.size=i,this.part=s,this.partial=n}}function Fr(){return{start:0,executeStart:0,executeEnd:0,end:0}}function Nr(e,t){let r=null;for(let i=0,s=e.length;i<s;i++){const s=e[i];if(s&&s.cc===t){r=s;break}}return r}function Ur(e,t,r){return!(!t.details||!(r.endCC>r.startCC||e&&e.cc<r.startCC))}function Br(e,t,r=0){const i=e.fragments,s=t.fragments;if(!s.length||!i.length)return void T.log("No fragments to align");const n=Nr(i,s[0].cc);if(n&&(!n||n.startPTS))return n;T.log("No frag in previous level to align on")}function $r(e,t){if(e){const r=e.start+t;e.start=e.startPTS=r,e.endPTS=r+e.duration}}function Gr(e,t){const r=t.fragments;for(let i=0,s=r.length;i<s;i++)$r(r[i],e);t.fragmentHint&&$r(t.fragmentHint,e),t.alignedSliding=!0}function jr(e,t,r){t&&(Kr(e,r,t),!r.alignedSliding&&t.details&&Vr(r,t.details),r.alignedSliding||!t.details||r.skippedSegments||Wt(t.details,r))}function Kr(e,t,r){if(Ur(e,r,t)){const e=Br(r.details,t);e&&u(e.start)&&(T.log("Adjusting PTS using last level due to CC increase within current level "+t.url),Gr(e.start,t))}}function Vr(e,t){if(!t.fragments.length||!e.hasProgramDateTime||!t.hasProgramDateTime)return;const r=t.fragments[0].programDateTime,i=e.fragments[0].programDateTime,s=(i-r)/1e3+t.fragments[0].start;s&&u(s)&&(T.log(`Adjusting PTS using programDateTime delta ${i-r}ms, sliding:${s.toFixed(3)} ${e.url} `),Gr(s,e))}function Hr(e,t){if(!e.hasProgramDateTime||!t.hasProgramDateTime)return;const r=e.fragments,i=t.fragments;if(!r.length||!i.length)return;const s=Math.round(i.length/2)-1,n=i[s],a=Nr(r,n.cc)||r[Math.round(r.length/2)-1],o=n.programDateTime,l=a.programDateTime;if(null===o||null===l)return;const d=(l-o)/1e3-(a.start-n.start);Gr(d,e)}class Yr{constructor(e,t){this.subtle=void 0,this.aesIV=void 0,this.subtle=e,this.aesIV=t}decrypt(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)}}class zr{constructor(e,t){this.subtle=void 0,this.key=void 0,this.subtle=e,this.key=t}expandKey(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])}}function Wr(e){const t=e.byteLength,r=t&&new DataView(e.buffer).getUint8(t-1);return r?Q(e,0,t-r):e}class qr{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),r=new Uint32Array(4);for(let i=0;i<4;i++)r[i]=t.getUint32(4*i);return r}initTable(){const e=this.sBox,t=this.invSBox,r=this.subMix,i=r[0],s=r[1],n=r[2],a=r[3],o=this.invSubMix,l=o[0],d=o[1],h=o[2],c=o[3],u=new Uint32Array(256);let f=0,p=0,m=0;for(m=0;m<256;m++)u[m]=m<128?m<<1:m<<1^283;for(m=0;m<256;m++){let r=p^p<<1^p<<2^p<<3^p<<4;r=r>>>8^255&r^99,e[f]=r,t[r]=f;const o=u[f],m=u[o],g=u[m];let y=257*u[r]^16843008*r;i[f]=y<<24|y>>>8,s[f]=y<<16|y>>>16,n[f]=y<<8|y>>>24,a[f]=y,y=16843009*g^65537*m^257*o^16843008*f,l[r]=y<<24|y>>>8,d[r]=y<<16|y>>>16,h[r]=y<<8|y>>>24,c[r]=y,f?(f=o^u[u[u[g^o]]],p^=u[u[p]]):f=p=1}}expandKey(e){const t=this.uint8ArrayToUint32Array_(e);let r=!0,i=0;while(i<t.length&&r)r=t[i]===this.key[i],i++;if(r)return;this.key=t;const s=this.keySize=t.length;if(4!==s&&6!==s&&8!==s)throw new Error("Invalid aes key size="+s);const n=this.ksRows=4*(s+6+1);let a,o;const l=this.keySchedule=new Uint32Array(n),d=this.invKeySchedule=new Uint32Array(n),h=this.sBox,c=this.rcon,u=this.invSubMix,f=u[0],p=u[1],m=u[2],g=u[3];let y,v;for(a=0;a<n;a++)a<s?y=l[a]=t[a]:(v=y,a%s===0?(v=v<<8|v>>>24,v=h[v>>>24]<<24|h[v>>>16&255]<<16|h[v>>>8&255]<<8|h[255&v],v^=c[a/s|0]<<24):s>6&&a%s===4&&(v=h[v>>>24]<<24|h[v>>>16&255]<<16|h[v>>>8&255]<<8|h[255&v]),l[a]=y=(l[a-s]^v)>>>0);for(o=0;o<n;o++)a=n-o,v=3&o?l[a]:l[a-4],d[o]=o<4||a<=4?v:f[h[v>>>24]]^p[h[v>>>16&255]]^m[h[v>>>8&255]]^g[h[255&v]],d[o]=d[o]>>>0}networkToHostOrderSwap(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24}decrypt(e,t,r){const i=this.keySize+6,s=this.invKeySchedule,n=this.invSBox,a=this.invSubMix,o=a[0],l=a[1],d=a[2],h=a[3],c=this.uint8ArrayToUint32Array_(r);let u=c[0],f=c[1],p=c[2],m=c[3];const g=new Int32Array(e),y=new Int32Array(g.length);let v,_,E,b,T,S,L,A,w,R,k,I,D,x;const C=this.networkToHostOrderSwap;while(t<g.length){for(w=C(g[t]),R=C(g[t+1]),k=C(g[t+2]),I=C(g[t+3]),T=w^s[0],S=I^s[1],L=k^s[2],A=R^s[3],D=4,x=1;x<i;x++)v=o[T>>>24]^l[S>>16&255]^d[L>>8&255]^h[255&A]^s[D],_=o[S>>>24]^l[L>>16&255]^d[A>>8&255]^h[255&T]^s[D+1],E=o[L>>>24]^l[A>>16&255]^d[T>>8&255]^h[255&S]^s[D+2],b=o[A>>>24]^l[T>>16&255]^d[S>>8&255]^h[255&L]^s[D+3],T=v,S=_,L=E,A=b,D+=4;v=n[T>>>24]<<24^n[S>>16&255]<<16^n[L>>8&255]<<8^n[255&A]^s[D],_=n[S>>>24]<<24^n[L>>16&255]<<16^n[A>>8&255]<<8^n[255&T]^s[D+1],E=n[L>>>24]<<24^n[A>>16&255]<<16^n[T>>8&255]<<8^n[255&S]^s[D+2],b=n[A>>>24]<<24^n[T>>16&255]<<16^n[S>>8&255]<<8^n[255&L]^s[D+3],y[t]=C(v^u),y[t+1]=C(b^f),y[t+2]=C(E^p),y[t+3]=C(_^m),u=w,f=R,p=k,m=I,t+=4}return y.buffer}}const Xr=16;class Qr{constructor(e,{removePKCS7Padding:t=!0}={}){if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=e.enableSoftwareAES,this.removePKCS7Padding=t,t)try{const e=self.crypto;e&&(this.subtle=e.subtle||e.webkitSubtle)}catch(r){}null===this.subtle&&(this.useSoftware=!0)}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}isSync(){return this.useSoftware}flush(){const{currentResult:e,remainderData:t}=this;if(!e||t)return this.reset(),null;const r=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?Wr(r):r}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,t,r){return this.useSoftware?new Promise((i,s)=>{this.softwareDecrypt(new Uint8Array(e),t,r);const n=this.flush();n?i(n.buffer):s(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,r)}softwareDecrypt(e,t,r){const{currentIV:i,currentResult:s,remainderData:n}=this;this.logOnce("JS AES decrypt"),n&&(e=Oe(n,e),this.remainderData=null);const a=this.getValidChunk(e);if(!a.length)return null;i&&(r=i);let o=this.softwareDecrypter;o||(o=this.softwareDecrypter=new qr),o.expandKey(t);const l=s;return this.currentResult=o.decrypt(a.buffer,0,r),this.currentIV=Q(a,-16).buffer,l||null}webCryptoDecrypt(e,t,r){const i=this.subtle;return this.key===t&&this.fastAesKey||(this.key=t,this.fastAesKey=new zr(i,t)),this.fastAesKey.expandKey().then(t=>{if(!i)return Promise.reject(new Error("web crypto not initialized"));this.logOnce("WebCrypto AES decrypt");const s=new Yr(i,new Uint8Array(r));return s.decrypt(e.buffer,t)}).catch(i=>(T.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${i.name}: ${i.message}`),this.onWebCryptoError(e,t,r)))}onWebCryptoError(e,t,r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r);const i=this.flush();if(i)return i.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(e){let t=e;const r=e.length-e.length%Xr;return r!==e.length&&(t=Q(e,0,r),this.remainderData=Q(e,r)),t}logOnce(e){this.logEnabled&&(T.log("[decrypter]: "+e),this.logEnabled=!1)}}const Zr={toString:function(e){let t="";const r=e.length;for(let i=0;i<r;i++)t+=`[${e.start(i).toFixed(3)}-${e.end(i).toFixed(3)}]`;return t}},Jr={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"};class ei extends Cr{constructor(e,t,r,i,s){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=Jr.STOPPED,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.loadedmetadata=!1,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.onvseeking=null,this.onvended=null,this.logPrefix="",this.log=void 0,this.warn=void 0,this.playlistType=s,this.logPrefix=i,this.log=T.log.bind(T,i+":"),this.warn=T.warn.bind(T,i+":"),this.hls=e,this.fragmentLoader=new Rr(e.config),this.keyLoader=r,this.fragmentTracker=t,this.config=e.config,this.decrypter=new Qr(e.config),e.on(f.MANIFEST_LOADED,this.onManifestLoaded,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);const e=this.fragCurrent;null!=e&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=Jr.STOPPED}_streamEnded(e,t){if(t.live||e.nextStart||!e.end||!this.media)return!1;const r=t.partList;if(null!=r&&r.length){const e=r[r.length-1],t=Or.isBuffered(this.media,e.start+e.duration/2);return t}const i=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(i)}getLevelDetails(){var e;if(this.levels&&null!==this.levelLastLoaded)return null==(e=this.levels[this.levelLastLoaded])?void 0:e.details}onMediaAttached(e,t){const r=this.media=this.mediaBuffer=t.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),r.addEventListener("seeking",this.onvseeking),r.addEventListener("ended",this.onvended);const i=this.config;this.levels&&i.autoStartLoad&&this.state===Jr.STOPPED&&this.startLoad(i.startPosition)}onMediaDetaching(){const e=this.media;null!=e&&e.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&this.onvseeking&&this.onvended&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}onMediaSeeking(){const{config:e,fragCurrent:t,media:r,mediaBuffer:i,state:s}=this,n=r?r.currentTime:0,a=Or.bufferInfo(i||r,n,e.maxBufferHole);if(this.log(`media seeking to ${u(n)?n.toFixed(3):n}, state: ${s}`),this.state===Jr.ENDED)this.resetLoadingState();else if(t){const r=e.maxFragLookUpTolerance,i=t.start-r,s=t.start+t.duration+r;if(!a.len||s<a.start||i>a.end){const e=n>s;(n<i||e)&&(e&&t.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),t.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}r&&(this.fragmentTracker.removeFragmentsInRange(n,1/0,this.playlistType,!0),this.lastCurrentTime=n),this.loadedmetadata||a.len||(this.nextLoadPosition=this.startPosition=n),this.tickImmediate()}onMediaEnded(){this.startPosition=this.lastCurrentTime=0}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset,this.initPTS=[]}onHandlerDestroying(){this.stopLoad(),super.onHandlerDestroying()}onHandlerDestroyed(){this.state=Jr.STOPPED,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,super.onHandlerDestroyed()}loadFragment(e,t,r){this._loadFragForPlayback(e,t,r)}_loadFragForPlayback(e,t,r){const i=t=>{if(this.fragContextChanged(e))return this.warn(`Fragment ${e.sn}${t.part?" p: "+t.part.index:""} of level ${e.level} was dropped during download.`),void this.fragmentTracker.removeFragment(e);e.stats.chunkCount++,this._handleFragmentLoadProgress(t)};this._doFragLoad(e,t,r,i).then(t=>{if(!t)return;const r=this.state;this.fragContextChanged(e)?(r===Jr.FRAG_LOADING||!this.fragCurrent&&r===Jr.PARSING)&&(this.fragmentTracker.removeFragment(e),this.state=Jr.IDLE):("payload"in t&&(this.log(`Loaded fragment ${e.sn} of level ${e.level}`),this.hls.trigger(f.FRAG_LOADED,t)),this._handleFragmentLoadComplete(t))}).catch(t=>{this.state!==Jr.STOPPED&&this.state!==Jr.ERROR&&(this.warn(t),this.resetFragmentLoading(e))})}clearTrackerIfNeeded(e){var t;const{fragmentTracker:r}=this,i=r.getState(e);if(i===Tr.APPENDING){const t=e.type,i=this.getFwdBufferInfo(this.mediaBuffer,t),s=Math.max(e.duration,i?i.len:this.config.maxBufferLength);this.reduceMaxBufferLength(s)&&r.removeFragment(e)}else 0===(null==(t=this.mediaBuffer)?void 0:t.buffered.length)?r.removeAllFragments():r.hasParts(e.type)&&(r.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),r.getState(e)===Tr.PARTIAL&&r.removeFragment(e))}checkLiveUpdate(e){if(e.updated&&!e.live){const t=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)}flushMainBuffer(e,t,r=null){if(!(e-t))return;const i={startOffset:e,endOffset:t,type:r};this.hls.trigger(f.BUFFER_FLUSHING,i)}_loadInitSegment(e,t){this._doFragLoad(e,t).then(t=>{if(!t||this.fragContextChanged(e)||!this.levels)throw new Error("init load aborted");return t}).then(t=>{const{hls:r}=this,{payload:i}=t,s=e.decryptdata;if(i&&i.byteLength>0&&s&&s.key&&s.iv&&"AES-128"===s.method){const n=self.performance.now();return this.decrypter.decrypt(new Uint8Array(i),s.key.buffer,s.iv.buffer).catch(t=>{throw r.trigger(f.ERROR,{type:p.MEDIA_ERROR,details:m.FRAG_DECRYPT_ERROR,fatal:!1,error:t,reason:t.message,frag:e}),t}).then(i=>{const s=self.performance.now();return r.trigger(f.FRAG_DECRYPTED,{frag:e,payload:i,stats:{tstart:n,tdecrypt:s}}),t.payload=i,t})}return t}).then(r=>{const{fragCurrent:i,hls:s,levels:n}=this;if(!n)throw new Error("init load aborted, missing levels");const a=e.stats;this.state=Jr.IDLE,t.fragmentError=0,e.data=new Uint8Array(r.payload),a.parsing.start=a.buffering.start=self.performance.now(),a.parsing.end=a.buffering.end=self.performance.now(),r.frag===i&&s.trigger(f.FRAG_BUFFERED,{stats:a,frag:i,part:null,id:e.type}),this.tick()}).catch(t=>{this.state!==Jr.STOPPED&&this.state!==Jr.ERROR&&(this.warn(t),this.resetFragmentLoading(e))})}fragContextChanged(e){const{fragCurrent:t}=this;return!e||!t||e.level!==t.level||e.sn!==t.sn||e.urlId!==t.urlId}fragBufferedComplete(e,t){var r,i,s,n;const a=this.mediaBuffer?this.mediaBuffer:this.media;this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.playlistType===_t.MAIN?"level":"track"} ${e.level} (frag:[${(null!=(r=e.startPTS)?r:NaN).toFixed(3)}-${(null!=(i=e.endPTS)?i:NaN).toFixed(3)}] > buffer:${a?Zr.toString(Or.getBuffered(a)):"(detached)"})`),this.state=Jr.IDLE,a&&(!this.loadedmetadata&&e.type==_t.MAIN&&a.buffered.length&&(null==(s=this.fragCurrent)?void 0:s.sn)===(null==(n=this.fragPrevious)?void 0:n.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(e){const{transmuxer:t}=this;if(!t)return;const{frag:r,part:i,partsLoaded:s}=e,n=!s||0===s.length||s.some(e=>!e),a=new Mr(r.level,r.sn,r.stats.chunkCount+1,0,i?i.index:-1,!n);t.flush(a)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,r=null,i){var s;const n=null==t?void 0:t.details;if(!this.levels||!n)throw new Error(`frag load aborted, missing level${n?"":" detail"}s`);let a=null;if(!e.encrypted||null!=(s=e.decryptdata)&&s.key?!e.encrypted&&n.encryptedFragments.length&&this.keyLoader.loadClear(e,n.encryptedFragments):(this.log(`Loading key for ${e.sn} of [${n.startSN}-${n.endSN}], ${"[stream-controller]"===this.logPrefix?"level":"track"} ${e.level}`),this.state=Jr.KEY_LOADING,this.fragCurrent=e,a=this.keyLoader.load(e).then(e=>{if(!this.fragContextChanged(e.frag))return this.hls.trigger(f.KEY_LOADED,e),this.state===Jr.KEY_LOADING&&(this.state=Jr.IDLE),e}),this.hls.trigger(f.KEY_LOADING,{frag:e}),null===this.fragCurrent&&(a=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))),r=Math.max(e.start,r||0),this.config.lowLatencyMode&&"initSegment"!==e.sn){const s=n.partList;if(s&&i){r>e.end&&n.fragmentHint&&(e=n.fragmentHint);const o=this.getNextPart(s,e,r);if(o>-1){const l=s[o];let d;return this.log(`Loading part sn: ${e.sn} p: ${l.index} cc: ${e.cc} of playlist [${n.startSN}-${n.endSN}] parts [0-${o}-${s.length-1}] ${"[stream-controller]"===this.logPrefix?"level":"track"}: ${e.level}, target: ${parseFloat(r.toFixed(3))}`),this.nextLoadPosition=l.start+l.duration,this.state=Jr.FRAG_LOADING,d=a?a.then(r=>!r||this.fragContextChanged(r.frag)?null:this.doFragPartsLoad(e,l,t,i)).catch(e=>this.handleFragLoadError(e)):this.doFragPartsLoad(e,l,t,i).catch(e=>this.handleFragLoadError(e)),this.hls.trigger(f.FRAG_LOADING,{frag:e,part:l,targetBufferTime:r}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):d}if(!e.url||this.loadedEndOfParts(s,r))return Promise.resolve(null)}}this.log(`Loading fragment ${e.sn} cc: ${e.cc} ${n?"of ["+n.startSN+"-"+n.endSN+"] ":""}${"[stream-controller]"===this.logPrefix?"level":"track"}: ${e.level}, target: ${parseFloat(r.toFixed(3))}`),u(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=Jr.FRAG_LOADING;const o=this.config.progressive;let l;return l=o&&a?a.then(t=>!t||this.fragContextChanged(null==t?void 0:t.frag)?null:this.fragmentLoader.load(e,i)).catch(e=>this.handleFragLoadError(e)):Promise.all([this.fragmentLoader.load(e,o?i:void 0),a]).then(([e])=>(!o&&e&&i&&i(e),e)).catch(e=>this.handleFragLoadError(e)),this.hls.trigger(f.FRAG_LOADING,{frag:e,targetBufferTime:r}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):l}doFragPartsLoad(e,t,r,i){return new Promise((s,n)=>{var a;const o=[],l=null==(a=r.details)?void 0:a.partList,d=t=>{this.fragmentLoader.loadPart(e,t,i).then(i=>{o[t.index]=i;const n=i.part;this.hls.trigger(f.FRAG_LOADED,i);const a=Zt(r,e.sn,t.index+1)||Jt(l,e.sn,t.index+1);if(!a)return s({frag:e,part:n,partsLoaded:o});d(a)}).catch(n)};d(t)})}handleFragLoadError(e){if("data"in e){const t=e.data;e.data&&t.details===m.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(f.ERROR,t)}else this.hls.trigger(f.ERROR,{type:p.OTHER_ERROR,details:m.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){const t=this.getCurrentContext(e);if(!t||this.state!==Jr.PARSING)return void(this.fragCurrent||this.state===Jr.STOPPED||this.state===Jr.ERROR||(this.state=Jr.IDLE));const{frag:r,part:i,level:s}=t,n=self.performance.now();r.stats.parsing.end=n,i&&(i.stats.parsing.end=n),this.updateLevelTiming(r,i,s,e.partial)}getCurrentContext(e){const{levels:t,fragCurrent:r}=this,{level:i,sn:s,part:n}=e;if(null==t||!t[i])return this.warn(`Levels object was unset while buffering fragment ${s} of level ${i}. The current chunk will not be buffered.`),null;const a=t[i],o=n>-1?Zt(a,s,n):null,l=o?o.fragment:Qt(a,s,r);return l?(r&&r!==l&&(l.stats=r.stats),{frag:l,part:o,level:a}):null}bufferFragmentData(e,t,r,i,s){var n;if(!e||this.state!==Jr.PARSING)return;const{data1:a,data2:o}=e;let l=a;if(a&&o&&(l=Oe(a,o)),null==(n=l)||!n.length)return;const d={type:e.type,frag:t,part:r,chunkMeta:i,parent:t.type,data:l};if(this.hls.trigger(f.BUFFER_APPENDING,d),e.dropped&&e.independent&&!r){if(s)return;this.flushBufferGap(t)}}flushBufferGap(e){const t=this.media;if(!t)return;if(!Or.isBuffered(t,t.currentTime))return void this.flushMainBuffer(0,e.start);const r=t.currentTime,i=Or.bufferInfo(t,r,0),s=e.duration,n=Math.min(2*this.config.maxFragLookUpTolerance,.25*s),a=Math.max(Math.min(e.start-n,i.end-n),r+n);e.start-a>n&&this.flushMainBuffer(a,e.start)}getFwdBufferInfo(e,t){const r=this.getLoadPosition();return u(r)?this.getFwdBufferInfoAtPos(e,r,t):null}getFwdBufferInfoAtPos(e,t,r){const{config:{maxBufferHole:i}}=this,s=Or.bufferInfo(e,t,i);if(0===s.len&&void 0!==s.nextStart){const n=this.fragmentTracker.getBufferedFrag(t,r);if(n&&s.nextStart<n.end)return Or.bufferInfo(e,t,Math.max(s.nextStart,i))}return s}getMaxBufferLength(e){const{config:t}=this;let r;return r=e?Math.max(8*t.maxBufferSize/e,t.maxBufferLength):t.maxBufferLength,Math.min(r,t.maxMaxBufferLength)}reduceMaxBufferLength(e){const t=this.config,r=e||t.maxBufferLength;return t.maxMaxBufferLength>=r&&(t.maxMaxBufferLength/=2,this.warn(`Reduce max buffer length to ${t.maxMaxBufferLength}s`),!0)}getAppendedFrag(e,t=_t.MAIN){const r=this.fragmentTracker.getAppendedFrag(e,_t.MAIN);return r&&"fragment"in r?r.fragment:r}getNextFragment(e,t){const r=t.fragments,i=r.length;if(!i)return null;const{config:s}=this,n=r[0].start;let a;if(t.live){const n=s.initialLiveManifestSize;if(i<n)return this.warn(`Not enough fragments to start playback (have: ${i}, need: ${n})`),null;t.PTSKnown||this.startFragRequested||-1!==this.startPosition||(a=this.getInitialLiveFragment(t,r),this.startPosition=a?this.hls.liveSyncPosition||a.start:e)}else e<=n&&(a=r[0]);if(!a){const r=s.lowLatencyMode?t.partEnd:t.fragmentEnd;a=this.getFragmentAtPosition(e,r,t)}return this.mapToInitFragWhenRequired(a)}isLoopLoading(e,t){const r=this.fragmentTracker.getState(e);return(r===Tr.OK||r===Tr.PARTIAL&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,r,i,s){const n=e.gap,a=this.getNextFragment(this.nextLoadPosition,t);if(null===a)return a;if(e=a,n&&e&&!e.gap&&r.nextStart){const t=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,r.nextStart,i);if(null!==t&&r.len+t.len>=s)return this.log(`buffer full after gaps in "${i}" playlist starting at sn: ${e.sn}`),null}return e}mapToInitFragWhenRequired(e){return null==e||!e.initSegment||null!=e&&e.initSegment.data||this.bitrateTest?e:e.initSegment}getNextPart(e,t,r){let i=-1,s=!1,n=!0;for(let a=0,o=e.length;a<o;a++){const o=e[a];if(n=n&&!o.independent,i>-1&&r<o.start)break;const l=o.loaded;l?i=-1:(s||o.independent||n)&&o.fragment===t&&(i=a),s=l}return i}loadedEndOfParts(e,t){const r=e[e.length-1];return r&&t>r.start&&r.loaded}getInitialLiveFragment(e,t){const r=this.fragPrevious;let i=null;if(r){if(e.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+r.programDateTime),i=or(t,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),!i){const s=r.sn+1;if(s>=e.startSN&&s<=e.endSN){const n=t[s-e.startSN];r.cc===n.cc&&(i=n,this.log("Live playlist, switching playlist, load frag with next SN: "+i.sn))}i||(i=cr(t,r.cc),i&&this.log("Live playlist, switching playlist, load frag with same CC: "+i.sn))}}else{const t=this.hls.liveSyncPosition;null!==t&&(i=this.getFragmentAtPosition(t,this.bitrateTest?e.fragmentEnd:e.edge,e))}return i}getFragmentAtPosition(e,t,r){const{config:i}=this;let{fragPrevious:s}=this,{fragments:n,endSN:a}=r;const{fragmentHint:o}=r,l=i.maxFragLookUpTolerance,d=r.partList,h=!!(i.lowLatencyMode&&null!=d&&d.length&&o);let c;if(h&&o&&!this.bitrateTest&&(n=n.concat(o),a=o.sn),e<t){const r=e>t-l?0:l;c=lr(s,n,e,r)}else c=n[n.length-1];if(c){const e=c.sn-r.startSN,t=this.fragmentTracker.getState(c);if((t===Tr.OK||t===Tr.PARTIAL&&c.gap)&&(s=c),s&&c.sn===s.sn&&(!h||d[0].fragment.sn>c.sn)){const t=s&&c.level===s.level;if(t){const t=n[e+1];c=c.sn<a&&this.fragmentTracker.getState(t)!==Tr.OK?t:null}}}return c}synchronizeToLiveEdge(e){const{config:t,media:r}=this;if(!r)return;const i=this.hls.liveSyncPosition,s=r.currentTime,n=e.fragments[0].start,a=e.edge,o=s>=n-t.maxFragLookUpTolerance&&s<=a;if(null!==i&&r.duration>i&&(s<i||!o)){const n=void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;(!o&&r.readyState<4||s<a-n)&&(this.loadedmetadata||(this.nextLoadPosition=i),r.readyState&&(this.warn(`Playback: ${s.toFixed(3)} is located too far from the end of live sliding playlist: ${a}, reset currentTime to : ${i.toFixed(3)}`),r.currentTime=i))}}alignPlaylists(e,t){const{levels:r,levelLastLoaded:i,fragPrevious:s}=this,n=null!==i?r[i]:null,a=e.fragments.length;if(!a)return this.warn("No fragments in live playlist"),0;const o=e.fragments[0].start,l=!t,d=e.alignedSliding&&u(o);if(l||!d&&!o){jr(s,n,e);const r=e.fragments[0].start;return this.log(`Live playlist sliding: ${r.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} prev-sn: ${s?s.sn:"na"} fragments: ${a}`),r}return o}waitForCdnTuneIn(e){const t=3;return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,e.partTarget*t)}setStartPosition(e,t){let r=this.startPosition;if(r<t&&(r=-1),-1===r||-1===this.lastCurrentTime){const i=null!==this.startTimeOffset,s=i?this.startTimeOffset:e.startTimeOffset;null!==s&&u(s)?(r=t+s,s<0&&(r+=e.totalduration),r=Math.min(Math.max(t,r),t+e.totalduration),this.log(`Start time offset ${s} found in ${i?"multivariant":"media"} playlist, adjust startPosition to ${r}`),this.startPosition=r):e.live?r=this.hls.liveSyncPosition||t:this.startPosition=r=0,this.lastCurrentTime=r}this.nextLoadPosition=r}getLoadPosition(){const{media:e}=this;let t=0;return this.loadedmetadata&&e?t=e.currentTime:this.nextLoadPosition&&(t=this.nextLoadPosition),t}handleFragLoadAborted(e,t){this.transmuxer&&"initSegment"!==e.sn&&e.stats.aborted&&(this.warn(`Fragment ${e.sn}${t?" part "+t.index:""} of level ${e.level} was aborted`),this.resetFragmentLoading(e))}resetFragmentLoading(e){this.fragCurrent&&(this.fragContextChanged(e)||this.state===Jr.FRAG_LOADING_WAITING_RETRY)||(this.state=Jr.IDLE)}onFragmentOrKeyLoadError(e,t){if(t.chunkMeta&&!t.frag){const e=this.getCurrentContext(t.chunkMeta);e&&(t.frag=e.frag)}const r=t.frag;if(!r||r.type!==e||!this.levels)return;var i;if(this.fragContextChanged(r))return void this.warn(`Frag load error must match current frag to retry ${r.url} > ${null==(i=this.fragCurrent)?void 0:i.url}`);const s=t.details===m.FRAG_GAP;s&&this.fragmentTracker.fragBuffered(r,!0);const n=t.errorAction,{action:a,retryCount:o=0,retryConfig:l}=n||{};if(n&&a===fr.RetryRequest&&l){var d;this.resetStartWhenNotLoaded(null!=(d=this.levelLastLoaded)?d:r.level);const i=rr(l,o);this.warn(`Fragment ${r.sn} of ${e} ${r.level} errored with ${t.details}, retrying loading ${o+1}/${l.maxNumRetry} in ${i}ms`),n.resolved=!0,this.retryDate=self.performance.now()+i,this.state=Jr.FRAG_LOADING_WAITING_RETRY}else l&&n?(this.resetFragmentErrors(e),o<l.maxNumRetry?s||(n.resolved=!0):T.warn(`${t.details} reached or exceeded max retry (${o})`)):(null==n?void 0:n.action)===fr.SendAlternateToPenaltyBox?this.state=Jr.WAITING_LEVEL:this.state=Jr.ERROR;this.tickImmediate()}reduceLengthAndFlushBuffer(e){if(this.state===Jr.PARSING||this.state===Jr.PARSED){const t=e.parent,r=this.getFwdBufferInfo(this.mediaBuffer,t),i=r&&r.len>.5;i&&this.reduceMaxBufferLength(r.len);const s=!i;return s&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${t} buffer`),e.frag&&(this.fragmentTracker.removeFragment(e.frag),this.nextLoadPosition=e.frag.start),this.resetLoadingState(),s}return!1}resetFragmentErrors(e){e===_t.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==Jr.STOPPED&&(this.state=Jr.IDLE)}afterBufferFlushed(e,t,r){if(!e)return;const i=Or.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,i,r),this.state===Jr.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=Jr.IDLE}resetStartWhenNotLoaded(e){if(!this.loadedmetadata){this.startFragRequested=!1;const t=this.levels?this.levels[e].details:null;null!=t&&t.live?(this.startPosition=-1,this.setStartPosition(t,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(e){var t;this.warn(`The loading context changed while buffering fragment ${e.sn} of level ${e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(null!=(t=this.levelLastLoaded)?t:e.level),this.resetLoadingState()}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(e,t,r,i){var s;const n=r.details;if(!n)return void this.warn("level.details undefined");const a=Object.keys(e.elementaryStreams).reduce((t,s)=>{const a=e.elementaryStreams[s];if(a){const o=a.endPTS-a.startPTS;if(o<=0)return this.warn(`Could not parse fragment ${e.sn} ${s} duration reliably (${o})`),t||!1;const l=i?0:Kt(n,e,a.startPTS,a.endPTS,a.startDTS,a.endDTS);return this.hls.trigger(f.LEVEL_PTS_UPDATED,{details:n,level:r,drift:l,type:s,frag:e,start:a.startPTS,end:a.endPTS}),!0}return t},!1);if(a)r.fragmentError=0;else if(null===(null==(s=this.transmuxer)?void 0:s.error)){const t=new Error(`Found no media in fragment ${e.sn} of level ${e.level} resetting transmuxer to fallback to playlist timing`);if(0===r.fragmentError&&(r.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)),this.warn(t.message),this.hls.trigger(f.ERROR,{type:p.MEDIA_ERROR,details:m.FRAG_PARSING_ERROR,fatal:!1,error:t,frag:e,reason:`Found no media in msn ${e.sn} of level "${r.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=Jr.PARSED,this.hls.trigger(f.FRAG_PARSED,{frag:e,part:t})}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(e){var t,r,i;"demuxerWorker"===e.event&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(null!=(t=null!=(r=this.levelLastLoaded)?r:null==(i=this.fragCurrent)?void 0:i.level)?t:0),this.resetLoadingState())}set state(e){const t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}get state(){return this._state}}function ti(){return self.SourceBuffer||self.WebKitSourceBuffer}function ri(){const e=Je();if(!e)return!1;const t=ti(),r=e&&"function"===typeof e.isTypeSupported&&e.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),i=!t||t.prototype&&"function"===typeof t.prototype.appendBuffer&&"function"===typeof t.prototype.remove;return!!r&&!!i}function ii(){var e;const t=ti();return"function"===typeof(null==t||null==(e=t.prototype)?void 0:e.changeType)}function si(){return"function"===typeof __HLS_WORKER_BUNDLE__}function ni(){const e=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),t=self.URL.createObjectURL(e),r=new self.Worker(t);return{worker:r,objectURL:t}}function ai(e){const t=new self.URL(e,self.location.href).href,r=new self.Worker(t);return{worker:r,scriptURL:t}}function oi(e="",t=9e4){return{type:e,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}class li{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(e,t,r,i){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(e){this.initPTS=e,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(e,t){return!1}appendFrame(e,t,r){}demux(e,t){this.cachedData&&(e=Oe(this.cachedData,e),this.cachedData=null);let r,i=ee(e,0),s=i?i.length:0;const n=this._audioTrack,a=this._id3Track,o=i?ie(i):void 0,l=e.length;(null===this.basePTS||0===this.frameIndex&&u(o))&&(this.basePTS=di(o,t,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),i&&i.length>0&&a.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:It.audioId3,duration:Number.POSITIVE_INFINITY});while(s<l){if(this.canParse(e,s)){const t=this.appendFrame(n,e,s);t?(this.frameIndex++,this.lastPTS=t.sample.pts,s+=t.length,r=s):s=l}else re(e,s)?(i=ee(e,s),a.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:It.audioId3,duration:Number.POSITIVE_INFINITY}),s+=i.length,r=s):s++;if(s===l&&r!==l){const t=Q(e,r);this.cachedData?this.cachedData=Oe(this.cachedData,t):this.cachedData=t}}return{audioTrack:n,videoTrack:oi(),id3Track:a,textTrack:oi()}}demuxSampleAes(e,t,r){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(e){const t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:oi(),id3Track:this._id3Track,textTrack:oi()}}destroy(){}}const di=(e,t,r)=>{if(u(e))return 90*e;const i=r?9e4*r.baseTime/r.timescale:0;return 9e4*t+i};function hi(e,t,r,i){let s,n,a,o;const l=navigator.userAgent.toLowerCase(),d=i,h=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];s=1+((192&t[r+2])>>>6);const c=(60&t[r+2])>>>2;if(!(c>h.length-1))return a=(1&t[r+2])<<2,a|=(192&t[r+3])>>>6,T.log(`manifest codec:${i}, ADTS type:${s}, samplingIndex:${c}`),/firefox/i.test(l)?c>=6?(s=5,o=new Array(4),n=c-3):(s=2,o=new Array(2),n=c):-1!==l.indexOf("android")?(s=2,o=new Array(2),n=c):(s=5,o=new Array(4),i&&(-1!==i.indexOf("mp4a.40.29")||-1!==i.indexOf("mp4a.40.5"))||!i&&c>=6?n=c-3:((i&&-1!==i.indexOf("mp4a.40.2")&&(c>=6&&1===a||/vivaldi/i.test(l))||!i&&1===a)&&(s=2,o=new Array(2)),n=c)),o[0]=s<<3,o[0]|=(14&c)>>1,o[1]|=(1&c)<<7,o[1]|=a<<3,5===s&&(o[1]|=(14&n)>>1,o[2]=(1&n)<<7,o[2]|=8,o[3]=0),{config:o,samplerate:h[c],channelCount:a,codec:"mp4a.40."+s,manifestCodec:d};e.trigger(f.ERROR,{type:p.MEDIA_ERROR,details:m.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+c})}function ci(e,t){return 255===e[t]&&240===(246&e[t+1])}function ui(e,t){return 1&e[t+1]?7:9}function fi(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function pi(e,t){return t+5<e.length}function mi(e,t){return t+1<e.length&&ci(e,t)}function gi(e,t){return pi(e,t)&&ci(e,t)&&fi(e,t)<=e.length-t}function yi(e,t){if(mi(e,t)){const r=ui(e,t);if(t+r>=e.length)return!1;const i=fi(e,t);if(i<=r)return!1;const s=t+i;return s===e.length||mi(e,s)}return!1}function vi(e,t,r,i,s){if(!e.samplerate){const n=hi(t,r,i,s);if(!n)return;e.config=n.config,e.samplerate=n.samplerate,e.channelCount=n.channelCount,e.codec=n.codec,e.manifestCodec=n.manifestCodec,T.log(`parsed codec:${e.codec}, rate:${n.samplerate}, channels:${n.channelCount}`)}}function _i(e){return 9216e4/e}function Ei(e,t){const r=ui(e,t);if(t+r<=e.length){const i=fi(e,t)-r;if(i>0)return{headerLength:r,frameLength:i}}}function bi(e,t,r,i,s){const n=_i(e.samplerate),a=i+s*n,o=Ei(t,r);let l;if(o){const{frameLength:i,headerLength:s}=o,n=s+i,d=Math.max(0,r+n-t.length);d?(l=new Uint8Array(n-s),l.set(t.subarray(r+s,t.length),0)):l=t.subarray(r+s,r+n);const h={unit:l,pts:a};return d||e.samples.push(h),{sample:h,length:n,missing:d}}const d=t.length-r;l=new Uint8Array(d),l.set(t.subarray(r,t.length),0);const h={unit:l,pts:a};return{sample:h,length:d,missing:-1}}class Ti extends li{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t}resetInitSegment(e,t,r,i){super.resetInitSegment(e,t,r,i),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:i,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;const t=ee(e,0)||[];let r=t.length;for(let i=e.length;r<i;r++)if(yi(e,r))return T.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return gi(e,t)}appendFrame(e,t,r){vi(e,this.observer,t,r,e.manifestCodec);const i=bi(e,t,r,this.basePTS,this.frameIndex);if(i&&0===i.missing)return i}}const Si=/\/emsg[-/]ID3/i;class Li{constructor(e,t){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=t}resetTimeStamp(){}resetInitSegment(e,t,r,i){const s=this.videoTrack=oi("video",1),n=this.audioTrack=oi("audio",1),a=this.txtTrack=oi("text",1);if(this.id3Track=oi("id3",1),this.timeOffset=0,null==e||!e.byteLength)return;const o=we(e);if(o.video){const{id:e,timescale:t,codec:r}=o.video;s.id=e,s.timescale=a.timescale=t,s.codec=r}if(o.audio){const{id:e,timescale:t,codec:r}=o.audio;n.id=e,n.timescale=t,n.codec=r}a.id=ve.text,s.sampleDuration=0,s.duration=n.duration=i}resetContiguity(){this.remainderData=null}static probe(e){return e=e.length>16384?e.subarray(0,16384):e,Le(e,["moof"]).length>0}demux(e,t){this.timeOffset=t;let r=e;const i=this.videoTrack,s=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=Oe(this.remainderData,e));const t=Pe(r);this.remainderData=t.remainder,i.samples=t.valid||new Uint8Array}else i.samples=r;const n=this.extractID3Track(i,t);return s.samples=Me(t,i),{videoTrack:i,audioTrack:this.audioTrack,id3Track:n,textTrack:this.txtTrack}}flush(){const e=this.timeOffset,t=this.videoTrack,r=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;const i=this.extractID3Track(t,this.timeOffset);return r.samples=Me(e,t),{videoTrack:t,audioTrack:oi(),id3Track:i,textTrack:oi()}}extractID3Track(e,t){const r=this.id3Track;if(e.samples.length){const i=Le(e.samples,["emsg"]);i&&i.forEach(e=>{const i=$e(e);if(Si.test(i.schemeIdUri)){const e=u(i.presentationTime)?i.presentationTime/i.timeScale:t+i.presentationTimeDelta/i.timeScale;let s=4294967295===i.eventDuration?Number.POSITIVE_INFINITY:i.eventDuration/i.timeScale;s<=.001&&(s=Number.POSITIVE_INFINITY);const n=i.payload;r.samples.push({data:n,len:n.byteLength,dts:e,pts:e,type:It.emsg,duration:s})}})}return r}demuxSampleAes(e,t,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}}let Ai=null;const wi=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],Ri=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],ki=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],Ii=[0,1,1,4];function Di(e,t,r,i,s){if(r+24>t.length)return;const n=xi(t,r);if(n&&r+n.frameLength<=t.length){const a=9e4*n.samplesPerFrame/n.sampleRate,o=i+s*a,l={unit:t.subarray(r,r+n.frameLength),pts:o,dts:o};return e.config=[],e.channelCount=n.channelCount,e.samplerate=n.sampleRate,e.samples.push(l),{sample:l,length:n.frameLength,missing:0}}}function xi(e,t){const r=e[t+1]>>3&3,i=e[t+1]>>1&3,s=e[t+2]>>4&15,n=e[t+2]>>2&3;if(1!==r&&0!==s&&15!==s&&3!==n){const a=e[t+2]>>1&1,o=e[t+3]>>6,l=3===r?3-i:3===i?3:4,d=1e3*wi[14*l+s-1],h=3===r?0:2===r?1:2,c=Ri[3*h+n],u=3===o?1:2,f=ki[r][i],p=Ii[i],m=8*f*p,g=Math.floor(f*d/c+a)*p;if(null===Ai){const e=navigator.userAgent||"",t=e.match(/Chrome\/(\d+)/i);Ai=t?parseInt(t[1]):0}const y=!!Ai&&Ai<=87;return y&&2===i&&d>=224e3&&0===o&&(e[t+3]=128|e[t+3]),{sampleRate:c,channelCount:u,frameLength:g,samplesPerFrame:m}}}function Ci(e,t){return 255===e[t]&&224===(224&e[t+1])&&0!==(6&e[t+1])}function Pi(e,t){return t+1<e.length&&Ci(e,t)}function Oi(e,t){const r=4;return Ci(e,t)&&r<=e.length-t}function Mi(e,t){if(t+1<e.length&&Ci(e,t)){const r=4,i=xi(e,t);let s=r;null!=i&&i.frameLength&&(s=i.frameLength);const n=t+s;return n===e.length||Pi(e,n)}return!1}class Fi{constructor(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){const e=this.data,t=this.bytesAvailable,r=e.byteLength-t,i=new Uint8Array(4),s=Math.min(4,t);if(0===s)throw new Error("no bytes available");i.set(e.subarray(r,r+s)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*s,this.bytesAvailable-=s}skipBits(e){let t;e=Math.min(e,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,t=e>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}readBits(e){let t=Math.min(this.bitsAvailable,e);const r=this.word>>>32-t;if(e>32&&T.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return t=e-t,t>0&&this.bitsAvailable?r<<t|this.readBits(t):r}skipLZ(){let e;for(e=0;e<this.bitsAvailable;++e)if(0!==(this.word&2147483648>>>e))return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){const e=this.skipLZ();return this.readBits(e+1)-1}readEG(){const e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}readBoolean(){return 1===this.readBits(1)}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}skipScalingList(e){let t,r=8,i=8;for(let s=0;s<e;s++)0!==i&&(t=this.readEG(),i=(r+t+256)%256),r=0===i?r:i}readSPS(){let e,t,r,i=0,s=0,n=0,a=0;const o=this.readUByte.bind(this),l=this.readBits.bind(this),d=this.readUEG.bind(this),h=this.readBoolean.bind(this),c=this.skipBits.bind(this),u=this.skipEG.bind(this),f=this.skipUEG.bind(this),p=this.skipScalingList.bind(this);o();const m=o();if(l(5),c(3),o(),f(),100===m||110===m||122===m||244===m||44===m||83===m||86===m||118===m||128===m){const e=d();if(3===e&&c(1),f(),f(),c(1),h())for(t=3!==e?8:12,r=0;r<t;r++)h()&&p(r<6?16:64)}f();const g=d();if(0===g)d();else if(1===g)for(c(1),u(),u(),e=d(),r=0;r<e;r++)u();f(),c(1);const y=d(),v=d(),_=l(1);0===_&&c(1),c(1),h()&&(i=d(),s=d(),n=d(),a=d());let E=[1,1];if(h()&&h()){const e=o();switch(e){case 1:E=[1,1];break;case 2:E=[12,11];break;case 3:E=[10,11];break;case 4:E=[16,11];break;case 5:E=[40,33];break;case 6:E=[24,11];break;case 7:E=[20,11];break;case 8:E=[32,11];break;case 9:E=[80,33];break;case 10:E=[18,11];break;case 11:E=[15,11];break;case 12:E=[64,33];break;case 13:E=[160,99];break;case 14:E=[4,3];break;case 15:E=[3,2];break;case 16:E=[2,1];break;case 255:E=[o()<<8|o(),o()<<8|o()];break}}return{width:Math.ceil(16*(y+1)-2*i-2*s),height:(2-_)*(v+1)*16-(_?2:4)*(n+a),pixelRatio:E}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}}class Ni{constructor(e,t,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new Qr(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(e,t,r){const i=e[t].unit;if(i.length<=16)return;const s=i.subarray(16,i.length-i.length%16),n=s.buffer.slice(s.byteOffset,s.byteOffset+s.length);this.decryptBuffer(n).then(s=>{const n=new Uint8Array(s);i.set(n,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,r)})}decryptAacSamples(e,t,r){for(;;t++){if(t>=e.length)return void r();if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,r),!this.decrypter.isSync()))return}}getAvcEncryptedData(e){const t=16*Math.floor((e.length-48)/160)+16,r=new Int8Array(t);let i=0;for(let s=32;s<e.length-16;s+=160,i+=16)r.set(e.subarray(s,s+16),i);return r}getAvcDecryptedUnit(e,t){const r=new Uint8Array(t);let i=0;for(let s=32;s<e.length-16;s+=160,i+=16)e.set(r.subarray(i,i+16),s);return e}decryptAvcSample(e,t,r,i,s){const n=Be(s.data),a=this.getAvcEncryptedData(n);this.decryptBuffer(a.buffer).then(a=>{s.data=this.getAvcDecryptedUnit(n,a),this.decrypter.isSync()||this.decryptAvcSamples(e,t,r+1,i)})}decryptAvcSamples(e,t,r,i){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length)return void i();const s=e[t].units;for(;;r++){if(r>=s.length)break;const n=s[r];if(!(n.data.length<=48||1!==n.type&&5!==n.type)&&(this.decryptAvcSample(e,t,r,i,n),!this.decrypter.isSync()))return}}}}const Ui=188;class Bi{constructor(e,t,r){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=e,this.config=t,this.typeSupported=r}static probe(e){const t=Bi.syncOffset(e);return t>0&&T.warn("MPEG2-TS detected but first sync word found @ offset "+t),-1!==t}static syncOffset(e){const t=e.length;let r=Math.min(5*Ui,e.length-Ui)+1,i=0;while(i<r){let s=!1,n=-1,a=0;for(let o=i;o<t;o+=Ui){if(71!==e[o]){if(a)return-1;break}if(a++,-1===n&&(n=o,0!==n&&(r=Math.min(n+99*Ui,e.length-Ui)+1)),s||(s=0===Gi(e,o)),s&&a>1&&(0===n&&a>2||o+Ui>r))return n}i++}return-1}static createTrack(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:ve[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===e?t:void 0}}resetInitSegment(e,t,r,i){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=Bi.createTrack("video"),this._audioTrack=Bi.createTrack("audio",i),this._id3Track=Bi.createTrack("id3"),this._txtTrack=Bi.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=r,this._duration=i}resetTimeStamp(){}resetContiguity(){const{_audioTrack:e,_avcTrack:t,_id3Track:r}=this;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null}demux(e,t,r=!1,i=!1){let s;r||(this.sampleAes=null);const n=this._avcTrack,a=this._audioTrack,o=this._id3Track,l=this._txtTrack;let d=n.pid,h=n.pesData,c=a.pid,u=o.pid,g=a.pesData,y=o.pesData,v=null,_=this.pmtParsed,E=this._pmtId,b=e.length;if(this.remainderData&&(e=Oe(this.remainderData,e),b=e.length,this.remainderData=null),b<Ui&&!i)return this.remainderData=e,{audioTrack:a,videoTrack:n,id3Track:o,textTrack:l};const S=Math.max(0,Bi.syncOffset(e));b-=(b-S)%Ui,b<e.byteLength&&!i&&(this.remainderData=new Uint8Array(e.buffer,b,e.buffer.byteLength-b));let L=0;for(let f=S;f<b;f+=Ui)if(71===e[f]){const t=!!(64&e[f+1]),i=Gi(e,f),p=(48&e[f+3])>>4;let m;if(p>1){if(m=f+5+e[f+4],m===f+Ui)continue}else m=f+4;switch(i){case d:t&&(h&&(s=Vi(h))&&this.parseAVCPES(n,l,s,!1),h={data:[],size:0}),h&&(h.data.push(e.subarray(m,f+Ui)),h.size+=f+Ui-m);break;case c:if(t){if(g&&(s=Vi(g)))switch(a.segmentCodec){case"aac":this.parseAACPES(a,s);break;case"mp3":this.parseMPEGPES(a,s);break}g={data:[],size:0}}g&&(g.data.push(e.subarray(m,f+Ui)),g.size+=f+Ui-m);break;case u:t&&(y&&(s=Vi(y))&&this.parseID3PES(o,s),y={data:[],size:0}),y&&(y.data.push(e.subarray(m,f+Ui)),y.size+=f+Ui-m);break;case 0:t&&(m+=e[m]+1),E=this._pmtId=ji(e,m);break;case E:{t&&(m+=e[m]+1);const i=Ki(e,m,this.typeSupported,r);d=i.avc,d>0&&(n.pid=d),c=i.audio,c>0&&(a.pid=c,a.segmentCodec=i.segmentCodec),u=i.id3,u>0&&(o.pid=u),null===v||_||(T.warn(`MPEG-TS PMT found at ${f} after unknown PID '${v}'. Backtracking to sync byte @${S} to parse all TS packets.`),v=null,f=S-188),_=this.pmtParsed=!0;break}case 17:case 8191:break;default:v=i;break}}else L++;if(L>0){const e=new Error(`Found ${L} TS packet/s that do not start with 0x47`);this.observer.emit(f.ERROR,f.ERROR,{type:p.MEDIA_ERROR,details:m.FRAG_PARSING_ERROR,fatal:!1,error:e,reason:e.message})}n.pesData=h,a.pesData=g,o.pesData=y;const A={audioTrack:a,videoTrack:n,id3Track:o,textTrack:l};return i&&this.extractRemainingSamples(A),A}flush(){const{remainderData:e}=this;let t;return this.remainderData=null,t=e?this.demux(e,-1,!1,!0):{videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t}extractRemainingSamples(e){const{audioTrack:t,videoTrack:r,id3Track:i,textTrack:s}=e,n=r.pesData,a=t.pesData,o=i.pesData;let l;if(n&&(l=Vi(n))?(this.parseAVCPES(r,s,l,!0),r.pesData=null):r.pesData=n,a&&(l=Vi(a))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,l);break;case"mp3":this.parseMPEGPES(t,l);break}t.pesData=null}else null!=a&&a.size&&T.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=a;o&&(l=Vi(o))?(this.parseID3PES(i,l),i.pesData=null):i.pesData=o}demuxSampleAes(e,t,r){const i=this.demux(e,r,!0,!this.config.progressive),s=this.sampleAes=new Ni(this.observer,this.config,t);return this.decrypt(i,s)}decrypt(e,t){return new Promise(r=>{const{audioTrack:i,videoTrack:s}=e;i.samples&&"aac"===i.segmentCodec?t.decryptAacSamples(i.samples,0,()=>{s.samples?t.decryptAvcSamples(s.samples,0,0,()=>{r(e)}):r(e)}):s.samples&&t.decryptAvcSamples(s.samples,0,0,()=>{r(e)})})}destroy(){this._duration=0}parseAVCPES(e,t,r,i){const s=this.parseAVCNALu(e,r.data);let n,a=this.avcSample,o=!1;r.data=null,a&&s.length&&!e.audFound&&(Hi(a,e),a=this.avcSample=$i(!1,r.pts,r.dts,"")),s.forEach(i=>{var s;switch(i.type){case 1:{let t=!1;n=!0;const s=i.data;if(o&&s.length>4){const e=new Fi(s).readSliceType();2!==e&&4!==e&&7!==e&&9!==e||(t=!0)}var l;if(t)null!=(l=a)&&l.frame&&!a.key&&(Hi(a,e),a=this.avcSample=null);a||(a=this.avcSample=$i(!0,r.pts,r.dts,"")),a.frame=!0,a.key=t;break}case 5:n=!0,null!=(s=a)&&s.frame&&!a.key&&(Hi(a,e),a=this.avcSample=null),a||(a=this.avcSample=$i(!0,r.pts,r.dts,"")),a.key=!0,a.frame=!0;break;case 6:n=!0,Ue(i.data,1,r.pts,t.samples);break;case 7:if(n=!0,o=!0,!e.sps){const t=i.data,r=new Fi(t),s=r.readSPS();e.width=s.width,e.height=s.height,e.pixelRatio=s.pixelRatio,e.sps=[t],e.duration=this._duration;const n=t.subarray(1,4);let a="avc1.";for(let e=0;e<3;e++){let t=n[e].toString(16);t.length<2&&(t="0"+t),a+=t}e.codec=a}break;case 8:n=!0,e.pps||(e.pps=[i.data]);break;case 9:n=!1,e.audFound=!0,a&&Hi(a,e),a=this.avcSample=$i(!1,r.pts,r.dts,"");break;case 12:n=!0;break;default:n=!1,a&&(a.debug+="unknown NAL "+i.type+" ");break}if(a&&n){const e=a.units;e.push(i)}}),i&&a&&(Hi(a,e),this.avcSample=null)}getLastNalUnit(e){var t;let r,i=this.avcSample;if(i&&0!==i.units.length||(i=e[e.length-1]),null!=(t=i)&&t.units){const e=i.units;r=e[e.length-1]}return r}parseAVCNALu(e,t){const r=t.byteLength;let i=e.naluState||0;const s=i,n=[];let a,o,l,d=0,h=-1,c=0;-1===i&&(h=0,c=31&t[0],i=0,d=1);while(d<r)if(a=t[d++],i)if(1!==i)if(a)if(1===a){if(h>=0){const e={data:t.subarray(h,d-i-1),type:c};n.push(e)}else{const r=this.getLastNalUnit(e.samples);if(r&&(s&&d<=4-s&&r.state&&(r.data=r.data.subarray(0,r.data.byteLength-s)),o=d-i-1,o>0)){const e=new Uint8Array(r.data.byteLength+o);e.set(r.data,0),e.set(t.subarray(0,o),r.data.byteLength),r.data=e,r.state=0}}d<r?(l=31&t[d],h=d,c=l,i=0):i=-1}else i=0;else i=3;else i=a?0:2;else i=a?0:1;if(h>=0&&i>=0){const e={data:t.subarray(h,r),type:c,state:i};n.push(e)}if(0===n.length){const r=this.getLastNalUnit(e.samples);if(r){const e=new Uint8Array(r.data.byteLength+t.byteLength);e.set(r.data,0),e.set(t,r.data.byteLength),r.data=e}}return e.naluState=i,n}parseAACPES(e,t){let r=0;const i=this.aacOverFlow;let s,n,a,o=t.data;if(i){this.aacOverFlow=null;const t=i.missing,s=i.sample.unit.byteLength;if(-1===t){const e=new Uint8Array(s+o.byteLength);e.set(i.sample.unit,0),e.set(o,s),o=e}else{const n=s-t;i.sample.unit.set(o.subarray(0,t),n),e.samples.push(i.sample),r=i.missing}}for(s=r,n=o.length;s<n-1;s++)if(mi(o,s))break;if(s!==r){let e;const t=s<n-1;e=t?"AAC PES did not start with ADTS header,offset:"+s:"No ADTS header found in AAC PES";const r=new Error(e);if(T.warn("parsing error: "+e),this.observer.emit(f.ERROR,f.ERROR,{type:p.MEDIA_ERROR,details:m.FRAG_PARSING_ERROR,fatal:!1,levelRetry:t,error:r,reason:e}),!t)return}if(vi(e,this.observer,o,s,this.audioCodec),void 0!==t.pts)a=t.pts;else{if(!i)return void T.warn("[tsdemuxer]: AAC PES unknown PTS");{const t=_i(e.samplerate);a=i.sample.pts+t}}let l,d=0;while(s<n){if(l=bi(e,o,s,a,d),s+=l.length,l.missing){this.aacOverFlow=l;break}for(d++;s<n-1;s++)if(mi(o,s))break}}parseMPEGPES(e,t){const r=t.data,i=r.length;let s=0,n=0;const a=t.pts;if(void 0!==a)while(n<i)if(Pi(r,n)){const t=Di(e,r,n,a,s);if(!t)break;n+=t.length,s++}else n++;else T.warn("[tsdemuxer]: MPEG PES unknown PTS")}parseID3PES(e,t){if(void 0===t.pts)return void T.warn("[tsdemuxer]: ID3 PES unknown PTS");const r=d({},t,{type:this._avcTrack?It.emsg:It.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(r)}}function $i(e,t,r,i){return{key:e,frame:!1,pts:t,dts:r,units:[],debug:i,length:0}}function Gi(e,t){return((31&e[t+1])<<8)+e[t+2]}function ji(e,t){return(31&e[t+10])<<8|e[t+11]}function Ki(e,t,r,i){const s={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},n=(15&e[t+1])<<8|e[t+2],a=t+3+n-4,o=(15&e[t+10])<<8|e[t+11];t+=12+o;while(t<a){const n=Gi(e,t);switch(e[t]){case 207:if(!i){T.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:-1===s.audio&&(s.audio=n);break;case 21:-1===s.id3&&(s.id3=n);break;case 219:if(!i){T.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:-1===s.avc&&(s.avc=n);break;case 3:case 4:!0!==r.mpeg&&!0!==r.mp3?T.log("MPEG audio found, not supported in this browser"):-1===s.audio&&(s.audio=n,s.segmentCodec="mp3");break;case 36:T.warn("Unsupported HEVC stream type found");break}t+=5+((15&e[t+3])<<8|e[t+4])}return s}function Vi(e){let t,r,i,s,n,a=0;const o=e.data;if(!e||0===e.size)return null;while(o[0].length<19&&o.length>1){const e=new Uint8Array(o[0].length+o[1].length);e.set(o[0]),e.set(o[1],o[0].length),o[0]=e,o.splice(1,1)}t=o[0];const l=(t[0]<<16)+(t[1]<<8)+t[2];if(1===l){if(r=(t[4]<<8)+t[5],r&&r>e.size-6)return null;const l=t[7];192&l&&(s=536870912*(14&t[9])+4194304*(255&t[10])+16384*(254&t[11])+128*(255&t[12])+(254&t[13])/2,64&l?(n=536870912*(14&t[14])+4194304*(255&t[15])+16384*(254&t[16])+128*(255&t[17])+(254&t[18])/2,s-n>54e5&&(T.warn(Math.round((s-n)/9e4)+"s delta between PTS and DTS, align them"),s=n)):n=s),i=t[8];let d=i+9;if(e.size<=d)return null;e.size-=d;const h=new Uint8Array(e.size);for(let e=0,r=o.length;e<r;e++){t=o[e];let r=t.byteLength;if(d){if(d>r){d-=r;continue}t=t.subarray(d),r-=d,d=0}h.set(t,a),a+=r}return r&&(r-=i+3),{data:h,pts:s,dts:n,len:r}}return null}function Hi(e,t){if(e.units.length&&e.frame){if(void 0===e.pts){const r=t.samples,i=r.length;if(!i)return void t.dropped++;{const t=r[i-1];e.pts=t.pts,e.dts=t.dts}}t.samples.push(e)}e.debug.length&&T.log(e.pts+"/"+e.dts+":"+e.debug)}class Yi extends li{resetInitSegment(e,t,r,i){super.resetInitSegment(e,t,r,i),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:i,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;const t=ee(e,0)||[];let r=t.length;for(let i=e.length;r<i;r++)if(Mi(e,r))return T.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return Oi(e,t)}appendFrame(e,t,r){if(null!==this.basePTS)return Di(e,t,r,this.basePTS,this.frameIndex)}}class zi{static getSilentFrame(e,t){switch(e){case"mp4a.40.2":if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(1===t)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}}}const Wi=Math.pow(2,32)-1;class qi{static init(){let e;for(e in qi.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},qi.types)qi.types.hasOwnProperty(e)&&(qi.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);const t=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),r=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);qi.HDLR_TYPES={video:t,audio:r};const i=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),s=new Uint8Array([0,0,0,0,0,0,0,0]);qi.STTS=qi.STSC=qi.STCO=s,qi.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),qi.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),qi.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),qi.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const n=new Uint8Array([105,115,111,109]),a=new Uint8Array([97,118,99,49]),o=new Uint8Array([0,0,0,1]);qi.FTYP=qi.box(qi.types.ftyp,n,o,n,a),qi.DINF=qi.box(qi.types.dinf,qi.box(qi.types.dref,i))}static box(e,...t){let r=8,i=t.length;const s=i;while(i--)r+=t[i].byteLength;const n=new Uint8Array(r);for(n[0]=r>>24&255,n[1]=r>>16&255,n[2]=r>>8&255,n[3]=255&r,n.set(e,4),i=0,r=8;i<s;i++)n.set(t[i],r),r+=t[i].byteLength;return n}static hdlr(e){return qi.box(qi.types.hdlr,qi.HDLR_TYPES[e])}static mdat(e){return qi.box(qi.types.mdat,e)}static mdhd(e,t){t*=e;const r=Math.floor(t/(Wi+1)),i=Math.floor(t%(Wi+1));return qi.box(qi.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,r>>24,r>>16&255,r>>8&255,255&r,i>>24,i>>16&255,i>>8&255,255&i,85,196,0,0]))}static mdia(e){return qi.box(qi.types.mdia,qi.mdhd(e.timescale,e.duration),qi.hdlr(e.type),qi.minf(e))}static mfhd(e){return qi.box(qi.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e]))}static minf(e){return"audio"===e.type?qi.box(qi.types.minf,qi.box(qi.types.smhd,qi.SMHD),qi.DINF,qi.stbl(e)):qi.box(qi.types.minf,qi.box(qi.types.vmhd,qi.VMHD),qi.DINF,qi.stbl(e))}static moof(e,t,r){return qi.box(qi.types.moof,qi.mfhd(e),qi.traf(r,t))}static moov(e){let t=e.length;const r=[];while(t--)r[t]=qi.trak(e[t]);return qi.box.apply(null,[qi.types.moov,qi.mvhd(e[0].timescale,e[0].duration)].concat(r).concat(qi.mvex(e)))}static mvex(e){let t=e.length;const r=[];while(t--)r[t]=qi.trex(e[t]);return qi.box.apply(null,[qi.types.mvex,...r])}static mvhd(e,t){t*=e;const r=Math.floor(t/(Wi+1)),i=Math.floor(t%(Wi+1)),s=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,r>>24,r>>16&255,r>>8&255,255&r,i>>24,i>>16&255,i>>8&255,255&i,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return qi.box(qi.types.mvhd,s)}static sdtp(e){const t=e.samples||[],r=new Uint8Array(4+t.length);let i,s;for(i=0;i<t.length;i++)s=t[i].flags,r[i+4]=s.dependsOn<<4|s.isDependedOn<<2|s.hasRedundancy;return qi.box(qi.types.sdtp,r)}static stbl(e){return qi.box(qi.types.stbl,qi.stsd(e),qi.box(qi.types.stts,qi.STTS),qi.box(qi.types.stsc,qi.STSC),qi.box(qi.types.stsz,qi.STSZ),qi.box(qi.types.stco,qi.STCO))}static avc1(e){let t,r,i,s=[],n=[];for(t=0;t<e.sps.length;t++)r=e.sps[t],i=r.byteLength,s.push(i>>>8&255),s.push(255&i),s=s.concat(Array.prototype.slice.call(r));for(t=0;t<e.pps.length;t++)r=e.pps[t],i=r.byteLength,n.push(i>>>8&255),n.push(255&i),n=n.concat(Array.prototype.slice.call(r));const a=qi.box(qi.types.avcC,new Uint8Array([1,s[3],s[4],s[5],255,224|e.sps.length].concat(s).concat([e.pps.length]).concat(n))),o=e.width,l=e.height,d=e.pixelRatio[0],h=e.pixelRatio[1];return qi.box(qi.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,o>>8&255,255&o,l>>8&255,255&l,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),a,qi.box(qi.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),qi.box(qi.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,255&d,h>>24,h>>16&255,h>>8&255,255&h])))}static esds(e){const t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))}static mp4a(e){const t=e.samplerate;return qi.box(qi.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,255&t,0,0]),qi.box(qi.types.esds,qi.esds(e)))}static mp3(e){const t=e.samplerate;return qi.box(qi.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,255&t,0,0]))}static stsd(e){return"audio"===e.type?"mp3"===e.segmentCodec&&"mp3"===e.codec?qi.box(qi.types.stsd,qi.STSD,qi.mp3(e)):qi.box(qi.types.stsd,qi.STSD,qi.mp4a(e)):qi.box(qi.types.stsd,qi.STSD,qi.avc1(e))}static tkhd(e){const t=e.id,r=e.duration*e.timescale,i=e.width,s=e.height,n=Math.floor(r/(Wi+1)),a=Math.floor(r%(Wi+1));return qi.box(qi.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,0,0,0,0,n>>24,n>>16&255,n>>8&255,255&n,a>>24,a>>16&255,a>>8&255,255&a,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,i>>8&255,255&i,0,0,s>>8&255,255&s,0,0]))}static traf(e,t){const r=qi.sdtp(e),i=e.id,s=Math.floor(t/(Wi+1)),n=Math.floor(t%(Wi+1));return qi.box(qi.types.traf,qi.box(qi.types.tfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i])),qi.box(qi.types.tfdt,new Uint8Array([1,0,0,0,s>>24,s>>16&255,s>>8&255,255&s,n>>24,n>>16&255,n>>8&255,255&n])),qi.trun(e,r.length+16+20+8+16+8+8),r)}static trak(e){return e.duration=e.duration||4294967295,qi.box(qi.types.trak,qi.tkhd(e),qi.mdia(e))}static trex(e){const t=e.id;return qi.box(qi.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,t){const r=e.samples||[],i=r.length,s=12+16*i,n=new Uint8Array(s);let a,o,l,d,h,c;for(t+=8+s,n.set(["video"===e.type?1:0,0,15,1,i>>>24&255,i>>>16&255,i>>>8&255,255&i,t>>>24&255,t>>>16&255,t>>>8&255,255&t],0),a=0;a<i;a++)o=r[a],l=o.duration,d=o.size,h=o.flags,c=o.cts,n.set([l>>>24&255,l>>>16&255,l>>>8&255,255&l,d>>>24&255,d>>>16&255,d>>>8&255,255&d,h.isLeading<<2|h.dependsOn,h.isDependedOn<<6|h.hasRedundancy<<4|h.paddingValue<<1|h.isNonSync,61440&h.degradPrio,15&h.degradPrio,c>>>24&255,c>>>16&255,c>>>8&255,255&c],12+16*a);return qi.box(qi.types.trun,n)}static initSegment(e){qi.types||qi.init();const t=qi.moov(e),r=new Uint8Array(qi.FTYP.byteLength+t.byteLength);return r.set(qi.FTYP),r.set(t,qi.FTYP.byteLength),r}}qi.types=void 0,qi.HDLR_TYPES=void 0,qi.STTS=void 0,qi.STSC=void 0,qi.STCO=void 0,qi.STSZ=void 0,qi.VMHD=void 0,qi.SMHD=void 0,qi.STSD=void 0,qi.FTYP=void 0,qi.DINF=void 0;const Xi=9e4;function Qi(e,t,r=1,i=!1){const s=e*t*r;return i?Math.round(s):s}function Zi(e,t,r=1,i=!1){return Qi(e,t,1/r,i)}function Ji(e,t=!1){return Qi(e,1e3,1/Xi,t)}function es(e,t=1){return Qi(e,Xi,1/t)}const ts=1e4,rs=1024,is=1152;let ss,ns=null,as=null;class os{constructor(e,t,r,i=""){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=e,this.config=t,this.typeSupported=r,this.ISGenerated=!1,null===ns){const e=navigator.userAgent||"",t=e.match(/Chrome\/(\d+)/i);ns=t?parseInt(t[1]):0}if(null===as){const e=navigator.userAgent.match(/Safari\/(\d+)/i);as=e?parseInt(e[1]):0}}destroy(){}resetTimeStamp(e){T.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e}resetNextTimestamp(){T.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){T.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1}getVideoStartPts(e){let t=!1;const r=e.reduce((e,r)=>{const i=r.pts-e;return i<-4294967296?(t=!0,ls(e,r.pts)):i>0?e:r.pts},e[0].pts);return t&&T.debug("PTS rollover detected"),r}remux(e,t,r,i,s,n,a,o){let l,d,h,c,u,f,p=s,m=s;const g=e.pid>-1,y=t.pid>-1,v=t.samples.length,_=e.samples.length>0,E=a&&v>0||v>1,b=(!g||_)&&(!y||E)||this.ISGenerated||a;if(b){this.ISGenerated||(h=this.generateIS(e,t,s,n));const r=this.isVideoContiguous;let i,a=-1;if(E&&(a=ds(t.samples),!r&&this.config.forceKeyFrameOnDiscontinuity))if(f=!0,a>0){T.warn(`[mp4-remuxer]: Dropped ${a} out of ${v} video samples due to a missing keyframe`);const e=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(a),t.dropped+=a,m+=(t.samples[0].pts-e)/t.inputTimeScale,i=m}else-1===a&&(T.warn(`[mp4-remuxer]: No keyframe found out of ${v} video samples`),f=!1);if(this.ISGenerated){if(_&&E){const r=this.getVideoStartPts(t.samples),i=ls(e.samples[0].pts,r)-r,s=i/t.inputTimeScale;p+=Math.max(0,s),m+=Math.max(0,-s)}if(_){if(e.samplerate||(T.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),h=this.generateIS(e,t,s,n)),d=this.remuxAudio(e,p,this.isAudioContiguous,n,y||E||o===_t.AUDIO?m:void 0),E){const i=d?d.endPTS-d.startPTS:0;t.inputTimeScale||(T.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),h=this.generateIS(e,t,s,n)),l=this.remuxVideo(t,m,r,i)}}else E&&(l=this.remuxVideo(t,m,r,0));l&&(l.firstKeyFrame=a,l.independent=-1!==a,l.firstKeyFramePTS=i)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(u=hs(r,s,this._initPTS,this._initDTS)),i.samples.length&&(c=cs(i,s,this._initPTS))),{audio:d,video:l,initSegment:h,independent:f,text:c,id3:u}}generateIS(e,t,r,i){const s=e.samples,n=t.samples,a=this.typeSupported,o={},l=this._initPTS;let d,h,c,u=!l||i,f="audio/mp4";if(u&&(d=h=1/0),e.config&&s.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":a.mpeg?(f="audio/mpeg",e.codec=""):a.mp3&&(e.codec="mp3");break}o.audio={id:"audio",container:f,codec:e.codec,initSegment:"mp3"===e.segmentCodec&&a.mpeg?new Uint8Array(0):qi.initSegment([e]),metadata:{channelCount:e.channelCount}},u&&(c=e.inputTimeScale,l&&c===l.timescale?u=!1:d=h=s[0].pts-Math.round(c*r))}if(t.sps&&t.pps&&n.length&&(t.timescale=t.inputTimeScale,o.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:qi.initSegment([t]),metadata:{width:t.width,height:t.height}},u))if(c=t.inputTimeScale,l&&c===l.timescale)u=!1;else{const e=this.getVideoStartPts(n),t=Math.round(c*r);h=Math.min(h,ls(n[0].dts,e)-t),d=Math.min(d,e-t)}if(Object.keys(o).length)return this.ISGenerated=!0,u?(this._initPTS={baseTime:d,timescale:c},this._initDTS={baseTime:h,timescale:c}):d=c=void 0,{tracks:o,initPTS:d,timescale:c}}remuxVideo(e,t,r,i){const s=e.inputTimeScale,n=e.samples,a=[],o=n.length,l=this._initPTS;let h,c,u=this.nextAvcDts,g=8,y=this.videoSampleDuration,v=Number.POSITIVE_INFINITY,_=Number.NEGATIVE_INFINITY,E=!1;if(!r||null===u){const e=t*s,r=n[0].pts-ls(n[0].dts,n[0].pts);u=e-r}const b=l.baseTime*s/l.timescale;for(let d=0;d<o;d++){const e=n[d];e.pts=ls(e.pts-b,u),e.dts=ls(e.dts-b,u),e.dts<n[d>0?d-1:d].dts&&(E=!0)}E&&n.sort((function(e,t){const r=e.dts-t.dts,i=e.pts-t.pts;return r||i})),h=n[0].dts,c=n[n.length-1].dts;const S=c-h,L=S?Math.round(S/(o-1)):y||e.inputTimeScale/30;if(r){const e=h-u,t=e>L,r=e<-1;if((t||r)&&(t?T.warn(`AVC: ${Ji(e,!0)} ms (${e}dts) hole between fragments detected, filling it`):T.warn(`AVC: ${Ji(-e,!0)} ms (${e}dts) overlapping between fragments detected`),!r||u>=n[0].pts)){h=u;const t=n[0].pts-e;n[0].dts=h,n[0].pts=t,T.log(`Video: First PTS/DTS adjusted: ${Ji(t,!0)}/${Ji(h,!0)}, delta: ${Ji(e,!0)} ms`)}}h=Math.max(0,h);let A=0,w=0;for(let d=0;d<o;d++){const e=n[d],t=e.units,r=t.length;let i=0;for(let s=0;s<r;s++)i+=t[s].data.length;w+=i,A+=r,e.length=i,e.dts=Math.max(e.dts,h),v=Math.min(e.pts,v),_=Math.max(e.pts,_)}c=n[o-1].dts;const R=w+4*A+8;let k;try{k=new Uint8Array(R)}catch(U){return void this.observer.emit(f.ERROR,f.ERROR,{type:p.MUX_ERROR,details:m.REMUX_ALLOC_ERROR,fatal:!1,error:U,bytes:R,reason:"fail allocating video mdat "+R})}const I=new DataView(k.buffer);I.setUint32(0,R),k.set(qi.types.mdat,4);let D=!1,x=Number.POSITIVE_INFINITY,C=Number.POSITIVE_INFINITY,P=Number.NEGATIVE_INFINITY,O=Number.NEGATIVE_INFINITY;for(let d=0;d<o;d++){const e=n[d],t=e.units;let r,l=0;for(let i=0,s=t.length;i<s;i++){const e=t[i],r=e.data,s=e.data.byteLength;I.setUint32(g,s),g+=4,k.set(r,g),g+=s,l+=4+s}if(d<o-1)y=n[d+1].dts-e.dts,r=n[d+1].pts-e.pts;else{const t=this.config,a=d>0?e.dts-n[d-1].dts:L;if(r=d>0?e.pts-n[d-1].pts:L,t.stretchShortVideoTrack&&null!==this.nextAudioPts){const r=Math.floor(t.maxBufferHole*s),n=(i?v+i*s:this.nextAudioPts)-e.pts;n>r?(y=n-a,y<0?y=a:D=!0,T.log(`[mp4-remuxer]: It is approximately ${n/90} ms to the next segment; using duration ${y/90} ms for the last video frame.`)):y=a}else y=a}const h=Math.round(e.pts-e.dts);x=Math.min(x,y),P=Math.max(P,y),C=Math.min(C,r),O=Math.max(O,r),a.push(new us(e.key,y,l,h))}if(a.length)if(ns){if(ns<70){const e=a[0].flags;e.dependsOn=2,e.isNonSync=0}}else if(as&&O-C<P-x&&L/P<.025&&0===a[0].cts){T.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let e=h;for(let t=0,r=a.length;t<r;t++){const i=e+a[t].duration,s=e+a[t].cts;if(t<r-1){const e=i+a[t+1].cts;a[t].duration=e-s}else a[t].duration=t?a[t-1].duration:L;a[t].cts=0,e=i}}y=D||!y?L:y,this.nextAvcDts=u=c+y,this.videoSampleDuration=y,this.isVideoContiguous=!0;const M=qi.moof(e.sequenceNumber++,h,d({},e,{samples:a})),F="video",N={data1:M,data2:k,startPTS:v/s,endPTS:(_+y)/s,startDTS:h/s,endDTS:u/s,type:F,hasAudio:!1,hasVideo:!0,nb:a.length,dropped:e.dropped};return e.samples=[],e.dropped=0,N}remuxAudio(e,t,r,i,s){const n=e.inputTimeScale,a=e.samplerate?e.samplerate:n,o=n/a,l="aac"===e.segmentCodec?rs:is,h=l*o,c=this._initPTS,u="mp3"===e.segmentCodec&&this.typeSupported.mpeg,g=[],y=void 0!==s;let v=e.samples,_=u?0:8,E=this.nextAudioPts||-1;const b=t*n,S=c.baseTime*n/c.timescale;if(this.isAudioContiguous=r=r||v.length&&E>0&&(i&&Math.abs(b-E)<9e3||Math.abs(ls(v[0].pts-S,b)-E)<20*h),v.forEach((function(e){e.pts=ls(e.pts-S,b)})),!r||E<0){if(v=v.filter(e=>e.pts>=0),!v.length)return;E=0===s?0:i&&!y?Math.max(0,b):v[0].pts}if("aac"===e.segmentCodec){const t=this.config.maxAudioFramesDrift;for(let r=0,i=E;r<v.length;r++){const s=v[r],a=s.pts,o=a-i,l=Math.abs(1e3*o/n);if(o<=-t*h&&y)0===r&&(T.warn(`Audio frame @ ${(a/n).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*o/n)} ms.`),this.nextAudioPts=E=i=a);else if(o>=t*h&&l<ts&&y){let t=Math.round(o/h);i=a-t*h,i<0&&(t--,i+=h),0===r&&(this.nextAudioPts=E=i),T.warn(`[mp4-remuxer]: Injecting ${t} audio frame @ ${(i/n).toFixed(3)}s due to ${Math.round(1e3*o/n)} ms gap.`);for(let n=0;n<t;n++){const t=Math.max(i,0);let n=zi.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);n||(T.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),n=s.unit.subarray()),v.splice(r,0,{unit:n,pts:t}),i+=h,r++}}s.pts=i,i+=h}}let L,A=null,w=null,R=0,k=v.length;while(k--)R+=v[k].unit.byteLength;for(let d=0,T=v.length;d<T;d++){const t=v[d],i=t.unit;let s=t.pts;if(null!==w){const e=g[d-1];e.duration=Math.round((s-w)/o)}else{if(r&&"aac"===e.segmentCodec&&(s=E),A=s,!(R>0))return;R+=_;try{L=new Uint8Array(R)}catch(F){return void this.observer.emit(f.ERROR,f.ERROR,{type:p.MUX_ERROR,details:m.REMUX_ALLOC_ERROR,fatal:!1,error:F,bytes:R,reason:"fail allocating audio mdat "+R})}if(!u){const e=new DataView(L.buffer);e.setUint32(0,R),L.set(qi.types.mdat,4)}}L.set(i,_);const n=i.byteLength;_+=n,g.push(new us(!0,l,n,0)),w=s}const I=g.length;if(!I)return;const D=g[g.length-1];this.nextAudioPts=E=w+o*D.duration;const x=u?new Uint8Array(0):qi.moof(e.sequenceNumber++,A/o,d({},e,{samples:g}));e.samples=[];const C=A/n,P=E/n,O="audio",M={data1:x,data2:L,startPTS:C,endPTS:P,startDTS:C,endDTS:P,type:O,hasAudio:!0,hasVideo:!1,nb:I};return this.isAudioContiguous=!0,M}remuxEmptyAudio(e,t,r,i){const s=e.inputTimeScale,n=e.samplerate?e.samplerate:s,a=s/n,o=this.nextAudioPts,l=this._initDTS,d=9e4*l.baseTime/l.timescale,h=(null!==o?o:i.startDTS*s)+d,c=i.endDTS*s+d,u=a*rs,f=Math.ceil((c-h)/u),p=zi.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(T.warn("[mp4-remuxer]: remux empty Audio"),!p)return void T.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");const m=[];for(let g=0;g<f;g++){const e=h+g*u;m.push({unit:p,pts:e,dts:e})}return e.samples=m,this.remuxAudio(e,t,r,!1)}}function ls(e,t){let r;if(null===t)return e;r=t<e?-8589934592:8589934592;while(Math.abs(e-t)>4294967296)e+=r;return e}function ds(e){for(let t=0;t<e.length;t++)if(e[t].key)return t;return-1}function hs(e,t,r,i){const s=e.samples.length;if(!s)return;const n=e.inputTimeScale;for(let o=0;o<s;o++){const s=e.samples[o];s.pts=ls(s.pts-r.baseTime*n/r.timescale,t*n)/n,s.dts=ls(s.dts-i.baseTime*n/i.timescale,t*n)/n}const a=e.samples;return e.samples=[],{samples:a}}function cs(e,t,r){const i=e.samples.length;if(!i)return;const s=e.inputTimeScale;for(let a=0;a<i;a++){const i=e.samples[a];i.pts=ls(i.pts-r.baseTime*s/r.timescale,t*s)/s}e.samples.sort((e,t)=>e.pts-t.pts);const n=e.samples;return e.samples=[],{samples:n}}class us{constructor(e,t,r,i){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=t,this.size=r,this.cts=i,this.flags=new fs(e)}}class fs{constructor(e){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=e?2:1,this.isNonSync=e?0:1}}class ps{constructor(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null}destroy(){}resetTimeStamp(e){this.initPTS=e,this.lastEndTime=null}resetNextTimestamp(){this.lastEndTime=null}resetInitSegment(e,t,r,i){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment(Re(e,i)),this.emitInitSegment=!0}generateInitSegment(e){let{audioCodec:t,videoCodec:r}=this;if(null==e||!e.byteLength)return this.initTracks=void 0,void(this.initData=void 0);const i=this.initData=we(e);t||(t=gs(i.audio,D.AUDIO)),r||(r=gs(i.video,D.VIDEO));const s={};i.audio&&i.video?s.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:e,id:"main"}:i.audio?s.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:i.video?s.video={container:"video/mp4",codec:r,initSegment:e,id:"main"}:T.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=s}remux(e,t,r,i,s,n){var a,o;let{initPTS:l,lastEndTime:d}=this;const h={audio:void 0,video:void 0,text:i,id3:r,initSegment:void 0};u(d)||(d=this.lastEndTime=s||0);const c=t.samples;if(null==c||!c.length)return h;const f={initPTS:void 0,timescale:1};let p=this.initData;if(null!=(a=p)&&a.length||(this.generateInitSegment(c),p=this.initData),null==(o=p)||!o.length)return T.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),h;this.emitInitSegment&&(f.tracks=this.initTracks,this.emitInitSegment=!1);const m=De(c,p),g=Ie(p,c),y=null===g?s:g;(ms(l,y,s,m)||f.timescale!==l.timescale&&n)&&(f.initPTS=y-s,l&&1===l.timescale&&T.warn("Adjusting initPTS by "+(f.initPTS-l.baseTime)),this.initPTS=l={baseTime:f.initPTS,timescale:1});const v=e?y-l.baseTime/l.timescale:d,_=v+m;Ce(p,c,l.baseTime/l.timescale),m>0?this.lastEndTime=_:(T.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const E=!!p.audio,b=!!p.video;let S="";E&&(S+="audio"),b&&(S+="video");const L={data1:c,startPTS:v,startDTS:v,endPTS:_,endDTS:_,type:S,hasAudio:E,hasVideo:b,nb:1,dropped:0};return h.audio="audio"===L.type?L:void 0,h.video="audio"!==L.type?L:void 0,h.initSegment=f,h.id3=hs(r,s,l,l),i.samples.length&&(h.text=cs(i,s,l)),h}}function ms(e,t,r,i){if(null===e)return!0;const s=Math.max(i,1),n=t-e.baseTime/e.timescale;return Math.abs(n-r)>s}function gs(e,t){const r=null==e?void 0:e.codec;return r&&r.length>4?r:"hvc1"===r||"hev1"===r?"hvc1.1.6.L120.90":"av01"===r?"av01.0.04M.08":"avc1"===r||t===D.VIDEO?"avc1.42e01e":"mp4a.40.5"}try{ss=self.performance.now.bind(self.performance)}catch(Na){T.debug("Unable to use Performance API on this environment"),ss="undefined"!==typeof self&&self.Date.now}const ys=[{demux:Li,remux:ps},{demux:Bi,remux:os},{demux:Ti,remux:os},{demux:Yi,remux:os}];class vs{constructor(e,t,r,i,s){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=e,this.typeSupported=t,this.config=r,this.vendor=i,this.id=s}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,r,i){const s=r.transmuxing;s.executeStart=ss();let n=new Uint8Array(e);const{currentTransmuxState:a,transmuxConfig:o}=this;i&&(this.currentTransmuxState=i);const{contiguous:l,discontinuity:d,trackSwitch:h,accurateTimeOffset:c,timeOffset:u,initSegmentChange:g}=i||a,{audioCodec:y,videoCodec:v,defaultInitPts:_,duration:E,initSegmentData:b}=o,S=_s(n,t);if(S&&"AES-128"===S.method){const e=this.getDecrypter();if(!e.isSync())return this.decryptionPromise=e.webCryptoDecrypt(n,S.key.buffer,S.iv.buffer).then(e=>{const t=this.push(e,null,r);return this.decryptionPromise=null,t}),this.decryptionPromise;{let t=e.softwareDecrypt(n,S.key.buffer,S.iv.buffer);const i=r.part>-1;if(i&&(t=e.flush()),!t)return s.executeEnd=ss(),Es(r);n=new Uint8Array(t)}}const L=this.needsProbing(d,h);if(L){const e=this.configureTransmuxer(n);if(e)return T.warn("[transmuxer] "+e.message),this.observer.emit(f.ERROR,f.ERROR,{type:p.MEDIA_ERROR,details:m.FRAG_PARSING_ERROR,fatal:!1,error:e,reason:e.message}),s.executeEnd=ss(),Es(r)}(d||h||g||L)&&this.resetInitSegment(b,y,v,E,t),(d||g||L)&&this.resetInitialTimestamp(_),l||this.resetContiguity();const A=this.transmux(n,S,u,c,r),w=this.currentTransmuxState;return w.contiguous=!0,w.discontinuity=!1,w.trackSwitch=!1,s.executeEnd=ss(),A}flush(e){const t=e.transmuxing;t.executeStart=ss();const{decrypter:r,currentTransmuxState:i,decryptionPromise:s}=this;if(s)return s.then(()=>this.flush(e));const n=[],{timeOffset:a}=i;if(r){const t=r.flush();t&&n.push(this.push(t,null,e))}const{demuxer:o,remuxer:l}=this;if(!o||!l)return t.executeEnd=ss(),[Es(e)];const d=o.flush(a);return bs(d)?d.then(t=>(this.flushRemux(n,t,e),n)):(this.flushRemux(n,d,e),n)}flushRemux(e,t,r){const{audioTrack:i,videoTrack:s,id3Track:n,textTrack:a}=t,{accurateTimeOffset:o,timeOffset:l}=this.currentTransmuxState;T.log(`[transmuxer.ts]: Flushed fragment ${r.sn}${r.part>-1?" p: "+r.part:""} of level ${r.level}`);const d=this.remuxer.remux(i,s,n,a,l,o,!0,this.id);e.push({remuxResult:d,chunkMeta:r}),r.transmuxing.executeEnd=ss()}resetInitialTimestamp(e){const{demuxer:t,remuxer:r}=this;t&&r&&(t.resetTimeStamp(e),r.resetTimeStamp(e))}resetContiguity(){const{demuxer:e,remuxer:t}=this;e&&t&&(e.resetContiguity(),t.resetNextTimestamp())}resetInitSegment(e,t,r,i,s){const{demuxer:n,remuxer:a}=this;n&&a&&(n.resetInitSegment(e,t,r,i),a.resetInitSegment(e,t,r,s))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,r,i,s){let n;return n=t&&"SAMPLE-AES"===t.method?this.transmuxSampleAes(e,t,r,i,s):this.transmuxUnencrypted(e,r,i,s),n}transmuxUnencrypted(e,t,r,i){const{audioTrack:s,videoTrack:n,id3Track:a,textTrack:o}=this.demuxer.demux(e,t,!1,!this.config.progressive),l=this.remuxer.remux(s,n,a,o,t,r,!1,this.id);return{remuxResult:l,chunkMeta:i}}transmuxSampleAes(e,t,r,i,s){return this.demuxer.demuxSampleAes(e,t,r).then(e=>{const t=this.remuxer.remux(e.audioTrack,e.videoTrack,e.id3Track,e.textTrack,r,i,!1,this.id);return{remuxResult:t,chunkMeta:s}})}configureTransmuxer(e){const{config:t,observer:r,typeSupported:i,vendor:s}=this;let n;for(let h=0,c=ys.length;h<c;h++)if(ys[h].demux.probe(e)){n=ys[h];break}if(!n)return new Error("Failed to find demuxer by probing fragment data");const a=this.demuxer,o=this.remuxer,l=n.remux,d=n.demux;o&&o instanceof l||(this.remuxer=new l(r,t,i,s)),a&&a instanceof d||(this.demuxer=new d(r,t,i),this.probe=d.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new Qr(this.config)),e}}function _s(e,t){let r=null;return e.byteLength>0&&null!=t&&null!=t.key&&null!==t.iv&&null!=t.method&&(r=t),r}const Es=e=>({remuxResult:{},chunkMeta:e});function bs(e){return"then"in e&&e.then instanceof Function}class Ts{constructor(e,t,r,i,s){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=r,this.duration=i,this.defaultInitPts=s||null}}class Ss{constructor(e,t,r,i,s,n){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=e,this.contiguous=t,this.accurateTimeOffset=r,this.trackSwitch=i,this.timeOffset=s,this.initSegmentChange=n}}var Ls={exports:{}};(function(e){var t=Object.prototype.hasOwnProperty,r="~";function i(){}function s(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function n(e,t,i,n,a){if("function"!==typeof i)throw new TypeError("The listener must be a function");var o=new s(i,n||e,a),l=r?r+t:t;return e._events[l]?e._events[l].fn?e._events[l]=[e._events[l],o]:e._events[l].push(o):(e._events[l]=o,e._eventsCount++),e}function a(e,t){0===--e._eventsCount?e._events=new i:delete e._events[t]}function o(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(r=!1)),o.prototype.eventNames=function(){var e,i,s=[];if(0===this._eventsCount)return s;for(i in e=this._events)t.call(e,i)&&s.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?s.concat(Object.getOwnPropertySymbols(e)):s},o.prototype.listeners=function(e){var t=r?r+e:e,i=this._events[t];if(!i)return[];if(i.fn)return[i.fn];for(var s=0,n=i.length,a=new Array(n);s<n;s++)a[s]=i[s].fn;return a},o.prototype.listenerCount=function(e){var t=r?r+e:e,i=this._events[t];return i?i.fn?1:i.length:0},o.prototype.emit=function(e,t,i,s,n,a){var o=r?r+e:e;if(!this._events[o])return!1;var l,d,h=this._events[o],c=arguments.length;if(h.fn){switch(h.once&&this.removeListener(e,h.fn,void 0,!0),c){case 1:return h.fn.call(h.context),!0;case 2:return h.fn.call(h.context,t),!0;case 3:return h.fn.call(h.context,t,i),!0;case 4:return h.fn.call(h.context,t,i,s),!0;case 5:return h.fn.call(h.context,t,i,s,n),!0;case 6:return h.fn.call(h.context,t,i,s,n,a),!0}for(d=1,l=new Array(c-1);d<c;d++)l[d-1]=arguments[d];h.fn.apply(h.context,l)}else{var u,f=h.length;for(d=0;d<f;d++)switch(h[d].once&&this.removeListener(e,h[d].fn,void 0,!0),c){case 1:h[d].fn.call(h[d].context);break;case 2:h[d].fn.call(h[d].context,t);break;case 3:h[d].fn.call(h[d].context,t,i);break;case 4:h[d].fn.call(h[d].context,t,i,s);break;default:if(!l)for(u=1,l=new Array(c-1);u<c;u++)l[u-1]=arguments[u];h[d].fn.apply(h[d].context,l)}}return!0},o.prototype.on=function(e,t,r){return n(this,e,t,r,!1)},o.prototype.once=function(e,t,r){return n(this,e,t,r,!0)},o.prototype.removeListener=function(e,t,i,s){var n=r?r+e:e;if(!this._events[n])return this;if(!t)return a(this,n),this;var o=this._events[n];if(o.fn)o.fn!==t||s&&!o.once||i&&o.context!==i||a(this,n);else{for(var l=0,d=[],h=o.length;l<h;l++)(o[l].fn!==t||s&&!o[l].once||i&&o[l].context!==i)&&d.push(o[l]);d.length?this._events[n]=1===d.length?d[0]:d:a(this,n)}return this},o.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&a(this,t)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=r,o.EventEmitter=o,e.exports=o})(Ls);var As=Ls.exports,ws=i(As);const Rs=Je()||{isTypeSupported:()=>!1};class ks{constructor(e,t,r,i){this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;const s=e.config;this.hls=e,this.id=t,this.useWorker=!!s.enableWorker,this.onTransmuxComplete=r,this.onFlush=i;const n=(e,t)=>{t=t||{},t.frag=this.frag,t.id=this.id,e===f.ERROR&&(this.error=t.error),this.hls.trigger(e,t)};this.observer=new ws,this.observer.on(f.FRAG_DECRYPTED,n),this.observer.on(f.ERROR,n);const a={mp4:Rs.isTypeSupported("video/mp4"),mpeg:Rs.isTypeSupported("audio/mpeg"),mp3:Rs.isTypeSupported('audio/mp4; codecs="mp3"')},o=navigator.vendor;if(this.useWorker&&"undefined"!==typeof Worker){const e=s.workerPath||si();if(e){try{s.workerPath?(T.log(`loading Web Worker ${s.workerPath} for "${t}"`),this.workerContext=ai(s.workerPath)):(T.log(`injecting Web Worker for "${t}"`),this.workerContext=ni()),this.onwmsg=e=>this.onWorkerMessage(e);const{worker:e}=this.workerContext;e.addEventListener("message",this.onwmsg),e.onerror=e=>{const r=new Error(`${e.message} (${e.filename}:${e.lineno})`);s.enableWorker=!1,T.warn(`Error in "${t}" Web Worker, fallback to inline`),this.hls.trigger(f.ERROR,{type:p.OTHER_ERROR,details:m.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:r})},e.postMessage({cmd:"init",typeSupported:a,vendor:o,id:t,config:JSON.stringify(s)})}catch(Na){T.warn(`Error setting up "${t}" Web Worker, fallback to inline`,Na),this.resetWorker(),this.error=null,this.transmuxer=new vs(this.observer,a,s,o,t)}return}}this.transmuxer=new vs(this.observer,a,s,o,t)}resetWorker(){if(this.workerContext){const{worker:e,objectURL:t}=this.workerContext;t&&self.URL.revokeObjectURL(t),e.removeEventListener("message",this.onwmsg),e.onerror=null,e.terminate(),this.workerContext=null}}destroy(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{const e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}const e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null}push(e,t,r,i,s,n,a,o,l,d){var h,c;l.transmuxing.start=self.performance.now();const{transmuxer:u}=this,f=n?n.start:s.start,p=s.decryptdata,m=this.frag,g=!(m&&s.cc===m.cc),y=!(m&&l.level===m.level),v=m?l.sn-m.sn:-1,_=this.part?l.part-this.part.index:-1,E=0===v&&l.id>1&&l.id===(null==m?void 0:m.stats.chunkCount),b=!y&&(1===v||0===v&&(1===_||E&&_<=0)),S=self.performance.now();(y||v||0===s.stats.parsing.start)&&(s.stats.parsing.start=S),!n||!_&&b||(n.stats.parsing.start=S);const L=!(m&&(null==(h=s.initSegment)?void 0:h.url)===(null==(c=m.initSegment)?void 0:c.url)),A=new Ss(g,b,o,y,f,L);if(!b||g||L){T.log(`[transmuxer-interface, ${s.type}]: Starting new transmux session for sn: ${l.sn} p: ${l.part} level: ${l.level} id: ${l.id}\n discontinuity: ${g}\n trackSwitch: ${y}\n contiguous: ${b}\n accurateTimeOffset: ${o}\n timeOffset: ${f}\n initSegmentChange: ${L}`);const e=new Ts(r,i,t,a,d);this.configureTransmuxer(e)}if(this.frag=s,this.part=n,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:p,chunkMeta:l,state:A},e instanceof ArrayBuffer?[e]:[]);else if(u){const t=u.push(e,p,l,A);bs(t)?(u.async=!0,t.then(e=>{this.handleTransmuxComplete(e)}).catch(e=>{this.transmuxerError(e,l,"transmuxer-interface push error")})):(u.async=!1,this.handleTransmuxComplete(t))}}flush(e){e.transmuxing.start=self.performance.now();const{transmuxer:t}=this;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:e});else if(t){let r=t.flush(e);const i=bs(r);i||t.async?(bs(r)||(r=Promise.resolve(r)),r.then(t=>{this.handleFlushResult(t,e)}).catch(t=>{this.transmuxerError(t,e,"transmuxer-interface flush error")})):this.handleFlushResult(r,e)}}transmuxerError(e,t,r){this.hls&&(this.error=e,this.hls.trigger(f.ERROR,{type:p.MEDIA_ERROR,details:m.FRAG_PARSING_ERROR,chunkMeta:t,fatal:!1,error:e,err:e,reason:r}))}handleFlushResult(e,t){e.forEach(e=>{this.handleTransmuxComplete(e)}),this.onFlush(t)}onWorkerMessage(e){const t=e.data,r=this.hls;switch(t.event){case"init":{var i;const e=null==(i=this.workerContext)?void 0:i.objectURL;e&&self.URL.revokeObjectURL(e);break}case"transmuxComplete":this.handleTransmuxComplete(t.data);break;case"flush":this.onFlush(t.data);break;case"workerLog":T[t.data.logType]&&T[t.data.logType](t.data.message);break;default:t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,r.trigger(t.event,t.data);break}}configureTransmuxer(e){const{transmuxer:t}=this;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:e}):t&&t.configure(e)}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}}const Is=250,Ds=2,xs=.1,Cs=.05;class Ps{constructor(e,t,r,i){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=e,this.media=t,this.fragmentTracker=r,this.hls=i}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(e,t){const{config:r,media:i,stalled:s}=this;if(null===i)return;const{currentTime:n,seeking:a}=i,o=this.seeking&&!a,l=!this.seeking&&a;if(this.seeking=a,n!==e){if(this.moved=!0,null!==s){if(this.stallReported){const e=self.performance.now()-s;T.warn(`playback not stuck anymore @${n}, after ${Math.round(e)}ms`),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if(l||o)return void(this.stalled=null);if(i.paused&&!a||i.ended||0===i.playbackRate||!Or.getBuffered(i).length)return;const d=Or.bufferInfo(i,n,0),h=d.len>0,c=d.nextStart||0;if(!h&&!c)return;if(a){const e=d.len>Ds,r=!c||t&&t.start<=n||c-n>Ds&&!this.fragmentTracker.getPartialFragment(n);if(e||r)return;this.moved=!1}if(!this.moved&&null!==this.stalled){var u;const e=Math.max(c,d.start||0)-n,t=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,r=null==t||null==(u=t.details)?void 0:u.live,i=r?2*t.details.targetduration:Ds,s=this.fragmentTracker.getPartialFragment(n);if(e>0&&(e<=i||s))return void this._trySkipBufferHole(s)}const f=self.performance.now();if(null===s)return void(this.stalled=f);const p=f-s;if(!a&&p>=Is&&(this._reportStall(d),!this.media))return;const m=Or.bufferInfo(i,n,r.maxBufferHole);this._tryFixBufferStall(m,p)}_tryFixBufferStall(e,t){const{config:r,fragmentTracker:i,media:s}=this;if(null===s)return;const n=s.currentTime,a=i.getPartialFragment(n);if(a){const e=this._trySkipBufferHole(a);if(e||!this.media)return}(e.len>r.maxBufferHole||e.nextStart&&e.nextStart-n<r.maxBufferHole)&&t>1e3*r.highBufferWatchdogPeriod&&(T.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(e){const{hls:t,media:r,stallReported:i}=this;if(!i&&r){this.stallReported=!0;const i=new Error(`Playback stalling at @${r.currentTime} due to low buffer (${JSON.stringify(e)})`);T.warn(i.message),t.trigger(f.ERROR,{type:p.MEDIA_ERROR,details:m.BUFFER_STALLED_ERROR,fatal:!1,error:i,buffer:e.len})}}_trySkipBufferHole(e){const{config:t,hls:r,media:i}=this;if(null===i)return 0;const s=i.currentTime,n=Or.bufferInfo(i,s,0),a=s<n.start?n.start:n.nextStart;if(a){const o=n.len<=t.maxBufferHole,l=n.len>0&&n.len<1&&i.readyState<3,d=a-s;if(d>0&&(o||l)){if(d>t.maxBufferHole){const{fragmentTracker:t}=this;let r=!1;if(0===s){const e=t.getAppendedFrag(0,_t.MAIN);e&&a<e.end&&(r=!0)}if(!r){const r=e||t.getAppendedFrag(s,_t.MAIN);if(r){let e=!1,i=r.end;while(i<a){const r=t.getPartialFragment(i);if(!r){e=!0;break}i+=r.duration}if(e)return 0}}}const n=Math.max(a+Cs,s+xs);if(T.warn(`skipping hole, adjusting currentTime from ${s} to ${n}`),this.moved=!0,this.stalled=null,i.currentTime=n,e&&!e.gap){const t=new Error(`fragment loaded with buffer holes, seeking from ${s} to ${n}`);r.trigger(f.ERROR,{type:p.MEDIA_ERROR,details:m.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:t,reason:t.message,frag:e})}return n}}return 0}_tryNudgeBuffer(){const{config:e,hls:t,media:r,nudgeRetry:i}=this;if(null===r)return;const s=r.currentTime;if(this.nudgeRetry++,i<e.nudgeMaxRetry){const n=s+(i+1)*e.nudgeOffset,a=new Error(`Nudging 'currentTime' from ${s} to ${n}`);T.warn(a.message),r.currentTime=n,t.trigger(f.ERROR,{type:p.MEDIA_ERROR,details:m.BUFFER_NUDGE_ON_STALL,error:a,fatal:!1})}else{const r=new Error(`Playhead still not moving while enough data buffered @${s} after ${e.nudgeMaxRetry} nudges`);T.error(r.message),t.trigger(f.ERROR,{type:p.MEDIA_ERROR,details:m.BUFFER_STALLED_ERROR,error:r,fatal:!0})}}}const Os=100;class Ms extends ei{constructor(e,t,r){super(e,t,r,"[stream-controller]",_t.MAIN),this.audioCodecSwap=!1,this.gapController=null,this.level=-1,this._forceStartLoad=!1,this.altAudio=!1,this.audioOnly=!1,this.fragPlaying=null,this.onvplaying=null,this.onvseeked=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this._registerListeners()}_registerListeners(){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.MANIFEST_PARSED,this.onManifestParsed,this),e.on(f.LEVEL_LOADING,this.onLevelLoading,this),e.on(f.LEVEL_LOADED,this.onLevelLoaded,this),e.on(f.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(f.ERROR,this.onError,this),e.on(f.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(f.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(f.BUFFER_CREATED,this.onBufferCreated,this),e.on(f.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(f.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(f.FRAG_BUFFERED,this.onFragBuffered,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.MANIFEST_PARSED,this.onManifestParsed,this),e.off(f.LEVEL_LOADED,this.onLevelLoaded,this),e.off(f.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(f.ERROR,this.onError,this),e.off(f.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(f.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(f.BUFFER_CREATED,this.onBufferCreated,this),e.off(f.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(f.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(f.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this._unregisterListeners(),this.onMediaDetaching()}startLoad(e){if(this.levels){const{lastCurrentTime:t,hls:r}=this;if(this.stopLoad(),this.setInterval(Os),this.level=-1,!this.startFragRequested){let e=r.startLevel;-1===e&&(r.config.testBandwidth&&this.levels.length>1?(e=0,this.bitrateTest=!0):e=r.nextAutoLevel),this.level=r.nextLoadLevel=e,this.loadedmetadata=!1}t>0&&-1===e&&(this.log("Override startPosition with lastCurrentTime @"+t.toFixed(3)),e=t),this.state=Jr.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=Jr.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case Jr.WAITING_LEVEL:{var e;const{levels:t,level:r}=this,i=null==t||null==(e=t[r])?void 0:e.details;if(i&&(!i.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(i))break;this.state=Jr.IDLE;break}if(this.hls.nextLoadLevel!==this.level){this.state=Jr.IDLE;break}break}case Jr.FRAG_LOADING_WAITING_RETRY:{var t;const e=self.performance.now(),r=this.retryDate;(!r||e>=r||null!=(t=this.media)&&t.seeking)&&(this.resetStartWhenNotLoaded(this.level),this.state=Jr.IDLE)}break}this.state===Jr.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){const{hls:e,levelLastLoaded:t,levels:r,media:i}=this,{config:s,nextLoadLevel:n}=e;if(null===t||!i&&(this.startFragRequested||!s.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;if(null==r||!r[n])return;const a=r[n],o=this.getMainFwdBufferInfo();if(null===o)return;const l=this.getLevelDetails();if(l&&this._streamEnded(o,l)){const e={};return this.altAudio&&(e.type="video"),this.hls.trigger(f.BUFFER_EOS,e),void(this.state=Jr.ENDED)}e.loadLevel!==n&&-1===e.manualLevel&&this.log(`Adapting to level ${n} from level ${this.level}`),this.level=e.nextLoadLevel=n;const d=a.details;if(!d||this.state===Jr.WAITING_LEVEL||d.live&&this.levelLastLoaded!==n)return this.level=n,void(this.state=Jr.WAITING_LEVEL);const h=o.len,c=this.getMaxBufferLength(a.maxBitrate);if(h>=c)return;this.backtrackFragment&&this.backtrackFragment.start>o.end&&(this.backtrackFragment=null);const u=this.backtrackFragment?this.backtrackFragment.start:o.end;let p=this.getNextFragment(u,d);if(this.couldBacktrack&&!this.fragPrevious&&p&&"initSegment"!==p.sn&&this.fragmentTracker.getState(p)!==Tr.OK){var m;const e=(null!=(m=this.backtrackFragment)?m:p).sn,t=e-d.startSN,r=d.fragments[t-1];r&&p.cc===r.cc&&(p=r,this.fragmentTracker.removeFragment(r))}else this.backtrackFragment&&o.len&&(this.backtrackFragment=null);if(p&&this.isLoopLoading(p,u)){const e=p.gap;if(!e){const e=this.audioOnly&&!this.altAudio?D.AUDIO:D.VIDEO,t=(e===D.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;t&&this.afterBufferFlushed(t,e,_t.MAIN)}p=this.getNextFragmentLoopLoading(p,d,o,_t.MAIN,c)}p&&(!p.initSegment||p.initSegment.data||this.bitrateTest||(p=p.initSegment),this.loadFragment(p,a,u))}loadFragment(e,t,r){const i=this.fragmentTracker.getState(e);this.fragCurrent=e,i===Tr.NOT_LOADED||i===Tr.PARTIAL?"initSegment"===e.sn?this._loadInitSegment(e,t):this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,t)):(this.startFragRequested=!0,super.loadFragment(e,t,r)):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,_t.MAIN)}followingBufferedFrag(e){return e?this.getBufferedFrag(e.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){const{levels:e,media:t}=this;if(null!=t&&t.readyState){let r;const i=this.getAppendedFrag(t.currentTime);i&&i.start>1&&this.flushMainBuffer(0,i.start-1);const s=this.getLevelDetails();if(null!=s&&s.live){const e=this.getMainFwdBufferInfo();if(!e||e.len<2*s.targetduration)return}if(!t.paused&&e){const t=this.hls.nextLoadLevel,i=e[t],s=this.fragLastKbps;r=s&&this.fragCurrent?this.fragCurrent.duration*i.maxBitrate/(1e3*s)+1:0}else r=0;const n=this.getBufferedFrag(t.currentTime+r);if(n){const e=this.followingBufferedFrag(n);if(e){this.abortCurrentFrag();const t=e.maxStartPTS?e.maxStartPTS:e.start,r=e.duration,i=Math.max(n.end,t+Math.min(Math.max(r-this.config.maxFragLookUpTolerance,.5*r),.75*r));this.flushMainBuffer(i,Number.POSITIVE_INFINITY)}}}}abortCurrentFrag(){const e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case Jr.KEY_LOADING:case Jr.FRAG_LOADING:case Jr.FRAG_LOADING_WAITING_RETRY:case Jr.PARSING:case Jr.PARSED:this.state=Jr.IDLE;break}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,this.altAudio?"video":null)}onMediaAttached(e,t){super.onMediaAttached(e,t);const r=t.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),r.addEventListener("playing",this.onvplaying),r.addEventListener("seeked",this.onvseeked),this.gapController=new Ps(this.config,r,this.fragmentTracker,this.hls)}onMediaDetaching(){const{media:e}=this;e&&this.onvplaying&&this.onvseeked&&(e.removeEventListener("playing",this.onvplaying),e.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),super.onMediaDetaching()}onMediaPlaying(){this.tick()}onMediaSeeked(){const e=this.media,t=e?e.currentTime:null;u(t)&&this.log("Media seeked to "+t.toFixed(3));const r=this.getMainFwdBufferInfo();null!==r&&0!==r.len?this.tick():this.warn(`Main forward buffer length on "seeked" event ${r?r.len:"empty"})`)}onManifestLoading(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(f.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.levels=this.fragPlaying=this.backtrackFragment=null,this.altAudio=this.audioOnly=!1}onManifestParsed(e,t){let r,i=!1,s=!1;t.levels.forEach(e=>{r=e.audioCodec,r&&(-1!==r.indexOf("mp4a.40.2")&&(i=!0),-1!==r.indexOf("mp4a.40.5")&&(s=!0))}),this.audioCodecSwitch=i&&s&&!ii(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1}onLevelLoading(e,t){const{levels:r}=this;if(!r||this.state!==Jr.IDLE)return;const i=r[t.level];(!i.details||i.details.live&&this.levelLastLoaded!==t.level||this.waitForCdnTuneIn(i.details))&&(this.state=Jr.WAITING_LEVEL)}onLevelLoaded(e,t){var r;const{levels:i}=this,s=t.level,n=t.details,a=n.totalduration;if(!i)return void this.warn("Levels were reset while loading level "+s);this.log(`Level ${s} loaded [${n.startSN},${n.endSN}]${n.lastPartSn?`[part-${n.lastPartSn}-${n.lastPartIndex}]`:""}, cc [${n.startCC}, ${n.endCC}] duration:${a}`);const o=i[s],l=this.fragCurrent;!l||this.state!==Jr.FRAG_LOADING&&this.state!==Jr.FRAG_LOADING_WAITING_RETRY||l.level===t.level&&l.urlId===o.urlId||!l.loader||this.abortCurrentFrag();let d=0;if(n.live||null!=(r=o.details)&&r.live){if(this.checkLiveUpdate(n),n.deltaUpdateFailed)return;d=this.alignPlaylists(n,o.details)}if(o.details=n,this.levelLastLoaded=s,this.hls.trigger(f.LEVEL_UPDATED,{details:n,level:s}),this.state===Jr.WAITING_LEVEL){if(this.waitForCdnTuneIn(n))return;this.state=Jr.IDLE}this.startFragRequested?n.live&&this.synchronizeToLiveEdge(n):this.setStartPosition(n,d),this.tick()}_handleFragmentLoadProgress(e){var t;const{frag:r,part:i,payload:s}=e,{levels:n}=this;if(!n)return void this.warn(`Levels were reset while fragment load was in progress. Fragment ${r.sn} of level ${r.level} will not be buffered`);const a=n[r.level],o=a.details;if(!o)return this.warn(`Dropping fragment ${r.sn} of level ${r.level} after level details were reset`),void this.fragmentTracker.removeFragment(r);const l=a.videoCodec,d=o.PTSKnown||!o.live,h=null==(t=r.initSegment)?void 0:t.data,c=this._getAudioCodec(a),u=this.transmuxer=this.transmuxer||new ks(this.hls,_t.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),f=i?i.index:-1,p=-1!==f,m=new Mr(r.level,r.sn,r.stats.chunkCount,s.byteLength,f,p),g=this.initPTS[r.cc];u.push(s,h,c,l,r,i,o.totalduration,d,m,g)}onAudioTrackSwitching(e,t){const r=this.altAudio,i=!!t.url;if(!i){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;const e=this.fragCurrent;e&&(this.log("Switching to main audio track, cancel main fragment load"),e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();const e=this.hls;r&&(e.trigger(f.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),e.trigger(f.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){const r=t.id,i=!!this.hls.audioTracks[r].url;if(i){const e=this.videoBuffer;e&&this.mediaBuffer!==e&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=e)}this.altAudio=i,this.tick()}onBufferCreated(e,t){const r=t.tracks;let i,s,n=!1;for(const a in r){const e=r[a];if("main"===e.id){if(s=a,i=e,"video"===a){const e=r[a];e&&(this.videoBuffer=e.buffer)}}else n=!0}n&&i?(this.log(`Alternate track found, use ${s}.buffered to schedule main fragment loading`),this.mediaBuffer=i.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){const{frag:r,part:i}=t;if(r&&r.type!==_t.MAIN)return;if(this.fragContextChanged(r))return this.warn(`Fragment ${r.sn}${i?" p: "+i.index:""} of level ${r.level} finished buffering, but was aborted. state: ${this.state}`),void(this.state===Jr.PARSED&&(this.state=Jr.IDLE));const s=i?i.stats:r.stats;this.fragLastKbps=Math.round(8*s.total/(s.buffering.end-s.loading.first)),"initSegment"!==r.sn&&(this.fragPrevious=r),this.fragBufferedComplete(r,i)}onError(e,t){var r;if(t.fatal)this.state=Jr.ERROR;else switch(t.details){case m.FRAG_GAP:case m.FRAG_PARSING_ERROR:case m.FRAG_DECRYPT_ERROR:case m.FRAG_LOAD_ERROR:case m.FRAG_LOAD_TIMEOUT:case m.KEY_LOAD_ERROR:case m.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(_t.MAIN,t);break;case m.LEVEL_LOAD_ERROR:case m.LEVEL_LOAD_TIMEOUT:case m.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==Jr.WAITING_LEVEL||(null==(r=t.context)?void 0:r.type)!==vt.LEVEL||(this.state=Jr.IDLE);break;case m.BUFFER_FULL_ERROR:if(!t.parent||"main"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case m.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}checkBuffer(){const{media:e,gapController:t}=this;if(e&&t&&e.readyState){if(this.loadedmetadata||!Or.getBuffered(e).length){const e=this.state!==Jr.IDLE?this.fragCurrent:null;t.poll(this.lastCurrentTime,e)}this.lastCurrentTime=e.currentTime}}onFragLoadEmergencyAborted(){this.state=Jr.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==D.AUDIO||this.audioOnly&&!this.altAudio){const e=(t===D.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(e,t,_t.MAIN)}}onLevelsUpdated(e,t){this.levels=t.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){const{media:e}=this;if(!e)return;const t=e.currentTime;let r=this.startPosition;if(r>=0&&t<r){if(e.seeking)return void this.log(`could not seek to ${r}, already seeking at ${t}`);const i=Or.getBuffered(e),s=i.length?i.start(0):0,n=s-r;n>0&&(n<this.config.maxBufferHole||n<this.config.maxFragLookUpTolerance)&&(this.log(`adjusting start position by ${n} to match buffer start`),r+=n,this.startPosition=r),this.log(`seek to target start position ${r} from current time ${t}`),e.currentTime=r}}_getAudioCodec(e){let t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t=-1!==t.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),t}_loadBitrateTestFrag(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then(r=>{const{hls:i}=this;if(!r||this.fragContextChanged(e))return;t.fragmentError=0,this.state=Jr.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;const s=e.stats;s.parsing.start=s.parsing.end=s.buffering.start=s.buffering.end=self.performance.now(),i.trigger(f.FRAG_LOADED,r),e.bitrateTest=!1})}_handleTransmuxComplete(e){var t;const r="main",{hls:i}=this,{remuxResult:s,chunkMeta:n}=e,a=this.getCurrentContext(n);if(!a)return void this.resetWhenMissingContext(n);const{frag:o,part:l,level:d}=a,{video:h,text:c,id3:p,initSegment:m}=s,{details:g}=d,y=this.altAudio?void 0:s.audio;if(this.fragContextChanged(o))this.fragmentTracker.removeFragment(o);else{if(this.state=Jr.PARSING,m){if(null!=m&&m.tracks){const e=o.initSegment||o;this._bufferInitSegment(d,m.tracks,e,n),i.trigger(f.FRAG_PARSING_INIT_SEGMENT,{frag:e,id:r,tracks:m.tracks})}const e=m.initPTS,t=m.timescale;u(e)&&(this.initPTS[o.cc]={baseTime:e,timescale:t},i.trigger(f.INIT_PTS_FOUND,{frag:o,id:r,initPTS:e,timescale:t}))}if(h&&g&&"initSegment"!==o.sn){const e=g.fragments[o.sn-1-g.startSN],t=o.sn===g.startSN,r=!e||o.cc>e.cc;if(!1!==s.independent){const{startPTS:e,endPTS:i,startDTS:s,endDTS:a}=h;if(l)l.elementaryStreams[h.type]={startPTS:e,endPTS:i,startDTS:s,endDTS:a};else if(h.firstKeyFrame&&h.independent&&1===n.id&&!r&&(this.couldBacktrack=!0),h.dropped&&h.independent){const s=this.getMainFwdBufferInfo(),n=(s?s.end:this.getLoadPosition())+this.config.maxBufferHole,l=h.firstKeyFramePTS?h.firstKeyFramePTS:e;if(!t&&n<l-this.config.maxBufferHole&&!r)return void this.backtrack(o);r&&(o.gap=!0),o.setElementaryStreamInfo(h.type,o.start,i,o.start,a,!0)}o.setElementaryStreamInfo(h.type,e,i,s,a),this.backtrackFragment&&(this.backtrackFragment=o),this.bufferFragmentData(h,o,l,n,t||r)}else{if(!t&&!r)return void this.backtrack(o);o.gap=!0}}if(y){const{startPTS:e,endPTS:t,startDTS:r,endDTS:i}=y;l&&(l.elementaryStreams[D.AUDIO]={startPTS:e,endPTS:t,startDTS:r,endDTS:i}),o.setElementaryStreamInfo(D.AUDIO,e,t,r,i),this.bufferFragmentData(y,o,l,n)}if(g&&null!=p&&null!=(t=p.samples)&&t.length){const e={id:r,frag:o,details:g,samples:p.samples};i.trigger(f.FRAG_PARSING_METADATA,e)}if(g&&c){const e={id:r,frag:o,details:g,samples:c.samples};i.trigger(f.FRAG_PARSING_USERDATA,e)}}}_bufferInitSegment(e,t,r,i){if(this.state!==Jr.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;const{audio:s,video:n,audiovideo:a}=t;if(s){let t=e.audioCodec;const r=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(t&&(t=-1!==t.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),1!==s.metadata.channelCount&&-1===r.indexOf("firefox")&&(t="mp4a.40.5")),-1!==r.indexOf("android")&&"audio/mpeg"!==s.container&&(t="mp4a.40.2",this.log("Android: force audio codec to "+t)),e.audioCodec&&e.audioCodec!==t&&this.log(`Swapping manifest audio codec "${e.audioCodec}" for "${t}"`),s.levelCodec=t,s.id="main",this.log(`Init audio buffer, container:${s.container}, codecs[selected/level/parsed]=[${t||""}/${e.audioCodec||""}/${s.codec}]`)}n&&(n.levelCodec=e.videoCodec,n.id="main",this.log(`Init video buffer, container:${n.container}, codecs[level/parsed]=[${e.videoCodec||""}/${n.codec}]`)),a&&this.log(`Init audiovideo buffer, container:${a.container}, codecs[level/parsed]=[${e.attrs.CODECS||""}/${a.codec}]`),this.hls.trigger(f.BUFFER_CODECS,t),Object.keys(t).forEach(e=>{const s=t[e],n=s.initSegment;null!=n&&n.byteLength&&this.hls.trigger(f.BUFFER_APPENDING,{type:e,data:n,frag:r,part:null,chunkMeta:i,parent:r.type})}),this.tick()}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,_t.MAIN)}backtrack(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=Jr.IDLE}checkFragmentChanged(){const e=this.media;let t=null;if(e&&e.readyState>1&&!1===e.seeking){const r=e.currentTime;if(Or.isBuffered(e,r)?t=this.getAppendedFrag(r):Or.isBuffered(e,r+.1)&&(t=this.getAppendedFrag(r+.1)),t){this.backtrackFragment=null;const e=this.fragPlaying,r=t.level;e&&t.sn===e.sn&&e.level===r&&t.urlId===e.urlId||(this.fragPlaying=t,this.hls.trigger(f.FRAG_CHANGED,{frag:t}),e&&e.level===r||this.hls.trigger(f.LEVEL_SWITCHED,{level:r}))}}}get nextLevel(){const e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){const e=this.media;return e?this.fragPlaying||this.getAppendedFrag(e.currentTime):null}get currentProgramDateTime(){const e=this.media;if(e){const t=e.currentTime,r=this.currentFrag;if(r&&u(t)&&u(r.programDateTime)){const e=r.programDateTime+1e3*(t-r.start);return new Date(e)}}return null}get currentLevel(){const e=this.currentFrag;return e?e.level:-1}get nextBufferedFrag(){const e=this.currentFrag;return e?this.followingBufferedFrag(e):null}get forceStartLoad(){return this._forceStartLoad}}class Fs{constructor(e,t=0,r=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=r}sample(e,t){const r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){const e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}}class Ns{constructor(e,t,r,i=100){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=r,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new Fs(e),this.fast_=new Fs(t),this.defaultTTFB_=i,this.ttfb_=new Fs(e)}update(e,t){const{slow_:r,fast_:i,ttfb_:s}=this;r.halfLife!==e&&(this.slow_=new Fs(e,r.getEstimate(),r.getTotalWeight())),i.halfLife!==t&&(this.fast_=new Fs(t,i.getEstimate(),i.getTotalWeight())),s.halfLife!==e&&(this.ttfb_=new Fs(e,s.getEstimate(),s.getTotalWeight()))}sample(e,t){e=Math.max(e,this.minDelayMs_);const r=8*t,i=e/1e3,s=r/i;this.fast_.sample(i,s),this.slow_.sample(i,s)}sampleTTFB(e){const t=e/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(r,Math.max(e,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}destroy(){}}class Us{constructor(e){this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=-1,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=e;const t=e.config;this.bwEstimator=new Ns(t.abrEwmaSlowVoD,t.abrEwmaFastVoD,t.abrEwmaDefaultEstimate),this.registerListeners()}registerListeners(){const{hls:e}=this;e.on(f.FRAG_LOADING,this.onFragLoading,this),e.on(f.FRAG_LOADED,this.onFragLoaded,this),e.on(f.FRAG_BUFFERED,this.onFragBuffered,this),e.on(f.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(f.LEVEL_LOADED,this.onLevelLoaded,this)}unregisterListeners(){const{hls:e}=this;e.off(f.FRAG_LOADING,this.onFragLoading,this),e.off(f.FRAG_LOADED,this.onFragLoaded,this),e.off(f.FRAG_BUFFERED,this.onFragBuffered,this),e.off(f.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(f.LEVEL_LOADED,this.onLevelLoaded,this)}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null}onFragLoading(e,t){var r;const i=t.frag;this.ignoreFragment(i)||(this.fragCurrent=i,this.partCurrent=null!=(r=t.part)?r:null,this.clearTimer(),this.timer=self.setInterval(this.onCheck,100))}onLevelSwitching(e,t){this.clearTimer()}getTimeToLoadFrag(e,t,r,i){const s=e+r/t,n=i?this.lastLevelLoadSec:0;return s+n}onLevelLoaded(e,t){const r=this.hls.config,{total:i,bwEstimate:s}=t.stats;u(i)&&u(s)&&(this.lastLevelLoadSec=8*i/s),t.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)}_abandonRulesCheck(){const{fragCurrent:e,partCurrent:t,hls:r}=this,{autoLevelEnabled:i,media:s}=r;if(!e||!s)return;const n=performance.now(),a=t?t.stats:e.stats,o=t?t.duration:e.duration,l=n-a.loading.start;if(a.aborted||a.loaded&&a.loaded===a.total||0===e.level)return this.clearTimer(),void(this._nextAutoLevel=-1);if(!i||s.paused||!s.playbackRate||!s.readyState)return;const d=r.mainForwardBufferInfo;if(null===d)return;const h=this.bwEstimator.getEstimateTTFB(),c=Math.abs(s.playbackRate);if(l<=Math.max(h,o/(2*c)*1e3))return;const p=d.len/c;if(p>=2*o/c)return;const m=a.loading.first?a.loading.first-a.loading.start:-1,g=a.loaded&&m>-1,y=this.bwEstimator.getEstimate(),{levels:v,minAutoLevel:_}=r,E=v[e.level],b=a.total||Math.max(a.loaded,Math.round(o*E.maxBitrate/8));let S=l-m;S<1&&g&&(S=Math.min(l,8*a.loaded/y));const L=g?1e3*a.loaded/S:0,A=L?(b-a.loaded)/L:8*b/y+h/1e3;if(A<=p)return;const w=L?8*L:y;let R,k=Number.POSITIVE_INFINITY;for(R=e.level-1;R>_;R--){const e=v[R].maxBitrate;if(k=this.getTimeToLoadFrag(h/1e3,w,o*e,!v[R].details),k<p)break}k>=A||k>10*o||(r.nextLoadLevel=R,g?this.bwEstimator.sample(l-Math.min(h,m),a.loaded):this.bwEstimator.sampleTTFB(l),this.clearTimer(),T.warn(`[abr] Fragment ${e.sn}${t?" part "+t.index:""} of level ${e.level} is loading too slowly;\n Time to underbuffer: ${p.toFixed(3)} s\n Estimated load time for current fragment: ${A.toFixed(3)} s\n Estimated load time for down switch fragment: ${k.toFixed(3)} s\n TTFB estimate: ${m}\n Current BW estimate: ${u(y)?(y/1024).toFixed(3):"Unknown"} Kb/s\n New BW estimate: ${(this.bwEstimator.getEstimate()/1024).toFixed(3)} Kb/s\n Aborting and switching to level ${R}`),e.loader&&(this.fragCurrent=this.partCurrent=null,e.abortRequests()),r.trigger(f.FRAG_LOAD_EMERGENCY_ABORTED,{frag:e,part:t,stats:a}))}onFragLoaded(e,{frag:t,part:r}){const i=r?r.stats:t.stats;if(t.type===_t.MAIN&&this.bwEstimator.sampleTTFB(i.loading.first-i.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),this.lastLoadedFragLevel=t.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){const e=r?r.duration:t.duration,s=this.hls.levels[t.level],n=(s.loaded?s.loaded.bytes:0)+i.loaded,a=(s.loaded?s.loaded.duration:0)+e;s.loaded={bytes:n,duration:a},s.realBitrate=Math.round(8*n/a)}if(t.bitrateTest){const e={stats:i,frag:t,part:r,id:t.type};this.onFragBuffered(f.FRAG_BUFFERED,e),t.bitrateTest=!1}}}onFragBuffered(e,t){const{frag:r,part:i}=t,s=null!=i&&i.stats.loaded?i.stats:r.stats;if(s.aborted)return;if(this.ignoreFragment(r))return;const n=s.parsing.end-s.loading.start-Math.min(s.loading.first-s.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(n,s.loaded),s.bwEstimate=this.bwEstimator.getEstimate(),r.bitrateTest?this.bitrateTestDelay=n/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==_t.MAIN||"initSegment"===e.sn}clearTimer(){self.clearInterval(this.timer)}get nextAutoLevel(){const e=this._nextAutoLevel,t=this.bwEstimator;if(-1!==e&&!t.canEstimate())return e;let r=this.getNextABRAutoLevel();if(-1!==e){const t=this.hls.levels;if(t.length>Math.max(e,r)&&t[e].loadError<=t[r].loadError)return e}return-1!==e&&(r=Math.min(e,r)),r}getNextABRAutoLevel(){const{fragCurrent:e,partCurrent:t,hls:r}=this,{maxAutoLevel:i,config:s,minAutoLevel:n,media:a}=r,o=t?t.duration:e?e.duration:0,l=a&&0!==a.playbackRate?Math.abs(a.playbackRate):1,d=this.bwEstimator?this.bwEstimator.getEstimate():s.abrEwmaDefaultEstimate,h=r.mainForwardBufferInfo,c=(h?h.len:0)/l;let u=this.findBestLevel(d,n,i,c,s.abrBandWidthFactor,s.abrBandWidthUpFactor);if(u>=0)return u;T.trace(`[abr] ${c?"rebuffering expected":"buffer is empty"}, finding optimal quality level`);let f=o?Math.min(o,s.maxStarvationDelay):s.maxStarvationDelay,p=s.abrBandWidthFactor,m=s.abrBandWidthUpFactor;if(!c){const e=this.bitrateTestDelay;if(e){const t=o?Math.min(o,s.maxLoadingDelay):s.maxLoadingDelay;f=t-e,T.trace(`[abr] bitrate test took ${Math.round(1e3*e)}ms, set first fragment max fetchDuration to ${Math.round(1e3*f)} ms`),p=m=1}}return u=this.findBestLevel(d,n,i,c+f,p,m),Math.max(u,0)}findBestLevel(e,t,r,i,s,n){var a;const{fragCurrent:o,partCurrent:l,lastLoadedFragLevel:d}=this,{levels:h}=this.hls,c=h[d],f=!(null==c||null==(a=c.details)||!a.live),p=null==c?void 0:c.codecSet,m=l?l.duration:o?o.duration:0,g=this.bwEstimator.getEstimateTTFB()/1e3;let y=t,v=-1;for(let _=r;_>=t;_--){const t=h[_];if(!t||p&&t.codecSet!==p){t&&(y=Math.min(_,y),v=Math.max(_,v));continue}-1!==v&&T.trace(`[abr] Skipped level(s) ${y}-${v} with CODECS:"${h[v].attrs.CODECS}"; not compatible with "${c.attrs.CODECS}"`);const r=t.details,a=(l?null==r?void 0:r.partTarget:null==r?void 0:r.averagetargetduration)||m;let o;o=_<=d?s*e:n*e;const E=h[_].maxBitrate,b=this.getTimeToLoadFrag(g,o,E*a,void 0===r);if(T.trace(`[abr] level:${_} adjustedbw-bitrate:${Math.round(o-E)} avgDuration:${a.toFixed(1)} maxFetchDuration:${i.toFixed(1)} fetchDuration:${b.toFixed(1)}`),o>E&&(0===b||!u(b)||f&&!this.bitrateTestDelay||b<i))return _}return-1}set nextAutoLevel(e){this._nextAutoLevel=e}}class Bs{constructor(){this.chunks=[],this.dataLength=0}push(e){this.chunks.push(e),this.dataLength+=e.length}flush(){const{chunks:e,dataLength:t}=this;let r;return e.length?(r=1===e.length?e[0]:$s(e,t),this.reset(),r):new Uint8Array(0)}reset(){this.chunks.length=0,this.dataLength=0}}function $s(e,t){const r=new Uint8Array(t);let i=0;for(let s=0;s<e.length;s++){const t=e[s];r.set(t,i),i+=t.length}return r}const Gs=100;class js extends ei{constructor(e,t,r){super(e,t,r,"[audio-stream-controller]",_t.AUDIO),this.videoBuffer=null,this.videoTrackCC=-1,this.waitingVideoCC=-1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.bufferFlushed=!1,this.cachedTrackLoadedData=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),this.mainDetails=null,this.bufferedTrack=null,this.switchingTrack=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.LEVEL_LOADED,this.onLevelLoaded,this),e.on(f.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(f.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(f.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(f.ERROR,this.onError,this),e.on(f.BUFFER_RESET,this.onBufferReset,this),e.on(f.BUFFER_CREATED,this.onBufferCreated,this),e.on(f.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(f.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(f.FRAG_BUFFERED,this.onFragBuffered,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.LEVEL_LOADED,this.onLevelLoaded,this),e.off(f.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(f.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(f.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(f.ERROR,this.onError,this),e.off(f.BUFFER_RESET,this.onBufferReset,this),e.off(f.BUFFER_CREATED,this.onBufferCreated,this),e.off(f.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(f.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(f.FRAG_BUFFERED,this.onFragBuffered,this)}onInitPtsFound(e,{frag:t,id:r,initPTS:i,timescale:s}){if("main"===r){const e=t.cc;this.initPTS[t.cc]={baseTime:i,timescale:s},this.log(`InitPTS for cc: ${e} found from main: ${i}`),this.videoTrackCC=e,this.state===Jr.WAITING_INIT_PTS&&this.tick()}}startLoad(e){if(!this.levels)return this.startPosition=e,void(this.state=Jr.STOPPED);const t=this.lastCurrentTime;this.stopLoad(),this.setInterval(Gs),t>0&&-1===e?(this.log("Override startPosition with lastCurrentTime @"+t.toFixed(3)),e=t,this.state=Jr.IDLE):(this.loadedmetadata=!1,this.state=Jr.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}doTick(){switch(this.state){case Jr.IDLE:this.doTickIdle();break;case Jr.WAITING_TRACK:{var e;const{levels:t,trackId:r}=this,i=null==t||null==(e=t[r])?void 0:e.details;if(i){if(this.waitForCdnTuneIn(i))break;this.state=Jr.WAITING_INIT_PTS}break}case Jr.FRAG_LOADING_WAITING_RETRY:{var t;const e=performance.now(),r=this.retryDate;(!r||e>=r||null!=(t=this.media)&&t.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=Jr.IDLE);break}case Jr.WAITING_INIT_PTS:{const e=this.waitingData;if(e){const{frag:t,part:r,cache:i,complete:s}=e;if(void 0!==this.initPTS[t.cc]){this.waitingData=null,this.waitingVideoCC=-1,this.state=Jr.FRAG_LOADING;const e=i.flush(),n={frag:t,part:r,payload:e,networkDetails:null};this._handleFragmentLoadProgress(n),s&&super._handleFragmentLoadComplete(n)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log(`Waiting fragment cc (${t.cc}) cancelled because video is at cc ${this.videoTrackCC}`),this.clearWaitingFragment();else{const e=this.getLoadPosition(),r=Or.bufferInfo(this.mediaBuffer,e,this.config.maxBufferHole),i=dr(r.end,this.config.maxFragLookUpTolerance,t);i<0&&(this.log(`Waiting fragment cc (${t.cc}) @ ${t.start} cancelled because another fragment at ${r.end} is needed`),this.clearWaitingFragment())}}else this.state=Jr.IDLE}}this.onTickEnd()}clearWaitingFragment(){const e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=Jr.IDLE)}resetLoadingState(){this.clearWaitingFragment(),super.resetLoadingState()}onTickEnd(){const{media:e}=this;null!=e&&e.readyState&&(this.lastCurrentTime=e.currentTime)}doTickIdle(){const{hls:e,levels:t,media:r,trackId:i}=this,s=e.config;if(null==t||!t[i])return;if(!r&&(this.startFragRequested||!s.startFragPrefetch))return;const n=t[i],a=n.details;if(!a||a.live&&this.levelLastLoaded!==i||this.waitForCdnTuneIn(a))return void(this.state=Jr.WAITING_TRACK);const o=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&o&&(this.bufferFlushed=!1,this.afterBufferFlushed(o,D.AUDIO,_t.AUDIO));const l=this.getFwdBufferInfo(o,_t.AUDIO);if(null===l)return;const{bufferedTrack:d,switchingTrack:h}=this;if(!h&&this._streamEnded(l,a))return e.trigger(f.BUFFER_EOS,{type:"audio"}),void(this.state=Jr.ENDED);const c=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,_t.MAIN),u=l.len,p=this.getMaxBufferLength(null==c?void 0:c.len);if(u>=p&&!h)return;const m=a.fragments,g=m[0].start;let y=l.end;if(h&&r){const e=this.getLoadPosition();d&&h.attrs!==d.attrs&&(y=e),a.PTSKnown&&e<g&&(l.end>g||l.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),r.currentTime=g+.05)}let v=this.getNextFragment(y,a),_=!1;if(v&&this.isLoopLoading(v,y)&&(_=!!v.gap,v=this.getNextFragmentLoopLoading(v,a,l,_t.MAIN,p)),!v)return void(this.bufferFlushed=!0);const E=c&&v.start>c.end+a.targetduration;if(E||(null==c||!c.len)&&l.len){const e=this.getAppendedFrag(v.start,_t.MAIN);if(null===e)return;if(_||(_=!!e.gap||!!E&&0===c.len),E&&!_||_&&l.nextStart&&l.nextStart<e.end)return}this.loadFragment(v,n,y)}getMaxBufferLength(e){const t=super.getMaxBufferLength();return e?Math.min(Math.max(t,e),this.config.maxMaxBufferLength):t}onMediaDetaching(){this.videoBuffer=null,super.onMediaDetaching()}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(e=>new Gt(e))}onAudioTrackSwitching(e,t){const r=!!t.url;this.trackId=t.id;const{fragCurrent:i}=this;i&&(i.abortRequests(),this.removeUnbufferedFrags(i.start)),this.resetLoadingState(),r?this.setInterval(Gs):this.resetTransmuxer(),r?(this.switchingTrack=t,this.state=Jr.IDLE):(this.switchingTrack=null,this.bufferedTrack=t,this.state=Jr.STOPPED),this.tick()}onManifestLoading(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1,this.levels=this.mainDetails=this.waitingData=this.bufferedTrack=this.cachedTrackLoadedData=this.switchingTrack=null,this.startFragRequested=!1,this.trackId=this.videoTrackCC=this.waitingVideoCC=-1}onLevelLoaded(e,t){this.mainDetails=t.details,null!==this.cachedTrackLoadedData&&(this.hls.trigger(f.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)}onAudioTrackLoaded(e,t){var r;if(null==this.mainDetails)return void(this.cachedTrackLoadedData=t);const{levels:i}=this,{details:s,id:n}=t;if(!i)return void this.warn("Audio tracks were reset while loading level "+n);this.log(`Track ${n} loaded [${s.startSN},${s.endSN}]${s.lastPartSn?`[part-${s.lastPartSn}-${s.lastPartIndex}]`:""},duration:${s.totalduration}`);const a=i[n];let o=0;if(s.live||null!=(r=a.details)&&r.live){this.checkLiveUpdate(s);const e=this.mainDetails;if(s.deltaUpdateFailed||!e)return;!a.details&&s.hasProgramDateTime&&e.hasProgramDateTime?(Hr(s,e),o=s.fragments[0].start):o=this.alignPlaylists(s,a.details)}a.details=s,this.levelLastLoaded=n,this.startFragRequested||!this.mainDetails&&s.live||this.setStartPosition(a.details,o),this.state!==Jr.WAITING_TRACK||this.waitForCdnTuneIn(s)||(this.state=Jr.IDLE),this.tick()}_handleFragmentLoadProgress(e){var t;const{frag:r,part:i,payload:s}=e,{config:n,trackId:a,levels:o}=this;if(!o)return void this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${r.sn} of level ${r.level} will not be buffered`);const l=o[a];if(!l)return void this.warn("Audio track is undefined on fragment load progress");const d=l.details;if(!d)return this.warn("Audio track details undefined on fragment load progress"),void this.removeUnbufferedFrags(r.start);const h=n.defaultAudioCodec||l.audioCodec||"mp4a.40.2";let c=this.transmuxer;c||(c=this.transmuxer=new ks(this.hls,_t.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const u=this.initPTS[r.cc],f=null==(t=r.initSegment)?void 0:t.data;if(void 0!==u){const e=!1,t=i?i.index:-1,n=-1!==t,a=new Mr(r.level,r.sn,r.stats.chunkCount,s.byteLength,t,n);c.push(s,f,h,"",r,i,d.totalduration,e,a,u)}else{this.log(`Unknown video PTS for cc ${r.cc}, waiting for video PTS before demuxing audio frag ${r.sn} of [${d.startSN} ,${d.endSN}],track ${a}`);const{cache:e}=this.waitingData=this.waitingData||{frag:r,part:i,cache:new Bs,complete:!1};e.push(new Uint8Array(s)),this.waitingVideoCC=this.videoTrackCC,this.state=Jr.WAITING_INIT_PTS}}_handleFragmentLoadComplete(e){this.waitingData?this.waitingData.complete=!0:super._handleFragmentLoadComplete(e)}onBufferReset(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1}onBufferCreated(e,t){const r=t.tracks.audio;r&&(this.mediaBuffer=r.buffer||null),t.tracks.video&&(this.videoBuffer=t.tracks.video.buffer||null)}onFragBuffered(e,t){const{frag:r,part:i}=t;if(r.type===_t.AUDIO)if(this.fragContextChanged(r))this.warn(`Fragment ${r.sn}${i?" p: "+i.index:""} of level ${r.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);else{if("initSegment"!==r.sn){this.fragPrevious=r;const e=this.switchingTrack;e&&(this.bufferedTrack=e,this.switchingTrack=null,this.hls.trigger(f.AUDIO_TRACK_SWITCHED,o({},e)))}this.fragBufferedComplete(r,i)}else if(!this.loadedmetadata&&r.type===_t.MAIN){const e=this.videoBuffer||this.media;if(e){const t=Or.getBuffered(e);t.length&&(this.loadedmetadata=!0)}}}onError(e,t){var r;if(t.fatal)this.state=Jr.ERROR;else switch(t.details){case m.FRAG_GAP:case m.FRAG_PARSING_ERROR:case m.FRAG_DECRYPT_ERROR:case m.FRAG_LOAD_ERROR:case m.FRAG_LOAD_TIMEOUT:case m.KEY_LOAD_ERROR:case m.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(_t.AUDIO,t);break;case m.AUDIO_TRACK_LOAD_ERROR:case m.AUDIO_TRACK_LOAD_TIMEOUT:case m.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==Jr.WAITING_TRACK||(null==(r=t.context)?void 0:r.type)!==vt.AUDIO_TRACK||(this.state=Jr.IDLE);break;case m.BUFFER_FULL_ERROR:if(!t.parent||"audio"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case m.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onBufferFlushed(e,{type:t}){t===D.AUDIO&&(this.bufferFlushed=!0,this.state===Jr.ENDED&&(this.state=Jr.IDLE))}_handleTransmuxComplete(e){var t;const r="audio",{hls:i}=this,{remuxResult:s,chunkMeta:n}=e,a=this.getCurrentContext(n);if(!a)return void this.resetWhenMissingContext(n);const{frag:o,part:l,level:h}=a,{details:c}=h,{audio:u,text:p,id3:m,initSegment:g}=s;if(!this.fragContextChanged(o)&&c){if(this.state=Jr.PARSING,this.switchingTrack&&u&&this.completeAudioSwitch(this.switchingTrack),null!=g&&g.tracks){const e=o.initSegment||o;this._bufferInitSegment(g.tracks,e,n),i.trigger(f.FRAG_PARSING_INIT_SEGMENT,{frag:e,id:r,tracks:g.tracks})}if(u){const{startPTS:e,endPTS:t,startDTS:r,endDTS:i}=u;l&&(l.elementaryStreams[D.AUDIO]={startPTS:e,endPTS:t,startDTS:r,endDTS:i}),o.setElementaryStreamInfo(D.AUDIO,e,t,r,i),this.bufferFragmentData(u,o,l,n)}if(null!=m&&null!=(t=m.samples)&&t.length){const e=d({id:r,frag:o,details:c},m);i.trigger(f.FRAG_PARSING_METADATA,e)}if(p){const e=d({id:r,frag:o,details:c},p);i.trigger(f.FRAG_PARSING_USERDATA,e)}}else this.fragmentTracker.removeFragment(o)}_bufferInitSegment(e,t,r){if(this.state!==Jr.PARSING)return;e.video&&delete e.video;const i=e.audio;if(!i)return;i.levelCodec=i.codec,i.id="audio",this.log(`Init audio buffer, container:${i.container}, codecs[parsed]=[${i.codec}]`),this.hls.trigger(f.BUFFER_CODECS,e);const s=i.initSegment;if(null!=s&&s.byteLength){const e={type:"audio",frag:t,part:null,chunkMeta:r,parent:t.type,data:s};this.hls.trigger(f.BUFFER_APPENDING,e)}this.tick()}loadFragment(e,t,r){const i=this.fragmentTracker.getState(e);var s;(this.fragCurrent=e,this.switchingTrack||i===Tr.NOT_LOADED||i===Tr.PARTIAL)?"initSegment"===e.sn?this._loadInitSegment(e,t):null!=(s=t.details)&&s.live&&!this.initPTS[e.cc]?(this.log(`Waiting for video PTS in continuity counter ${e.cc} of live stream before loading audio fragment ${e.sn} of level ${this.trackId}`),this.state=Jr.WAITING_INIT_PTS):(this.startFragRequested=!0,super.loadFragment(e,t,r)):this.clearTrackerIfNeeded(e)}completeAudioSwitch(e){const{hls:t,media:r,bufferedTrack:i}=this,s=null==i?void 0:i.attrs,n=e.attrs;r&&s&&(s.CHANNELS!==n.CHANNELS||s.NAME!==n.NAME||s.LANGUAGE!==n.LANGUAGE)&&(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio")),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(f.AUDIO_TRACK_SWITCHED,o({},e))}}class Ks extends yr{constructor(e){super(e,"[audio-track-controller]"),this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){const{hls:e}=this;e.on(f.MANIFEST_LOADING,this.onManifestLoading,this),e.on(f.MANIFEST_PARSED,this.onManifestParsed,this),e.on(f.LEVEL_LOADING,this.onLevelLoading,this),e.on(f.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(f.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(f.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(f.MANIFEST_LOADING,this.onManifestLoading,this),e.off(f.MANIFEST_PARSED,this.onManifestParsed,this),e.off(f.LEVEL_LOADING,this.onLevelLoading,this),e.off(f.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(f.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(f.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.audioTracks||[]}onAudioTrackLoaded(e,t){const{id:r,groupId:i,details:s}=t,n=this.tracksInGroup[r];if(!n||n.groupId!==i)return void this.warn(`Track with id:${r} and group:${i} not found in active group ${n.groupId}`);const a=n.details;n.details=t.details,this.log(`audio-track ${r} "${n.name}" lang:${n.lang} group:${i} loaded [${s.startSN}-${s.endSN}]`),r===this.trackId&&this.playlistLoaded(r,t,a)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(null==t||!t.audioGroupIds)return;const r=t.audioGroupIds[t.urlId];if(this.groupId!==r){this.groupId=r||null;const e=this.tracks.filter(e=>!r||e.groupId===r);this.selectDefaultTrack&&!e.some(e=>e.default)&&(this.selectDefaultTrack=!1),this.tracksInGroup=e;const t={audioTracks:e};this.log(`Updating audio tracks, ${e.length} track(s) found in group:${r}`),this.hls.trigger(f.AUDIO_TRACKS_UPDATED,t),this.selectInitialTrack()}else this.shouldReloadPlaylist(this.currentTrack)&&this.setAudioTrack(this.trackId)}onError(e,t){!t.fatal&&t.context&&t.context.type===vt.AUDIO_TRACK&&t.context.id===this.trackId&&t.context.groupId===this.groupId&&(this.requestScheduled=-1,this.checkRetry(t))}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}setAudioTrack(e){const t=this.tracksInGroup;if(e<0||e>=t.length)return void this.warn("Invalid id passed to audio-track controller");this.clearTimer();const r=this.currentTrack;t[this.trackId];const i=t[e],{groupId:s,name:n}=i;if(this.log(`Switching to audio-track ${e} "${n}" lang:${i.lang} group:${s}`),this.trackId=e,this.currentTrack=i,this.selectDefaultTrack=!1,this.hls.trigger(f.AUDIO_TRACK_SWITCHING,o({},i)),i.details&&!i.details.live)return;const a=this.switchParams(i.url,null==r?void 0:r.details);this.loadPlaylist(a)}selectInitialTrack(){const e=this.tracksInGroup,t=this.findTrackId(this.currentTrack)|this.findTrackId(null);if(-1!==t)this.setAudioTrack(t);else{const t=new Error(`No track found for running audio group-ID: ${this.groupId} track count: ${e.length}`);this.warn(t.message),this.hls.trigger(f.ERROR,{type:p.MEDIA_ERROR,details:m.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:t})}}findTrackId(e){const t=this.tracksInGroup;for(let r=0;r<t.length;r++){const i=t[r];if(!this.selectDefaultTrack||i.default){if(!e||void 0!==e.attrs["STABLE-RENDITION-ID"]&&e.attrs["STABLE-RENDITION-ID"]===i.attrs["STABLE-RENDITION-ID"])return i.id;if(e.name===i.name&&e.lang===i.lang)return i.id}}return-1}loadPlaylist(e){super.loadPlaylist();const t=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(t)){const i=t.id,s=t.groupId;let n=t.url;if(e)try{n=e.addDirectives(n)}catch(r){this.warn("Could not construct new URL with HLS Delivery Directives: "+r)}this.log(`loading audio-track playlist ${i} "${t.name}" lang:${t.lang} group:${s}`),this.clearTimer(),this.hls.trigger(f.AUDIO_TRACK_LOADING,{url:n,id:i,groupId:s,deliveryDirectives:e||null})}}}function Vs(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!Hs(e[r].attrs,t[r].attrs))return!1;return!0}function Hs(e,t){const r=e["STABLE-RENDITION-ID"];return r?r===t["STABLE-RENDITION-ID"]:!["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED"].some(r=>e[r]!==t[r])}const Ys=500;class zs extends ei{constructor(e,t,r){super(e,t,r,"[subtitle-stream-controller]",_t.SUBTITLE),this.levels=[],this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),this.mainDetails=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.LEVEL_LOADED,this.onLevelLoaded,this),e.on(f.ERROR,this.onError,this),e.on(f.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(f.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(f.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(f.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(f.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(f.FRAG_BUFFERED,this.onFragBuffered,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.LEVEL_LOADED,this.onLevelLoaded,this),e.off(f.ERROR,this.onError,this),e.off(f.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(f.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(f.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(f.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(f.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(f.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(e){this.stopLoad(),this.state=Jr.IDLE,this.setInterval(Ys),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}onManifestLoading(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()}onMediaDetaching(){this.tracksBuffered=[],super.onMediaDetaching()}onLevelLoaded(e,t){this.mainDetails=t.details}onSubtitleFragProcessed(e,t){const{frag:r,success:i}=t;if(this.fragPrevious=r,this.state=Jr.IDLE,!i)return;const s=this.tracksBuffered[this.currentTrackId];if(!s)return;let n;const a=r.start;for(let l=0;l<s.length;l++)if(a>=s[l].start&&a<=s[l].end){n=s[l];break}const o=r.start+r.duration;n?n.end=o:(n={start:a,end:o},s.push(n)),this.fragmentTracker.fragBuffered(r)}onBufferFlushing(e,t){const{startOffset:r,endOffset:i}=t;if(0===r&&i!==Number.POSITIVE_INFINITY){const e=i-1;if(e<=0)return;t.endOffsetSubtitles=Math.max(0,e),this.tracksBuffered.forEach(t=>{for(let r=0;r<t.length;)if(t[r].end<=e)t.shift();else{if(!(t[r].start<e))break;t[r].start=e,r++}}),this.fragmentTracker.removeFragmentsInRange(r,e,_t.SUBTITLE)}}onFragBuffered(e,t){var r;this.loadedmetadata||t.frag.type!==_t.MAIN||null!=(r=this.media)&&r.buffered.length&&(this.loadedmetadata=!0)}onError(e,t){const r=t.frag;(null==r?void 0:r.type)===_t.SUBTITLE&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==Jr.STOPPED&&(this.state=Jr.IDLE))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){Vs(this.levels,t)?this.levels=t.map(e=>new Gt(e)):(this.tracksBuffered=[],this.levels=t.map(e=>{const t=new Gt(e);return this.tracksBuffered[t.id]=[],t}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,_t.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null)}onSubtitleTrackSwitch(e,t){if(this.currentTrackId=t.id,!this.levels.length||-1===this.currentTrackId)return void this.clearInterval();const r=this.levels[this.currentTrackId];null!=r&&r.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,r&&this.setInterval(Ys)}onSubtitleTrackLoaded(e,t){var r;const{details:i,id:s}=t,{currentTrackId:n,levels:a}=this;if(!a.length)return;const o=a[n];if(s>=a.length||s!==n||!o)return;this.mediaBuffer=this.mediaBufferTimeRanges;let l=0;if(i.live||null!=(r=o.details)&&r.live){const e=this.mainDetails;if(i.deltaUpdateFailed||!e)return;const t=e.fragments[0];o.details?(l=this.alignPlaylists(i,o.details),0===l&&t&&(l=t.start,qt(i,l))):i.hasProgramDateTime&&e.hasProgramDateTime?(Hr(i,e),l=i.fragments[0].start):t&&(l=t.start,qt(i,l))}if(o.details=i,this.levelLastLoaded=s,this.startFragRequested||!this.mainDetails&&i.live||this.setStartPosition(o.details,l),this.tick(),i.live&&!this.fragCurrent&&this.media&&this.state===Jr.IDLE){const e=lr(null,i.fragments,this.media.currentTime,0);e||(this.warn("Subtitle playlist not aligned with playback"),o.details=void 0)}}_handleFragmentLoadComplete(e){const{frag:t,payload:r}=e,i=t.decryptdata,s=this.hls;if(!this.fragContextChanged(t)&&r&&r.byteLength>0&&i&&i.key&&i.iv&&"AES-128"===i.method){const e=performance.now();this.decrypter.decrypt(new Uint8Array(r),i.key.buffer,i.iv.buffer).catch(e=>{throw s.trigger(f.ERROR,{type:p.MEDIA_ERROR,details:m.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:t}),e}).then(r=>{const i=performance.now();s.trigger(f.FRAG_DECRYPTED,{frag:t,payload:r,stats:{tstart:e,tdecrypt:i}})}).catch(e=>{this.warn(`${e.name}: ${e.message}`),this.state=Jr.IDLE})}}doTick(){if(this.media){if(this.state===Jr.IDLE){const{currentTrackId:e,levels:t}=this,r=t[e];if(!t.length||!r||!r.details)return;const{config:i}=this,s=this.getLoadPosition(),n=Or.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],s,i.maxBufferHole),{end:a,len:o}=n,l=this.getFwdBufferInfo(this.media,_t.MAIN),d=r.details,h=this.getMaxBufferLength(null==l?void 0:l.len)+d.levelTargetDuration;if(o>h)return;const c=d.fragments,u=c.length,f=d.edge;let p=null;const m=this.fragPrevious;if(a<f){const e=i.maxFragLookUpTolerance,t=a>f-e?0:e;p=lr(m,c,Math.max(c[0].start,a),t),!p&&m&&m.start<c[0].start&&(p=c[0])}else p=c[u-1];if(!p)return;if(p=this.mapToInitFragWhenRequired(p),"initSegment"!==p.sn){const e=p.sn-d.startSN,t=c[e-1];t&&t.cc===p.cc&&this.fragmentTracker.getState(t)===Tr.NOT_LOADED&&(p=t)}this.fragmentTracker.getState(p)===Tr.NOT_LOADED&&this.loadFragment(p,r,a)}}else this.state=Jr.IDLE}getMaxBufferLength(e){const t=super.getMaxBufferLength();return e?Math.max(t,e):t}loadFragment(e,t,r){this.fragCurrent=e,"initSegment"===e.sn?this._loadInitSegment(e,t):(this.startFragRequested=!0,super.loadFragment(e,t,r))}get mediaBufferTimeRanges(){return new Ws(this.tracksBuffered[this.currentTrackId]||[])}}class Ws{constructor(e){this.buffered=void 0;const t=(t,r,i)=>{if(r>>>=0,r>i-1)throw new DOMException(`Failed to execute '${t}' on 'TimeRanges': The index provided (${r}) is greater than the maximum bound (${i})`);return e[r][t]};this.buffered={get length(){return e.length},end(r){return t("end",r,e.length)},start(r){return t("start",r,e.length)}}}}class qs extends yr{constructor(e){super(e,"[subtitle-track-controller]"),this.media=null,this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.trackChangeListener=()=>this.onTextTracksChanged(),this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes(this.trackId)}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.MANIFEST_PARSED,this.onManifestParsed,this),e.on(f.LEVEL_LOADING,this.onLevelLoading,this),e.on(f.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(f.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(f.ERROR,this.onError,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.MANIFEST_PARSED,this.onManifestParsed,this),e.off(f.LEVEL_LOADING,this.onLevelLoading,this),e.off(f.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(f.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(f.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))}pollTrackChange(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,e)}onMediaDetaching(){if(!this.media)return;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId);const e=Xs(this.media.textTracks);e.forEach(e=>{At(e)}),this.subtitleTrack=-1,this.media=null}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.subtitleTracks}onSubtitleTrackLoaded(e,t){const{id:r,details:i}=t,{trackId:s}=this,n=this.tracksInGroup[s];if(!n)return void this.warn("Invalid subtitle track id "+r);const a=n.details;n.details=t.details,this.log(`subtitle track ${r} loaded [${i.startSN}-${i.endSN}]`),r===this.trackId&&this.playlistLoaded(r,t,a)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(null==t||!t.textGroupIds)return;const r=t.textGroupIds[t.urlId],i=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;if(this.groupId!==r){const e=this.tracks.filter(e=>!r||e.groupId===r);this.tracksInGroup=e;const t=this.findTrackId(null==i?void 0:i.name)||this.findTrackId();this.groupId=r||null;const s={subtitleTracks:e};this.log(`Updating subtitle tracks, ${e.length} track(s) found in "${r}" group-id`),this.hls.trigger(f.SUBTITLE_TRACKS_UPDATED,s),-1!==t&&this.setSubtitleTrack(t,i)}else this.shouldReloadPlaylist(i)&&this.setSubtitleTrack(this.trackId,i)}findTrackId(e){const t=this.tracksInGroup;for(let r=0;r<t.length;r++){const i=t[r];if((!this.selectDefaultTrack||i.default)&&(!e||e===i.name))return i.id}return-1}onError(e,t){!t.fatal&&t.context&&t.context.type===vt.SUBTITLE_TRACK&&t.context.id===this.trackId&&t.context.groupId===this.groupId&&this.checkRetry(t)}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(e){this.selectDefaultTrack=!1;const t=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(e,t)}loadPlaylist(e){super.loadPlaylist();const t=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(t)){const i=t.id,s=t.groupId;let n=t.url;if(e)try{n=e.addDirectives(n)}catch(r){this.warn("Could not construct new URL with HLS Delivery Directives: "+r)}this.log("Loading subtitle playlist for id "+i),this.hls.trigger(f.SUBTITLE_TRACK_LOADING,{url:n,id:i,groupId:s,deliveryDirectives:e||null})}}toggleTrackModes(e){const{media:t,trackId:r}=this;if(!t)return;const i=Xs(t.textTracks),s=i.filter(e=>e.groupId===this.groupId);if(-1===e)[].slice.call(i).forEach(e=>{e.mode="disabled"});else{const e=s[r];e&&(e.mode="disabled")}const n=s[e];n&&(n.mode=this.subtitleDisplay?"showing":"hidden")}setSubtitleTrack(e,t){var r;const i=this.tracksInGroup;if(!this.media)return void(this.queuedDefaultTrack=e);if(this.trackId!==e&&this.toggleTrackModes(e),this.trackId===e&&(-1===e||null!=(r=i[e])&&r.details)||e<-1||e>=i.length)return;this.clearTimer();const s=i[e];if(this.log("Switching to subtitle-track "+e+(s?` "${s.name}" lang:${s.lang} group:${s.groupId}`:"")),this.trackId=e,s){const{id:e,groupId:r="",name:i,type:n,url:a}=s;this.hls.trigger(f.SUBTITLE_TRACK_SWITCH,{id:e,groupId:r,name:i,type:n,url:a});const o=this.switchParams(s.url,null==t?void 0:t.details);this.loadPlaylist(o)}else this.hls.trigger(f.SUBTITLE_TRACK_SWITCH,{id:e})}onTextTracksChanged(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let e=-1;const t=Xs(this.media.textTracks);for(let r=0;r<t.length;r++)if("hidden"===t[r].mode)e=r;else if("showing"===t[r].mode){e=r;break}this.subtitleTrack!==e&&(this.subtitleTrack=e)}}function Xs(e){const t=[];for(let r=0;r<e.length;r++){const i=e[r];"subtitles"!==i.kind&&"captions"!==i.kind||!i.label||t.push(e[r])}return t}class Qs{constructor(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}append(e,t){const r=this.queues[t];r.push(e),1===r.length&&this.buffers[t]&&this.executeNext(t)}insertAbort(e,t){const r=this.queues[t];r.unshift(e),this.executeNext(t)}appendBlocker(e){let t;const r=new Promise(e=>{t=e}),i={execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(i,e),r}executeNext(e){const{buffers:t,queues:r}=this,i=t[e],s=r[e];if(s.length){const t=s[0];try{t.execute()}catch(n){T.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),t.onError(n),null!=i&&i.updating||(s.shift(),this.executeNext(e))}}}shiftAndExecuteNext(e){this.queues[e].shift(),this.executeNext(e)}current(e){return this.queues[e][0]}}const Zs=Je(),Js=/([ha]vc.)(?:\.[^.,]+)+/;class en{constructor(e){this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=()=>{const{media:e,mediaSource:t}=this;T.log("[buffer-controller]: Media source opened"),e&&(e.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(f.MEDIA_ATTACHED,{media:e})),t&&t.removeEventListener("sourceopen",this._onMediaSourceOpen),this.checkPendingTracks()},this._onMediaSourceClose=()=>{T.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=()=>{T.log("[buffer-controller]: Media source ended")},this._onMediaEmptied=()=>{const{media:e,_objectUrl:t}=this;e&&e.src!==t&&T.error(`Media element src was set while attaching MediaSource (${t} > ${e.src})`)},this.hls=e,this._initSourceBuffer(),this.registerListeners()}hasSourceTypes(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null}registerListeners(){const{hls:e}=this;e.on(f.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(f.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(f.MANIFEST_LOADING,this.onManifestLoading,this),e.on(f.MANIFEST_PARSED,this.onManifestParsed,this),e.on(f.BUFFER_RESET,this.onBufferReset,this),e.on(f.BUFFER_APPENDING,this.onBufferAppending,this),e.on(f.BUFFER_CODECS,this.onBufferCodecs,this),e.on(f.BUFFER_EOS,this.onBufferEos,this),e.on(f.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(f.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(f.FRAG_PARSED,this.onFragParsed,this),e.on(f.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){const{hls:e}=this;e.off(f.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(f.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(f.MANIFEST_LOADING,this.onManifestLoading,this),e.off(f.MANIFEST_PARSED,this.onManifestParsed,this),e.off(f.BUFFER_RESET,this.onBufferReset,this),e.off(f.BUFFER_APPENDING,this.onBufferAppending,this),e.off(f.BUFFER_CODECS,this.onBufferCodecs,this),e.off(f.BUFFER_EOS,this.onBufferEos,this),e.off(f.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(f.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(f.FRAG_PARSED,this.onFragParsed,this),e.off(f.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new Qs(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null}onManifestLoading(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null}onManifestParsed(e,t){let r=2;(t.audio&&!t.video||!t.altAudio)&&(r=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,T.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")}onMediaAttaching(e,t){const r=this.media=t.media;if(r&&Zs){const e=this.mediaSource=new Zs;e.addEventListener("sourceopen",this._onMediaSourceOpen),e.addEventListener("sourceended",this._onMediaSourceEnded),e.addEventListener("sourceclose",this._onMediaSourceClose),r.src=self.URL.createObjectURL(e),this._objectUrl=r.src,r.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){const{media:e,mediaSource:t,_objectUrl:r}=this;if(t){if(T.log("[buffer-controller]: media source detaching"),"open"===t.readyState)try{t.endOfStream()}catch(Na){T.warn(`[buffer-controller]: onMediaDetaching: ${Na.message} while calling endOfStream`)}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(e.removeEventListener("emptied",this._onMediaEmptied),r&&self.URL.revokeObjectURL(r),e.src===r?(e.removeAttribute("src"),e.load()):T.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(f.MEDIA_DETACHED,void 0)}onBufferReset(){this.getSourceBufferTypes().forEach(e=>{const t=this.sourceBuffer[e];try{t&&(this.removeBufferListeners(e),this.mediaSource&&this.mediaSource.removeSourceBuffer(t),this.sourceBuffer[e]=void 0)}catch(Na){T.warn(`[buffer-controller]: Failed to reset the ${e} buffer`,Na)}}),this._initSourceBuffer()}onBufferCodecs(e,t){const r=this.getSourceBufferTypes().length;Object.keys(t).forEach(e=>{if(r){const r=this.tracks[e];if(r&&"function"===typeof r.buffer.changeType){const{id:i,codec:s,levelCodec:n,container:a,metadata:o}=t[e],l=(r.levelCodec||r.codec).replace(Js,"$1"),d=(n||s).replace(Js,"$1");if(l!==d){const t=`${a};codecs=${n||s}`;this.appendChangeType(e,t),T.log(`[buffer-controller]: switching codec ${l} to ${d}`),this.tracks[e]={buffer:r.buffer,codec:s,container:a,levelCodec:n,metadata:o,id:i}}}}else this.pendingTracks[e]=t[e]}),r||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks())}appendChangeType(e,t){const{operationQueue:r}=this,i={execute:()=>{const i=this.sourceBuffer[e];i&&(T.log(`[buffer-controller]: changing ${e} sourceBuffer type to ${t}`),i.changeType(t)),r.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:t=>{T.warn(`[buffer-controller]: Failed to change ${e} SourceBuffer type`,t)}};r.append(i,e)}onBufferAppending(e,t){const{hls:r,operationQueue:i,tracks:s}=this,{data:n,type:a,frag:o,part:l,chunkMeta:d}=t,h=d.buffering[a],c=self.performance.now();h.start=c;const u=o.stats.buffering,g=l?l.stats.buffering:null;0===u.start&&(u.start=c),g&&0===g.start&&(g.start=c);const y=s.audio;let v=!1;"audio"===a&&"audio/mpeg"===(null==y?void 0:y.container)&&(v=!this.lastMpegAudioChunk||1===d.id||this.lastMpegAudioChunk.sn!==d.sn,this.lastMpegAudioChunk=d);const _=o.start,E={execute:()=>{if(h.executeStart=self.performance.now(),v){const e=this.sourceBuffer[a];if(e){const t=_-e.timestampOffset;Math.abs(t)>=.1&&(T.log(`[buffer-controller]: Updating audio SourceBuffer timestampOffset to ${_} (delta: ${t}) sn: ${o.sn})`),e.timestampOffset=_)}}this.appendExecutor(n,a)},onStart:()=>{},onComplete:()=>{const e=self.performance.now();h.executeEnd=h.end=e,0===u.first&&(u.first=e),g&&0===g.first&&(g.first=e);const{sourceBuffer:t}=this,r={};for(const i in t)r[i]=Or.getBuffered(t[i]);this.appendError=0,this.hls.trigger(f.BUFFER_APPENDED,{type:a,frag:o,part:l,chunkMeta:d,parent:o.type,timeRanges:r})},onError:e=>{T.error(`[buffer-controller]: Error encountered while trying to append to the ${a} SourceBuffer`,e);const t={type:p.MEDIA_ERROR,parent:o.type,details:m.BUFFER_APPEND_ERROR,frag:o,part:l,chunkMeta:d,error:e,err:e,fatal:!1};e.code===DOMException.QUOTA_EXCEEDED_ERR?t.details=m.BUFFER_FULL_ERROR:(this.appendError++,t.details=m.BUFFER_APPEND_ERROR,this.appendError>r.config.appendErrorMaxRetry&&(T.error(`[buffer-controller]: Failed ${r.config.appendErrorMaxRetry} times to append segment in sourceBuffer`),t.fatal=!0)),r.trigger(f.ERROR,t)}};i.append(E,a)}onBufferFlushing(e,t){const{operationQueue:r}=this,i=e=>({execute:this.removeExecutor.bind(this,e,t.startOffset,t.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(f.BUFFER_FLUSHED,{type:e})},onError:t=>{T.warn(`[buffer-controller]: Failed to remove from ${e} SourceBuffer`,t)}});t.type?r.append(i(t.type),t.type):this.getSourceBufferTypes().forEach(e=>{r.append(i(e),e)})}onFragParsed(e,t){const{frag:r,part:i}=t,s=[],n=i?i.elementaryStreams:r.elementaryStreams;n[D.AUDIOVIDEO]?s.push("audiovideo"):(n[D.AUDIO]&&s.push("audio"),n[D.VIDEO]&&s.push("video"));const a=()=>{const e=self.performance.now();r.stats.buffering.end=e,i&&(i.stats.buffering.end=e);const t=i?i.stats:r.stats;this.hls.trigger(f.FRAG_BUFFERED,{frag:r,part:i,stats:t,id:r.type})};0===s.length&&T.warn(`Fragments must have at least one ElementaryStreamType set. type: ${r.type} level: ${r.level} sn: ${r.sn}`),this.blockBuffers(a,s)}onFragChanged(e,t){this.flushBackBuffer()}onBufferEos(e,t){const r=this.getSourceBufferTypes().reduce((e,r)=>{const i=this.sourceBuffer[r];return!i||t.type&&t.type!==r||(i.ending=!0,i.ended||(i.ended=!0,T.log(`[buffer-controller]: ${r} sourceBuffer now EOS`))),e&&!(i&&!i.ended)},!0);r&&(T.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers(()=>{this.getSourceBufferTypes().forEach(e=>{const t=this.sourceBuffer[e];t&&(t.ending=!1)});const{mediaSource:e}=this;e&&"open"===e.readyState?(T.log("[buffer-controller]: Calling mediaSource.endOfStream()"),e.endOfStream()):e&&T.info("[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: "+e.readyState)}))}onLevelUpdated(e,{details:t}){t.fragments.length&&(this.details=t,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())}flushBackBuffer(){const{hls:e,details:t,media:r,sourceBuffer:i}=this;if(!r||null===t)return;const s=this.getSourceBufferTypes();if(!s.length)return;const n=t.live&&null!==e.config.liveBackBufferLength?e.config.liveBackBufferLength:e.config.backBufferLength;if(!u(n)||n<0)return;const a=r.currentTime,o=t.levelTargetDuration,l=Math.max(n,o),d=Math.floor(a/o)*o-l;s.forEach(r=>{const s=i[r];if(s){const i=Or.getBuffered(s);if(i.length>0&&d>i.start(0)){if(e.trigger(f.BACK_BUFFER_REACHED,{bufferEnd:d}),t.live)e.trigger(f.LIVE_BACK_BUFFER_REACHED,{bufferEnd:d});else if(s.ended&&i.end(i.length-1)-a<2*o)return void T.info(`[buffer-controller]: Cannot flush ${r} back buffer while SourceBuffer is in ended state`);e.trigger(f.BUFFER_FLUSHING,{startOffset:0,endOffset:d,type:r})}}})}updateMediaElementDuration(){if(!this.details||!this.media||!this.mediaSource||"open"!==this.mediaSource.readyState)return;const{details:e,hls:t,media:r,mediaSource:i}=this,s=e.fragments[0].start+e.totalduration,n=r.duration,a=u(i.duration)?i.duration:0;e.live&&t.config.liveDurationInfinity?(T.log("[buffer-controller]: Media Source duration is set to Infinity"),i.duration=1/0,this.updateSeekableRange(e)):(s>a&&s>n||!u(n))&&(T.log("[buffer-controller]: Updating Media Source duration to "+s.toFixed(3)),i.duration=s)}updateSeekableRange(e){const t=this.mediaSource,r=e.fragments,i=r.length;if(i&&e.live&&null!=t&&t.setLiveSeekableRange){const i=Math.max(0,r[0].start),s=Math.max(i,i+e.totalduration);t.setLiveSeekableRange(i,s)}}checkPendingTracks(){const{bufferCodecEventsExpected:e,operationQueue:t,pendingTracks:r}=this,i=Object.keys(r).length;if(i&&!e||2===i){this.createSourceBuffers(r),this.pendingTracks={};const e=this.getSourceBufferTypes();if(e.length)this.hls.trigger(f.BUFFER_CREATED,{tracks:this.tracks}),e.forEach(e=>{t.executeNext(e)});else{const e=new Error("could not create source buffer for media codec(s)");this.hls.trigger(f.ERROR,{type:p.MEDIA_ERROR,details:m.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:e,reason:e.message})}}}createSourceBuffers(e){const{sourceBuffer:t,mediaSource:r}=this;if(!r)throw Error("createSourceBuffers called when mediaSource was null");for(const i in e)if(!t[i]){const s=e[i];if(!s)throw Error(`source buffer exists for track ${i}, however track does not`);const n=s.levelCodec||s.codec,a=`${s.container};codecs=${n}`;T.log(`[buffer-controller]: creating sourceBuffer(${a})`);try{const e=t[i]=r.addSourceBuffer(a),o=i;this.addBufferListener(o,"updatestart",this._onSBUpdateStart),this.addBufferListener(o,"updateend",this._onSBUpdateEnd),this.addBufferListener(o,"error",this._onSBUpdateError),this.tracks[i]={buffer:e,codec:n,container:s.container,levelCodec:s.levelCodec,metadata:s.metadata,id:s.id}}catch(Na){T.error("[buffer-controller]: error while trying to add sourceBuffer: "+Na.message),this.hls.trigger(f.ERROR,{type:p.MEDIA_ERROR,details:m.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:Na,mimeType:a})}}}_onSBUpdateStart(e){const{operationQueue:t}=this,r=t.current(e);r.onStart()}_onSBUpdateEnd(e){const{operationQueue:t}=this,r=t.current(e);r.onComplete(),t.shiftAndExecuteNext(e)}_onSBUpdateError(e,t){const r=new Error(e+" SourceBuffer error");T.error("[buffer-controller]: "+r,t),this.hls.trigger(f.ERROR,{type:p.MEDIA_ERROR,details:m.BUFFER_APPENDING_ERROR,error:r,fatal:!1});const i=this.operationQueue.current(e);i&&i.onError(t)}removeExecutor(e,t,r){const{media:i,mediaSource:s,operationQueue:n,sourceBuffer:a}=this,o=a[e];if(!i||!s||!o)return T.warn(`[buffer-controller]: Attempting to remove from the ${e} SourceBuffer, but it does not exist`),void n.shiftAndExecuteNext(e);const l=u(i.duration)?i.duration:1/0,d=u(s.duration)?s.duration:1/0,h=Math.max(0,t),c=Math.min(r,l,d);c>h&&!o.ending?(o.ended=!1,T.log(`[buffer-controller]: Removing [${h},${c}] from the ${e} SourceBuffer`),o.remove(h,c)):n.shiftAndExecuteNext(e)}appendExecutor(e,t){const{operationQueue:r,sourceBuffer:i}=this,s=i[t];if(!s)return T.warn(`[buffer-controller]: Attempting to append to the ${t} SourceBuffer, but it does not exist`),void r.shiftAndExecuteNext(t);s.ended=!1,s.appendBuffer(e)}blockBuffers(e,t=this.getSourceBufferTypes()){if(!t.length)return T.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve().then(e);const{operationQueue:r}=this,i=t.map(e=>r.appendBlocker(e));Promise.all(i).then(()=>{e(),t.forEach(e=>{const t=this.sourceBuffer[e];null!=t&&t.updating||r.shiftAndExecuteNext(e)})})}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(e,t,r){const i=this.sourceBuffer[e];if(!i)return;const s=r.bind(this,e);this.listeners[e].push({event:t,listener:s}),i.addEventListener(t,s)}removeBufferListeners(e){const t=this.sourceBuffer[e];t&&this.listeners[e].forEach(e=>{t.removeEventListener(e.event,e.listener)})}}const tn={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},rn=function(e){let t=e;return tn.hasOwnProperty(e)&&(t=tn[e]),String.fromCharCode(t)},sn=15,nn=100,an={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},on={17:2,18:4,21:6,22:8,23:10,19:13,20:15},ln={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},dn={25:2,26:4,29:6,30:8,31:10,27:13,28:15},hn=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class cn{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){const r="function"===typeof t?t():t;T.log(`${this.time} [${e}] ${r}`)}}}const un=function(e){const t=[];for(let r=0;r<e.length;r++)t.push(e[r].toString(16));return t};class fn{constructor(e,t,r,i,s){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=e||"white",this.underline=t||!1,this.italics=r||!1,this.background=i||"black",this.flash=s||!1}reset(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}setStyles(e){const t=["foreground","underline","italics","background","flash"];for(let r=0;r<t.length;r++){const i=t[r];e.hasOwnProperty(i)&&(this[i]=e[i])}}isDefault(){return"white"===this.foreground&&!this.underline&&!this.italics&&"black"===this.background&&!this.flash}equals(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash}copy(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}}class pn{constructor(e,t,r,i,s,n){this.uchar=void 0,this.penState=void 0,this.uchar=e||" ",this.penState=new fn(t,r,i,s,n)}reset(){this.uchar=" ",this.penState.reset()}setChar(e,t){this.uchar=e,this.penState.copy(t)}setPenState(e){this.penState.copy(e)}equals(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)}copy(e){this.uchar=e.uchar,this.penState.copy(e.penState)}isEmpty(){return" "===this.uchar&&this.penState.isDefault()}}class mn{constructor(e){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(let t=0;t<nn;t++)this.chars.push(new pn);this.logger=e,this.pos=0,this.currPenState=new fn}equals(e){let t=!0;for(let r=0;r<nn;r++)if(!this.chars[r].equals(e.chars[r])){t=!1;break}return t}copy(e){for(let t=0;t<nn;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<nn;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e}setCursor(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>nn&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=nn)}moveCursor(e){const t=this.pos+e;if(e>1)for(let r=this.pos+1;r<t+1;r++)this.chars[r].setPenState(this.currPenState);this.setCursor(t)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(e){e>=144&&this.backSpace();const t=rn(e);this.pos>=nn?this.logger.log(0,()=>"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!"):(this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1))}clearFromPos(e){let t;for(t=e;t<nn;t++)this.chars[t].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){const e=[];let t=!0;for(let r=0;r<nn;r++){const i=this.chars[r].uchar;" "!==i&&(t=!1),e.push(i)}return t?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e);const t=this.chars[this.pos];t.setPenState(this.currPenState)}}class gn{constructor(e){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(let t=0;t<sn;t++)this.rows.push(new mn(e));this.logger=e,this.currRow=sn-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}reset(){for(let e=0;e<sn;e++)this.rows[e].clear();this.currRow=sn-1}equals(e){let t=!0;for(let r=0;r<sn;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t}copy(e){for(let t=0;t<sn;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<sn;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e}backSpace(){const e=this.rows[this.currRow];e.backSpace()}clearToEndOfRow(){const e=this.rows[this.currRow];e.clearToEndOfRow()}insertChar(e){const t=this.rows[this.currRow];t.insertChar(e)}setPen(e){const t=this.rows[this.currRow];t.setPenStyles(e)}moveCursor(e){const t=this.rows[this.currRow];t.moveCursor(e)}setCursor(e){this.logger.log(2,"setCursor: "+e);const t=this.rows[this.currRow];t.setCursor(e)}setPAC(e){this.logger.log(2,()=>"pacData = "+JSON.stringify(e));let t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(let t=0;t<sn;t++)this.rows[t].clear();const e=this.currRow+1-this.nrRollUpRows,r=this.lastOutputScreen;if(r){const i=r.rows[e].cueStartTime,s=this.logger.time;if(i&&null!==s&&i<s)for(let n=0;n<this.nrRollUpRows;n++)this.rows[t-this.nrRollUpRows+n+1].copy(r.rows[e+n])}}this.currRow=t;const r=this.rows[this.currRow];if(null!==e.indent){const t=e.indent,i=Math.max(t-1,0);r.setCursor(e.indent),e.color=r.chars[i].penState.foreground}const i={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(i)}setBkgData(e){this.logger.log(2,()=>"bkgData = "+JSON.stringify(e)),this.backSpace(),this.setPen(e),this.insertChar(32)}setRollUpRows(e){this.nrRollUpRows=e}rollUp(){if(null===this.nrRollUpRows)return void this.logger.log(3,"roll_up but nrRollUpRows not set yet");this.logger.log(1,()=>this.getDisplayText());const e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(2,"Rolling up")}getDisplayText(e){e=e||!1;const t=[];let r="",i=-1;for(let s=0;s<sn;s++){const r=this.rows[s].getTextString();r&&(i=s+1,e?t.push("Row "+i+": '"+r+"'"):t.push(r.trim()))}return t.length>0&&(r=e?"["+t.join(" | ")+"]":t.join("\n")),r}getTextAndFormat(){return this.rows}}class yn{constructor(e,t,r){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new gn(r),this.nonDisplayedMemory=new gn(r),this.lastOutputScreen=new gn(r),this.currRollUpRow=this.displayedMemory.rows[sn-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=r}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[sn-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(e){this.outputFilter=e}setPAC(e){this.writeScreen.setPAC(e)}setBkgData(e){this.writeScreen.setBkgData(e)}setMode(e){e!==this.mode&&(this.mode=e,this.logger.log(2,()=>"MODE="+e),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)}insertChars(e){for(let r=0;r<e.length;r++)this.writeScreen.insertChar(e[r]);const t=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>t+": "+this.writeScreen.getDisplayText(!0)),"MODE_PAINT-ON"!==this.mode&&"MODE_ROLL-UP"!==this.mode||(this.logger.log(1,()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())}ccRCL(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}ccBS(){this.logger.log(2,"BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}ccAOF(){}ccAON(){}ccDER(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}ccRU(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}ccEOC(){if(this.logger.log(2,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode){const e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}ccTO(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}ccMIDROW(e){const t={flash:!1};if(t.underline=e%2===1,t.italics=e>=46,t.italics)t.foreground="white";else{const r=Math.floor(e/2)-16,i=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=i[r]}this.logger.log(2,"MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)}outputDataUpdate(e=!1){const t=this.logger.time;null!==t&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t):this.cueStartTime=t,this.lastOutputScreen.copy(this.displayedMemory))}cueSplitAtTime(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))}}class vn{constructor(e,t,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;const i=new cn;this.channels=[null,new yn(e,t,i),new yn(e+1,r,i)],this.cmdHistory=bn(),this.logger=i}getHandler(e){return this.channels[e].getHandler()}setHandler(e,t){this.channels[e].setHandler(t)}addData(e,t){let r,i,s,n=!1;this.logger.time=e;for(let a=0;a<t.length;a+=2)if(i=127&t[a],s=127&t[a+1],0!==i||0!==s){if(this.logger.log(3,"["+un([t[a],t[a+1]])+"] -> ("+un([i,s])+")"),r=this.parseCmd(i,s),r||(r=this.parseMidrow(i,s)),r||(r=this.parsePAC(i,s)),r||(r=this.parseBackgroundAttributes(i,s)),!r&&(n=this.parseChars(i,s),n)){const e=this.currentChannel;if(e&&e>0){const t=this.channels[e];t.insertChars(n)}else this.logger.log(2,"No channel found yet. TEXT-MODE?")}r||n||this.logger.log(2,"Couldn't parse cleaned data "+un([i,s])+" orig: "+un([t[a],t[a+1]]))}}parseCmd(e,t){const{cmdHistory:r}=this,i=(20===e||28===e||21===e||29===e)&&t>=32&&t<=47,s=(23===e||31===e)&&t>=33&&t<=35;if(!i&&!s)return!1;if(En(e,t,r))return _n(null,null,r),this.logger.log(3,"Repeated command ("+un([e,t])+") is dropped"),!0;const n=20===e||21===e||23===e?1:2,a=this.channels[n];return 20===e||21===e||28===e||29===e?32===t?a.ccRCL():33===t?a.ccBS():34===t?a.ccAOF():35===t?a.ccAON():36===t?a.ccDER():37===t?a.ccRU(2):38===t?a.ccRU(3):39===t?a.ccRU(4):40===t?a.ccFON():41===t?a.ccRDC():42===t?a.ccTR():43===t?a.ccRTD():44===t?a.ccEDM():45===t?a.ccCR():46===t?a.ccENM():47===t&&a.ccEOC():a.ccTO(t-32),_n(e,t,r),this.currentChannel=n,!0}parseMidrow(e,t){let r=0;if((17===e||25===e)&&t>=32&&t<=47){if(r=17===e?1:2,r!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;const i=this.channels[r];return!!i&&(i.ccMIDROW(t),this.logger.log(3,"MIDROW ("+un([e,t])+")"),!0)}return!1}parsePAC(e,t){let r;const i=this.cmdHistory,s=(e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127,n=(16===e||24===e)&&t>=64&&t<=95;if(!s&&!n)return!1;if(En(e,t,i))return _n(null,null,i),!0;const a=e<=23?1:2;r=t>=64&&t<=95?1===a?an[e]:ln[e]:1===a?on[e]:dn[e];const o=this.channels[a];return!!o&&(o.setPAC(this.interpretPAC(r,t)),_n(e,t,i),this.currentChannel=a,!0)}interpretPAC(e,t){let r;const i={color:null,italics:!1,indent:null,underline:!1,row:e};return r=t>95?t-96:t-64,i.underline=1===(1&r),r<=13?i.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(i.italics=!0,i.color="white"):i.indent=4*Math.floor((r-16)/2),i}parseChars(e,t){let r,i=null,s=null;if(e>=25?(r=2,s=e-8):(r=1,s=e),s>=17&&s<=19){let e;e=17===s?t+80:18===s?t+112:t+144,this.logger.log(2,"Special char '"+rn(e)+"' in channel "+r),i=[e]}else e>=32&&e<=127&&(i=0===t?[e]:[e,t]);if(i){const r=un(i);this.logger.log(3,"Char codes = "+r.join(",")),_n(e,t,this.cmdHistory)}return i}parseBackgroundAttributes(e,t){const r=(16===e||24===e)&&t>=32&&t<=47,i=(23===e||31===e)&&t>=45&&t<=47;if(!r&&!i)return!1;let s;const n={};16===e||24===e?(s=Math.floor((t-32)/2),n.background=hn[s],t%2===1&&(n.background=n.background+"_semi")):45===t?n.background="transparent":(n.foreground="black",47===t&&(n.underline=!0));const a=e<=23?1:2,o=this.channels[a];return o.setBkgData(n),_n(e,t,this.cmdHistory),!0}reset(){for(let e=0;e<Object.keys(this.channels).length;e++){const t=this.channels[e];t&&t.reset()}this.cmdHistory=bn()}cueSplitAtTime(e){for(let t=0;t<this.channels.length;t++){const r=this.channels[t];r&&r.cueSplitAtTime(e)}}}function _n(e,t,r){r.a=e,r.b=t}function En(e,t,r){return r.a===e&&r.b===t}function bn(){return{a:null,b:null}}class Tn{constructor(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}dispatchCue(){null!==this.startTime&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(e,t,r){(null===this.startTime||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}var Sn=function(){if("undefined"!==typeof self&&self.VTTCue)return self.VTTCue;const e=["","lr","rl"],t=["start","middle","end","left","right"];function r(e,t){if("string"!==typeof t)return!1;if(!Array.isArray(e))return!1;const r=t.toLowerCase();return!!~e.indexOf(r)&&r}function i(t){return r(e,t)}function s(e){return r(t,e)}function n(e,...t){let r=1;for(;r<arguments.length;r++){const t=arguments[r];for(const r in t)e[r]=t[r]}return e}function a(e,t,r){const a=this,o={enumerable:!0};a.hasBeenReset=!1;let l="",d=!1,h=e,c=t,u=r,f=null,p="",m=!0,g="auto",y="start",v=50,_="middle",E=50,b="middle";Object.defineProperty(a,"id",n({},o,{get:function(){return l},set:function(e){l=""+e}})),Object.defineProperty(a,"pauseOnExit",n({},o,{get:function(){return d},set:function(e){d=!!e}})),Object.defineProperty(a,"startTime",n({},o,{get:function(){return h},set:function(e){if("number"!==typeof e)throw new TypeError("Start time must be set to a number.");h=e,this.hasBeenReset=!0}})),Object.defineProperty(a,"endTime",n({},o,{get:function(){return c},set:function(e){if("number"!==typeof e)throw new TypeError("End time must be set to a number.");c=e,this.hasBeenReset=!0}})),Object.defineProperty(a,"text",n({},o,{get:function(){return u},set:function(e){u=""+e,this.hasBeenReset=!0}})),Object.defineProperty(a,"region",n({},o,{get:function(){return f},set:function(e){f=e,this.hasBeenReset=!0}})),Object.defineProperty(a,"vertical",n({},o,{get:function(){return p},set:function(e){const t=i(e);if(!1===t)throw new SyntaxError("An invalid or illegal string was specified.");p=t,this.hasBeenReset=!0}})),Object.defineProperty(a,"snapToLines",n({},o,{get:function(){return m},set:function(e){m=!!e,this.hasBeenReset=!0}})),Object.defineProperty(a,"line",n({},o,{get:function(){return g},set:function(e){if("number"!==typeof e&&"auto"!==e)throw new SyntaxError("An invalid number or illegal string was specified.");g=e,this.hasBeenReset=!0}})),Object.defineProperty(a,"lineAlign",n({},o,{get:function(){return y},set:function(e){const t=s(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");y=t,this.hasBeenReset=!0}})),Object.defineProperty(a,"position",n({},o,{get:function(){return v},set:function(e){if(e<0||e>100)throw new Error("Position must be between 0 and 100.");v=e,this.hasBeenReset=!0}})),Object.defineProperty(a,"positionAlign",n({},o,{get:function(){return _},set:function(e){const t=s(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");_=t,this.hasBeenReset=!0}})),Object.defineProperty(a,"size",n({},o,{get:function(){return E},set:function(e){if(e<0||e>100)throw new Error("Size must be between 0 and 100.");E=e,this.hasBeenReset=!0}})),Object.defineProperty(a,"align",n({},o,{get:function(){return b},set:function(e){const t=s(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");b=t,this.hasBeenReset=!0}})),a.displayState=void 0}return a.prototype.getCueAsHTML=function(){const e=self.WebVTT;return e.convertCueToDOMTree(self,this.text)},a}();class Ln{decode(e,t){if(!e)return"";if("string"!==typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}function An(e){function t(e,t,r,i){return 3600*(0|e)+60*(0|t)+(0|r)+parseFloat(i||0)}const r=e.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return r?parseFloat(r[2])>59?t(r[2],r[3],0,r[4]):t(r[1],r[2],r[3],r[4]):null}class wn{constructor(){this.values=Object.create(null)}set(e,t){this.get(e)||""===t||(this.values[e]=t)}get(e,t,r){return r?this.has(e)?this.values[e]:t[r]:this.has(e)?this.values[e]:t}has(e){return e in this.values}alt(e,t,r){for(let i=0;i<r.length;++i)if(t===r[i]){this.set(e,t);break}}integer(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))}percent(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){const r=parseFloat(t);if(r>=0&&r<=100)return this.set(e,r),!0}return!1}}function Rn(e,t,r,i){const s=i?e.split(i):[e];for(const n in s){if("string"!==typeof s[n])continue;const e=s[n].split(r);if(2!==e.length)continue;const i=e[0],a=e[1];t(i,a)}}const kn=new Sn(0,0,""),In="middle"===kn.align?"middle":"center";function Dn(e,t,r){const i=e;function s(){const t=An(e);if(null===t)throw new Error("Malformed timestamp: "+i);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function n(e,t){const i=new wn;Rn(e,(function(e,t){let s;switch(e){case"region":for(let s=r.length-1;s>=0;s--)if(r[s].id===t){i.set(e,r[s].region);break}break;case"vertical":i.alt(e,t,["rl","lr"]);break;case"line":s=t.split(","),i.integer(e,s[0]),i.percent(e,s[0])&&i.set("snapToLines",!1),i.alt(e,s[0],["auto"]),2===s.length&&i.alt("lineAlign",s[1],["start",In,"end"]);break;case"position":s=t.split(","),i.percent(e,s[0]),2===s.length&&i.alt("positionAlign",s[1],["start",In,"end","line-left","line-right","auto"]);break;case"size":i.percent(e,t);break;case"align":i.alt(e,t,["start",In,"end","left","right"]);break}}),/:/,/\s/),t.region=i.get("region",null),t.vertical=i.get("vertical","");let s=i.get("line","auto");"auto"===s&&-1===kn.line&&(s=-1),t.line=s,t.lineAlign=i.get("lineAlign","start"),t.snapToLines=i.get("snapToLines",!0),t.size=i.get("size",100),t.align=i.get("align",In);let n=i.get("position","auto");"auto"===n&&50===kn.position&&(n="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=n}function a(){e=e.replace(/^\s+/,"")}if(a(),t.startTime=s(),a(),"--\x3e"!==e.slice(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+i);e=e.slice(3),a(),t.endTime=s(),a(),n(e,t)}function xn(e){return e.replace(/<br(?: \/)?>/gi,"\n")}class Cn{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new Ln,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(e){const t=this;function r(){let e=t.buffer,r=0;e=xn(e);while(r<e.length&&"\r"!==e[r]&&"\n"!==e[r])++r;const i=e.slice(0,r);return"\r"===e[r]&&++r,"\n"===e[r]&&++r,t.buffer=e.slice(r),i}function i(e){Rn(e,(function(e,t){}),/:/)}e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));try{let e="";if("INITIAL"===t.state){if(!/\r\n|\n/.test(t.buffer))return this;e=r();const i=e.match(/^()?WEBVTT([ \t].*)?$/);if(null==i||!i[0])throw new Error("Malformed WebVTT signature.");t.state="HEADER"}let n=!1;while(t.buffer){if(!/\r\n|\n/.test(t.buffer))return this;switch(n?n=!1:e=r(),t.state){case"HEADER":/:/.test(e)?i(e):e||(t.state="ID");continue;case"NOTE":e||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(e)){t.state="NOTE";break}if(!e)continue;if(t.cue=new Sn(0,0,""),t.state="CUE",-1===e.indexOf("--\x3e")){t.cue.id=e;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{Dn(e,t.cue,t.regionList)}catch(s){t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":{const r=-1!==e.indexOf("--\x3e");if(!e||r&&(n=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(null===t.cue)continue;t.cue.text&&(t.cue.text+="\n"),t.cue.text+=e}continue;case"BADCUE":e||(t.state="ID")}}}catch(s){"CUETEXT"===t.state&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state="INITIAL"===t.state?"BADWEBVTT":"BADCUE"}return this}flush(){const e=this;try{if((e.cue||"HEADER"===e.state)&&(e.buffer+="\n\n",e.parse()),"INITIAL"===e.state||"BADWEBVTT"===e.state)throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this}}const Pn=/\r\n|\n\r|\n|\r/g,On=function(e,t,r=0){return e.slice(r,r+t.length)===t},Mn=function(e){let t=parseInt(e.slice(-3));const r=parseInt(e.slice(-6,-4)),i=parseInt(e.slice(-9,-7)),s=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!u(t)||!u(r)||!u(i)||!u(s))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+e);return t+=1e3*r,t+=6e4*i,t+=36e5*s,t},Fn=function(e){let t=5381,r=e.length;while(r)t=33*t^e.charCodeAt(--r);return(t>>>0).toString()};function Nn(e,t,r){return Fn(e.toString())+Fn(t.toString())+Fn(r)}const Un=function(e,t,r){let i=e[t],s=e[i.prevCC];if(!s||!s.new&&i.new)return e.ccOffset=e.presentationOffset=i.start,void(i.new=!1);while(null!=(n=s)&&n.new){var n;e.ccOffset+=i.start-s.start,i.new=!1,i=s,s=e[i.prevCC]}e.presentationOffset=r};function Bn(e,t,r,i,s,n,a){const o=new Cn,l=ue(new Uint8Array(e)).trim().replace(Pn,"\n").split("\n"),d=[],h=t?es(t.baseTime,t.timescale):0;let c,u="00:00.000",f=0,p=0,m=!0;o.oncue=function(e){const n=r[i];let a=r.ccOffset;const o=(f-h)/9e4;if(null!=n&&n.new&&(void 0!==p?a=r.ccOffset=n.start:Un(r,i,o)),o){if(!t)return void(c=new Error("Missing initPTS for VTT MPEGTS"));a=o-r.presentationOffset}const l=e.endTime-e.startTime,u=ls(9e4*(e.startTime+a-p),9e4*s)/9e4;e.startTime=Math.max(u,0),e.endTime=Math.max(u+l,0);const m=e.text.trim();e.text=decodeURIComponent(encodeURIComponent(m)),e.id||(e.id=Nn(e.startTime,e.endTime,m)),e.endTime>0&&d.push(e)},o.onparsingerror=function(e){c=e},o.onflush=function(){c?a(c):n(d)},l.forEach(e=>{if(m){if(On(e,"X-TIMESTAMP-MAP=")){m=!1,e.slice(16).split(",").forEach(e=>{On(e,"LOCAL:")?u=e.slice(6):On(e,"MPEGTS:")&&(f=parseInt(e.slice(7)))});try{p=Mn(u)/1e3}catch(t){c=t}return}""===e&&(m=!1)}o.parse(e+"\n")}),o.flush()}const $n="stpp.ttml.im1t",Gn=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,jn=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,Kn={left:"start",center:"center",right:"end",start:"start",end:"end"};function Vn(e,t,r,i){const s=Le(new Uint8Array(e),["mdat"]);if(0===s.length)return void i(new Error("Could not parse IMSC1 mdat"));const n=s.map(e=>ue(e)),a=Zi(t.baseTime,1,t.timescale);try{n.forEach(e=>r(Hn(e,a)))}catch(o){i(o)}}function Hn(e,t){const r=new DOMParser,i=r.parseFromString(e,"text/xml"),s=i.getElementsByTagName("tt")[0];if(!s)throw new Error("Invalid ttml");const n={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},a=Object.keys(n).reduce((e,t)=>(e[t]=s.getAttribute("ttp:"+t)||n[t],e),{}),o="preserve"!==s.getAttribute("xml:space"),l=zn(Yn(s,"styling","style")),h=zn(Yn(s,"layout","region")),c=Yn(s,"body","[begin]");return[].map.call(c,e=>{const r=Wn(e,o);if(!r||!e.hasAttribute("begin"))return null;const i=Zn(e.getAttribute("begin"),a),s=Zn(e.getAttribute("dur"),a);let n=Zn(e.getAttribute("end"),a);if(null===i)throw Qn(e);if(null===n){if(null===s)throw Qn(e);n=i+s}const c=new Sn(i-t,n-t,r);c.id=Nn(c.startTime,c.endTime,c.text);const u=h[e.getAttribute("region")],f=l[e.getAttribute("style")],p=qn(u,f,l),{textAlign:m}=p;if(m){const e=Kn[m];e&&(c.lineAlign=e),c.align=m}return d(c,p),c}).filter(e=>null!==e)}function Yn(e,t,r){const i=e.getElementsByTagName(t)[0];return i?[].slice.call(i.querySelectorAll(r)):[]}function zn(e){return e.reduce((e,t)=>{const r=t.getAttribute("xml:id");return r&&(e[r]=t),e},{})}function Wn(e,t){return[].slice.call(e.childNodes).reduce((e,r,i)=>{var s;return"br"===r.nodeName&&i?e+"\n":null!=(s=r.childNodes)&&s.length?Wn(r,t):t?e+r.textContent.trim().replace(/\s+/g," "):e+r.textContent},"")}function qn(e,t,r){const i="http://www.w3.org/ns/ttml#styling";let s=null;const n=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],a=null!=e&&e.hasAttribute("style")?e.getAttribute("style"):null;return a&&r.hasOwnProperty(a)&&(s=r[a]),n.reduce((r,n)=>{const a=Xn(t,i,n)||Xn(e,i,n)||Xn(s,i,n);return a&&(r[n]=a),r},{})}function Xn(e,t,r){return e&&e.hasAttributeNS(t,r)?e.getAttributeNS(t,r):null}function Qn(e){return new Error("Could not parse ttml timestamp "+e)}function Zn(e,t){if(!e)return null;let r=An(e);return null===r&&(Gn.test(e)?r=Jn(e,t):jn.test(e)&&(r=ea(e,t))),r}function Jn(e,t){const r=Gn.exec(e),i=(0|r[4])+(0|r[5])/t.subFrameRate;return 3600*(0|r[1])+60*(0|r[2])+(0|r[3])+i/t.frameRate}function ea(e,t){const r=jn.exec(e),i=Number(r[1]),s=r[2];switch(s){case"h":return 3600*i;case"m":return 60*i;case"ms":return 1e3*i;case"f":return i/t.frameRate;case"t":return i/t.tickRate}return i}class ta{constructor(e){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=sa(),this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){const e=new Tn(this,"textTrack1"),t=new Tn(this,"textTrack2"),r=new Tn(this,"textTrack3"),i=new Tn(this,"textTrack4");this.cea608Parser1=new vn(1,e,t),this.cea608Parser2=new vn(3,r,i)}e.on(f.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(f.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(f.MANIFEST_LOADING,this.onManifestLoading,this),e.on(f.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(f.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(f.FRAG_LOADING,this.onFragLoading,this),e.on(f.FRAG_LOADED,this.onFragLoaded,this),e.on(f.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(f.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(f.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(f.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(f.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:e}=this;e.off(f.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(f.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(f.MANIFEST_LOADING,this.onManifestLoading,this),e.off(f.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(f.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(f.FRAG_LOADING,this.onFragLoading,this),e.off(f.FRAG_LOADED,this.onFragLoaded,this),e.off(f.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(f.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(f.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(f.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(f.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null}addCues(e,t,r,i,s){let n=!1;for(let a=s.length;a--;){const e=s[a],i=ia(e[0],e[1],t,r);if(i>=0&&(e[0]=Math.min(e[0],t),e[1]=Math.max(e[1],r),n=!0,i/(r-t)>.5))return}if(n||s.push([t,r]),this.config.renderTextTracksNatively){const s=this.captionsTracks[e];this.Cues.newCue(s,t,r,i)}else{const s=this.Cues.newCue(null,t,r,i);this.hls.trigger(f.CUES_PARSED,{type:"captions",cues:s,track:e})}}onInitPtsFound(e,{frag:t,id:r,initPTS:i,timescale:s}){const{unparsedVttFrags:n}=this;"main"===r&&(this.initPTS[t.cc]={baseTime:i,timescale:s}),n.length&&(this.unparsedVttFrags=[],n.forEach(e=>{this.onFragLoaded(f.FRAG_LOADED,e)}))}getExistingTrack(e){const{media:t}=this;if(t)for(let r=0;r<t.textTracks.length;r++){const i=t.textTracks[r];if(i[e])return i}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}createNativeTrack(e){if(this.captionsTracks[e])return;const{captionsProperties:t,captionsTracks:r,media:i}=this,{label:s,languageCode:n}=t[e],a=this.getExistingTrack(e);if(a)r[e]=a,At(r[e]),St(r[e],i);else{const t=this.createTextTrack("captions",s,n);t&&(t[e]=!0,r[e]=t)}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;const t=this.captionsProperties[e];if(!t)return;const r=t.label,i={_id:e,label:r,kind:"captions",default:!!t.media&&!!t.media.default,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=i,this.hls.trigger(f.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[i]})}createTextTrack(e,t,r){const i=this.media;if(i)return i.addTextTrack(e,t,r)}onMediaAttaching(e,t){this.media=t.media,this._cleanTracks()}onMediaDetaching(){const{captionsTracks:e}=this;Object.keys(e).forEach(t=>{At(e[t]),delete e[t]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=sa(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}_cleanTracks(){const{media:e}=this;if(!e)return;const t=e.textTracks;if(t)for(let r=0;r<t.length;r++)At(t[r])}onSubtitleTracksUpdated(e,t){const r=t.subtitleTracks||[],i=r.some(e=>e.textCodec===$n);if(this.config.enableWebVTT||i&&this.config.enableIMSC1){const e=Vs(this.tracks,r);if(e)return void(this.tracks=r);if(this.textTracks=[],this.tracks=r,this.config.renderTextTracksNatively){const e=this.media?this.media.textTracks:null;this.tracks.forEach((t,r)=>{let i;if(e&&r<e.length){let r=null;for(let i=0;i<e.length;i++)if(ra(e[i],t)){r=e[i];break}r&&(i=r)}if(i)At(i);else{const e=this._captionsOrSubtitlesFromCharacteristics(t);i=this.createTextTrack(e,t.name,t.lang),i&&(i.mode="disabled")}i&&(i.groupId=t.groupId,this.textTracks.push(i))})}else if(this.tracks.length){const e=this.tracks.map(e=>({label:e.name,kind:e.type.toLowerCase(),default:e.default,subtitleTrack:e}));this.hls.trigger(f.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:e})}}}_captionsOrSubtitlesFromCharacteristics(e){if(e.attrs.CHARACTERISTICS){const t=/transcribes-spoken-dialog/gi.test(e.attrs.CHARACTERISTICS),r=/describes-music-and-sound/gi.test(e.attrs.CHARACTERISTICS);if(t&&r)return"captions"}return"subtitles"}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(e=>{const t=/(?:CC|SERVICE)([1-4])/.exec(e.instreamId);if(!t)return;const r="textTrack"+t[1],i=this.captionsProperties[r];i&&(i.label=e.name,e.lang&&(i.languageCode=e.lang),i.media=e)})}closedCaptionsForLevel(e){const t=this.hls.levels[e.level];return null==t?void 0:t.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){const{cea608Parser1:r,cea608Parser2:i,lastSn:s,lastPartIndex:n}=this;if(this.enabled&&r&&i&&t.frag.type===_t.MAIN){var a,o;const e=t.frag.sn,l=null!=(a=null==t||null==(o=t.part)?void 0:o.index)?a:-1;e===s+1||e===s&&l===n+1||(r.reset(),i.reset()),this.lastSn=e,this.lastPartIndex=l}}onFragLoaded(e,t){const{frag:r,payload:i}=t;if(r.type===_t.SUBTITLE)if(i.byteLength){const e=r.decryptdata,s="stats"in t;if(null==e||!e.encrypted||s){const e=this.tracks[r.level],s=this.vttCCs;s[r.cc]||(s[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),e&&e.textCodec===$n?this._parseIMSC1(r,i):this._parseVTTs(t)}}else this.hls.trigger(f.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){const r=this.hls;Vn(t,this.initPTS[e.cc],t=>{this._appendCues(t,e.level),r.trigger(f.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},t=>{T.log("Failed to parse IMSC1: "+t),r.trigger(f.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:t})})}_parseVTTs(e){var t;const{frag:r,payload:i}=e,{initPTS:s,unparsedVttFrags:n}=this,a=s.length-1;if(!s[r.cc]&&-1===a)return void n.push(e);const o=this.hls,l=null!=(t=r.initSegment)&&t.data?Oe(r.initSegment.data,new Uint8Array(i)):i;Bn(l,this.initPTS[r.cc],this.vttCCs,r.cc,r.start,e=>{this._appendCues(e,r.level),o.trigger(f.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:r})},t=>{const s="Missing initPTS for VTT MPEGTS"===t.message;s?n.push(e):this._fallbackToIMSC1(r,i),T.log("Failed to parse VTT cue: "+t),s&&a>r.cc||o.trigger(f.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:t})})}_fallbackToIMSC1(e,t){const r=this.tracks[e.level];r.textCodec||Vn(t,this.initPTS[e.cc],()=>{r.textCodec=$n,this._parseIMSC1(e,t)},()=>{r.textCodec="wvtt"})}_appendCues(e,t){const r=this.hls;if(this.config.renderTextTracksNatively){const r=this.textTracks[t];if(!r||"disabled"===r.mode)return;e.forEach(e=>Lt(r,e))}else{const i=this.tracks[t];if(!i)return;const s=i.default?"default":"subtitles"+t;r.trigger(f.CUES_PARSED,{type:"subtitles",cues:e,track:s})}}onFragDecrypted(e,t){const{frag:r}=t;r.type===_t.SUBTITLE&&this.onFragLoaded(f.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){const{cea608Parser1:r,cea608Parser2:i}=this;if(!this.enabled||!r||!i)return;const{frag:s,samples:n}=t;if(s.type!==_t.MAIN||"NONE"!==this.closedCaptionsForLevel(s))for(let a=0;a<n.length;a++){const e=n[a].bytes;if(e){const t=this.extractCea608Data(e);r.addData(n[a].pts,t[0]),i.addData(n[a].pts,t[1])}}}onBufferFlushing(e,{startOffset:t,endOffset:r,endOffsetSubtitles:i,type:s}){const{media:n}=this;if(n&&!(n.currentTime<r)){if(!s||"video"===s){const{captionsTracks:e}=this;Object.keys(e).forEach(i=>wt(e[i],t,r))}if(this.config.renderTextTracksNatively&&0===t&&void 0!==i){const{textTracks:e}=this;Object.keys(e).forEach(r=>wt(e[r],t,i))}}}extractCea608Data(e){const t=[[],[]],r=31&e[0];let i=2;for(let s=0;s<r;s++){const r=e[i++],s=127&e[i++],n=127&e[i++];if(0===s&&0===n)continue;const a=0!==(4&r);if(a){const e=3&r;0!==e&&1!==e||(t[e].push(s),t[e].push(n))}}return t}}function ra(e,t){return!!e&&e.label===t.name&&!(e.textTrack1||e.textTrack2)}function ia(e,t,r,i){return Math.min(t,i)-Math.max(e,r)}function sa(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}class na{constructor(e){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(e){this.streamController=e}destroy(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){const{hls:e}=this;e.on(f.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(f.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(f.MANIFEST_PARSED,this.onManifestParsed,this),e.on(f.BUFFER_CODECS,this.onBufferCodecs,this),e.on(f.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:e}=this;e.off(f.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(f.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(f.MANIFEST_PARSED,this.onManifestParsed,this),e.off(f.BUFFER_CODECS,this.onBufferCodecs,this),e.off(f.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(e,t){const r=this.hls.levels[t.droppedLevel];this.isLevelAllowed(r)&&this.restrictedLevels.push({bitrate:r.bitrate,height:r.height,width:r.width})}onMediaAttaching(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null}onManifestParsed(e,t){const r=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,r.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onBufferCodecs(e,t){const r=this.hls;r.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onMediaDetaching(){this.stopCapping()}detectPlayerSize(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){const e=this.hls.levels;if(e.length){const t=this.hls;t.autoLevelCapping=this.getMaxLevel(e.length-1),t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}}getMaxLevel(e){const t=this.hls.levels;if(!t.length)return-1;const r=t.filter((t,r)=>this.isLevelAllowed(t)&&r<=e);return this.clientRect=null,na.getMaxLevelByMediaSize(r,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}stopCapping(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}getDimensions(){if(this.clientRect)return this.clientRect;const e=this.media,t={width:0,height:0};if(e){const r=e.getBoundingClientRect();t.width=r.width,t.height=r.height,t.width||t.height||(t.width=r.right-r.left||e.width||0,t.height=r.bottom-r.top||e.height||0)}return this.clientRect=t,t}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch(t){}return e}isLevelAllowed(e){const t=this.restrictedLevels;return!t.some(t=>e.bitrate===t.bitrate&&e.width===t.width&&e.height===t.height)}static getMaxLevelByMediaSize(e,t,r){if(null==e||!e.length)return-1;const i=(e,t)=>!t||(e.width!==t.width||e.height!==t.height);let s=e.length-1;for(let n=0;n<e.length;n+=1){const a=e[n];if((a.width>=t||a.height>=r)&&i(a,e[n+1])){s=n;break}}return s}}class aa{constructor(e){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=e,this.registerListeners()}setStreamController(e){this.streamController=e}registerListeners(){this.hls.on(f.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(f.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){const r=this.hls.config;if(r.capLevelOnFPSDrop){const e=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=e,e&&"function"===typeof e.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}}checkFPS(e,t,r){const i=performance.now();if(t){if(this.lastTime){const e=i-this.lastTime,s=r-this.lastDroppedFrames,n=t-this.lastDecodedFrames,a=1e3*s/e,o=this.hls;if(o.trigger(f.FPS_DROP,{currentDropped:s,currentDecoded:n,totalDroppedFrames:r}),a>0&&s>o.config.fpsDroppedMonitoringThreshold*n){let e=o.currentLevel;T.warn("drop FPS ratio greater than max allowed value for currentLevel: "+e),e>0&&(-1===o.autoLevelCapping||o.autoLevelCapping>=e)&&(e-=1,o.trigger(f.FPS_DROP_LEVEL_CAPPING,{level:e,droppedLevel:o.currentLevel}),o.autoLevelCapping=e,this.streamController.nextLevelSwitch())}}this.lastTime=i,this.lastDroppedFrames=r,this.lastDecodedFrames=t}}checkFPSInterval(){const e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){const t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}}const oa="[eme]";class la{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=la.CDMCleanupPromise?[la.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=T.debug.bind(T,oa),this.log=T.log.bind(T,oa),this.warn=T.warn.bind(T,oa),this.error=T.error.bind(T,oa),this.hls=e,this.config=e.config,this.registerListeners()}destroy(){this.unregisterListeners(),this.onMediaDetached();const e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null,this.config=null}registerListeners(){this.hls.on(f.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(f.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(f.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(f.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(f.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(f.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(f.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(f.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(e){const{drmSystems:t,widevineLicenseUrl:r}=this.config,i=t[e];if(i)return i.licenseUrl;if(e===G.WIDEVINE&&r)return r;throw new Error(`no license server URL configured for key-system "${e}"`)}getServerCertificateUrl(e){const{drmSystems:t}=this.config,r=t[e];if(r)return r.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}attemptKeySystemAccess(e){const t=this.hls.levels,r=(e,t,r)=>!!e&&r.indexOf(e)===t,i=t.map(e=>e.audioCodec).filter(r),s=t.map(e=>e.videoCodec).filter(r);return i.length+s.length===0&&s.push("avc1.42e01e"),new Promise((t,r)=>{const n=e=>{const a=e.shift();this.getMediaKeysPromise(a,i,s).then(e=>t({keySystem:a,mediaKeys:e})).catch(t=>{e.length?n(e):r(t instanceof da?t:new da({type:p.KEY_SYSTEM_ERROR,details:m.KEY_SYSTEM_NO_ACCESS,error:t,fatal:!0},t.message))})};n(e)})}requestMediaKeySystemAccess(e,t){const{requestMediaKeySystemAccessFunc:r}=this.config;if("function"!==typeof r){let e="Configured requestMediaKeySystemAccess is not a function "+r;return null===W&&"http:"===self.location.protocol&&(e="navigator.requestMediaKeySystemAccess is not available over insecure protocol "+location.protocol),Promise.reject(new Error(e))}return r(e,t)}getMediaKeysPromise(e,t,r){const i=q(e,t,r,this.config.drmSystemOptions),s=this.keySystemAccessPromises[e];let n=null==s?void 0:s.keySystemAccess;if(!n){this.log(`Requesting encrypted media "${e}" key-system access with config: ${JSON.stringify(i)}`),n=this.requestMediaKeySystemAccess(e,i);const t=this.keySystemAccessPromises[e]={keySystemAccess:n};return n.catch(t=>{this.log(`Failed to obtain access to key-system "${e}": ${t}`)}),n.then(r=>{this.log(`Access for key-system "${r.keySystem}" obtained`);const i=this.fetchServerCertificate(e);return this.log(`Create media-keys for "${e}"`),t.mediaKeys=r.createMediaKeys().then(t=>(this.log(`Media-keys created for "${e}"`),i.then(r=>r?this.setMediaKeysServerCertificate(t,e,r):t))),t.mediaKeys.catch(t=>{this.error(`Failed to create media-keys for "${e}"}: ${t}`)}),t.mediaKeys})}return n.then(()=>s.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:r}){this.log(`Creating key-system session "${t}" keyId: ${me.hexDump(e.keyId||[])}`);const i=r.createSession(),s={decryptdata:e,keySystem:t,mediaKeys:r,mediaKeysSession:i,keyStatus:"status-pending"};return this.mediaKeySessions.push(s),s}renewKeySession(e){const t=e.decryptdata;if(t.pssh){const r=this.createMediaKeySessionContext(e),i=this.getKeyIdString(t),s="cenc";this.keyIdToKeySessionPromise[i]=this.generateRequestWithPreferredKeySession(r,s,t.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}getKeyIdString(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(null===e.keyId)throw new Error("keyId is null");return me.hexDump(e.keyId)}updateKeySession(e,t){var r;const i=e.mediaKeysSession;return this.log(`Updating key-session "${i.sessionId}" for keyID ${me.hexDump((null==(r=e.decryptdata)?void 0:r.keyId)||[])}\n } (data length: ${t?t.byteLength:t})`),i.update(t)}selectKeySystemFormat(e){const t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${e.sn} ${e.type}: ${e.level}) key formats ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}getKeyFormatPromise(e){return new Promise((t,r)=>{const i=z(this.config),s=e.map(K).filter(e=>!!e&&-1!==i.indexOf(e));return this.getKeySystemSelectionPromise(s).then(({keySystem:e})=>{const i=Y(e);i?t(i):r(new Error(`Unable to find format for key-system "${e}"`))}).catch(r)})}loadKey(e){const t=e.keyInfo.decryptdata,r=this.getKeyIdString(t),i=`(keyId: ${r} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log("Starting session for key "+i);let s=this.keyIdToKeySessionPromise[r];return s||(s=this.keyIdToKeySessionPromise[r]=this.getKeySystemForKeyPromise(t).then(({keySystem:r,mediaKeys:s})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${i}`),this.attemptSetMediaKeys(r,s).then(()=>{this.throwIfDestroyed();const e=this.createMediaKeySessionContext({keySystem:r,mediaKeys:s,decryptdata:t}),i="cenc";return this.generateRequestWithPreferredKeySession(e,i,t.pssh,"playlist-key")}))),s.catch(e=>this.handleError(e))),s}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e){this.hls&&(this.error(e.message),e instanceof da?this.hls.trigger(f.ERROR,e.data):this.hls.trigger(f.ERROR,{type:p.KEY_SYSTEM_ERROR,details:m.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))}getKeySystemForKeyPromise(e){const t=this.getKeyIdString(e),r=this.keyIdToKeySessionPromise[t];if(!r){const t=K(e.keyFormat),r=t?[t]:z(this.config);return this.attemptKeySystemAccess(r)}return r}getKeySystemSelectionPromise(e){if(e.length||(e=z(this.config)),0===e.length)throw new da({type:p.KEY_SYSTEM_ERROR,details:m.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},"Missing key-system license configuration options "+JSON.stringify({drmSystems:this.config.drmSystems}));return this.attemptKeySystemAccess(e)}_onMediaEncrypted(e){const{initDataType:t,initData:r}=e;if(this.debug(`"${e.type}" event: init data type: "${t}"`),null===r)return;let i,s;if("sinf"===t&&this.config.drmSystems[G.FAIRPLAY]){const e=_e(new Uint8Array(r));try{const t=F(JSON.parse(e).sinf),r=ke(new Uint8Array(t));if(!r)return;i=r.subarray(8,24),s=G.FAIRPLAY}catch(d){return void this.warn('Failed to parse sinf "encrypted" event message initData')}}else{const e=Ke(r);if(null===e)return;0===e.version&&e.systemId===V.WIDEVINE&&e.data&&(i=e.data.subarray(8,24)),s=H(e.systemId)}if(!s||!i)return;const n=me.hexDump(i),{keyIdToKeySessionPromise:a,mediaKeySessions:o}=this;let l=a[n];for(let h=0;h<o.length;h++){const e=o[h],s=e.decryptdata;if(s.pssh||!s.keyId)continue;const d=me.hexDump(s.keyId);if(n===d||-1!==s.uri.replace(/-/g,"").indexOf(n)){l=a[d],delete a[d],s.pssh=new Uint8Array(r),s.keyId=i,l=a[n]=l.then(()=>this.generateRequestWithPreferredKeySession(e,t,r,"encrypted-event-key-match"));break}}l||(l=a[n]=this.getKeySystemSelectionPromise([s]).then(({keySystem:e,mediaKeys:s})=>{var a;this.throwIfDestroyed();const o=new He("ISO-23001-7",n,null!=(a=Y(e))?a:"");return o.pssh=new Uint8Array(r),o.keyId=i,this.attemptSetMediaKeys(e,s).then(()=>{this.throwIfDestroyed();const i=this.createMediaKeySessionContext({decryptdata:o,keySystem:e,mediaKeys:s});return this.generateRequestWithPreferredKeySession(i,t,r,"encrypted-event-no-match")})})),l.catch(e=>this.handleError(e))}_onWaitingForKey(e){this.log(`"${e.type}" event`)}attemptSetMediaKeys(e,t){const r=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);const i=Promise.all(r).then(()=>{if(!this.media)throw new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(t)});return this.setMediaKeysQueue.push(i),i.then(()=>{this.log(`Media-keys set for "${e}"`),r.push(i),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(e=>-1===r.indexOf(e))})}generateRequestWithPreferredKeySession(e,t,r,i){var s,n;const a=null==(s=this.config.drmSystems)||null==(n=s[e.keySystem])?void 0:n.generateRequest;if(a)try{const i=a.call(this.hls,t,r,e);if(!i)throw new Error("Invalid response from configured generateRequest filter");t=i.initDataType,r=e.decryptdata.pssh=i.initData?new Uint8Array(i.initData):null}catch(c){var o;if(this.warn(c.message),null!=(o=this.hls)&&o.config.debug)throw c}if(null===r)return this.log(`Skipping key-session request for "${i}" (no initData)`),Promise.resolve(e);const l=this.getKeyIdString(e.decryptdata);this.log(`Generating key-session request for "${i}": ${l} (init data type: ${t} length: ${r?r.byteLength:null})`);const d=new ws;e.mediaKeysSession.onmessage=t=>{const r=e.mediaKeysSession;if(!r)return void d.emit("error",new Error("invalid state"));const{messageType:i,message:s}=t;this.log(`"${i}" message event for session "${r.sessionId}" message size: ${s.byteLength}`),"license-request"===i||"license-renewal"===i?this.renewLicense(e,s).catch(e=>{this.handleError(e),d.emit("error",e)}):"license-release"===i?e.keySystem===G.FAIRPLAY&&(this.updateKeySession(e,$("acknowledged")),this.removeSession(e)):this.warn(`unhandled media key message type "${i}"`)},e.mediaKeysSession.onkeystatuseschange=t=>{const r=e.mediaKeysSession;if(!r)return void d.emit("error",new Error("invalid state"));this.onKeyStatusChange(e);const i=e.keyStatus;d.emit("keyStatus",i),"expired"===i&&(this.warn(`${e.keySystem} expired for key ${l}`),this.renewKeySession(e))};const h=new Promise((e,t)=>{d.on("error",t),d.on("keyStatus",r=>{r.startsWith("usable")?e():"output-restricted"===r?t(new da({type:p.KEY_SYSTEM_ERROR,details:m.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):"internal-error"===r?t(new da({type:p.KEY_SYSTEM_ERROR,details:m.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${r}"`)):"expired"===r?t(new Error("key expired while generating request")):this.warn(`unhandled key status change "${r}"`)})});return e.mediaKeysSession.generateRequest(t,r).then(()=>{var t;this.log(`Request generated for key-session "${null==(t=e.mediaKeysSession)?void 0:t.sessionId}" keyId: ${l}`)}).catch(e=>{throw new da({type:p.KEY_SYSTEM_ERROR,details:m.KEY_SYSTEM_NO_SESSION,error:e,fatal:!1},"Error generating key-session request: "+e)}).then(()=>h).catch(t=>{throw d.removeAllListeners(),this.removeSession(e),t}).then(()=>(d.removeAllListeners(),e))}onKeyStatusChange(e){e.mediaKeysSession.keyStatuses.forEach((t,r)=>{this.log(`key status change "${t}" for keyStatuses keyId: ${me.hexDump("buffer"in r?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):new Uint8Array(r))} session keyId: ${me.hexDump(new Uint8Array(e.decryptdata.keyId||[]))} uri: ${e.decryptdata.uri}`),e.keyStatus=t})}fetchServerCertificate(e){const t=this.config,r=t.loader,i=new r(t),s=this.getServerCertificateUrl(e);return s?(this.log(`Fetching serverCertificate for "${e}"`),new Promise((r,n)=>{const a={responseType:"arraybuffer",url:s},l=t.certLoadPolicy.default,d={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},h={onSuccess:(e,t,i,s)=>{r(e.data)},onError:(t,r,i,l)=>{n(new da({type:p.KEY_SYSTEM_ERROR,details:m.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:i,response:o({url:a.url,data:void 0},t)},`"${e}" certificate request failed (${s}). Status: ${t.code} (${t.text})`))},onTimeout:(t,r,i)=>{n(new da({type:p.KEY_SYSTEM_ERROR,details:m.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:i,response:{url:a.url,data:void 0}},`"${e}" certificate request timed out (${s})`))},onAbort:(e,t,r)=>{n(new Error("aborted"))}};i.load(a,d,h)})):Promise.resolve()}setMediaKeysServerCertificate(e,t,r){return new Promise((i,s)=>{e.setServerCertificate(r).then(s=>{this.log(`setServerCertificate ${s?"success":"not supported by CDM"} (${null==r?void 0:r.byteLength}) on "${t}"`),i(e)}).catch(e=>{s(new da({type:p.KEY_SYSTEM_ERROR,details:m.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:e,fatal:!0},e.message))})})}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then(t=>this.updateKeySession(e,new Uint8Array(t)).catch(e=>{throw new da({type:p.KEY_SYSTEM_ERROR,details:m.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:e,fatal:!0},e.message)}))}setupLicenseXHR(e,t,r,i){const s=this.config.licenseXhrSetup;return s?Promise.resolve().then(()=>{if(!r.decryptdata)throw new Error("Key removed");return s.call(this.hls,e,t,r,i)}).catch(n=>{if(!r.decryptdata)throw n;return e.open("POST",t,!0),s.call(this.hls,e,t,r,i)}).then(r=>{e.readyState||e.open("POST",t,!0);const s=r||i;return{xhr:e,licenseChallenge:s}}):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:i}))}requestLicense(e,t){const r=this.config.keyLoadPolicy.default;return new Promise((i,s)=>{const n=this.getLicenseServerUrl(e.keySystem);this.log("Sending license request to URL: "+n);const a=new XMLHttpRequest;a.responseType="arraybuffer",a.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return s(new Error("invalid state"));if(4===a.readyState)if(200===a.status){this._requestLicenseFailureCount=0;let t=a.response;this.log("License received "+(t instanceof ArrayBuffer?t.byteLength:t));const r=this.config.licenseResponseCallback;if(r)try{t=r.call(this.hls,a,n,e)}catch(o){this.error(o)}i(t)}else{const o=r.errorRetry,l=o?o.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>l||a.status>=400&&a.status<500)s(new da({type:p.KEY_SYSTEM_ERROR,details:m.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:a,response:{url:n,data:void 0,code:a.status,text:a.statusText}},`License Request XHR failed (${n}). Status: ${a.status} (${a.statusText})`));else{const r=l-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${r} attempts left`),this.requestLicense(e,t).then(i,s)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=a,this.setupLicenseXHR(a,n,e,t).then(({xhr:e,licenseChallenge:t})=>{e.send(t)})})}onMediaAttached(e,t){if(!this.config.emeEnabled)return;const r=t.media;this.media=r,r.addEventListener("encrypted",this.onMediaEncrypted),r.addEventListener("waitingforkey",this.onWaitingForKey)}onMediaDetached(){const e=this.media,t=this.mediaKeySessions;e&&(e.removeEventListener("encrypted",this.onMediaEncrypted),e.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},He.clearKeyUriToKeyIdMap();const r=t.length;la.CDMCleanupPromise=Promise.all(t.map(e=>this.removeSession(e)).concat(null==e?void 0:e.setMediaKeys(null).catch(t=>{this.log(`Could not clear media keys: ${t}. media.src: ${null==e?void 0:e.src}`)}))).then(()=>{r&&(this.log("finished closing key sessions and clearing media keys"),t.length=0)}).catch(t=>{this.log(`Could not close sessions and clear media keys: ${t}. media.src: ${null==e?void 0:e.src}`)})}onManifestLoading(){this.keyFormatPromise=null}onManifestLoaded(e,{sessionKeys:t}){if(t&&this.config.emeEnabled&&!this.keyFormatPromise){const e=t.reduce((e,t)=>(-1===e.indexOf(t.keyFormat)&&e.push(t.keyFormat),e),[]);this.log("Selecting key-system from session-keys "+e.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(e)}}removeSession(e){const{mediaKeysSession:t,licenseXhr:r}=e;if(t){this.log("Remove licenses and keys and close session "+t.sessionId),t.onmessage=null,t.onkeystatuseschange=null,r&&r.readyState!==XMLHttpRequest.DONE&&r.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;const i=this.mediaKeySessions.indexOf(e);return i>-1&&this.mediaKeySessions.splice(i,1),t.remove().catch(e=>{this.log("Could not remove session: "+e)}).then(()=>t.close()).catch(e=>{this.log("Could not close session: "+e)})}}}la.CDMCleanupPromise=void 0;class da extends Error{constructor(e,t){super(t),this.data=void 0,e.error||(e.error=new Error(t)),this.data=e,e.err=e.error}}const ha=1;var ca={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"};const ua="h";class fa{constructor(e){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=e=>{try{this.apply(e,{ot:ca.MANIFEST,su:!this.initialized})}catch(t){T.warn("Could not generate manifest CMCD data.",t)}},this.applyFragmentData=e=>{try{const t=e.frag,r=this.hls.levels[t.level],i=this.getObjectType(t),s={d:1e3*t.duration,ot:i};i!==ca.VIDEO&&i!==ca.AUDIO&&i!=ca.MUXED||(s.br=r.bitrate/1e3,s.tb=this.getTopBandwidth(i)/1e3,s.bl=this.getBufferLength(i)),this.apply(e,s)}catch(t){T.warn("Could not generate segment CMCD data.",t)}},this.hls=e;const t=this.config=e.config,{cmcd:r}=t;null!=r&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=r.sessionId||fa.uuid(),this.cid=r.contentId,this.useHeaders=!0===r.useHeaders,this.registerListeners())}registerListeners(){const e=this.hls;e.on(f.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(f.MEDIA_DETACHED,this.onMediaDetached,this),e.on(f.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const e=this.hls;e.off(f.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(f.MEDIA_DETACHED,this.onMediaDetached,this),e.off(f.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(e,t){var r,i;this.audioBuffer=null==(r=t.tracks.audio)?void 0:r.buffer,this.videoBuffer=null==(i=t.tracks.video)?void 0:i.buffer}createData(){var e;return{v:ha,sf:ua,sid:this.sid,cid:this.cid,pr:null==(e=this.media)?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){d(t,this.createData());const r=t.ot===ca.INIT||t.ot===ca.VIDEO||t.ot===ca.MUXED;if(this.starved&&r&&(t.bs=!0,t.su=!0,this.starved=!1),null==t.su&&(t.su=this.buffering),this.useHeaders){const r=fa.toHeaders(t);if(!Object.keys(r).length)return;e.headers||(e.headers={}),d(e.headers,r)}else{const r=fa.toQuery(t);if(!r)return;e.url=fa.appendQueryToUri(e.url,r)}}getObjectType(e){const{type:t}=e;return"subtitle"===t?ca.TIMED_TEXT:"initSegment"===e.sn?ca.INIT:"audio"===t?ca.AUDIO:"main"===t?this.hls.audioTracks.length?ca.VIDEO:ca.MUXED:void 0}getTopBandwidth(e){let t,r=0;const i=this.hls;if(e===ca.AUDIO)t=i.audioTracks;else{const e=i.maxAutoLevel,r=e>-1?e+1:i.levels.length;t=i.levels.slice(0,r)}for(const s of t)s.bitrate>r&&(r=s.bitrate);return r>0?r:NaN}getBufferLength(e){const t=this.hls.media,r=e===ca.AUDIO?this.audioBuffer:this.videoBuffer;if(!r||!t)return NaN;const i=Or.bufferInfo(r,t.currentTime,this.config.maxBufferHole);return 1e3*i.len}createPlaylistLoader(){const{pLoader:e}=this.config,t=this.applyPlaylistData,r=e||this.config.loader;return class{constructor(e){this.loader=void 0,this.loader=new r(e)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(e,r,i){t(e),this.loader.load(e,r,i)}}}createFragmentLoader(){const{fLoader:e}=this.config,t=this.applyFragmentData,r=e||this.config.loader;return class{constructor(e){this.loader=void 0,this.loader=new r(e)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(e,r,i){t(e),this.loader.load(e,r,i)}}}static uuid(){const e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}static serialize(e){const t=[],r=e=>!Number.isNaN(e)&&null!=e&&""!==e&&!1!==e,i=e=>Math.round(e),s=e=>100*i(e/100),n=e=>encodeURIComponent(e),a={br:i,d:i,bl:s,dl:s,mtp:s,nor:n,rtp:s,tb:i},o=Object.keys(e||{}).sort();for(const l of o){let i=e[l];if(!r(i))continue;if("v"===l&&1===i)continue;if("pr"==l&&1===i)continue;const s=a[l];s&&(i=s(i));const n=typeof i;let o;o="ot"===l||"sf"===l||"st"===l?`${l}=${i}`:"boolean"===n?l:"number"===n?`${l}=${i}`:`${l}=${JSON.stringify(i)}`,t.push(o)}return t.join(",")}static toHeaders(e){const t=Object.keys(e),r={},i=["Object","Request","Session","Status"],s=[{},{},{},{}],n={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3};for(const a of t){const t=null!=n[a]?n[a]:1;s[t][a]=e[a]}for(let a=0;a<s.length;a++){const e=fa.serialize(s[a]);e&&(r["CMCD-"+i[a]]=e)}return r}static toQuery(e){return"CMCD="+encodeURIComponent(fa.serialize(e))}static appendQueryToUri(e,t){if(!t)return e;const r=e.includes("?")?"&":"?";return`${e}${r}${t}`}}const pa=3e5;class ma{constructor(e){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.log=T.log.bind(T,"[content-steering]:"),this.registerListeners()}registerListeners(){const e=this.hls;e.on(f.MANIFEST_LOADING,this.onManifestLoading,this),e.on(f.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(f.MANIFEST_PARSED,this.onManifestParsed,this),e.on(f.ERROR,this.onError,this)}unregisterListeners(){const e=this.hls;e&&(e.off(f.MANIFEST_LOADING,this.onManifestLoading,this),e.off(f.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(f.MANIFEST_PARSED,this.onManifestParsed,this),e.off(f.ERROR,this.onError,this))}startLoad(){if(this.started=!0,self.clearTimeout(this.reloadTimer),this.enabled&&this.uri)if(this.updated){const e=Math.max(1e3*this.timeToLoad-(performance.now()-this.updated),0);this.scheduleRefresh(this.uri,e)}else this.loadSteeringManifest(this.uri)}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),self.clearTimeout(this.reloadTimer)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(e){const t=this.levels;t&&(this.levels=t.filter(t=>t!==e))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(e,t){const{contentSteering:r}=t;null!==r&&(this.pathwayId=r.pathwayId,this.uri=r.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){const{errorAction:r}=t;if((null==r?void 0:r.action)===fr.SendAlternateToPenaltyBox&&r.flags===pr.MoveAllAlternatesMatchingHost){let e=this.pathwayPriority;const t=this.pathwayId;this.penalizedPathways[t]||(this.penalizedPathways[t]=performance.now()),!e&&this.levels&&(e=this.levels.reduce((e,t)=>(-1===e.indexOf(t.pathwayId)&&e.push(t.pathwayId),e),[])),e&&e.length>1&&(this.updatePathwayPriority(e),r.resolved=this.pathwayId!==t)}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(0===t.length){const r=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${r}"`),t=this.getLevelsForPathway(r),this.pathwayId=r}return t.length!==e.length?(this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t):e}getLevelsForPathway(e){return null===this.levels?[]:this.levels.filter(t=>e===t.pathwayId)}updatePathwayPriority(e){let t;this.pathwayPriority=e;const r=this.penalizedPathways,i=performance.now();Object.keys(r).forEach(e=>{i-r[e]>pa&&delete r[e]});for(let s=0;s<e.length;s++){const i=e[s];if(r[i])continue;if(i===this.pathwayId)return;const n=this.hls.nextLoadLevel,a=this.hls.levels[n];if(t=this.getLevelsForPathway(i),t.length>0){this.log(`Setting Pathway to "${i}"`),this.pathwayId=i,this.hls.trigger(f.LEVELS_UPDATED,{levels:t});const e=this.hls.levels[n];a&&e&&this.levels&&(e.attrs["STABLE-VARIANT-ID"]!==a.attrs["STABLE-VARIANT-ID"]&&e.bitrate!==a.bitrate&&this.log(`Unstable Pathways change from bitrate ${a.bitrate} to ${e.bitrate}`),this.hls.nextLoadLevel=n);break}}}clonePathways(e){const t=this.levels;if(!t)return;const r={},i={};e.forEach(e=>{const{ID:s,"BASE-ID":n,"URI-REPLACEMENT":a}=e;if(t.some(e=>e.pathwayId===s))return;const o=this.getLevelsForPathway(n).map(e=>{const t=d({},e);t.details=void 0,t.url=ya(e.uri,e.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",a);const n=new A(e.attrs);n["PATHWAY-ID"]=s;const o=n.AUDIO&&`${n.AUDIO}_clone_${s}`,l=n.SUBTITLES&&`${n.SUBTITLES}_clone_${s}`;o&&(r[n.AUDIO]=o,n.AUDIO=o),l&&(i[n.SUBTITLES]=l,n.SUBTITLES=l),t.attrs=n;const h=new Gt(t);return Er(h,"audio",o),Er(h,"text",l),h});t.push(...o),ga(this.audioTracks,r,a,s),ga(this.subtitleTracks,i,a,s)})}loadSteeringManifest(e){const t=this.hls.config,r=t.loader;let i;this.loader&&this.loader.destroy(),this.loader=new r(t);try{i=new self.URL(e)}catch(d){return this.enabled=!1,void this.log("Failed to parse Steering Manifest URI: "+e)}if("data:"!==i.protocol){const e=0|(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate);i.searchParams.set("_HLS_pathway",this.pathwayId),i.searchParams.set("_HLS_throughput",""+e)}const s={responseType:"json",url:i.href},n=t.steeringManifestLoadPolicy.default,a=n.errorRetry||n.timeoutRetry||{},o={loadPolicy:n,timeout:n.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},l={onSuccess:(e,t,r,s)=>{this.log(`Loaded steering manifest: "${i}"`);const n=e.data;if(1!==n.VERSION)return void this.log(`Steering VERSION ${n.VERSION} not supported!`);this.updated=performance.now(),this.timeToLoad=n.TTL;const{"RELOAD-URI":a,"PATHWAY-CLONES":o,"PATHWAY-PRIORITY":l}=n;if(a)try{this.uri=new self.URL(a,i).href}catch(d){return this.enabled=!1,void this.log("Failed to parse Steering Manifest RELOAD-URI: "+a)}this.scheduleRefresh(this.uri||r.url),o&&this.clonePathways(o),l&&this.updatePathwayPriority(l)},onError:(e,t,r,i)=>{if(this.log(`Error loading steering manifest: ${e.code} ${e.text} (${t.url})`),this.stopLoad(),410===e.code)return this.enabled=!1,void this.log(`Steering manifest ${t.url} no longer available`);let s=1e3*this.timeToLoad;if(429!==e.code)this.scheduleRefresh(this.uri||t.url,s);else{const e=this.loader;if("function"===typeof(null==e?void 0:e.getResponseHeader)){const t=e.getResponseHeader("Retry-After");t&&(s=1e3*parseFloat(t))}this.log(`Steering manifest ${t.url} rate limited`)}},onTimeout:(e,t,r)=>{this.log(`Timeout loading steering manifest (${t.url})`),this.scheduleRefresh(this.uri||t.url)}};this.log("Requesting steering manifest: "+i),this.loader.load(s,o,l)}scheduleRefresh(e,t=1e3*this.timeToLoad){self.clearTimeout(this.reloadTimer),this.reloadTimer=self.setTimeout(()=>{this.loadSteeringManifest(e)},t)}}function ga(e,t,r,i){e&&Object.keys(t).forEach(s=>{const n=e.filter(e=>e.groupId===s).map(e=>{const n=d({},e);return n.details=void 0,n.attrs=new A(n.attrs),n.url=n.attrs.URI=ya(e.url,e.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",r),n.groupId=n.attrs["GROUP-ID"]=t[s],n.attrs["PATHWAY-ID"]=i,n});e.push(...n)})}function ya(e,t,r,i){const{HOST:s,PARAMS:n,[r]:a}=i;let o;t&&(o=null==a?void 0:a[t],o&&(e=o));const l=new self.URL(e);return s&&!o&&(l.host=s),n&&Object.keys(n).sort().forEach(e=>{e&&l.searchParams.set(e,n[e])}),l.href}const va=/^age:\s*[\d.]+\s*$/im;class _a{constructor(e){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=e&&e.xhrSetup||null,this.stats=new I,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null}abortInternal(){const e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,4!==e.readyState&&(this.stats.aborted=!0,e.abort()))}abort(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(e,t,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=r,this.loadInternal()}loadInternal(){const{config:e,context:t}=this;if(!e)return;const r=this.loader=new self.XMLHttpRequest,i=this.stats;i.loading.first=0,i.loaded=0,i.aborted=!1;const s=this.xhrSetup;s?Promise.resolve().then(()=>{if(!this.stats.aborted)return s(r,t.url)}).catch(e=>(r.open("GET",t.url,!0),s(r,t.url))).then(()=>{this.stats.aborted||this.openAndSendXhr(r,t,e)}).catch(e=>{this.callbacks.onError({code:r.status,text:e.message},t,r,i)}):this.openAndSendXhr(r,t,e)}openAndSendXhr(e,t,r){e.readyState||e.open("GET",t.url,!0);const i=this.context.headers,{maxTimeToFirstByteMs:s,maxLoadTimeMs:n}=r.loadPolicy;if(i)for(const a in i)e.setRequestHeader(a,i[a]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),r.timeout=s&&u(s)?s:n,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),e.send()}readystatechange(){const{context:e,loader:t,stats:r}=this;if(!e||!t)return;const i=t.readyState,s=this.config;if(!r.aborted&&i>=2&&(0===r.loading.first&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),s.timeout!==s.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),s.timeout=s.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),s.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start)))),4===i)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;const i=t.status,n="text"!==t.responseType;if(i>=200&&i<300&&(n&&t.response||null!==t.responseText)){r.loading.end=Math.max(self.performance.now(),r.loading.first);const s=n?t.response:t.responseText,a="arraybuffer"===t.responseType?s.byteLength:s.length;if(r.loaded=r.total=a,r.bwEstimate=8e3*r.total/(r.loading.end-r.loading.first),!this.callbacks)return;const o=this.callbacks.onProgress;if(o&&o(r,e,s,t),!this.callbacks)return;const l={url:t.responseURL,data:s,code:i};this.callbacks.onSuccess(l,r,e,t)}else{const n=s.loadPolicy.errorRetry,a=r.retry;sr(n,a,!1,i)?this.retry(n):(T.error(`${i} while loading ${e.url}`),this.callbacks.onError({code:i,text:t.statusText},e,t,r))}}}loadtimeout(){var e;const t=null==(e=this.config)?void 0:e.loadPolicy.timeoutRetry,r=this.stats.retry;if(sr(t,r,!0))this.retry(t);else{T.warn("timeout while loading "+this.context.url);const e=this.callbacks;e&&(this.abortInternal(),e.onTimeout(this.stats,this.context,this.loader))}}retry(e){const{context:t,stats:r}=this;this.retryDelay=rr(e,r.retry),r.retry++,T.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${t.url}, retrying ${r.retry}/${e.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)}loadprogress(e){const t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}getCacheAge(){let e=null;if(this.loader&&va.test(this.loader.getAllResponseHeaders())){const t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}}function Ea(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(e){}return!1}const ba=/(\d+)-(\d+)\/(\d+)/;class Ta{constructor(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||wa,this.controller=new self.AbortController,this.stats=new I}destroy(){this.loader=this.callbacks=null,this.abortInternal()}abortInternal(){const e=this.response;null!=e&&e.ok||(this.stats.aborted=!0,this.controller.abort())}abort(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(e,t,r){const i=this.stats;if(i.loading.start)throw new Error("Loader can only be used once.");i.loading.start=self.performance.now();const s=Sa(e,this.controller.signal),n=r.onProgress,a="arraybuffer"===e.responseType,o=a?"byteLength":"length",{maxTimeToFirstByteMs:l,maxLoadTimeMs:d}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,s),self.clearTimeout(this.requestTimeout),t.timeout=l&&u(l)?l:d,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),r.onTimeout(i,e,this.response)},t.timeout),self.fetch(this.request).then(s=>{this.response=this.loader=s;const o=Math.max(self.performance.now(),i.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=d,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),r.onTimeout(i,e,this.response)},d-(o-i.loading.start)),!s.ok){const{status:e,statusText:t}=s;throw new Ra(t||"fetch, bad network response",e,s)}return i.loading.first=o,i.total=Aa(s.headers)||i.total,n&&u(t.highWaterMark)?this.loadProgressively(s,i,e,t.highWaterMark,n):a?s.arrayBuffer():"json"===e.responseType?s.json():s.text()}).then(s=>{const{response:a}=this;self.clearTimeout(this.requestTimeout),i.loading.end=Math.max(self.performance.now(),i.loading.first);const l=s[o];l&&(i.loaded=i.total=l);const d={url:a.url,data:s,code:a.status};n&&!u(t.highWaterMark)&&n(i,e,s,a),r.onSuccess(d,i,e,a)}).catch(t=>{if(self.clearTimeout(this.requestTimeout),i.aborted)return;const s=t&&t.code||0,n=t?t.message:null;r.onError({code:s,text:n},e,t?t.details:null,i)})}getCacheAge(){let e=null;if(this.response){const t=this.response.headers.get("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,t,r,i=0,s){const n=new Bs,a=e.body.getReader(),o=()=>a.read().then(a=>{if(a.done)return n.dataLength&&s(t,r,n.flush(),e),Promise.resolve(new ArrayBuffer(0));const l=a.value,d=l.length;return t.loaded+=d,d<i||n.dataLength?(n.push(l),n.dataLength>=i&&s(t,r,n.flush(),e)):s(t,r,l,e),o()}).catch(()=>Promise.reject());return o()}}function Sa(e,t){const r={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(d({},e.headers))};return e.rangeEnd&&r.headers.set("Range","bytes="+e.rangeStart+"-"+String(e.rangeEnd-1)),r}function La(e){const t=ba.exec(e);if(t)return parseInt(t[2])-parseInt(t[1])+1}function Aa(e){const t=e.get("Content-Range");if(t){const e=La(t);if(u(e))return e}const r=e.get("Content-Length");if(r)return parseInt(r)}function wa(e,t){return new self.Request(e.url,t)}class Ra extends Error{constructor(e,t,r){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=r}}const ka=/\s/,Ia={newCue(e,t,r,i){const s=[];let n,a,o,l,d;const h=self.VTTCue||self.TextTrackCue;for(let u=0;u<i.rows.length;u++)if(n=i.rows[u],o=!0,l=0,d="",!n.isEmpty()){var c;for(let e=0;e<n.chars.length;e++)ka.test(n.chars[e].uchar)&&o?l++:(d+=n.chars[e].uchar,o=!1);n.cueStartTime=t,t===r&&(r+=1e-4),l>=16?l--:l++;const i=xn(d.trim()),f=Nn(t,r,i);null!=e&&null!=(c=e.cues)&&c.getCueById(f)||(a=new h(t,r,i),a.id=f,a.line=u+1,a.align="left",a.position=10+Math.min(80,10*Math.floor(8*l/32)),s.push(a))}return e&&s.length&&(s.sort((e,t)=>"auto"===e.line||"auto"===t.line?0:e.line>8&&t.line>8?t.line-e.line:e.line-t.line),s.forEach(t=>Lt(e,t))),s}},Da={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},xa=o(o({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:6e7,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:_a,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:Us,bufferController:en,capLevelController:na,errorController:mr,fpsController:aa,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:W,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,certLoadPolicy:{default:Da},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},Ca()),{},{subtitleStreamController:zs,subtitleTrackController:qs,timelineController:ta,audioStreamController:js,audioTrackController:Ks,emeController:la,cmcdController:fa,contentSteeringController:ma});function Ca(){return{cueHandler:Ia,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function Pa(e,t){if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==t.liveMaxLatencyDurationCount&&(void 0===t.liveSyncDurationCount||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==t.liveMaxLatencyDuration&&(void 0===t.liveSyncDuration||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const r=Oa(e),i=["manifest","level","frag"],s=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return i.forEach(e=>{const i=("level"===e?"playlist":e)+"LoadPolicy",n=void 0===t[i],a=[];s.forEach(s=>{const o=`${e}Loading${s}`,l=t[o];if(void 0!==l&&n){a.push(o);const e=r[i].default;switch(t[i]={default:e},s){case"TimeOut":e.maxLoadTimeMs=l,e.maxTimeToFirstByteMs=l;break;case"MaxRetry":e.errorRetry.maxNumRetry=l,e.timeoutRetry.maxNumRetry=l;break;case"RetryDelay":e.errorRetry.retryDelayMs=l,e.timeoutRetry.retryDelayMs=l;break;case"MaxRetryTimeout":e.errorRetry.maxRetryDelayMs=l,e.timeoutRetry.maxRetryDelayMs=l;break}}}),a.length&&T.warn(`hls.js config: "${a.join('", "')}" setting(s) are deprecated, use "${i}": ${JSON.stringify(t[i])}`)}),o(o({},r),t)}function Oa(e){return e&&"object"===typeof e?Array.isArray(e)?e.map(Oa):Object.keys(e).reduce((t,r)=>(t[r]=Oa(e[r]),t),{}):e}function Ma(e){const t=e.loader;if(t!==Ta&&t!==_a)T.log("[config]: Custom loader detected, cannot enable progressive streaming"),e.progressive=!1;else{const t=Ea();t&&(e.loader=Ta,e.progressive=!0,e.enableSoftwareAES=!0,T.log("[config]: Progressive streaming enabled, using FetchLoader"))}}class Fa{static get version(){return"1.4.12"}static isSupported(){return ri()}static get Events(){return f}static get ErrorTypes(){return p}static get ErrorDetails(){return m}static get DefaultConfig(){return Fa.defaultConfig?Fa.defaultConfig:xa}static set DefaultConfig(e){Fa.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new ws,this._autoLevelCapping=void 0,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,b(e.debug||!1,"Hls instance");const t=this.config=Pa(Fa.DefaultConfig,e);this.userConfig=e,this._autoLevelCapping=-1,t.progressive&&Ma(t);const{abrController:r,bufferController:i,capLevelController:s,errorController:n,fpsController:a}=t,o=new n(this),l=this.abrController=new r(this),d=this.bufferController=new i(this),h=this.capLevelController=new s(this),c=new a(this),u=new Tt(this),p=new Mt(this),m=t.contentSteeringController,g=m?new m(this):null,y=this.levelController=new _r(this,g),v=new Sr(this),_=new xr(this.config),E=this.streamController=new Ms(this,v,_);h.setStreamController(E),c.setStreamController(E);const T=[u,y,E];g&&T.splice(1,0,g),this.networkControllers=T;const S=[l,d,h,c,p,v];this.audioTrackController=this.createController(t.audioTrackController,T);const L=t.audioStreamController;L&&T.push(new L(this,v,_)),this.subtitleTrackController=this.createController(t.subtitleTrackController,T);const A=t.subtitleStreamController;A&&T.push(new A(this,v,_)),this.createController(t.timelineController,S),_.emeController=this.emeController=this.createController(t.emeController,S),this.cmcdController=this.createController(t.cmcdController,S),this.latencyController=this.createController(Ft,S),this.coreComponents=S,T.push(o);const w=o.onErrorOut;"function"===typeof w&&this.on(f.ERROR,w,o)}createController(e,t){if(e){const r=new e(this);return t&&t.push(r),r}return null}on(e,t,r=this){this._emitter.on(e,t,r)}once(e,t,r=this){this._emitter.once(e,t,r)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,r=this,i){this._emitter.off(e,t,r,i)}listeners(e){return this._emitter.listeners(e)}emit(e,t,r){return this._emitter.emit(e,t,r)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(r){T.error("An internal error happened while handling event "+e+'. Error message: "'+r.message+'". Here is a stacktrace:',r),this.trigger(f.ERROR,{type:p.OTHER_ERROR,details:m.INTERNAL_EXCEPTION,fatal:!1,event:e,error:r})}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){T.log("destroy"),this.trigger(f.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(e=>e.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(e=>e.destroy()),this.coreComponents.length=0;const e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}attachMedia(e){T.log("attachMedia"),this._media=e,this.trigger(f.MEDIA_ATTACHING,{media:e})}detachMedia(){T.log("detachMedia"),this.trigger(f.MEDIA_DETACHING,void 0),this._media=null}loadSource(e){this.stopLoad();const t=this.media,r=this.url,i=this.url=n.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});T.log("loadSource:"+i),t&&r&&(r!==i||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(f.MANIFEST_LOADING,{url:e})}startLoad(e=-1){T.log(`startLoad(${e})`),this.networkControllers.forEach(t=>{t.startLoad(e)})}stopLoad(){T.log("stopLoad"),this.networkControllers.forEach(e=>{e.stopLoad()})}swapAudioCodec(){T.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){T.log("recoverMediaError");const e=this._media;this.detachMedia(),e&&this.attachMedia(e)}removeLevel(e,t=0){this.levelController.removeLevel(e,t)}get levels(){const e=this.levelController.levels;return e||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){T.log("set currentLevel:"+e),this.loadLevel=e,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){T.log("set nextLevel:"+e),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){T.log("set loadLevel:"+e),this.levelController.manualLevel=e}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(e){this.levelController.nextLoadLevel=e}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(e){T.log("set firstLevel:"+e),this.levelController.firstLevel=e}get startLevel(){return this.levelController.startLevel}set startLevel(e){T.log("set startLevel:"+e),-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){const t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimate():NaN}get ttfbEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(T.log("set autoLevelCapping:"+e),this._autoLevelCapping=e)}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){Nt.indexOf(e)>-1&&(this._maxHdcpLevel=e)}get autoLevelEnabled(){return-1===this.levelController.manualLevel}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){const{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;const r=e.length;for(let i=0;i<r;i++)if(e[i].maxBitrate>=t)return i;return 0}get maxAutoLevel(){const{levels:e,autoLevelCapping:t,maxHdcpLevel:r}=this;let i;if(i=-1===t&&e&&e.length?e.length-1:t,r)for(let s=i;s--;){const t=e[s].attrs["HDCP-LEVEL"];if(t&&t<=r)return s}return i}get nextAutoLevel(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)}set nextAutoLevel(e){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,e)}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get audioTracks(){const e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){const e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){const t=this.audioTrackController;t&&(t.audioTrack=e)}get subtitleTracks(){const e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){const e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){const t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}get subtitleDisplay(){const e=this.subtitleTrackController;return!!e&&e.subtitleDisplay}set subtitleDisplay(e){const t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(e){this.config.lowLatencyMode=e}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}}Fa.defaultConfig=void 0},ae74:function(e,t,r){var i=r("24fb");t=i(!1),t.push([e.i,'/*!\n* Mui Player Css Library v1.8.1 @Professional edition\n* Date2023-01-28\n* Released under GPL-3.0 license\n* https://muiplayer.js.org/\n*/.m-player{width:auto;height:225px;position:relative;overflow:hidden;background:#000;outline:none;-webkit-font-smoothing:antialiased;font-smoothing:antialiased;-webkit-tap-highlight-color:transparent;-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.m-player .mplayer-footer{color:#fff;position:absolute;bottom:0;right:0;left:0;background:linear-gradient(180deg,hsla(0,0%,100%,0),rgba(0,0,0,.65));-webkit-transform:translateY(50px);transform:translateY(50px);transition:-webkit-transform .3s;transition:transform .3s;transition:transform .3s,-webkit-transform .3s;z-index:7;height:48px;padding:0 10px}.m-player .mplayer-footer.show{-webkit-transform:translateY(0)!important;transform:translateY(0)!important}.m-player .mplayer-footer .progress{display:flex;align-items:center;justify-content:space-between;height:inherit}.m-player .mplayer-footer .progress .progress-container{display:flex;align-items:center;flex:1;height:25px}.m-player .mplayer-footer .progress .progress-container.upper-position{position:absolute;left:20px;right:20px;bottom:100%;margin-bottom:-10.5px}.m-player .mplayer-footer .progress .progress-container .touch-effective{position:relative;height:100%;display:flex;flex:1;align-items:center;margin-left:8px;margin-right:8px;cursor:pointer;-webkit-tap-highlight-color:transparent;-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.m-player .mplayer-footer .progress .progress-container .touch-effective .progress-default-scale{border-radius:0!important;-webkit-transform:translateY(-50%) translateZ(0) scaleY(2)!important;transform:translateY(-50%) translateZ(0) scaleY(2)!important}.m-player .mplayer-footer .progress .progress-container .touch-effective .progress-hover-scale{-webkit-transform:translateY(-50%) translateZ(0) scaleY(3)!important;transform:translateY(-50%) translateZ(0) scaleY(3)!important}.m-player .mplayer-footer .progress .progress-container .touch-effective .progress-total{width:100%;background-color:hsla(0,0%,100%,.2);overflow:hidden}.m-player .mplayer-footer .progress .progress-container .touch-effective .progress-play,.m-player .mplayer-footer .progress .progress-container .touch-effective .progress-total{position:absolute;height:2px;border-radius:5px;top:50%;-webkit-transform:scaleY(.9) translateY(-50%);transform:scaleY(.9) translateY(-50%);transition:-webkit-transform .15s;transition:transform .15s;transition:transform .15s,-webkit-transform .15s}.m-player .mplayer-footer .progress .progress-container .touch-effective .progress-buffered{background-color:hsla(0,0%,71%,.7);position:absolute;height:2px;border-top-left-radius:5px;border-bottom-left-radius:5px;top:50%;-webkit-transform:scaleY(.9) translateY(-50%);transform:scaleY(.9) translateY(-50%);transition:width .15s,-webkit-transform;transition:transform,width .15s;transition:transform,width .15s,-webkit-transform}.m-player .mplayer-footer .progress .progress-container .touch-effective .progress-prompt{position:absolute;height:2px;width:9px;top:50%;-webkit-transform:scaleY(.9) translateY(-50%);transform:scaleY(.9) translateY(-50%);transition:-webkit-transform .15s;transition:transform .15s;transition:transform .15s,-webkit-transform .15s;z-index:6}.m-player .mplayer-footer .progress .progress-container .touch-effective .progress-seekline{position:absolute;background-color:#ddd;height:2px;width:3px;top:50%;-webkit-transform:scaleY(.9) translateY(-50%);transform:scaleY(.9) translateY(-50%);transition:left 0s linear;z-index:5;visibility:hidden}.m-player .mplayer-footer .progress .progress-container .touch-effective .ball-container,.m-player .mplayer-footer .progress .progress-container .touch-effective .prompts-container{position:absolute;height:100%;width:100%}.m-player .mplayer-footer .progress .progress-container .touch-effective .ball-container .progress-drag,.m-player .mplayer-footer .progress .progress-container .touch-effective .prompts-container .progress-drag{height:30px;width:30px;position:absolute;top:50%;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);transition:-webkit-transform .15s;transition:transform .15s;transition:transform .15s,-webkit-transform .15s;z-index:7}.m-player .mplayer-footer .progress .progress-container .touch-effective .ball-container .progress-drag.hover-scale,.m-player .mplayer-footer .progress .progress-container .touch-effective .prompts-container .progress-drag.hover-scale{-webkit-transform:translate(-50%,-50%) scale(1)!important;transform:translate(-50%,-50%) scale(1)!important}.m-player .mplayer-footer .progress .progress-container .touch-effective .ball-container .progress-drag.default-scale,.m-player .mplayer-footer .progress .progress-container .touch-effective .prompts-container .progress-drag.default-scale{-webkit-transform:translate(-50%,-50%) scale(0);transform:translate(-50%,-50%) scale(0)}.m-player .mplayer-footer .progress .progress-container .touch-effective .ball-container .progress-drag .progress-ball,.m-player .mplayer-footer .progress .progress-container .touch-effective .prompts-container .progress-drag .progress-ball{position:absolute;top:50%;left:50%;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);height:17px;width:17px;border-radius:50%;display:inline-block;background:#fff}.m-player .mplayer-footer .progress .progress-begin{font-size:13px;min-width:40px;text-align:left}.m-player .mplayer-footer .progress .progress-long{font-size:13px;min-width:40px;text-align:right}.m-player .mplayer-footer .progress .left-part,.m-player .mplayer-footer .progress .right-part{display:flex;height:inherit}.m-player .mplayer-footer .progress .left-part .footer-control,.m-player .mplayer-footer .progress .right-part .footer-control{position:relative}.m-player .mplayer-footer .progress .left-part .footer-control:not(.no-active):active,.m-player .mplayer-footer .progress .right-part .footer-control:not(.no-active):active{opacity:.75}.m-player .mplayer-footer .progress .left-part .footer-control svg,.m-player .mplayer-footer .progress .right-part .footer-control svg{vertical-align:middle}.m-player .mplayer-footer .progress .panel-controls{position:absolute;min-height:50px;bottom:50px;padding:12px;background-color:rgba(0,0,0,.6);border-radius:3px}.m-player .mplayer-footer .progress .live-mode{color:#fff;position:relative;font-size:14px;width:auto;white-space:nowrap}.m-player .mplayer-footer .progress .live-mode .spot{width:6px;height:6px;border-radius:50%;background:#1e98d4;margin-right:5px;display:inline-block;vertical-align:middle}.m-player .mplayer-footer .progress .live-mode .mode-text{display:inline-block;vertical-align:middle}.m-player .mplayer-header{background:linear-gradient(180deg,rgba(0,0,0,.5),hsla(0,0%,100%,0));padding:0 10px;height:60px;position:absolute;top:0;left:0;right:0;display:flex;justify-content:space-between;align-items:center;-webkit-transform:translateY(-50px);transform:translateY(-50px);transition:-webkit-transform .3s;transition:transform .3s;transition:transform .3s,-webkit-transform .3s;z-index:7}.m-player .mplayer-header.show{-webkit-transform:translateY(0)!important;transform:translateY(0)!important}.m-player .mplayer-header .title-groupt{height:100%}.m-player .mplayer-header .title-groupt .back-button{white-space:nowrap;width:auto}.m-player .mplayer-header .title-groupt .back-button div,.m-player .mplayer-header .title-groupt .back-button svg{vertical-align:middle}.m-player .mplayer-header .title-groupt .back-button .title-name{position:relative;color:#fff;margin-left:5px;display:inline-block}.m-player .mplayer-header .buttom-group{display:flex;height:100%}.m-player .mplayer-header .buttom-group .battery-info{display:flex;flex-direction:column;align-items:center;justify-content:center;-webkit-transform:scale(.75);transform:scale(.75);-webkit-transform-origin:right;transform-origin:right}.m-player .mplayer-header .buttom-group .battery-info .time{color:#fff;font-size:14px;position:relative;top:4px;right:0}.m-player .mplayer-header .buttom-group .battery-info .capacity{border:1px solid #fff;height:11px;width:24px;border-radius:2px;position:relative}.m-player .mplayer-header .buttom-group .battery-info .capacity:after{content:"";height:7px;width:2px;position:absolute;top:50%;-webkit-transform:translateY(-50%);transform:translateY(-50%);border-right:none;border-top-left-radius:3px;border-bottom-left-radius:3px;left:-3px;background:#fff}.m-player .mplayer-header .buttom-group .battery-info .capacity .level{position:absolute;top:1px;bottom:1px;left:1px;right:1px}.m-player .mplayer-header .buttom-group .battery-info .capacity .level .count{background:#fff;height:100%;width:0;float:right;border-top-right-radius:1px;border-bottom-right-radius:1px}.m-player .mplayer-sidebar{display:block;position:absolute;top:0;bottom:0;right:0;background-color:rgba(0,0,0,.75);z-index:8;-webkit-transform:translateX(100%);transform:translateX(100%);transition:-webkit-transform .4s ease;transition:transform .4s ease;transition:transform .4s ease,-webkit-transform .4s ease;overflow:auto}.m-player .mplayer-sidebar.open{-webkit-transform:none!important;transform:none!important}.m-player .mplayer-sidebar::-webkit-scrollbar{width:4px;background:transparent}.m-player .mplayer-sidebar::-webkit-scrollbar-thumb{background:rgba(230,230,250,.24);border-radius:3px;height:100px}.m-player .mplayer-sidebar .title{color:#9a9e98;font-size:15px;line-height:40px;position:relative;margin-left:20px;margin-right:50px;text-align:left}.m-player .mplayer-sidebar .title:before{content:"";border-bottom:1px solid hsla(0,0%,87%,.3);position:absolute;left:0;right:0;bottom:0;-webkit-transform:scaleY(.5);transform:scaleY(.5)}.m-player .mplayer-sidebar .setting-box{font-size:15px;color:#fff;display:flex;flex-wrap:wrap;align-items:center;margin:15px 50px 20px 20px}.m-player .mplayer-sidebar .setting-box .box-name{margin-left:12px;flex:1;text-align:left}.m-player .mplayer-sidebar .setting-box .toogle-switch{margin-left:12px;cursor:pointer;border-radius:50px;width:45px;height:22px;position:relative;transition:background-color .2s ease-in}.m-player .mplayer-sidebar .setting-box .toogle-switch.open .ball{right:3px}.m-player .mplayer-sidebar .setting-box .toogle-switch.close{background-color:hsla(0,0%,100%,.3)!important}.m-player .mplayer-sidebar .setting-box .toogle-switch.close .ball{right:24px}.m-player .mplayer-sidebar .setting-box .toogle-switch .ball{border-radius:50px;height:18px;width:18px;border-radius:50%;background:#fff;position:absolute;top:50%;-webkit-transform:translateY(-50%);transform:translateY(-50%);transition:right .2s ease-in}.m-player .mplayer-sidebar .setting-box .toogle-switch .disable{position:absolute;top:0;bottom:0;right:0;left:0;border-radius:50px;background:rgba(0,0,0,.6)}.m-player .mplayer-sidebar .setting-box .play-speed{cursor:pointer;font-size:16px;height:35px;width:48px;display:flex;justify-content:center;align-items:center;border-radius:5px;margin-right:4px;flex-shrink:0}.m-player .mplayer-sidebar .setting-box .share-box{cursor:pointer;height:45px;width:45px;display:flex;justify-content:center;align-items:center;margin-right:22px;margin-bottom:12px;flex-shrink:0}.m-player .mp-tooltip{position:absolute;font-size:12px;white-space:nowrap;background-color:rgba(0,0,0,.73);padding:3px 10px;display:block;color:#fff;z-index:9;border-radius:3px;pointer-events:none}.m-player .player-btn{position:relative;cursor:pointer;border:none;background-color:initial;padding:0;padding:0 11px;outline:0;width:45px;min-width:45px;height:inherit;font-size:14px}.m-player .player-btn:focus{outline:none}.m-player .player-btn::-moz-focus-inner{border:0;outline:0}.m-player .mplayer-poster{position:absolute;top:0;bottom:0;left:0;right:0;background:#000}.m-player .mplayer-poster:before{content:"";position:absolute;top:0;bottom:0;left:0;right:0;background:rgba(0,0,0,.4)}.m-player .mplayer-cover{position:absolute;top:0;bottom:0;left:0;right:0;background:#000;z-index:8;opacity:0;transition:opacity .2s;pointer-events:none}.m-player .mplayer-time{position:absolute;top:50%;left:50%;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);z-index:8;opacity:0}.m-player .mplayer-time .time{color:#fff;font-size:26px;text-align:center;white-space:nowrap}.m-player .mplayer-time .time-progress{margin:auto;height:3px;background:hsla(0,0%,100%,.6);width:180px;border-radius:50px;margin-top:9px;overflow:hidden}.m-player .mplayer-time .time-progress .time-total{background:#fff;height:100%;width:50%;border-top-left-radius:50px;border-bottom-left-radius:50px}.m-player .small-control{height:32px;position:absolute;width:143px;top:15%;left:50%;-webkit-transform:translateX(-50%);transform:translateX(-50%);border-radius:50px;background-color:rgba(0,0,0,.55);display:flex;align-items:center;justify-content:center;opacity:0;z-index:7}.m-player .small-control .progress{border-radius:50px;overflow:hidden;height:3px;width:96px;background:hsla(0,0%,87%,.85);margin-left:6px}.m-player .small-control .progress .total{width:50%;height:100%;background:#fff}.m-player .mplayer-loading{color:#1e98d4;position:absolute;top:50%;left:50%;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);max-width:100%;max-height:100%;display:none;z-index:8}@-webkit-keyframes mp-rotate{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}@keyframes mp-rotate{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}@-webkit-keyframes mp-circular{0%{stroke-dasharray:1,200;stroke-dashoffset:0}50%{stroke-dasharray:90,150;stroke-dashoffset:-40}to{stroke-dasharray:90,150;stroke-dashoffset:-120}}@keyframes mp-circular{0%{stroke-dasharray:1,200;stroke-dashoffset:0}50%{stroke-dasharray:90,150;stroke-dashoffset:-40}to{stroke-dasharray:90,150;stroke-dashoffset:-120}}.m-player .mplayer-loading .mplayer-loading__circular{width:40px;height:40px;-webkit-animation:mp-rotate 1.8s linear infinite;animation:mp-rotate 1.8s linear infinite}.m-player .mplayer-loading .mplayer-loading__circular circle{-webkit-animation:mp-circular 1.5s ease-in-out infinite;animation:mp-circular 1.5s ease-in-out infinite;stroke:currentColor;stroke-width:3;stroke-linecap:round}.m-player .mplayer-toast{padding:7px 12px;background-color:rgba(80,80,77,.9);position:absolute;bottom:18%;color:#fff;border-radius:50px;font-size:14px;left:50%;-webkit-transform:translateX(-50%);transform:translateX(-50%);-webkit-animation:mplayerToast .25s;animation:mplayerToast .25s;z-index:10}@-webkit-keyframes mplayerToast{0%{bottom:-18%}to{bottom:18%}}@keyframes mplayerToast{0%{bottom:-18%}to{bottom:18%}}.m-player .mplayer-left{position:absolute;top:50%;-webkit-transform:translateY(-50%);transform:translateY(-50%);transition:left .3s;opacity:0;z-index:7}.m-player .mplayer-left ._unlock,.m-player .mplayer-left .control-icon ._lock{height:38px;width:38px;border-radius:50%;background-color:rgba(0,0,0,.3);display:flex;justify-content:center;align-items:center;cursor:pointer}.m-player .mplayer-error{position:absolute;top:50%;left:50%;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);color:#fff;z-index:10;font-size:13px;text-align:center;display:none;opacity:1;-webkit-animation:mplayerError .7s;animation:mplayerError .7s}@-webkit-keyframes mplayerError{0%{opacity:0}to{opacity:1}}@keyframes mplayerError{0%{opacity:0}to{opacity:1}}.m-player .mplayer-error .errop-tip{height:25px}.m-player .mplayer-error:active{opacity:.75}.m-player .mini-progress{height:2px;position:absolute;bottom:0;left:0;right:0;-webkit-transform:translateY(.3px);transform:translateY(.3px);opacity:0;z-index:7}.m-player .mini-progress .mini-total{position:absolute;background-color:hsla(0,0%,100%,.2);width:100%;height:100%}.m-player .mini-progress .mini-buffered{position:absolute;background-color:hsla(0,0%,71%,.5);height:100%}.m-player .mini-progress .mini-play{position:absolute;height:100%}@-webkit-keyframes mp-bezel-fadeout{0%{opacity:1}to{opacity:0;-webkit-transform:scale(1.5);transform:scale(1.5)}}@keyframes mp-bezel-fadeout{0%{opacity:1}to{opacity:0;-webkit-transform:scale(1.5);transform:scale(1.5)}}.m-player .mp-bezel-text-hide .mp-bezel{z-index:10;position:absolute;left:50%;top:50%;width:52px;height:52px;margin-left:-26px;margin-top:-26px;background:rgba(0,0,0,.6);border-radius:26px;-webkit-animation:mp-bezel-fadeout .4s linear 1 normal forwards;animation:mp-bezel-fadeout .4s linear 1 normal forwards;pointer-events:none}.m-player .mp-bezel-text-hide .mp-bezel .mp-bezel-icon{width:24px;height:24px;margin:14px}.m-player .mp-bezel-text-hide .mp-bezel .mp-bezel-icon .mp-svg-shadow{stroke:#000;stroke-opacity:.15;stroke-width:2px;fill:none}.m-player .ctxmenu-wrapper{position:absolute;top:0;bottom:0;left:0;right:0;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;display:none}.m-player .ctxmenu-wrapper .ctxmenulist{text-align:left;position:absolute;list-style:none;font-size:14px;background:rgba(28,28,28,.9);text-shadow:0 0 2px rgba(0,0,0,.5);color:#eee;border-radius:2px;margin:0;padding:0;min-width:170px;transition:opacity .1s;opacity:0;outline:0;z-index:9}.m-player .ctxmenu-wrapper .ctxmenulist li{padding:9px 30px;cursor:pointer}.m-player .ctxmenu-wrapper .ctxmenulist li:first-child{border-top-left-radius:2px;border-top-right-radius:2px}.m-player .ctxmenu-wrapper .ctxmenulist li:last-child{border-bottom-left-radius:2px;border-bottom-right-radius:2px}.m-player .ctxmenu-wrapper .ctxmenulist li:hover{background-color:hsla(0,0%,100%,.1)}.m-player .mplayer-shortcut{text-align:left;font-size:16px;background:rgba(28,28,28,.9);text-shadow:0 0 2px rgba(0,0,0,.5);color:#eee;border-radius:3px;padding:15px 0 15px 20px;position:absolute;top:10px;left:10px;z-index:8;display:none;-webkit-user-select:text;-moz-user-select:text;-ms-user-select:text;user-select:text;width:430px;max-width:calc(100% - 40px)}.m-player .mplayer-shortcut .title{margin:0;padding-bottom:10px}.m-player .mplayer-shortcut .close-shortcut-panel{position:absolute;top:15px;right:15px;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;width:24px;height:24px}.m-player .mplayer-shortcut .close-shortcut-panel:active{opacity:.8}.m-player .mplayer-shortcut ul{list-style:none;margin:0 0 2px;padding:0;font-size:14px}.m-player .mplayer-shortcut ul li{display:inline-block;height:28px;line-height:28px;width:50%}.m-player .mplayer-shortcut ul li span{color:#999}.m-player .mp-popup-animation{transition:all .25s cubic-bezier(0,0,.2,1)}.m-player .popup-toggle{transition:opacity .1s cubic-bezier(0,0,.2,1)!important}.m-player .mp-popup{border-radius:2px;overflow:hidden;position:absolute;font-size:13px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;will-change:width,height;background:rgba(28,28,28,.9);opacity:0;min-width:42px}.m-player .mp-popup .mp-panel{min-width:260px}.m-player .mp-popup .mp-panel.mp-panel-child .mp-menuitem{padding-left:14.5%}.m-player .mp-popup .mp-panel.mp-panel-item{position:absolute;bottom:0;right:0;overflow-y:auto;overflow-x:hidden}.m-player .mp-popup .mp-panel.mp-panel-item::-webkit-scrollbar{width:8px;background-color:#424242}.m-player .mp-popup .mp-panel.mp-panel-item::-webkit-scrollbar-thumb{background-color:#8e8e8e;border:1px solid #424242;border-radius:3px}.m-player .mp-popup .mp-panel.mp-panel-item::-webkit-scrollbar-track{background-color:#424242}.m-player .mp-popup .mp-panel.mp-panel-item .mp-panel-selected{background-size:8%;background-repeat:no-repeat;background-position:4%;vertical-align:middle;background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCI+PHBhdGggZD0iTTkgMTYuMkw0LjggMTJsLTEuNCAxLjRMOSAxOSAyMSA3bC0xLjQtMS40TDkgMTYuMnoiIGZpbGw9IiNmZmYiLz48L3N2Zz4=)}.m-player .mp-popup .mp-panel.mp-panel-item .mp-panel-header{height:50px;padding-left:0;line-height:50px}.m-player .mp-popup .mp-panel.mp-panel-item .mp-panel-header:before{content:"";position:absolute;border-bottom:1px solid #fff;left:0;right:0;bottom:0;-webkit-transform:scaleY(.5);transform:scaleY(.5);opacity:.2;z-index:100}.m-player .mp-popup .mp-panel .mp-menuitem{position:relative;list-style:none;color:#eee;margin:0;padding:0;display:flex;justify-content:space-between;align-items:center;padding-left:10%;height:40px;line-height:40px;white-space:nowrap;outline:none}.m-player .mp-popup .mp-panel .mp-menuitem:not(.mp-panel-header){cursor:pointer}.m-player .mp-popup .mp-panel .mp-menuitem:not(.mp-panel-header):hover{background-color:hsla(0,0%,100%,.1)}.m-player .mp-popup .mp-panel .mp-menuitem li{height:inherit;width:50%}.m-player .mp-popup .mp-panel .mp-menuitem li:first-child{padding-right:40px;white-space:pre;overflow:hidden;text-overflow:ellipsis;text-align:left}.m-player .mp-popup .mp-panel .mp-menuitem li:last-child{text-align:right}.m-player .mp-popup .mp-panel .mp-menuitem li .mp-menuitem-content{height:inherit}.m-player .mp-popup .mp-panel .mp-menuitem li .arrow-icon{background:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzMiAzMiI+PHBhdGggZD0iTTEyLjU5IDIwLjM0bDQuNTgtNC41OS00LjU4LTQuNTlMMTQgOS43NWw2IDYtNiA2eiIgZmlsbD0iI2ZmZiIvPjwvc3ZnPg==);background-size:35%;background-repeat:no-repeat;background-position:100%;vertical-align:middle;padding-right:35%}.m-player .mp-popup .mp-panel .mp-menuitem li .left-arrow-icon{background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzMiAzMiI+PHBhdGggZD0iTTE5LjQxIDIwLjA5bC00LjU4LTQuNTkgNC41OC00LjU5TDE4IDkuNWwtNiA2IDYgNnoiIGZpbGw9IiNmZmYiLz48L3N2Zz4=);background-repeat:no-repeat;background-position:0;background-size:30%;padding-left:30%;text-align:left;cursor:pointer}.m-player .mp-popup .mp-panel .mp-menuitem li .toogle-switch{cursor:pointer;border-radius:50px;width:41px;height:20px;position:relative;display:inline-block;transition:background-color .2s ease-in;vertical-align:middle;right:13%}.m-player .mp-popup .mp-panel .mp-menuitem li .toogle-switch.close{background-color:hsla(0,0%,100%,.3)!important}.m-player .mp-popup .mp-panel .mp-menuitem li .toogle-switch.open .ball{right:4.83%}.m-player .mp-popup .mp-panel .mp-menuitem li .toogle-switch .ball{border-radius:50px;height:16px;width:16px;border-radius:50%;background:#fff;position:absolute;top:50%;-webkit-transform:translateY(-50%);transform:translateY(-50%);transition:right .15s ease-in;right:56.46%}.m-player .volume-container{width:100%;height:100%;border-radius:2px;color:#fff;text-align:center;outline:0;font-size:12px;padding-top:8px;padding-bottom:8px}.m-player .volume-container .volume-size{color:#fff}.m-player .volume-container .volume-capacity{cursor:pointer;height:100px;width:4px;background-color:#373838;border-radius:7px;margin:25% auto 0;position:relative}.m-player .volume-container .volume-capacity .volume-drag-ball{background-color:#fff;width:14px;height:14px;border-radius:50%;position:absolute;left:50%;-webkit-transform:translateX(-50%);transform:translateX(-50%);bottom:0;z-index:7}.m-player .volume-container .volume-capacity .progress-bar{border-radius:7px;position:absolute;bottom:0;left:0;right:0;height:0}.m-player .danmaku-controls{display:flex;flex-direction:row;align-items:center;font-size:12px;flex:0.65;margin:auto .82%}.m-player .danmaku-controls .dms-button:active{cursor:pointer;opacity:.85}.m-player .danmaku-controls .danmaku-input-wrap{position:relative;width:auto;height:34px;background-color:#111226;flex:1;flex-shrink:0;border-radius:50px;background:hsla(0,0%,100%,.25);color:#fff;margin-left:1.2%;display:flex}.m-player .danmaku-controls .danmaku-input-wrap .dms-input-text{height:100%;border:0;left:0;border-radius:50px 0 0 50px;flex:1;padding:0;margin:0;outline:0;background-color:initial;padding:0 12px;color:#fff;font-size:14px;text-shadow:0 0 4px rgba(0,0,0,.75)}.m-player .danmaku-controls .danmaku-input-wrap .dms-input-text::-webkit-input-placeholder{color:#ddd;text-shadow:0 0 4px rgba(0,0,0,.75)}.m-player .danmaku-controls .danmaku-input-wrap .dms-input-text::-moz-placeholder{color:#ddd;text-shadow:0 0 4px rgba(0,0,0,.75)}.m-player .danmaku-controls .danmaku-input-wrap .dms-input-text::-ms-input-placeholder{color:#ddd;text-shadow:0 0 4px rgba(0,0,0,.75)}.m-player .danmaku-controls .danmaku-input-wrap .dms-input-text::placeholder{color:#ddd;text-shadow:0 0 4px rgba(0,0,0,.75)}.m-player .danmaku-controls .danmaku-input-wrap .dms-btn-submit{top:0;right:0;width:66px;height:100%;border:none;border-radius:0 50px 50px 0;outline:0;background-color:#292a3c;color:#eee;cursor:pointer;margin-left:8px;position:relative}.m-player .danmaku-controls .danmaku-input-wrap .dms-btn-submit span{display:inline-block;position:absolute;top:50%;left:50%;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%)}.m-player .mp-rolling{position:absolute;top:0;width:100%;color:#fff;overflow:hidden;z-index:6;-webkit-transform-origin:right;transform-origin:right}.m-player .mp-rolling .rolling-content{position:relative;white-space:nowrap;display:inline-block}.m-player .mp-logot-box{position:absolute;width:100%;height:100%;left:50%;top:50%;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);pointer-events:none;z-index:6}@-webkit-keyframes mp-logot-show{0%{opacity:.1}to{opacity:1}}@keyframes mp-logot-show{0%{opacity:.1}to{opacity:1}}.m-player .mp-logot-box .mp-logot{position:absolute;background-repeat:no-repeat;background-size:contain;opacity:0;-webkit-animation:mp-logot-show .35s linear both;animation:mp-logot-show .35s linear both;image-rendering:-moz-crisp-edges;image-rendering:-o-crisp-edges;image-rendering:-webkit-optimize-contrast;image-rendering:crisp-edges;-ms-interpolation-mode:nearest-neighbor}.m-player .mp-logot-box .mp-logot.logot-top-right{right:1.5%;top:3%;-webkit-transform-origin:top right;transform-origin:top right}.m-player .mp-logot-box .mp-logot.logot-top-left{left:1.5%;top:3%;-webkit-transform-origin:top left;transform-origin:top left}.m-player .mp-logot-box .mp-logot.logot-bottom-left{left:1.5%;bottom:3%;-webkit-transform-origin:bottom left;transform-origin:bottom left}.m-player .mp-logot-box .mp-logot.logot-bottom-right{right:1.5%;bottom:3%;-webkit-transform-origin:bottom right;transform-origin:bottom right}.m-player .advertise-wrap{position:absolute;top:50%;left:50%;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);z-index:7;width:320px;height:240px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:pointer;overflow:hidden;background:rgba(0,0,0,.65);max-height:calc(100% - 40px);max-width:calc(100% - 40px);box-shadow:0 2px 5px 0 rgba(0,0,0,.16)}.m-player .advertise-wrap .ad-tip{position:absolute;bottom:3px;left:3px;display:inline-block;cursor:auto;height:20px;margin:0 2px 0 0;padding:0 4px;line-height:20px;font-size:12px;color:#fff;background:rgba(0,0,0,.5);border-radius:2px}.m-player .advertise-wrap .ad-close{position:absolute;right:4px;top:4px;cursor:pointer}.m-player .advertise-wrap .ad-close .ad-icon{width:18px;height:18px;padding:3px;border-radius:100%;vertical-align:middle;background:rgba(0,0,0,.5)}.m-player .advertise-wrap .ad-close .ad-icon path{transition:fill .3s}.m-player:-webkit-full-screen{position:fixed!important;top:0!important;right:0!important;bottom:0!important;left:0!important;box-sizing:border-box!important;min-width:0!important;max-width:none!important;min-height:0!important;max-height:none!important;width:100%!important;height:100%!important;-webkit-transform:none!important;transform:none!important;margin:0!important;padding:0!important;z-index:1000!important}.m-player:-webkit-full-screen uni-video{position:relative}.m-player.browser-fullscreen{position:fixed!important;top:0!important;right:0!important;bottom:0!important;left:0!important;box-sizing:border-box!important;min-width:0!important;max-width:none!important;min-height:0!important;max-height:none!important;width:100%!important;height:100%!important;-webkit-transform:none!important;transform:none!important;margin:0!important;padding:0!important;z-index:1000!important}.m-player.browser-fullscreen uni-video{position:relative}.m-player.page-fullscreen{position:fixed!important;top:0!important;right:0!important;bottom:0!important;left:0!important;box-sizing:border-box!important;min-width:0!important;max-width:none!important;min-height:0!important;max-height:none!important;width:100%!important;height:100%!important;-webkit-transform:none!important;transform:none!important;margin:0!important;padding:0!important;z-index:1000!important}.m-player.page-fullscreen uni-video{position:relative}.m-player.mp-keyboard-focus .keyboard-input:focus,.m-player.mp-keyboard-focus .mp-menuitem:focus{box-shadow:inset 0 0 0 2px rgba(27,127,204,.8)}.m-player .player-wrapper{height:100%;width:100%;position:relative}.m-player .player-wrapper.mplayer-miniwindow{position:fixed;transition-property:width,height,opacity,bottom,right,border-radius;will-change:bottom,right,border-radius;overflow:hidden;z-index:1000;border-radius:0;opacity:1;background:#000;box-shadow:0 2px 5px 0 rgba(0,0,0,.16)}.m-player .player-wrapper.mplayer-miniwindow.transition-disable{transition-property:none;cursor:move}.m-player .player-wrapper.mplayer-miniwindow .element-hidden,.m-player .player-wrapper.mplayer-miniwindow .mp-popup{visibility:hidden}.m-player .player-wrapper.mplayer-miniwindow uni-video{width:100%!important;height:100%!important}.m-player .player-wrapper.mplayer-miniwindow .scrim-layer{position:absolute;height:100%;width:100%;top:0;z-index:7;background-color:initial;transition-property:background-color;transition-duration:.08s;transition-timing-function:linear}.m-player .player-wrapper .video-wrapper{height:100%;display:flex;justify-content:center;align-items:center}.m-player .player-wrapper .video-wrapper uni-video{-o-object-fit:contain;object-fit:contain;display:block;opacity:0}.m-player .player-wrapper .video-wrapper uni-video.covered{height:100%!important;width:100%!important;-o-object-fit:cover;object-fit:cover}.m-player .player-wrapper .video-wrapper uni-video::cue{color:#fff;background:transparent;text-shadow:0 0 1px #000}.m-player .player-wrapper .video-wrapper uni-video::-webkit-media-text-track-display{margin-top:-5px}.m-player .player-wrapper .video-wrapper uni-video::-webkit-media-controls-overlay-play-button,.m-player .player-wrapper .video-wrapper uni-video::-webkit-media-controls-start-playback-button,.m-player .player-wrapper .video-wrapper uni-video::-webkit-media-controls-volume-slider,.m-player .player-wrapper .video-wrapper uni-video uni-video::-webkit-media-controls-mute-button{display:none}',""]),e.exports=t},bf15:function(module,exports,__webpack_require__){"use strict";(function(module){var __WEBPACK_AMD_DEFINE_FACTORY__,__WEBPACK_AMD_DEFINE_RESULT__;
/*!
* Mui Player Javascript Library v1.8.1 @Professional edition
* Date2023-01-28
* Released under GPL-3.0 license
* https://muiplayer.js.org/
*/function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _createForOfIteratorHelper(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0;t=function(){};return{s:t,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:t}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,n=!0,a=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return n=e.done,e},e:function(e){a=!0,s=e},f:function(){try{n||null==r.return||r.return()}finally{if(a)throw s}}}}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(r="Object"===r&&e.constructor?e.constructor.name:r)||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}!function(e,t){"object"==_typeof(exports)&&"object"==_typeof(module)?module.exports=t():_typeof(__webpack_require__("3c35"))?(__WEBPACK_AMD_DEFINE_FACTORY__=t,__WEBPACK_AMD_DEFINE_RESULT__="function"===typeof __WEBPACK_AMD_DEFINE_FACTORY__?__WEBPACK_AMD_DEFINE_FACTORY__.call(exports,__webpack_require__,exports,module):__WEBPACK_AMD_DEFINE_FACTORY__,void 0===__WEBPACK_AMD_DEFINE_RESULT__||(module.exports=__WEBPACK_AMD_DEFINE_RESULT__)):e.MuiPlayer=t()}(window,(function(){var MuiPlayer=function MuiPlayer(config){var _this=this;_this._global_={};var webpagePlugin="",mobilePlugin="",hls=null,flv=null,option=config||{},plugins=option.plugins||[];this._event_={};var con="string"==typeof option.container?document.querySelector(option.container):option.container,$CONSTANT,$habit,$node,$global,element,$el,variable,$data,$method;con&&($CONSTANT={unitLengthReg:/^(auto|inherit|initial|\d+(\.\d+)?(\%|px|cm|mm|em|rem|vw|vh|)?)$/i,encodeKey:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"},$habit={themeColor:"#1e98d4"},$node={video:'\x3c!-- HTML5 Video --\x3e<div class="video-wrapper"><video width="100%" height="100%"></video></div>',mplayerPoster:'<div class="mplayer-poster" id="mplayer-poster"></div>',mplayerCover:'\x3c!-- 媒体播放遮罩层 --\x3e<div class="mplayer-cover" id="mplayer-cover"></div>',mplayerLoading:'\x3c!-- Mplayer加载Loading --\x3e<div class="mplayer-loading"id="mplayer-loading"control><svg viewBox="25 25 50 50"class="mplayer-loading__circular"><circle cx="50"cy="50"r="20"fill="none"></circle></svg></div>',mplayerError:'\x3c!-- 视频加载错误显示 --\x3e<div class="mplayer-error"id="mplayer-error"control><div class="errop-tip">视频加载失败,点击刷新</div><svg t="1575125481608"class="icon"viewBox="0 0 1024 1024"version="1.1"xmlns="http://www.w3.org/2000/svg"p-id="5893"width="28"height="28"><path d="M513.34 831.74C337.03 831.74 193.6 688.31 193.6 512c0-71.09 23.31-138.85 65.53-194.03v51.61c0 17.67 14.33 32 32 32s32-14.33 32-32V239.45c0-5.87-1.59-11.36-4.34-16.09-0.06-0.1-0.11-0.2-0.17-0.3-0.16-0.28-0.34-0.55-0.51-0.82-0.13-0.2-0.26-0.41-0.39-0.61-0.08-0.13-0.17-0.25-0.26-0.37a35.5 35.5 0 0 0-1.58-2.13c-6.81-8.35-16.96-12.35-26.95-11.69h-130c-17.67 0-32 14.33-32 32s14.33 32 32 32h55.35C159.8 339 129.6 423.35 129.6 512c0 51.79 10.15 102.05 30.17 149.38 19.33 45.7 46.99 86.74 82.23 121.97 35.23 35.23 76.27 62.9 121.97 82.23 47.33 20.02 97.59 30.17 149.38 30.17 17.67 0 32-14.33 32-32s-14.34-32.01-32.01-32.01zM855.38 762.3h-51.23c19.81-23 36.93-48.3 50.75-75.22 27.6-53.74 42.18-114.28 42.18-175.08 0-51.79-10.15-102.05-30.17-149.38-19.33-45.7-46.99-86.73-82.23-121.97-35.23-35.23-76.27-62.9-121.97-82.23-47.33-20.02-97.59-30.17-149.38-30.17-17.67 0-32 14.33-32 32s14.33 32 32 32c176.31 0 319.74 143.44 319.74 319.74 0 78.31-27.68 151.61-77.6 209.05l0.24-56.04c0.08-17.67-14.19-32.06-31.86-32.14h-0.14c-17.61 0-31.92 14.24-32 31.86l-0.55 129.43a31.988 31.988 0 0 0 9.32 22.71 31.68 31.68 0 0 0 5.33 4.3c0.02 0.01 0.04 0.02 0.06 0.04 0.48 0.31 0.97 0.61 1.47 0.89l0.15 0.09c0.5 0.28 1 0.54 1.51 0.8 0.03 0.01 0.05 0.03 0.08 0.04 1.64 0.8 3.34 1.46 5.1 1.98 0.01 0 0.02 0.01 0.03 0.01 0.55 0.16 1.1 0.3 1.66 0.43 0.07 0.02 0.15 0.03 0.22 0.05 0.5 0.11 1 0.21 1.5 0.3 0.1 0.02 0.2 0.04 0.3 0.05 0.48 0.08 0.96 0.15 1.44 0.21 0.11 0.01 0.23 0.03 0.34 0.04 0.48 0.05 0.95 0.09 1.43 0.12l0.34 0.03c0.53 0.03 1.07 0.04 1.61 0.05h132.31c17.67 0 32-14.33 32-32s-14.31-31.99-31.98-31.99z"p-id="5894"fill="#ffffff"></path></svg></div>',mplayerHeader:'\x3c!-- Mplayer 顶部导航 --\x3e<div class="mplayer-header"id="mplayer-header"><div class="title-groupt"id="title-groupt"><button class="player-btn header-control back-button keyboard-input"id="back-button"control><svg id="back-icon-svg"t="1573891955387"viewBox="0 0 1024 1024"version="1.1"xmlns="http://www.w3.org/2000/svg"p-id="4550"width="18"height="18"><path d="M305.519192 557.640404c-11.636364 0-23.40202-4.39596-32.323232-13.317172-17.842424-17.842424-17.842424-46.674747 0-64.517171L683.830303 69.30101c17.842424-17.842424 46.674747-17.842424 64.517172 0 17.842424 17.842424 17.842424 46.674747 0 64.517172L337.713131 544.323232c-8.921212 8.921212-20.557576 13.317172-32.193939 13.317172z m0 0"fill="#ffffff"p-id="4551"></path><path d="M715.894949 968.145455c-11.636364 0-23.40202-4.39596-32.323232-13.317172L273.19596 544.323232c-17.842424-17.842424-17.842424-46.674747 0-64.517171 17.842424-17.842424 46.674747-17.842424 64.517171 0l410.505051 410.50505c17.842424 17.842424 17.842424 46.674747 0 64.517172-8.921212 8.921212-20.557576 13.317172-32.323233 13.317172z m0 0"fill="#ffffff"p-id="4552"></path></svg><div class="title-name"id="title-name"></div></button></div><div class="buttom-group"id="buttom-group"></div></div>',mplayerFooter:'\x3c!-- Mplayer 底部操作控件 --\x3e<div class="mplayer-footer"id="mplayer-footer"><div class="progress"id="progress"><div class="left-part"id="left-part"><button class="player-btn keyboard-input play-switch footer-control"id="play-switch"control>\x3c!--play button--\x3e<div class="_play"><svg t="1574051894346"viewBox="0 0 1024 1024"version="1.1"xmlns="http://www.w3.org/2000/svg"p-id="1212"><path d="M324.085 95.787l500.422 300.664c82.373 50.453 79.284 136.946-1.030 186.37v0l-506.6 304.784c-41.187 23.683-87.522 37.068-131.798 9.267-36.037-22.653-46.335-58.691-46.335-97.819v-616.774c0-39.127 13.386-75.166 48.395-97.819 45.305-27.801 94.731-14.416 136.946 11.327v0z"p-id="1213"fill="#ffffff"></path></svg></div>\x3c!--pause button--\x3e<div class="_pause"style="display: none;"><svg t="1574051952939"viewBox="0 0 1024 1024"version="1.1"xmlns="http://www.w3.org/2000/svg"p-id="1434"><path d="M248.26311111 515.072c0-110.592-0.22755555-221.184 0.11377778-331.776 0.11377778-35.84 18.20444445-60.87111111 49.26577778-70.99733333 27.53422222-8.87466667 56.88888889 0.34133333 75.32088888 23.77955555 10.58133333 13.42577778 15.13244445 28.89955555 15.01866667 45.96622223-0.11377778 223.11822222 0.11377778 446.23644445-0.22755555 669.35466666-0.11377778 42.55288889-31.06133333 73.27288889-70.54222222 72.81777778-39.25333333-0.45511111-68.72177778-31.51644445-68.94933334-74.52444444-0.34133333-111.50222222 0-223.11822222 0-334.62044445zM638.52088889 516.66488889V193.64977778c0-52.45155555 27.42044445-85.21955555 70.54222222-84.65066667 42.43911111 0.56888889 69.17688889 32.42666667 69.17688889 83.05777778 0.11377778 218.22577778 0.11377778 436.56533333 0 654.79111111 0 38.34311111-17.29422222 63.60177778-49.152 73.95555555-27.648 8.98844445-56.54755555 0-75.43466667-23.552-12.17422222-15.13244445-15.36-32.768-15.24622222-51.76888888 0.22755555-109.568 0.11377778-219.136 0.11377778-328.81777778z"p-id="1435"fill="#ffffff"></path></svg></div></button>\x3c!--直播模式--\x3e<button class="player-btn live-mode footer-control"id="live-mode"control><div class="spot"></div><div class="mode-text">直播</div></button></div>\x3c!--底部进度容器--\x3e<div class="progress-container"id="progress-container">\x3c!--安全进度时长--\x3e<div class="progress-begin"id="progress-begin">开始</div>\x3c!--拖动有效的作用域--\x3e<div class="touch-effective"id="touch-effective">\x3c!--加载进度条总长--\x3e<div class="progress-total"id="progress-total"></div>\x3c!--资源缓存进度--\x3e<div class="progress-buffered"id="progress-buffered"></div>\x3c!--播放进度--\x3e<div class="progress-play"id="progress-play"></div>\x3c!--拖动进度球--\x3e<div class="ball-container"><div class="progress-drag"id="progress-ball"><div class="progress-ball"></div></div></div></div>\x3c!--总时长--\x3e<div class="progress-long"id="progress-long">结束</div></div><div class="right-part"id="right-part">\x3c!--全屏开关--\x3e<button class="player-btn keyboard-input full-switch footer-control"id="full-switch"tooltip="全屏"control><div class="_full"><svg t="1607611836872"class="icon"viewBox="0 0 1024 1024"version="1.1"xmlns="http://www.w3.org/2000/svg"p-id="2384"><path d="M842 797.08l-226.07999999-226.08a30 30 0 0 0-42.42000001 42.42000001L799.58 839.5 692 839.5a30 30 0 0 0 0 60L872 899.5a29.91 29.91 0 0 0 30-29.99999999l0-180a30 30 0 0 0-60 0l0 107.57999999zM130.79 128.29A29.91 29.91 0 0 1 152 119.5l180 0a30 30 0 0 1 0 60l-107.58 0 226.08 226.08a30 30 0 0 1-42.42000001 42.42L182 221.92 182 329.50000001a30 30 0 0 1-60 0L122 149.50000001a29.91 29.91 0 0 1 8.79-21.21000001z"fill="#ffffff"p-id="2385"></path></svg></div><div class="_unfull"style="display: none;"><svg t="1607611848290"class="icon"viewBox="0 0 1024 1024"version="1.1"xmlns="http://www.w3.org/2000/svg"p-id="2546"><path d="M416.00000001 370.752L174.848 129.59999999a32 32 0 0 0-45.24800001 45.24800001L370.752 416.00000001 256 416a32 32 0 0 0 0 64l192 0a31.904 31.904 0 0 0 32-32L480 256a32 32 0 0 0-64 0l1e-8 114.752z m137.37599999 182.624A31.904 31.904 0 0 1 576 544L768 544a32 32 0 0 1 0 64l-114.752-1e-8 241.15200001 241.15200001a32 32 0 1 1-45.24800001 45.24800001L607.99999999 653.248 608 768a32 32 0 0 1-64 0l0-192a31.904 31.904 0 0 1 9.376-22.624z"fill="#ffffff"p-id="2547"></path></svg></div></button></div></div></div>',miniProgress:'\x3c!-- Mplayer 底部播放迷你进度条 --\x3e<div class="mini-progress"id="mini-progress">\x3c!--加载进度条总长--\x3e<div class="mini-total"id="mini-total"></div>\x3c!--资源缓存进度--\x3e<div class="mini-buffered"id="mini-buffered"></div>\x3c!--播放进度--\x3e<div class="mini-play"id="mini-play"></div></div>'},$global=function(){return{first_authplay:!1,isReady:!1,webpagePlugin:{},mobilePlugin:{},cssAutoprefixer:["webkit","ms","moz","o"]}},element=function(){return{mPlayer:con,videoObject:con.querySelector("video"),mplayerCover:con.querySelector("#mplayer-cover"),mplayerPoster:con.querySelector("#mplayer-poster"),mplayerHeader:con.querySelector("#mplayer-header"),headerMenu:con.querySelector("#buttom-group"),backButton:con.querySelector("#back-button"),mplayerFooter:con.querySelector("#mplayer-footer"),progressContainer:con.querySelector("#progress-container"),playSwitch:con.querySelector("#play-switch"),fullSwitch:con.querySelector("#full-switch"),progressBall:con.querySelector("#progress-ball"),progressBegin:con.querySelector("#progress-begin"),progressLong:con.querySelector("#progress-long"),touchEffective:con.querySelector("#touch-effective"),progressBuffered:con.querySelector("#progress-buffered"),progressPlay:con.querySelector("#progress-play"),miniProgress:con.querySelector("#mini-progress"),miniBuffered:con.querySelector("#mini-buffered"),miniPlay:con.querySelector("#mini-play"),mplayerLoading:con.querySelector("#mplayer-loading"),mplayerError:con.querySelector("#mplayer-error")}},$el=new element,variable=function(){return{mediaPlayDirectives:0,isFullScreen:!1,showScreenControls:!1,ball_move_status:!1,isPlay:!1,mediaStatus:!1,duration:0,percentage:0,currentTime:0,playError:0,isDestroy:!1,isShowRightSidebar:!1,startX:null,startY:null,moveX:null,moveY:null,_defaultPlayProgressPro:null,isTouchMove:!1,isControlsTimer:!0}},$data=new variable,$method={getLanguageText:function(){return{"zh-cn":{srcNull:"视频地址为空",begin:"开始",end:"结束",live:"直播",settings:"设置",coveredPlay:"铺满播放",loopPlay:"循环播放",playbackSpeed:"播放速度",share:"分享",pictureInPicture:"画中画",exitPictureInPicture:"退出画中画",pageScreen:"网页全屏",exitPageScreen:"退出网页全屏",fullScreen:"全屏",exitFullScreen:"退出全屏",normal:"正常",open:"打开",subtitles:"字幕",selectLangage:"选择语言",dsps:"切换到默认倍速度播放",tsps:"切换到?倍速度播放",errorTip:"视频加载失败,点击刷新",shortcuts:"快捷键",shortcutsPanel:{title:"快捷功能",space:"空格",spaceAction:"播放/暂停",esc:"退出全屏",up:"音量增加5%",down:"音量减少5%",right:"快进5秒",left:"快退5秒"},advertise:"广告"},en:{srcNull:"Video address is empty",begin:"Begin",end:"End",live:"Live",settings:"Settings",coveredPlay:"Covered play",loopPlay:"Loop play",playbackSpeed:"Playback speed",share:"Share",pictureInPicture:"Picture in picture",exitPictureInPicture:"Exit picture in picture",pageScreen:"Page screen",exitPageScreen:"Exit page screen",fullScreen:"Full screen",exitFullScreen:"Exit full screen",normal:"Normal",open:"Open",subtitles:"Subtitles",selectLangage:"Select langage",dsps:"to default speed playback",tsps:"to ?x speed playback",errorTip:"Video failed to load, click refresh",shortcuts:"Shortcuts",shortcutsPanel:{title:"Shortcuts function",space:"Space",spaceAction:"play/pause",esc:"exit full screen",up:"voice increase 5%",down:"voice reduce 5%",right:"fast forward 5 seconds",left:"fast backward 5 seconds"},advertise:"Advertise"},"zh-tw":{srcNull:"視頻地址為空",begin:"開始",end:"結束",live:"直播",settings:"設置",coveredPlay:"鋪滿播放",loopPlay:"循環播放",playbackSpeed:"播放速度",share:"分享",pictureInPicture:"畫中畫",exitPictureInPicture:"退出畫中畫",pageScreen:"網頁全屏",exitPageScreen:"退出網頁全屏",fullScreen:"全屏",exitFullScreen:"退出全屏",normal:"正常",open:"打開",subtitles:"字幕",selectLangage:"選擇語言",dsps:"切換到默認倍速度播放",tsps:"切換到?倍速度播放",errorTip:"視頻加載失敗,點擊刷新",shortcuts:"快捷鍵",shortcutsPanel:{title:"快捷功能",space:"空格",spaceAction:"播放/暫停",esc:"退出全屏",up:"音量增加5%",down:"音量减少5%",right:"快進5秒",left:"快退5秒"},advertise:"廣告"}}},getLangObject:function(){var e=option.lang||navigator.language||navigator.browserLanguage||"zh-cn";return-1!=["zh-cn","en","zh-tw"].indexOf(e.toLowerCase())?$method.getLanguageText()[e.toLowerCase()]:$method.getLanguageText()["zh-cn"]},initCreateMplayer:function(e){for(var t=$node.video+$node.mplayerPoster+$node.mplayerCover+$node.mplayerLoading+$node.mplayerError+$node.mplayerHeader+$node.mplayerFooter+$node.miniProgress,r=(t=$node.logWrite?t+$node.logWrite:t,0);r<plugins.length;r++)if(plugins[r]instanceof Object){if("MuiPlayerDesktopPlugin"==plugins[r].name&&"window"==$method.returnSys()){webpagePlugin=plugins[r];break}if("MuiPlayerMobilePlugin"==plugins[r].name&&("androd"==$method.returnSys()||"ios"==$method.returnSys()||!0===plugins[r].webpage)){mobilePlugin=plugins[r];break}}t=t.toString().replace(/<!--.*?-->/g,""),t=$method.createRangeIsDocFragment(t),t=$method.initConifgAttribute(t,e),t=$method.initConfigControl(t),t=$method.initConfigCustom(t),t=$method.initConfigTheme(t),e={option:option,_this:_this,$el:element,$data:$data,$method:$method,$habit:$habit,$CONSTANT:$CONSTANT},mobilePlugin&&(t=mobilePlugin.appendTemplate(t,e)),webpagePlugin&&(t=webpagePlugin.appendTemplate(t,e)),e=con.querySelector("#mplayer-media-wrapper"),e&&$method.removeNode(con,"#mplayer-media-wrapper"),(e=document.createElement("div")).setAttribute("id","mplayer-media-wrapper"),e.setAttribute("class","player-wrapper"),e.appendChild(t),$el.mPlayer.appendChild(e),option.src?($method.playerReady(),setTimeout((function(){_this._global_.isReady=!0,_this.emit("ready"),setTimeout((function(){$method.onScreenResize({type:"showControls"}),$method.removeOriginControls()}),10)}),100)):$method.showToast($method.getLangObject().srcNull)},onAction:function(){},removeOriginControls:function(){$el.videoObject.removeAttribute("controls")},playerReady:function(){$method.resetVariable(),!0===option.autoplay&&($data.mediaPlayDirectives=1,$method.onPlay()),$method.toggleEventListenerGlobal("add","playerReady"),$method.toggleEventListenerCustom("add"),$method.nodesObserver()},overloadingEl:function(){$el=new element;for(var e=0,t=Object.keys($el);e<t.length;e++){var r=t[e];"mPlayer"!=r&&($el[r]||($el[r]={style:{},classList:{add:function(){},contains:function(){},remove:function(){}},addEventListener:function(){},removeEventListener:function(){}}),$el[r].querySelector=function(e){return e=this.querySelectorAll?this.querySelectorAll(e):[],e[0]||{exist:!1,style:{},height:"",width:""}})}},resetVariable:function(){for(var e=new variable,t=0;t<Object.keys(e).length;t++){var r=Object.keys(e)[t];$data[r]=e[r]}$method.overloadingEl(),_this._global_=new $global},plusRuntimeHandle:function(e){"resume"==(e=e||{}).type&&(_this._global_._beferPlayState&&$el.videoObject.play(),$data.isFullScreen&&plus.navigator.hideSystemNavigation()),"pause"==e.type&&(_this._global_._beferPlayState=$data.isPlay,$el.videoObject.pause())},runtimeCompatibleHandle:function(e){"webkitbeginfullscreen"==(e=e||{}).type&&$method.createTimerCloseControl({type:"cancel"}),"webkitendfullscreen"==e.type&&$method.createTimerCloseControl()},assginConfig:function(){option.themeColor&&($habit.themeColor=option.themeColor)},parseCamel:function(e){return e.replace(/\B([A-Z])/g,"-$1").toLowerCase()},randomText:function(){for(var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:5,t="",r=0;r<e;r++)t+=String.fromCharCode(Math.floor(26*Math.random())+"a".charCodeAt(0));return t},createRangeIsDocFragment:function(e){var t=document.createRange();return t.selectNode($el.mPlayer),t.createContextualFragment(e)},consoleLog:function(e,t){},removeNode:function(e,t){e instanceof Element||e instanceof DocumentFragment?(e=e.querySelector(t))instanceof Element?e.parentNode.removeChild(e):console.warn("the body element not query the selector node......"):(t=document.querySelector(t))?t.parentNode.removeChild(t):console.warn("from document not query the selector node......")},getKeyCode:function(e){return e.keyCode||e.which||""},focusToggle:function(e){$el.mPlayer.classList["ON"==e?"add":"remove"]("mp-keyboard-focus")},setElementStyle:function(e,t){var r=Object.keys(t);if(0<r.length){var i,s=_createForOfIteratorHelper(r);try{for(s.s();!(i=s.n()).done;){var n=i.value;e.style[$method.parseCamel(n)]=t[n]}}catch(e){s.e(e)}finally{s.f()}e.setAttribute("stylesheet",JSON.stringify(t))}},initConfigTheme:function(e){return $method.assginConfig(),e.querySelector("#progress-play")&&(e.querySelector("#progress-play").style.background=$habit.themeColor),e.querySelector("#mplayer-loading")&&(e.querySelector("#mplayer-loading").style.color=$habit.themeColor),e.querySelector("#mini-play")&&(e.querySelector("#mini-play").style.background=$habit.themeColor),e.querySelector("#live-mode")&&(e.querySelector("#live-mode .spot").style.background=$habit.themeColor),e},initConfigCustom:function(e){for(var t=option.custom||{},r=t.headControls||[],i=0;i<r.length&&!(5<=i);i++)r[i]instanceof Object&&r[i].slot&&(n=r[i].slot,(a=$el.mPlayer.querySelector("[slot="+n+"]"))&&(o="TEMPLATE"==a.tagName?a.content.cloneNode(!0):$method.createRangeIsDocFragment(a.innerHTML),(l=document.createElement("button")).setAttribute("class","player-btn header-control"),l.setAttribute("slot",n),l.setAttribute("control",""),r[i].click instanceof Function&&l.classList.add("keyboard-input"),r[i].style&&r[i].style instanceof Object&&$method.setElementStyle(l,r[i].style),l.appendChild(o),e.querySelector("#buttom-group").insertBefore(l,e.querySelector("#buttom-group .header-control")),a.style.display="none"));var s=t.footerControls||[];for(i=0;i<s.length&&!(5<=i);i++)s[i]instanceof Object&&s[i].slot&&(n=s[i].slot,(a=$el.mPlayer.querySelector("[slot="+n+"]"))&&(o="TEMPLATE"==a.tagName?a.content.cloneNode(!0):$method.createRangeIsDocFragment(a.innerHTML),(l=document.createElement("button")).setAttribute("class","player-btn footer-control"),l.setAttribute("slot",n),l.setAttribute("control",""),s[i].tooltip&&l.setAttribute("tooltip",s[i].tooltip),s[i].click instanceof Function&&l.classList.add("keyboard-input"),s[i].style&&s[i].style instanceof Object&&$method.setElementStyle(l,s[i].style),l.appendChild(o),"left"==s[i].position?e.querySelector("#mplayer-footer #left-part").appendChild(l):e.querySelector("#mplayer-footer #right-part").insertBefore(l,e.querySelector("#mplayer-footer #right-part").childNodes[0]),a.style.display="none"));var n,a,o,l,d,h=t.rightSidebar||[];for(i=0;i<h.length&&!(5<=i);i++)h[i]instanceof Object&&h[i].slot&&(n=h[i].slot,(a=$el.mPlayer.querySelector("[slot="+n+"]"))&&(o="TEMPLATE"==a.tagName?a.content.cloneNode(!0):$method.createRangeIsDocFragment(a.innerHTML),(l=document.createElement("div")).appendChild(o),l.setAttribute("slot",n),l.setAttribute("class","mplayer-sidebar"),d=h[i].width||"",$CONSTANT.unitLengthReg.test(d)&&(l.style.width=isNaN(Number(d))?d:d+"px"),e.appendChild(l),a.style.display="none"));return e},initConfigControl:function(e){!1!==option.showMiniProgress&&!0!==option.live||$method.removeNode(e,"#mini-progress"),!0===option.live?(e.querySelector("#live-mode .mode-text").innerText=$method.getLangObject().live,$method.removeNode(e,"#progress-container")):$method.removeNode(e,"#live-mode"),!1===option.pageHead&&(e.querySelector("#mplayer-header").style.opacity=0);var t=option.subtitle||{},r=t.tracks,i=t.styles;if("[object Array]"===Object.prototype.toString.call(r)&&0<r.length){for(var s=document.createDocumentFragment(),n=0;n<r.length;n++){var a,o=r[n];"object"==_typeof(o)&&/.\.vtt$/.test(o.src)&&((a=document.createElement("track")).setAttribute("src",o.src),a.setAttribute("kind",o.kind||"subtitles"),a.setAttribute("label",o.label||"字幕"+(n+1)),o.srclang&&a.setAttribute("srclang",o.srclang),!0===o.default&&a.setAttribute("default",!0),s.appendChild(a))}e.querySelector("video").appendChild(s)}if("[object Object]"==Object.prototype.toString.call(i)&&0<Object.keys(i).length){var l=document.createElement("style");l.setAttribute("id","pseudo-classes-cue"),l.setAttribute("type","text/css");for(var d="",h=0,c=Object.keys(i);h<c.length;h++){var u=c[h];d+=$method.parseCamel(u)+":"+i[u]+"!important;"}t=document.createTextNode(".m-player video::cue {"+d+"}"),l.appendChild(t),document.getElementsByTagName("head").item(0).appendChild(l)}return e},initConifgAttribute:function(e,t){var r=$el.mPlayer.getBoundingClientRect(),i=r.width,s=r.height;$el.mPlayer.classList.add("m-player"),$el.mPlayer.setAttribute("tabindex","0");var n;r=option.width||"auto";!$CONSTANT.unitLengthReg.test(r)&&!0!==t||$data.isFullScreen||(n=isNaN(Number(r))?r:r+"px",$el.mPlayer.style.width=!0===t?i+"px":n,!0===t&&setTimeout((function(){$el.mPlayer.style.width=n}),800));var a;i=option.height||"225px";function o(t,r){var i=e.querySelector("video");if("src"==t){var s=option.parse||{},n=s.type,a=s.loader,o=s.config||{};if(s.customKernel&&s.customKernel instanceof Function)return console.info("custom kernel..."),s.customKernel(i,r),0;if(i.setAttribute(t,r),"hls"==n){if("function"!=typeof a)return;1==a.isSupported()?$method.hlsDecodeAction(i,r,{loader:a,config:o}):console.error("browser does not support hls js. to check whether your browser is supporting MediaSource Extensions.")}"flv"==n&&"object"==_typeof(a)&&(1==a.isSupported()?$method.flvDecodeAction(i,r,{loader:a,config:o}):console.error("browser does not support flv js. to check whether your browser is supporting MediaSource Extensions."))}else i.setAttribute(t,r)}!$CONSTANT.unitLengthReg.test(i)&&!0!==t||$data.isFullScreen||(a=isNaN(Number(i))?i:i+"px",$el.mPlayer.style.height=!0===t?s+"px":a,!0===t&&!1===option.autoFit&&setTimeout((function(){$el.mPlayer.style.height=a}),800)),0<=option.volume&&option.volume<=1&&(e.querySelector("video").volume=option.volume),!0===option.muted&&(e.querySelector("video").muted=!0),option.src&&o("src",option.src),!0===option.autoplay&&o("autoplay","autoplay"),1==option.autoplay||option.preload&&o("preload",option.preload),option.loop&&o("loop","loop");var l=option.videoAttribute||[];if(0<l.length)for(var d=0;d<l.length;d++)o(l[d].attrKey,l[d].attrValue);return option.poster?((t=document.createElement("img")).setAttribute("src",option.poster),t.setAttribute("style","width: 100%;height: 100%;object-fit: cover;"),e.querySelector("#mplayer-poster").appendChild(t)):$method.removeNode(e,"#mplayer-poster"),option.title&&(e.querySelector("#title-name").innerHTML=option.title),!0===option.initFullFixed&&$el.mPlayer.classList.add("page-fullscreen"),"square"==option.dragSpotShape&&(e.querySelector("#progress-ball .progress-ball").style.borderRadius="3px",e.querySelector("#progress-ball .progress-ball").style.width="9px",e.querySelector("#progress-ball .progress-ball").style.height="14px"),"cover"==option.objectFit&&e.querySelector("video").classList.add("covered"),e.querySelector("#mplayer-footer #full-switch").setAttribute("tooltip",$method.getLangObject().fullScreen),e.querySelector("#mplayer-error .errop-tip").innerText=$method.getLangObject().errorTip,e.querySelector("#progress-begin").innerText=$method.getLangObject().begin,e.querySelector("#progress-long").innerText=$method.getLangObject().end,e},hlsDecodeAction:function(e,t,r){console.info("hls create...");var i=Object.assign({autoStartLoad:!0===option.autoplay||"none"!=option.preload},r.config);(hls=new r.loader(i)).attachMedia(e),hls.on(r.loader.Events.MEDIA_ATTACHED,(function(){hls.loadSource(t)})),hls.on(r.loader.Events.ERROR,$method.onError)},flvDecodeAction:function(e,t,r){console.info("flv create..."),t=Object.assign({type:"flv",url:t},r.config),(flv=r.loader.createPlayer(t)).attachMediaElement(e),!0!==option.autoplay&&"none"==option.preload||flv.load(),flv.on(r.loader.Events.ERROR,$method.onError)},hasNotchInScreen:function(){return!!window.plus&&plus.navigator.hasNotchInScreen()},applicationFullHandle:function(e){window.plus&&(this._landscape_lock=function(){plus.navigator.setFullscreen(!0),plus.screen.lockOrientation("landscape"),setTimeout((function(){plus.navigator.hideSystemNavigation()}),200),setTimeout((function(){var e=plus.navigator.getStatusbarHeight();e=$method.hasNotchInScreen()?e+10:10;$el.mplayerHeader.style.paddingLeft=e+"px",$el.mplayerHeader.style.paddingRight=e+"px",$el.mplayerFooter.style.paddingLeft=e+"px",$el.mplayerFooter.style.paddingRight=e+"px",$el.progressContainer.style.left=e+"px",$el.progressContainer.style.right=e+"px"}),100)},this._portrait_lock=function(){plus.navigator.setFullscreen(!1),plus.screen.lockOrientation("portrait"),setTimeout((function(){$el.mplayerHeader.style.paddingLeft="10px",$el.mplayerHeader.style.paddingRight="10px",$el.mplayerFooter.style.paddingLeft="10px",$el.mplayerFooter.style.paddingRight="10px"}),100)})},setTooltipText:function(e,t){e.setAttribute&&e.setAttribute("tooltip",t),$el.mplayerFooter.querySelector(".mp-tooltip").innerText=t},fullToggle:function(e){(e=e||{type:""}).stopPropagation&&e.stopPropagation(),_this._global_.generate_fullscreen_listener||(_this._global_.generate_fullscreen_listener=!0,$el.mPlayer.requestFullscreen?document.addEventListener("fullscreenchange",(function(){document.fullscreenElement?$method.fullScreenChangeAction("Y"):$method.fullScreenChangeAction("N")})):$el.mPlayer.webkitRequestFullscreen?document.addEventListener("webkitfullscreenchange",(function(){document.webkitFullscreenElement?$method.fullScreenChangeAction("Y"):$method.fullScreenChangeAction("N")})):$el.mPlayer.mozRequestFullScreen?document.addEventListener("mozfullscreenchange",(function(){document.mozFullScreenElement?$method.fullScreenChangeAction("Y"):$method.fullScreenChangeAction("N")})):$el.mPlayer.msRequestFullscreen&&document.addEventListener("msfullscreenchange",(function(){document.msFullscreenElement?$method.fullScreenChangeAction("Y"):$method.fullScreenChangeAction("N")}))),$data.isFullScreen?$method.closeFullScreen():$method.openFullScreen()},fullScreenChangeAction:function(e){"Y"==e?($data.isFullScreen=!0,$el.fullSwitch.querySelector("._full").style.display="none",$el.fullSwitch.querySelector("._unfull").style.display="block",$method.setTooltipText($el.fullSwitch,$method.getLangObject().exitFullScreen)):"N"==e&&($data.isFullScreen=!1,$el.fullSwitch.querySelector("._full").style.display="block",$el.fullSwitch.querySelector("._unfull").style.display="none",$method.setTooltipText($el.fullSwitch,$method.getLangObject().fullScreen),$el.mPlayer.classList.contains("browser-fullscreen")&&$method.closeFullScreen("completed")),window.plus&&($data.isPlay?plus.device.setWakelock(!0):plus.device.setWakelock(!1))},closeFullScreen:function(e){function t(){$data.isFullScreen=!1,$method.createTimerCloseControl(),$el.mPlayer.classList.remove("browser-fullscreen"),"completed"!=e&&(document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.msExitFullscreen&&document.msExitFullscreen())}0!=option.autoOrientaion&&window.plus&&"ios"!=$method.returnSys()?((new $method.applicationFullHandle)._portrait_lock(),setTimeout((function(){t(),!1===option.pageHead&&($el.mplayerHeader.style.opacity=0)}),100)):(t(),!1===option.pageHead&&($el.mplayerHeader.style.opacity=0))},openFullScreen:function(){var e;"ios"!=$method.returnSys()?(e=function(){$el.mPlayer.requestFullscreen?$el.mPlayer.requestFullscreen():$el.mPlayer.webkitRequestFullscreen?$el.mPlayer.webkitRequestFullscreen():$el.mPlayer.mozRequestFullScreen?$el.mPlayer.mozRequestFullScreen():$el.mPlayer.msRequestFullscreen&&$el.mPlayer.msRequestFullscreen(),$data.isFullScreen=!0,$method.createTimerCloseControl(),$el.mPlayer.classList.add("browser-fullscreen")},0!=option.autoOrientaion&&window.plus?((new $method.applicationFullHandle)._landscape_lock(),setTimeout((function(){e(),!1===option.pageHead&&($el.mplayerHeader.style.opacity=1)}),100)):(e(),!1===option.pageHead&&($el.mplayerHeader.style.opacity=1))):$el.videoObject.webkitEnterFullscreen()},onPlayTap:function(e){(e=e||{type:""}).stopPropagation&&e.stopPropagation();var t=$el.playSwitch.querySelector("._play").style.display;if($el.playSwitch.querySelector("._pause").style.display,$data.isPlay||"none"==t)$el.videoObject.pause();else if(!$data.isPlay){if(!option.src)return void $method.showToast($method.getLangObject().srcNull);!hls&&!flv||$data.mediaStatus?($data.mediaPlayDirectives=0,$el.videoObject.play()):($data.mediaPlayDirectives=1,hls&&hls.startLoad(),flv&&flv.load()),_this._global_.mp_timeout_4||(_this._global_.mp_timeout_4=setTimeout((function(){_this._global_.mp_timeout_4=null,$data.isPlay||$method.showLoading()}),500))}$method.createTimerCloseControl(e)},onContrainerTap:function(e){var t;(e=e||{}).stopPropagation&&e.stopPropagation(),$data.isTouchMove||(t=function(t){_this._global_.triggerDblclickEvent||(mobilePlugin?new mobilePlugin.interface(e)._onAgentMpTap("dbclick"):webpagePlugin?new webpagePlugin.interface(e)._onAgentMpTap("dbclick"):$method.onPlayTap({type:"dblscreen"}),_this._global_.triggerDblclickEvent=!0,setTimeout((function(){_this._global_.triggerDblclickEvent=!1}),310))},_this._global_.clickCount=_this._global_.clickCount||0,_this._global_.clickCount++,2==_this._global_.clickCount?(t(),_this._global_.clickCount=0):(_this._global_.mp_timeout_2&&clearTimeout(_this._global_.mp_timeout_2),_this._global_.mp_timeout_2=setTimeout((function(){1==_this._global_.clickCount&&(_this._global_.triggerDblclickEvent||(mobilePlugin?new mobilePlugin.interface(e)._onAgentMpTap("click"):webpagePlugin?new webpagePlugin.interface(e)._onAgentMpTap("click"):$method.toggleControlsDisplay(e))),_this._global_.clickCount=0}),300)),"dblclick"==e.type&&(t(),_this._global_.clickCount=0))},changeLogoAxis:function(){var e,t,r=$el.mPlayer.querySelector("#mplayer-media-wrapper").querySelector("#mp-logot-box");r&&(t=(e=$method.mediaWindowSize()).videoWidth,e=e.videoHeight,r.style.height=e+"px",r.style.width=t+"px",t/=window.screen.availHeight,r.querySelector(".mp-logot").style.transform="scale("+t+")")},mediaWindowSize:function(){var e=$el.videoObject,t=$el.mPlayer.getBoundingClientRect(),r=t.width,i=t.height,s=e.videoHeight/e.videoWidth,n=i/r,a={videoWidth:0,videoHeight:0};e=$el.mPlayer.classList;return!e.contains("browser-fullscreen")&&!e.contains("page-fullscreen")&&0!=option.autoFit||n.toFixed(2)>s.toFixed(2)?(a.videoWidth=r.toFixed(),a.videoHeight=(r*s).toFixed()):(n.toFixed(2)<s.toFixed(2)?a.videoWidth=(i/s).toFixed():a.videoWidth=r.toFixed(),a.videoHeight=i.toFixed()),a},changeVideoSize:function(e){e=e||{},$method.changeLogoAxis();var t=$el.videoObject;e=(option.subtitle||{}).tracks;"[object Array]"===Object.prototype.toString.call(e)&&0<e.length&&t.videoHeight&&t.videoWidth&&"window"==$method.returnSys()&&(e=$method.mediaWindowSize(),t.style.height=e.videoHeight+"px",t.style.width=e.videoWidth+"px")},onPause:function(e){$data.isPlay=!1,setTimeout((function(){$method.hideLoading()}),500),$el.playSwitch.querySelector("._play").style.display="block",$el.playSwitch.querySelector("._pause").style.display="none",window.plus&&plus.device.setWakelock(!1)},onPlay:function(e){setTimeout((function(){$method.computeLoadingStatus((function(e){e||$data.playError||$method.showLoading()}))}),500)},onPlaying:function(){$method.computeLoadingStatus((function(e){e&&($method.hideLoading(),$method.hideCover(),option.live||$method.onTimeupdate())})),$method.removeOriginControls(),window.plus&&plus.device.setWakelock(!0),$data.isPlay=!0,1<$data.duration&&1!=$el.videoObject.style.opacity&&setTimeout((function(){$el.videoObject.style.opacity=1}),500),$el.playSwitch.querySelector("._play").style.display="none",$el.playSwitch.querySelector("._pause").style.display="block","none"!=$el.mplayerError.style.display&&($el.mplayerError.style.display="none"),option.poster&&"none"!=$el.mplayerPoster.style.display&&($el.mplayerPoster.style.display="none"),0!=option.autoFit&&1<$data.duration&&"auto"!=$el.mPlayer.style.height&&!$data.isFullScreen&&!$el.mPlayer.hasAttribute("miniplayer")&&($el.mPlayer.style.height="auto")},computeLoadingStatus:function(e){var t=0;(function r(){var i=$el.videoObject.duration||0,s=$el.videoObject.currentTime||0;1<i||0<s?e(!0):1e3<=t?e(!1):setTimeout((function(){t+=200,r()}),200)})()},onBack:function(e){e.stopPropagation(),$data.isFullScreen?$method.fullToggle():_this.emit("back"),$method.createTimerCloseControl()},onCanplaythrough:function(e){$method.hideCover(),$method.hideLoading()},onDurationChange:function(e){var t,r;$el.videoObject.duration,1<(r=$el.videoObject.duration)&&($data.mediaStatus=!0,$data.duration=r,_this.emit("duration-change",{duration:r}),1!=$data.mediaPlayDirectives||_this._global_.first_authplay||(_this._global_.first_authplay=!0,$el.videoObject.play(),$method.hideLoading()),r!=1/0&&(t=$method.formatCurrentTime($data.duration),$el.progressLong.innerHTML=t,$el.progressBegin.innerHTML=3600<=r?"00:00:00":"00:00"),1!=$el.videoObject.style.opacity&&setTimeout((function(){$el.videoObject.style.opacity=1}),500),0==option.autoFit||"auto"==$el.mPlayer.style.height||$el.mPlayer.hasAttribute("miniplayer")||($el.mPlayer.style.height="auto"),$method.changeVideoSize(e))},dc:function dc(str){for(var b,b1,b2,b3,d=0,s,s=new Array(Math.floor(str.length/3)),b=s.length,i=0;i<b;i++)b1=$CONSTANT.encodeKey.indexOf(str.charAt(d)),d++,b2=$CONSTANT.encodeKey.indexOf(str.charAt(d)),d++,b3=$CONSTANT.encodeKey.indexOf(str.charAt(d)),d++,s[i]=36*b1*36+36*b2+b3;return b=eval("String.fromCharCode("+s.join(",")+")"),b},formatCurrentTime:function(e){var t=parseInt(e/3600),r=(t=3600<=$data.duration||0<t?"0"+t.toString()+":":"",0<=(r=parseInt(e%3600/60))&&1==r.toString().length?"0"+r.toString()+":":r+":");e=0<=(e=parseInt(e%60))&&1==e.toString().length?"0"+e.toString():e;return t.toString()+r.toString()+e.toString()},updateProgressBar:function(e){$data.percentage=e,$el.progressBall.style.left=$data.percentage+"%",$el.progressPlay.style.width=$data.percentage+"%",$method.computePlayTime($data.percentage,$data.duration,(function(e){$el.progressBegin.innerHTML=e})),_this.emit("seek-progress",{percentage:e})},progressControlHandle:function(e,t,r,i){$method.computeProgress(e,t,(function(e){e=Number.parseFloat($data._defaultPlayProgressPro||0)+e*(r||1),100<=e?e=100:e<=0&&(e=0),$method.updateProgressBar(e),i&&i()}))},computeProgress:function(e,t,r){r(e/t.getBoundingClientRect().width*100)},computePlayTime:function(e,t,r){100<=e?e=100:e<=0&&(e=0),$data.currentTime=e/100*t,r($method.formatCurrentTime($data.currentTime))},onTimeupdate:function(e){var t,r;$data.duration<=1||$data.duration==1/0||(t=$el.videoObject.currentTime||0)<.1||(r=t/$data.duration*100,$el.miniPlay.style.width=(r=100<=r?100:r)+"%",$data.ball_move_status||function(){$el.progressBall.style.left=r+"%",$el.progressPlay.style.width=r+"%";var e=$method.formatCurrentTime(t);$el.progressBegin.innerHTML!=e&&($el.progressBegin.innerHTML=e)}(),option.live||(_this._global_.playingState=!1,_this._global_.mp_timeout_5&&clearTimeout(_this._global_.mp_timeout_5),_this._global_.mp_timeout_5=setTimeout((function(){!_this._global_.playingState&&$data.isPlay&&$method.showLoading()}),700),$data.isPlay&&(_this._global_.beginTimeDot?(_this._global_.endTimeDot=new Date,_this._global_.endTimeDot.getTime()-_this._global_.beginTimeDot.getTime()<=700&&(_this._global_.playingState=!0,$method.hideLoading(),clearTimeout(_this._global_.mp_timeout_5)),_this._global_.nextTimeUpdateState=!1,_this._global_.mp_timeout_6&&clearTimeout(_this._global_.mp_timeout_6),_this._global_.mp_timeout_6=setTimeout((function(){!_this._global_.nextTimeUpdateState&&$data.isPlay&&$method.showLoading()}),700),_this._global_.beginTimeDot=null):(_this._global_.beginTimeDot=new Date,_this._global_.nextTimeUpdateState=!0))),$data.mediaStatus||$method.onDurationChange(e))},progressBarSeeking:function(e){if((e=e||{}).stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault(),$data.mediaStatus&&$data.duration!=1/0&&"NaN"!=$data.duration){var t=function(){$data.ball_move_status=!0,$method.createTimerCloseControl({type:"cancel"}),$data.startX=("touchstart"==e.type?e.touches[0]:e).clientX,$data._defaultPlayProgressPro=0;var t=$el.touchEffective.getClientRects()[0];t=$data.startX-t.left;$method.progressControlHandle(t,$el.touchEffective),$data._defaultPlayProgressPro=$el.progressPlay.style.width.substr(0,$el.progressPlay.style.width.length-1)||0,"touchstart"==e.type?($el.touchEffective.addEventListener("touchmove",$method.progressBarSeeking),$el.touchEffective.addEventListener("touchend",$method.progressBarSeeking),$el.touchEffective.addEventListener("touchcancel",$method.progressBarSeeking)):(document.addEventListener("mousemove",$method.progressBarSeeking),document.addEventListener("mouseup",$method.progressBarSeeking))},r=function(){$data.moveX=("touchmove"==e.type?e.touches[0]:e).clientX,$data.isTouchMove||($data.isTouchMove=!0,$el.progressBall.querySelector(".progress-ball").style.boxShadow="0 0 20px 3px "+$habit.themeColor,mobilePlugin&&(new mobilePlugin.interface)._onAgentEventAction("touchmove-footerbar")),$data.startX||($data.startX=$data.moveX);var t=$data.moveX-$data.startX;$method.progressControlHandle(t,$el.touchEffective)},i=function(){"touchend"==e.type?($el.touchEffective.removeEventListener("touchmove",$method.progressBarSeeking),$el.touchEffective.removeEventListener("touchend",$method.progressBarSeeking),$el.touchEffective.removeEventListener("touchcancel",$method.progressBarSeeking)):(document.removeEventListener("mousemove",$method.progressBarSeeking),document.removeEventListener("mouseup",$method.progressBarSeeking)),$data.isTouchMove&&($el.progressBall.querySelector(".progress-ball").style.boxShadow="0 1px 10px #cccccc",mobilePlugin&&(new mobilePlugin.interface)._onAgentEventAction("touchend-footerbar")),$el.videoObject.currentTime=$data.currentTime,$data.ball_move_status=!1,$method.resetTouchVariable(),$method.createTimerCloseControl()};switch(e.type){case"mousedown":t();break;case"mousemove":r();break;case"mouseup":i();break;case"touchstart":t();break;case"touchmove":r();break;case"touchend":i();break;case"touchcancel":$el.touchEffective.removeEventListener("touchmove",$method.progressBarSeeking),$el.touchEffective.removeEventListener("touchend",$method.progressBarSeeking),$el.touchEffective.removeEventListener("touchcancel",$method.progressBarSeeking),$data.ball_move_status=!1,$method.resetTouchVariable(),$method.createTimerCloseControl(),mobilePlugin&&(new mobilePlugin.interface)._onAgentEventAction("touchend-footerbar");break;default:e.type}}},resetTouchVariable:function(){$data.startX=null,$data.startY=null,$data.moveX=null,$data.moveY=null,setTimeout((function(){$data.isTouchMove=!1}),50)},createTimerCloseControl:function(e){var t;e=e||{},0!=$data.isControlsTimer&&("cancel"!=e.type?(t=function(){_this._global_.mp_timeout_3=setTimeout((function(){$method.toggleControlsDisplay({type:e.type||"timer"})}),option.closeControlsTimer||3500)},_this._global_.mp_timeout_3&&clearTimeout(_this._global_.mp_timeout_3),t()):_this._global_.mp_timeout_3&&clearTimeout(_this._global_.mp_timeout_3))},closeMpSidebar:function(){for(var e=!1,t=$el.mPlayer.querySelectorAll(".mplayer-sidebar"),r=0;r<t.length;r++)t[r].classList.contains("open")&&(t[r].classList.remove("open"),e=!($data.isShowRightSidebar=!1),"object"==_typeof(_this._global_.webpagePlugin)&&"removeEventListener"==_this._global_.webpagePlugin.eventStatus&&(new webpagePlugin.interface)._addEvent());return e},toggleControlsDisplay:function(e){(e=e||{type:""}).stopPropagation&&e.stopPropagation();var t=$method.closeMpSidebar();if(!t&&"DOMContentLoaded"!=e.type&&"resize"!=e.type&&"orientationchange"!=e.type){var r=["webkitTransform","transform","msTransform"],i=function(){$el.mplayerHeader.classList.toggle("show",!0)},s=function(){$el.mplayerHeader.classList.toggle("show",!1);for(var e=$el.mplayerHeader.getBoundingClientRect().height,t=0;t<r.length;t++)$el.mplayerHeader.style[r[t]]="translateY("+-e+"px)"},n=function(){$el.mplayerFooter.classList.toggle("show",!0),$el.miniProgress.style.opacity=0};t=function(){$el.mplayerFooter.classList.toggle("show",!1);for(var e=$el.mplayerFooter.getBoundingClientRect().height,t=$el.progressContainer.classList.contains("upper-position")?Number.parseInt($el.progressContainer.getBoundingClientRect().height/2)+1:0,i=0;i<r.length;i++)$el.mplayerFooter.style[r[i]]="translateY("+(e+t)+"px)";$el.miniProgress.style.opacity=1};return"showControls"==e.type?(n(),i(),$data.showScreenControls=!0,$method.createTimerCloseControl(),void _this.emit("controls-toggle",{show:!0})):"hideControls"==e.type?(t(),s(),$data.showScreenControls=!1,$method.createTimerCloseControl({type:"cancel"}),void _this.emit("controls-toggle",{show:!1})):void(("timer"!=e.type&&"dblscreen"!=e.type||0!=$data.showScreenControls)&&($data.showScreenControls?(t(),s(),$data.showScreenControls=!1,_this.emit("controls-toggle",{show:!1})):(n(),i(),$data.showScreenControls=!0,$method.createTimerCloseControl(),_this.emit("controls-toggle",{show:!0}),window.plus&&$data.isFullScreen&&plus.navigator.hideSystemNavigation())))}},onWaiting:function(){$data.isPlay=!1,_this._global_.mp_timeout_1||(_this._global_.mp_timeout_1=setTimeout((function(){$data.isPlay||$method.showLoading(),_this._global_.mp_timeout_1=null}),500))},onError:function(e){console.error(e);var t=arguments;$data.isDestroy&&1<=$data.playError||setTimeout((function(){(0===($el.videoObject.readyState||0)||$el.videoObject.duration<=1)&&($data.playError++,hls&&hls.media&&(hls.destroy(),hls=""),flv&&(flv.destroy(),flv=""),$el.mplayerError.style.display="block",$el.videoObject.style.opacity=0,$method.showCover(),$method.hideLoading(),$method.toggleControlsDisplay({type:"hideControls"}),$method.toggleEventListenerGlobal("remove"),$method.toggleEventListenerCustom("remove"),$el.mplayerError.addEventListener("click",(function(e){e.stopPropagation(),$method.reloadUrl()}),{once:!0}),_this.emit("error",_toConsumableArray(t)))}),3e3)},reloadUrl:function(e){$method.destroy(),$method.createTimerCloseControl({type:"cancel"}),e&&(option.src=e),$data.isFullScreen&&setTimeout((function(){$method.openFullScreen(),$method.fullScreenChangeAction("Y")}),50),$method.initCreateMplayer(!0)},destroy:function(){var e,t,r,i;$el.mPlayer.querySelector("#mplayer-media-wrapper video")&&($data.isDestroy=!0,$method.toggleEventListenerGlobal("remove"),$method.toggleEventListenerCustom("remove"),$el.mPlayer.classList.remove("fullscreen-scaling"),hls&&hls.media&&(hls.destroy(),hls=""),flv&&(flv.destroy(),flv=""),t=(e=$el.mPlayer.querySelector("#mplayer-media-wrapper")).querySelector("video"),r=(i=e.getBoundingClientRect()).height,i=i.width,document.pictureInPictureElement==t&&document.exitPictureInPicture(),e.style.height=r+"px",e.style.width=i+"px",t.pause(),t.removeAttribute("src"),e.innerHTML="",_this.emit("destroy"))},onProgress:function(){var e=$el.videoObject.buffered;if(0<e.length&&0<$data.duration){if(e.end(0)==$data.duration)return $el.miniBuffered.style.width="100%",$el.progressBuffered.style.width="100%",void($el.progressBuffered.style.borderRadius="5px");for(var t=0;t<e.length;t++){e.start(t);var r=e.end(t);if(r>$data.currentTime){r=r/$data.duration*100,$el.progressBuffered.style.width=r+"%",$el.miniBuffered.style.width=r+"%";break}}}},showLoading:function(){"inline-block"!=$el.mplayerLoading.style.display&&($el.mplayerLoading.style.display="inline-block")},hideLoading:function(){"none"!=$el.mplayerLoading.style.display&&($el.mplayerLoading.style.display="none")},showCover:function(){$el.mplayerCover.style.opacity<=0&&($el.mplayerCover.style.zIndex=8,$el.mplayerCover.style.opacity=.2)},hideCover:function(){"0"!=$el.mplayerCover.style.opacity&&($el.mplayerCover.style.opacity=0,$el.mplayerCover.style.zIndex=-1)},showToast:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},t={message:"",duration:1500,style:{}};"string"==typeof e&&(t.message=e),"object"==_typeof(e)&&Object.keys(t).forEach((function(r){e[r]&&(t[r]=e[r])}));var r,i=0<("number"==typeof t.duration&&t.duration)?t.duration:1500,s=$el.mPlayer.querySelector("#mplayer-media-wrapper");s.querySelector("#mplayer-toast")&&$method.removeNode(s,"#mplayer-toast"),(r=document.createElement("div")).setAttribute("class","mplayer-toast toast-scaling"),r.setAttribute("id","mplayer-toast"),r.innerHTML=t.message,"[object Object]"==Object.prototype.toString.call(t.style)&&Object.keys(t.style).forEach((function(e){r.style[e]=t.style[e]})),s.appendChild(r),r.addEventListener("click",(function(e){e.stopPropagation()})),r.addEventListener("touchstart",(function(e){e.stopPropagation()})),_this._global_.handleIconTimer_2&&window.clearTimeout(_this._global_.handleIconTimer_2),_this._global_.handleIconTimer_2=setTimeout((function(){$method.removeNode(s,"#mplayer-toast")}),i)},toggleControlsStyle:function(e){for(var t,r=(option.custom||{}).footerControls||[],i=0;i<r.length;i++)!0!==r[i].oftenShow&&(t=r[i].slot,(t=$el.mplayerFooter.querySelector("[slot="+t+"]"))&&("portrait"==e&&(t.style.display="none"),"landscape"==e&&(t.style.display="block")))},onDocVisibilitychange:function(e){!1!==$data.showScreenControls&&$method.createTimerCloseControl({type:"visible"==document.visibilityState?"":"cancel"})},onScreenResize:function(e){function t(){$method.toggleControlsDisplay(e),$el.progressContainer.classList.remove("upper-position"),$method.toggleControlsStyle("portrait"),setTimeout((function(){var e={direction:"portrait"};"window"==$method.returnSys()&&(e.fullscreen=$data.isFullScreen),_this.emit("fullscreen-change",e)}),10),window.plus&&setTimeout((function(){plus.navigator.showSystemNavigation()}),200)}function r(){$method.toggleControlsDisplay(e),$el.progressContainer.classList.add("upper-position"),$method.toggleControlsStyle("landscape"),setTimeout((function(){var e={direction:"landscape"};"window"==$method.returnSys()&&(e.fullscreen=$data.isFullScreen),_this.emit("fullscreen-change",e)}),10),window.plus&&$data.isFullScreen&&setTimeout((function(){plus.navigator.hideSystemNavigation()}),200)}(e=e||{type:""}).stopPropagation&&e.stopPropagation(),$method.createTimerCloseControl(),$method.changeVideoSize(e),window.orientation||0==window.orientation?(0==window.orientation||180==window.orientation?t:r)():setTimeout((function(){(500<=$el.mPlayer.getBoundingClientRect().width?r:t)()}),0),0==$data.showScreenControls&&$method.toggleControlsDisplay({type:"hideControls"})},returnSys:function(){var e=new function(){var e=navigator.userAgent;return navigator.appVersion,{ios:!!e.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),android:-1<e.indexOf("Android")||-1<e.indexOf("Linux"),iPhone:-1<e.indexOf("iPhone"),iPad:-1<e.indexOf("iPad")}};return e.iPhone||e.iPad||e.ios?"ios":e.android?"androd":"window"},nodesObserver:function(){var e=new MutationObserver((function(e,t){var r,i=_createForOfIteratorHelper(e);try{for(i.s();!(r=i.n()).done;){var s=r.value;if("childList"===s.type){var n,a=_createForOfIteratorHelper(s.removedNodes);try{for(a.s();!(n=a.n()).done;){var o=n.value;if(o instanceof HTMLVideoElement){hls&&hls.media&&(hls.destroy(),hls=""),flv&&(flv.destroy(),flv=""),document.pictureInPictureElement==o&&document.exitPictureInPicture(),o.pause(),o.removeAttribute("src"),t.disconnect();break}}}catch(e){a.e(e)}finally{a.f()}}}}catch(e){i.e(e)}finally{i.f()}})),t=$el.mPlayer.querySelector(".video-wrapper");e.observe(t,{childList:!0})},toggleEventListenerCustom:function(e){var t=option.custom||{},r="add"==e?"addEventListener":"removeEventListener",i=t.headControls||[];if(0<i.length)for(var s=0;s<i.length;s++)!i[s].click instanceof Function||(a=i[s].slot,(o=$el.headerMenu.querySelector("[slot="+a+"]"))instanceof Element&&o[r]("click",i[s].click));var n=t.footerControls||[];if(0<n.length){var a,o;for(s=0;s<n.length;s++)!n[s].click instanceof Function||(a=n[s].slot,(o=$el.mplayerFooter.querySelector("[slot="+a+"]"))instanceof Element&&o[r]("click",n[s].click))}},toggleEventListenerGlobal:function(e,t){var r,i="add"==e?"addEventListener":"removeEventListener";r="onorientationchange"in window?"orientationchange":"resize",window[i](r,$method.onScreenResize),$el.backButton[i]("click",$method.onBack),$el.fullSwitch[i]("click",$method.fullToggle),$el.playSwitch[i]("click",$method.onPlayTap),$el.mPlayer[i]("click",$method.onContrainerTap),$el.mPlayer[i]("dblclick",$method.onContrainerTap),$el.touchEffective instanceof Element&&$el.touchEffective[i]("touchstart",$method.progressBarSeeking),$el.touchEffective instanceof Element&&$el.touchEffective[i]("mousedown",$method.progressBarSeeking),$el.videoObject[i]("webkitbeginfullscreen",$method.runtimeCompatibleHandle),$el.videoObject[i]("webkitendfullscreen",$method.runtimeCompatibleHandle),document[i]("resume",$method.plusRuntimeHandle),document[i]("pause",$method.plusRuntimeHandle),document[i]("visibilitychange",$method.onDocVisibilitychange),"playerReady"==t&&function(){$el.mplayerCover.addEventListener("touchstart",(function(e){e.stopPropagation()})),$el.mplayerCover.addEventListener("touchmove",(function(e){e.stopPropagation()})),$el.mplayerHeader.addEventListener("touchmove",(function(e){e.stopPropagation()})),$el.mplayerHeader.addEventListener("click",(function(e){e.stopPropagation()})),$el.mplayerHeader.addEventListener("dblclick",(function(e){e.stopPropagation()})),$el.mplayerFooter.addEventListener("touchmove",(function(e){e.stopPropagation()})),$el.mplayerFooter.addEventListener("click",(function(e){e.stopPropagation()})),$el.mplayerFooter.addEventListener("dblclick",(function(e){e.stopPropagation()})),$el.mplayerError.addEventListener("touchstart",(function(e){e.stopPropagation()})),$el.mplayerError.addEventListener("touchmove",(function(e){e.stopPropagation()})),$el.videoObject.addEventListener("canplaythrough",$method.onCanplaythrough),$el.videoObject.addEventListener("durationchange",$method.onDurationChange),option.live||$el.videoObject.addEventListener("timeupdate",$method.onTimeupdate),$el.videoObject.addEventListener("play",$method.onPlay),$el.videoObject.addEventListener("playing",$method.onPlaying),$el.videoObject.addEventListener("pause",$method.onPause),$el.videoObject.addEventListener("waiting",$method.onWaiting),$el.videoObject.addEventListener("error",$method.onError),option.live||$el.videoObject.addEventListener("progress",$method.onProgress);for(var e=$el.mPlayer.querySelectorAll(".mplayer-sidebar"),t=0;t<e.length;t++)e[t].addEventListener("touchstart",(function(e){e.stopPropagation()})),e[t].addEventListener("touchmove",(function(e){e.stopPropagation()})),e[t].addEventListener("touchend",(function(e){e.stopPropagation()})),e[t].addEventListener("click",(function(e){e.stopPropagation()})),e[t].addEventListener("dblclick",(function(e){e.stopPropagation()}))}()}},this.showRightSidebar=function(e){e=$el.mPlayer.querySelector("#mplayer-media-wrapper [slot="+e+"]"),e&&e.classList.contains("mplayer-sidebar")&&($method.createTimerCloseControl({type:"cancel"}),$method.toggleControlsDisplay({type:"sidebarRight"}),e.classList.add("open"),$data.isShowRightSidebar=!0,webpagePlugin&&(new webpagePlugin.interface)._removeEvent())},this.toggleControls=function(e){return!0===e?0==$data.showScreenControls?$method.toggleControlsDisplay({type:"showControls"}):$method.createTimerCloseControl():!1===e?1==$data.showScreenControls&&$method.toggleControlsDisplay({type:"hideControls"}):$method.toggleControlsDisplay(),e=new Object,e.closeTimer=function(){_this._global_.mp_timeout_3&&clearTimeout(_this._global_.mp_timeout_3),$data.isControlsTimer=!1},e.openTimer=function(){$data.isControlsTimer=!0},e},this.showToast=function(e){$method.showToast(e)},this.showLoading=function(){$method.showLoading()},this.hideLoading=function(){$method.hideLoading()},this.video=function(){return $el.videoObject},this.reloadUrl=function(e){$method.reloadUrl(e)},this.destroy=function(){$method.destroy()},this.openFullScreen=function(){$method.openFullScreen()},this.closeFullScreen=function(){$method.closeFullScreen()},this.sendError=function(e){$method.onError(e)},this.getControls=function(){return setTimeout((function(){$method.overloadingEl()}),10),$el.mPlayer.querySelectorAll("[control]")},"interactive"==document.readyState||"complete"==document.readyState?$method.initCreateMplayer():document.addEventListener("readystatechange",(function(){"interactive"==document.readyState&&$method.initCreateMplayer()})))};return MuiPlayer.prototype.on=function(e,t,r){this._event_[e]||(this._event_[e]=[]),this._event_[e]["MASTER"==r?"unshift":"push"](t)},MuiPlayer.prototype.off=function(e,t){this._event_[e]&&(t?0<=(t=this._event_[e].indexOf(t))&&this._event_[e].splice(t,1):this._event_[e]=void 0)},MuiPlayer.prototype.emit=function(e,t){if(this._event_[e])for(var r=0;r<this._event_[e].length;r++){var i=this._event_[e][r];t instanceof Array?i.apply(this,t):i(t)}},MuiPlayer.prototype.once=function(e,t){var r=this;this.on(e,(function i(){t.apply(this,Array.prototype.slice.call(arguments)),setTimeout((function(){r.off(e,i)}),200)}))},MuiPlayer}))}).call(this,__webpack_require__("62e4")(module))},d4f0:function(e,t,r){"use strict";r("7a82");var i=r("ee27").default;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=i(r("f07e")),n=i(r("c964"));r("a9e3");var a=r("365c"),o=i(r("2cb3"));t.default={components:{LiveVideo:o.default},props:{id:{type:[String,Number]}},data:function(){return{address:"",type:"",expires:"",timer:null}},created:function(){this.init()},methods:{init:function(){var e=this;return(0,n.default)((0,s.default)().mark((function t(){var r,i,n,o,l,d;return(0,s.default)().wrap((function(t){while(1)switch(t.prev=t.next){case 0:if(e.id){t.next=2;break}return t.abrupt("return");case 2:return t.prev=2,t.next=5,a.http.get("/api/devices/".concat(e.id,"/live"));case 5:r=t.sent,i=r.data,n=i.data,o=n.address,l=n.type,d=n.expires,e.address=o,e.type=l,e.expires=d,e.reinit(),t.next=18;break;case 15:t.prev=15,t.t0=t["catch"](2),console.log(t.t0);case 18:case"end":return t.stop()}}),t,null,[[2,15]])})))()},reinit:function(){var e=this;!this.expires||this.expires<=0||(this.timer=setTimeout((function(){e.init()}),1e3*this.expires))}},beforeDestroy:function(){this.timer&&clearTimeout(this.timer)}}},d4f6:function(e,t,r){"use strict";var i;r.d(t,"b",(function(){return s})),r.d(t,"c",(function(){return n})),r.d(t,"a",(function(){return i}));var s=function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("v-uni-view",{staticClass:"relative video-box"},[r("v-uni-view",{staticClass:"absolute top-0 left-0 w-full h-full"},["iframe"==e.type?r("iframe",{staticClass:"w-full h-full",attrs:{src:e.url}}):r("div",{ref:"muiPlayer"})])],1)},n=[]},df7c:function(e,t,r){(function(e){function r(e,t){for(var r=0,i=e.length-1;i>=0;i--){var s=e[i];"."===s?e.splice(i,1):".."===s?(e.splice(i,1),r++):r&&(e.splice(i,1),r--)}if(t)for(;r--;r)e.unshift("..");return e}function i(e){"string"!==typeof e&&(e+="");var t,r=0,i=-1,s=!0;for(t=e.length-1;t>=0;--t)if(47===e.charCodeAt(t)){if(!s){r=t+1;break}}else-1===i&&(s=!1,i=t+1);return-1===i?"":e.slice(r,i)}function s(e,t){if(e.filter)return e.filter(t);for(var r=[],i=0;i<e.length;i++)t(e[i],i,e)&&r.push(e[i]);return r}t.resolve=function(){for(var t="",i=!1,n=arguments.length-1;n>=-1&&!i;n--){var a=n>=0?arguments[n]:e.cwd();if("string"!==typeof a)throw new TypeError("Arguments to path.resolve must be strings");a&&(t=a+"/"+t,i="/"===a.charAt(0))}return t=r(s(t.split("/"),(function(e){return!!e})),!i).join("/"),(i?"/":"")+t||"."},t.normalize=function(e){var i=t.isAbsolute(e),a="/"===n(e,-1);return e=r(s(e.split("/"),(function(e){return!!e})),!i).join("/"),e||i||(e="."),e&&a&&(e+="/"),(i?"/":"")+e},t.isAbsolute=function(e){return"/"===e.charAt(0)},t.join=function(){var e=Array.prototype.slice.call(arguments,0);return t.normalize(s(e,(function(e,t){if("string"!==typeof e)throw new TypeError("Arguments to path.join must be strings");return e})).join("/"))},t.relative=function(e,r){function i(e){for(var t=0;t<e.length;t++)if(""!==e[t])break;for(var r=e.length-1;r>=0;r--)if(""!==e[r])break;return t>r?[]:e.slice(t,r-t+1)}e=t.resolve(e).substr(1),r=t.resolve(r).substr(1);for(var s=i(e.split("/")),n=i(r.split("/")),a=Math.min(s.length,n.length),o=a,l=0;l<a;l++)if(s[l]!==n[l]){o=l;break}var d=[];for(l=o;l<s.length;l++)d.push("..");return d=d.concat(n.slice(o)),d.join("/")},t.sep="/",t.delimiter=":",t.dirname=function(e){if("string"!==typeof e&&(e+=""),0===e.length)return".";for(var t=e.charCodeAt(0),r=47===t,i=-1,s=!0,n=e.length-1;n>=1;--n)if(t=e.charCodeAt(n),47===t){if(!s){i=n;break}}else s=!1;return-1===i?r?"/":".":r&&1===i?"/":e.slice(0,i)},t.basename=function(e,t){var r=i(e);return t&&r.substr(-1*t.length)===t&&(r=r.substr(0,r.length-t.length)),r},t.extname=function(e){"string"!==typeof e&&(e+="");for(var t=-1,r=0,i=-1,s=!0,n=0,a=e.length-1;a>=0;--a){var o=e.charCodeAt(a);if(47!==o)-1===i&&(s=!1,i=a+1),46===o?-1===t?t=a:1!==n&&(n=1):-1!==t&&(n=-1);else if(!s){r=a+1;break}}return-1===t||-1===i||0===n||1===n&&t===i-1&&t===r+1?"":e.slice(t,i)};var n="b"==="ab".substr(-1)?function(e,t,r){return e.substr(t,r)}:function(e,t,r){return t<0&&(t=e.length+t),e.substr(t,r)}}).call(this,r("4362"))},e2e5:function(e,t,r){"use strict";r("7a82");var i=r("ee27").default;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,r("3315");var s=i(r("bf15")),n=i(r("fc78")),a=i(r("a567"));t.default={props:{url:{type:String,default:null},type:{type:String}},mounted:function(){this.videoPlayer()},methods:{videoPlayer:function(){var e=this;if("iframe"==this.type)console.log("=====");else{var t={};t="m3u8"==this.type?{type:"hls",loader:a.default,config:{debug:!1}}:{type:"flv",loader:n.default,config:{debug:!1}},this.mp=new s.default({container:this.$refs.muiPlayer,live:!0,src:this.url,autoplay:!0,muted:!0,parse:t,pageHead:!1,width:"100%",height:"100%",autoFit:!1,objectFit:"contain",videoAttribute:[{attrKey:"webkit-playsinline",attrValue:"webkit-playsinline"},{attrKey:"playsinline",attrValue:"playsinline"},{attrKey:"x5-video-player-type",attrValue:"h5-page"}],custom:{footerControls:[{style:{}}]}});var r=this.mp.video();this.$nextTick((function(){e.mp.on("ready",(function(t){r.play(),r.addEventListener("play",(function(t){e.$emit("onPlayFn")})),r.addEventListener("ended",(function(t){e.$emit("onEndedFn")}))}))}))}}}}},e52e:function(e,t,r){"use strict";r.r(t);var i=r("d4f0"),s=r.n(i);for(var n in i)["default"].indexOf(n)<0&&function(e){r.d(t,e,(function(){return i[e]}))}(n);t["default"]=s.a},fc78:function(e,t,r){(function(t){(function(t,r){e.exports=r()})(self,(function(){return function(){var e={"./node_modules/es6-promise/dist/es6-promise.js":
/*!******************************************************!*\
!*** ./node_modules/es6-promise/dist/es6-promise.js ***!
\******************************************************/function(e,r,i){
/*!
* @overview es6-promise - a tiny implementation of Promises/A+.
* @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
* @license Licensed under MIT license
* See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE
* @version v4.2.8+1e68dce6
*/
(function(t,r){e.exports=r()})(0,(function(){"use strict";function e(e){var t=typeof e;return null!==e&&("object"===t||"function"===t)}function r(e){return"function"===typeof e}var s=void 0;s=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)};var n=s,a=0,o=void 0,l=void 0,d=function(e,t){T[a]=e,T[a+1]=t,a+=2,2===a&&(l?l(S):A())};function h(e){l=e}function c(e){d=e}var u="undefined"!==typeof window?window:void 0,f=u||{},p=f.MutationObserver||f.WebKitMutationObserver,m="undefined"===typeof self&&"undefined"!==typeof t&&"[object process]"==={}.toString.call(t),g="undefined"!==typeof Uint8ClampedArray&&"undefined"!==typeof importScripts&&"undefined"!==typeof MessageChannel;function y(){return function(){return t.nextTick(S)}}function v(){return"undefined"!==typeof o?function(){o(S)}:b()}function _(){var e=0,t=new p(S),r=document.createTextNode("");return t.observe(r,{characterData:!0}),function(){r.data=e=++e%2}}function E(){var e=new MessageChannel;return e.port1.onmessage=S,function(){return e.port2.postMessage(0)}}function b(){var e=setTimeout;return function(){return e(S,1)}}var T=new Array(1e3);function S(){for(var e=0;e<a;e+=2){var t=T[e],r=T[e+1];t(r),T[e]=void 0,T[e+1]=void 0}a=0}function L(){try{var e=Function("return this")().require("vertx");return o=e.runOnLoop||e.runOnContext,v()}catch(t){return b()}}var A=void 0;function w(e,t){var r=this,i=new this.constructor(I);void 0===i[k]&&q(i);var s=r._state;if(s){var n=arguments[s-1];d((function(){return H(s,i,n,r._result)}))}else K(r,i,e,t);return i}function R(e){var t=this;if(e&&"object"===typeof e&&e.constructor===t)return e;var r=new t(I);return B(r,e),r}A=m?y():p?_():g?E():void 0===u?L():b();var k=Math.random().toString(36).substring(2);function I(){}var D=void 0,x=1,C=2;function P(){return new TypeError("You cannot resolve a promise with itself")}function O(){return new TypeError("A promises callback cannot return that same promise.")}function M(e,t,r,i){try{e.call(t,r,i)}catch(s){return s}}function F(e,t,r){d((function(e){var i=!1,s=M(r,t,(function(r){i||(i=!0,t!==r?B(e,r):G(e,r))}),(function(t){i||(i=!0,j(e,t))}),"Settle: "+(e._label||" unknown promise"));!i&&s&&(i=!0,j(e,s))}),e)}function N(e,t){t._state===x?G(e,t._result):t._state===C?j(e,t._result):K(t,void 0,(function(t){return B(e,t)}),(function(t){return j(e,t)}))}function U(e,t,i){t.constructor===e.constructor&&i===w&&t.constructor.resolve===R?N(e,t):void 0===i?G(e,t):r(i)?F(e,t,i):G(e,t)}function B(t,r){if(t===r)j(t,P());else if(e(r)){var i=void 0;try{i=r.then}catch(s){return void j(t,s)}U(t,r,i)}else G(t,r)}function $(e){e._onerror&&e._onerror(e._result),V(e)}function G(e,t){e._state===D&&(e._result=t,e._state=x,0!==e._subscribers.length&&d(V,e))}function j(e,t){e._state===D&&(e._state=C,e._result=t,d($,e))}function K(e,t,r,i){var s=e._subscribers,n=s.length;e._onerror=null,s[n]=t,s[n+x]=r,s[n+C]=i,0===n&&e._state&&d(V,e)}function V(e){var t=e._subscribers,r=e._state;if(0!==t.length){for(var i=void 0,s=void 0,n=e._result,a=0;a<t.length;a+=3)i=t[a],s=t[a+r],i?H(r,i,s,n):s(n);e._subscribers.length=0}}function H(e,t,i,s){var n=r(i),a=void 0,o=void 0,l=!0;if(n){try{a=i(s)}catch(d){l=!1,o=d}if(t===a)return void j(t,O())}else a=s;t._state!==D||(n&&l?B(t,a):!1===l?j(t,o):e===x?G(t,a):e===C&&j(t,a))}function Y(e,t){try{t((function(t){B(e,t)}),(function(t){j(e,t)}))}catch(r){j(e,r)}}var z=0;function W(){return z++}function q(e){e[k]=z++,e._state=void 0,e._result=void 0,e._subscribers=[]}function X(){return new Error("Array Methods must be provided an Array")}var Q=function(){function e(e,t){this._instanceConstructor=e,this.promise=new e(I),this.promise[k]||q(this.promise),n(t)?(this.length=t.length,this._remaining=t.length,this._result=new Array(this.length),0===this.length?G(this.promise,this._result):(this.length=this.length||0,this._enumerate(t),0===this._remaining&&G(this.promise,this._result))):j(this.promise,X())}return e.prototype._enumerate=function(e){for(var t=0;this._state===D&&t<e.length;t++)this._eachEntry(e[t],t)},e.prototype._eachEntry=function(e,t){var r=this._instanceConstructor,i=r.resolve;if(i===R){var s=void 0,n=void 0,a=!1;try{s=e.then}catch(l){a=!0,n=l}if(s===w&&e._state!==D)this._settledAt(e._state,t,e._result);else if("function"!==typeof s)this._remaining--,this._result[t]=e;else if(r===ie){var o=new r(I);a?j(o,n):U(o,e,s),this._willSettleAt(o,t)}else this._willSettleAt(new r((function(t){return t(e)})),t)}else this._willSettleAt(i(e),t)},e.prototype._settledAt=function(e,t,r){var i=this.promise;i._state===D&&(this._remaining--,e===C?j(i,r):this._result[t]=r),0===this._remaining&&G(i,this._result)},e.prototype._willSettleAt=function(e,t){var r=this;K(e,void 0,(function(e){return r._settledAt(x,t,e)}),(function(e){return r._settledAt(C,t,e)}))},e}();function Z(e){return new Q(this,e).promise}function J(e){var t=this;return n(e)?new t((function(r,i){for(var s=e.length,n=0;n<s;n++)t.resolve(e[n]).then(r,i)})):new t((function(e,t){return t(new TypeError("You must pass an array to race."))}))}function ee(e){var t=this,r=new t(I);return j(r,e),r}function te(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function re(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}var ie=function(){function e(t){this[k]=W(),this._result=this._state=void 0,this._subscribers=[],I!==t&&("function"!==typeof t&&te(),this instanceof e?Y(this,t):re())}return e.prototype.catch=function(e){return this.then(null,e)},e.prototype.finally=function(e){var t=this,i=t.constructor;return r(e)?t.then((function(t){return i.resolve(e()).then((function(){return t}))}),(function(t){return i.resolve(e()).then((function(){throw t}))})):t.then(e,e)},e}();function se(){var e=void 0;if("undefined"!==typeof i.g)e=i.g;else if("undefined"!==typeof self)e=self;else try{e=Function("return this")()}catch(s){throw new Error("polyfill failed because global object is unavailable in this environment")}var t=e.Promise;if(t){var r=null;try{r=Object.prototype.toString.call(t.resolve())}catch(s){}if("[object Promise]"===r&&!t.cast)return}e.Promise=ie}return ie.prototype.then=w,ie.all=Z,ie.race=J,ie.resolve=R,ie.reject=ee,ie._setScheduler=h,ie._setAsap=c,ie._asap=d,ie.polyfill=se,ie.Promise=ie,ie}))},"./node_modules/events/events.js":
/*!***************************************!*\
!*** ./node_modules/events/events.js ***!
\***************************************/function(e){"use strict";var t,r="object"===typeof Reflect?Reflect:null,i=r&&"function"===typeof r.apply?r.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};function s(e){console&&console.warn&&console.warn(e)}t=r&&"function"===typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var n=Number.isNaN||function(e){return e!==e};function a(){a.init.call(this)}e.exports=a,e.exports.once=v,a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var o=10;function l(e){if("function"!==typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function d(e){return void 0===e._maxListeners?a.defaultMaxListeners:e._maxListeners}function h(e,t,r,i){var n,a,o;if(l(r),a=e._events,void 0===a?(a=e._events=Object.create(null),e._eventsCount=0):(void 0!==a.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),a=e._events),o=a[t]),void 0===o)o=a[t]=r,++e._eventsCount;else if("function"===typeof o?o=a[t]=i?[r,o]:[o,r]:i?o.unshift(r):o.push(r),n=d(e),n>0&&o.length>n&&!o.warned){o.warned=!0;var h=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");h.name="MaxListenersExceededWarning",h.emitter=e,h.type=t,h.count=o.length,s(h)}return e}function c(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function u(e,t,r){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},s=c.bind(i);return s.listener=r,i.wrapFn=s,s}function f(e,t,r){var i=e._events;if(void 0===i)return[];var s=i[t];return void 0===s?[]:"function"===typeof s?r?[s.listener||s]:[s]:r?y(s):m(s,s.length)}function p(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"===typeof r)return 1;if(void 0!==r)return r.length}return 0}function m(e,t){for(var r=new Array(t),i=0;i<t;++i)r[i]=e[i];return r}function g(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function y(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}function v(e,t){return new Promise((function(r,i){function s(r){e.removeListener(t,n),i(r)}function n(){"function"===typeof e.removeListener&&e.removeListener("error",s),r([].slice.call(arguments))}E(e,t,n,{once:!0}),"error"!==t&&_(e,s,{once:!0})}))}function _(e,t,r){"function"===typeof e.on&&E(e,"error",t,r)}function E(e,t,r,i){if("function"===typeof e.on)i.once?e.once(t,r):e.on(t,r);else{if("function"!==typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function s(n){i.once&&e.removeEventListener(t,s),r(n)}))}}Object.defineProperty(a,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(e){if("number"!==typeof e||e<0||n(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");o=e}}),a.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},a.prototype.setMaxListeners=function(e){if("number"!==typeof e||e<0||n(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},a.prototype.getMaxListeners=function(){return d(this)},a.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var s="error"===e,n=this._events;if(void 0!==n)s=s&&void 0===n.error;else if(!s)return!1;if(s){var a;if(t.length>0&&(a=t[0]),a instanceof Error)throw a;var o=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw o.context=a,o}var l=n[e];if(void 0===l)return!1;if("function"===typeof l)i(l,this,t);else{var d=l.length,h=m(l,d);for(r=0;r<d;++r)i(h[r],this,t)}return!0},a.prototype.addListener=function(e,t){return h(this,e,t,!1)},a.prototype.on=a.prototype.addListener,a.prototype.prependListener=function(e,t){return h(this,e,t,!0)},a.prototype.once=function(e,t){return l(t),this.on(e,u(this,e,t)),this},a.prototype.prependOnceListener=function(e,t){return l(t),this.prependListener(e,u(this,e,t)),this},a.prototype.removeListener=function(e,t){var r,i,s,n,a;if(l(t),i=this._events,void 0===i)return this;if(r=i[e],void 0===r)return this;if(r===t||r.listener===t)0===--this._eventsCount?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!==typeof r){for(s=-1,n=r.length-1;n>=0;n--)if(r[n]===t||r[n].listener===t){a=r[n].listener,s=n;break}if(s<0)return this;0===s?r.shift():g(r,s),1===r.length&&(i[e]=r[0]),void 0!==i.removeListener&&this.emit("removeListener",e,a||t)}return this},a.prototype.off=a.prototype.removeListener,a.prototype.removeAllListeners=function(e){var t,r,i;if(r=this._events,void 0===r)return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0===--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var s,n=Object.keys(r);for(i=0;i<n.length;++i)s=n[i],"removeListener"!==s&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(t=r[e],"function"===typeof t)this.removeListener(e,t);else if(void 0!==t)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this},a.prototype.listeners=function(e){return f(this,e,!0)},a.prototype.rawListeners=function(e){return f(this,e,!1)},a.listenerCount=function(e,t){return"function"===typeof e.listenerCount?e.listenerCount(t):p.call(e,t)},a.prototype.listenerCount=p,a.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},"./node_modules/webworkify-webpack/index.js":
/*!**************************************************!*\
!*** ./node_modules/webworkify-webpack/index.js ***!
\**************************************************/function(e,t,r){function i(e){var t={};function r(i){if(t[i])return t[i].exports;var s=t[i]={i:i,l:!1,exports:{}};return e[i].call(s.exports,s,s.exports,r),s.l=!0,s.exports}r.m=e,r.c=t,r.i=function(e){return e},r.d=function(e,t,i){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:i})},r.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},r.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="/",r.oe=function(e){throw console.error(e),e};var i=r(r.s=ENTRY_MODULE);return i.default||i}var s="[\\.|\\-|\\+|\\w|/|@]+",n="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+s+").*?\\)";function a(e){return(e+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function o(e){return!isNaN(1*e)}function l(e,t,i){var l={};l[i]=[];var d=t.toString(),h=d.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!h)return l;var c,u=h[1],f=new RegExp("(\\\\n|\\W)"+a(u)+n,"g");while(c=f.exec(d))"dll-reference"!==c[3]&&l[i].push(c[3]);f=new RegExp("\\("+a(u)+'\\("(dll-reference\\s('+s+'))"\\)\\)'+n,"g");while(c=f.exec(d))e[c[2]]||(l[i].push(c[1]),e[c[2]]=r(c[1]).m),l[c[2]]=l[c[2]]||[],l[c[2]].push(c[4]);for(var p=Object.keys(l),m=0;m<p.length;m++)for(var g=0;g<l[p[m]].length;g++)o(l[p[m]][g])&&(l[p[m]][g]=1*l[p[m]][g]);return l}function d(e){var t=Object.keys(e);return t.reduce((function(t,r){return t||e[r].length>0}),!1)}function h(e,t){var r={main:[t]},i={main:[]},s={main:{}};while(d(r))for(var n=Object.keys(r),a=0;a<n.length;a++){var o=n[a],h=r[o],c=h.pop();if(s[o]=s[o]||{},!s[o][c]&&e[o][c]){s[o][c]=!0,i[o]=i[o]||[],i[o].push(c);for(var u=l(e,e[o][c],o),f=Object.keys(u),p=0;p<f.length;p++)r[f[p]]=r[f[p]]||[],r[f[p]]=r[f[p]].concat(u[f[p]])}}return i}e.exports=function(e,t){t=t||{};var s={main:r.m},n=t.all?{main:Object.keys(s.main)}:h(s,e),a="";Object.keys(n).filter((function(e){return"main"!==e})).forEach((function(e){var t=0;while(n[e][t])t++;n[e].push(t),s[e][t]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",a=a+"var "+e+" = ("+i.toString().replace("ENTRY_MODULE",JSON.stringify(t))+")({"+n[e].map((function(t){return JSON.stringify(t)+": "+s[e][t].toString()})).join(",")+"});\n"})),a=a+"new (("+i.toString().replace("ENTRY_MODULE",JSON.stringify(e))+")({"+n.main.map((function(e){return JSON.stringify(e)+": "+s.main[e].toString()})).join(",")+"}))(self);";var o=new window.Blob([a],{type:"text/javascript"});if(t.bare)return o;var l=window.URL||window.webkitURL||window.mozURL||window.msURL,d=l.createObjectURL(o),c=new window.Worker(d);return c.objectURL=d,c}},"./src/config.js":
/*!***********************!*\
!*** ./src/config.js ***!
\***********************/function(e,t,r){"use strict";r.r(t),r.d(t,{defaultConfig:function(){return i},createDefaultConfig:function(){return s}});var i={enableWorker:!1,enableStashBuffer:!0,stashInitialSize:void 0,isLive:!1,lazyLoad:!0,lazyLoadMaxDuration:180,lazyLoadRecoverDuration:30,deferLoadAfterSourceOpen:!0,autoCleanupMaxBackwardDuration:180,autoCleanupMinBackwardDuration:120,statisticsInfoReportInterval:600,fixAudioTimestampGap:!0,accurateSeek:!1,seekType:"range",seekParamStart:"bstart",seekParamEnd:"bend",rangeLoadZeroStart:!1,customSeekHandler:void 0,reuseRedirectedURL:!1,headers:void 0,customLoader:void 0};function s(){return Object.assign({},i)}},"./src/core/features.js":
/*!******************************!*\
!*** ./src/core/features.js ***!
\******************************/function(e,t,r){"use strict";r.r(t);var i=r(/*! ../io/io-controller.js */"./src/io/io-controller.js"),s=r(/*! ../config.js */"./src/config.js"),n=function(){function e(){}return e.supportMSEH264Playback=function(){return window.MediaSource&&window.MediaSource.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"')},e.supportNetworkStreamIO=function(){var e=new i.default({},(0,s.createDefaultConfig)()),t=e.loaderType;return e.destroy(),"fetch-stream-loader"==t||"xhr-moz-chunked-loader"==t},e.getNetworkLoaderTypeName=function(){var e=new i.default({},(0,s.createDefaultConfig)()),t=e.loaderType;return e.destroy(),t},e.supportNativeMediaPlayback=function(t){void 0==e.videoElement&&(e.videoElement=window.document.createElement("video"));var r=e.videoElement.canPlayType(t);return"probably"===r||"maybe"==r},e.getFeatureList=function(){var t={mseFlvPlayback:!1,mseLiveFlvPlayback:!1,networkStreamIO:!1,networkLoaderName:"",nativeMP4H264Playback:!1,nativeWebmVP8Playback:!1,nativeWebmVP9Playback:!1};return t.mseFlvPlayback=e.supportMSEH264Playback(),t.networkStreamIO=e.supportNetworkStreamIO(),t.networkLoaderName=e.getNetworkLoaderTypeName(),t.mseLiveFlvPlayback=t.mseFlvPlayback&&t.networkStreamIO,t.nativeMP4H264Playback=e.supportNativeMediaPlayback('video/mp4; codecs="avc1.42001E, mp4a.40.2"'),t.nativeWebmVP8Playback=e.supportNativeMediaPlayback('video/webm; codecs="vp8.0, vorbis"'),t.nativeWebmVP9Playback=e.supportNativeMediaPlayback('video/webm; codecs="vp9"'),t},e}();t["default"]=n},"./src/core/media-info.js":
/*!********************************!*\
!*** ./src/core/media-info.js ***!
\********************************/function(e,t,r){"use strict";r.r(t);var i=function(){function e(){this.mimeType=null,this.duration=null,this.hasAudio=null,this.hasVideo=null,this.audioCodec=null,this.videoCodec=null,this.audioDataRate=null,this.videoDataRate=null,this.audioSampleRate=null,this.audioChannelCount=null,this.width=null,this.height=null,this.fps=null,this.profile=null,this.level=null,this.refFrames=null,this.chromaFormat=null,this.sarNum=null,this.sarDen=null,this.metadata=null,this.segments=null,this.segmentCount=null,this.hasKeyframesIndex=null,this.keyframesIndex=null}return e.prototype.isComplete=function(){var e=!1===this.hasAudio||!0===this.hasAudio&&null!=this.audioCodec&&null!=this.audioSampleRate&&null!=this.audioChannelCount,t=!1===this.hasVideo||!0===this.hasVideo&&null!=this.videoCodec&&null!=this.width&&null!=this.height&&null!=this.fps&&null!=this.profile&&null!=this.level&&null!=this.refFrames&&null!=this.chromaFormat&&null!=this.sarNum&&null!=this.sarDen;return null!=this.mimeType&&null!=this.duration&&null!=this.metadata&&null!=this.hasKeyframesIndex&&e&&t},e.prototype.isSeekable=function(){return!0===this.hasKeyframesIndex},e.prototype.getNearestKeyframe=function(e){if(null==this.keyframesIndex)return null;var t=this.keyframesIndex,r=this._search(t.times,e);return{index:r,milliseconds:t.times[r],fileposition:t.filepositions[r]}},e.prototype._search=function(e,t){var r=0,i=e.length-1,s=0,n=0,a=i;t<e[0]&&(r=0,n=a+1);while(n<=a){if(s=n+Math.floor((a-n)/2),s===i||t>=e[s]&&t<e[s+1]){r=s;break}e[s]<t?n=s+1:a=s-1}return r},e}();t["default"]=i},"./src/core/media-segment-info.js":
/*!****************************************!*\
!*** ./src/core/media-segment-info.js ***!
\****************************************/function(e,t,r){"use strict";r.r(t),r.d(t,{SampleInfo:function(){return i},MediaSegmentInfo:function(){return s},IDRSampleList:function(){return n},MediaSegmentInfoList:function(){return a}});var i=function(){function e(e,t,r,i,s){this.dts=e,this.pts=t,this.duration=r,this.originalDts=i,this.isSyncPoint=s,this.fileposition=null}return e}(),s=function(){function e(){this.beginDts=0,this.endDts=0,this.beginPts=0,this.endPts=0,this.originalBeginDts=0,this.originalEndDts=0,this.syncPoints=[],this.firstSample=null,this.lastSample=null}return e.prototype.appendSyncPoint=function(e){e.isSyncPoint=!0,this.syncPoints.push(e)},e}(),n=function(){function e(){this._list=[]}return e.prototype.clear=function(){this._list=[]},e.prototype.appendArray=function(e){var t=this._list;0!==e.length&&(t.length>0&&e[0].originalDts<t[t.length-1].originalDts&&this.clear(),Array.prototype.push.apply(t,e))},e.prototype.getLastSyncPointBeforeDts=function(e){if(0==this._list.length)return null;var t=this._list,r=0,i=t.length-1,s=0,n=0,a=i;e<t[0].dts&&(r=0,n=a+1);while(n<=a){if(s=n+Math.floor((a-n)/2),s===i||e>=t[s].dts&&e<t[s+1].dts){r=s;break}t[s].dts<e?n=s+1:a=s-1}return this._list[r]},e}(),a=function(){function e(e){this._type=e,this._list=[],this._lastAppendLocation=-1}return Object.defineProperty(e.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return this._list.length},enumerable:!1,configurable:!0}),e.prototype.isEmpty=function(){return 0===this._list.length},e.prototype.clear=function(){this._list=[],this._lastAppendLocation=-1},e.prototype._searchNearestSegmentBefore=function(e){var t=this._list;if(0===t.length)return-2;var r=t.length-1,i=0,s=0,n=r,a=0;if(e<t[0].originalBeginDts)return a=-1,a;while(s<=n){if(i=s+Math.floor((n-s)/2),i===r||e>t[i].lastSample.originalDts&&e<t[i+1].originalBeginDts){a=i;break}t[i].originalBeginDts<e?s=i+1:n=i-1}return a},e.prototype._searchNearestSegmentAfter=function(e){return this._searchNearestSegmentBefore(e)+1},e.prototype.append=function(e){var t=this._list,r=e,i=this._lastAppendLocation,s=0;-1!==i&&i<t.length&&r.originalBeginDts>=t[i].lastSample.originalDts&&(i===t.length-1||i<t.length-1&&r.originalBeginDts<t[i+1].originalBeginDts)?s=i+1:t.length>0&&(s=this._searchNearestSegmentBefore(r.originalBeginDts)+1),this._lastAppendLocation=s,this._list.splice(s,0,r)},e.prototype.getLastSegmentBefore=function(e){var t=this._searchNearestSegmentBefore(e);return t>=0?this._list[t]:null},e.prototype.getLastSampleBefore=function(e){var t=this.getLastSegmentBefore(e);return null!=t?t.lastSample:null},e.prototype.getLastSyncPointBefore=function(e){var t=this._searchNearestSegmentBefore(e),r=this._list[t].syncPoints;while(0===r.length&&t>0)t--,r=this._list[t].syncPoints;return r.length>0?r[r.length-1]:null},e}()},"./src/core/mse-controller.js":
/*!************************************!*\
!*** ./src/core/mse-controller.js ***!
\************************************/function(e,t,r){"use strict";r.r(t);var i=r(/*! events */"./node_modules/events/events.js"),s=r.n(i),n=r(/*! ../utils/logger.js */"./src/utils/logger.js"),a=r(/*! ../utils/browser.js */"./src/utils/browser.js"),o=r(/*! ./mse-events.js */"./src/core/mse-events.js"),l=r(/*! ./media-segment-info.js */"./src/core/media-segment-info.js"),d=r(/*! ../utils/exception.js */"./src/utils/exception.js"),h=function(){function e(e){this.TAG="MSEController",this._config=e,this._emitter=new(s()),this._config.isLive&&void 0==this._config.autoCleanupSourceBuffer&&(this._config.autoCleanupSourceBuffer=!0),this.e={onSourceOpen:this._onSourceOpen.bind(this),onSourceEnded:this._onSourceEnded.bind(this),onSourceClose:this._onSourceClose.bind(this),onSourceBufferError:this._onSourceBufferError.bind(this),onSourceBufferUpdateEnd:this._onSourceBufferUpdateEnd.bind(this)},this._mediaSource=null,this._mediaSourceObjectURL=null,this._mediaElement=null,this._isBufferFull=!1,this._hasPendingEos=!1,this._requireSetMediaDuration=!1,this._pendingMediaDuration=0,this._pendingSourceBufferInit=[],this._mimeTypes={video:null,audio:null},this._sourceBuffers={video:null,audio:null},this._lastInitSegments={video:null,audio:null},this._pendingSegments={video:[],audio:[]},this._pendingRemoveRanges={video:[],audio:[]},this._idrList=new l.IDRSampleList}return e.prototype.destroy=function(){(this._mediaElement||this._mediaSource)&&this.detachMediaElement(),this.e=null,this._emitter.removeAllListeners(),this._emitter=null},e.prototype.on=function(e,t){this._emitter.addListener(e,t)},e.prototype.off=function(e,t){this._emitter.removeListener(e,t)},e.prototype.attachMediaElement=function(e){if(this._mediaSource)throw new d.IllegalStateException("MediaSource has been attached to an HTMLMediaElement!");var t=this._mediaSource=new window.MediaSource;t.addEventListener("sourceopen",this.e.onSourceOpen),t.addEventListener("sourceended",this.e.onSourceEnded),t.addEventListener("sourceclose",this.e.onSourceClose),this._mediaElement=e,this._mediaSourceObjectURL=window.URL.createObjectURL(this._mediaSource),e.src=this._mediaSourceObjectURL},e.prototype.detachMediaElement=function(){if(this._mediaSource){var e=this._mediaSource;for(var t in this._sourceBuffers){var r=this._pendingSegments[t];r.splice(0,r.length),this._pendingSegments[t]=null,this._pendingRemoveRanges[t]=null,this._lastInitSegments[t]=null;var i=this._sourceBuffers[t];if(i){if("closed"!==e.readyState){try{e.removeSourceBuffer(i)}catch(s){n.default.e(this.TAG,s.message)}i.removeEventListener("error",this.e.onSourceBufferError),i.removeEventListener("updateend",this.e.onSourceBufferUpdateEnd)}this._mimeTypes[t]=null,this._sourceBuffers[t]=null}}if("open"===e.readyState)try{e.endOfStream()}catch(s){n.default.e(this.TAG,s.message)}e.removeEventListener("sourceopen",this.e.onSourceOpen),e.removeEventListener("sourceended",this.e.onSourceEnded),e.removeEventListener("sourceclose",this.e.onSourceClose),this._pendingSourceBufferInit=[],this._isBufferFull=!1,this._idrList.clear(),this._mediaSource=null}this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src"),this._mediaElement=null),this._mediaSourceObjectURL&&(window.URL.revokeObjectURL(this._mediaSourceObjectURL),this._mediaSourceObjectURL=null)},e.prototype.appendInitSegment=function(e,t){if(!this._mediaSource||"open"!==this._mediaSource.readyState)return this._pendingSourceBufferInit.push(e),void this._pendingSegments[e.type].push(e);var r=e,i=""+r.container;r.codec&&r.codec.length>0&&(i+=";codecs="+r.codec);var s=!1;if(n.default.v(this.TAG,"Received Initialization Segment, mimeType: "+i),this._lastInitSegments[r.type]=r,i!==this._mimeTypes[r.type]){if(this._mimeTypes[r.type])n.default.v(this.TAG,"Notice: "+r.type+" mimeType changed, origin: "+this._mimeTypes[r.type]+", target: "+i);else{s=!0;try{var l=this._sourceBuffers[r.type]=this._mediaSource.addSourceBuffer(i);l.addEventListener("error",this.e.onSourceBufferError),l.addEventListener("updateend",this.e.onSourceBufferUpdateEnd)}catch(d){return n.default.e(this.TAG,d.message),void this._emitter.emit(o.default.ERROR,{code:d.code,msg:d.message})}}this._mimeTypes[r.type]=i}t||this._pendingSegments[r.type].push(r),s||this._sourceBuffers[r.type]&&!this._sourceBuffers[r.type].updating&&this._doAppendSegments(),a.default.safari&&"audio/mpeg"===r.container&&r.mediaDuration>0&&(this._requireSetMediaDuration=!0,this._pendingMediaDuration=r.mediaDuration/1e3,this._updateMediaSourceDuration())},e.prototype.appendMediaSegment=function(e){var t=e;this._pendingSegments[t.type].push(t),this._config.autoCleanupSourceBuffer&&this._needCleanupSourceBuffer()&&this._doCleanupSourceBuffer();var r=this._sourceBuffers[t.type];!r||r.updating||this._hasPendingRemoveRanges()||this._doAppendSegments()},e.prototype.seek=function(e){for(var t in this._sourceBuffers)if(this._sourceBuffers[t]){var r=this._sourceBuffers[t];if("open"===this._mediaSource.readyState)try{r.abort()}catch(h){n.default.e(this.TAG,h.message)}this._idrList.clear();var i=this._pendingSegments[t];if(i.splice(0,i.length),"closed"!==this._mediaSource.readyState){for(var s=0;s<r.buffered.length;s++){var o=r.buffered.start(s),l=r.buffered.end(s);this._pendingRemoveRanges[t].push({start:o,end:l})}if(r.updating||this._doRemoveRanges(),a.default.safari){var d=this._lastInitSegments[t];d&&(this._pendingSegments[t].push(d),r.updating||this._doAppendSegments())}}}},e.prototype.endOfStream=function(){var e=this._mediaSource,t=this._sourceBuffers;e&&"open"===e.readyState?t.video&&t.video.updating||t.audio&&t.audio.updating?this._hasPendingEos=!0:(this._hasPendingEos=!1,e.endOfStream()):e&&"closed"===e.readyState&&this._hasPendingSegments()&&(this._hasPendingEos=!0)},e.prototype.getNearestKeyframe=function(e){return this._idrList.getLastSyncPointBeforeDts(e)},e.prototype._needCleanupSourceBuffer=function(){if(!this._config.autoCleanupSourceBuffer)return!1;var e=this._mediaElement.currentTime;for(var t in this._sourceBuffers){var r=this._sourceBuffers[t];if(r){var i=r.buffered;if(i.length>=1&&e-i.start(0)>=this._config.autoCleanupMaxBackwardDuration)return!0}}return!1},e.prototype._doCleanupSourceBuffer=function(){var e=this._mediaElement.currentTime;for(var t in this._sourceBuffers){var r=this._sourceBuffers[t];if(r){for(var i=r.buffered,s=!1,n=0;n<i.length;n++){var a=i.start(n),o=i.end(n);if(a<=e&&e<o+3){if(e-a>=this._config.autoCleanupMaxBackwardDuration){s=!0;var l=e-this._config.autoCleanupMinBackwardDuration;this._pendingRemoveRanges[t].push({start:a,end:l})}}else o<e&&(s=!0,this._pendingRemoveRanges[t].push({start:a,end:o}))}s&&!r.updating&&this._doRemoveRanges()}}},e.prototype._updateMediaSourceDuration=function(){var e=this._sourceBuffers;if(0!==this._mediaElement.readyState&&"open"===this._mediaSource.readyState&&!(e.video&&e.video.updating||e.audio&&e.audio.updating)){var t=this._mediaSource.duration,r=this._pendingMediaDuration;r>0&&(isNaN(t)||r>t)&&(n.default.v(this.TAG,"Update MediaSource duration from "+t+" to "+r),this._mediaSource.duration=r),this._requireSetMediaDuration=!1,this._pendingMediaDuration=0}},e.prototype._doRemoveRanges=function(){for(var e in this._pendingRemoveRanges)if(this._sourceBuffers[e]&&!this._sourceBuffers[e].updating){var t=this._sourceBuffers[e],r=this._pendingRemoveRanges[e];while(r.length&&!t.updating){var i=r.shift();t.remove(i.start,i.end)}}},e.prototype._doAppendSegments=function(){var e=this._pendingSegments;for(var t in e)if(this._sourceBuffers[t]&&!this._sourceBuffers[t].updating&&e[t].length>0){var r=e[t].shift();if(r.timestampOffset){var i=this._sourceBuffers[t].timestampOffset,s=r.timestampOffset/1e3,a=Math.abs(i-s);a>.1&&(n.default.v(this.TAG,"Update MPEG audio timestampOffset from "+i+" to "+s),this._sourceBuffers[t].timestampOffset=s),delete r.timestampOffset}if(!r.data||0===r.data.byteLength)continue;try{this._sourceBuffers[t].appendBuffer(r.data),this._isBufferFull=!1,"video"===t&&r.hasOwnProperty("info")&&this._idrList.appendArray(r.info.syncPoints)}catch(l){this._pendingSegments[t].unshift(r),22===l.code?(this._isBufferFull||this._emitter.emit(o.default.BUFFER_FULL),this._isBufferFull=!0):(n.default.e(this.TAG,l.message),this._emitter.emit(o.default.ERROR,{code:l.code,msg:l.message}))}}},e.prototype._onSourceOpen=function(){if(n.default.v(this.TAG,"MediaSource onSourceOpen"),this._mediaSource.removeEventListener("sourceopen",this.e.onSourceOpen),this._pendingSourceBufferInit.length>0){var e=this._pendingSourceBufferInit;while(e.length){var t=e.shift();this.appendInitSegment(t,!0)}}this._hasPendingSegments()&&this._doAppendSegments(),this._emitter.emit(o.default.SOURCE_OPEN)},e.prototype._onSourceEnded=function(){n.default.v(this.TAG,"MediaSource onSourceEnded")},e.prototype._onSourceClose=function(){n.default.v(this.TAG,"MediaSource onSourceClose"),this._mediaSource&&null!=this.e&&(this._mediaSource.removeEventListener("sourceopen",this.e.onSourceOpen),this._mediaSource.removeEventListener("sourceended",this.e.onSourceEnded),this._mediaSource.removeEventListener("sourceclose",this.e.onSourceClose))},e.prototype._hasPendingSegments=function(){var e=this._pendingSegments;return e.video.length>0||e.audio.length>0},e.prototype._hasPendingRemoveRanges=function(){var e=this._pendingRemoveRanges;return e.video.length>0||e.audio.length>0},e.prototype._onSourceBufferUpdateEnd=function(){this._requireSetMediaDuration?this._updateMediaSourceDuration():this._hasPendingRemoveRanges()?this._doRemoveRanges():this._hasPendingSegments()?this._doAppendSegments():this._hasPendingEos&&this.endOfStream(),this._emitter.emit(o.default.UPDATE_END)},e.prototype._onSourceBufferError=function(e){n.default.e(this.TAG,"SourceBuffer Error: "+e)},e}();t["default"]=h},"./src/core/mse-events.js":
/*!********************************!*\
!*** ./src/core/mse-events.js ***!
\********************************/function(e,t,r){"use strict";r.r(t);var i={ERROR:"error",SOURCE_OPEN:"source_open",UPDATE_END:"update_end",BUFFER_FULL:"buffer_full"};t["default"]=i},"./src/core/transmuxer.js":
/*!********************************!*\
!*** ./src/core/transmuxer.js ***!
\********************************/function(e,t,r){"use strict";r.r(t);var i=r(/*! events */"./node_modules/events/events.js"),s=r.n(i),n=r(/*! webworkify-webpack */"./node_modules/webworkify-webpack/index.js"),a=r.n(n),o=r(/*! ../utils/logger.js */"./src/utils/logger.js"),l=r(/*! ../utils/logging-control.js */"./src/utils/logging-control.js"),d=r(/*! ./transmuxing-controller.js */"./src/core/transmuxing-controller.js"),h=r(/*! ./transmuxing-events.js */"./src/core/transmuxing-events.js"),c=r(/*! ./media-info.js */"./src/core/media-info.js"),u=function(){function e(e,t){if(this.TAG="Transmuxer",this._emitter=new(s()),t.enableWorker&&"undefined"!==typeof Worker)try{this._worker=a()(/*! ./transmuxing-worker */"./src/core/transmuxing-worker.js"),this._workerDestroying=!1,this._worker.addEventListener("message",this._onWorkerMessage.bind(this)),this._worker.postMessage({cmd:"init",param:[e,t]}),this.e={onLoggingConfigChanged:this._onLoggingConfigChanged.bind(this)},l.default.registerListener(this.e.onLoggingConfigChanged),this._worker.postMessage({cmd:"logging_config",param:l.default.getConfig()})}catch(i){o.default.e(this.TAG,"Error while initialize transmuxing worker, fallback to inline transmuxing"),this._worker=null,this._controller=new d.default(e,t)}else this._controller=new d.default(e,t);if(this._controller){var r=this._controller;r.on(h.default.IO_ERROR,this._onIOError.bind(this)),r.on(h.default.DEMUX_ERROR,this._onDemuxError.bind(this)),r.on(h.default.INIT_SEGMENT,this._onInitSegment.bind(this)),r.on(h.default.MEDIA_SEGMENT,this._onMediaSegment.bind(this)),r.on(h.default.LOADING_COMPLETE,this._onLoadingComplete.bind(this)),r.on(h.default.RECOVERED_EARLY_EOF,this._onRecoveredEarlyEof.bind(this)),r.on(h.default.MEDIA_INFO,this._onMediaInfo.bind(this)),r.on(h.default.METADATA_ARRIVED,this._onMetaDataArrived.bind(this)),r.on(h.default.SCRIPTDATA_ARRIVED,this._onScriptDataArrived.bind(this)),r.on(h.default.STATISTICS_INFO,this._onStatisticsInfo.bind(this)),r.on(h.default.RECOMMEND_SEEKPOINT,this._onRecommendSeekpoint.bind(this))}}return e.prototype.destroy=function(){this._worker?this._workerDestroying||(this._workerDestroying=!0,this._worker.postMessage({cmd:"destroy"}),l.default.removeListener(this.e.onLoggingConfigChanged),this.e=null):(this._controller.destroy(),this._controller=null),this._emitter.removeAllListeners(),this._emitter=null},e.prototype.on=function(e,t){this._emitter.addListener(e,t)},e.prototype.off=function(e,t){this._emitter.removeListener(e,t)},e.prototype.hasWorker=function(){return null!=this._worker},e.prototype.open=function(){this._worker?this._worker.postMessage({cmd:"start"}):this._controller.start()},e.prototype.close=function(){this._worker?this._worker.postMessage({cmd:"stop"}):this._controller.stop()},e.prototype.seek=function(e){this._worker?this._worker.postMessage({cmd:"seek",param:e}):this._controller.seek(e)},e.prototype.pause=function(){this._worker?this._worker.postMessage({cmd:"pause"}):this._controller.pause()},e.prototype.resume=function(){this._worker?this._worker.postMessage({cmd:"resume"}):this._controller.resume()},e.prototype._onInitSegment=function(e,t){var r=this;Promise.resolve().then((function(){r._emitter.emit(h.default.INIT_SEGMENT,e,t)}))},e.prototype._onMediaSegment=function(e,t){var r=this;Promise.resolve().then((function(){r._emitter.emit(h.default.MEDIA_SEGMENT,e,t)}))},e.prototype._onLoadingComplete=function(){var e=this;Promise.resolve().then((function(){e._emitter.emit(h.default.LOADING_COMPLETE)}))},e.prototype._onRecoveredEarlyEof=function(){var e=this;Promise.resolve().then((function(){e._emitter.emit(h.default.RECOVERED_EARLY_EOF)}))},e.prototype._onMediaInfo=function(e){var t=this;Promise.resolve().then((function(){t._emitter.emit(h.default.MEDIA_INFO,e)}))},e.prototype._onMetaDataArrived=function(e){var t=this;Promise.resolve().then((function(){t._emitter.emit(h.default.METADATA_ARRIVED,e)}))},e.prototype._onScriptDataArrived=function(e){var t=this;Promise.resolve().then((function(){t._emitter.emit(h.default.SCRIPTDATA_ARRIVED,e)}))},e.prototype._onStatisticsInfo=function(e){var t=this;Promise.resolve().then((function(){t._emitter.emit(h.default.STATISTICS_INFO,e)}))},e.prototype._onIOError=function(e,t){var r=this;Promise.resolve().then((function(){r._emitter.emit(h.default.IO_ERROR,e,t)}))},e.prototype._onDemuxError=function(e,t){var r=this;Promise.resolve().then((function(){r._emitter.emit(h.default.DEMUX_ERROR,e,t)}))},e.prototype._onRecommendSeekpoint=function(e){var t=this;Promise.resolve().then((function(){t._emitter.emit(h.default.RECOMMEND_SEEKPOINT,e)}))},e.prototype._onLoggingConfigChanged=function(e){this._worker&&this._worker.postMessage({cmd:"logging_config",param:e})},e.prototype._onWorkerMessage=function(e){var t=e.data,r=t.data;if("destroyed"===t.msg||this._workerDestroying)return this._workerDestroying=!1,this._worker.terminate(),void(this._worker=null);switch(t.msg){case h.default.INIT_SEGMENT:case h.default.MEDIA_SEGMENT:this._emitter.emit(t.msg,r.type,r.data);break;case h.default.LOADING_COMPLETE:case h.default.RECOVERED_EARLY_EOF:this._emitter.emit(t.msg);break;case h.default.MEDIA_INFO:Object.setPrototypeOf(r,c.default.prototype),this._emitter.emit(t.msg,r);break;case h.default.METADATA_ARRIVED:case h.default.SCRIPTDATA_ARRIVED:case h.default.STATISTICS_INFO:this._emitter.emit(t.msg,r);break;case h.default.IO_ERROR:case h.default.DEMUX_ERROR:this._emitter.emit(t.msg,r.type,r.info);break;case h.default.RECOMMEND_SEEKPOINT:this._emitter.emit(t.msg,r);break;case"logcat_callback":o.default.emitter.emit("log",r.type,r.logcat);break;default:break}},e}();t["default"]=u},"./src/core/transmuxing-controller.js":
/*!********************************************!*\
!*** ./src/core/transmuxing-controller.js ***!
\********************************************/function(e,t,r){"use strict";r.r(t);var i=r(/*! events */"./node_modules/events/events.js"),s=r.n(i),n=r(/*! ../utils/logger.js */"./src/utils/logger.js"),a=r(/*! ../utils/browser.js */"./src/utils/browser.js"),o=r(/*! ./media-info.js */"./src/core/media-info.js"),l=r(/*! ../demux/flv-demuxer.js */"./src/demux/flv-demuxer.js"),d=r(/*! ../remux/mp4-remuxer.js */"./src/remux/mp4-remuxer.js"),h=r(/*! ../demux/demux-errors.js */"./src/demux/demux-errors.js"),c=r(/*! ../io/io-controller.js */"./src/io/io-controller.js"),u=r(/*! ./transmuxing-events.js */"./src/core/transmuxing-events.js"),f=function(){function e(e,t){this.TAG="TransmuxingController",this._emitter=new(s()),this._config=t,e.segments||(e.segments=[{duration:e.duration,filesize:e.filesize,url:e.url}]),"boolean"!==typeof e.cors&&(e.cors=!0),"boolean"!==typeof e.withCredentials&&(e.withCredentials=!1),this._mediaDataSource=e,this._currentSegmentIndex=0;var r=0;this._mediaDataSource.segments.forEach((function(i){i.timestampBase=r,r+=i.duration,i.cors=e.cors,i.withCredentials=e.withCredentials,t.referrerPolicy&&(i.referrerPolicy=t.referrerPolicy)})),isNaN(r)||this._mediaDataSource.duration===r||(this._mediaDataSource.duration=r),this._mediaInfo=null,this._demuxer=null,this._remuxer=null,this._ioctl=null,this._pendingSeekTime=null,this._pendingResolveSeekPoint=null,this._statisticsReporter=null}return e.prototype.destroy=function(){this._mediaInfo=null,this._mediaDataSource=null,this._statisticsReporter&&this._disableStatisticsReporter(),this._ioctl&&(this._ioctl.destroy(),this._ioctl=null),this._demuxer&&(this._demuxer.destroy(),this._demuxer=null),this._remuxer&&(this._remuxer.destroy(),this._remuxer=null),this._emitter.removeAllListeners(),this._emitter=null},e.prototype.on=function(e,t){this._emitter.addListener(e,t)},e.prototype.off=function(e,t){this._emitter.removeListener(e,t)},e.prototype.start=function(){this._loadSegment(0),this._enableStatisticsReporter()},e.prototype._loadSegment=function(e,t){this._currentSegmentIndex=e;var r=this._mediaDataSource.segments[e],i=this._ioctl=new c.default(r,this._config,e);i.onError=this._onIOException.bind(this),i.onSeeked=this._onIOSeeked.bind(this),i.onComplete=this._onIOComplete.bind(this),i.onRedirect=this._onIORedirect.bind(this),i.onRecoveredEarlyEof=this._onIORecoveredEarlyEof.bind(this),t?this._demuxer.bindDataSource(this._ioctl):i.onDataArrival=this._onInitChunkArrival.bind(this),i.open(t)},e.prototype.stop=function(){this._internalAbort(),this._disableStatisticsReporter()},e.prototype._internalAbort=function(){this._ioctl&&(this._ioctl.destroy(),this._ioctl=null)},e.prototype.pause=function(){this._ioctl&&this._ioctl.isWorking()&&(this._ioctl.pause(),this._disableStatisticsReporter())},e.prototype.resume=function(){this._ioctl&&this._ioctl.isPaused()&&(this._ioctl.resume(),this._enableStatisticsReporter())},e.prototype.seek=function(e){if(null!=this._mediaInfo&&this._mediaInfo.isSeekable()){var t=this._searchSegmentIndexContains(e);if(t===this._currentSegmentIndex){var r=this._mediaInfo.segments[t];if(void 0==r)this._pendingSeekTime=e;else{var i=r.getNearestKeyframe(e);this._remuxer.seek(i.milliseconds),this._ioctl.seek(i.fileposition),this._pendingResolveSeekPoint=i.milliseconds}}else{var s=this._mediaInfo.segments[t];if(void 0==s)this._pendingSeekTime=e,this._internalAbort(),this._remuxer.seek(),this._remuxer.insertDiscontinuity(),this._loadSegment(t);else{i=s.getNearestKeyframe(e);this._internalAbort(),this._remuxer.seek(e),this._remuxer.insertDiscontinuity(),this._demuxer.resetMediaInfo(),this._demuxer.timestampBase=this._mediaDataSource.segments[t].timestampBase,this._loadSegment(t,i.fileposition),this._pendingResolveSeekPoint=i.milliseconds,this._reportSegmentMediaInfo(t)}}this._enableStatisticsReporter()}},e.prototype._searchSegmentIndexContains=function(e){for(var t=this._mediaDataSource.segments,r=t.length-1,i=0;i<t.length;i++)if(e<t[i].timestampBase){r=i-1;break}return r},e.prototype._onInitChunkArrival=function(e,t){var r=this,i=null,s=0;if(t>0)this._demuxer.bindDataSource(this._ioctl),this._demuxer.timestampBase=this._mediaDataSource.segments[this._currentSegmentIndex].timestampBase,s=this._demuxer.parseChunks(e,t);else if((i=l.default.probe(e)).match){this._demuxer=new l.default(i,this._config),this._remuxer||(this._remuxer=new d.default(this._config));var a=this._mediaDataSource;void 0==a.duration||isNaN(a.duration)||(this._demuxer.overridedDuration=a.duration),"boolean"===typeof a.hasAudio&&(this._demuxer.overridedHasAudio=a.hasAudio),"boolean"===typeof a.hasVideo&&(this._demuxer.overridedHasVideo=a.hasVideo),this._demuxer.timestampBase=a.segments[this._currentSegmentIndex].timestampBase,this._demuxer.onError=this._onDemuxException.bind(this),this._demuxer.onMediaInfo=this._onMediaInfo.bind(this),this._demuxer.onMetaDataArrived=this._onMetaDataArrived.bind(this),this._demuxer.onScriptDataArrived=this._onScriptDataArrived.bind(this),this._remuxer.bindDataSource(this._demuxer.bindDataSource(this._ioctl)),this._remuxer.onInitSegment=this._onRemuxerInitSegmentArrival.bind(this),this._remuxer.onMediaSegment=this._onRemuxerMediaSegmentArrival.bind(this),s=this._demuxer.parseChunks(e,t)}else i=null,n.default.e(this.TAG,"Non-FLV, Unsupported media type!"),Promise.resolve().then((function(){r._internalAbort()})),this._emitter.emit(u.default.DEMUX_ERROR,h.default.FORMAT_UNSUPPORTED,"Non-FLV, Unsupported media type"),s=0;return s},e.prototype._onMediaInfo=function(e){var t=this;null==this._mediaInfo&&(this._mediaInfo=Object.assign({},e),this._mediaInfo.keyframesIndex=null,this._mediaInfo.segments=[],this._mediaInfo.segmentCount=this._mediaDataSource.segments.length,Object.setPrototypeOf(this._mediaInfo,o.default.prototype));var r=Object.assign({},e);Object.setPrototypeOf(r,o.default.prototype),this._mediaInfo.segments[this._currentSegmentIndex]=r,this._reportSegmentMediaInfo(this._currentSegmentIndex),null!=this._pendingSeekTime&&Promise.resolve().then((function(){var e=t._pendingSeekTime;t._pendingSeekTime=null,t.seek(e)}))},e.prototype._onMetaDataArrived=function(e){this._emitter.emit(u.default.METADATA_ARRIVED,e)},e.prototype._onScriptDataArrived=function(e){this._emitter.emit(u.default.SCRIPTDATA_ARRIVED,e)},e.prototype._onIOSeeked=function(){this._remuxer.insertDiscontinuity()},e.prototype._onIOComplete=function(e){var t=e,r=t+1;r<this._mediaDataSource.segments.length?(this._internalAbort(),this._remuxer.flushStashedSamples(),this._loadSegment(r)):(this._remuxer.flushStashedSamples(),this._emitter.emit(u.default.LOADING_COMPLETE),this._disableStatisticsReporter())},e.prototype._onIORedirect=function(e){var t=this._ioctl.extraData;this._mediaDataSource.segments[t].redirectedURL=e},e.prototype._onIORecoveredEarlyEof=function(){this._emitter.emit(u.default.RECOVERED_EARLY_EOF)},e.prototype._onIOException=function(e,t){n.default.e(this.TAG,"IOException: type = "+e+", code = "+t.code+", msg = "+t.msg),this._emitter.emit(u.default.IO_ERROR,e,t),this._disableStatisticsReporter()},e.prototype._onDemuxException=function(e,t){n.default.e(this.TAG,"DemuxException: type = "+e+", info = "+t),this._emitter.emit(u.default.DEMUX_ERROR,e,t)},e.prototype._onRemuxerInitSegmentArrival=function(e,t){this._emitter.emit(u.default.INIT_SEGMENT,e,t)},e.prototype._onRemuxerMediaSegmentArrival=function(e,t){if(null==this._pendingSeekTime&&(this._emitter.emit(u.default.MEDIA_SEGMENT,e,t),null!=this._pendingResolveSeekPoint&&"video"===e)){var r=t.info.syncPoints,i=this._pendingResolveSeekPoint;this._pendingResolveSeekPoint=null,a.default.safari&&r.length>0&&r[0].originalDts===i&&(i=r[0].pts),this._emitter.emit(u.default.RECOMMEND_SEEKPOINT,i)}},e.prototype._enableStatisticsReporter=function(){null==this._statisticsReporter&&(this._statisticsReporter=self.setInterval(this._reportStatisticsInfo.bind(this),this._config.statisticsInfoReportInterval))},e.prototype._disableStatisticsReporter=function(){this._statisticsReporter&&(self.clearInterval(this._statisticsReporter),this._statisticsReporter=null)},e.prototype._reportSegmentMediaInfo=function(e){var t=this._mediaInfo.segments[e],r=Object.assign({},t);r.duration=this._mediaInfo.duration,r.segmentCount=this._mediaInfo.segmentCount,delete r.segments,delete r.keyframesIndex,this._emitter.emit(u.default.MEDIA_INFO,r)},e.prototype._reportStatisticsInfo=function(){var e={};e.url=this._ioctl.currentURL,e.hasRedirect=this._ioctl.hasRedirect,e.hasRedirect&&(e.redirectedURL=this._ioctl.currentRedirectedURL),e.speed=this._ioctl.currentSpeed,e.loaderType=this._ioctl.loaderType,e.currentSegmentIndex=this._currentSegmentIndex,e.totalSegmentCount=this._mediaDataSource.segments.length,this._emitter.emit(u.default.STATISTICS_INFO,e)},e}();t["default"]=f},"./src/core/transmuxing-events.js":
/*!****************************************!*\
!*** ./src/core/transmuxing-events.js ***!
\****************************************/function(e,t,r){"use strict";r.r(t);var i={IO_ERROR:"io_error",DEMUX_ERROR:"demux_error",INIT_SEGMENT:"init_segment",MEDIA_SEGMENT:"media_segment",LOADING_COMPLETE:"loading_complete",RECOVERED_EARLY_EOF:"recovered_early_eof",MEDIA_INFO:"media_info",METADATA_ARRIVED:"metadata_arrived",SCRIPTDATA_ARRIVED:"scriptdata_arrived",STATISTICS_INFO:"statistics_info",RECOMMEND_SEEKPOINT:"recommend_seekpoint"};t["default"]=i},"./src/core/transmuxing-worker.js":
/*!****************************************!*\
!*** ./src/core/transmuxing-worker.js ***!
\****************************************/function(e,t,r){"use strict";r.r(t);var i=r(/*! ../utils/logging-control.js */"./src/utils/logging-control.js"),s=r(/*! ../utils/polyfill.js */"./src/utils/polyfill.js"),n=r(/*! ./transmuxing-controller.js */"./src/core/transmuxing-controller.js"),a=r(/*! ./transmuxing-events.js */"./src/core/transmuxing-events.js"),o=function(e){var t=null,r=v.bind(this);function o(t,r){var i={msg:a.default.INIT_SEGMENT,data:{type:t,data:r}};e.postMessage(i,[r.data])}function l(t,r){var i={msg:a.default.MEDIA_SEGMENT,data:{type:t,data:r}};e.postMessage(i,[r.data])}function d(){var t={msg:a.default.LOADING_COMPLETE};e.postMessage(t)}function h(){var t={msg:a.default.RECOVERED_EARLY_EOF};e.postMessage(t)}function c(t){var r={msg:a.default.MEDIA_INFO,data:t};e.postMessage(r)}function u(t){var r={msg:a.default.METADATA_ARRIVED,data:t};e.postMessage(r)}function f(t){var r={msg:a.default.SCRIPTDATA_ARRIVED,data:t};e.postMessage(r)}function p(t){var r={msg:a.default.STATISTICS_INFO,data:t};e.postMessage(r)}function m(t,r){e.postMessage({msg:a.default.IO_ERROR,data:{type:t,info:r}})}function g(t,r){e.postMessage({msg:a.default.DEMUX_ERROR,data:{type:t,info:r}})}function y(t){e.postMessage({msg:a.default.RECOMMEND_SEEKPOINT,data:t})}function v(t,r){e.postMessage({msg:"logcat_callback",data:{type:t,logcat:r}})}s.default.install(),e.addEventListener("message",(function(s){switch(s.data.cmd){case"init":t=new n.default(s.data.param[0],s.data.param[1]),t.on(a.default.IO_ERROR,m.bind(this)),t.on(a.default.DEMUX_ERROR,g.bind(this)),t.on(a.default.INIT_SEGMENT,o.bind(this)),t.on(a.default.MEDIA_SEGMENT,l.bind(this)),t.on(a.default.LOADING_COMPLETE,d.bind(this)),t.on(a.default.RECOVERED_EARLY_EOF,h.bind(this)),t.on(a.default.MEDIA_INFO,c.bind(this)),t.on(a.default.METADATA_ARRIVED,u.bind(this)),t.on(a.default.SCRIPTDATA_ARRIVED,f.bind(this)),t.on(a.default.STATISTICS_INFO,p.bind(this)),t.on(a.default.RECOMMEND_SEEKPOINT,y.bind(this));break;case"destroy":t&&(t.destroy(),t=null),e.postMessage({msg:"destroyed"});break;case"start":t.start();break;case"stop":t.stop();break;case"seek":t.seek(s.data.param);break;case"pause":t.pause();break;case"resume":t.resume();break;case"logging_config":var v=s.data.param;i.default.applyConfig(v),!0===v.enableCallback?i.default.addLogListener(r):i.default.removeLogListener(r);break}}))};t["default"]=o},"./src/demux/amf-parser.js":
/*!*********************************!*\
!*** ./src/demux/amf-parser.js ***!
\*********************************/function(e,t,r){"use strict";r.r(t);var i=r(/*! ../utils/logger.js */"./src/utils/logger.js"),s=r(/*! ../utils/utf8-conv.js */"./src/utils/utf8-conv.js"),n=r(/*! ../utils/exception.js */"./src/utils/exception.js"),a=function(){var e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),256===new Int16Array(e)[0]}(),o=function(){function e(){}return e.parseScriptData=function(t,r,s){var n={};try{var a=e.parseValue(t,r,s),o=e.parseValue(t,r+a.size,s-a.size);n[a.data]=o.data}catch(l){i.default.e("AMF",l.toString())}return n},e.parseObject=function(t,r,i){if(i<3)throw new n.IllegalStateException("Data not enough when parse ScriptDataObject");var s=e.parseString(t,r,i),a=e.parseValue(t,r+s.size,i-s.size),o=a.objectEnd;return{data:{name:s.data,value:a.data},size:s.size+a.size,objectEnd:o}},e.parseVariable=function(t,r,i){return e.parseObject(t,r,i)},e.parseString=function(e,t,r){if(r<2)throw new n.IllegalStateException("Data not enough when parse String");var i,o=new DataView(e,t,r),l=o.getUint16(0,!a);return i=l>0?(0,s.default)(new Uint8Array(e,t+2,l)):"",{data:i,size:2+l}},e.parseLongString=function(e,t,r){if(r<4)throw new n.IllegalStateException("Data not enough when parse LongString");var i,o=new DataView(e,t,r),l=o.getUint32(0,!a);return i=l>0?(0,s.default)(new Uint8Array(e,t+4,l)):"",{data:i,size:4+l}},e.parseDate=function(e,t,r){if(r<10)throw new n.IllegalStateException("Data size invalid when parse Date");var i=new DataView(e,t,r),s=i.getFloat64(0,!a),o=i.getInt16(8,!a);return s+=60*o*1e3,{data:new Date(s),size:10}},e.parseValue=function(t,r,s){if(s<1)throw new n.IllegalStateException("Data not enough when parse Value");var o,l=new DataView(t,r,s),d=1,h=l.getUint8(0),c=!1;try{switch(h){case 0:o=l.getFloat64(1,!a),d+=8;break;case 1:var u=l.getUint8(1);o=!!u,d+=1;break;case 2:var f=e.parseString(t,r+1,s-1);o=f.data,d+=f.size;break;case 3:o={};var p=0;9===(16777215&l.getUint32(s-4,!a))&&(p=3);while(d<s-4){var m=e.parseObject(t,r+d,s-d-p);if(m.objectEnd)break;o[m.data.name]=m.data.value,d+=m.size}if(d<=s-3){var g=16777215&l.getUint32(d-1,!a);9===g&&(d+=3)}break;case 8:o={},d+=4;p=0;9===(16777215&l.getUint32(s-4,!a))&&(p=3);while(d<s-8){var y=e.parseVariable(t,r+d,s-d-p);if(y.objectEnd)break;o[y.data.name]=y.data.value,d+=y.size}if(d<=s-3){g=16777215&l.getUint32(d-1,!a);9===g&&(d+=3)}break;case 9:o=void 0,d=1,c=!0;break;case 10:o=[];var v=l.getUint32(1,!a);d+=4;for(var _=0;_<v;_++){var E=e.parseValue(t,r+d,s-d);o.push(E.data),d+=E.size}break;case 11:var b=e.parseDate(t,r+1,s-1);o=b.data,d+=b.size;break;case 12:var T=e.parseString(t,r+1,s-1);o=T.data,d+=T.size;break;default:d=s,i.default.w("AMF","Unsupported AMF value type "+h)}}catch(S){i.default.e("AMF",S.toString())}return{data:o,size:d,objectEnd:c}},e}();t["default"]=o},"./src/demux/demux-errors.js":
/*!***********************************!*\
!*** ./src/demux/demux-errors.js ***!
\***********************************/function(e,t,r){"use strict";r.r(t);var i={OK:"OK",FORMAT_ERROR:"FormatError",FORMAT_UNSUPPORTED:"FormatUnsupported",CODEC_UNSUPPORTED:"CodecUnsupported"};t["default"]=i},"./src/demux/exp-golomb.js":
/*!*********************************!*\
!*** ./src/demux/exp-golomb.js ***!
\*********************************/function(e,t,r){"use strict";r.r(t);var i=r(/*! ../utils/exception.js */"./src/utils/exception.js"),s=function(){function e(e){this.TAG="ExpGolomb",this._buffer=e,this._buffer_index=0,this._total_bytes=e.byteLength,this._total_bits=8*e.byteLength,this._current_word=0,this._current_word_bits_left=0}return e.prototype.destroy=function(){this._buffer=null},e.prototype._fillCurrentWord=function(){var e=this._total_bytes-this._buffer_index;if(e<=0)throw new i.IllegalStateException("ExpGolomb: _fillCurrentWord() but no bytes available");var t=Math.min(4,e),r=new Uint8Array(4);r.set(this._buffer.subarray(this._buffer_index,this._buffer_index+t)),this._current_word=new DataView(r.buffer).getUint32(0,!1),this._buffer_index+=t,this._current_word_bits_left=8*t},e.prototype.readBits=function(e){if(e>32)throw new i.InvalidArgumentException("ExpGolomb: readBits() bits exceeded max 32bits!");if(e<=this._current_word_bits_left){var t=this._current_word>>>32-e;return this._current_word<<=e,this._current_word_bits_left-=e,t}var r=this._current_word_bits_left?this._current_word:0;r>>>=32-this._current_word_bits_left;var s=e-this._current_word_bits_left;this._fillCurrentWord();var n=Math.min(s,this._current_word_bits_left),a=this._current_word>>>32-n;return this._current_word<<=n,this._current_word_bits_left-=n,r=r<<n|a,r},e.prototype.readBool=function(){return 1===this.readBits(1)},e.prototype.readByte=function(){return this.readBits(8)},e.prototype._skipLeadingZero=function(){var e;for(e=0;e<this._current_word_bits_left;e++)if(0!==(this._current_word&2147483648>>>e))return this._current_word<<=e,this._current_word_bits_left-=e,e;return this._fillCurrentWord(),e+this._skipLeadingZero()},e.prototype.readUEG=function(){var e=this._skipLeadingZero();return this.readBits(e+1)-1},e.prototype.readSEG=function(){var e=this.readUEG();return 1&e?e+1>>>1:-1*(e>>>1)},e}();t["default"]=s},"./src/demux/flv-demuxer.js":
/*!**********************************!*\
!*** ./src/demux/flv-demuxer.js ***!
\**********************************/function(e,t,r){"use strict";r.r(t);var i=r(/*! ../utils/logger.js */"./src/utils/logger.js"),s=r(/*! ./amf-parser.js */"./src/demux/amf-parser.js"),n=r(/*! ./sps-parser.js */"./src/demux/sps-parser.js"),a=r(/*! ./demux-errors.js */"./src/demux/demux-errors.js"),o=r(/*! ../core/media-info.js */"./src/core/media-info.js"),l=r(/*! ../utils/exception.js */"./src/utils/exception.js");function d(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}var h=function(){function e(e,t){this.TAG="FLVDemuxer",this._config=t,this._onError=null,this._onMediaInfo=null,this._onMetaDataArrived=null,this._onScriptDataArrived=null,this._onTrackMetadata=null,this._onDataAvailable=null,this._dataOffset=e.dataOffset,this._firstParse=!0,this._dispatch=!1,this._hasAudio=e.hasAudioTrack,this._hasVideo=e.hasVideoTrack,this._hasAudioFlagOverrided=!1,this._hasVideoFlagOverrided=!1,this._audioInitialMetadataDispatched=!1,this._videoInitialMetadataDispatched=!1,this._mediaInfo=new o.default,this._mediaInfo.hasAudio=this._hasAudio,this._mediaInfo.hasVideo=this._hasVideo,this._metadata=null,this._audioMetadata=null,this._videoMetadata=null,this._naluLengthSize=4,this._timestampBase=0,this._timescale=1e3,this._duration=0,this._durationOverrided=!1,this._referenceFrameRate={fixed:!0,fps:23.976,fps_num:23976,fps_den:1e3},this._flvSoundRateTable=[5500,11025,22050,44100,48e3],this._mpegSamplingRates=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],this._mpegAudioV10SampleRateTable=[44100,48e3,32e3,0],this._mpegAudioV20SampleRateTable=[22050,24e3,16e3,0],this._mpegAudioV25SampleRateTable=[11025,12e3,8e3,0],this._mpegAudioL1BitRateTable=[0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,-1],this._mpegAudioL2BitRateTable=[0,32,48,56,64,80,96,112,128,160,192,224,256,320,384,-1],this._mpegAudioL3BitRateTable=[0,32,40,48,56,64,80,96,112,128,160,192,224,256,320,-1],this._videoTrack={type:"video",id:1,sequenceNumber:0,samples:[],length:0},this._audioTrack={type:"audio",id:2,sequenceNumber:0,samples:[],length:0},this._littleEndian=function(){var e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),256===new Int16Array(e)[0]}()}return e.prototype.destroy=function(){this._mediaInfo=null,this._metadata=null,this._audioMetadata=null,this._videoMetadata=null,this._videoTrack=null,this._audioTrack=null,this._onError=null,this._onMediaInfo=null,this._onMetaDataArrived=null,this._onScriptDataArrived=null,this._onTrackMetadata=null,this._onDataAvailable=null},e.probe=function(e){var t=new Uint8Array(e),r={match:!1};if(70!==t[0]||76!==t[1]||86!==t[2]||1!==t[3])return r;var i=(4&t[4])>>>2!==0,s=0!==(1&t[4]),n=d(t,5);return n<9?r:{match:!0,consumed:n,dataOffset:n,hasAudioTrack:i,hasVideoTrack:s}},e.prototype.bindDataSource=function(e){return e.onDataArrival=this.parseChunks.bind(this),this},Object.defineProperty(e.prototype,"onTrackMetadata",{get:function(){return this._onTrackMetadata},set:function(e){this._onTrackMetadata=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onMediaInfo",{get:function(){return this._onMediaInfo},set:function(e){this._onMediaInfo=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onMetaDataArrived",{get:function(){return this._onMetaDataArrived},set:function(e){this._onMetaDataArrived=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onScriptDataArrived",{get:function(){return this._onScriptDataArrived},set:function(e){this._onScriptDataArrived=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onError",{get:function(){return this._onError},set:function(e){this._onError=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onDataAvailable",{get:function(){return this._onDataAvailable},set:function(e){this._onDataAvailable=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"timestampBase",{get:function(){return this._timestampBase},set:function(e){this._timestampBase=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"overridedDuration",{get:function(){return this._duration},set:function(e){this._durationOverrided=!0,this._duration=e,this._mediaInfo.duration=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"overridedHasAudio",{set:function(e){this._hasAudioFlagOverrided=!0,this._hasAudio=e,this._mediaInfo.hasAudio=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"overridedHasVideo",{set:function(e){this._hasVideoFlagOverrided=!0,this._hasVideo=e,this._mediaInfo.hasVideo=e},enumerable:!1,configurable:!0}),e.prototype.resetMediaInfo=function(){this._mediaInfo=new o.default},e.prototype._isInitialMetadataDispatched=function(){return this._hasAudio&&this._hasVideo?this._audioInitialMetadataDispatched&&this._videoInitialMetadataDispatched:this._hasAudio&&!this._hasVideo?this._audioInitialMetadataDispatched:!(this._hasAudio||!this._hasVideo)&&this._videoInitialMetadataDispatched},e.prototype.parseChunks=function(t,r){if(!this._onError||!this._onMediaInfo||!this._onTrackMetadata||!this._onDataAvailable)throw new l.IllegalStateException("Flv: onError & onMediaInfo & onTrackMetadata & onDataAvailable callback must be specified");var s=0,n=this._littleEndian;if(0===r){if(!(t.byteLength>13))return 0;var a=e.probe(t);s=a.dataOffset}if(this._firstParse){this._firstParse=!1,r+s!==this._dataOffset&&i.default.w(this.TAG,"First time parsing but chunk byteStart invalid!");var o=new DataView(t,s),d=o.getUint32(0,!n);0!==d&&i.default.w(this.TAG,"PrevTagSize0 !== 0 !!!"),s+=4}while(s<t.byteLength){this._dispatch=!0;o=new DataView(t,s);if(s+11+4>t.byteLength)break;var h=o.getUint8(0),c=16777215&o.getUint32(0,!n);if(s+11+c+4>t.byteLength)break;if(8===h||9===h||18===h){var u=o.getUint8(4),f=o.getUint8(5),p=o.getUint8(6),m=o.getUint8(7),g=p|f<<8|u<<16|m<<24,y=16777215&o.getUint32(7,!n);0!==y&&i.default.w(this.TAG,"Meet tag which has StreamID != 0!");var v=s+11;switch(h){case 8:this._parseAudioData(t,v,c,g);break;case 9:this._parseVideoData(t,v,c,g,r+s);break;case 18:this._parseScriptData(t,v,c);break}var _=o.getUint32(11+c,!n);_!==11+c&&i.default.w(this.TAG,"Invalid PrevTagSize "+_),s+=11+c+4}else i.default.w(this.TAG,"Unsupported tag type "+h+", skipped"),s+=11+c+4}return this._isInitialMetadataDispatched()&&this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack),s},e.prototype._parseScriptData=function(e,t,r){var n=s.default.parseScriptData(e,t,r);if(n.hasOwnProperty("onMetaData")){if(null==n.onMetaData||"object"!==typeof n.onMetaData)return void i.default.w(this.TAG,"Invalid onMetaData structure!");this._metadata&&i.default.w(this.TAG,"Found another onMetaData tag!"),this._metadata=n;var a=this._metadata.onMetaData;if(this._onMetaDataArrived&&this._onMetaDataArrived(Object.assign({},a)),"boolean"===typeof a.hasAudio&&!1===this._hasAudioFlagOverrided&&(this._hasAudio=a.hasAudio,this._mediaInfo.hasAudio=this._hasAudio),"boolean"===typeof a.hasVideo&&!1===this._hasVideoFlagOverrided&&(this._hasVideo=a.hasVideo,this._mediaInfo.hasVideo=this._hasVideo),"number"===typeof a.audiodatarate&&(this._mediaInfo.audioDataRate=a.audiodatarate),"number"===typeof a.videodatarate&&(this._mediaInfo.videoDataRate=a.videodatarate),"number"===typeof a.width&&(this._mediaInfo.width=a.width),"number"===typeof a.height&&(this._mediaInfo.height=a.height),"number"===typeof a.duration){if(!this._durationOverrided){var o=Math.floor(a.duration*this._timescale);this._duration=o,this._mediaInfo.duration=o}}else this._mediaInfo.duration=0;if("number"===typeof a.framerate){var l=Math.floor(1e3*a.framerate);if(l>0){var d=l/1e3;this._referenceFrameRate.fixed=!0,this._referenceFrameRate.fps=d,this._referenceFrameRate.fps_num=l,this._referenceFrameRate.fps_den=1e3,this._mediaInfo.fps=d}}if("object"===typeof a.keyframes){this._mediaInfo.hasKeyframesIndex=!0;var h=a.keyframes;this._mediaInfo.keyframesIndex=this._parseKeyframesIndex(h),a.keyframes=null}else this._mediaInfo.hasKeyframesIndex=!1;this._dispatch=!1,this._mediaInfo.metadata=a,i.default.v(this.TAG,"Parsed onMetaData"),this._mediaInfo.isComplete()&&this._onMediaInfo(this._mediaInfo)}Object.keys(n).length>0&&this._onScriptDataArrived&&this._onScriptDataArrived(Object.assign({},n))},e.prototype._parseKeyframesIndex=function(e){for(var t=[],r=[],i=1;i<e.times.length;i++){var s=this._timestampBase+Math.floor(1e3*e.times[i]);t.push(s),r.push(e.filepositions[i])}return{times:t,filepositions:r}},e.prototype._parseAudioData=function(e,t,r,s){if(r<=1)i.default.w(this.TAG,"Flv: Invalid audio packet, missing SoundData payload!");else if(!0!==this._hasAudioFlagOverrided||!1!==this._hasAudio){this._littleEndian;var n=new DataView(e,t,r),o=n.getUint8(0),l=o>>>4;if(2===l||10===l){var d=0,h=(12&o)>>>2;if(h>=0&&h<=4){d=this._flvSoundRateTable[h];var c=1&o,u=this._audioMetadata,f=this._audioTrack;if(u||(!1===this._hasAudio&&!1===this._hasAudioFlagOverrided&&(this._hasAudio=!0,this._mediaInfo.hasAudio=!0),u=this._audioMetadata={},u.type="audio",u.id=f.id,u.timescale=this._timescale,u.duration=this._duration,u.audioSampleRate=d,u.channelCount=0===c?1:2),10===l){var p=this._parseAACAudioData(e,t+1,r-1);if(void 0==p)return;if(0===p.packetType){u.config&&i.default.w(this.TAG,"Found another AudioSpecificConfig!");var m=p.data;u.audioSampleRate=m.samplingRate,u.channelCount=m.channelCount,u.codec=m.codec,u.originalCodec=m.originalCodec,u.config=m.config,u.refSampleDuration=1024/u.audioSampleRate*u.timescale,i.default.v(this.TAG,"Parsed AudioSpecificConfig"),this._isInitialMetadataDispatched()?this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack):this._audioInitialMetadataDispatched=!0,this._dispatch=!1,this._onTrackMetadata("audio",u);var g=this._mediaInfo;g.audioCodec=u.originalCodec,g.audioSampleRate=u.audioSampleRate,g.audioChannelCount=u.channelCount,g.hasVideo?null!=g.videoCodec&&(g.mimeType='video/x-flv; codecs="'+g.videoCodec+","+g.audioCodec+'"'):g.mimeType='video/x-flv; codecs="'+g.audioCodec+'"',g.isComplete()&&this._onMediaInfo(g)}else if(1===p.packetType){var y=this._timestampBase+s,v={unit:p.data,length:p.data.byteLength,dts:y,pts:y};f.samples.push(v),f.length+=p.data.length}else i.default.e(this.TAG,"Flv: Unsupported AAC data type "+p.packetType)}else if(2===l){if(!u.codec){m=this._parseMP3AudioData(e,t+1,r-1,!0);if(void 0==m)return;u.audioSampleRate=m.samplingRate,u.channelCount=m.channelCount,u.codec=m.codec,u.originalCodec=m.originalCodec,u.refSampleDuration=1152/u.audioSampleRate*u.timescale,i.default.v(this.TAG,"Parsed MPEG Audio Frame Header"),this._audioInitialMetadataDispatched=!0,this._onTrackMetadata("audio",u);g=this._mediaInfo;g.audioCodec=u.codec,g.audioSampleRate=u.audioSampleRate,g.audioChannelCount=u.channelCount,g.audioDataRate=m.bitRate,g.hasVideo?null!=g.videoCodec&&(g.mimeType='video/x-flv; codecs="'+g.videoCodec+","+g.audioCodec+'"'):g.mimeType='video/x-flv; codecs="'+g.audioCodec+'"',g.isComplete()&&this._onMediaInfo(g)}var _=this._parseMP3AudioData(e,t+1,r-1,!1);if(void 0==_)return;y=this._timestampBase+s;var E={unit:_,length:_.byteLength,dts:y,pts:y};f.samples.push(E),f.length+=_.length}}else this._onError(a.default.FORMAT_ERROR,"Flv: Invalid audio sample rate idx: "+h)}else this._onError(a.default.CODEC_UNSUPPORTED,"Flv: Unsupported audio codec idx: "+l)}},e.prototype._parseAACAudioData=function(e,t,r){if(!(r<=1)){var s={},n=new Uint8Array(e,t,r);return s.packetType=n[0],0===n[0]?s.data=this._parseAACAudioSpecificConfig(e,t+1,r-1):s.data=n.subarray(1),s}i.default.w(this.TAG,"Flv: Invalid AAC packet, missing AACPacketType or/and Data!")},e.prototype._parseAACAudioSpecificConfig=function(e,t,r){var i=new Uint8Array(e,t,r),s=null,n=0,o=0,l=0,d=null;if(n=o=i[0]>>>3,l=(7&i[0])<<1|i[1]>>>7,l<0||l>=this._mpegSamplingRates.length)this._onError(a.default.FORMAT_ERROR,"Flv: AAC invalid sampling frequency index!");else{var h=this._mpegSamplingRates[l],c=(120&i[1])>>>3;if(!(c<0||c>=8)){5===n&&(d=(7&i[1])<<1|i[2]>>>7,(124&i[2])>>>2);var u=self.navigator.userAgent.toLowerCase();return-1!==u.indexOf("firefox")?l>=6?(n=5,s=new Array(4),d=l-3):(n=2,s=new Array(2),d=l):-1!==u.indexOf("android")?(n=2,s=new Array(2),d=l):(n=5,d=l,s=new Array(4),l>=6?d=l-3:1===c&&(n=2,s=new Array(2),d=l)),s[0]=n<<3,s[0]|=(15&l)>>>1,s[1]=(15&l)<<7,s[1]|=(15&c)<<3,5===n&&(s[1]|=(15&d)>>>1,s[2]=(1&d)<<7,s[2]|=8,s[3]=0),{config:s,samplingRate:h,channelCount:c,codec:"mp4a.40."+n,originalCodec:"mp4a.40."+o}}this._onError(a.default.FORMAT_ERROR,"Flv: AAC invalid channel configuration")}},e.prototype._parseMP3AudioData=function(e,t,r,s){if(!(r<4)){this._littleEndian;var n=new Uint8Array(e,t,r),a=null;if(s){if(255!==n[0])return;var o=n[1]>>>3&3,l=(6&n[1])>>1,d=(240&n[2])>>>4,h=(12&n[2])>>>2,c=n[3]>>>6&3,u=3!==c?2:1,f=0,p=0,m="mp3";switch(o){case 0:f=this._mpegAudioV25SampleRateTable[h];break;case 2:f=this._mpegAudioV20SampleRateTable[h];break;case 3:f=this._mpegAudioV10SampleRateTable[h];break}switch(l){case 1:34,d<this._mpegAudioL3BitRateTable.length&&(p=this._mpegAudioL3BitRateTable[d]);break;case 2:33,d<this._mpegAudioL2BitRateTable.length&&(p=this._mpegAudioL2BitRateTable[d]);break;case 3:32,d<this._mpegAudioL1BitRateTable.length&&(p=this._mpegAudioL1BitRateTable[d]);break}a={bitRate:p,samplingRate:f,channelCount:u,codec:m,originalCodec:m}}else a=n;return a}i.default.w(this.TAG,"Flv: Invalid MP3 packet, header missing!")},e.prototype._parseVideoData=function(e,t,r,s,n){if(r<=1)i.default.w(this.TAG,"Flv: Invalid video packet, missing VideoData payload!");else if(!0!==this._hasVideoFlagOverrided||!1!==this._hasVideo){var o=new Uint8Array(e,t,r)[0],l=(240&o)>>>4,d=15&o;7===d?this._parseAVCVideoPacket(e,t+1,r-1,s,n,l):this._onError(a.default.CODEC_UNSUPPORTED,"Flv: Unsupported codec in video frame: "+d)}},e.prototype._parseAVCVideoPacket=function(e,t,r,s,n,o){if(r<4)i.default.w(this.TAG,"Flv: Invalid AVC packet, missing AVCPacketType or/and CompositionTime");else{var l=this._littleEndian,d=new DataView(e,t,r),h=d.getUint8(0),c=16777215&d.getUint32(0,!l),u=c<<8>>8;if(0===h)this._parseAVCDecoderConfigurationRecord(e,t+4,r-4);else if(1===h)this._parseAVCVideoData(e,t+4,r-4,s,n,o,u);else if(2!==h)return void this._onError(a.default.FORMAT_ERROR,"Flv: Invalid video packet type "+h)}},e.prototype._parseAVCDecoderConfigurationRecord=function(e,t,r){if(r<7)i.default.w(this.TAG,"Flv: Invalid AVCDecoderConfigurationRecord, lack of data!");else{var s=this._videoMetadata,o=this._videoTrack,l=this._littleEndian,d=new DataView(e,t,r);s?"undefined"!==typeof s.avcc&&i.default.w(this.TAG,"Found another AVCDecoderConfigurationRecord!"):(!1===this._hasVideo&&!1===this._hasVideoFlagOverrided&&(this._hasVideo=!0,this._mediaInfo.hasVideo=!0),s=this._videoMetadata={},s.type="video",s.id=o.id,s.timescale=this._timescale,s.duration=this._duration);var h=d.getUint8(0),c=d.getUint8(1);d.getUint8(2),d.getUint8(3);if(1===h&&0!==c)if(this._naluLengthSize=1+(3&d.getUint8(4)),3===this._naluLengthSize||4===this._naluLengthSize){var u=31&d.getUint8(5);if(0!==u){u>1&&i.default.w(this.TAG,"Flv: Strange AVCDecoderConfigurationRecord: SPS Count = "+u);for(var f=6,p=0;p<u;p++){var m=d.getUint16(f,!l);if(f+=2,0!==m){var g=new Uint8Array(e,t+f,m);f+=m;var y=n.default.parseSPS(g);if(0===p){s.codecWidth=y.codec_size.width,s.codecHeight=y.codec_size.height,s.presentWidth=y.present_size.width,s.presentHeight=y.present_size.height,s.profile=y.profile_string,s.level=y.level_string,s.bitDepth=y.bit_depth,s.chromaFormat=y.chroma_format,s.sarRatio=y.sar_ratio,s.frameRate=y.frame_rate,!1!==y.frame_rate.fixed&&0!==y.frame_rate.fps_num&&0!==y.frame_rate.fps_den||(s.frameRate=this._referenceFrameRate);var v=s.frameRate.fps_den,_=s.frameRate.fps_num;s.refSampleDuration=s.timescale*(v/_);for(var E=g.subarray(1,4),b="avc1.",T=0;T<3;T++){var S=E[T].toString(16);S.length<2&&(S="0"+S),b+=S}s.codec=b;var L=this._mediaInfo;L.width=s.codecWidth,L.height=s.codecHeight,L.fps=s.frameRate.fps,L.profile=s.profile,L.level=s.level,L.refFrames=y.ref_frames,L.chromaFormat=y.chroma_format_string,L.sarNum=s.sarRatio.width,L.sarDen=s.sarRatio.height,L.videoCodec=b,L.hasAudio?null!=L.audioCodec&&(L.mimeType='video/x-flv; codecs="'+L.videoCodec+","+L.audioCodec+'"'):L.mimeType='video/x-flv; codecs="'+L.videoCodec+'"',L.isComplete()&&this._onMediaInfo(L)}}}var A=d.getUint8(f);if(0!==A){A>1&&i.default.w(this.TAG,"Flv: Strange AVCDecoderConfigurationRecord: PPS Count = "+A),f++;for(p=0;p<A;p++){m=d.getUint16(f,!l);f+=2,0!==m&&(f+=m)}s.avcc=new Uint8Array(r),s.avcc.set(new Uint8Array(e,t,r),0),i.default.v(this.TAG,"Parsed AVCDecoderConfigurationRecord"),this._isInitialMetadataDispatched()?this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack):this._videoInitialMetadataDispatched=!0,this._dispatch=!1,this._onTrackMetadata("video",s)}else this._onError(a.default.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord: No PPS")}else this._onError(a.default.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord: No SPS")}else this._onError(a.default.FORMAT_ERROR,"Flv: Strange NaluLengthSizeMinusOne: "+(this._naluLengthSize-1));else this._onError(a.default.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord")}},e.prototype._parseAVCVideoData=function(e,t,r,s,n,a,o){var l=this._littleEndian,d=new DataView(e,t,r),h=[],c=0,u=0,f=this._naluLengthSize,p=this._timestampBase+s,m=1===a;while(u<r){if(u+4>=r){i.default.w(this.TAG,"Malformed Nalu near timestamp "+p+", offset = "+u+", dataSize = "+r);break}var g=d.getUint32(u,!l);if(3===f&&(g>>>=8),g>r-f)return void i.default.w(this.TAG,"Malformed Nalus near timestamp "+p+", NaluSize > DataSize!");var y=31&d.getUint8(u+f);5===y&&(m=!0);var v=new Uint8Array(e,t+u,f+g),_={type:y,data:v};h.push(_),c+=v.byteLength,u+=f+g}if(h.length){var E=this._videoTrack,b={units:h,length:c,isKeyframe:m,dts:p,cts:o,pts:p+o};m&&(b.fileposition=n),E.samples.push(b),E.length+=c}},e}();t["default"]=h},"./src/demux/sps-parser.js":
/*!*********************************!*\
!*** ./src/demux/sps-parser.js ***!
\*********************************/function(e,t,r){"use strict";r.r(t);var i=r(/*! ./exp-golomb.js */"./src/demux/exp-golomb.js"),s=function(){function e(){}return e._ebsp2rbsp=function(e){for(var t=e,r=t.byteLength,i=new Uint8Array(r),s=0,n=0;n<r;n++)n>=2&&3===t[n]&&0===t[n-1]&&0===t[n-2]||(i[s]=t[n],s++);return new Uint8Array(i.buffer,0,s)},e.parseSPS=function(t){var r=e._ebsp2rbsp(t),s=new i.default(r);s.readByte();var n=s.readByte();s.readByte();var a=s.readByte();s.readUEG();var o=e.getProfileString(n),l=e.getLevelString(a),d=1,h=420,c=[0,420,422,444],u=8;if((100===n||110===n||122===n||244===n||44===n||83===n||86===n||118===n||128===n||138===n||144===n)&&(d=s.readUEG(),3===d&&s.readBits(1),d<=3&&(h=c[d]),u=s.readUEG()+8,s.readUEG(),s.readBits(1),s.readBool()))for(var f=3!==d?8:12,p=0;p<f;p++)s.readBool()&&(p<6?e._skipScalingList(s,16):e._skipScalingList(s,64));s.readUEG();var m=s.readUEG();if(0===m)s.readUEG();else if(1===m){s.readBits(1),s.readSEG(),s.readSEG();var g=s.readUEG();for(p=0;p<g;p++)s.readSEG()}var y=s.readUEG();s.readBits(1);var v=s.readUEG(),_=s.readUEG(),E=s.readBits(1);0===E&&s.readBits(1),s.readBits(1);var b=0,T=0,S=0,L=0,A=s.readBool();A&&(b=s.readUEG(),T=s.readUEG(),S=s.readUEG(),L=s.readUEG());var w=1,R=1,k=0,I=!0,D=0,x=0,C=s.readBool();if(C){if(s.readBool()){var P=s.readByte(),O=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2],M=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1];P>0&&P<16?(w=O[P-1],R=M[P-1]):255===P&&(w=s.readByte()<<8|s.readByte(),R=s.readByte()<<8|s.readByte())}if(s.readBool()&&s.readBool(),s.readBool()&&(s.readBits(4),s.readBool()&&s.readBits(24)),s.readBool()&&(s.readUEG(),s.readUEG()),s.readBool()){var F=s.readBits(32),N=s.readBits(32);I=s.readBool(),D=N,x=2*F,k=D/x}}var U=1;1===w&&1===R||(U=w/R);var B=0,$=0;if(0===d)B=1,$=2-E;else{var G=3===d?1:2,j=1===d?2:1;B=G,$=j*(2-E)}var K=16*(v+1),V=16*(_+1)*(2-E);K-=(b+T)*B,V-=(S+L)*$;var H=Math.ceil(K*U);return s.destroy(),s=null,{profile_string:o,level_string:l,bit_depth:u,ref_frames:y,chroma_format:h,chroma_format_string:e.getChromaFormatString(h),frame_rate:{fixed:I,fps:k,fps_den:x,fps_num:D},sar_ratio:{width:w,height:R},codec_size:{width:K,height:V},present_size:{width:H,height:V}}},e._skipScalingList=function(e,t){for(var r=8,i=8,s=0,n=0;n<t;n++)0!==i&&(s=e.readSEG(),i=(r+s+256)%256),r=0===i?r:i},e.getProfileString=function(e){switch(e){case 66:return"Baseline";case 77:return"Main";case 88:return"Extended";case 100:return"High";case 110:return"High10";case 122:return"High422";case 244:return"High444";default:return"Unknown"}},e.getLevelString=function(e){return(e/10).toFixed(1)},e.getChromaFormatString=function(e){switch(e){case 420:return"4:2:0";case 422:return"4:2:2";case 444:return"4:4:4";default:return"Unknown"}},e}();t["default"]=s},"./src/flv.js":
/*!********************!*\
!*** ./src/flv.js ***!
\********************/function(e,t,r){"use strict";r.r(t);var i=r(/*! ./utils/polyfill.js */"./src/utils/polyfill.js"),s=r(/*! ./core/features.js */"./src/core/features.js"),n=r(/*! ./io/loader.js */"./src/io/loader.js"),a=r(/*! ./player/flv-player.js */"./src/player/flv-player.js"),o=r(/*! ./player/native-player.js */"./src/player/native-player.js"),l=r(/*! ./player/player-events.js */"./src/player/player-events.js"),d=r(/*! ./player/player-errors.js */"./src/player/player-errors.js"),h=r(/*! ./utils/logging-control.js */"./src/utils/logging-control.js"),c=r(/*! ./utils/exception.js */"./src/utils/exception.js");function u(e,t){var r=e;if(null==r||"object"!==typeof r)throw new c.InvalidArgumentException("MediaDataSource must be an javascript object!");if(!r.hasOwnProperty("type"))throw new c.InvalidArgumentException("MediaDataSource must has type field to indicate video file type!");switch(r.type){case"flv":return new a.default(r,t);default:return new o.default(r,t)}}function f(){return s.default.supportMSEH264Playback()}function p(){return s.default.getFeatureList()}i.default.install();var m={};m.createPlayer=u,m.isSupported=f,m.getFeatureList=p,m.BaseLoader=n.BaseLoader,m.LoaderStatus=n.LoaderStatus,m.LoaderErrors=n.LoaderErrors,m.Events=l.default,m.ErrorTypes=d.ErrorTypes,m.ErrorDetails=d.ErrorDetails,m.FlvPlayer=a.default,m.NativePlayer=o.default,m.LoggingControl=h.default,Object.defineProperty(m,"version",{enumerable:!0,get:function(){return"1.6.2"}}),t["default"]=m},"./src/index.js":
/*!**********************!*\
!*** ./src/index.js ***!
\**********************/function(e,t,r){e.exports=r(/*! ./flv.js */"./src/flv.js").default},"./src/io/fetch-stream-loader.js":
/*!***************************************!*\
!*** ./src/io/fetch-stream-loader.js ***!
\***************************************/function(e,t,r){"use strict";r.r(t);var i=r(/*! ../utils/browser.js */"./src/utils/browser.js"),s=r(/*! ./loader.js */"./src/io/loader.js"),n=r(/*! ../utils/exception.js */"./src/utils/exception.js"),a=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!==typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function i(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}}(),o=function(e){function t(t,r){var i=e.call(this,"fetch-stream-loader")||this;return i.TAG="FetchStreamLoader",i._seekHandler=t,i._config=r,i._needStash=!0,i._requestAbort=!1,i._contentLength=null,i._receivedLength=0,i}return a(t,e),t.isSupported=function(){try{var e=i.default.msedge&&i.default.version.minor>=15048,t=!i.default.msedge||e;return self.fetch&&self.ReadableStream&&t}catch(r){return!1}},t.prototype.destroy=function(){this.isWorking()&&this.abort(),e.prototype.destroy.call(this)},t.prototype.open=function(e,t){var r=this;this._dataSource=e,this._range=t;var i=e.url;this._config.reuseRedirectedURL&&void 0!=e.redirectedURL&&(i=e.redirectedURL);var a=this._seekHandler.getConfig(i,t),o=new self.Headers;if("object"===typeof a.headers){var l=a.headers;for(var d in l)l.hasOwnProperty(d)&&o.append(d,l[d])}var h={method:"GET",headers:o,mode:"cors",cache:"default",referrerPolicy:"no-referrer-when-downgrade"};if("object"===typeof this._config.headers)for(var d in this._config.headers)o.append(d,this._config.headers[d]);!1===e.cors&&(h.mode="same-origin"),e.withCredentials&&(h.credentials="include"),e.referrerPolicy&&(h.referrerPolicy=e.referrerPolicy),self.AbortController&&(this._abortController=new self.AbortController,h.signal=this._abortController.signal),this._status=s.LoaderStatus.kConnecting,self.fetch(a.url,h).then((function(e){if(r._requestAbort)return r._status=s.LoaderStatus.kIdle,void e.body.cancel();if(e.ok&&e.status>=200&&e.status<=299){if(e.url!==a.url&&r._onURLRedirect){var t=r._seekHandler.removeURLParameters(e.url);r._onURLRedirect(t)}var i=e.headers.get("Content-Length");return null!=i&&(r._contentLength=parseInt(i),0!==r._contentLength&&r._onContentLengthKnown&&r._onContentLengthKnown(r._contentLength)),r._pump.call(r,e.body.getReader())}if(r._status=s.LoaderStatus.kError,!r._onError)throw new n.RuntimeException("FetchStreamLoader: Http code invalid, "+e.status+" "+e.statusText);r._onError(s.LoaderErrors.HTTP_STATUS_CODE_INVALID,{code:e.status,msg:e.statusText})})).catch((function(e){if(!r._abortController||!r._abortController.signal.aborted){if(r._status=s.LoaderStatus.kError,!r._onError)throw e;r._onError(s.LoaderErrors.EXCEPTION,{code:-1,msg:e.message})}}))},t.prototype.abort=function(){if(this._requestAbort=!0,(this._status!==s.LoaderStatus.kBuffering||!i.default.chrome)&&this._abortController)try{this._abortController.abort()}catch(e){}},t.prototype._pump=function(e){var t=this;return e.read().then((function(r){if(r.done)if(null!==t._contentLength&&t._receivedLength<t._contentLength){t._status=s.LoaderStatus.kError;var i=s.LoaderErrors.EARLY_EOF,a={code:-1,msg:"Fetch stream meet Early-EOF"};if(!t._onError)throw new n.RuntimeException(a.msg);t._onError(i,a)}else t._status=s.LoaderStatus.kComplete,t._onComplete&&t._onComplete(t._range.from,t._range.from+t._receivedLength-1);else{if(t._abortController&&t._abortController.signal.aborted)return void(t._status=s.LoaderStatus.kComplete);if(!0===t._requestAbort)return t._status=s.LoaderStatus.kComplete,e.cancel();t._status=s.LoaderStatus.kBuffering;var o=r.value.buffer,l=t._range.from+t._receivedLength;t._receivedLength+=o.byteLength,t._onDataArrival&&t._onDataArrival(o,l,t._receivedLength),t._pump(e)}})).catch((function(e){if(t._abortController&&t._abortController.signal.aborted)t._status=s.LoaderStatus.kComplete;else if(11!==e.code||!i.default.msedge){t._status=s.LoaderStatus.kError;var r=0,a=null;if(19!==e.code&&"network error"!==e.message||!(null===t._contentLength||null!==t._contentLength&&t._receivedLength<t._contentLength)?(r=s.LoaderErrors.EXCEPTION,a={code:e.code,msg:e.message}):(r=s.LoaderErrors.EARLY_EOF,a={code:e.code,msg:"Fetch stream meet Early-EOF"}),!t._onError)throw new n.RuntimeException(a.msg);t._onError(r,a)}}))},t}(s.BaseLoader);t["default"]=o},"./src/io/io-controller.js":
/*!*********************************!*\
!*** ./src/io/io-controller.js ***!
\*********************************/function(e,t,r){"use strict";r.r(t);var i=r(/*! ../utils/logger.js */"./src/utils/logger.js"),s=r(/*! ./speed-sampler.js */"./src/io/speed-sampler.js"),n=r(/*! ./loader.js */"./src/io/loader.js"),a=r(/*! ./fetch-stream-loader.js */"./src/io/fetch-stream-loader.js"),o=r(/*! ./xhr-moz-chunked-loader.js */"./src/io/xhr-moz-chunked-loader.js"),l=r(/*! ./xhr-range-loader.js */"./src/io/xhr-range-loader.js"),d=r(/*! ./websocket-loader.js */"./src/io/websocket-loader.js"),h=r(/*! ./range-seek-handler.js */"./src/io/range-seek-handler.js"),c=r(/*! ./param-seek-handler.js */"./src/io/param-seek-handler.js"),u=r(/*! ../utils/exception.js */"./src/utils/exception.js"),f=function(){function e(e,t,r){this.TAG="IOController",this._config=t,this._extraData=r,this._stashInitialSize=393216,void 0!=t.stashInitialSize&&t.stashInitialSize>0&&(this._stashInitialSize=t.stashInitialSize),this._stashUsed=0,this._stashSize=this._stashInitialSize,this._bufferSize=3145728,this._stashBuffer=new ArrayBuffer(this._bufferSize),this._stashByteStart=0,this._enableStash=!0,!1===t.enableStashBuffer&&(this._enableStash=!1),this._loader=null,this._loaderClass=null,this._seekHandler=null,this._dataSource=e,this._isWebSocketURL=/wss?:\/\/(.+?)/.test(e.url),this._refTotalLength=e.filesize?e.filesize:null,this._totalLength=this._refTotalLength,this._fullRequestFlag=!1,this._currentRange=null,this._redirectedURL=null,this._speedNormalized=0,this._speedSampler=new s.default,this._speedNormalizeList=[64,128,256,384,512,768,1024,1536,2048,3072,4096],this._isEarlyEofReconnecting=!1,this._paused=!1,this._resumeFrom=0,this._onDataArrival=null,this._onSeeked=null,this._onError=null,this._onComplete=null,this._onRedirect=null,this._onRecoveredEarlyEof=null,this._selectSeekHandler(),this._selectLoader(),this._createLoader()}return e.prototype.destroy=function(){this._loader.isWorking()&&this._loader.abort(),this._loader.destroy(),this._loader=null,this._loaderClass=null,this._dataSource=null,this._stashBuffer=null,this._stashUsed=this._stashSize=this._bufferSize=this._stashByteStart=0,this._currentRange=null,this._speedSampler=null,this._isEarlyEofReconnecting=!1,this._onDataArrival=null,this._onSeeked=null,this._onError=null,this._onComplete=null,this._onRedirect=null,this._onRecoveredEarlyEof=null,this._extraData=null},e.prototype.isWorking=function(){return this._loader&&this._loader.isWorking()&&!this._paused},e.prototype.isPaused=function(){return this._paused},Object.defineProperty(e.prototype,"status",{get:function(){return this._loader.status},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"extraData",{get:function(){return this._extraData},set:function(e){this._extraData=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onDataArrival",{get:function(){return this._onDataArrival},set:function(e){this._onDataArrival=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onSeeked",{get:function(){return this._onSeeked},set:function(e){this._onSeeked=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onError",{get:function(){return this._onError},set:function(e){this._onError=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onComplete",{get:function(){return this._onComplete},set:function(e){this._onComplete=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onRedirect",{get:function(){return this._onRedirect},set:function(e){this._onRedirect=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onRecoveredEarlyEof",{get:function(){return this._onRecoveredEarlyEof},set:function(e){this._onRecoveredEarlyEof=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentURL",{get:function(){return this._dataSource.url},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasRedirect",{get:function(){return null!=this._redirectedURL||void 0!=this._dataSource.redirectedURL},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentRedirectedURL",{get:function(){return this._redirectedURL||this._dataSource.redirectedURL},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentSpeed",{get:function(){return this._loaderClass===l.default?this._loader.currentSpeed:this._speedSampler.lastSecondKBps},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"loaderType",{get:function(){return this._loader.type},enumerable:!1,configurable:!0}),e.prototype._selectSeekHandler=function(){var e=this._config;if("range"===e.seekType)this._seekHandler=new h.default(this._config.rangeLoadZeroStart);else if("param"===e.seekType){var t=e.seekParamStart||"bstart",r=e.seekParamEnd||"bend";this._seekHandler=new c.default(t,r)}else{if("custom"!==e.seekType)throw new u.InvalidArgumentException("Invalid seekType in config: "+e.seekType);if("function"!==typeof e.customSeekHandler)throw new u.InvalidArgumentException("Custom seekType specified in config but invalid customSeekHandler!");this._seekHandler=new e.customSeekHandler}},e.prototype._selectLoader=function(){if(null!=this._config.customLoader)this._loaderClass=this._config.customLoader;else if(this._isWebSocketURL)this._loaderClass=d.default;else if(a.default.isSupported())this._loaderClass=a.default;else if(o.default.isSupported())this._loaderClass=o.default;else{if(!l.default.isSupported())throw new u.RuntimeException("Your browser doesn't support xhr with arraybuffer responseType!");this._loaderClass=l.default}},e.prototype._createLoader=function(){this._loader=new this._loaderClass(this._seekHandler,this._config),!1===this._loader.needStashBuffer&&(this._enableStash=!1),this._loader.onContentLengthKnown=this._onContentLengthKnown.bind(this),this._loader.onURLRedirect=this._onURLRedirect.bind(this),this._loader.onDataArrival=this._onLoaderChunkArrival.bind(this),this._loader.onComplete=this._onLoaderComplete.bind(this),this._loader.onError=this._onLoaderError.bind(this)},e.prototype.open=function(e){this._currentRange={from:0,to:-1},e&&(this._currentRange.from=e),this._speedSampler.reset(),e||(this._fullRequestFlag=!0),this._loader.open(this._dataSource,Object.assign({},this._currentRange))},e.prototype.abort=function(){this._loader.abort(),this._paused&&(this._paused=!1,this._resumeFrom=0)},e.prototype.pause=function(){this.isWorking()&&(this._loader.abort(),0!==this._stashUsed?(this._resumeFrom=this._stashByteStart,this._currentRange.to=this._stashByteStart-1):this._resumeFrom=this._currentRange.to+1,this._stashUsed=0,this._stashByteStart=0,this._paused=!0)},e.prototype.resume=function(){if(this._paused){this._paused=!1;var e=this._resumeFrom;this._resumeFrom=0,this._internalSeek(e,!0)}},e.prototype.seek=function(e){this._paused=!1,this._stashUsed=0,this._stashByteStart=0,this._internalSeek(e,!0)},e.prototype._internalSeek=function(e,t){this._loader.isWorking()&&this._loader.abort(),this._flushStashBuffer(t),this._loader.destroy(),this._loader=null;var r={from:e,to:-1};this._currentRange={from:r.from,to:-1},this._speedSampler.reset(),this._stashSize=this._stashInitialSize,this._createLoader(),this._loader.open(this._dataSource,r),this._onSeeked&&this._onSeeked()},e.prototype.updateUrl=function(e){if(!e||"string"!==typeof e||0===e.length)throw new u.InvalidArgumentException("Url must be a non-empty string!");this._dataSource.url=e},e.prototype._expandBuffer=function(e){var t=this._stashSize;while(t+1048576<e)t*=2;if(t+=1048576,t!==this._bufferSize){var r=new ArrayBuffer(t);if(this._stashUsed>0){var i=new Uint8Array(this._stashBuffer,0,this._stashUsed),s=new Uint8Array(r,0,t);s.set(i,0)}this._stashBuffer=r,this._bufferSize=t}},e.prototype._normalizeSpeed=function(e){var t=this._speedNormalizeList,r=t.length-1,i=0,s=0,n=r;if(e<t[0])return t[0];while(s<=n){if(i=s+Math.floor((n-s)/2),i===r||e>=t[i]&&e<t[i+1])return t[i];t[i]<e?s=i+1:n=i-1}},e.prototype._adjustStashSize=function(e){var t=0;t=this._config.isLive||e<512?e:e>=512&&e<=1024?Math.floor(1.5*e):2*e,t>8192&&(t=8192);var r=1024*t+1048576;this._bufferSize<r&&this._expandBuffer(r),this._stashSize=1024*t},e.prototype._dispatchChunks=function(e,t){return this._currentRange.to=t+e.byteLength-1,this._onDataArrival(e,t)},e.prototype._onURLRedirect=function(e){this._redirectedURL=e,this._onRedirect&&this._onRedirect(e)},e.prototype._onContentLengthKnown=function(e){e&&this._fullRequestFlag&&(this._totalLength=e,this._fullRequestFlag=!1)},e.prototype._onLoaderChunkArrival=function(e,t,r){if(!this._onDataArrival)throw new u.IllegalStateException("IOController: No existing consumer (onDataArrival) callback!");if(!this._paused){this._isEarlyEofReconnecting&&(this._isEarlyEofReconnecting=!1,this._onRecoveredEarlyEof&&this._onRecoveredEarlyEof()),this._speedSampler.addBytes(e.byteLength);var i=this._speedSampler.lastSecondKBps;if(0!==i){var s=this._normalizeSpeed(i);this._speedNormalized!==s&&(this._speedNormalized=s,this._adjustStashSize(s))}if(this._enableStash)if(0===this._stashUsed&&0===this._stashByteStart&&(this._stashByteStart=t),this._stashUsed+e.byteLength<=this._stashSize){l=new Uint8Array(this._stashBuffer,0,this._stashSize);l.set(new Uint8Array(e),this._stashUsed),this._stashUsed+=e.byteLength}else{l=new Uint8Array(this._stashBuffer,0,this._bufferSize);if(this._stashUsed>0){var n=this._stashBuffer.slice(0,this._stashUsed);a=this._dispatchChunks(n,this._stashByteStart);if(a<n.byteLength){if(a>0){d=new Uint8Array(n,a);l.set(d,0),this._stashUsed=d.byteLength,this._stashByteStart+=a}}else this._stashUsed=0,this._stashByteStart+=a;this._stashUsed+e.byteLength>this._bufferSize&&(this._expandBuffer(this._stashUsed+e.byteLength),l=new Uint8Array(this._stashBuffer,0,this._bufferSize)),l.set(new Uint8Array(e),this._stashUsed),this._stashUsed+=e.byteLength}else{a=this._dispatchChunks(e,t);if(a<e.byteLength){o=e.byteLength-a;o>this._bufferSize&&(this._expandBuffer(o),l=new Uint8Array(this._stashBuffer,0,this._bufferSize)),l.set(new Uint8Array(e,a),0),this._stashUsed+=o,this._stashByteStart=t+a}}}else if(0===this._stashUsed){var a=this._dispatchChunks(e,t);if(a<e.byteLength){var o=e.byteLength-a;o>this._bufferSize&&this._expandBuffer(o);var l=new Uint8Array(this._stashBuffer,0,this._bufferSize);l.set(new Uint8Array(e,a),0),this._stashUsed+=o,this._stashByteStart=t+a}}else{this._stashUsed+e.byteLength>this._bufferSize&&this._expandBuffer(this._stashUsed+e.byteLength);var l=new Uint8Array(this._stashBuffer,0,this._bufferSize);l.set(new Uint8Array(e),this._stashUsed),this._stashUsed+=e.byteLength;var a=this._dispatchChunks(this._stashBuffer.slice(0,this._stashUsed),this._stashByteStart);if(a<this._stashUsed&&a>0){var d=new Uint8Array(this._stashBuffer,a);l.set(d,0)}this._stashUsed-=a,this._stashByteStart+=a}}},e.prototype._flushStashBuffer=function(e){if(this._stashUsed>0){var t=this._stashBuffer.slice(0,this._stashUsed),r=this._dispatchChunks(t,this._stashByteStart),s=t.byteLength-r;if(r<t.byteLength){if(!e){if(r>0){var n=new Uint8Array(this._stashBuffer,0,this._bufferSize),a=new Uint8Array(t,r);n.set(a,0),this._stashUsed=a.byteLength,this._stashByteStart+=r}return 0}i.default.w(this.TAG,s+" bytes unconsumed data remain when flush buffer, dropped")}return this._stashUsed=0,this._stashByteStart=0,s}return 0},e.prototype._onLoaderComplete=function(e,t){this._flushStashBuffer(!0),this._onComplete&&this._onComplete(this._extraData)},e.prototype._onLoaderError=function(e,t){switch(i.default.e(this.TAG,"Loader error, code = "+t.code+", msg = "+t.msg),this._flushStashBuffer(!1),this._isEarlyEofReconnecting&&(this._isEarlyEofReconnecting=!1,e=n.LoaderErrors.UNRECOVERABLE_EARLY_EOF),e){case n.LoaderErrors.EARLY_EOF:if(!this._config.isLive&&this._totalLength){var r=this._currentRange.to+1;return void(r<this._totalLength&&(i.default.w(this.TAG,"Connection lost, trying reconnect..."),this._isEarlyEofReconnecting=!0,this._internalSeek(r,!1)))}e=n.LoaderErrors.UNRECOVERABLE_EARLY_EOF;break;case n.LoaderErrors.UNRECOVERABLE_EARLY_EOF:case n.LoaderErrors.CONNECTING_TIMEOUT:case n.LoaderErrors.HTTP_STATUS_CODE_INVALID:case n.LoaderErrors.EXCEPTION:break}if(!this._onError)throw new u.RuntimeException("IOException: "+t.msg);this._onError(e,t)},e}();t["default"]=f},"./src/io/loader.js":
/*!**************************!*\
!*** ./src/io/loader.js ***!
\**************************/function(e,t,r){"use strict";r.r(t),r.d(t,{LoaderStatus:function(){return s},LoaderErrors:function(){return n},BaseLoader:function(){return a}});var i=r(/*! ../utils/exception.js */"./src/utils/exception.js"),s={kIdle:0,kConnecting:1,kBuffering:2,kError:3,kComplete:4},n={OK:"OK",EXCEPTION:"Exception",HTTP_STATUS_CODE_INVALID:"HttpStatusCodeInvalid",CONNECTING_TIMEOUT:"ConnectingTimeout",EARLY_EOF:"EarlyEof",UNRECOVERABLE_EARLY_EOF:"UnrecoverableEarlyEof"},a=function(){function e(e){this._type=e||"undefined",this._status=s.kIdle,this._needStash=!1,this._onContentLengthKnown=null,this._onURLRedirect=null,this._onDataArrival=null,this._onError=null,this._onComplete=null}return e.prototype.destroy=function(){this._status=s.kIdle,this._onContentLengthKnown=null,this._onURLRedirect=null,this._onDataArrival=null,this._onError=null,this._onComplete=null},e.prototype.isWorking=function(){return this._status===s.kConnecting||this._status===s.kBuffering},Object.defineProperty(e.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"status",{get:function(){return this._status},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"needStashBuffer",{get:function(){return this._needStash},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onContentLengthKnown",{get:function(){return this._onContentLengthKnown},set:function(e){this._onContentLengthKnown=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onURLRedirect",{get:function(){return this._onURLRedirect},set:function(e){this._onURLRedirect=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onDataArrival",{get:function(){return this._onDataArrival},set:function(e){this._onDataArrival=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onError",{get:function(){return this._onError},set:function(e){this._onError=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onComplete",{get:function(){return this._onComplete},set:function(e){this._onComplete=e},enumerable:!1,configurable:!0}),e.prototype.open=function(e,t){throw new i.NotImplementedException("Unimplemented abstract function!")},e.prototype.abort=function(){throw new i.NotImplementedException("Unimplemented abstract function!")},e}()},"./src/io/param-seek-handler.js":
/*!**************************************!*\
!*** ./src/io/param-seek-handler.js ***!
\**************************************/function(e,t,r){"use strict";r.r(t);var i=function(){function e(e,t){this._startName=e,this._endName=t}return e.prototype.getConfig=function(e,t){var r=e;if(0!==t.from||-1!==t.to){var i=!0;-1===r.indexOf("?")&&(r+="?",i=!1),i&&(r+="&"),r+=this._startName+"="+t.from.toString(),-1!==t.to&&(r+="&"+this._endName+"="+t.to.toString())}return{url:r,headers:{}}},e.prototype.removeURLParameters=function(e){var t=e.split("?")[0],r=void 0,i=e.indexOf("?");-1!==i&&(r=e.substring(i+1));var s="";if(void 0!=r&&r.length>0)for(var n=r.split("&"),a=0;a<n.length;a++){var o=n[a].split("="),l=a>0;o[0]!==this._startName&&o[0]!==this._endName&&(l&&(s+="&"),s+=n[a])}return 0===s.length?t:t+"?"+s},e}();t["default"]=i},"./src/io/range-seek-handler.js":
/*!**************************************!*\
!*** ./src/io/range-seek-handler.js ***!
\**************************************/function(e,t,r){"use strict";r.r(t);var i=function(){function e(e){this._zeroStart=e||!1}return e.prototype.getConfig=function(e,t){var r={};if(0!==t.from||-1!==t.to){var i=void 0;i=-1!==t.to?"bytes="+t.from.toString()+"-"+t.to.toString():"bytes="+t.from.toString()+"-",r["Range"]=i}else this._zeroStart&&(r["Range"]="bytes=0-");return{url:e,headers:r}},e.prototype.removeURLParameters=function(e){return e},e}();t["default"]=i},"./src/io/speed-sampler.js":
/*!*********************************!*\
!*** ./src/io/speed-sampler.js ***!
\*********************************/function(e,t,r){"use strict";r.r(t);var i=function(){function e(){this._firstCheckpoint=0,this._lastCheckpoint=0,this._intervalBytes=0,this._totalBytes=0,this._lastSecondBytes=0,self.performance&&self.performance.now?this._now=self.performance.now.bind(self.performance):this._now=Date.now}return e.prototype.reset=function(){this._firstCheckpoint=this._lastCheckpoint=0,this._totalBytes=this._intervalBytes=0,this._lastSecondBytes=0},e.prototype.addBytes=function(e){0===this._firstCheckpoint?(this._firstCheckpoint=this._now(),this._lastCheckpoint=this._firstCheckpoint,this._intervalBytes+=e,this._totalBytes+=e):this._now()-this._lastCheckpoint<1e3?(this._intervalBytes+=e,this._totalBytes+=e):(this._lastSecondBytes=this._intervalBytes,this._intervalBytes=e,this._totalBytes+=e,this._lastCheckpoint=this._now())},Object.defineProperty(e.prototype,"currentKBps",{get:function(){this.addBytes(0);var e=(this._now()-this._lastCheckpoint)/1e3;return 0==e&&(e=1),this._intervalBytes/e/1024},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lastSecondKBps",{get:function(){return this.addBytes(0),0!==this._lastSecondBytes?this._lastSecondBytes/1024:this._now()-this._lastCheckpoint>=500?this.currentKBps:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"averageKBps",{get:function(){var e=(this._now()-this._firstCheckpoint)/1e3;return this._totalBytes/e/1024},enumerable:!1,configurable:!0}),e}();t["default"]=i},"./src/io/websocket-loader.js":
/*!************************************!*\
!*** ./src/io/websocket-loader.js ***!
\************************************/function(e,t,r){"use strict";r.r(t);var i=r(/*! ./loader.js */"./src/io/loader.js"),s=r(/*! ../utils/exception.js */"./src/utils/exception.js"),n=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!==typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function i(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}}(),a=function(e){function t(){var t=e.call(this,"websocket-loader")||this;return t.TAG="WebSocketLoader",t._needStash=!0,t._ws=null,t._requestAbort=!1,t._receivedLength=0,t}return n(t,e),t.isSupported=function(){try{return"undefined"!==typeof self.WebSocket}catch(e){return!1}},t.prototype.destroy=function(){this._ws&&this.abort(),e.prototype.destroy.call(this)},t.prototype.open=function(e){try{var t=this._ws=new self.WebSocket(e.url);t.binaryType="arraybuffer",t.onopen=this._onWebSocketOpen.bind(this),t.onclose=this._onWebSocketClose.bind(this),t.onmessage=this._onWebSocketMessage.bind(this),t.onerror=this._onWebSocketError.bind(this),this._status=i.LoaderStatus.kConnecting}catch(n){this._status=i.LoaderStatus.kError;var r={code:n.code,msg:n.message};if(!this._onError)throw new s.RuntimeException(r.msg);this._onError(i.LoaderErrors.EXCEPTION,r)}},t.prototype.abort=function(){var e=this._ws;!e||0!==e.readyState&&1!==e.readyState||(this._requestAbort=!0,e.close()),this._ws=null,this._status=i.LoaderStatus.kComplete},t.prototype._onWebSocketOpen=function(e){this._status=i.LoaderStatus.kBuffering},t.prototype._onWebSocketClose=function(e){!0!==this._requestAbort?(this._status=i.LoaderStatus.kComplete,this._onComplete&&this._onComplete(0,this._receivedLength-1)):this._requestAbort=!1},t.prototype._onWebSocketMessage=function(e){var t=this;if(e.data instanceof ArrayBuffer)this._dispatchArrayBuffer(e.data);else if(e.data instanceof Blob){var r=new FileReader;r.onload=function(){t._dispatchArrayBuffer(r.result)},r.readAsArrayBuffer(e.data)}else{this._status=i.LoaderStatus.kError;var n={code:-1,msg:"Unsupported WebSocket message type: "+e.data.constructor.name};if(!this._onError)throw new s.RuntimeException(n.msg);this._onError(i.LoaderErrors.EXCEPTION,n)}},t.prototype._dispatchArrayBuffer=function(e){var t=e,r=this._receivedLength;this._receivedLength+=t.byteLength,this._onDataArrival&&this._onDataArrival(t,r,this._receivedLength)},t.prototype._onWebSocketError=function(e){this._status=i.LoaderStatus.kError;var t={code:e.code,msg:e.message};if(!this._onError)throw new s.RuntimeException(t.msg);this._onError(i.LoaderErrors.EXCEPTION,t)},t}(i.BaseLoader);t["default"]=a},"./src/io/xhr-moz-chunked-loader.js":
/*!******************************************!*\
!*** ./src/io/xhr-moz-chunked-loader.js ***!
\******************************************/function(e,t,r){"use strict";r.r(t);var i=r(/*! ../utils/logger.js */"./src/utils/logger.js"),s=r(/*! ./loader.js */"./src/io/loader.js"),n=r(/*! ../utils/exception.js */"./src/utils/exception.js"),a=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!==typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function i(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}}(),o=function(e){function t(t,r){var i=e.call(this,"xhr-moz-chunked-loader")||this;return i.TAG="MozChunkedLoader",i._seekHandler=t,i._config=r,i._needStash=!0,i._xhr=null,i._requestAbort=!1,i._contentLength=null,i._receivedLength=0,i}return a(t,e),t.isSupported=function(){try{var e=new XMLHttpRequest;return e.open("GET","https://example.com",!0),e.responseType="moz-chunked-arraybuffer","moz-chunked-arraybuffer"===e.responseType}catch(t){return i.default.w("MozChunkedLoader",t.message),!1}},t.prototype.destroy=function(){this.isWorking()&&this.abort(),this._xhr&&(this._xhr.onreadystatechange=null,this._xhr.onprogress=null,this._xhr.onloadend=null,this._xhr.onerror=null,this._xhr=null),e.prototype.destroy.call(this)},t.prototype.open=function(e,t){this._dataSource=e,this._range=t;var r=e.url;this._config.reuseRedirectedURL&&void 0!=e.redirectedURL&&(r=e.redirectedURL);var i=this._seekHandler.getConfig(r,t);this._requestURL=i.url;var n=this._xhr=new XMLHttpRequest;if(n.open("GET",i.url,!0),n.responseType="moz-chunked-arraybuffer",n.onreadystatechange=this._onReadyStateChange.bind(this),n.onprogress=this._onProgress.bind(this),n.onloadend=this._onLoadEnd.bind(this),n.onerror=this._onXhrError.bind(this),e.withCredentials&&(n.withCredentials=!0),"object"===typeof i.headers){var a=i.headers;for(var o in a)a.hasOwnProperty(o)&&n.setRequestHeader(o,a[o])}if("object"===typeof this._config.headers){a=this._config.headers;for(var o in a)a.hasOwnProperty(o)&&n.setRequestHeader(o,a[o])}this._status=s.LoaderStatus.kConnecting,n.send()},t.prototype.abort=function(){this._requestAbort=!0,this._xhr&&this._xhr.abort(),this._status=s.LoaderStatus.kComplete},t.prototype._onReadyStateChange=function(e){var t=e.target;if(2===t.readyState){if(void 0!=t.responseURL&&t.responseURL!==this._requestURL&&this._onURLRedirect){var r=this._seekHandler.removeURLParameters(t.responseURL);this._onURLRedirect(r)}if(0!==t.status&&(t.status<200||t.status>299)){if(this._status=s.LoaderStatus.kError,!this._onError)throw new n.RuntimeException("MozChunkedLoader: Http code invalid, "+t.status+" "+t.statusText);this._onError(s.LoaderErrors.HTTP_STATUS_CODE_INVALID,{code:t.status,msg:t.statusText})}else this._status=s.LoaderStatus.kBuffering}},t.prototype._onProgress=function(e){if(this._status!==s.LoaderStatus.kError){null===this._contentLength&&null!==e.total&&0!==e.total&&(this._contentLength=e.total,this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength));var t=e.target.response,r=this._range.from+this._receivedLength;this._receivedLength+=t.byteLength,this._onDataArrival&&this._onDataArrival(t,r,this._receivedLength)}},t.prototype._onLoadEnd=function(e){!0!==this._requestAbort?this._status!==s.LoaderStatus.kError&&(this._status=s.LoaderStatus.kComplete,this._onComplete&&this._onComplete(this._range.from,this._range.from+this._receivedLength-1)):this._requestAbort=!1},t.prototype._onXhrError=function(e){this._status=s.LoaderStatus.kError;var t=0,r=null;if(this._contentLength&&e.loaded<this._contentLength?(t=s.LoaderErrors.EARLY_EOF,r={code:-1,msg:"Moz-Chunked stream meet Early-Eof"}):(t=s.LoaderErrors.EXCEPTION,r={code:-1,msg:e.constructor.name+" "+e.type}),!this._onError)throw new n.RuntimeException(r.msg);this._onError(t,r)},t}(s.BaseLoader);t["default"]=o},"./src/io/xhr-range-loader.js":
/*!************************************!*\
!*** ./src/io/xhr-range-loader.js ***!
\************************************/function(e,t,r){"use strict";r.r(t);var i=r(/*! ../utils/logger.js */"./src/utils/logger.js"),s=r(/*! ./speed-sampler.js */"./src/io/speed-sampler.js"),n=r(/*! ./loader.js */"./src/io/loader.js"),a=r(/*! ../utils/exception.js */"./src/utils/exception.js"),o=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!==typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function i(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}}(),l=function(e){function t(t,r){var i=e.call(this,"xhr-range-loader")||this;return i.TAG="RangeLoader",i._seekHandler=t,i._config=r,i._needStash=!1,i._chunkSizeKBList=[128,256,384,512,768,1024,1536,2048,3072,4096,5120,6144,7168,8192],i._currentChunkSizeKB=384,i._currentSpeedNormalized=0,i._zeroSpeedChunkCount=0,i._xhr=null,i._speedSampler=new s.default,i._requestAbort=!1,i._waitForTotalLength=!1,i._totalLengthReceived=!1,i._currentRequestURL=null,i._currentRedirectedURL=null,i._currentRequestRange=null,i._totalLength=null,i._contentLength=null,i._receivedLength=0,i._lastTimeLoaded=0,i}return o(t,e),t.isSupported=function(){try{var e=new XMLHttpRequest;return e.open("GET","https://example.com",!0),e.responseType="arraybuffer","arraybuffer"===e.responseType}catch(t){return i.default.w("RangeLoader",t.message),!1}},t.prototype.destroy=function(){this.isWorking()&&this.abort(),this._xhr&&(this._xhr.onreadystatechange=null,this._xhr.onprogress=null,this._xhr.onload=null,this._xhr.onerror=null,this._xhr=null),e.prototype.destroy.call(this)},Object.defineProperty(t.prototype,"currentSpeed",{get:function(){return this._speedSampler.lastSecondKBps},enumerable:!1,configurable:!0}),t.prototype.open=function(e,t){this._dataSource=e,this._range=t,this._status=n.LoaderStatus.kConnecting;var r=!1;void 0!=this._dataSource.filesize&&0!==this._dataSource.filesize&&(r=!0,this._totalLength=this._dataSource.filesize),this._totalLengthReceived||r?this._openSubRange():(this._waitForTotalLength=!0,this._internalOpen(this._dataSource,{from:0,to:-1}))},t.prototype._openSubRange=function(){var e=1024*this._currentChunkSizeKB,t=this._range.from+this._receivedLength,r=t+e;null!=this._contentLength&&r-this._range.from>=this._contentLength&&(r=this._range.from+this._contentLength-1),this._currentRequestRange={from:t,to:r},this._internalOpen(this._dataSource,this._currentRequestRange)},t.prototype._internalOpen=function(e,t){this._lastTimeLoaded=0;var r=e.url;this._config.reuseRedirectedURL&&(void 0!=this._currentRedirectedURL?r=this._currentRedirectedURL:void 0!=e.redirectedURL&&(r=e.redirectedURL));var i=this._seekHandler.getConfig(r,t);this._currentRequestURL=i.url;var s=this._xhr=new XMLHttpRequest;if(s.open("GET",i.url,!0),s.responseType="arraybuffer",s.onreadystatechange=this._onReadyStateChange.bind(this),s.onprogress=this._onProgress.bind(this),s.onload=this._onLoad.bind(this),s.onerror=this._onXhrError.bind(this),e.withCredentials&&(s.withCredentials=!0),"object"===typeof i.headers){var n=i.headers;for(var a in n)n.hasOwnProperty(a)&&s.setRequestHeader(a,n[a])}if("object"===typeof this._config.headers){n=this._config.headers;for(var a in n)n.hasOwnProperty(a)&&s.setRequestHeader(a,n[a])}s.send()},t.prototype.abort=function(){this._requestAbort=!0,this._internalAbort(),this._status=n.LoaderStatus.kComplete},t.prototype._internalAbort=function(){this._xhr&&(this._xhr.onreadystatechange=null,this._xhr.onprogress=null,this._xhr.onload=null,this._xhr.onerror=null,this._xhr.abort(),this._xhr=null)},t.prototype._onReadyStateChange=function(e){var t=e.target;if(2===t.readyState){if(void 0!=t.responseURL){var r=this._seekHandler.removeURLParameters(t.responseURL);t.responseURL!==this._currentRequestURL&&r!==this._currentRedirectedURL&&(this._currentRedirectedURL=r,this._onURLRedirect&&this._onURLRedirect(r))}if(t.status>=200&&t.status<=299){if(this._waitForTotalLength)return;this._status=n.LoaderStatus.kBuffering}else{if(this._status=n.LoaderStatus.kError,!this._onError)throw new a.RuntimeException("RangeLoader: Http code invalid, "+t.status+" "+t.statusText);this._onError(n.LoaderErrors.HTTP_STATUS_CODE_INVALID,{code:t.status,msg:t.statusText})}}},t.prototype._onProgress=function(e){if(this._status!==n.LoaderStatus.kError){if(null===this._contentLength){var t=!1;if(this._waitForTotalLength){this._waitForTotalLength=!1,this._totalLengthReceived=!0,t=!0;var r=e.total;this._internalAbort(),null!=r&0!==r&&(this._totalLength=r)}if(-1===this._range.to?this._contentLength=this._totalLength-this._range.from:this._contentLength=this._range.to-this._range.from+1,t)return void this._openSubRange();this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength)}var i=e.loaded-this._lastTimeLoaded;this._lastTimeLoaded=e.loaded,this._speedSampler.addBytes(i)}},t.prototype._normalizeSpeed=function(e){var t=this._chunkSizeKBList,r=t.length-1,i=0,s=0,n=r;if(e<t[0])return t[0];while(s<=n){if(i=s+Math.floor((n-s)/2),i===r||e>=t[i]&&e<t[i+1])return t[i];t[i]<e?s=i+1:n=i-1}},t.prototype._onLoad=function(e){if(this._status!==n.LoaderStatus.kError)if(this._waitForTotalLength)this._waitForTotalLength=!1;else{this._lastTimeLoaded=0;var t=this._speedSampler.lastSecondKBps;if(0===t&&(this._zeroSpeedChunkCount++,this._zeroSpeedChunkCount>=3&&(t=this._speedSampler.currentKBps)),0!==t){var r=this._normalizeSpeed(t);this._currentSpeedNormalized!==r&&(this._currentSpeedNormalized=r,this._currentChunkSizeKB=r)}var i=e.target.response,s=this._range.from+this._receivedLength;this._receivedLength+=i.byteLength;var a=!1;null!=this._contentLength&&this._receivedLength<this._contentLength?this._openSubRange():a=!0,this._onDataArrival&&this._onDataArrival(i,s,this._receivedLength),a&&(this._status=n.LoaderStatus.kComplete,this._onComplete&&this._onComplete(this._range.from,this._range.from+this._receivedLength-1))}},t.prototype._onXhrError=function(e){this._status=n.LoaderStatus.kError;var t=0,r=null;if(this._contentLength&&this._receivedLength>0&&this._receivedLength<this._contentLength?(t=n.LoaderErrors.EARLY_EOF,r={code:-1,msg:"RangeLoader meet Early-Eof"}):(t=n.LoaderErrors.EXCEPTION,r={code:-1,msg:e.constructor.name+" "+e.type}),!this._onError)throw new a.RuntimeException(r.msg);this._onError(t,r)},t}(n.BaseLoader);t["default"]=l},"./src/player/flv-player.js":
/*!**********************************!*\
!*** ./src/player/flv-player.js ***!
\**********************************/function(e,t,r){"use strict";r.r(t);var i=r(/*! events */"./node_modules/events/events.js"),s=r.n(i),n=r(/*! ../utils/logger.js */"./src/utils/logger.js"),a=r(/*! ../utils/browser.js */"./src/utils/browser.js"),o=r(/*! ./player-events.js */"./src/player/player-events.js"),l=r(/*! ../core/transmuxer.js */"./src/core/transmuxer.js"),d=r(/*! ../core/transmuxing-events.js */"./src/core/transmuxing-events.js"),h=r(/*! ../core/mse-controller.js */"./src/core/mse-controller.js"),c=r(/*! ../core/mse-events.js */"./src/core/mse-events.js"),u=r(/*! ./player-errors.js */"./src/player/player-errors.js"),f=r(/*! ../config.js */"./src/config.js"),p=r(/*! ../utils/exception.js */"./src/utils/exception.js"),m=function(){function e(e,t){if(this.TAG="FlvPlayer",this._type="FlvPlayer",this._emitter=new(s()),this._config=(0,f.createDefaultConfig)(),"object"===typeof t&&Object.assign(this._config,t),"flv"!==e.type.toLowerCase())throw new p.InvalidArgumentException("FlvPlayer requires an flv MediaDataSource input!");!0===e.isLive&&(this._config.isLive=!0),this.e={onvLoadedMetadata:this._onvLoadedMetadata.bind(this),onvSeeking:this._onvSeeking.bind(this),onvCanPlay:this._onvCanPlay.bind(this),onvStalled:this._onvStalled.bind(this),onvProgress:this._onvProgress.bind(this)},self.performance&&self.performance.now?this._now=self.performance.now.bind(self.performance):this._now=Date.now,this._pendingSeekTime=null,this._requestSetTime=!1,this._seekpointRecord=null,this._progressChecker=null,this._mediaDataSource=e,this._mediaElement=null,this._msectl=null,this._transmuxer=null,this._mseSourceOpened=!1,this._hasPendingLoad=!1,this._receivedCanPlay=!1,this._mediaInfo=null,this._statisticsInfo=null;var r=a.default.chrome&&(a.default.version.major<50||50===a.default.version.major&&a.default.version.build<2661);this._alwaysSeekKeyframe=!!(r||a.default.msedge||a.default.msie),this._alwaysSeekKeyframe&&(this._config.accurateSeek=!1)}return e.prototype.destroy=function(){null!=this._progressChecker&&(window.clearInterval(this._progressChecker),this._progressChecker=null),this._transmuxer&&this.unload(),this._mediaElement&&this.detachMediaElement(),this.e=null,this._mediaDataSource=null,this._emitter.removeAllListeners(),this._emitter=null},e.prototype.on=function(e,t){var r=this;e===o.default.MEDIA_INFO?null!=this._mediaInfo&&Promise.resolve().then((function(){r._emitter.emit(o.default.MEDIA_INFO,r.mediaInfo)})):e===o.default.STATISTICS_INFO&&null!=this._statisticsInfo&&Promise.resolve().then((function(){r._emitter.emit(o.default.STATISTICS_INFO,r.statisticsInfo)})),this._emitter.addListener(e,t)},e.prototype.off=function(e,t){this._emitter.removeListener(e,t)},e.prototype.attachMediaElement=function(e){var t=this;if(this._mediaElement=e,e.addEventListener("loadedmetadata",this.e.onvLoadedMetadata),e.addEventListener("seeking",this.e.onvSeeking),e.addEventListener("canplay",this.e.onvCanPlay),e.addEventListener("stalled",this.e.onvStalled),e.addEventListener("progress",this.e.onvProgress),this._msectl=new h.default(this._config),this._msectl.on(c.default.UPDATE_END,this._onmseUpdateEnd.bind(this)),this._msectl.on(c.default.BUFFER_FULL,this._onmseBufferFull.bind(this)),this._msectl.on(c.default.SOURCE_OPEN,(function(){t._mseSourceOpened=!0,t._hasPendingLoad&&(t._hasPendingLoad=!1,t.load())})),this._msectl.on(c.default.ERROR,(function(e){t._emitter.emit(o.default.ERROR,u.ErrorTypes.MEDIA_ERROR,u.ErrorDetails.MEDIA_MSE_ERROR,e)})),this._msectl.attachMediaElement(e),null!=this._pendingSeekTime)try{e.currentTime=this._pendingSeekTime,this._pendingSeekTime=null}catch(r){}},e.prototype.detachMediaElement=function(){this._mediaElement&&(this._msectl.detachMediaElement(),this._mediaElement.removeEventListener("loadedmetadata",this.e.onvLoadedMetadata),this._mediaElement.removeEventListener("seeking",this.e.onvSeeking),this._mediaElement.removeEventListener("canplay",this.e.onvCanPlay),this._mediaElement.removeEventListener("stalled",this.e.onvStalled),this._mediaElement.removeEventListener("progress",this.e.onvProgress),this._mediaElement=null),this._msectl&&(this._msectl.destroy(),this._msectl=null)},e.prototype.load=function(){var e=this;if(!this._mediaElement)throw new p.IllegalStateException("HTMLMediaElement must be attached before load()!");if(this._transmuxer)throw new p.IllegalStateException("FlvPlayer.load() has been called, please call unload() first!");this._hasPendingLoad||(this._config.deferLoadAfterSourceOpen&&!1===this._mseSourceOpened?this._hasPendingLoad=!0:(this._mediaElement.readyState>0&&(this._requestSetTime=!0,this._mediaElement.currentTime=0),this._transmuxer=new l.default(this._mediaDataSource,this._config),this._transmuxer.on(d.default.INIT_SEGMENT,(function(t,r){e._msectl.appendInitSegment(r)})),this._transmuxer.on(d.default.MEDIA_SEGMENT,(function(t,r){if(e._msectl.appendMediaSegment(r),e._config.lazyLoad&&!e._config.isLive){var i=e._mediaElement.currentTime;r.info.endDts>=1e3*(i+e._config.lazyLoadMaxDuration)&&null==e._progressChecker&&(n.default.v(e.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),e._suspendTransmuxer())}})),this._transmuxer.on(d.default.LOADING_COMPLETE,(function(){e._msectl.endOfStream(),e._emitter.emit(o.default.LOADING_COMPLETE)})),this._transmuxer.on(d.default.RECOVERED_EARLY_EOF,(function(){e._emitter.emit(o.default.RECOVERED_EARLY_EOF)})),this._transmuxer.on(d.default.IO_ERROR,(function(t,r){e._emitter.emit(o.default.ERROR,u.ErrorTypes.NETWORK_ERROR,t,r)})),this._transmuxer.on(d.default.DEMUX_ERROR,(function(t,r){e._emitter.emit(o.default.ERROR,u.ErrorTypes.MEDIA_ERROR,t,{code:-1,msg:r})})),this._transmuxer.on(d.default.MEDIA_INFO,(function(t){e._mediaInfo=t,e._emitter.emit(o.default.MEDIA_INFO,Object.assign({},t))})),this._transmuxer.on(d.default.METADATA_ARRIVED,(function(t){e._emitter.emit(o.default.METADATA_ARRIVED,t)})),this._transmuxer.on(d.default.SCRIPTDATA_ARRIVED,(function(t){e._emitter.emit(o.default.SCRIPTDATA_ARRIVED,t)})),this._transmuxer.on(d.default.STATISTICS_INFO,(function(t){e._statisticsInfo=e._fillStatisticsInfo(t),e._emitter.emit(o.default.STATISTICS_INFO,Object.assign({},e._statisticsInfo))})),this._transmuxer.on(d.default.RECOMMEND_SEEKPOINT,(function(t){e._mediaElement&&!e._config.accurateSeek&&(e._requestSetTime=!0,e._mediaElement.currentTime=t/1e3)})),this._transmuxer.open()))},e.prototype.unload=function(){this._mediaElement&&this._mediaElement.pause(),this._msectl&&this._msectl.seek(0),this._transmuxer&&(this._transmuxer.close(),this._transmuxer.destroy(),this._transmuxer=null)},e.prototype.play=function(){return this._mediaElement.play()},e.prototype.pause=function(){this._mediaElement.pause()},Object.defineProperty(e.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"buffered",{get:function(){return this._mediaElement.buffered},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"duration",{get:function(){return this._mediaElement.duration},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"volume",{get:function(){return this._mediaElement.volume},set:function(e){this._mediaElement.volume=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"muted",{get:function(){return this._mediaElement.muted},set:function(e){this._mediaElement.muted=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentTime",{get:function(){return this._mediaElement?this._mediaElement.currentTime:0},set:function(e){this._mediaElement?this._internalSeek(e):this._pendingSeekTime=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"mediaInfo",{get:function(){return Object.assign({},this._mediaInfo)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"statisticsInfo",{get:function(){return null==this._statisticsInfo&&(this._statisticsInfo={}),this._statisticsInfo=this._fillStatisticsInfo(this._statisticsInfo),Object.assign({},this._statisticsInfo)},enumerable:!1,configurable:!0}),e.prototype._fillStatisticsInfo=function(e){if(e.playerType=this._type,!(this._mediaElement instanceof HTMLVideoElement))return e;var t=!0,r=0,i=0;if(this._mediaElement.getVideoPlaybackQuality){var s=this._mediaElement.getVideoPlaybackQuality();r=s.totalVideoFrames,i=s.droppedVideoFrames}else void 0!=this._mediaElement.webkitDecodedFrameCount?(r=this._mediaElement.webkitDecodedFrameCount,i=this._mediaElement.webkitDroppedFrameCount):t=!1;return t&&(e.decodedFrames=r,e.droppedFrames=i),e},e.prototype._onmseUpdateEnd=function(){if(this._config.lazyLoad&&!this._config.isLive){for(var e=this._mediaElement.buffered,t=this._mediaElement.currentTime,r=0,i=0;i<e.length;i++){var s=e.start(i),a=e.end(i);if(s<=t&&t<a){s,r=a;break}}r>=t+this._config.lazyLoadMaxDuration&&null==this._progressChecker&&(n.default.v(this.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),this._suspendTransmuxer())}},e.prototype._onmseBufferFull=function(){n.default.v(this.TAG,"MSE SourceBuffer is full, suspend transmuxing task"),null==this._progressChecker&&this._suspendTransmuxer()},e.prototype._suspendTransmuxer=function(){this._transmuxer&&(this._transmuxer.pause(),null==this._progressChecker&&(this._progressChecker=window.setInterval(this._checkProgressAndResume.bind(this),1e3)))},e.prototype._checkProgressAndResume=function(){for(var e=this._mediaElement.currentTime,t=this._mediaElement.buffered,r=!1,i=0;i<t.length;i++){var s=t.start(i),a=t.end(i);if(e>=s&&e<a){e>=a-this._config.lazyLoadRecoverDuration&&(r=!0);break}}r&&(window.clearInterval(this._progressChecker),this._progressChecker=null,r&&(n.default.v(this.TAG,"Continue loading from paused position"),this._transmuxer.resume()))},e.prototype._isTimepointBuffered=function(e){for(var t=this._mediaElement.buffered,r=0;r<t.length;r++){var i=t.start(r),s=t.end(r);if(e>=i&&e<s)return!0}return!1},e.prototype._internalSeek=function(e){var t=this._isTimepointBuffered(e),r=!1,i=0;if(e<1&&this._mediaElement.buffered.length>0){var s=this._mediaElement.buffered.start(0);(s<1&&e<s||a.default.safari)&&(r=!0,i=a.default.safari?.1:s)}if(r)this._requestSetTime=!0,this._mediaElement.currentTime=i;else if(t){if(this._alwaysSeekKeyframe){var n=this._msectl.getNearestKeyframe(Math.floor(1e3*e));this._requestSetTime=!0,this._mediaElement.currentTime=null!=n?n.dts/1e3:e}else this._requestSetTime=!0,this._mediaElement.currentTime=e;null!=this._progressChecker&&this._checkProgressAndResume()}else null!=this._progressChecker&&(window.clearInterval(this._progressChecker),this._progressChecker=null),this._msectl.seek(e),this._transmuxer.seek(Math.floor(1e3*e)),this._config.accurateSeek&&(this._requestSetTime=!0,this._mediaElement.currentTime=e)},e.prototype._checkAndApplyUnbufferedSeekpoint=function(){if(this._seekpointRecord)if(this._seekpointRecord.recordTime<=this._now()-100){var e=this._mediaElement.currentTime;this._seekpointRecord=null,this._isTimepointBuffered(e)||(null!=this._progressChecker&&(window.clearTimeout(this._progressChecker),this._progressChecker=null),this._msectl.seek(e),this._transmuxer.seek(Math.floor(1e3*e)),this._config.accurateSeek&&(this._requestSetTime=!0,this._mediaElement.currentTime=e))}else window.setTimeout(this._checkAndApplyUnbufferedSeekpoint.bind(this),50)},e.prototype._checkAndResumeStuckPlayback=function(e){var t=this._mediaElement;if(e||!this._receivedCanPlay||t.readyState<2){var r=t.buffered;r.length>0&&t.currentTime<r.start(0)&&(n.default.w(this.TAG,"Playback seems stuck at "+t.currentTime+", seek to "+r.start(0)),this._requestSetTime=!0,this._mediaElement.currentTime=r.start(0),this._mediaElement.removeEventListener("progress",this.e.onvProgress))}else this._mediaElement.removeEventListener("progress",this.e.onvProgress)},e.prototype._onvLoadedMetadata=function(e){null!=this._pendingSeekTime&&(this._mediaElement.currentTime=this._pendingSeekTime,this._pendingSeekTime=null)},e.prototype._onvSeeking=function(e){var t=this._mediaElement.currentTime,r=this._mediaElement.buffered;if(this._requestSetTime)this._requestSetTime=!1;else{if(t<1&&r.length>0){var i=r.start(0);if(i<1&&t<i||a.default.safari)return this._requestSetTime=!0,void(this._mediaElement.currentTime=a.default.safari?.1:i)}if(this._isTimepointBuffered(t)){if(this._alwaysSeekKeyframe){var s=this._msectl.getNearestKeyframe(Math.floor(1e3*t));null!=s&&(this._requestSetTime=!0,this._mediaElement.currentTime=s.dts/1e3)}null!=this._progressChecker&&this._checkProgressAndResume()}else this._seekpointRecord={seekPoint:t,recordTime:this._now()},window.setTimeout(this._checkAndApplyUnbufferedSeekpoint.bind(this),50)}},e.prototype._onvCanPlay=function(e){this._receivedCanPlay=!0,this._mediaElement.removeEventListener("canplay",this.e.onvCanPlay)},e.prototype._onvStalled=function(e){this._checkAndResumeStuckPlayback(!0)},e.prototype._onvProgress=function(e){this._checkAndResumeStuckPlayback()},e}();t["default"]=m},"./src/player/native-player.js":
/*!*************************************!*\
!*** ./src/player/native-player.js ***!
\*************************************/function(e,t,r){"use strict";r.r(t);var i=r(/*! events */"./node_modules/events/events.js"),s=r.n(i),n=r(/*! ./player-events.js */"./src/player/player-events.js"),a=r(/*! ../config.js */"./src/config.js"),o=r(/*! ../utils/exception.js */"./src/utils/exception.js"),l=function(){function e(e,t){if(this.TAG="NativePlayer",this._type="NativePlayer",this._emitter=new(s()),this._config=(0,a.createDefaultConfig)(),"object"===typeof t&&Object.assign(this._config,t),"flv"===e.type.toLowerCase())throw new o.InvalidArgumentException("NativePlayer does't support flv MediaDataSource input!");if(e.hasOwnProperty("segments"))throw new o.InvalidArgumentException("NativePlayer("+e.type+") doesn't support multipart playback!");this.e={onvLoadedMetadata:this._onvLoadedMetadata.bind(this)},this._pendingSeekTime=null,this._statisticsReporter=null,this._mediaDataSource=e,this._mediaElement=null}return e.prototype.destroy=function(){this._mediaElement&&(this.unload(),this.detachMediaElement()),this.e=null,this._mediaDataSource=null,this._emitter.removeAllListeners(),this._emitter=null},e.prototype.on=function(e,t){var r=this;e===n.default.MEDIA_INFO?null!=this._mediaElement&&0!==this._mediaElement.readyState&&Promise.resolve().then((function(){r._emitter.emit(n.default.MEDIA_INFO,r.mediaInfo)})):e===n.default.STATISTICS_INFO&&null!=this._mediaElement&&0!==this._mediaElement.readyState&&Promise.resolve().then((function(){r._emitter.emit(n.default.STATISTICS_INFO,r.statisticsInfo)})),this._emitter.addListener(e,t)},e.prototype.off=function(e,t){this._emitter.removeListener(e,t)},e.prototype.attachMediaElement=function(e){if(this._mediaElement=e,e.addEventListener("loadedmetadata",this.e.onvLoadedMetadata),null!=this._pendingSeekTime)try{e.currentTime=this._pendingSeekTime,this._pendingSeekTime=null}catch(t){}},e.prototype.detachMediaElement=function(){this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src"),this._mediaElement.removeEventListener("loadedmetadata",this.e.onvLoadedMetadata),this._mediaElement=null),null!=this._statisticsReporter&&(window.clearInterval(this._statisticsReporter),this._statisticsReporter=null)},e.prototype.load=function(){if(!this._mediaElement)throw new o.IllegalStateException("HTMLMediaElement must be attached before load()!");this._mediaElement.src=this._mediaDataSource.url,this._mediaElement.readyState>0&&(this._mediaElement.currentTime=0),this._mediaElement.preload="auto",this._mediaElement.load(),this._statisticsReporter=window.setInterval(this._reportStatisticsInfo.bind(this),this._config.statisticsInfoReportInterval)},e.prototype.unload=function(){this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src")),null!=this._statisticsReporter&&(window.clearInterval(this._statisticsReporter),this._statisticsReporter=null)},e.prototype.play=function(){return this._mediaElement.play()},e.prototype.pause=function(){this._mediaElement.pause()},Object.defineProperty(e.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"buffered",{get:function(){return this._mediaElement.buffered},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"duration",{get:function(){return this._mediaElement.duration},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"volume",{get:function(){return this._mediaElement.volume},set:function(e){this._mediaElement.volume=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"muted",{get:function(){return this._mediaElement.muted},set:function(e){this._mediaElement.muted=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentTime",{get:function(){return this._mediaElement?this._mediaElement.currentTime:0},set:function(e){this._mediaElement?this._mediaElement.currentTime=e:this._pendingSeekTime=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"mediaInfo",{get:function(){var e=this._mediaElement instanceof HTMLAudioElement?"audio/":"video/",t={mimeType:e+this._mediaDataSource.type};return this._mediaElement&&(t.duration=Math.floor(1e3*this._mediaElement.duration),this._mediaElement instanceof HTMLVideoElement&&(t.width=this._mediaElement.videoWidth,t.height=this._mediaElement.videoHeight)),t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"statisticsInfo",{get:function(){var e={playerType:this._type,url:this._mediaDataSource.url};if(!(this._mediaElement instanceof HTMLVideoElement))return e;var t=!0,r=0,i=0;if(this._mediaElement.getVideoPlaybackQuality){var s=this._mediaElement.getVideoPlaybackQuality();r=s.totalVideoFrames,i=s.droppedVideoFrames}else void 0!=this._mediaElement.webkitDecodedFrameCount?(r=this._mediaElement.webkitDecodedFrameCount,i=this._mediaElement.webkitDroppedFrameCount):t=!1;return t&&(e.decodedFrames=r,e.droppedFrames=i),e},enumerable:!1,configurable:!0}),e.prototype._onvLoadedMetadata=function(e){null!=this._pendingSeekTime&&(this._mediaElement.currentTime=this._pendingSeekTime,this._pendingSeekTime=null),this._emitter.emit(n.default.MEDIA_INFO,this.mediaInfo)},e.prototype._reportStatisticsInfo=function(){this._emitter.emit(n.default.STATISTICS_INFO,this.statisticsInfo)},e}();t["default"]=l},"./src/player/player-errors.js":
/*!*************************************!*\
!*** ./src/player/player-errors.js ***!
\*************************************/function(e,t,r){"use strict";r.r(t),r.d(t,{ErrorTypes:function(){return n},ErrorDetails:function(){return a}});var i=r(/*! ../io/loader.js */"./src/io/loader.js"),s=r(/*! ../demux/demux-errors.js */"./src/demux/demux-errors.js"),n={NETWORK_ERROR:"NetworkError",MEDIA_ERROR:"MediaError",OTHER_ERROR:"OtherError"},a={NETWORK_EXCEPTION:i.LoaderErrors.EXCEPTION,NETWORK_STATUS_CODE_INVALID:i.LoaderErrors.HTTP_STATUS_CODE_INVALID,NETWORK_TIMEOUT:i.LoaderErrors.CONNECTING_TIMEOUT,NETWORK_UNRECOVERABLE_EARLY_EOF:i.LoaderErrors.UNRECOVERABLE_EARLY_EOF,MEDIA_MSE_ERROR:"MediaMSEError",MEDIA_FORMAT_ERROR:s.default.FORMAT_ERROR,MEDIA_FORMAT_UNSUPPORTED:s.default.FORMAT_UNSUPPORTED,MEDIA_CODEC_UNSUPPORTED:s.default.CODEC_UNSUPPORTED}},"./src/player/player-events.js":
/*!*************************************!*\
!*** ./src/player/player-events.js ***!
\*************************************/function(e,t,r){"use strict";r.r(t);var i={ERROR:"error",LOADING_COMPLETE:"loading_complete",RECOVERED_EARLY_EOF:"recovered_early_eof",MEDIA_INFO:"media_info",METADATA_ARRIVED:"metadata_arrived",SCRIPTDATA_ARRIVED:"scriptdata_arrived",STATISTICS_INFO:"statistics_info"};t["default"]=i},"./src/remux/aac-silent.js":
/*!*********************************!*\
!*** ./src/remux/aac-silent.js ***!
\*********************************/function(e,t,r){"use strict";r.r(t);var i=function(){function e(){}return e.getSilentFrame=function(e,t){if("mp4a.40.2"===e){if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(1===t)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}return null},e}();t["default"]=i},"./src/remux/mp4-generator.js":
/*!************************************!*\
!*** ./src/remux/mp4-generator.js ***!
\************************************/function(e,t,r){"use strict";r.r(t);var i=function(){function e(){}return e.init=function(){for(var t in e.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[],".mp3":[]},e.types)e.types.hasOwnProperty(t)&&(e.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);var r=e.constants={};r.FTYP=new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]),r.STSD_PREFIX=new Uint8Array([0,0,0,0,0,0,0,1]),r.STTS=new Uint8Array([0,0,0,0,0,0,0,0]),r.STSC=r.STCO=r.STTS,r.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),r.HDLR_VIDEO=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),r.HDLR_AUDIO=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]),r.DREF=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),r.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),r.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])},e.box=function(e){for(var t=8,r=null,i=Array.prototype.slice.call(arguments,1),s=i.length,n=0;n<s;n++)t+=i[n].byteLength;r=new Uint8Array(t),r[0]=t>>>24&255,r[1]=t>>>16&255,r[2]=t>>>8&255,r[3]=255&t,r.set(e,4);var a=8;for(n=0;n<s;n++)r.set(i[n],a),a+=i[n].byteLength;return r},e.generateInitSegment=function(t){var r=e.box(e.types.ftyp,e.constants.FTYP),i=e.moov(t),s=new Uint8Array(r.byteLength+i.byteLength);return s.set(r,0),s.set(i,r.byteLength),s},e.moov=function(t){var r=e.mvhd(t.timescale,t.duration),i=e.trak(t),s=e.mvex(t);return e.box(e.types.moov,r,i,s)},e.mvhd=function(t,r){return e.box(e.types.mvhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t,r>>>24&255,r>>>16&255,r>>>8&255,255&r,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]))},e.trak=function(t){return e.box(e.types.trak,e.tkhd(t),e.mdia(t))},e.tkhd=function(t){var r=t.id,i=t.duration,s=t.presentWidth,n=t.presentHeight;return e.box(e.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,r>>>24&255,r>>>16&255,r>>>8&255,255&r,0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,s>>>8&255,255&s,0,0,n>>>8&255,255&n,0,0]))},e.mdia=function(t){return e.box(e.types.mdia,e.mdhd(t),e.hdlr(t),e.minf(t))},e.mdhd=function(t){var r=t.timescale,i=t.duration;return e.box(e.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,r>>>24&255,r>>>16&255,r>>>8&255,255&r,i>>>24&255,i>>>16&255,i>>>8&255,255&i,85,196,0,0]))},e.hdlr=function(t){var r=null;return r="audio"===t.type?e.constants.HDLR_AUDIO:e.constants.HDLR_VIDEO,e.box(e.types.hdlr,r)},e.minf=function(t){var r=null;return r="audio"===t.type?e.box(e.types.smhd,e.constants.SMHD):e.box(e.types.vmhd,e.constants.VMHD),e.box(e.types.minf,r,e.dinf(),e.stbl(t))},e.dinf=function(){var t=e.box(e.types.dinf,e.box(e.types.dref,e.constants.DREF));return t},e.stbl=function(t){var r=e.box(e.types.stbl,e.stsd(t),e.box(e.types.stts,e.constants.STTS),e.box(e.types.stsc,e.constants.STSC),e.box(e.types.stsz,e.constants.STSZ),e.box(e.types.stco,e.constants.STCO));return r},e.stsd=function(t){return"audio"===t.type?"mp3"===t.codec?e.box(e.types.stsd,e.constants.STSD_PREFIX,e.mp3(t)):e.box(e.types.stsd,e.constants.STSD_PREFIX,e.mp4a(t)):e.box(e.types.stsd,e.constants.STSD_PREFIX,e.avc1(t))},e.mp3=function(t){var r=t.channelCount,i=t.audioSampleRate,s=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,r,0,16,0,0,0,0,i>>>8&255,255&i,0,0]);return e.box(e.types[".mp3"],s)},e.mp4a=function(t){var r=t.channelCount,i=t.audioSampleRate,s=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,r,0,16,0,0,0,0,i>>>8&255,255&i,0,0]);return e.box(e.types.mp4a,s,e.esds(t))},e.esds=function(t){var r=t.config||[],i=r.length,s=new Uint8Array([0,0,0,0,3,23+i,0,1,0,4,15+i,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([i]).concat(r).concat([6,1,2]));return e.box(e.types.esds,s)},e.avc1=function(t){var r=t.avcc,i=t.codecWidth,s=t.codecHeight,n=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,i>>>8&255,255&i,s>>>8&255,255&s,0,72,0,0,0,72,0,0,0,0,0,0,0,1,10,120,113,113,47,102,108,118,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,255,255]);return e.box(e.types.avc1,n,e.box(e.types.avcC,r))},e.mvex=function(t){return e.box(e.types.mvex,e.trex(t))},e.trex=function(t){var r=t.id,i=new Uint8Array([0,0,0,0,r>>>24&255,r>>>16&255,r>>>8&255,255&r,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return e.box(e.types.trex,i)},e.moof=function(t,r){return e.box(e.types.moof,e.mfhd(t.sequenceNumber),e.traf(t,r))},e.mfhd=function(t){var r=new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t]);return e.box(e.types.mfhd,r)},e.traf=function(t,r){var i=t.id,s=e.box(e.types.tfhd,new Uint8Array([0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i])),n=e.box(e.types.tfdt,new Uint8Array([0,0,0,0,r>>>24&255,r>>>16&255,r>>>8&255,255&r])),a=e.sdtp(t),o=e.trun(t,a.byteLength+16+16+8+16+8+8);return e.box(e.types.traf,s,n,o,a)},e.sdtp=function(t){for(var r=t.samples||[],i=r.length,s=new Uint8Array(4+i),n=0;n<i;n++){var a=r[n].flags;s[n+4]=a.isLeading<<6|a.dependsOn<<4|a.isDependedOn<<2|a.hasRedundancy}return e.box(e.types.sdtp,s)},e.trun=function(t,r){var i=t.samples||[],s=i.length,n=12+16*s,a=new Uint8Array(n);r+=8+n,a.set([0,0,15,1,s>>>24&255,s>>>16&255,s>>>8&255,255&s,r>>>24&255,r>>>16&255,r>>>8&255,255&r],0);for(var o=0;o<s;o++){var l=i[o].duration,d=i[o].size,h=i[o].flags,c=i[o].cts;a.set([l>>>24&255,l>>>16&255,l>>>8&255,255&l,d>>>24&255,d>>>16&255,d>>>8&255,255&d,h.isLeading<<2|h.dependsOn,h.isDependedOn<<6|h.hasRedundancy<<4|h.isNonSync,0,0,c>>>24&255,c>>>16&255,c>>>8&255,255&c],12+16*o)}return e.box(e.types.trun,a)},e.mdat=function(t){return e.box(e.types.mdat,t)},e}();i.init(),t["default"]=i},"./src/remux/mp4-remuxer.js":
/*!**********************************!*\
!*** ./src/remux/mp4-remuxer.js ***!
\**********************************/function(e,t,r){"use strict";r.r(t);var i=r(/*! ../utils/logger.js */"./src/utils/logger.js"),s=r(/*! ./mp4-generator.js */"./src/remux/mp4-generator.js"),n=r(/*! ./aac-silent.js */"./src/remux/aac-silent.js"),a=r(/*! ../utils/browser.js */"./src/utils/browser.js"),o=r(/*! ../core/media-segment-info.js */"./src/core/media-segment-info.js"),l=r(/*! ../utils/exception.js */"./src/utils/exception.js"),d=function(){function e(e){this.TAG="MP4Remuxer",this._config=e,this._isLive=!0===e.isLive,this._dtsBase=-1,this._dtsBaseInited=!1,this._audioDtsBase=1/0,this._videoDtsBase=1/0,this._audioNextDts=void 0,this._videoNextDts=void 0,this._audioStashedLastSample=null,this._videoStashedLastSample=null,this._audioMeta=null,this._videoMeta=null,this._audioSegmentInfoList=new o.MediaSegmentInfoList("audio"),this._videoSegmentInfoList=new o.MediaSegmentInfoList("video"),this._onInitSegment=null,this._onMediaSegment=null,this._forceFirstIDR=!(!a.default.chrome||!(a.default.version.major<50||50===a.default.version.major&&a.default.version.build<2661)),this._fillSilentAfterSeek=a.default.msedge||a.default.msie,this._mp3UseMpegAudio=!a.default.firefox,this._fillAudioTimestampGap=this._config.fixAudioTimestampGap}return e.prototype.destroy=function(){this._dtsBase=-1,this._dtsBaseInited=!1,this._audioMeta=null,this._videoMeta=null,this._audioSegmentInfoList.clear(),this._audioSegmentInfoList=null,this._videoSegmentInfoList.clear(),this._videoSegmentInfoList=null,this._onInitSegment=null,this._onMediaSegment=null},e.prototype.bindDataSource=function(e){return e.onDataAvailable=this.remux.bind(this),e.onTrackMetadata=this._onTrackMetadataReceived.bind(this),this},Object.defineProperty(e.prototype,"onInitSegment",{get:function(){return this._onInitSegment},set:function(e){this._onInitSegment=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onMediaSegment",{get:function(){return this._onMediaSegment},set:function(e){this._onMediaSegment=e},enumerable:!1,configurable:!0}),e.prototype.insertDiscontinuity=function(){this._audioNextDts=this._videoNextDts=void 0},e.prototype.seek=function(e){this._audioStashedLastSample=null,this._videoStashedLastSample=null,this._videoSegmentInfoList.clear(),this._audioSegmentInfoList.clear()},e.prototype.remux=function(e,t){if(!this._onMediaSegment)throw new l.IllegalStateException("MP4Remuxer: onMediaSegment callback must be specificed!");this._dtsBaseInited||this._calculateDtsBase(e,t),this._remuxVideo(t),this._remuxAudio(e)},e.prototype._onTrackMetadataReceived=function(e,t){var r=null,i="mp4",n=t.codec;if("audio"===e)this._audioMeta=t,"mp3"===t.codec&&this._mp3UseMpegAudio?(i="mpeg",n="",r=new Uint8Array):r=s.default.generateInitSegment(t);else{if("video"!==e)return;this._videoMeta=t,r=s.default.generateInitSegment(t)}if(!this._onInitSegment)throw new l.IllegalStateException("MP4Remuxer: onInitSegment callback must be specified!");this._onInitSegment(e,{type:e,data:r.buffer,codec:n,container:e+"/"+i,mediaDuration:t.duration})},e.prototype._calculateDtsBase=function(e,t){this._dtsBaseInited||(e.samples&&e.samples.length&&(this._audioDtsBase=e.samples[0].dts),t.samples&&t.samples.length&&(this._videoDtsBase=t.samples[0].dts),this._dtsBase=Math.min(this._audioDtsBase,this._videoDtsBase),this._dtsBaseInited=!0)},e.prototype.flushStashedSamples=function(){var e=this._videoStashedLastSample,t=this._audioStashedLastSample,r={type:"video",id:1,sequenceNumber:0,samples:[],length:0};null!=e&&(r.samples.push(e),r.length=e.length);var i={type:"audio",id:2,sequenceNumber:0,samples:[],length:0};null!=t&&(i.samples.push(t),i.length=t.length),this._videoStashedLastSample=null,this._audioStashedLastSample=null,this._remuxVideo(r,!0),this._remuxAudio(i,!0)},e.prototype._remuxAudio=function(e,t){if(null!=this._audioMeta){var r=e,l=r.samples,d=void 0,h=-1,c=-1,u=this._audioMeta.refSampleDuration,f="mp3"===this._audioMeta.codec&&this._mp3UseMpegAudio,p=this._dtsBaseInited&&void 0===this._audioNextDts,m=!1;if(l&&0!==l.length&&(1!==l.length||t)){var g=0,y=null,v=0;f?(g=0,v=r.length):(g=8,v=8+r.length);var _=null;if(l.length>1&&(_=l.pop(),v-=_.length),null!=this._audioStashedLastSample){var E=this._audioStashedLastSample;this._audioStashedLastSample=null,l.unshift(E),v+=E.length}null!=_&&(this._audioStashedLastSample=_);var b=l[0].dts-this._dtsBase;if(this._audioNextDts)d=b-this._audioNextDts;else if(this._audioSegmentInfoList.isEmpty())d=0,this._fillSilentAfterSeek&&!this._videoSegmentInfoList.isEmpty()&&"mp3"!==this._audioMeta.originalCodec&&(m=!0);else{var T=this._audioSegmentInfoList.getLastSampleBefore(b);if(null!=T){var S=b-(T.originalDts+T.duration);S<=3&&(S=0);var L=T.dts+T.duration+S;d=b-L}else d=0}if(m){var A=b-d,w=this._videoSegmentInfoList.getLastSegmentBefore(b);if(null!=w&&w.beginDts<A){var R=n.default.getSilentFrame(this._audioMeta.originalCodec,this._audioMeta.channelCount);if(R){var k=w.beginDts,I=A-w.beginDts;i.default.v(this.TAG,"InsertPrefixSilentAudio: dts: "+k+", duration: "+I),l.unshift({unit:R,dts:k,pts:k}),v+=R.byteLength}}else m=!1}for(var D=[],x=0;x<l.length;x++){E=l[x];var C=E.unit,P=E.dts-this._dtsBase,O=(k=P,!1),M=null,F=0;if(!(P<-.001)){if("mp3"!==this._audioMeta.codec){var N=P,U=3;if(this._audioNextDts&&(N=this._audioNextDts),d=P-N,d<=-U*u){i.default.w(this.TAG,"Dropping 1 audio frame (originalDts: "+P+" ms ,curRefDts: "+N+" ms) due to dtsCorrection: "+d+" ms overlap.");continue}if(d>=U*u&&this._fillAudioTimestampGap&&!a.default.safari){O=!0;var B=Math.floor(d/u);i.default.w(this.TAG,"Large audio timestamp gap detected, may cause AV sync to drift. Silent frames will be generated to avoid unsync.\noriginalDts: "+P+" ms, curRefDts: "+N+" ms, dtsCorrection: "+Math.round(d)+" ms, generate: "+B+" frames"),k=Math.floor(N),F=Math.floor(N+u)-k;R=n.default.getSilentFrame(this._audioMeta.originalCodec,this._audioMeta.channelCount);null==R&&(i.default.w(this.TAG,"Unable to generate silent frame for "+this._audioMeta.originalCodec+" with "+this._audioMeta.channelCount+" channels, repeat last frame"),R=C),M=[];for(var $=0;$<B;$++){N+=u;var G=Math.floor(N),j=Math.floor(N+u)-G,K={dts:G,pts:G,cts:0,unit:R,size:R.byteLength,duration:j,originalDts:P,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}};M.push(K),v+=K.size}this._audioNextDts=N+u}else k=Math.floor(N),F=Math.floor(N+u)-k,this._audioNextDts=N+u}else{if(k=P-d,x!==l.length-1){var V=l[x+1].dts-this._dtsBase-d;F=V-k}else if(null!=_){V=_.dts-this._dtsBase-d;F=V-k}else F=D.length>=1?D[D.length-1].duration:Math.floor(u);this._audioNextDts=k+F}-1===h&&(h=k),D.push({dts:k,pts:k,cts:0,unit:E.unit,size:E.unit.byteLength,duration:F,originalDts:P,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}}),O&&D.push.apply(D,M)}}if(0===D.length)return r.samples=[],void(r.length=0);f?y=new Uint8Array(v):(y=new Uint8Array(v),y[0]=v>>>24&255,y[1]=v>>>16&255,y[2]=v>>>8&255,y[3]=255&v,y.set(s.default.types.mdat,4));for(x=0;x<D.length;x++){C=D[x].unit;y.set(C,g),g+=C.byteLength}var H=D[D.length-1];c=H.dts+H.duration;var Y=new o.MediaSegmentInfo;Y.beginDts=h,Y.endDts=c,Y.beginPts=h,Y.endPts=c,Y.originalBeginDts=D[0].originalDts,Y.originalEndDts=H.originalDts+H.duration,Y.firstSample=new o.SampleInfo(D[0].dts,D[0].pts,D[0].duration,D[0].originalDts,!1),Y.lastSample=new o.SampleInfo(H.dts,H.pts,H.duration,H.originalDts,!1),this._isLive||this._audioSegmentInfoList.append(Y),r.samples=D,r.sequenceNumber++;var z=null;z=f?new Uint8Array:s.default.moof(r,h),r.samples=[],r.length=0;var W={type:"audio",data:this._mergeBoxes(z,y).buffer,sampleCount:D.length,info:Y};f&&p&&(W.timestampOffset=h),this._onMediaSegment("audio",W)}}},e.prototype._remuxVideo=function(e,t){if(null!=this._videoMeta){var r=e,i=r.samples,n=void 0,a=-1,l=-1,d=-1,h=-1;if(i&&0!==i.length&&(1!==i.length||t)){var c=8,u=null,f=8+e.length,p=null;if(i.length>1&&(p=i.pop(),f-=p.length),null!=this._videoStashedLastSample){var m=this._videoStashedLastSample;this._videoStashedLastSample=null,i.unshift(m),f+=m.length}null!=p&&(this._videoStashedLastSample=p);var g=i[0].dts-this._dtsBase;if(this._videoNextDts)n=g-this._videoNextDts;else if(this._videoSegmentInfoList.isEmpty())n=0;else{var y=this._videoSegmentInfoList.getLastSampleBefore(g);if(null!=y){var v=g-(y.originalDts+y.duration);v<=3&&(v=0);var _=y.dts+y.duration+v;n=g-_}else n=0}for(var E=new o.MediaSegmentInfo,b=[],T=0;T<i.length;T++){m=i[T];var S=m.dts-this._dtsBase,L=m.isKeyframe,A=S-n,w=m.cts,R=A+w;-1===a&&(a=A,d=R);var k=0;if(T!==i.length-1){var I=i[T+1].dts-this._dtsBase-n;k=I-A}else if(null!=p){I=p.dts-this._dtsBase-n;k=I-A}else k=b.length>=1?b[b.length-1].duration:Math.floor(this._videoMeta.refSampleDuration);if(L){var D=new o.SampleInfo(A,R,k,m.dts,!0);D.fileposition=m.fileposition,E.appendSyncPoint(D)}b.push({dts:A,pts:R,cts:w,units:m.units,size:m.length,isKeyframe:L,duration:k,originalDts:S,flags:{isLeading:0,dependsOn:L?2:1,isDependedOn:L?1:0,hasRedundancy:0,isNonSync:L?0:1}})}u=new Uint8Array(f),u[0]=f>>>24&255,u[1]=f>>>16&255,u[2]=f>>>8&255,u[3]=255&f,u.set(s.default.types.mdat,4);for(T=0;T<b.length;T++){var x=b[T].units;while(x.length){var C=x.shift(),P=C.data;u.set(P,c),c+=P.byteLength}}var O=b[b.length-1];if(l=O.dts+O.duration,h=O.pts+O.duration,this._videoNextDts=l,E.beginDts=a,E.endDts=l,E.beginPts=d,E.endPts=h,E.originalBeginDts=b[0].originalDts,E.originalEndDts=O.originalDts+O.duration,E.firstSample=new o.SampleInfo(b[0].dts,b[0].pts,b[0].duration,b[0].originalDts,b[0].isKeyframe),E.lastSample=new o.SampleInfo(O.dts,O.pts,O.duration,O.originalDts,O.isKeyframe),this._isLive||this._videoSegmentInfoList.append(E),r.samples=b,r.sequenceNumber++,this._forceFirstIDR){var M=b[0].flags;M.dependsOn=2,M.isNonSync=0}var F=s.default.moof(r,a);r.samples=[],r.length=0,this._onMediaSegment("video",{type:"video",data:this._mergeBoxes(F,u).buffer,sampleCount:b.length,info:E})}}},e.prototype._mergeBoxes=function(e,t){var r=new Uint8Array(e.byteLength+t.byteLength);return r.set(e,0),r.set(t,e.byteLength),r},e}();t["default"]=d},"./src/utils/browser.js":
/*!******************************!*\
!*** ./src/utils/browser.js ***!
\******************************/function(e,t,r){"use strict";r.r(t);var i={};function s(){var e=self.navigator.userAgent.toLowerCase(),t=/(edge)\/([\w.]+)/.exec(e)||/(opr)[\/]([\w.]+)/.exec(e)||/(chrome)[ \/]([\w.]+)/.exec(e)||/(iemobile)[\/]([\w.]+)/.exec(e)||/(version)(applewebkit)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+).*(version)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+)/.exec(e)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(e)||/(msie) ([\w.]+)/.exec(e)||e.indexOf("trident")>=0&&/(rv)(?::| )([\w.]+)/.exec(e)||e.indexOf("compatible")<0&&/(firefox)[ \/]([\w.]+)/.exec(e)||[],r=/(ipad)/.exec(e)||/(ipod)/.exec(e)||/(windows phone)/.exec(e)||/(iphone)/.exec(e)||/(kindle)/.exec(e)||/(android)/.exec(e)||/(windows)/.exec(e)||/(mac)/.exec(e)||/(linux)/.exec(e)||/(cros)/.exec(e)||[],s={browser:t[5]||t[3]||t[1]||"",version:t[2]||t[4]||"0",majorVersion:t[4]||t[2]||"0",platform:r[0]||""},n={};if(s.browser){n[s.browser]=!0;var a=s.majorVersion.split(".");n.version={major:parseInt(s.majorVersion,10),string:s.version},a.length>1&&(n.version.minor=parseInt(a[1],10)),a.length>2&&(n.version.build=parseInt(a[2],10))}if(s.platform&&(n[s.platform]=!0),(n.chrome||n.opr||n.safari)&&(n.webkit=!0),n.rv||n.iemobile){n.rv&&delete n.rv;var o="msie";s.browser=o,n[o]=!0}if(n.edge){delete n.edge;var l="msedge";s.browser=l,n[l]=!0}if(n.opr){var d="opera";s.browser=d,n[d]=!0}if(n.safari&&n.android){var h="android";s.browser=h,n[h]=!0}for(var c in n.name=s.browser,n.platform=s.platform,i)i.hasOwnProperty(c)&&delete i[c];Object.assign(i,n)}s(),t["default"]=i},"./src/utils/exception.js":
/*!********************************!*\
!*** ./src/utils/exception.js ***!
\********************************/function(e,t,r){"use strict";r.r(t),r.d(t,{RuntimeException:function(){return s},IllegalStateException:function(){return n},InvalidArgumentException:function(){return a},NotImplementedException:function(){return o}});var i=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!==typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function i(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}}(),s=function(){function e(e){this._message=e}return Object.defineProperty(e.prototype,"name",{get:function(){return"RuntimeException"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"message",{get:function(){return this._message},enumerable:!1,configurable:!0}),e.prototype.toString=function(){return this.name+": "+this.message},e}(),n=function(e){function t(t){return e.call(this,t)||this}return i(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return"IllegalStateException"},enumerable:!1,configurable:!0}),t}(s),a=function(e){function t(t){return e.call(this,t)||this}return i(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return"InvalidArgumentException"},enumerable:!1,configurable:!0}),t}(s),o=function(e){function t(t){return e.call(this,t)||this}return i(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return"NotImplementedException"},enumerable:!1,configurable:!0}),t}(s)},"./src/utils/logger.js":
/*!*****************************!*\
!*** ./src/utils/logger.js ***!
\*****************************/function(e,t,r){"use strict";r.r(t);var i=r(/*! events */"./node_modules/events/events.js"),s=r.n(i),n=function(){function e(){}return e.e=function(t,r){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var i="["+t+"] > "+r;e.ENABLE_CALLBACK&&e.emitter.emit("log","error",i),e.ENABLE_ERROR&&(console.error?console.error(i):console.warn?console.warn(i):console.log(i))},e.i=function(t,r){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var i="["+t+"] > "+r;e.ENABLE_CALLBACK&&e.emitter.emit("log","info",i),e.ENABLE_INFO&&(console.info?console.info(i):console.log(i))},e.w=function(t,r){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var i="["+t+"] > "+r;e.ENABLE_CALLBACK&&e.emitter.emit("log","warn",i),e.ENABLE_WARN&&(console.warn?console.warn(i):console.log(i))},e.d=function(t,r){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var i="["+t+"] > "+r;e.ENABLE_CALLBACK&&e.emitter.emit("log","debug",i),e.ENABLE_DEBUG&&(console.debug?console.debug(i):console.log(i))},e.v=function(t,r){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var i="["+t+"] > "+r;e.ENABLE_CALLBACK&&e.emitter.emit("log","verbose",i),e.ENABLE_VERBOSE&&console.log(i)},e}();n.GLOBAL_TAG="flv.js",n.FORCE_GLOBAL_TAG=!1,n.ENABLE_ERROR=!0,n.ENABLE_INFO=!0,n.ENABLE_WARN=!0,n.ENABLE_DEBUG=!0,n.ENABLE_VERBOSE=!0,n.ENABLE_CALLBACK=!1,n.emitter=new(s()),t["default"]=n},"./src/utils/logging-control.js":
/*!**************************************!*\
!*** ./src/utils/logging-control.js ***!
\**************************************/function(e,t,r){"use strict";r.r(t);var i=r(/*! events */"./node_modules/events/events.js"),s=r.n(i),n=r(/*! ./logger.js */"./src/utils/logger.js"),a=function(){function e(){}return Object.defineProperty(e,"forceGlobalTag",{get:function(){return n.default.FORCE_GLOBAL_TAG},set:function(t){n.default.FORCE_GLOBAL_TAG=t,e._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(e,"globalTag",{get:function(){return n.default.GLOBAL_TAG},set:function(t){n.default.GLOBAL_TAG=t,e._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(e,"enableAll",{get:function(){return n.default.ENABLE_VERBOSE&&n.default.ENABLE_DEBUG&&n.default.ENABLE_INFO&&n.default.ENABLE_WARN&&n.default.ENABLE_ERROR},set:function(t){n.default.ENABLE_VERBOSE=t,n.default.ENABLE_DEBUG=t,n.default.ENABLE_INFO=t,n.default.ENABLE_WARN=t,n.default.ENABLE_ERROR=t,e._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(e,"enableDebug",{get:function(){return n.default.ENABLE_DEBUG},set:function(t){n.default.ENABLE_DEBUG=t,e._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(e,"enableVerbose",{get:function(){return n.default.ENABLE_VERBOSE},set:function(t){n.default.ENABLE_VERBOSE=t,e._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(e,"enableInfo",{get:function(){return n.default.ENABLE_INFO},set:function(t){n.default.ENABLE_INFO=t,e._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(e,"enableWarn",{get:function(){return n.default.ENABLE_WARN},set:function(t){n.default.ENABLE_WARN=t,e._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(e,"enableError",{get:function(){return n.default.ENABLE_ERROR},set:function(t){n.default.ENABLE_ERROR=t,e._notifyChange()},enumerable:!1,configurable:!0}),e.getConfig=function(){return{globalTag:n.default.GLOBAL_TAG,forceGlobalTag:n.default.FORCE_GLOBAL_TAG,enableVerbose:n.default.ENABLE_VERBOSE,enableDebug:n.default.ENABLE_DEBUG,enableInfo:n.default.ENABLE_INFO,enableWarn:n.default.ENABLE_WARN,enableError:n.default.ENABLE_ERROR,enableCallback:n.default.ENABLE_CALLBACK}},e.applyConfig=function(e){n.default.GLOBAL_TAG=e.globalTag,n.default.FORCE_GLOBAL_TAG=e.forceGlobalTag,n.default.ENABLE_VERBOSE=e.enableVerbose,n.default.ENABLE_DEBUG=e.enableDebug,n.default.ENABLE_INFO=e.enableInfo,n.default.ENABLE_WARN=e.enableWarn,n.default.ENABLE_ERROR=e.enableError,n.default.ENABLE_CALLBACK=e.enableCallback},e._notifyChange=function(){var t=e.emitter;if(t.listenerCount("change")>0){var r=e.getConfig();t.emit("change",r)}},e.registerListener=function(t){e.emitter.addListener("change",t)},e.removeListener=function(t){e.emitter.removeListener("change",t)},e.addLogListener=function(t){n.default.emitter.addListener("log",t),n.default.emitter.listenerCount("log")>0&&(n.default.ENABLE_CALLBACK=!0,e._notifyChange())},e.removeLogListener=function(t){n.default.emitter.removeListener("log",t),0===n.default.emitter.listenerCount("log")&&(n.default.ENABLE_CALLBACK=!1,e._notifyChange())},e}();a.emitter=new(s()),t["default"]=a},"./src/utils/polyfill.js":
/*!*******************************!*\
!*** ./src/utils/polyfill.js ***!
\*******************************/function(e,t,r){"use strict";r.r(t);var i=function(){function e(){}return e.install=function(){Object.setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Object.assign=Object.assign||function(e){if(void 0===e||null===e)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),r=1;r<arguments.length;r++){var i=arguments[r];if(void 0!==i&&null!==i)for(var s in i)i.hasOwnProperty(s)&&(t[s]=i[s])}return t},"function"!==typeof self.Promise&&r(/*! es6-promise */"./node_modules/es6-promise/dist/es6-promise.js").polyfill()},e}();i.install(),t["default"]=i},"./src/utils/utf8-conv.js":
/*!********************************!*\
!*** ./src/utils/utf8-conv.js ***!
\********************************/function(e,t,r){"use strict";function i(e,t,r){var i=e;if(t+r<i.length){while(r--)if(128!==(192&i[++t]))return!1;return!0}return!1}function s(e){var t=[],r=e,s=0,n=e.length;while(s<n)if(r[s]<128)t.push(String.fromCharCode(r[s])),++s;else{if(r[s]<192);else if(r[s]<224){if(i(r,s,1)){var a=(31&r[s])<<6|63&r[s+1];if(a>=128){t.push(String.fromCharCode(65535&a)),s+=2;continue}}}else if(r[s]<240){if(i(r,s,2)){a=(15&r[s])<<12|(63&r[s+1])<<6|63&r[s+2];if(a>=2048&&55296!==(63488&a)){t.push(String.fromCharCode(65535&a)),s+=3;continue}}}else if(r[s]<248&&i(r,s,3)){a=(7&r[s])<<18|(63&r[s+1])<<12|(63&r[s+2])<<6|63&r[s+3];if(a>65536&&a<1114112){a-=65536,t.push(String.fromCharCode(a>>>10|55296)),t.push(String.fromCharCode(1023&a|56320)),s+=4;continue}}t.push(String.fromCharCode(65533)),++s}return t.join("")}r.r(t),t["default"]=s}},r={};function i(t){var s=r[t];if(void 0!==s)return s.exports;var n=r[t]={exports:{}};return e[t].call(n.exports,n,n.exports,i),n.exports}i.m=e,function(){i.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return i.d(t,{a:t}),t}}(),function(){i.d=function(e,t){for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}}(),function(){i.g=function(){if("object"===typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"===typeof window)return window}}()}(),function(){i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}}(),function(){i.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}}();var s=i("./src/index.js");return s}()}))}).call(this,r("4362"))}}]);