@v360-tech/v360-player 1.4.14 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,55 +1,48 @@
1
- (function(Ri,se){typeof exports=="object"&&typeof module<"u"?se(exports):typeof define=="function"&&define.amd?define(["exports"],se):(Ri=typeof globalThis<"u"?globalThis:Ri||self,se(Ri.V360Player={}))})(this,(function(Ri){"use strict";const se=Number.isFinite||function(a){return typeof a=="number"&&isFinite(a)},Iu=Number.isSafeInteger||function(a){return typeof a=="number"&&Math.abs(a)<=Cu},Cu=Number.MAX_SAFE_INTEGER||9007199254740991;let de=(function(a){return a.NETWORK_ERROR="networkError",a.MEDIA_ERROR="mediaError",a.KEY_SYSTEM_ERROR="keySystemError",a.MUX_ERROR="muxError",a.OTHER_ERROR="otherError",a})({}),U=(function(a){return a.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",a.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",a.KEY_SYSTEM_NO_SESSION="keySystemNoSession",a.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",a.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",a.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",a.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",a.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",a.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",a.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",a.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR="keySystemDestroyMediaKeysError",a.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR="keySystemDestroyCloseSessionError",a.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR="keySystemDestroyRemoveSessionError",a.MANIFEST_LOAD_ERROR="manifestLoadError",a.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",a.MANIFEST_PARSING_ERROR="manifestParsingError",a.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",a.LEVEL_EMPTY_ERROR="levelEmptyError",a.LEVEL_LOAD_ERROR="levelLoadError",a.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",a.LEVEL_PARSING_ERROR="levelParsingError",a.LEVEL_SWITCH_ERROR="levelSwitchError",a.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",a.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",a.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",a.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",a.FRAG_LOAD_ERROR="fragLoadError",a.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",a.FRAG_DECRYPT_ERROR="fragDecryptError",a.FRAG_PARSING_ERROR="fragParsingError",a.FRAG_GAP="fragGap",a.REMUX_ALLOC_ERROR="remuxAllocError",a.KEY_LOAD_ERROR="keyLoadError",a.KEY_LOAD_TIMEOUT="keyLoadTimeOut",a.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",a.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",a.BUFFER_APPEND_ERROR="bufferAppendError",a.BUFFER_APPENDING_ERROR="bufferAppendingError",a.BUFFER_STALLED_ERROR="bufferStalledError",a.BUFFER_FULL_ERROR="bufferFullError",a.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",a.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",a.ASSET_LIST_LOAD_ERROR="assetListLoadError",a.ASSET_LIST_LOAD_TIMEOUT="assetListLoadTimeout",a.ASSET_LIST_PARSING_ERROR="assetListParsingError",a.INTERSTITIAL_ASSET_ITEM_ERROR="interstitialAssetItemError",a.INTERNAL_EXCEPTION="internalException",a.INTERNAL_ABORTED="aborted",a.ATTACH_MEDIA_ERROR="attachMediaError",a.UNKNOWN="unknown",a})({}),y=(function(a){return a.MEDIA_ATTACHING="hlsMediaAttaching",a.MEDIA_ATTACHED="hlsMediaAttached",a.MEDIA_DETACHING="hlsMediaDetaching",a.MEDIA_DETACHED="hlsMediaDetached",a.MEDIA_ENDED="hlsMediaEnded",a.STALL_RESOLVED="hlsStallResolved",a.BUFFER_RESET="hlsBufferReset",a.BUFFER_CODECS="hlsBufferCodecs",a.BUFFER_CREATED="hlsBufferCreated",a.BUFFER_APPENDING="hlsBufferAppending",a.BUFFER_APPENDED="hlsBufferAppended",a.BUFFER_EOS="hlsBufferEos",a.BUFFERED_TO_END="hlsBufferedToEnd",a.BUFFER_FLUSHING="hlsBufferFlushing",a.BUFFER_FLUSHED="hlsBufferFlushed",a.MANIFEST_LOADING="hlsManifestLoading",a.MANIFEST_LOADED="hlsManifestLoaded",a.MANIFEST_PARSED="hlsManifestParsed",a.LEVEL_SWITCHING="hlsLevelSwitching",a.LEVEL_SWITCHED="hlsLevelSwitched",a.LEVEL_LOADING="hlsLevelLoading",a.LEVEL_LOADED="hlsLevelLoaded",a.LEVEL_UPDATED="hlsLevelUpdated",a.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",a.LEVELS_UPDATED="hlsLevelsUpdated",a.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",a.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",a.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",a.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",a.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",a.AUDIO_TRACK_UPDATED="hlsAudioTrackUpdated",a.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",a.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",a.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",a.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",a.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",a.SUBTITLE_TRACK_UPDATED="hlsSubtitleTrackUpdated",a.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",a.CUES_PARSED="hlsCuesParsed",a.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",a.INIT_PTS_FOUND="hlsInitPtsFound",a.FRAG_LOADING="hlsFragLoading",a.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",a.FRAG_LOADED="hlsFragLoaded",a.FRAG_DECRYPTED="hlsFragDecrypted",a.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",a.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",a.FRAG_PARSING_METADATA="hlsFragParsingMetadata",a.FRAG_PARSED="hlsFragParsed",a.FRAG_BUFFERED="hlsFragBuffered",a.FRAG_CHANGED="hlsFragChanged",a.FPS_DROP="hlsFpsDrop",a.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",a.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",a.ERROR="hlsError",a.DESTROYING="hlsDestroying",a.KEY_LOADING="hlsKeyLoading",a.KEY_LOADED="hlsKeyLoaded",a.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",a.BACK_BUFFER_REACHED="hlsBackBufferReached",a.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",a.ASSET_LIST_LOADING="hlsAssetListLoading",a.ASSET_LIST_LOADED="hlsAssetListLoaded",a.INTERSTITIALS_UPDATED="hlsInterstitialsUpdated",a.INTERSTITIALS_BUFFERED_TO_BOUNDARY="hlsInterstitialsBufferedToBoundary",a.INTERSTITIAL_ASSET_PLAYER_CREATED="hlsInterstitialAssetPlayerCreated",a.INTERSTITIAL_STARTED="hlsInterstitialStarted",a.INTERSTITIAL_ASSET_STARTED="hlsInterstitialAssetStarted",a.INTERSTITIAL_ASSET_ENDED="hlsInterstitialAssetEnded",a.INTERSTITIAL_ASSET_ERROR="hlsInterstitialAssetError",a.INTERSTITIAL_ENDED="hlsInterstitialEnded",a.INTERSTITIALS_PRIMARY_RESUMED="hlsInterstitialsPrimaryResumed",a.PLAYOUT_LIMIT_REACHED="hlsPlayoutLimitReached",a.EVENT_CUE_ENTER="hlsEventCueEnter",a})({});var be={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},he={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};class Di{constructor(e,t=0,i=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=i}sample(e,t){const i=Math.pow(this.alpha_,e);this.estimate_=t*(1-i)+i*this.estimate_,this.totalWeight_+=e}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){const e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}}class yu{constructor(e,t,i,s=100){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=i,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new Di(e),this.fast_=new Di(t),this.defaultTTFB_=s,this.ttfb_=new Di(e)}update(e,t){const{slow_:i,fast_:s,ttfb_:r}=this;i.halfLife!==e&&(this.slow_=new Di(e,i.getEstimate(),i.getTotalWeight())),s.halfLife!==t&&(this.fast_=new Di(t,s.getEstimate(),s.getTotalWeight())),r.halfLife!==e&&(this.ttfb_=new Di(e,r.getEstimate(),r.getTotalWeight()))}sample(e,t){e=Math.max(e,this.minDelayMs_);const i=8*t,s=e/1e3,r=i/s;this.fast_.sample(s,r),this.slow_.sample(s,r)}sampleTTFB(e){const t=e/1e3,i=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(i,Math.max(e,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}get defaultEstimate(){return this.defaultEstimate_}destroy(){}}function Eu(a,e,t){return(e=Tu(e))in a?Object.defineProperty(a,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):a[e]=t,a}function Ne(){return Ne=Object.assign?Object.assign.bind():function(a){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)({}).hasOwnProperty.call(t,i)&&(a[i]=t[i])}return a},Ne.apply(null,arguments)}function qn(a,e){var t=Object.keys(a);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(a);e&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(a,s).enumerable})),t.push.apply(t,i)}return t}function Be(a){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?qn(Object(t),!0).forEach(function(i){Eu(a,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(t)):qn(Object(t)).forEach(function(i){Object.defineProperty(a,i,Object.getOwnPropertyDescriptor(t,i))})}return a}function vu(a,e){if(typeof a!="object"||!a)return a;var t=a[Symbol.toPrimitive];if(t!==void 0){var i=t.call(a,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(a)}function Tu(a){var e=vu(a,"string");return typeof e=="symbol"?e:e+""}class Tt{constructor(e,t){this.trace=void 0,this.debug=void 0,this.log=void 0,this.warn=void 0,this.info=void 0,this.error=void 0;const i=`[${e}]:`;this.trace=si,this.debug=t.debug.bind(null,i),this.log=t.log.bind(null,i),this.warn=t.warn.bind(null,i),this.info=t.info.bind(null,i),this.error=t.error.bind(null,i)}}const si=function(){},Su={trace:si,debug:si,log:si,warn:si,info:si,error:si};function dr(){return Ne({},Su)}function xu(a,e){const t=self.console[a];return t?t.bind(self.console,`${e?"["+e+"] ":""}[${a}] >`):si}function Xn(a,e,t){return e[a]?e[a].bind(e):xu(a,t)}const fr=dr();function bu(a,e,t){const i=dr();if(typeof console=="object"&&a===!0||typeof a=="object"){const s=["debug","log","info","warn","error"];s.forEach(r=>{i[r]=Xn(r,a,t)});try{i.log(`Debug logs enabled for "${e}" in hls.js version 1.6.11`)}catch{return dr()}s.forEach(r=>{fr[r]=Xn(r,a)})}else Ne(fr,i);return i}const Oe=fr;function ri(a=!0){return typeof self>"u"?void 0:(a||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function Lu(a){return typeof self<"u"&&a===self.ManagedMediaSource}function Zn(a,e){const t=Object.keys(a),i=Object.keys(e),s=t.length,r=i.length;return!s||!r||s===r&&!t.some(n=>i.indexOf(n)===-1)}function mt(a,e=!1){if(typeof TextDecoder<"u"){const u=new TextDecoder("utf-8").decode(a);if(e){const h=u.indexOf("\0");return h!==-1?u.substring(0,h):u}return u.replace(/\0/g,"")}const t=a.length;let i,s,r,n="",o=0;for(;o<t;){if(i=a[o++],i===0&&e)return n;if(i===0||i===3)continue;switch(i>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:n+=String.fromCharCode(i);break;case 12:case 13:s=a[o++],n+=String.fromCharCode((i&31)<<6|s&63);break;case 14:s=a[o++],r=a[o++],n+=String.fromCharCode((i&15)<<12|(s&63)<<6|(r&63)<<0);break}}return n}function It(a){let e="";for(let t=0;t<a.length;t++){let i=a[t].toString(16);i.length<2&&(i="0"+i),e+=i}return e}function Qn(a){return Uint8Array.from(a.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}function Ru(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var gr={exports:{}},Jn;function Du(){return Jn||(Jn=1,(function(a,e){(function(t){var i=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,s=/^(?=([^\/?#]*))\1([^]*)$/,r=/(?:\/|^)\.(?=\/)/g,n=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(c,u,h){if(h=h||{},c=c.trim(),u=u.trim(),!u){if(!h.alwaysNormalize)return c;var f=o.parseURL(c);if(!f)throw new Error("Error trying to parse base URL.");return f.path=o.normalizePath(f.path),o.buildURLFromParts(f)}var g=o.parseURL(u);if(!g)throw new Error("Error trying to parse relative URL.");if(g.scheme)return h.alwaysNormalize?(g.path=o.normalizePath(g.path),o.buildURLFromParts(g)):u;var I=o.parseURL(c);if(!I)throw new Error("Error trying to parse base URL.");if(!I.netLoc&&I.path&&I.path[0]!=="/"){var m=s.exec(I.path);I.netLoc=m[1],I.path=m[2]}I.netLoc&&!I.path&&(I.path="/");var E={scheme:I.scheme,netLoc:g.netLoc,path:null,params:g.params,query:g.query,fragment:g.fragment};if(!g.netLoc&&(E.netLoc=I.netLoc,g.path[0]!=="/"))if(!g.path)E.path=I.path,g.params||(E.params=I.params,g.query||(E.query=I.query));else{var v=I.path,x=v.substring(0,v.lastIndexOf("/")+1)+g.path;E.path=o.normalizePath(x)}return E.path===null&&(E.path=h.alwaysNormalize?o.normalizePath(g.path):g.path),o.buildURLFromParts(E)},parseURL:function(c){var u=i.exec(c);return u?{scheme:u[1]||"",netLoc:u[2]||"",path:u[3]||"",params:u[4]||"",query:u[5]||"",fragment:u[6]||""}:null},normalizePath:function(c){for(c=c.split("").reverse().join("").replace(r,"");c.length!==(c=c.replace(n,"")).length;);return c.split("").reverse().join("")},buildURLFromParts:function(c){return c.scheme+c.netLoc+c.path+c.params+c.query+c.fragment}};a.exports=o})()})(gr)),gr.exports}var pr=Du();class Ar{constructor(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}}var Ue={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"};class ea{constructor(e){this._byteRange=null,this._url=null,this._stats=null,this._streams=null,this.base=void 0,this.relurl=void 0,typeof e=="string"&&(e={url:e}),this.base=e,_u(this,"stats")}setByteRange(e,t){const i=e.split("@",2);let s;i.length===1?s=t?.byteRangeEndOffset||0:s=parseInt(i[1]),this._byteRange=[s,parseInt(i[0])+s]}get baseurl(){return this.base.url}get byteRange(){return this._byteRange===null?[]:this._byteRange}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get elementaryStreams(){return this._streams===null&&(this._streams={[Ue.AUDIO]:null,[Ue.VIDEO]:null,[Ue.AUDIOVIDEO]:null}),this._streams}set elementaryStreams(e){this._streams=e}get hasStats(){return this._stats!==null}get hasStreams(){return this._streams!==null}get stats(){return this._stats===null&&(this._stats=new Ar),this._stats}set stats(e){this._stats=e}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=pr.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}clearElementaryStreamInfo(){const{elementaryStreams:e}=this;e[Ue.AUDIO]=null,e[Ue.VIDEO]=null,e[Ue.AUDIOVIDEO]=null}}function qe(a){return a.sn!=="initSegment"}class mr extends ea{constructor(e,t){super(t),this._decryptdata=null,this._programDateTime=null,this._ref=null,this._bitrate=void 0,this.rawProgramDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.playlistOffset=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.urlId=0,this.type=e}get byteLength(){if(this.hasStats){const e=this.stats.total;if(e)return e}if(this.byteRange.length){const e=this.byteRange[0],t=this.byteRange[1];if(se(e)&&se(t))return t-e}return null}get bitrate(){return this.byteLength?this.byteLength*8/this.duration:this._bitrate?this._bitrate:null}set bitrate(e){this._bitrate=e}get decryptdata(){const{levelkeys:e}=this;if(!e&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){const t=this.levelkeys.identity;if(t)this._decryptdata=t.getDecryptData(this.sn);else{const i=Object.keys(this.levelkeys);if(i.length===1){const s=this._decryptdata=this.levelkeys[i[0]]||null;if(s)return s.getDecryptData(this.sn)}}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null)return null;const e=se(this.duration)?this.duration:0;return this.programDateTime+e*1e3}get encrypted(){var e;if((e=this._decryptdata)!=null&&e.encrypted)return!0;if(this.levelkeys){var t;const i=Object.keys(this.levelkeys),s=i.length;if(s>1||s===1&&(t=this.levelkeys[i[0]])!=null&&t.encrypted)return!0}return!1}get programDateTime(){return this._programDateTime===null&&this.rawProgramDateTime&&(this.programDateTime=Date.parse(this.rawProgramDateTime)),this._programDateTime}set programDateTime(e){if(!se(e)){this._programDateTime=this.rawProgramDateTime=null;return}this._programDateTime=e}get ref(){return qe(this)?(this._ref||(this._ref={base:this.base,start:this.start,duration:this.duration,sn:this.sn,programDateTime:this.programDateTime}),this._ref):null}addStart(e){this.setStart(this.start+e)}setStart(e){this.start=e,this._ref&&(this._ref.start=e)}setDuration(e){this.duration=e,this._ref&&(this._ref.duration=e)}setKeyFormat(e){if(this.levelkeys){const t=this.levelkeys[e];t&&!this._decryptdata&&(this._decryptdata=t.getDecryptData(this.sn))}}abortRequests(){var e,t;(e=this.loader)==null||e.abort(),(t=this.keyLoader)==null||t.abort()}setElementaryStreamInfo(e,t,i,s,r,n=!1){const{elementaryStreams:o}=this,c=o[e];if(!c){o[e]={startPTS:t,endPTS:i,startDTS:s,endDTS:r,partial:n};return}c.startPTS=Math.min(c.startPTS,t),c.endPTS=Math.max(c.endPTS,i),c.startDTS=Math.min(c.startDTS,s),c.endDTS=Math.max(c.endDTS,r)}}class Pu extends ea{constructor(e,t,i,s,r){super(i),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=t,this.index=s;const n=e.enumeratedString("BYTERANGE");n&&this.setByteRange(n,r),r&&(this.fragOffset=r.fragOffset+r.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){const{elementaryStreams:e}=this;return!!(e.audio||e.video||e.audiovideo)}}function ta(a,e){const t=Object.getPrototypeOf(a);if(t){const i=Object.getOwnPropertyDescriptor(t,e);return i||ta(t,e)}}function _u(a,e){const t=ta(a,e);t&&(t.enumerable=!0,Object.defineProperty(a,e,t))}const ia=Math.pow(2,32)-1,wu=[].push,sa={video:1,audio:2,id3:3,text:4};function Ze(a){return String.fromCharCode.apply(null,a)}function ra(a,e){const t=a[e]<<8|a[e+1];return t<0?65536+t:t}function Ie(a,e){const t=aa(a,e);return t<0?4294967296+t:t}function na(a,e){let t=Ie(a,e);return t*=Math.pow(2,32),t+=Ie(a,e+4),t}function aa(a,e){return a[e]<<24|a[e+1]<<16|a[e+2]<<8|a[e+3]}function ku(a){const e=a.byteLength;for(let t=0;t<e;){const i=Ie(a,t);if(i>8&&a[t+4]===109&&a[t+5]===111&&a[t+6]===111&&a[t+7]===102)return!0;t=i>1?t+i:e}return!1}function xe(a,e){const t=[];if(!e.length)return t;const i=a.byteLength;for(let s=0;s<i;){const r=Ie(a,s),n=Ze(a.subarray(s+4,s+8)),o=r>1?s+r:i;if(n===e[0])if(e.length===1)t.push(a.subarray(s+8,o));else{const c=xe(a.subarray(s+8,o),e.slice(1));c.length&&wu.apply(t,c)}s=o}return t}function Mu(a){const e=[],t=a[0];let i=8;const s=Ie(a,i);i+=4;let r=0,n=0;t===0?(r=Ie(a,i),n=Ie(a,i+4),i+=8):(r=na(a,i),n=na(a,i+8),i+=16),i+=2;let o=a.length+n;const c=ra(a,i);i+=2;for(let u=0;u<c;u++){let h=i;const f=Ie(a,h);h+=4;const g=f&2147483647;if((f&2147483648)>>>31===1)return Oe.warn("SIDX has hierarchical references (not supported)"),null;const m=Ie(a,h);h+=4,e.push({referenceSize:g,subsegmentDuration:m,info:{duration:m/s,start:o,end:o+g-1}}),o+=g,h+=4,i=h}return{earliestPresentationTime:r,timescale:s,version:t,referencesCount:c,references:e}}function oa(a){const e=[],t=xe(a,["moov","trak"]);for(let s=0;s<t.length;s++){const r=t[s],n=xe(r,["tkhd"])[0];if(n){let o=n[0];const c=Ie(n,o===0?12:20),u=xe(r,["mdia","mdhd"])[0];if(u){o=u[0];const h=Ie(u,o===0?12:20),f=xe(r,["mdia","hdlr"])[0];if(f){const g=Ze(f.subarray(8,12)),I={soun:Ue.AUDIO,vide:Ue.VIDEO}[g],m=xe(r,["mdia","minf","stbl","stsd"])[0],E=Ou(m);I?(e[c]={timescale:h,type:I,stsd:E},e[I]=Be({timescale:h,id:c},E)):e[c]={timescale:h,type:g,stsd:E}}}}}return xe(a,["moov","mvex","trex"]).forEach(s=>{const r=Ie(s,4),n=e[r];n&&(n.default={duration:Ie(s,12),flags:Ie(s,20)})}),e}function Ou(a){const e=a.subarray(8),t=e.subarray(86),i=Ze(e.subarray(4,8));let s=i,r;const n=i==="enca"||i==="encv";if(n){const u=xe(e,[i])[0].subarray(i==="enca"?28:78);xe(u,["sinf"]).forEach(f=>{const g=xe(f,["schm"])[0];if(g){const I=Ze(g.subarray(4,8));if(I==="cbcs"||I==="cenc"){const m=xe(f,["frma"])[0];m&&(s=Ze(m))}}})}const o=s;switch(s){case"avc1":case"avc2":case"avc3":case"avc4":{const c=xe(t,["avcC"])[0];c&&c.length>3&&(s+="."+Is(c[1])+Is(c[2])+Is(c[3]),r=ms(o==="avc1"?"dva1":"dvav",t));break}case"mp4a":{const c=xe(e,[i])[0],u=xe(c.subarray(28),["esds"])[0];if(u&&u.length>7){let h=4;if(u[h++]!==3)break;h=Ir(u,h),h+=2;const f=u[h++];if(f&128&&(h+=2),f&64&&(h+=u[h++]),u[h++]!==4)break;h=Ir(u,h);const g=u[h++];if(g===64)s+="."+Is(g);else break;if(h+=12,u[h++]!==5)break;h=Ir(u,h);const I=u[h++];let m=(I&248)>>3;m===31&&(m+=1+((I&7)<<3)+((u[h]&224)>>5)),s+="."+m}break}case"hvc1":case"hev1":{const c=xe(t,["hvcC"])[0];if(c&&c.length>12){const u=c[1],h=["","A","B","C"][u>>6],f=u&31,g=Ie(c,2),I=(u&32)>>5?"H":"L",m=c[12],E=c.subarray(6,12);s+="."+h+f,s+="."+Fu(g).toString(16).toUpperCase(),s+="."+I+m;let v="";for(let x=E.length;x--;){const D=E[x];(D||v)&&(v="."+D.toString(16).toUpperCase()+v)}s+=v}r=ms(o=="hev1"?"dvhe":"dvh1",t);break}case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":{s=ms(s,t)||s;break}case"vp09":{const c=xe(t,["vpcC"])[0];if(c&&c.length>6){const u=c[4],h=c[5],f=c[6]>>4&15;s+="."+Mt(u)+"."+Mt(h)+"."+Mt(f)}break}case"av01":{const c=xe(t,["av1C"])[0];if(c&&c.length>2){const u=c[1]>>>5,h=c[1]&31,f=c[2]>>>7?"H":"M",g=(c[2]&64)>>6,I=(c[2]&32)>>5,m=u===2&&g?I?12:10:g?10:8,E=(c[2]&16)>>4,v=(c[2]&8)>>3,x=(c[2]&4)>>2,D=c[2]&3;s+="."+u+"."+Mt(h)+f+"."+Mt(m)+"."+E+"."+v+x+D+"."+Mt(1)+"."+Mt(1)+"."+Mt(1)+"."+0,r=ms("dav1",t)}break}}return{codec:s,encrypted:n,supplemental:r}}function ms(a,e){const t=xe(e,["dvvC"]),i=t.length?t[0]:xe(e,["dvcC"])[0];if(i){const s=i[2]>>1&127,r=i[2]<<5&32|i[3]>>3&31;return a+"."+Mt(s)+"."+Mt(r)}}function Fu(a){let e=0;for(let t=0;t<32;t++)e|=(a>>t&1)<<31-t;return e>>>0}function Ir(a,e){const t=e+5;for(;a[e++]&128&&e<t;);return e}function Is(a){return("0"+a.toString(16).toUpperCase()).slice(-2)}function Mt(a){return(a<10?"0":"")+a}function Nu(a,e){if(!a||!e)return;const t=e.keyId;t&&e.isCommonEncryption&&xe(a,["moov","trak"]).forEach(s=>{const n=xe(s,["mdia","minf","stbl","stsd"])[0].subarray(8);let o=xe(n,["enca"]);const c=o.length>0;c||(o=xe(n,["encv"])),o.forEach(u=>{const h=c?u.subarray(28):u.subarray(78);xe(h,["sinf"]).forEach(g=>{const I=la(g);if(I){const m=I.subarray(8,24);m.some(E=>E!==0)||(Oe.log(`[eme] Patching keyId in 'enc${c?"a":"v"}>sinf>>tenc' box: ${It(m)} -> ${It(t)}`),I.set(t,8))}})})})}function la(a){const e=xe(a,["schm"])[0];if(e){const t=Ze(e.subarray(4,8));if(t==="cbcs"||t==="cenc")return xe(a,["schi","tenc"])[0]}return null}function Bu(a,e,t){const i={},s=xe(a,["moof","traf"]);for(let r=0;r<s.length;r++){const n=s[r],o=xe(n,["tfhd"])[0],c=Ie(o,4),u=e[c];if(!u)continue;i[c]||(i[c]={start:NaN,duration:0,sampleCount:0,timescale:u.timescale,type:u.type});const h=i[c],f=xe(n,["tfdt"])[0];if(f){const L=f[0];let w=Ie(f,4);L===1&&(w===ia?t.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"):(w*=ia+1,w+=Ie(f,8))),se(w)&&(!se(h.start)||w<h.start)&&(h.start=w)}const g=u.default,I=Ie(o,0)|g?.flags;let m=g?.duration||0;I&8&&(I&2?m=Ie(o,12):m=Ie(o,8));const E=xe(n,["trun"]);let v=h.start||0,x=0,D=m;for(let L=0;L<E.length;L++){const w=E[L],N=Ie(w,4),K=h.sampleCount;h.sampleCount+=N;const p=w[3]&1,$=w[3]&4,F=w[2]&1,O=w[2]&2,W=w[2]&4,ie=w[2]&8;let X=8,ce=N;for(p&&(X+=4),$&&N&&(!(w[X+1]&1)&&h.keyFrameIndex===void 0&&(h.keyFrameIndex=K),X+=4,F?(D=Ie(w,X),X+=4):D=m,O&&(X+=4),ie&&(X+=4),v+=D,x+=D,ce--);ce--;)F?(D=Ie(w,X),X+=4):D=m,O&&(X+=4),W&&(w[X+1]&1||h.keyFrameIndex===void 0&&(h.keyFrameIndex=h.sampleCount-(ce+1),h.keyFrameStart=v),X+=4),ie&&(X+=4),v+=D,x+=D;!x&&m&&(x+=m*N)}h.duration+=x}if(!Object.keys(i).some(r=>i[r].duration)){let r=1/0,n=0;const o=xe(a,["sidx"]);for(let c=0;c<o.length;c++){const u=Mu(o[c]);if(u!=null&&u.references){r=Math.min(r,u.earliestPresentationTime/u.timescale);const h=u.references.reduce((f,g)=>f+g.info.duration||0,0);n=Math.max(n,h+u.earliestPresentationTime/u.timescale)}}n&&se(n)&&Object.keys(i).forEach(c=>{i[c].duration||(i[c].duration=n*i[c].timescale-i[c].start)})}return i}function Uu(a){const e={valid:null,remainder:null},t=xe(a,["moof"]);if(t.length<2)return e.remainder=a,e;const i=t[t.length-1];return e.valid=a.slice(0,i.byteOffset-8),e.remainder=a.slice(i.byteOffset-8),e}function St(a,e){const t=new Uint8Array(a.length+e.length);return t.set(a),t.set(e,a.length),t}function ua(a,e){const t=[],i=e.samples,s=e.timescale,r=e.id;let n=!1;return xe(i,["moof"]).map(c=>{const u=c.byteOffset-8;xe(c,["traf"]).map(f=>{const g=xe(f,["tfdt"]).map(I=>{const m=I[0];let E=Ie(I,4);return m===1&&(E*=Math.pow(2,32),E+=Ie(I,8)),E/s})[0];return g!==void 0&&(a=g),xe(f,["tfhd"]).map(I=>{const m=Ie(I,4),E=Ie(I,0)&16777215,v=(E&1)!==0,x=(E&2)!==0,D=(E&8)!==0;let L=0;const w=(E&16)!==0;let N=0;const K=(E&32)!==0;let p=8;m===r&&(v&&(p+=8),x&&(p+=4),D&&(L=Ie(I,p),p+=4),w&&(N=Ie(I,p),p+=4),K&&(p+=4),e.type==="video"&&(n=Cs(e.codec)),xe(f,["trun"]).map($=>{const F=$[0],O=Ie($,0)&16777215,W=(O&1)!==0;let ie=0;const X=(O&4)!==0,ce=(O&256)!==0;let ue=0;const Q=(O&512)!==0;let ne=0;const re=(O&1024)!==0,le=(O&2048)!==0;let pe=0;const J=Ie($,4);let ee=8;W&&(ie=Ie($,ee),ee+=4),X&&(ee+=4);let ve=ie+u;for(let ke=0;ke<J;ke++){if(ce?(ue=Ie($,ee),ee+=4):ue=L,Q?(ne=Ie($,ee),ee+=4):ne=N,re&&(ee+=4),le&&(F===0?pe=Ie($,ee):pe=aa($,ee),ee+=4),e.type===Ue.VIDEO){let Te=0;for(;Te<ne;){const Le=Ie(i,ve);if(ve+=4,$u(n,i[ve])){const it=i.subarray(ve,ve+Le);Cr(it,n?2:1,a+pe/s,t)}ve+=Le,Te+=Le+4}}a+=ue/s}}))})})}),t}function Cs(a){if(!a)return!1;const e=a.substring(0,4);return e==="hvc1"||e==="hev1"||e==="dvh1"||e==="dvhe"}function $u(a,e){if(a){const t=e>>1&63;return t===39||t===40}else return(e&31)===6}function Cr(a,e,t,i){const s=ca(a);let r=0;r+=e;let n=0,o=0,c=0;for(;r<s.length;){n=0;do{if(r>=s.length)break;c=s[r++],n+=c}while(c===255);o=0;do{if(r>=s.length)break;c=s[r++],o+=c}while(c===255);const u=s.length-r;let h=r;if(o<u)r+=o;else if(o>u){Oe.error(`Malformed SEI payload. ${o} is too small, only ${u} bytes left to parse.`);break}if(n===4){if(s[h++]===181){const g=ra(s,h);if(h+=2,g===49){const I=Ie(s,h);if(h+=4,I===1195456820){const m=s[h++];if(m===3){const E=s[h++],v=31&E,x=64&E,D=x?2+v*3:0,L=new Uint8Array(D);if(x){L[0]=E;for(let w=1;w<D;w++)L[w]=s[h++]}i.push({type:m,payloadType:n,pts:t,bytes:L})}}}}}else if(n===5&&o>16){const f=[];for(let m=0;m<16;m++){const E=s[h++].toString(16);f.push(E.length==1?"0"+E:E),(m===3||m===5||m===7||m===9)&&f.push("-")}const g=o-16,I=new Uint8Array(g);for(let m=0;m<g;m++)I[m]=s[h++];i.push({payloadType:n,pts:t,uuid:f.join(""),userData:mt(I),userDataBytes:I})}}}function ca(a){const e=a.byteLength,t=[];let i=1;for(;i<e-2;)a[i]===0&&a[i+1]===0&&a[i+2]===3?(t.push(i+2),i+=2):i++;if(t.length===0)return a;const s=e-t.length,r=new Uint8Array(s);let n=0;for(i=0;i<s;n++,i++)n===t[0]&&(n++,t.shift()),r[i]=a[n];return r}function Gu(a){const e=a[0];let t="",i="",s=0,r=0,n=0,o=0,c=0,u=0;if(e===0){for(;Ze(a.subarray(u,u+1))!=="\0";)t+=Ze(a.subarray(u,u+1)),u+=1;for(t+=Ze(a.subarray(u,u+1)),u+=1;Ze(a.subarray(u,u+1))!=="\0";)i+=Ze(a.subarray(u,u+1)),u+=1;i+=Ze(a.subarray(u,u+1)),u+=1,s=Ie(a,12),r=Ie(a,16),o=Ie(a,20),c=Ie(a,24),u=28}else if(e===1){u+=4,s=Ie(a,u),u+=4;const f=Ie(a,u);u+=4;const g=Ie(a,u);for(u+=4,n=2**32*f+g,Iu(n)||(n=Number.MAX_SAFE_INTEGER,Oe.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=Ie(a,u),u+=4,c=Ie(a,u),u+=4;Ze(a.subarray(u,u+1))!=="\0";)t+=Ze(a.subarray(u,u+1)),u+=1;for(t+=Ze(a.subarray(u,u+1)),u+=1;Ze(a.subarray(u,u+1))!=="\0";)i+=Ze(a.subarray(u,u+1)),u+=1;i+=Ze(a.subarray(u,u+1)),u+=1}const h=a.subarray(u,a.byteLength);return{schemeIdUri:t,value:i,timeScale:s,presentationTime:n,presentationTimeDelta:r,eventDuration:o,id:c,payload:h}}function Hu(a,...e){const t=e.length;let i=8,s=t;for(;s--;)i+=e[s].byteLength;const r=new Uint8Array(i);for(r[0]=i>>24&255,r[1]=i>>16&255,r[2]=i>>8&255,r[3]=i&255,r.set(a,4),s=0,i=8;s<t;s++)r.set(e[s],i),i+=e[s].byteLength;return r}function Vu(a,e,t){if(a.byteLength!==16)throw new RangeError("Invalid system id");let i,s;i=0,s=new Uint8Array;let r;i>0?(r=new Uint8Array(4),e.length>0&&new DataView(r.buffer).setUint32(0,e.length,!1)):r=new Uint8Array;const n=new Uint8Array(4);return t.byteLength>0&&new DataView(n.buffer).setUint32(0,t.byteLength,!1),Hu([112,115,115,104],new Uint8Array([i,0,0,0]),a,r,s,n,t)}const ha=()=>/\(Windows.+Firefox\//i.test(navigator.userAgent),Pi={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,dav1:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function yr(a,e){const t=Pi[e];return!!t&&!!t[a.slice(0,4)]}function Er(a,e,t=!0){return!a.split(",").some(i=>!vr(i,e,t))}function vr(a,e,t=!0){var i;const s=ri(t);return(i=s?.isTypeSupported(Xi(a,e)))!=null?i:!1}function Xi(a,e){return`${e}/mp4;codecs=${a}`}function da(a){if(a){const e=a.substring(0,4);return Pi.video[e]}return 2}function ys(a){const e=ha();return a.split(",").reduce((t,i)=>{const r=e&&Cs(i)?9:Pi.video[i];return r?(r*2+t)/(t?3:2):(Pi.audio[i]+t)/(t?2:1)},0)}const Tr={};function Ku(a,e=!0){if(Tr[a])return Tr[a];const t={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[a];for(let s=0;s<t.length;s++){var i;if(vr(t[s],"audio",e))return Tr[a]=t[s],t[s];if(t[s]==="mp3"&&(i=ri(e))!=null&&i.isTypeSupported("audio/mpeg"))return""}return a}const Yu=/flac|opus|mp4a\.40\.34/i;function Es(a,e=!0){return a.replace(Yu,t=>Ku(t.toLowerCase(),e))}function Wu(a,e){const t=[];if(a){const i=a.split(",");for(let s=0;s<i.length;s++)yr(i[s],"video")||t.push(i[s])}return e&&t.push(e),t.join(",")}function vs(a,e){if(a&&(a.length>4||["ac-3","ec-3","alac","fLaC","Opus"].indexOf(a)!==-1)&&(fa(a,"audio")||fa(a,"video")))return a;if(e){const t=e.split(",");if(t.length>1){if(a){for(let i=t.length;i--;)if(t[i].substring(0,4)===a.substring(0,4))return t[i]}return t[0]}}return e||a}function fa(a,e){return yr(a,e)&&vr(a,e)}function ju(a){const e=a.split(",");for(let t=0;t<e.length;t++){const i=e[t].split(".");i.length>2&&i[0]==="avc1"&&(e[t]=`avc1.${parseInt(i[1]).toString(16)}${("000"+parseInt(i[2]).toString(16)).slice(-4)}`)}return e.join(",")}function zu(a){if(a.startsWith("av01.")){const e=a.split("."),t=["0","111","01","01","01","0"];for(let i=e.length;i>4&&i<10;i++)e[i]=t[i-4];return e.join(".")}return a}function ga(a){const e=ri(a)||{isTypeSupported:()=>!1};return{mpeg:e.isTypeSupported("audio/mpeg"),mp3:e.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:e.isTypeSupported('audio/mp4; codecs="ac-3"')}}function Sr(a){return a.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}const qu={supported:!0,powerEfficient:!0,smooth:!0},Xu={supported:!1,smooth:!1,powerEfficient:!1},pa={supported:!0,configurations:[],decodingInfoResults:[qu]};function Aa(a,e){return{supported:!1,configurations:e,decodingInfoResults:[Xu],error:a}}function Zu(a,e,t,i,s,r){const n=a.videoCodec,o=a.audioCodec?a.audioGroups:null,c=r?.audioCodec,u=r?.channels,h=u?parseInt(u):c?1/0:2;let f=null;if(o!=null&&o.length)try{o.length===1&&o[0]?f=e.groups[o[0]].channels:f=o.reduce((g,I)=>{if(I){const m=e.groups[I];if(!m)throw new Error(`Audio track group ${I} not found`);Object.keys(m.channels).forEach(E=>{g[E]=(g[E]||0)+m.channels[E]})}return g},{2:0})}catch{return!0}return n!==void 0&&(n.split(",").some(g=>Cs(g))||a.width>1920&&a.height>1088||a.height>1920&&a.width>1088||a.frameRate>Math.max(i,30)||a.videoRange!=="SDR"&&a.videoRange!==t||a.bitrate>Math.max(s,8e6))||!!f&&se(h)&&Object.keys(f).some(g=>parseInt(g)>h)}function ma(a,e,t,i={}){const s=a.videoCodec;if(!s&&!a.audioCodec||!t)return Promise.resolve(pa);const r=[],n=Qu(a),o=n.length,c=Ju(a,e,o>0),u=c.length;for(let h=o||1*u||1;h--;){const f={type:"media-source"};if(o&&(f.video=n[h%o]),u){f.audio=c[h%u];const g=f.audio.bitrate;f.video&&g&&(f.video.bitrate-=g)}r.push(f)}if(s){const h=navigator.userAgent;if(s.split(",").some(f=>Cs(f))&&ha())return Promise.resolve(Aa(new Error(`Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent string: (${h})`),r))}return Promise.all(r.map(h=>{const f=tc(h);return i[f]||(i[f]=t.decodingInfo(h))})).then(h=>({supported:!h.some(f=>!f.supported),configurations:r,decodingInfoResults:h})).catch(h=>({supported:!1,configurations:r,decodingInfoResults:[],error:h}))}function Qu(a){var e;const t=(e=a.videoCodec)==null?void 0:e.split(","),i=Ia(a),s=a.width||640,r=a.height||480,n=a.frameRate||30,o=a.videoRange.toLowerCase();return t?t.map(c=>{const u={contentType:Xi(zu(c),"video"),width:s,height:r,bitrate:i,framerate:n};return o!=="sdr"&&(u.transferFunction=o),u}):[]}function Ju(a,e,t){var i;const s=(i=a.audioCodec)==null?void 0:i.split(","),r=Ia(a);return s&&a.audioGroups?a.audioGroups.reduce((n,o)=>{var c;const u=o?(c=e.groups[o])==null?void 0:c.tracks:null;return u?u.reduce((h,f)=>{if(f.groupId===o){const g=parseFloat(f.channels||"");s.forEach(I=>{const m={contentType:Xi(I,"audio"),bitrate:t?ec(I,r):r};g&&(m.channels=""+g),h.push(m)})}return h},n):n},[]):[]}function ec(a,e){if(e<=1)return 1;let t=128e3;return a==="ec-3"?t=768e3:a==="ac-3"&&(t=64e4),Math.min(e/2,t)}function Ia(a){return Math.ceil(Math.max(a.bitrate*.9,a.averageBitrate)/1e3)*1e3||1}function tc(a){let e="";const{audio:t,video:i}=a;if(i){const s=Sr(i.contentType);e+=`${s}_r${i.height}x${i.width}f${Math.ceil(i.framerate)}${i.transferFunction||"sd"}_${Math.ceil(i.bitrate/1e5)}`}if(t){const s=Sr(t.contentType);e+=`${i?"_":""}${s}_c${t.channels}`}return e}const xr=["NONE","TYPE-0","TYPE-1",null];function ic(a){return xr.indexOf(a)>-1}const Ts=["SDR","PQ","HLG"];function sc(a){return!!a&&Ts.indexOf(a)>-1}var Ss={No:"",Yes:"YES",v2:"v2"};function Ca(a){const{canSkipUntil:e,canSkipDateRanges:t,age:i}=a,s=i<e/2;return e&&s?t?Ss.v2:Ss.Yes:Ss.No}class ya{constructor(e,t,i){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=i}addDirectives(e){const t=new self.URL(e);return this.msn!==void 0&&t.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href}}class Zi{constructor(e){if(this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.supplemental=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.frameRate=e.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=e.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.codecSet=[e.videoCodec,e.audioCodec].filter(i=>!!i).map(i=>i.substring(0,4)).join(","),"supplemental"in e){var t;this.supplemental=e.supplemental;const i=(t=e.supplemental)==null?void 0:t.videoCodec;i&&i!==e.videoCodec&&(this.codecSet+=`,${i.substring(0,4)}`)}this.addGroupId("audio",e.attrs.AUDIO),this.addGroupId("text",e.attrs.SUBTITLES)}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get averageBitrate(){return this._avgBitrate||this.realBitrate||this.bitrate}get attrs(){return this._attrs[0]}get codecs(){return this.attrs.CODECS||""}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get videoRange(){return this.attrs["VIDEO-RANGE"]||"SDR"}get score(){return this.attrs.optionalFloat("SCORE",0)}get uri(){return this.url[0]||""}hasAudioGroup(e){return Ea(this._audioGroups,e)}hasSubtitleGroup(e){return Ea(this._subtitleGroups,e)}get audioGroups(){return this._audioGroups}get subtitleGroups(){return this._subtitleGroups}addGroupId(e,t){if(t){if(e==="audio"){let i=this._audioGroups;i||(i=this._audioGroups=[]),i.indexOf(t)===-1&&i.push(t)}else if(e==="text"){let i=this._subtitleGroups;i||(i=this._subtitleGroups=[]),i.indexOf(t)===-1&&i.push(t)}}}get urlId(){return 0}set urlId(e){}get audioGroupIds(){return this.audioGroups?[this.audioGroupId]:void 0}get textGroupIds(){return this.subtitleGroups?[this.textGroupId]:void 0}get audioGroupId(){var e;return(e=this.audioGroups)==null?void 0:e[0]}get textGroupId(){var e;return(e=this.subtitleGroups)==null?void 0:e[0]}addFallback(){}}function Ea(a,e){return!e||!a?!1:a.indexOf(e)!==-1}function rc(){if(typeof matchMedia=="function"){const a=matchMedia("(dynamic-range: high)"),e=matchMedia("bad query");if(a.media!==e.media)return a.matches===!0}return!1}function nc(a,e){let t=!1,i=[];if(a&&(t=a!=="SDR",i=[a]),e){i=e.allowedVideoRanges||Ts.slice(0);const s=i.join("")!=="SDR"&&!e.videoCodec;t=e.preferHDR!==void 0?e.preferHDR:s&&rc(),t||(i=["SDR"])}return{preferHDR:t,allowedVideoRanges:i}}const ac=a=>{const e=new WeakSet;return(t,i)=>{if(a&&(i=a(t,i)),typeof i=="object"&&i!==null){if(e.has(i))return;e.add(i)}return i}},Ge=(a,e)=>JSON.stringify(a,ac(e));function oc(a,e,t,i,s){const r=Object.keys(a),n=i?.channels,o=i?.audioCodec,c=s?.videoCodec,u=n&&parseInt(n)===2;let h=!1,f=!1,g=1/0,I=1/0,m=1/0,E=1/0,v=0,x=[];const{preferHDR:D,allowedVideoRanges:L}=nc(e,s);for(let $=r.length;$--;){const F=a[r[$]];h||(h=F.channels[2]>0),g=Math.min(g,F.minHeight),I=Math.min(I,F.minFramerate),m=Math.min(m,F.minBitrate),L.filter(W=>F.videoRanges[W]>0).length>0&&(f=!0)}g=se(g)?g:0,I=se(I)?I:0;const w=Math.max(1080,g),N=Math.max(30,I);m=se(m)?m:t,t=Math.max(m,t),f||(e=void 0);const K=r.length>1;return{codecSet:r.reduce(($,F)=>{const O=a[F];if(F===$)return $;if(x=f?L.filter(W=>O.videoRanges[W]>0):[],K){if(O.minBitrate>t)return Ot(F,`min bitrate of ${O.minBitrate} > current estimate of ${t}`),$;if(!O.hasDefaultAudio)return Ot(F,"no renditions with default or auto-select sound found"),$;if(o&&F.indexOf(o.substring(0,4))%5!==0)return Ot(F,`audio codec preference "${o}" not found`),$;if(n&&!u){if(!O.channels[n])return Ot(F,`no renditions with ${n} channel sound found (channels options: ${Object.keys(O.channels)})`),$}else if((!o||u)&&h&&O.channels[2]===0)return Ot(F,"no renditions with stereo sound found"),$;if(O.minHeight>w)return Ot(F,`min resolution of ${O.minHeight} > maximum of ${w}`),$;if(O.minFramerate>N)return Ot(F,`min framerate of ${O.minFramerate} > maximum of ${N}`),$;if(!x.some(W=>O.videoRanges[W]>0))return Ot(F,`no variants with VIDEO-RANGE of ${Ge(x)} found`),$;if(c&&F.indexOf(c.substring(0,4))%5!==0)return Ot(F,`video codec preference "${c}" not found`),$;if(O.maxScore<v)return Ot(F,`max score of ${O.maxScore} < selected max of ${v}`),$}return $&&(ys(F)>=ys($)||O.fragmentError>a[$].fragmentError)?$:(E=O.minIndex,v=O.maxScore,F)},void 0),videoRanges:x,preferHDR:D,minFramerate:I,minBitrate:m,minIndex:E}}function Ot(a,e){Oe.log(`[abr] start candidates with "${a}" ignored because ${e}`)}function va(a){return a.reduce((e,t)=>{let i=e.groups[t.groupId];i||(i=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),i.tracks.push(t);const s=t.channels||"2";return i.channels[s]=(i.channels[s]||0)+1,i.hasDefault=i.hasDefault||t.default,i.hasAutoSelect=i.hasAutoSelect||t.autoselect,i.hasDefault&&(e.hasDefaultAudio=!0),i.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function lc(a,e,t,i){return a.slice(t,i+1).reduce((s,r,n)=>{if(!r.codecSet)return s;const o=r.audioGroups;let c=s[r.codecSet];c||(s[r.codecSet]=c={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:n,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!o,fragmentError:0}),c.minBitrate=Math.min(c.minBitrate,r.bitrate);const u=Math.min(r.height,r.width);return c.minHeight=Math.min(c.minHeight,u),c.minFramerate=Math.min(c.minFramerate,r.frameRate),c.minIndex=Math.min(c.minIndex,n),c.maxScore=Math.max(c.maxScore,r.score),c.fragmentError+=r.fragmentError,c.videoRanges[r.videoRange]=(c.videoRanges[r.videoRange]||0)+1,o&&o.forEach(h=>{if(!h)return;const f=e.groups[h];f&&(c.hasDefaultAudio=c.hasDefaultAudio||e.hasDefaultAudio?f.hasDefault:f.hasAutoSelect||!e.hasDefaultAudio&&!e.hasAutoSelectAudio,Object.keys(f.channels).forEach(g=>{c.channels[g]=(c.channels[g]||0)+f.channels[g]}))}),s},{})}function Ta(a){if(!a)return a;const{lang:e,assocLang:t,characteristics:i,channels:s,audioCodec:r}=a;return{lang:e,assocLang:t,characteristics:i,channels:s,audioCodec:r}}function Ft(a,e,t){if("attrs"in a){const i=e.indexOf(a);if(i!==-1)return i}for(let i=0;i<e.length;i++){const s=e[i];if(Ii(a,s,t))return i}return-1}function Ii(a,e,t){const{groupId:i,name:s,lang:r,assocLang:n,default:o}=a,c=a.forced;return(i===void 0||e.groupId===i)&&(s===void 0||e.name===s)&&(r===void 0||uc(r,e.lang))&&(r===void 0||e.assocLang===n)&&(o===void 0||e.default===o)&&(c===void 0||e.forced===c)&&(!("characteristics"in a)||cc(a.characteristics||"",e.characteristics))&&(t===void 0||t(a,e))}function uc(a,e="--"){return a.length===e.length?a===e:a.startsWith(e)||e.startsWith(a)}function cc(a,e=""){const t=a.split(","),i=e.split(",");return t.length===i.length&&!t.some(s=>i.indexOf(s)===-1)}function Ci(a,e){const{audioCodec:t,channels:i}=a;return(t===void 0||(e.audioCodec||"").substring(0,4)===t.substring(0,4))&&(i===void 0||i===(e.channels||"2"))}function hc(a,e,t,i,s){const r=e[i],o=e.reduce((g,I,m)=>{const E=I.uri;return(g[E]||(g[E]=[])).push(m),g},{})[r.uri];o.length>1&&(i=Math.max.apply(Math,o));const c=r.videoRange,u=r.frameRate,h=r.codecSet.substring(0,4),f=Sa(e,i,g=>{if(g.videoRange!==c||g.frameRate!==u||g.codecSet.substring(0,4)!==h)return!1;const I=g.audioGroups,m=t.filter(E=>!I||I.indexOf(E.groupId)!==-1);return Ft(a,m,s)>-1});return f>-1?f:Sa(e,i,g=>{const I=g.audioGroups,m=t.filter(E=>!I||I.indexOf(E.groupId)!==-1);return Ft(a,m,s)>-1})}function Sa(a,e,t){for(let i=e;i>-1;i--)if(t(a[i]))return i;for(let i=e+1;i<a.length;i++)if(t(a[i]))return i;return-1}function xs(a,e){var t;return!!a&&a!==((t=e.loadLevelObj)==null?void 0:t.uri)}class dc extends Tt{constructor(e){super("abr",e.logger),this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.codecTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.rebufferNotice=-1,this.supportedCache={},this.bwEstimator=void 0,this._abandonRulesCheck=t=>{var i;const{fragCurrent:s,partCurrent:r,hls:n}=this,{autoLevelEnabled:o,media:c}=n;if(!s||!c)return;const u=performance.now(),h=r?r.stats:s.stats,f=r?r.duration:s.duration,g=u-h.loading.start,I=n.minAutoLevel,m=s.level,E=this._nextAutoLevel;if(h.aborted||h.loaded&&h.loaded===h.total||m<=I){this.clearTimer(),this._nextAutoLevel=-1;return}if(!o)return;const v=E>-1&&E!==m,x=!!t||v;if(!x&&(c.paused||!c.playbackRate||!c.readyState))return;const D=n.mainForwardBufferInfo;if(!x&&D===null)return;const L=this.bwEstimator.getEstimateTTFB(),w=Math.abs(c.playbackRate);if(g<=Math.max(L,1e3*(f/(w*2))))return;const N=D?D.len/w:0,K=h.loading.first?h.loading.first-h.loading.start:-1,p=h.loaded&&K>-1,$=this.getBwEstimate(),F=n.levels,O=F[m],W=Math.max(h.loaded,Math.round(f*(s.bitrate||O.averageBitrate)/8));let ie=p?g-K:g;ie<1&&p&&(ie=Math.min(g,h.loaded*8/$));const X=p?h.loaded*1e3/ie:0,ce=L/1e3,ue=X?(W-h.loaded)/X:W*8/$+ce;if(ue<=N)return;const Q=X?X*8:$,ne=((i=t?.details||this.hls.latestLevelDetails)==null?void 0:i.live)===!0,re=this.hls.config.abrBandWidthUpFactor;let le=Number.POSITIVE_INFINITY,pe;for(pe=m-1;pe>I;pe--){const ke=F[pe].maxBitrate,Te=!F[pe].details||ne;if(le=this.getTimeToLoadFrag(ce,Q,f*ke,Te),le<Math.min(N,f+ce))break}if(le>=ue||le>f*10)return;p?this.bwEstimator.sample(g-Math.min(L,K),h.loaded):this.bwEstimator.sampleTTFB(g);const J=F[pe].maxBitrate;this.getBwEstimate()*re>J&&this.resetEstimator(J);const ee=this.findBestLevel(J,I,pe,0,N,1,1);ee>-1&&(pe=ee),this.warn(`Fragment ${s.sn}${r?" part "+r.index:""} of level ${m} is loading too slowly;
1
+ (function(Vi,se){typeof exports=="object"&&typeof module<"u"?se(exports):typeof define=="function"&&define.amd?define(["exports"],se):(Vi=typeof globalThis<"u"?globalThis:Vi||self,se(Vi.V360Player={}))})(this,(function(Vi){"use strict";const se=Number.isFinite||function(r){return typeof r=="number"&&isFinite(r)},qc=Number.isSafeInteger||function(r){return typeof r=="number"&&Math.abs(r)<=zc},zc=Number.MAX_SAFE_INTEGER||9007199254740991;let me=(function(r){return r.NETWORK_ERROR="networkError",r.MEDIA_ERROR="mediaError",r.KEY_SYSTEM_ERROR="keySystemError",r.MUX_ERROR="muxError",r.OTHER_ERROR="otherError",r})({}),U=(function(r){return r.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",r.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",r.KEY_SYSTEM_NO_SESSION="keySystemNoSession",r.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",r.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",r.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",r.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",r.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",r.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",r.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",r.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR="keySystemDestroyMediaKeysError",r.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR="keySystemDestroyCloseSessionError",r.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR="keySystemDestroyRemoveSessionError",r.MANIFEST_LOAD_ERROR="manifestLoadError",r.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",r.MANIFEST_PARSING_ERROR="manifestParsingError",r.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",r.LEVEL_EMPTY_ERROR="levelEmptyError",r.PLAYLIST_UNCHANGED_ERROR="playlistUnchangedError",r.LEVEL_LOAD_ERROR="levelLoadError",r.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",r.LEVEL_PARSING_ERROR="levelParsingError",r.LEVEL_SWITCH_ERROR="levelSwitchError",r.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",r.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",r.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",r.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",r.FRAG_LOAD_ERROR="fragLoadError",r.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",r.FRAG_DECRYPT_ERROR="fragDecryptError",r.FRAG_PARSING_ERROR="fragParsingError",r.FRAG_GAP="fragGap",r.REMUX_ALLOC_ERROR="remuxAllocError",r.KEY_LOAD_ERROR="keyLoadError",r.KEY_LOAD_TIMEOUT="keyLoadTimeOut",r.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",r.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",r.BUFFER_APPEND_ERROR="bufferAppendError",r.BUFFER_APPENDING_ERROR="bufferAppendingError",r.BUFFER_APPEND_NO_PROGRESS="bufferAppendNoProgress",r.BUFFER_STALLED_ERROR="bufferStalledError",r.BUFFER_FULL_ERROR="bufferFullError",r.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",r.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",r.ASSET_LIST_LOAD_ERROR="assetListLoadError",r.ASSET_LIST_LOAD_TIMEOUT="assetListLoadTimeout",r.ASSET_LIST_PARSING_ERROR="assetListParsingError",r.INTERSTITIAL_ASSET_ITEM_ERROR="interstitialAssetItemError",r.INTERNAL_EXCEPTION="internalException",r.INTERNAL_ABORTED="aborted",r.ATTACH_MEDIA_ERROR="attachMediaError",r.MEDIA_SOURCE_REQUIRES_RESET="mediaSourceRequiresReset",r.UNKNOWN="unknown",r})({}),E=(function(r){return r.MEDIA_ATTACHING="hlsMediaAttaching",r.MEDIA_ATTACHED="hlsMediaAttached",r.MEDIA_DETACHING="hlsMediaDetaching",r.MEDIA_DETACHED="hlsMediaDetached",r.MEDIA_ENDED="hlsMediaEnded",r.STALL_RESOLVED="hlsStallResolved",r.BUFFER_RESET="hlsBufferReset",r.BUFFER_CODECS="hlsBufferCodecs",r.BUFFER_CREATED="hlsBufferCreated",r.BUFFER_APPENDING="hlsBufferAppending",r.BUFFER_APPENDED="hlsBufferAppended",r.BUFFER_EOS="hlsBufferEos",r.BUFFERED_TO_END="hlsBufferedToEnd",r.BUFFER_FLUSHING="hlsBufferFlushing",r.BUFFER_FLUSHED="hlsBufferFlushed",r.MANIFEST_LOADING="hlsManifestLoading",r.MANIFEST_LOADED="hlsManifestLoaded",r.MANIFEST_PARSED="hlsManifestParsed",r.LEVEL_SWITCHING="hlsLevelSwitching",r.LEVEL_SWITCHED="hlsLevelSwitched",r.LEVEL_LOADING="hlsLevelLoading",r.LEVEL_LOADED="hlsLevelLoaded",r.LEVEL_UPDATED="hlsLevelUpdated",r.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",r.LEVELS_UPDATED="hlsLevelsUpdated",r.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",r.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",r.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",r.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",r.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",r.AUDIO_TRACK_UPDATED="hlsAudioTrackUpdated",r.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",r.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",r.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",r.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",r.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",r.SUBTITLE_TRACK_UPDATED="hlsSubtitleTrackUpdated",r.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",r.CUES_PARSED="hlsCuesParsed",r.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",r.INIT_PTS_FOUND="hlsInitPtsFound",r.FRAG_LOADING="hlsFragLoading",r.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",r.FRAG_LOADED="hlsFragLoaded",r.FRAG_DECRYPTED="hlsFragDecrypted",r.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",r.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",r.FRAG_PARSING_METADATA="hlsFragParsingMetadata",r.FRAG_PARSED="hlsFragParsed",r.FRAG_BUFFERED="hlsFragBuffered",r.FRAG_CHANGED="hlsFragChanged",r.FPS_DROP="hlsFpsDrop",r.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",r.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",r.ERROR="hlsError",r.DESTROYING="hlsDestroying",r.KEY_LOADING="hlsKeyLoading",r.KEY_LOADED="hlsKeyLoaded",r.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",r.BACK_BUFFER_REACHED="hlsBackBufferReached",r.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",r.ASSET_LIST_LOADING="hlsAssetListLoading",r.ASSET_LIST_LOADED="hlsAssetListLoaded",r.INTERSTITIALS_UPDATED="hlsInterstitialsUpdated",r.INTERSTITIALS_BUFFERED_TO_BOUNDARY="hlsInterstitialsBufferedToBoundary",r.INTERSTITIAL_ASSET_PLAYER_CREATED="hlsInterstitialAssetPlayerCreated",r.INTERSTITIAL_STARTED="hlsInterstitialStarted",r.INTERSTITIAL_ASSET_STARTED="hlsInterstitialAssetStarted",r.INTERSTITIAL_ASSET_ENDED="hlsInterstitialAssetEnded",r.INTERSTITIAL_ASSET_ERROR="hlsInterstitialAssetError",r.INTERSTITIAL_ENDED="hlsInterstitialEnded",r.INTERSTITIALS_PRIMARY_RESUMED="hlsInterstitialsPrimaryResumed",r.PLAYOUT_LIMIT_REACHED="hlsPlayoutLimitReached",r.EVENT_CUE_ENTER="hlsEventCueEnter",r})({});function Xc(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Hn={exports:{}},Na;function Zc(){return Na||(Na=1,(function(r,e){(function(t){var i=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,s=/^(?=([^\/?#]*))\1([^]*)$/,n=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(l,u,h){if(h=h||{},l=l.trim(),u=u.trim(),!u){if(!h.alwaysNormalize)return l;var d=o.parseURL(l);if(!d)throw new Error("Error trying to parse base URL.");return d.path=o.normalizePath(d.path),o.buildURLFromParts(d)}var g=o.parseURL(u);if(!g)throw new Error("Error trying to parse relative URL.");if(g.scheme)return h.alwaysNormalize?(g.path=o.normalizePath(g.path),o.buildURLFromParts(g)):u;var m=o.parseURL(l);if(!m)throw new Error("Error trying to parse base URL.");if(!m.netLoc&&m.path&&m.path[0]!=="/"){var A=s.exec(m.path);m.netLoc=A[1],m.path=A[2]}m.netLoc&&!m.path&&(m.path="/");var C={scheme:m.scheme,netLoc:g.netLoc,path:null,params:g.params,query:g.query,fragment:g.fragment};if(!g.netLoc&&(C.netLoc=m.netLoc,g.path[0]!=="/"))if(!g.path)C.path=m.path,g.params||(C.params=m.params,g.query||(C.query=m.query));else{var v=m.path,S=v.substring(0,v.lastIndexOf("/")+1)+g.path;C.path=o.normalizePath(S)}return C.path===null&&(C.path=h.alwaysNormalize?o.normalizePath(g.path):g.path),o.buildURLFromParts(C)},parseURL:function(l){var u=i.exec(l);return u?{scheme:u[1]||"",netLoc:u[2]||"",path:u[3]||"",params:u[4]||"",query:u[5]||"",fragment:u[6]||""}:null},normalizePath:function(l){for(l=l.split("").reverse().join("").replace(n,"");l.length!==(l=l.replace(a,"")).length;);return l.split("").reverse().join("")},buildURLFromParts:function(l){return l.scheme+l.netLoc+l.path+l.params+l.query+l.fragment}};r.exports=o})()})(Hn)),Hn.exports}var Vn=Zc();class Kn{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}}}let ke=(function(r){return r.MANIFEST="manifest",r.LEVEL="level",r.AUDIO_TRACK="audioTrack",r.SUBTITLE_TRACK="subtitleTrack",r.MEDIA_FRAGMENT="media-fragment",r.KEY="key",r.STEERING_MANIFEST="steering-manifest",r.SERVER_CERTIFICATE="server-certificate",r.INTERSTITIAL_ASSET_LIST="interstitial-asset-list",r})({}),ge=(function(r){return r.MAIN="main",r.AUDIO="audio",r.SUBTITLE="subtitle",r})({});var ze={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"};class Ba{constructor(e){this._byteRange=null,this._url=null,this._stats=null,this._streams=null,this.base=void 0,this.relurl=void 0,typeof e=="string"&&(e={url:e}),this.base=e,Jc(this,"stats")}setByteRange(e,t){const i=e.split("@",2);let s;i.length===1?s=t?.byteRangeEndOffset||0:s=parseInt(i[1]),this._byteRange=[s,parseInt(i[0])+s]}get baseurl(){return this.base.url}get byteRange(){return this._byteRange===null?[]:this._byteRange}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get elementaryStreams(){return this._streams===null&&(this._streams={[ze.AUDIO]:null,[ze.VIDEO]:null,[ze.AUDIOVIDEO]:null}),this._streams}set elementaryStreams(e){this._streams=e}get hasStats(){return this._stats!==null}get hasStreams(){return this._streams!==null}get stats(){return this._stats===null&&(this._stats=new Kn),this._stats}set stats(e){this._stats=e}get url(){return!this._url&&this.relurl&&(this._url=Vn.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}clearElementaryStreamInfo(){const{elementaryStreams:e}=this;e[ze.AUDIO]=null,e[ze.VIDEO]=null,e[ze.AUDIOVIDEO]=null,this.url=null}}function st(r){return r.sn!=="initSegment"}function us(r,e){return r.sn===e?.sn&&r.level===e.level}function Yn(r,e){return r.sn===e?.sn&&r.level===e.level&&r.cc===e.cc}class Gs extends Ba{constructor(e,t){super(t),this._decryptdata=null,this._programDateTime=null,this._ref=null,this._bitrate=void 0,this.rawProgramDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.playlistOffset=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.urlId=0,this.type=e}get byteLength(){if(this.hasStats){const e=this.stats.total;if(e)return e}if(this.byteRange.length){const e=this.byteRange[0],t=this.byteRange[1];if(se(e)&&se(t))return t-e}return null}get bitrate(){return this.byteLength?this.byteLength*8/this.duration:this._bitrate?this._bitrate:null}set bitrate(e){this._bitrate=e}get decryptdata(){var e;const{levelkeys:t}=this;if(!t||t.NONE)return null;if(t.identity)this._decryptdata||(this._decryptdata=t.identity.getDecryptData(this.sn));else if(!((e=this._decryptdata)!=null&&e.keyId)){const i=Object.keys(t);if(i.length===1){const s=this._decryptdata=t[i[0]]||null;s&&(this._decryptdata=s.getDecryptData(this.sn,t))}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null)return null;const e=se(this.duration)?this.duration:0;return this.programDateTime+e*1e3}get encrypted(){var e;if((e=this._decryptdata)!=null&&e.encrypted)return!0;if(this.levelkeys){var t;const i=Object.keys(this.levelkeys),s=i.length;if(s>1||s===1&&(t=this.levelkeys[i[0]])!=null&&t.encrypted)return!0}return!1}get programDateTime(){return this._programDateTime===null&&this.rawProgramDateTime&&(this.programDateTime=Date.parse(this.rawProgramDateTime)),this._programDateTime}set programDateTime(e){if(!se(e)){this._programDateTime=this.rawProgramDateTime=null;return}this._programDateTime=e}get ref(){return st(this)?(this._ref||(this._ref={base:this.base,start:this.start,duration:this.duration,sn:this.sn,programDateTime:this.programDateTime}),this._ref):null}addStart(e){this.setStart(this.start+e)}setStart(e){this.start=e,this._ref&&(this._ref.start=e)}setDuration(e){this.duration=e,this._ref&&(this._ref.duration=e)}setKeyFormat(e){const t=this.levelkeys;if(t){var i;const s=t[e];s&&!((i=this._decryptdata)!=null&&i.keyId)&&(this._decryptdata=s.getDecryptData(this.sn,t))}}abortRequests(){var e,t;(e=this.loader)==null||e.abort(),(t=this.keyLoader)==null||t.abort()}setElementaryStreamInfo(e,t,i,s,n,a=!1){const{elementaryStreams:o}=this,l=o[e];if(!l){o[e]={startPTS:t,endPTS:i,startDTS:s,endDTS:n,partial:a};return}l.startPTS=Math.min(l.startPTS,t),l.endPTS=Math.max(l.endPTS,i),l.startDTS=Math.min(l.startDTS,s),l.endDTS=Math.max(l.endDTS,n)}}class Qc extends Ba{constructor(e,t,i,s,n){super(i),this.fragOffset=0,this.duration=0,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.gap=!1,this.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=t,this.index=s;const a=e.enumeratedString("BYTERANGE");a&&this.setByteRange(a,n),n&&(this.fragOffset=n.fragOffset+n.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){const{elementaryStreams:e}=this;return!!(e.audio||e.video||e.audiovideo||this.fragment.type===ge.SUBTITLE&&this.stats.loading.end>0)}}function Ua(r,e){const t=Object.getPrototypeOf(r);if(t){const i=Object.getOwnPropertyDescriptor(t,e);return i||Ua(t,e)}}function Jc(r,e){const t=Ua(r,e);t&&(t.enumerable=!0,Object.defineProperty(r,e,t))}function eh(r,e,t){return(e=sh(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function je(){return je=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)({}).hasOwnProperty.call(t,i)&&(r[i]=t[i])}return r},je.apply(null,arguments)}function $a(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(r);e&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(r,s).enumerable})),t.push.apply(t,i)}return t}function Ae(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?$a(Object(t),!0).forEach(function(i){eh(r,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):$a(Object(t)).forEach(function(i){Object.defineProperty(r,i,Object.getOwnPropertyDescriptor(t,i))})}return r}function Hs(r,e){if(r==null)return{};var t,i,s=th(r,e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);for(i=0;i<n.length;i++)t=n[i],e.indexOf(t)===-1&&{}.propertyIsEnumerable.call(r,t)&&(s[t]=r[t])}return s}function th(r,e){if(r==null)return{};var t={};for(var i in r)if({}.hasOwnProperty.call(r,i)){if(e.indexOf(i)!==-1)continue;t[i]=r[i]}return t}function ih(r,e){if(typeof r!="object"||!r)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var i=t.call(r,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function sh(r){var e=ih(r,"string");return typeof e=="symbol"?e:e+""}function Vs(r){switch(r.details){case U.FRAG_LOAD_TIMEOUT:case U.KEY_LOAD_TIMEOUT:case U.LEVEL_LOAD_TIMEOUT:case U.MANIFEST_LOAD_TIMEOUT:case U.AUDIO_TRACK_LOAD_TIMEOUT:case U.SUBTITLE_TRACK_LOAD_TIMEOUT:case U.ASSET_LIST_LOAD_TIMEOUT:return!0}return!1}function Ga(r){return r.details.startsWith("key")}function Ha(r){return Ga(r)&&!!r.frag&&!r.frag.decryptdata}function Va(r,e){const t=Vs(e);return r.default[`${t?"timeout":"error"}Retry`]}function Wn(r,e){const t=r.backoff==="linear"?1:Math.pow(2,e);return Math.min(t*r.retryDelayMs,r.maxRetryDelayMs)}function Ka(r){return Ae(Ae({},r),{errorRetry:null,timeoutRetry:null})}function cs(r,e,t,i){if(!r)return!1;const s=i?.code,n=e<r.maxNumRetry&&(nh(s)||!!t);return r.shouldRetry?r.shouldRetry(r,e,t,i,n):n}function nh(r){return hs(r)||!!r&&(r<400||r>499)}function hs(r){return r===0&&navigator.onLine===!1}function Ya(r,e){return e>0&&r.loadError>0&&r.loadErrorTime!==0&&self.performance.now()-r.loadErrorTime>e}class Ki{constructor(e,t=0,i=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=i}sample(e,t){const i=Math.pow(this.alpha_,e);this.estimate_=t*(1-i)+i*this.estimate_,this.totalWeight_+=e}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){const e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}}class rh{constructor(e,t,i,s=100){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=i,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new Ki(e),this.fast_=new Ki(t),this.defaultTTFB_=s,this.ttfb_=new Ki(e)}update(e,t){const{slow_:i,fast_:s,ttfb_:n}=this;i.halfLife!==e&&(this.slow_=new Ki(e,i.getEstimate(),i.getTotalWeight())),s.halfLife!==t&&(this.fast_=new Ki(t,s.getEstimate(),s.getTotalWeight())),n.halfLife!==e&&(this.ttfb_=new Ki(e,n.getEstimate(),n.getTotalWeight()))}sample(e,t){if(t<=0)return;const i=Math.min(this.minDelayMs_,t/1e5),s=8*t,n=Math.max(e,i)/1e3,a=s/n;this.fast_.sample(n,a),this.slow_.sample(n,a)}sampleTTFB(e){const t=e/1e3,i=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(i,Math.max(e,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}get defaultEstimate(){return this.defaultEstimate_}destroy(){}}class wt{constructor(e,t){this.trace=void 0,this.debug=void 0,this.log=void 0,this.warn=void 0,this.info=void 0,this.error=void 0;const i=`[${e}]:`;this.trace=vi,this.debug=t.debug.bind(null,i),this.log=t.log.bind(null,i),this.warn=t.warn.bind(null,i),this.info=t.info.bind(null,i),this.error=t.error.bind(null,i)}}const vi=function(){},ah={trace:vi,debug:vi,log:vi,warn:vi,info:vi,error:vi};function jn(){return je({},ah)}function oh(r,e){const t=self.console[r];return t?t.bind(self.console,`${e?"["+e+"] ":""}[${r}] >`):vi}function Wa(r,e,t){return e[r]?e[r].bind(e):oh(r,t)}const qn=jn();function lh(r,e,t){const i=jn();if(typeof console=="object"&&r===!0||typeof r=="object"){const s=["debug","log","info","warn","error"];s.forEach(n=>{i[n]=Wa(n,r,t)});try{i.log(`Debug logs enabled for "${e}" in hls.js version 1.7.3`)}catch{return jn()}s.forEach(n=>{qn[n]=Wa(n,r)})}else je(qn,i);return i}const Ge=qn;function Ei(r=!0){return typeof self>"u"?void 0:(r||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function uh(r){return typeof self<"u"&&r===self.ManagedMediaSource}function ja(r,e){const t=Object.keys(r),i=Object.keys(e),s=t.length,n=i.length;return!s||!n||s===n&&!t.some(a=>i.indexOf(a)===-1)}function ch(r){return btoa(String.fromCharCode(...r))}function Ks(r){return r instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&r instanceof SharedArrayBuffer}const hh="utf-16",zn="utf-16be",qa="utf-16le",Ys="utf-8";function dh(r,e={}){let t;Ks(r)?t=new DataView(r):t=new DataView(r.buffer,r.byteOffset,r.byteLength);let i=0,{encoding:s}=e;if(!s){const u=t.getUint8(0),h=t.getUint8(1);u==239&&h==187&&t.getUint8(2)==191?(s=Ys,i=3):u==254&&h==255?(s=zn,i=2):u==255&&h==254?(s=qa,i=2):s=Ys}if(typeof TextDecoder<"u")return new TextDecoder(s).decode(t);const{byteLength:n}=t,a=s!==zn;let o="",l;for(;i<n;){switch(s){case Ys:if(l=t.getUint8(i),l<128)i++;else if(l>=194&&l<=223)if(i+1<n){const u=t.getUint8(i+1);u>=128&&u<=191?(l=(l&31)<<6|u&63,i+=2):i++}else i++;else if(l>=224&&l<=239)if(i+2<=n-1){const u=t.getUint8(i+1),h=t.getUint8(i+2);u>=128&&u<=191&&h>=128&&h<=191?(l=(l&15)<<12|(u&63)<<6|h&63,i+=3):i++}else i++;else if(l>=240&&l<=244)if(i+3<=n-1){const u=t.getUint8(i+1),h=t.getUint8(i+2),d=t.getUint8(i+3);u>=128&&u<=191&&h>=128&&h<=191&&d>=128&&d<=191?(l=(l&7)<<18|(u&63)<<12|(h&63)<<6|d&63,i+=4):i++}else i++;else i++;break;case zn:case hh:case qa:l=t.getUint16(i,a),i+=2;break}o+=String.fromCodePoint(l)}return o}function fh(r){const e=typeof r=="string"?new URL(r):r;return e.origin+e.pathname.substring(0,e.pathname.lastIndexOf("/")+1)}function za(r,e){if(r<0)return-za(-r,e);const t=Math.pow(10,e);if(Math.abs(r*t%1-.5)<Number.EPSILON){const i=Math.floor(r*t);return(i%2===0?i:i+1)/t}else return Math.round(r*t)/t}function gh(r,e){let t;try{t=new URL(r)}catch{return r}const i=new URL(e);if(t.origin!==i.origin)return r;const s=t.pathname.split("/").slice(1),n=i.pathname.split("/").slice(1,-1),a=Math.min(s.length,n.length);for(let o=0;o<a&&s[o]===n[o];o++)s.shift(),n.shift();for(;n.length;)n.shift(),s.unshift("..");return s.join("/")+t.search+t.hash}function Xa(){try{return crypto.randomUUID()}catch{try{const e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch{let t=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,i=>{const s=(t+Math.random()*16)%16|0;return t=Math.floor(t/16),(i=="x"?s:s&3|8).toString(16)})}}}function Xn(r,e){return e+10<=r.length&&r[e]===73&&r[e+1]===68&&r[e+2]===51&&r[e+3]<255&&r[e+4]<255&&r[e+6]<128&&r[e+7]<128&&r[e+8]<128&&r[e+9]<128}function Ws(r,e){let t=0;return t=(r[e]&127)<<21,t|=(r[e+1]&127)<<14,t|=(r[e+2]&127)<<7,t|=r[e+3]&127,t}function ph(r,e){return Xn(r,e)&&Ws(r,e+6)+10<=r.length-e}function Za(r,e){return e+10<=r.length&&r[e]===51&&r[e+1]===68&&r[e+2]===73&&r[e+3]<255&&r[e+4]<255&&r[e+6]<128&&r[e+7]<128&&r[e+8]<128&&r[e+9]<128}function ds(r,e){const t=e;let i=0;for(;Xn(r,e);){i+=10;const s=Ws(r,e+6);i+=s,Za(r,e+10)&&(i+=10),e+=i}if(i>0)return r.subarray(t,t+i)}function mh(r){return Ks(r)?r:r.byteOffset==0&&r.byteLength==r.buffer.byteLength?r.buffer:new Uint8Array(r).buffer}function Zn(r,e=0,t=1/0){return Ah(r,e,t,Uint8Array)}function Ah(r,e,t,i){const s=Ih(r);let n=1;"BYTES_PER_ELEMENT"in i&&(n=i.BYTES_PER_ELEMENT);const a=Ch(r)?r.byteOffset:0,o=(a+r.byteLength)/n,l=(a+e)/n,u=Math.floor(Math.max(0,Math.min(l,o)));return new i(s,u,Math.floor(Math.min(u+Math.max(t,0),o))-u)}function Ih(r){return Ks(r)?r:r.buffer}function Ch(r){return r&&Ks(r.buffer)&&r.byteLength!==void 0&&r.byteOffset!==void 0}function Mt(r,e=!1){const t=e?r.indexOf(0):r.length,i=dh(new DataView(r.buffer,r.byteOffset,t),{encoding:Ys});return e?i:i.replace(/\0/g,"")}function yh(r){const e={key:r.type,description:"",data:"",mimeType:null,pictureType:null},t=3;if(r.size<2)return;if(r.data[0]!==t){console.log("Ignore frame with unrecognized character encoding");return}const i=r.data.subarray(1).indexOf(0);if(i===-1)return;const s=Mt(Zn(r.data,1,i)),n=r.data[2+i],a=r.data.subarray(3+i).indexOf(0);if(a===-1)return;const o=Mt(Zn(r.data,3+i,a));let l;return s==="-->"?l=Mt(Zn(r.data,4+i+a)):l=mh(r.data.subarray(4+i+a)),e.mimeType=s,e.pictureType=n,e.description=o,e.data=l,e}function vh(r){if(r.size<2)return;const e=Mt(r.data,!0),t=new Uint8Array(r.data.subarray(e.length+1));return{key:r.type,info:e,data:t.buffer}}function Eh(r){if(r.size<2)return;if(r.type==="TXXX"){let t=1;const{data:i}=r,s=Mt(i.subarray(t),!0);t+=s.length+1;const n=Mt(i.subarray(t));return{key:r.type,info:s,data:n}}const e=Mt(r.data.subarray(1));return{key:r.type,info:"",data:e}}function Th(r){if(r.type==="WXXX"){if(r.size<2)return;let t=1;const i=Mt(r.data.subarray(t),!0);t+=i.length+1;const s=Mt(r.data.subarray(t));return{key:r.type,info:i,data:s}}const e=Mt(r.data);return{key:r.type,info:"",data:e}}function Sh(r){return r.type==="PRIV"?vh(r):r.type[0]==="W"?Th(r):r.type==="APIC"?yh(r):Eh(r)}function xh(r){const e=String.fromCharCode(r[0],r[1],r[2],r[3]),t=Ws(r,4),i=10;return{type:e,size:t,data:r.subarray(i,i+t)}}const js=10,bh=10;function Qa(r){let e=0;const t=[];for(;Xn(r,e);){const i=Ws(r,e+6);r[e+5]>>6&1&&(e+=js),e+=js;const s=e+i;for(;e+bh<s;){const n=xh(r.subarray(e)),a=Sh(n);a&&t.push(a),e+=n.size+js}Za(r,e)&&(e+=js)}return t}function Ja(r){return r&&r.key==="PRIV"&&r.info==="com.apple.streaming.transportStreamTimestamp"}function Lh(r){if(r.data.byteLength===8){const e=new Uint8Array(r.data),t=e[3]&1;let i=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return i/=45,t&&(i+=4772185884e-2),Math.round(i)}}function Qn(r){const e=Qa(r);for(const t of e)if(Ja(t))return Lh(t)}function ut(r){let e="";for(let t=0;t<r.length;t++){let i=r[t].toString(16);i.length<2&&(i="0"+i),e+=i}return e}function eo(r){return Uint8Array.from(r.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}function Jn(r){return Uint8Array.from(atob(r),e=>e.charCodeAt(0))}function Yt(r){return String.fromCharCode.apply(null,r)}const Jt=Math.pow(2,32)-1,Te={avc1:1635148593,avcC:1635148611,hvc1:1752589105,hvcC:1752589123,btrt:1651798644,dinf:1684631142,dref:1685218662,esds:1702061171,free:1718773093,ftyp:1718909296,hdlr:1751411826,mdat:1835295092,mdhd:1835296868,mdia:1835297121,mfhd:1835427940,minf:1835626086,moof:1836019558,moov:1836019574,mp4a:1836069985,".mp3":778924083,dac3:1684103987,"ac-3":1633889587,mvex:1836475768,mvhd:1836476516,pasp:1885434736,sdtp:1935963248,stbl:1937007212,stco:1937007471,stsc:1937011555,stsd:1937011556,stsz:1937011578,stts:1937011827,tfdt:1952867444,tfhd:1952868452,traf:1953653094,trak:1953653099,trun:1953658222,trex:1953654136,tkhd:1953196132,vmhd:1986881636,smhd:1936549988},to={video:1,audio:2,id3:3,text:4};function io(r,e){const t=r[e]<<8|r[e+1];return t<0?65536+t:t}function ce(r,e){const t=r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3];return t<0?4294967296+t:t}function so(r,e){let t=ce(r,e);return t*=Math.pow(2,32),t+=ce(r,e+4),t}function qs(r,e){let t="";for(let i=e;i<r.length;i++)if(t+=String.fromCharCode(r[i]),r[i]===0)return t;return null}function er(r,e){return r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3]}function lt(r,e,t){r[e]=t>>24,r[e+1]=t>>16&255,r[e+2]=t>>8&255,r[e+3]=t&255}function no(r,e,t){const i=e.byteOffset-r.byteOffset-8,s=8+t,n=e.byteLength+8-s;n<8||(lt(r,i,s),lt(r,i+s,n),lt(r,i+s+4,Te.free))}function tr(r,e){return[r.byteOffset-e-8,r.byteOffset-e+r.byteLength]}function ro(r,e){e.sort((o,l)=>o[0]-l[0]);const t=e.reduce((o,[l,u])=>o+u-l,0),i=new Uint8Array(r.byteLength-t);let s=0,n=0;for(let o=0;o<e.length;o++){const[l,u]=e[o];i.set(r.subarray(s,l),n),n+=l-s,s=u}return i.set(r.subarray(s),n),{result:i,dropped:t,droppedBefore:o=>e.reduce((l,[u,h])=>h<=o?l+h-u:l,0)}}function Rh(r){const e=xe(r,["moov"]);if(e.length!==1||xe(r,["moof"]).length)return null;const t=r.byteOffset,i=[],s=[];let n=!1;const a=xe(e[0],["trak"]);for(let m=0;m<a.length;m++){const A=a[m],C=xe(A,["mdia","hdlr"])[0];if((C?Yt(C.subarray(8,12)):"")==="vide"){n=!0;continue}const S=xe(A,["tkhd"])[0];if(!S)return null;const R=S[0];s.push(ce(S,R===0?12:20)),i.push(tr(A,t))}if(!n||!i.length)return null;const o=xe(e[0],["mvex"])[0];let l=0;if(o){const m=xe(o,["trex"]);for(let A=0;A<m.length;A++){const C=m[A];s.indexOf(ce(C,4))!==-1&&(i.push(tr(C,t)),l+=C.byteLength+8)}}const{result:u,dropped:h,droppedBefore:d}=ro(r,i),g=e[0].byteOffset-t-8;if(lt(u,g,e[0].byteLength+8-h),o&&l){const m=o.byteOffset-t-8;lt(u,m-d(m),o.byteLength+8-l)}return u}function Dh(r,e,t,i,s){if(t<1)return null;const n=xe(r,["moof"]);if(n.length!==1)return null;const a=n[0],o=r.byteOffset,l=[],u=[],h=xe(a,["traf"]);let d=!0;for(let C=0;C<h.length;C++){const v=h[C],S=xe(v,["tfhd"])[0];if(!S)return null;ce(S,4)===e?(l.push(v),ce(S,0)&131072||(d=!1)):u.push(tr(v,o))}if(!l.length||u.length&&!d)return null;if(i!==void 0){let C=t;for(let S=0;S<l.length;S++){const R=l[S];let b=0;const D=xe(R,["trun"]);for(let p=0;p<D.length;p++){const $=D[p],N=Math.min(C,ce($,4));if(N){lt(r,$.byteOffset-o+4,N);const O=ce($,0)&16777215,W=(O&256?4:0)+(O&512?4:0)+(O&1024?4:0)+(O&2048?4:0);no(r,$,8+(O&1?4:0)+(O&4?4:0)+N*W)}else lt(r,$.byteOffset-o-4,Te.free);C-=N,b+=N}const _=xe(R,["senc"])[0];_&&lt(r,_.byteOffset-o+4,b);const M=xe(R,["saiz"])[0];if(M){const p=M[1]<<16|M[2]<<8|M[3];let $=4;p&1&&($+=8);const N=M[$];$+=1,lt(r,M.byteOffset-o+$,b),no(r,M,$+4+(N===0?b:0))}}const v=xe(r,["mdat"]);if(v.length===1){const S=v[0].byteOffset-o-8;lt(r,S,i-S)}}let g=r,m=0,A=()=>0;if(u.length){({result:g,dropped:m,droppedBefore:A}=ro(r,u)),lt(g,a.byteOffset-o-8,a.byteLength+8-m);for(let C=0;C<l.length;C++){const v=l[C],S=A(v.byteOffset-o),R=xe(v,["trun"]);for(let b=0;b<R.length;b++){const D=R[b];ce(D,0)&1&&lt(g,D.byteOffset-o-S+8,ce(D,8)-m)}if(S){const b=xe(v,["saio"]);for(let D=0;D<b.length;D++){const _=b[D],M=_[0]===0?4:8;let p=ce(_,0)&1?12:4,$=ce(_,p);for(p+=4;$--;p+=M){const N=p+M-4;lt(g,_.byteOffset-o-S+N,ce(_,N)-S)}}}}}if(s){const{durationOffset:C,value:v}=s;lt(g,C-A(C),v)}return i!==void 0?g.subarray(0,i-m):g}function Ph(r,e){const t=r.byteLength;for(let i=0;i<t;){const s=ce(r,i);if(s>8&&ce(r,i+4)===Te[e])return!0;i=s>1?i+s:t}return!1}function xe(r,e){const t=[];return e.length&&ao(r,e,0,0,r.byteLength,t),t}function ao(r,e,t,i,s,n){const a=e[t];if(a?.length!==4)return;const o=a.charCodeAt(0),l=a.charCodeAt(1),u=a.charCodeAt(2),h=a.charCodeAt(3),d=e.length-1;for(let g=i;g<s;){const m=g+8<=s,A=g+4<=s?r[g]*16777216+(r[g+1]<<16|r[g+2]<<8|r[g+3]):ce(r,g),C=A>1?g+A:s;if(m&&r[g+4]===o&&r[g+5]===l&&r[g+6]===u&&r[g+7]===h){const v=Math.min(C,s);t===d?n.push(r.subarray(g+8,v)):ao(r,e,t+1,g+8,v,n)}g=C}}function _h(r){const e=[],t=r[0];let i=8;const s=ce(r,i);i+=4;let n=0,a=0;t===0?(n=ce(r,i),a=ce(r,i+4),i+=8):(n=so(r,i),a=so(r,i+8),i+=16),i+=2;let o=r.length+a;const l=io(r,i);i+=2;for(let u=0;u<l;u++){let h=i;const d=ce(r,h);h+=4;const g=d&2147483647;if((d&2147483648)>>>31===1)return Ge.warn("SIDX has hierarchical references (not supported)"),null;const A=ce(r,h);h+=4,e.push({referenceSize:g,subsegmentDuration:A,info:{duration:A/s,start:o,end:o+g-1}}),o+=g,h+=4,i=h}return{earliestPresentationTime:n,timescale:s,version:t,referencesCount:l,references:e}}function oo(r){const e=[],t=xe(r,["moov","trak"]);for(let s=0;s<t.length;s++){const n=t[s],a=xe(n,["tkhd"])[0];if(a){let o=a[0];const l=ce(a,o===0?12:20),u=xe(n,["mdia","mdhd"])[0];if(u){o=u[0];const h=ce(u,o===0?12:20),d=xe(n,["mdia","hdlr"])[0];if(d){const g=Yt(d.subarray(8,12)),m={soun:ze.AUDIO,vide:ze.VIDEO}[g],A=xe(n,["mdia","minf","stbl","stsd"])[0],C=kh(A);m?(e[l]={timescale:h,type:m,stsd:C},e[m]=Ae({timescale:h,id:l},C)):e[l]={timescale:h,type:g,stsd:C}}}}}return xe(r,["moov","mvex","trex"]).forEach(s=>{const n=ce(s,4),a=e[n];a&&(a.default={duration:ce(s,12),sampleSize:ce(s,16),flags:ce(s,20)})}),e}function kh(r){const e=r.subarray(8),t=e.subarray(86),i=Yt(e.subarray(4,8));let s=i,n;const a=i==="enca"||i==="encv";if(a){const u=xe(e,[i])[0].subarray(i==="enca"?28:78);xe(u,["sinf"]).forEach(d=>{const g=xe(d,["schm"])[0];if(g){const m=Yt(g.subarray(4,8));if(m==="cbcs"||m==="cenc"){const A=xe(d,["frma"])[0];A&&(s=Yt(A))}}})}const o=s;switch(s){case"avc1":case"avc2":case"avc3":case"avc4":{const l=xe(t,["avcC"])[0];l&&l.length>3&&(s+="."+Xs(l[1])+Xs(l[2])+Xs(l[3]),n=zs(o==="avc1"?"dva1":"dvav",t));break}case"mp4a":{const l=xe(e,[i])[0],u=xe(l.subarray(28),["esds"])[0];if(u&&u.length>7){let h=4;if(u[h++]!==3)break;h=ir(u,h),h+=2;const d=u[h++];if(d&128&&(h+=2),d&64&&(h+=u[h++]),u[h++]!==4)break;h=ir(u,h);const g=u[h++];if(g===64)s+="."+Xs(g);else break;if(h+=12,u[h++]!==5)break;h=ir(u,h);const m=u[h++];let A=(m&248)>>3;A===31&&(A+=1+((m&7)<<3)+((u[h]&224)>>5)),s+="."+A}break}case"hvc1":case"hev1":{const l=xe(t,["hvcC"])[0];if(l&&l.length>12){const u=l[1],h=["","A","B","C"][u>>6],d=u&31,g=ce(l,2),m=(u&32)>>5?"H":"L",A=l[12],C=l.subarray(6,12);s+="."+h+d,s+="."+wh(g).toString(16).toUpperCase(),s+="."+m+A;let v="";for(let S=C.length;S--;){const R=C[S];(R||v)&&(v="."+R.toString(16).toUpperCase()+v)}s+=v}n=zs(o=="hev1"?"dvhe":"dvh1",t);break}case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":{s=zs(s,t)||s;break}case"vp09":{const l=xe(t,["vpcC"])[0];if(l&&l.length>6){const u=l[4],h=l[5],d=l[6]>>4&15;s+="."+ei(u)+"."+ei(h)+"."+ei(d)}break}case"av01":{const l=xe(t,["av1C"])[0];if(l&&l.length>2){const u=l[1]>>>5,h=l[1]&31,d=l[2]>>>7?"H":"M",g=(l[2]&64)>>6,m=(l[2]&32)>>5,A=u===2&&g?m?12:10:g?10:8,C=(l[2]&16)>>4,v=(l[2]&8)>>3,S=(l[2]&4)>>2,R=l[2]&3;s+="."+u+"."+ei(h)+d+"."+ei(A)+"."+C+"."+v+S+R+"."+ei(1)+"."+ei(1)+"."+ei(1)+"."+0,n=zs("dav1",t)}break}}return{codec:s,encrypted:a,supplemental:n}}function zs(r,e){const t=xe(e,["dvvC"]),i=t.length?t[0]:xe(e,["dvcC"])[0];if(i){const s=i[2]>>1&127,n=i[2]<<5&32|i[3]>>3&31;return r+"."+ei(s)+"."+ei(n)}}function wh(r){let e=0;for(let t=0;t<32;t++)e|=(r>>t&1)<<31-t;return e>>>0}function ir(r,e){const t=e+5;for(;r[e++]&128&&e<t;);return e}function Xs(r){return("0"+r.toString(16).toUpperCase()).slice(-2)}function ei(r){return(r<10?"0":"")+r}function Mh(r,e){if(!r||!e)return;const t=e.keyId;t?.byteLength===16&&e.isCommonEncryption&&lo(r,(i,s)=>{const n=i.subarray(8,24);n.some(a=>a!==0)||(Ge.log(`[eme] Patching keyId in 'enc${s?"a":"v"}>sinf>>tenc' box: ${ut(n)} -> ${ut(t)}`),i.set(t,8))})}function Oh(r){const e=[];return lo(r,t=>e.push(t.subarray(8,24))),e}function lo(r,e){xe(r,["moov","trak"]).forEach(i=>{const s=xe(i,["mdia","minf","stbl","stsd"])[0];if(!s)return;const n=s.subarray(8);let a=xe(n,["enca"]);const o=a.length>0;o||(a=xe(n,["encv"])),a.forEach(l=>{const u=o?l.subarray(28):l.subarray(78);xe(u,["sinf"]).forEach(d=>{const g=uo(d);g&&e(g,o)})})})}function uo(r){const e=xe(r,["schm"])[0];if(e){const t=Yt(e.subarray(4,8));if(t==="cbcs"||t==="cenc"){const i=xe(r,["schi","tenc"])[0];if(i)return i}}}let co;function Fh(r){return typeof TextDecoder>"u"?Mt(r):(co||(co=new TextDecoder("utf-8"))).decode(r).replace(/\0/g,"")}function Nh(r){const e=r.byteLength,t=[];for(let i=0;i<e;){const s=i+8<=e,n=i+4<=e?r[i]*16777216+(r[i+1]<<16|r[i+2]<<8|r[i+3]):ce(r,i),a=n>1?i+n:e;if(s&&r[i+4]===109&&r[i+5]===111&&r[i+6]===111&&r[i+7]===102){const o=Math.min(a,e);for(let l=i+8;l<o;){const u=l+8<=o,h=l+4<=o?r[l]*16777216+(r[l+1]<<16|r[l+2]<<8|r[l+3]):ce(r,l),d=h>1?l+h:o;if(u&&r[l+4]===116&&r[l+5]===114&&r[l+6]===97&&r[l+7]===102){const g=Math.min(d,o);let m,A;const C=[];for(let v=l+8;v<g;){const S=v+8<=g,R=v+4<=g?r[v]*16777216+(r[v+1]<<16|r[v+2]<<8|r[v+3]):ce(r,v),b=R>1?v+R:g;if(S&&r[v+4]===116){const D=Math.min(b,g);r[v+5]===102&&r[v+6]===104&&r[v+7]===100?A||(A=r.subarray(v+8,D)):r[v+5]===102&&r[v+6]===100&&r[v+7]===116?m||(m=r.subarray(v+8,D)):r[v+5]===114&&r[v+6]===117&&r[v+7]===110&&C.push(r.subarray(v+8,D))}v=b}t.push({moofOffset:r.byteOffset+i,tfdt:m,tfhd:A,truns:C})}l=d}}i=a}return t}function Bh(r,e,t,i,s=!0){return ho(r,e,i,s)}function Uh(r,e,t,i,s=!1){const n=[],a=e.samples,o=ho(a,t,i,s,{isHEVCFlavor:fs(e.codec),samples:n,timeOffset:r,timescale:e.timescale,trackId:e.id});return{samples:n,sampleData:{includeSampleDetails:s,tracks:o}}}function ho(r,e,t,i,s){const n={};let a=!1;const o=Nh(r),l=r.byteLength;for(let d=0;d<o.length;d++){const{moofOffset:g,tfdt:m,tfhd:A,truns:C}=o[d],v=ce(A,4),S=e[v];if(!S)continue;const R=n[v]||(n[v]={start:NaN,duration:0,sampleCount:0,trun:[],timescale:S.timescale,type:S.type});let b;if(m){const Z=m[0];b=ce(m,4),Z===1&&(b===Jt?t.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"):(b*=Jt+1,b+=ce(m,8))),se(b)&&(!se(R.start)||b<R.start)&&(R.start=b),s&&se(b)&&(s.timeOffset=b/s.timescale)}const D=s?.trackId===v&&S.type===ze.VIDEO,_=S.default,M=ce(A,0)&16777215;let p=_?.duration||0,$,N=_?.sampleSize||0,O=8;M&1&&(O+=8),M&2&&(O+=4),M&8&&(p=ce(A,O),$=A.byteOffset-r.byteOffset+O,O+=4),M&16&&(N=ce(A,O));let W=0;const q=(M&1)!==0,z=!q&&(M&131072)!==0;q?(W=ce(A,8),W*=Math.pow(2,32),W+=ce(A,12)):z&&(W=g);let oe=b||0,ne=0,J=p;for(let Z=0;Z<C.length;Z++){const Q=C[Z],ee=ce(Q,4),he=R.sampleCount;R.sampleCount+=ee;const te=Q[3]&1;let re=0;const Ee=Q[3]&4,Ie=Q[2]&1,_e=Q[2]&2,ye=Q[2]&4,Oe=Q[2]&8;let Le=8;te&&(re=er(Q,Le),Le+=4),Ee&&(!(Q[Le+1]&1)&&R.keyFrameIndex===void 0&&(R.keyFrameIndex=he),Le+=4);let Fe=W+re;if(!i&&Q[1]===0&&Q[2]===6&&Q[3]===1){var u,h;const We=oe,St=Fe,$t=Le;let pe=-1,we=0,Re=0,rt=(u=s?.timeOffset)!=null?u:0;const it=p/((h=s?.timescale)!=null?h:1),At=s?.isHEVCFlavor===!0,at=At?2:1;for(let nt=0;nt<ee;nt++){const ue=Q[Le]===0?Q[Le+1]<<16|Q[Le+2]<<8|Q[Le+3]:ce(Q,Le),Ze=pe===-1&&R.keyFrameIndex===void 0&&(Q[Le+5]&1)===0;Le+=8;const xt=Fe+ue;if(D){if(ue>0){let ft=Fe;do{const li=r[ft]===0?r[ft+1]<<16|r[ft+2]<<8|r[ft+3]:ce(r,ft);ft+=4;const Gt=r[ft],Dt=At?Gt>>1&63:Gt&31;(At?Dt===39||Dt===40:Dt===6)&&gs(r.subarray(ft,ft+li),at,rt,s.samples),ft+=li}while(ft<xt)}rt+=it}Fe=xt,Ze&&(pe=nt,we=Fe)}if(Fe<=l)Re=ee;else{let nt=St,ue=$t;for(let Ze=0;Ze<ee;Ze++){const xt=Q[ue]===0?Q[ue+1]<<16|Q[ue+2]<<8|Q[ue+3]:ce(Q,ue);if(nt+=xt,nt>l)break;Re=Ze+1,ue+=8}}if(D&&(s.timeOffset=rt),pe!==-1&&we<=l&&R.keyFrameIndex===void 0&&(R.keyFrameIndex=pe,R.keyFrameStart=We+pe*p),Re){(!se(R.ptsMin)||We<R.ptsMin)&&(R.ptsMin=We);const nt=We+Re*p;(!se(R.ptsMax)||nt>R.ptsMax)&&(R.ptsMax=nt)}const Bt=p*ee;oe=We+Bt,ne+=Bt;continue}let Ye,Ct;i&&(Ye=[],Ct={sampleOffset:Fe,samples:Ye,defaultSampleDurationOffset:$},Fe<=l&&R.trun.push(Ct));let yt;for(let We=0;We<ee;We++){let St;Ie?(i&&(St=Q.byteOffset-r.byteOffset+Le),J=ce(Q,Le),Le+=4):J=p,_e?(yt=ce(Q,Le),Le+=4):yt=N;let $t,pe;ye&&(pe=Q[Le+1]&1?1:0,i&&($t={isNonSync:pe,dependsOn:(Q[Le]&3)===1?1:2}),Le+=4);let we=0;if(Oe&&(we=Q[0]===0?ce(Q,Le):er(Q,Le),Le+=4),D){let Re=Fe,rt=0;for(;rt<yt;){const it=ce(r,Re);Re+=4,fo(s.isHEVCFlavor,r[Re])&&gs(r.subarray(Re,Re+it),s.isHEVCFlavor?2:1,s.timeOffset+we/s.timescale,s.samples),Re+=it,rt+=it+4}s.timeOffset+=J/s.timescale}if(Fe+=yt,Fe<=l){Ct&&St!==void 0&&(Ct.lastSampleDurationOffset=St),pe===0&&R.keyFrameIndex===void 0&&(R.keyFrameIndex=We,R.keyFrameStart=oe);const Re=oe+we;(!se(R.ptsMin)||Re<R.ptsMin)&&(R.ptsMin=Re),(!se(R.ptsMax)||Re+J>R.ptsMax)&&(R.ptsMax=Re+J),Ye&&(Ye[We]={cts:we,duration:J,flags:$t,size:yt})}oe+=J,ne+=J}!ne&&p&&(ne+=p*ee)}R.duration+=ne,R.duration&&(a=!0)}if(!a){let d=1/0,g=0;const m=xe(r,["sidx"]);for(let A=0;A<m.length;A++){const C=_h(m[A]);if(C!=null&&C.references){d=Math.min(d,C.earliestPresentationTime/C.timescale);const v=C.references.reduce((S,R)=>S+R.info.duration||0,0);g=Math.max(g,v+C.earliestPresentationTime/C.timescale)}}g&&se(g)&&Object.keys(n).forEach(A=>{n[A].duration||(n[A].duration=g*n[A].timescale-n[A].start)})}return n}function $h(r){const e={valid:null,remainder:null},t=xe(r,["moof"]);if(t.length<2)return e.remainder=r,e;const i=t[t.length-1];return e.valid=r.slice(0,i.byteOffset-8),e.remainder=r.slice(i.byteOffset-8),e}function Ut(r,e){const t=new Uint8Array(r.length+e.length);return t.set(r),t.set(e,r.length),t}function Gh(r,e){const t=[],i=e.samples,s=e.timescale,n=e.id;let a=!1;return xe(i,["moof"]).map(l=>{const u=l.byteOffset-8;xe(l,["traf"]).map(d=>{const g=xe(d,["tfdt"]).map(m=>{const A=m[0];let C=ce(m,4);return A===1&&(C*=Math.pow(2,32),C+=ce(m,8)),C/s})[0];return g!==void 0&&(r=g),xe(d,["tfhd"]).map(m=>{const A=ce(m,4),C=ce(m,0)&16777215,v=(C&1)!==0;let S=0;const R=(C&2)!==0,b=(C&8)!==0;let D=0;const _=(C&16)!==0;let M=0;const p=(C&32)!==0,$=!v&&(C&131072)!==0;let N=8;A===n&&(v?(S=ce(m,N),N+=4,S*=Math.pow(2,32),S+=ce(m,N),N+=4):$&&(S=u),R&&(N+=4),b&&(D=ce(m,N),N+=4),_&&(M=ce(m,N),N+=4),p&&(N+=4),e.type==="video"&&(a=fs(e.codec)),xe(d,["trun"]).map(O=>{const W=O[0],q=ce(O,0)&16777215,z=(q&1)!==0;let oe=0;const ne=(q&4)!==0,J=(q&256)!==0;let Z=0;const Q=(q&512)!==0;let ee=0;const he=(q&1024)!==0,te=(q&2048)!==0;let re=0;const Ee=ce(O,4);let Ie=8;z&&(oe=ce(O,Ie),Ie+=4),ne&&(Ie+=4);let _e=S+oe;for(let ye=0;ye<Ee;ye++){if(J?(Z=ce(O,Ie),Ie+=4):Z=D,Q?(ee=ce(O,Ie),Ie+=4):ee=M,he&&(Ie+=4),te&&(W===0?re=ce(O,Ie):re=er(O,Ie),Ie+=4),e.type===ze.VIDEO){let Oe=0;for(;Oe<ee;){const Le=ce(i,_e);if(_e+=4,fo(a,i[_e])){const Fe=i.subarray(_e,_e+Le);gs(Fe,a?2:1,r+re/s,t)}_e+=Le,Oe+=Le+4}}r+=Z/s}}))})})}),t}function fs(r){if(!r)return!1;const e=r.substring(0,4);return e==="hvc1"||e==="hev1"||e==="dvh1"||e==="dvhe"}function fo(r,e){if(r){const t=e>>1&63;return t===39||t===40}else return(e&31)===6}function gs(r,e,t,i){const s=go(r);let n=0;n+=e;let a=0,o=0,l=0;for(;n<s.length;){a=0;do{if(n>=s.length)break;l=s[n++],a+=l}while(l===255);o=0;do{if(n>=s.length)break;l=s[n++],o+=l}while(l===255);const u=s.length-n;let h=n;if(o<u)n+=o;else if(o>u){Ge.error(`Malformed SEI payload. ${o} is too small, only ${u} bytes left to parse.`);break}if(a===4){if(s[h++]===181){const g=io(s,h);if(h+=2,g===49){const m=ce(s,h);if(h+=4,m===1195456820){const A=s[h++];if(A===3){const C=s[h++],v=31&C,S=64&C,R=S?2+v*3:0,b=new Uint8Array(R);if(S){b[0]=C;for(let D=1;D<R;D++)b[D]=s[h++]}i.push({type:A,payloadType:a,pts:t,bytes:b})}}}}}else if(a===5&&o>16){const d=[];for(let A=0;A<16;A++){const C=s[h++].toString(16);d.push(C.length==1?"0"+C:C),(A===3||A===5||A===7||A===9)&&d.push("-")}const g=o-16,m=new Uint8Array(g);for(let A=0;A<g;A++)m[A]=s[h++];i.push({payloadType:a,pts:t,uuid:d.join(""),userData:Fh(m),userDataBytes:m})}}}function go(r){const e=r.byteLength;let t,i=r.indexOf(3,3);for(;i!==-1;)r[i-1]===0&&r[i-2]===0&&(t||(t=[])).push(i),i=r.indexOf(3,i+1);if(!t)return r;const s=e-t.length,n=new Uint8Array(s);let a=0,o=0;for(let l=0;l<s;o++,l++)o===t[a]&&(o++,a++),n[l]=r[o];return n}function Hh(r){const e=r[0];let t="",i="",s=0,n=0,a,o=0,l=0,u=4;if(e===0){const d=qs(r,u),g=d!==null?qs(r,u+d.length):null;d!==null&&g!==null?(t=d,i=g,u+=d.length+g.length,s=ce(r,u),u+=4,n=ce(r,u),u+=4,o=ce(r,u),u+=4,l=ce(r,u),u+=4):(Ge.warn(`Unterminated ${d===null?"scheme_id_uri":"value"} in parsing emsg box: version 0 box ends inside a string, dropping all of its fields`),u=r.length)}else if(e===1){s=ce(r,u),u+=4;const d=ce(r,u);u+=4;const g=ce(r,u);u+=4,a=2**32*d+g,qc(a)||(a=Number.MAX_SAFE_INTEGER,Ge.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=ce(r,u),u+=4,l=ce(r,u),u+=4;const m=qs(r,u),A=m!==null?qs(r,u+m.length):null;m!==null&&(t=m,u+=m.length),A!==null?(i=A,u+=A.length):(Ge.warn(`Unterminated ${m===null?"scheme_id_uri":"value"} in parsing emsg box: version 1 box ends inside a string, dropping its ${m===null?"strings and payload":"value and payload"}`),u=r.length)}const h=r.subarray(u,r.byteLength);return{schemeIdUri:t,value:i,timeScale:s,presentationTime:a,presentationTimeDelta:n,eventDuration:o,id:l,payload:h}}function Vh(r,...e){const t=e.length;let i=8,s=t;for(;s--;)i+=e[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]=i&255,n.set(r,4),s=0,i=8;s<t;s++)n.set(e[s],i),i+=e[s].byteLength;return n}function Kh(r,e,t){if(r.byteLength!==16)throw new RangeError("Invalid system id");let i,s;i=0,s=new Uint8Array;let n;i>0?(n=new Uint8Array(4),e.length>0&&new DataView(n.buffer).setUint32(0,e.length,!1)):n=new Uint8Array;const a=new Uint8Array(4);return t.byteLength>0&&new DataView(a.buffer).setUint32(0,t.byteLength,!1),Vh([112,115,115,104],new Uint8Array([i,0,0,0]),r,n,s,a,t)}function po(r){const e=[];if(r instanceof ArrayBuffer){const t=r.byteLength;let i=0;for(;i+32<t;){const s=new DataView(r,i),n=Wh(s);e.push(n),i+=n.size}}return e}function Yh(r){const e=[];for(let t=0;t<r.length;){const i=r[t++],s=i&7;if(s===0){for(;r[t++]&128;);continue}if(s!==2){t+=s===1?8:4;continue}let n=0;for(let a=0,o=128;o&128;a+=7)n|=((o=r[t++])&127)<<a;if(i>>3===2)if(n===32){const a=new Uint8Array(16);for(let o=0;o<16;o++)a[o]=parseInt(String.fromCharCode(r[t+o*2],r[t+o*2+1]),16);e.push(a)}else n===16&&e.push(r.subarray(t,t+16));t+=n}return e}function Wh(r){const e=r.getUint32(0),t=r.byteOffset,i=r.byteLength;if(i<e)return{offset:t,size:i};if(r.getUint32(4)!==1886614376)return{offset:t,size:e};const n=r.getUint32(8)>>>24;if(n!==0&&n!==1)return{offset:t,size:e};const a=r.buffer,o=ut(new Uint8Array(a,t+12,16));let l=null,u=null,h=0;if(n===0)h=28;else{const g=r.getUint32(28);if(!g||i<32+g*16)return{offset:t,size:e};l=[];for(let m=0;m<g;m++)l.push(new Uint8Array(a,t+32+m*16,16));h=32+g*16}if(!h)return{offset:t,size:e};const d=r.getUint32(h);return e-32<d?{offset:t,size:e}:(u=new Uint8Array(a,t+h+4,d),n===0&&(l=Yh(u)),{version:n,systemId:o,kids:l,data:u,offset:t,size:e})}const Yi=mo("userAgent"),jh=mo("vendor");let sr,nr,rr;function mo(r){try{return navigator[r]||""}catch{}return""}function qh(){if(rr===void 0){const r=Yi.match(/Safari\/(\d+)/i);rr=r?parseInt(r[1]):0}return rr}function ps(){if(sr===void 0){const r=Yi.match(/Chrome\/(\d+)/i);sr=r?parseInt(r[1]):0}return sr}function zh(){if(nr===void 0){const r=Yi.match(/Firefox\/(\d+)/i);nr=r?parseInt(r[1]):0}return nr}function Ao(){return/\(Windows.+Firefox\//i.test(Yi)}function Xh(){return jh.indexOf("Apple")>-1||/iPhone|iPad|iPod/.test(Yi)}function Zh(){return/Android/.test(Yi)}const Wi={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,dav1:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1},image:{mjpg:1}};function ar(r,e){const t=Wi[e];return!!t&&!!t[r.slice(0,4)]}function ms(r,e,t=!0){return!r.split(",").some(i=>!or(i,e,t))}function or(r,e,t=!0){var i;const s=Ei(t);return(i=s?.isTypeSupported(As(r,e)))!=null?i:!1}function As(r,e){return`${e}/mp4;codecs=${r}`}function Io(r){if(r){const e=r.substring(0,4);return Wi.video[e]}return 2}function Zs(r){const e=Ao();return r.split(",").reduce((t,i)=>{const n=e&&fs(i)?9:Wi.video[i];return n?(n*2+t)/(t?3:2):(Wi.audio[i]+t)/(t?2:1)},0)}const lr={};function Qh(r,e=!0){if(lr[r])return lr[r];const t={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[r];for(let s=0;s<t.length;s++){var i;if(or(t[s],"audio",e))return lr[r]=t[s],t[s];if(t[s]==="mp3"&&(i=Ei(e))!=null&&i.isTypeSupported("audio/mpeg"))return""}return r}const Jh=/flac|opus|mp4a\.40\.34/i;function Qs(r,e=!0){return r.replace(Jh,t=>Qh(t.toLowerCase(),e))}function ed(r,e){const t=[];if(r){const i=r.split(",");for(let s=0;s<i.length;s++)ar(i[s],"video")||t.push(i[s])}return e&&t.push(e),t.join(",")}function Js(r,e){if(r&&(r.length>4||["ac-3","ec-3","alac","fLaC","Opus"].indexOf(r)!==-1)&&(Co(r,"audio")||Co(r,"video")))return r;if(e){const t=e.split(",");if(t.length>1){if(r){for(let i=t.length;i--;)if(t[i].substring(0,4)===r.substring(0,4))return t[i]}return t[0]}}return e||r}function Co(r,e){return ar(r,e)&&or(r,e)}function td(r){const e=r.split(",");for(let t=0;t<e.length;t++){const i=e[t].split(".");i.length>2&&i[0]==="avc1"&&(e[t]=`avc1.${parseInt(i[1]).toString(16)}${("000"+parseInt(i[2]).toString(16)).slice(-4)}`)}return e.join(",")}function id(r){if(r.startsWith("av01.")){const e=r.split("."),t=["0","111","01","01","01","0"];for(let i=e.length;i>4&&i<10;i++)e[i]=t[i-4];return e.join(".")}return r}function yo(r){const e=Ei(r)||{isTypeSupported:()=>!1};return{mpeg:e.isTypeSupported("audio/mpeg"),mp3:e.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:e.isTypeSupported('audio/mp4; codecs="ac-3"')}}function ur(r){return r.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}const sd={supported:!0,powerEfficient:!0,smooth:!0},nd={supported:!1,smooth:!1,powerEfficient:!1},vo={supported:!0,configurations:[],decodingInfoResults:[sd]};function Eo(r,e){return{supported:!1,configurations:e,decodingInfoResults:[nd],error:r}}function rd(r,e,t,i,s,n){const a=r.videoCodec,o=r.audioCodec?r.audioGroups:null,l=n?.audioCodec,u=n?.channels,h=u?parseInt(u):l?1/0:2;let d=null;if(o!=null&&o.length)try{o.length===1&&o[0]?d=e.groups[o[0]].channels:d=o.reduce((g,m)=>{if(m){const A=e.groups[m];if(!A)throw new Error(`Audio track group ${m} not found`);Object.keys(A.channels).forEach(C=>{g[C]=(g[C]||0)+A.channels[C]})}return g},{2:0})}catch{return!0}return a!==void 0&&(a.split(",").some(g=>fs(g))||r.width>1920&&r.height>1088||r.height>1920&&r.width>1088||r.frameRate>Math.max(i,30)||r.videoRange!=="SDR"&&r.videoRange!==t||r.bitrate>Math.max(s,8e6))||!!d&&se(h)&&Object.keys(d).some(g=>parseInt(g)>h)}function To(r,e,t,i={}){const s=r.videoCodec;if(!s&&!r.audioCodec||!t)return Promise.resolve(vo);const n=[],a=ad(r),o=a.length,l=od(r,e,o>0),u=l.length;for(let h=o||1*u||1;h--;){const d={type:"media-source"};if(o&&(d.video=a[h%o]),u){d.audio=l[h%u];const g=d.audio.bitrate;d.video&&g&&(d.video.bitrate-=g)}n.push(d)}if(s){const h=navigator.userAgent;if(s.split(",").some(d=>fs(d))&&Ao())return Promise.resolve(Eo(new Error(`Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent string: (${h})`),n))}return Promise.all(n.map(h=>{const d=ld(h);return i[d]||(i[d]=t.decodingInfo(h))})).then(h=>({supported:!h.some(d=>!d.supported),configurations:n,decodingInfoResults:h})).catch(h=>({supported:!1,configurations:n,decodingInfoResults:[],error:h}))}function ad(r){var e;const t=(e=r.videoCodec)==null?void 0:e.split(","),i=xo(r),s=r.width||640,n=r.height||480,a=r.frameRate||30,o=r.videoRange.toLowerCase();return t?t.map(l=>{const u={contentType:As(id(l),"video"),width:s,height:n,bitrate:i,framerate:a};return o!=="sdr"&&(u.transferFunction=o),u}):[]}function od(r,e,t){var i;const s=(i=r.audioCodec)==null?void 0:i.split(","),n=xo(r);return s&&r.audioGroups?r.audioGroups.reduce((a,o)=>{var l;const u=o?(l=e.groups[o])==null?void 0:l.tracks:null;return u?u.reduce((h,d)=>{if(d.groupId===o){const g=parseFloat(d.channels||"");s.forEach(m=>{const A={contentType:As(m,"audio"),bitrate:t?So(m,n):n};g&&(A.channels=""+g),h.push(A)})}return h},a):a},[]):[]}function So(r,e){if(e<=1)return 1;let t=128e3;return r==="ec-3"?t=768e3:r==="ac-3"&&(t=64e4),Math.min(e/2,t)}function xo(r){return Math.ceil(Math.max(r.bitrate*.9,r.averageBitrate)/1e3)*1e3||1}function ld(r){let e="";const{audio:t,video:i}=r;if(i){const s=ur(i.contentType);e+=`${s}_r${i.height}x${i.width}f${Math.ceil(i.framerate)}${i.transferFunction||"sd"}_${Math.ceil(i.bitrate/1e5)}`}if(t){const s=ur(t.contentType);e+=`${i?"_":""}${s}_c${t.channels}`}return e}function Ti(r,e,t){const i=encodeURIComponent(e),s=`${i}=${encodeURIComponent(t)}`;let n=!1;const a=[];r.search.substring(1).split("&").forEach(o=>{o===i||o.startsWith(i+"=")?n||(a.push(s),n=!0):o&&a.push(o)}),n||a.push(s),r.search=a.join("&")}const cr=["NONE","TYPE-0","TYPE-1",null];function ud(r){return cr.indexOf(r)>-1}const en=["SDR","PQ","HLG"];function cd(r){return!!r&&en.indexOf(r)>-1}var tn={No:"",Yes:"YES",v2:"v2"};function bo(r){const{canSkipUntil:e,canSkipDateRanges:t,age:i}=r,s=i<e/2;return e&&s?t?tn.v2:tn.Yes:tn.No}class Lo{constructor(e,t,i){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=i}addDirectives(e){const t=new self.URL(e);return this.msn!==void 0&&Ti(t,"_HLS_msn",this.msn.toString()),this.part!==void 0&&Ti(t,"_HLS_part",this.part.toString()),this.skip&&Ti(t,"_HLS_skip",this.skip),t.href}}class Is{constructor(e){if(this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.supplemental=void 0,this.videoCodec=void 0,this.width=void 0,this.imageCodec=void 0,this.iframes=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loadErrorTime=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.frameRate=e.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=e.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,"imageCodec"in e&&(this.imageCodec=e.imageCodec),this.codecSet=[e.videoCodec,e.audioCodec].filter(i=>!!i).map(i=>i.substring(0,4)).join(","),"supplemental"in e){var t;this.supplemental=e.supplemental;const i=(t=e.supplemental)==null?void 0:t.videoCodec;i&&i!==e.videoCodec&&(this.codecSet+=`,${i.substring(0,4)}`)}"iframes"in e&&e.iframes?this.iframes=!0:(this.addGroupId("audio",e.attrs.AUDIO),this.addGroupId("text",e.attrs.SUBTITLES))}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get averageBitrate(){return this._avgBitrate||this.realBitrate||this.bitrate}get attrs(){return this._attrs[0]}get codecs(){return this.attrs.CODECS||""}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get videoRange(){return this.attrs["VIDEO-RANGE"]||"SDR"}get score(){return this.attrs.optionalFloat("SCORE",0)}get uri(){return this.url[0]||""}hasAudioGroup(e){return Ro(this._audioGroups,e)}hasSubtitleGroup(e){return Ro(this._subtitleGroups,e)}get audioGroups(){return this._audioGroups}get subtitleGroups(){return this._subtitleGroups}addGroupId(e,t){if(t){if(e==="audio"){let i=this._audioGroups;i||(i=this._audioGroups=[]),i.indexOf(t)===-1&&i.push(t)}else if(e==="text"){let i=this._subtitleGroups;i||(i=this._subtitleGroups=[]),i.indexOf(t)===-1&&i.push(t)}}}get urlId(){return 0}set urlId(e){}get audioGroupIds(){return this.audioGroups?[this.audioGroupId]:void 0}get textGroupIds(){return this.subtitleGroups?[this.textGroupId]:void 0}get audioGroupId(){var e;return(e=this.audioGroups)==null?void 0:e[0]}get textGroupId(){var e;return(e=this.subtitleGroups)==null?void 0:e[0]}addFallback(){}}function Ro(r,e){return!e||!r?!1:r.indexOf(e)!==-1}function hd(){if(typeof matchMedia=="function"){const r=matchMedia("(dynamic-range: high)"),e=matchMedia("bad query");if(r.media!==e.media)return r.matches===!0}return!1}function dd(r,e){let t=!1,i=[];if(r&&(t=r!=="SDR",i=[r]),e){i=e.allowedVideoRanges||en.slice(0);const s=i.join("")!=="SDR"&&!e.videoCodec;t=e.preferHDR!==void 0?e.preferHDR:s&&hd(),t||(i=["SDR"])}return{preferHDR:t,allowedVideoRanges:i}}const fd=r=>{const e=new WeakSet;return(t,i)=>{if(r&&(i=r(t,i)),typeof i=="object"&&i!==null){if(e.has(i))return;e.add(i)}return i}},Xe=(r,e)=>JSON.stringify(r,fd(e));function gd(r,e,t,i,s){const n=Object.keys(r),a=i?.channels,o=i?.audioCodec,l=s?.videoCodec,u=a&&parseInt(a)===2;let h=!1,d=!1,g=1/0,m=1/0,A=1/0,C=1/0,v=0,S=[];const{preferHDR:R,allowedVideoRanges:b}=dd(e,s);for(let $=n.length;$--;){const N=r[n[$]];h||(h=N.channels[2]>0),g=Math.min(g,N.minHeight),m=Math.min(m,N.minFramerate),A=Math.min(A,N.minBitrate),b.filter(W=>N.videoRanges[W]>0).length>0&&(d=!0)}g=se(g)?g:0,m=se(m)?m:0;const D=Math.max(1080,g),_=Math.max(30,m);A=se(A)?A:t,t=Math.max(A,t),d||(e=void 0);const M=n.length>1;return{codecSet:n.reduce(($,N)=>{const O=r[N];if(N===$)return $;if(S=d?b.filter(W=>O.videoRanges[W]>0):[],M){if(O.minBitrate>t)return ti(N,`min bitrate of ${O.minBitrate} > current estimate of ${t}`),$;if(!O.hasDefaultAudio)return ti(N,"no renditions with default or auto-select sound found"),$;if(o&&N.indexOf(o.substring(0,4))%5!==0)return ti(N,`audio codec preference "${o}" not found`),$;if(a&&!u){if(!O.channels[a])return ti(N,`no renditions with ${a} channel sound found (channels options: ${Object.keys(O.channels)})`),$}else if((!o||u)&&h&&O.channels[2]===0)return ti(N,"no renditions with stereo sound found"),$;if(O.minHeight>D)return ti(N,`min resolution of ${O.minHeight} > maximum of ${D}`),$;if(O.minFramerate>_)return ti(N,`min framerate of ${O.minFramerate} > maximum of ${_}`),$;if(!S.some(W=>O.videoRanges[W]>0))return ti(N,`no variants with VIDEO-RANGE of ${Xe(S)} found`),$;if(l&&N.indexOf(l.substring(0,4))%5!==0)return ti(N,`video codec preference "${l}" not found`),$;if(O.maxScore<v)return ti(N,`max score of ${O.maxScore} < selected max of ${v}`),$}return $&&(Zs(N)>=Zs($)||O.fragmentError>r[$].fragmentError)?$:(C=O.minIndex,v=O.maxScore,N)},void 0),videoRanges:S,preferHDR:R,minFramerate:m,minBitrate:A,minIndex:C}}function ti(r,e){Ge.log(`[abr] start candidates with "${r}" ignored because ${e}`)}function Do(r){return r.reduce((e,t)=>{let i=e.groups[t.groupId];i||(i=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),i.tracks.push(t);const s=t.channels||"2";return i.channels[s]=(i.channels[s]||0)+1,i.hasDefault=i.hasDefault||t.default,i.hasAutoSelect=i.hasAutoSelect||t.autoselect,i.hasDefault&&(e.hasDefaultAudio=!0),i.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function pd(r,e,t,i){return r.slice(t,i+1).reduce((s,n,a)=>{if(!n.codecSet)return s;const o=n.audioGroups;let l=s[n.codecSet];l||(s[n.codecSet]=l={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:a,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!o,fragmentError:0}),l.minBitrate=Math.min(l.minBitrate,n.bitrate);const u=Math.min(n.height,n.width);return l.minHeight=Math.min(l.minHeight,u),l.minFramerate=Math.min(l.minFramerate,n.frameRate),l.minIndex=Math.min(l.minIndex,a),l.maxScore=Math.max(l.maxScore,n.score),l.fragmentError+=n.fragmentError,l.videoRanges[n.videoRange]=(l.videoRanges[n.videoRange]||0)+1,o&&o.forEach(h=>{if(!h)return;const d=e.groups[h];d&&(l.hasDefaultAudio=l.hasDefaultAudio||e.hasDefaultAudio?d.hasDefault:d.hasAutoSelect||!e.hasDefaultAudio&&!e.hasAutoSelectAudio,Object.keys(d.channels).forEach(g=>{l.channels[g]=(l.channels[g]||0)+d.channels[g]}))}),s},{})}function Po(r){if(!r)return r;const{lang:e,assocLang:t,characteristics:i,channels:s,audioCodec:n}=r;return{lang:e,assocLang:t,characteristics:i,channels:s,audioCodec:n}}function ii(r,e,t){if("attrs"in r){const i=e.indexOf(r);if(i!==-1)return i}for(let i=0;i<e.length;i++){const s=e[i];if(wi(r,s,t))return i}return-1}function wi(r,e,t){const{groupId:i,name:s,lang:n,assocLang:a,default:o}=r,l=r.forced;return(i===void 0||e.groupId===i)&&(s===void 0||e.name===s)&&(n===void 0||md(n,e.lang))&&(a===void 0||e.assocLang===a)&&(o===void 0||e.default===o)&&(l===void 0||e.forced===l)&&(!("characteristics"in r)||Ad(r.characteristics||"",e.characteristics))&&(t===void 0||t(r,e))}function md(r,e="--"){return r.length===e.length?r===e:r.startsWith(e)||e.startsWith(r)}function Ad(r,e=""){const t=r.split(","),i=e.split(",");return t.length===i.length&&!t.some(s=>i.indexOf(s)===-1)}function Mi(r,e){const{audioCodec:t,channels:i}=r;return(t===void 0||(e.audioCodec||"").substring(0,4)===t.substring(0,4))&&(i===void 0||i===(e.channels||"2"))}function Id(r,e,t,i,s){const n=e[i],o=e.reduce((g,m,A)=>{const C=m.uri;return(g[C]||(g[C]=[])).push(A),g},{})[n.uri];o.length>1&&(i=Math.max.apply(Math,o));const l=n.videoRange,u=n.frameRate,h=n.codecSet.substring(0,4),d=_o(e,i,g=>{if(g.videoRange!==l||g.frameRate!==u||g.codecSet.substring(0,4)!==h)return!1;const m=g.audioGroups,A=t.filter(C=>Cs(C.groupId,m));return ii(r,A,s)>-1});return d>-1?d:_o(e,i,g=>{const m=g.audioGroups,A=t.filter(C=>Cs(C.groupId,m));return ii(r,A,s)>-1})}function _o(r,e,t){for(let i=e;i>-1;i--)if(t(r[i]))return i;for(let i=e+1;i<r.length;i++)if(t(r[i]))return i;return-1}function sn(r,e){var t;return!!r&&r!==((t=e.loadLevelObj)==null?void 0:t.uri)}function Cs(r,e){return e?e.indexOf(r)!==-1:!0}function ko(r,e){if(e||r){const t=je({},e);return r&&(r.videoCodec&&(t.videoCodec=r.videoCodec),r.videoRange&&(t.allowedVideoRanges=[r.videoRange])),t}}class Cd extends wt{constructor(e){super("abr",e.logger),this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.firstAutoFloor=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.codecTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.rebufferNotice=-1,this.supportedCache={},this.bwEstimator=void 0,this._abandonRulesCheck=t=>{var i;const{fragCurrent:s,partCurrent:n,hls:a}=this;if(!a)return;const{autoLevelEnabled:o,media:l}=a;if(!s||!l)return;const u=performance.now(),h=n?n.stats:s.stats,d=n?n.duration:s.duration,g=u-h.loading.start,m=a.minAutoLevel,A=s.level,C=this._nextAutoLevel;if(h.aborted||h.loaded&&h.loaded===h.total||A<=m){this.clearTimer(),this._nextAutoLevel=-1;return}if(!o)return;const v=C>-1&&C!==A,S=!!t||v;if(!S&&(l.paused||!l.playbackRate||!l.readyState))return;const R=a.mainForwardBufferInfo;if(!S&&R===null)return;const b=this.bwEstimator.getEstimateTTFB(),D=Math.abs(l.playbackRate);if(g<=Math.max(b,1e3*(d/(D*2))))return;const _=R?R.len/D:0,M=h.loading.first?h.loading.first-h.loading.start:-1,p=h.loaded&&M>-1,$=this.getBwEstimate(),N=a.levels,O=N[A],W=Math.max(h.loaded,Math.round(d*(s.bitrate||O.averageBitrate)/8));let q=p?g-M:g;q<1&&p&&(q=Math.min(g,h.loaded*8/$));const z=p?h.loaded*1e3/q:0,oe=b/1e3,ne=z?(W-h.loaded)/z:W*8/$+oe;if(ne<=_)return;const J=z?z*8:$,Z=((i=t?.details||a.latestLevelDetails)==null?void 0:i.live)===!0,Q=a.config.abrBandWidthUpFactor;let ee=Number.POSITIVE_INFINITY,he;for(he=A-1;he>m;he--){const Ie=N[he].maxBitrate,_e=!N[he].details||Z;if(ee=this.getTimeToLoadFrag(oe,J,d*Ie,_e),ee<Math.min(_,d+oe))break}if(ee>=ne||ee>d*10)return;p?this.bwEstimator.sample(g-Math.min(b,M),h.loaded):this.bwEstimator.sampleTTFB(g);const te=N[he].maxBitrate;this.getBwEstimate()*Q>te&&(this.firstAutoFloor=Math.min(he,a.firstLevel),this.resetEstimator(te));const re=this.findBestLevel(te,m,he,0,_,1,1);re>-1&&(he=re),this.warn(`Fragment ${s.sn}${n?" part "+n.index:""} of level ${A} is loading too slowly;
2
2
  Fragment duration: ${s.duration.toFixed(3)}
3
- Time to underbuffer: ${N.toFixed(3)} s
4
- Estimated load time for current fragment: ${ue.toFixed(3)} s
5
- Estimated load time for down switch fragment: ${le.toFixed(3)} s
6
- TTFB estimate: ${K|0} ms
3
+ Time to underbuffer: ${_.toFixed(3)} s
4
+ Estimated load time for current fragment: ${ne.toFixed(3)} s
5
+ Estimated load time for down switch fragment: ${ee.toFixed(3)} s
6
+ TTFB estimate: ${M|0} ms
7
7
  Current BW estimate: ${se($)?$|0:"Unknown"} bps
8
8
  New BW estimate: ${this.getBwEstimate()|0} bps
9
- Switching to level ${pe} @ ${J|0} bps`),n.nextLoadLevel=n.nextAutoLevel=pe,this.clearTimer();const ve=()=>{if(this.clearTimer(),this.fragCurrent===s&&this.hls.loadLevel===pe&&pe>0){const ke=this.getStarvationDelay();if(this.warn(`Aborting inflight request ${pe>0?"and switching down":""}
9
+ Switching to level ${he} @ ${te|0} bps`),a.nextLoadLevel=a.nextAutoLevel=he,this.clearTimer();const Ee=()=>{this.clearTimer();const Ie=this.hls;if(this.fragCurrent===s&&Ie.loadLevel===he&&he>0){const _e=this.getStarvationDelay();if(this.warn(`Aborting inflight request ${he>0?"and switching down":""}
10
10
  Fragment duration: ${s.duration.toFixed(3)} s
11
- Time to underbuffer: ${ke.toFixed(3)} s`),s.abortRequests(),this.fragCurrent=this.partCurrent=null,pe>I){let Te=this.findBestLevel(this.hls.levels[I].bitrate,I,pe,0,ke,1,1);Te===-1&&(Te=I),this.hls.nextLoadLevel=this.hls.nextAutoLevel=Te,this.resetEstimator(this.hls.levels[Te].bitrate)}}};v||ue>le*2?ve():this.timer=self.setInterval(ve,le*1e3),n.trigger(y.FRAG_LOAD_EMERGENCY_ABORTED,{frag:s,part:r,stats:h})},this.hls=e,this.bwEstimator=this.initEstimator(),this.registerListeners()}resetEstimator(e){e&&(this.log(`setting initial bwe to ${e}`),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()}initEstimator(){const e=this.hls.config;return new yu(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}registerListeners(){const{hls:e}=this;e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.FRAG_LOADING,this.onFragLoading,this),e.on(y.FRAG_LOADED,this.onFragLoaded,this),e.on(y.FRAG_BUFFERED,this.onFragBuffered,this),e.on(y.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(y.LEVEL_LOADED,this.onLevelLoaded,this),e.on(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(y.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(y.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e&&(e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.FRAG_LOADING,this.onFragLoading,this),e.off(y.FRAG_LOADED,this.onFragLoaded,this),e.off(y.FRAG_BUFFERED,this.onFragBuffered,this),e.off(y.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(y.LEVEL_LOADED,this.onLevelLoaded,this),e.off(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(y.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(y.ERROR,this.onError,this))}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=this.supportedCache=null,this.fragCurrent=this.partCurrent=null}onManifestLoading(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.supportedCache={},this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()}onLevelsUpdated(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null}onMaxAutoLevelUpdated(){this.firstSelection=-1,this.nextAutoLevelKey=""}onFragLoading(e,t){const i=t.frag;if(!this.ignoreFragment(i)){if(!i.bitrateTest){var s;this.fragCurrent=i,this.partCurrent=(s=t.part)!=null?s:null}this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)}}onLevelSwitching(e,t){this.clearTimer()}onError(e,t){if(!t.fatal)switch(t.details){case U.BUFFER_ADD_CODEC_ERROR:case U.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case U.FRAG_LOAD_TIMEOUT:{const i=t.frag,{fragCurrent:s,partCurrent:r}=this;if(i&&s&&i.sn===s.sn&&i.level===s.level){const n=performance.now(),o=r?r.stats:i.stats,c=n-o.loading.start,u=o.loading.first?o.loading.first-o.loading.start:-1;if(o.loaded&&u>-1){const f=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(c-Math.min(f,u),o.loaded)}else this.bwEstimator.sampleTTFB(c)}break}}}getTimeToLoadFrag(e,t,i,s){const r=e+i/t,n=s?e+this.lastLevelLoadSec:0;return r+n}onLevelLoaded(e,t){const i=this.hls.config,{loading:s}=t.stats,r=s.end-s.first;se(r)&&(this.lastLevelLoadSec=r/1e3),t.details.live?this.bwEstimator.update(i.abrEwmaSlowLive,i.abrEwmaFastLive):this.bwEstimator.update(i.abrEwmaSlowVoD,i.abrEwmaFastVoD),this.timer>-1&&this._abandonRulesCheck(t.levelInfo)}onFragLoaded(e,{frag:t,part:i}){const s=i?i.stats:t.stats;if(t.type===he.MAIN&&this.bwEstimator.sampleTTFB(s.loading.first-s.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),t.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){const r=i?i.duration:t.duration,n=this.hls.levels[t.level],o=(n.loaded?n.loaded.bytes:0)+s.loaded,c=(n.loaded?n.loaded.duration:0)+r;n.loaded={bytes:o,duration:c},n.realBitrate=Math.round(8*o/c)}if(t.bitrateTest){const r={stats:s,frag:t,part:i,id:t.type};this.onFragBuffered(y.FRAG_BUFFERED,r),t.bitrateTest=!1}else this.lastLoadedFragLevel=t.level}}onFragBuffered(e,t){const{frag:i,part:s}=t,r=s!=null&&s.stats.loaded?s.stats:i.stats;if(r.aborted||this.ignoreFragment(i))return;const n=r.parsing.end-r.loading.start-Math.min(r.loading.first-r.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(n,r.loaded),r.bwEstimate=this.getBwEstimate(),i.bitrateTest?this.bitrateTestDelay=n/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==he.MAIN||e.sn==="initSegment"}clearTimer(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}get firstAutoLevel(){const{maxAutoLevel:e,minAutoLevel:t}=this.hls,i=this.getBwEstimate(),s=this.hls.config.maxStarvationDelay,r=this.findBestLevel(i,t,e,0,s,1,1);if(r>-1)return r;const n=this.hls.firstLevel,o=Math.min(Math.max(n,t),e);return this.warn(`Could not find best starting auto level. Defaulting to first in playlist ${n} clamped to ${o}`),o}get forcedAutoLevel(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}get nextAutoLevel(){const e=this.forcedAutoLevel,i=this.bwEstimator.canEstimate(),s=this.lastLoadedFragLevel>-1;if(e!==-1&&(!i||!s||this.nextAutoLevelKey===this.getAutoLevelKey()))return e;const r=i&&s?this.getNextABRAutoLevel():this.firstAutoLevel;if(e!==-1){const n=this.hls.levels;if(n.length>Math.max(e,r)&&n[e].loadError<=n[r].loadError)return e}return this._nextAutoLevel=r,this.nextAutoLevelKey=this.getAutoLevelKey(),r}getAutoLevelKey(){return`${this.getBwEstimate()}_${this.getStarvationDelay().toFixed(2)}`}getNextABRAutoLevel(){const{fragCurrent:e,partCurrent:t,hls:i}=this;if(i.levels.length<=1)return i.loadLevel;const{maxAutoLevel:s,config:r,minAutoLevel:n}=i,o=t?t.duration:e?e.duration:0,c=this.getBwEstimate(),u=this.getStarvationDelay();let h=r.abrBandWidthFactor,f=r.abrBandWidthUpFactor;if(u){const v=this.findBestLevel(c,n,s,u,0,h,f);if(v>=0)return this.rebufferNotice=-1,v}let g=o?Math.min(o,r.maxStarvationDelay):r.maxStarvationDelay;if(!u){const v=this.bitrateTestDelay;v&&(g=(o?Math.min(o,r.maxLoadingDelay):r.maxLoadingDelay)-v,this.info(`bitrate test took ${Math.round(1e3*v)}ms, set first fragment max fetchDuration to ${Math.round(1e3*g)} ms`),h=f=1)}const I=this.findBestLevel(c,n,s,u,g,h,f);if(this.rebufferNotice!==I&&(this.rebufferNotice=I,this.info(`${u?"rebuffering expected":"buffer is empty"}, optimal quality level ${I}`)),I>-1)return I;const m=i.levels[n],E=i.loadLevelObj;return E&&m?.bitrate<E.bitrate?n:i.loadLevel}getStarvationDelay(){const e=this.hls,t=e.media;if(!t)return 1/0;const i=t&&t.playbackRate!==0?Math.abs(t.playbackRate):1,s=e.mainForwardBufferInfo;return(s?s.len:0)/i}getBwEstimate(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}findBestLevel(e,t,i,s,r,n,o){var c;const u=s+r,h=this.lastLoadedFragLevel,f=h===-1?this.hls.firstLevel:h,{fragCurrent:g,partCurrent:I}=this,{levels:m,allAudioTracks:E,loadLevel:v,config:x}=this.hls;if(m.length===1)return 0;const D=m[f],L=!!((c=this.hls.latestLevelDetails)!=null&&c.live),w=v===-1||h===-1;let N,K="SDR",p=D?.frameRate||0;const{audioPreference:$,videoPreference:F}=x,O=this.audioTracksByGroup||(this.audioTracksByGroup=va(E));let W=-1;if(w){if(this.firstSelection!==-1)return this.firstSelection;const Q=this.codecTiers||(this.codecTiers=lc(m,O,t,i)),ne=oc(Q,K,e,$,F),{codecSet:re,videoRanges:le,minFramerate:pe,minBitrate:J,minIndex:ee,preferHDR:ve}=ne;W=ee,N=re,K=ve?le[le.length-1]:le[0],p=pe,e=Math.max(e,J),this.log(`picked start tier ${Ge(ne)}`)}else N=D?.codecSet,K=D?.videoRange;const ie=I?I.duration:g?g.duration:0,X=this.bwEstimator.getEstimateTTFB()/1e3,ce=[];for(let Q=i;Q>=t;Q--){var ue;const ne=m[Q],re=Q>f;if(!ne)continue;if(x.useMediaCapabilities&&!ne.supportedResult&&!ne.supportedPromise){const Te=navigator.mediaCapabilities;typeof Te?.decodingInfo=="function"&&Zu(ne,O,K,p,e,$)?(ne.supportedPromise=ma(ne,O,Te,this.supportedCache),ne.supportedPromise.then(Le=>{if(!this.hls)return;ne.supportedResult=Le;const it=this.hls.levels,Je=it.indexOf(ne);Le.error?this.warn(`MediaCapabilities decodingInfo error: "${Le.error}" for level ${Je} ${Ge(Le)}`):Le.supported?Le.decodingInfoResults.some(lt=>lt.smooth===!1||lt.powerEfficient===!1)&&this.log(`MediaCapabilities decodingInfo for level ${Je} not smooth or powerEfficient: ${Ge(Le)}`):(this.warn(`Unsupported MediaCapabilities decodingInfo result for level ${Je} ${Ge(Le)}`),Je>-1&&it.length>1&&(this.log(`Removing unsupported level ${Je}`),this.hls.removeLevel(Je),this.hls.loadLevel===-1&&(this.hls.nextLoadLevel=0)))}).catch(Le=>{this.warn(`Error handling MediaCapabilities decodingInfo: ${Le}`)})):ne.supportedResult=pa}if((N&&ne.codecSet!==N||K&&ne.videoRange!==K||re&&p>ne.frameRate||!re&&p>0&&p<ne.frameRate||(ue=ne.supportedResult)!=null&&(ue=ue.decodingInfoResults)!=null&&ue.some(Te=>Te.smooth===!1))&&(!w||Q!==W)){ce.push(Q);continue}const le=ne.details,pe=(I?le?.partTarget:le?.averagetargetduration)||ie;let J;re?J=o*e:J=n*e;const ee=ie&&s>=ie*2&&r===0?ne.averageBitrate:ne.maxBitrate,ve=this.getTimeToLoadFrag(X,J,ee*pe,le===void 0);if(J>=ee&&(Q===h||ne.loadError===0&&ne.fragmentError===0)&&(ve<=X||!se(ve)||L&&!this.bitrateTestDelay||ve<u)){const Te=this.forcedAutoLevel;return Q!==v&&(Te===-1||Te!==v)&&(ce.length&&this.trace(`Skipped level(s) ${ce.join(",")} of ${i} max with CODECS and VIDEO-RANGE:"${m[ce[0]].codecs}" ${m[ce[0]].videoRange}; not compatible with "${N}" ${K}`),this.info(`switch candidate:${f}->${Q} adjustedbw(${Math.round(J)})-bitrate=${Math.round(J-ee)} ttfb:${X.toFixed(1)} avgDuration:${pe.toFixed(1)} maxFetchDuration:${u.toFixed(1)} fetchDuration:${ve.toFixed(1)} firstSelection:${w} codecSet:${ne.codecSet} videoRange:${ne.videoRange} hls.loadLevel:${v}`)),w&&(this.firstSelection=Q),Q}}return-1}set nextAutoLevel(e){const t=this.deriveNextAutoLevel(e);this._nextAutoLevel!==t&&(this.nextAutoLevelKey="",this._nextAutoLevel=t)}deriveNextAutoLevel(e){const{maxAutoLevel:t,minAutoLevel:i}=this.hls;return Math.min(Math.max(e,i),t)}}const xa={search:function(a,e){let t=0,i=a.length-1,s=null,r=null;for(;t<=i;){s=(t+i)/2|0,r=a[s];const n=e(r);if(n>0)t=s+1;else if(n<0)i=s-1;else return r}return null}};function fc(a,e,t){if(e===null||!Array.isArray(a)||!a.length||!se(e))return null;const i=a[0].programDateTime;if(e<(i||0))return null;const s=a[a.length-1].endProgramDateTime;if(e>=(s||0))return null;for(let r=0;r<a.length;++r){const n=a[r];if(pc(e,t,n))return n}return null}function yi(a,e,t=0,i=0,s=.005){let r=null;if(a){r=e[1+a.sn-e[0].sn]||null;const o=a.endDTS-t;o>0&&o<15e-7&&(t+=15e-7),r&&a.level!==r.level&&r.end<=a.end&&(r=e[2+a.sn-e[0].sn]||null)}else t===0&&e[0].start===0&&(r=e[0]);if(r&&((!a||a.level===r.level)&&ba(t,i,r)===0||gc(r,a,Math.min(s,i))))return r;const n=xa.search(e,ba.bind(null,t,i));return n&&(n!==a||!r)?n:r}function gc(a,e,t){if(e&&e.start===0&&e.level<a.level&&(e.endPTS||0)>0){const i=e.tagList.reduce((s,r)=>(r[0]==="INF"&&(s+=parseFloat(r[1])),s),t);return a.start<=i}return!1}function ba(a=0,e=0,t){if(t.start<=a&&t.start+t.duration>a)return 0;const i=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0));return t.start+t.duration-i<=a?1:t.start-i>a&&t.start?-1:0}function pc(a,e,t){const i=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0))*1e3;return(t.endProgramDateTime||0)-i>a}function La(a,e,t){if(a&&a.startCC<=e&&a.endCC>=e){let i=a.fragments;const{fragmentHint:s}=a;s&&(i=i.concat(s));let r;return xa.search(i,n=>n.cc<e?1:n.cc>e?-1:(r=n,n.end<=t?1:n.start>t?-1:0)),r||null}return null}function bs(a){switch(a.details){case U.FRAG_LOAD_TIMEOUT:case U.KEY_LOAD_TIMEOUT:case U.LEVEL_LOAD_TIMEOUT:case U.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function Ra(a,e){const t=bs(e);return a.default[`${t?"timeout":"error"}Retry`]}function br(a,e){const t=a.backoff==="linear"?1:Math.pow(2,e);return Math.min(t*a.retryDelayMs,a.maxRetryDelayMs)}function Da(a){return Be(Be({},a),{errorRetry:null,timeoutRetry:null})}function Ls(a,e,t,i){if(!a)return!1;const s=i?.code,r=e<a.maxNumRetry&&(Ac(s)||!!t);return a.shouldRetry?a.shouldRetry(a,e,t,i,r):r}function Ac(a){return Lr(a)||!!a&&(a<400||a>499)}function Lr(a){return a===0&&navigator.onLine===!1}var rt={DoNothing:0,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,RetryRequest:5},Ct={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,MoveAllAlternatesMatchingKey:4};class mc extends Tt{constructor(e){super("error-controller",e.logger),this.hls=void 0,this.playlistError=0,this.hls=e,this.registerListeners()}registerListeners(){const e=this.hls;e.on(y.ERROR,this.onError,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const e=this.hls;e&&(e.off(y.ERROR,this.onError,this),e.off(y.ERROR,this.onErrorOut,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null}startLoad(e){}stopLoad(){this.playlistError=0}getVariantLevelIndex(e){return e?.type===he.MAIN?e.level:this.getVariantIndex()}getVariantIndex(){var e;const t=this.hls,i=t.currentLevel;return(e=t.loadLevelObj)!=null&&e.details||i===-1?t.loadLevel:i}variantHasKey(e,t){if(e){var i;if((i=e.details)!=null&&i.hasKey(t))return!0;const s=e.audioGroups;if(s)return this.hls.allAudioTracks.filter(n=>s.indexOf(n.groupId)>=0).some(n=>{var o;return(o=n.details)==null?void 0:o.hasKey(t)})}return!1}onManifestLoading(){this.playlistError=0}onLevelUpdated(){this.playlistError=0}onError(e,t){var i;if(t.fatal)return;const s=this.hls,r=t.context;switch(t.details){case U.FRAG_LOAD_ERROR:case U.FRAG_LOAD_TIMEOUT:case U.KEY_LOAD_ERROR:case U.KEY_LOAD_TIMEOUT:t.errorAction=this.getFragRetryOrSwitchAction(t);return;case U.FRAG_PARSING_ERROR:if((i=t.frag)!=null&&i.gap){t.errorAction=_i();return}case U.FRAG_GAP:case U.FRAG_DECRYPT_ERROR:{t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=rt.SendAlternateToPenaltyBox;return}case U.LEVEL_EMPTY_ERROR:case U.LEVEL_PARSING_ERROR:{var n;const c=t.parent===he.MAIN?t.level:s.loadLevel;t.details===U.LEVEL_EMPTY_ERROR&&((n=t.context)!=null&&(n=n.levelDetails)!=null&&n.live)?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,c):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,c))}return;case U.LEVEL_LOAD_ERROR:case U.LEVEL_LOAD_TIMEOUT:typeof r?.level=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,r.level));return;case U.AUDIO_TRACK_LOAD_ERROR:case U.AUDIO_TRACK_LOAD_TIMEOUT:case U.SUBTITLE_LOAD_ERROR:case U.SUBTITLE_TRACK_LOAD_TIMEOUT:if(r){const c=s.loadLevelObj;if(c&&(r.type===be.AUDIO_TRACK&&c.hasAudioGroup(r.groupId)||r.type===be.SUBTITLE_TRACK&&c.hasSubtitleGroup(r.groupId))){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,s.loadLevel),t.errorAction.action=rt.SendAlternateToPenaltyBox,t.errorAction.flags=Ct.MoveAllAlternatesMatchingHost;return}}return;case U.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:t.errorAction={action:rt.SendAlternateToPenaltyBox,flags:Ct.MoveAllAlternatesMatchingHDCP};return;case U.KEY_SYSTEM_SESSION_UPDATE_FAILED:case U.KEY_SYSTEM_STATUS_INTERNAL_ERROR:case U.KEY_SYSTEM_NO_SESSION:t.errorAction={action:rt.SendAlternateToPenaltyBox,flags:Ct.MoveAllAlternatesMatchingKey};return;case U.BUFFER_ADD_CODEC_ERROR:case U.REMUX_ALLOC_ERROR:case U.BUFFER_APPEND_ERROR:if(!t.errorAction){var o;t.errorAction=this.getLevelSwitchAction(t,(o=t.level)!=null?o:s.loadLevel)}return;case U.INTERNAL_EXCEPTION:case U.BUFFER_APPENDING_ERROR:case U.BUFFER_FULL_ERROR:case U.LEVEL_SWITCH_ERROR:case U.BUFFER_STALLED_ERROR:case U.BUFFER_SEEK_OVER_HOLE:case U.BUFFER_NUDGE_ON_STALL:t.errorAction=_i();return}t.type===de.KEY_SYSTEM_ERROR&&(t.levelRetry=!1,t.errorAction=_i())}getPlaylistRetryOrSwitchAction(e,t){const i=this.hls,s=Ra(i.config.playlistLoadPolicy,e),r=this.playlistError++;if(Ls(s,r,bs(e),e.response))return{action:rt.RetryRequest,flags:Ct.None,retryConfig:s,retryCount:r};const o=this.getLevelSwitchAction(e,t);return s&&(o.retryConfig=s,o.retryCount=r),o}getFragRetryOrSwitchAction(e){const t=this.hls,i=this.getVariantLevelIndex(e.frag),s=t.levels[i],{fragLoadPolicy:r,keyLoadPolicy:n}=t.config,o=Ra(e.details.startsWith("key")?n:r,e),c=t.levels.reduce((h,f)=>h+f.fragmentError,0);if(s&&(e.details!==U.FRAG_GAP&&s.fragmentError++,Ls(o,c,bs(e),e.response)))return{action:rt.RetryRequest,flags:Ct.None,retryConfig:o,retryCount:c};const u=this.getLevelSwitchAction(e,i);return o&&(u.retryConfig=o,u.retryCount=c),u}getLevelSwitchAction(e,t){const i=this.hls;t==null&&(t=i.loadLevel);const s=this.hls.levels[t];if(s){var r,n;const u=e.details;s.loadError++,u===U.BUFFER_APPEND_ERROR&&s.fragmentError++;let h=-1;const{levels:f,loadLevel:g,minAutoLevel:I,maxAutoLevel:m}=i;!i.autoLevelEnabled&&!i.config.preserveManualLevelOnError&&(i.loadLevel=-1);const E=(r=e.frag)==null?void 0:r.type,x=(E===he.AUDIO&&u===U.FRAG_PARSING_ERROR||e.sourceBufferName==="audio"&&(u===U.BUFFER_ADD_CODEC_ERROR||u===U.BUFFER_APPEND_ERROR))&&f.some(({audioCodec:K})=>s.audioCodec!==K),L=e.sourceBufferName==="video"&&(u===U.BUFFER_ADD_CODEC_ERROR||u===U.BUFFER_APPEND_ERROR)&&f.some(({codecSet:K,audioCodec:p})=>s.codecSet!==K&&s.audioCodec===p),{type:w,groupId:N}=(n=e.context)!=null?n:{};for(let K=f.length;K--;){const p=(K+g)%f.length;if(p!==g&&p>=I&&p<=m&&f[p].loadError===0){var o,c;const $=f[p];if(u===U.FRAG_GAP&&E===he.MAIN&&e.frag){const F=f[p].details;if(F){const O=yi(e.frag,F.fragments,e.frag.start);if(O!=null&&O.gap)continue}}else{if(w===be.AUDIO_TRACK&&$.hasAudioGroup(N)||w===be.SUBTITLE_TRACK&&$.hasSubtitleGroup(N))continue;if(E===he.AUDIO&&(o=s.audioGroups)!=null&&o.some(F=>$.hasAudioGroup(F))||E===he.SUBTITLE&&(c=s.subtitleGroups)!=null&&c.some(F=>$.hasSubtitleGroup(F))||x&&s.audioCodec===$.audioCodec||L&&s.codecSet===$.codecSet||!x&&s.codecSet!==$.codecSet)continue}h=p;break}}if(h>-1&&i.loadLevel!==h)return e.levelRetry=!0,this.playlistError=0,{action:rt.SendAlternateToPenaltyBox,flags:Ct.None,nextAutoLevel:h}}return{action:rt.SendAlternateToPenaltyBox,flags:Ct.MoveAllAlternatesMatchingHost}}onErrorOut(e,t){var i;switch((i=t.errorAction)==null?void 0:i.action){case rt.DoNothing:break;case rt.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t),!t.errorAction.resolved&&t.details!==U.FRAG_GAP?t.fatal=!0:/MediaSource readyState: ended/.test(t.error.message)&&(this.warn(`MediaSource ended after "${t.sourceBufferName}" sourceBuffer append error. Attempting to recover from media error.`),this.hls.recoverMediaError());break}if(t.fatal){this.hls.stopLoad();return}}sendAlternateToPenaltyBox(e){const t=this.hls,i=e.errorAction;if(!i)return;const{flags:s}=i,r=i.nextAutoLevel;switch(s){case Ct.None:this.switchLevel(e,r);break;case Ct.MoveAllAlternatesMatchingHDCP:{const c=this.getVariantLevelIndex(e.frag),u=t.levels[c],h=u?.attrs["HDCP-LEVEL"];if(i.hdcpLevel=h,h){t.maxHdcpLevel=xr[xr.indexOf(h)-1],i.resolved=!0,this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}}case Ct.MoveAllAlternatesMatchingKey:{const c=e.decryptdata;if(c){const u=this.hls.levels;for(let h=u.length;h--;)if(this.variantHasKey(u[h],c)){var n,o;this.log(`Banned key found in level ${h} (${u[h].bitrate}bps) or audio group "${(n=u[h].audioGroups)==null?void 0:n.join(",")}" (${(o=e.frag)==null?void 0:o.type} fragment) ${It(c.keyId||[])}`),u[h].fragmentError++,u[h].loadError++,this.log(`Removing level ${h} with key error (${e.error})`),this.hls.removeLevel(h)}u.length&&(i.resolved=!0)}break}}i.resolved||this.switchLevel(e,r)}switchLevel(e,t){if(t!==void 0&&e.errorAction&&(this.warn(`switching to level ${t} after ${e.details}`),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel,e.details===U.BUFFER_ADD_CODEC_ERROR&&e.mimeType&&e.sourceBufferName!=="audiovideo")){const i=Sr(e.mimeType),s=this.hls.levels;for(let r=s.length;r--;)s[r][`${e.sourceBufferName}Codec`]===i&&(this.log(`Removing level ${r} for ${e.details} ("${i}" not supported)`),this.hls.removeLevel(r))}}}function _i(a){const e={action:rt.DoNothing,flags:Ct.None};return a&&(e.resolved=!0),e}var Qe={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};class Ic{constructor(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}_registerListeners(){const{hls:e}=this;e&&(e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.BUFFER_APPENDED,this.onBufferAppended,this),e.on(y.FRAG_BUFFERED,this.onFragBuffered,this),e.on(y.FRAG_LOADED,this.onFragLoaded,this))}_unregisterListeners(){const{hls:e}=this;e&&(e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.BUFFER_APPENDED,this.onBufferAppended,this),e.off(y.FRAG_BUFFERED,this.onFragBuffered,this),e.off(y.FRAG_LOADED,this.onFragLoaded,this))}destroy(){this._unregisterListeners(),this.hls=this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){const i=this.activePartLists[t];if(i)for(let s=i.length;s--;){const r=i[s];if(!r)break;if(r.start<=e&&e<=r.end&&r.loaded)return r}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){return this.getFragAtPos(e,t,!0)}getFragAtPos(e,t,i){const{fragments:s}=this,r=Object.keys(s);for(let n=r.length;n--;){const o=s[r[n]];if(o?.body.type===t&&(!i||o.buffered)){const c=o.body;if(c.start<=e&&e<=c.end)return c}}return null}detectEvictedFragments(e,t,i,s,r){this.timeRanges&&(this.timeRanges[e]=t);const n=s?.fragment.sn||-1;Object.keys(this.fragments).forEach(o=>{const c=this.fragments[o];if(!c||n>=c.body.sn)return;if(!c.buffered&&(!c.loaded||r)){c.body.type===i&&this.removeFragment(c.body);return}const u=c.range[e];if(u){if(u.time.length===0){this.removeFragment(c.body);return}u.time.some(h=>{const f=!this.isTimeBuffered(h.startPTS,h.endPTS,t);return f&&this.removeFragment(c.body),f})}})}detectPartialFragments(e){const t=this.timeRanges;if(!t||e.frag.sn==="initSegment")return;const i=e.frag,s=wi(i),r=this.fragments[s];if(!r||r.buffered&&i.gap)return;const n=!i.relurl;Object.keys(t).forEach(o=>{const c=i.elementaryStreams[o];if(!c)return;const u=t[o],h=n||c.partial===!0;r.range[o]=this.getBufferedTimes(i,e.part,h,u)}),r.loaded=null,Object.keys(r.range).length?(r.buffered=!0,(r.body.endList=i.endList||r.body.endList)&&(this.endListFragments[r.body.type]=r),Rs(r)||this.removeParts(i.sn-1,i.type)):this.removeFragment(r.body)}removeParts(e,t){const i=this.activePartLists[t];i&&(this.activePartLists[t]=Pa(i,s=>s.fragment.sn>=e))}fragBuffered(e,t){const i=wi(e);let s=this.fragments[i];!s&&t&&(s=this.fragments[i]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),s&&(s.loaded=null,s.buffered=!0)}getBufferedTimes(e,t,i,s){const r={time:[],partial:i},n=e.start,o=e.end,c=e.minEndPTS||o,u=e.maxStartPTS||n;for(let h=0;h<s.length;h++){const f=s.start(h)-this.bufferPadding,g=s.end(h)+this.bufferPadding;if(u>=f&&c<=g){r.time.push({startPTS:Math.max(n,s.start(h)),endPTS:Math.min(o,s.end(h))});break}else if(n<g&&o>f){const I=Math.max(n,s.start(h)),m=Math.min(o,s.end(h));m>I&&(r.partial=!0,r.time.push({startPTS:I,endPTS:m}))}else if(o<=f)break}return r}getPartialFragment(e){let t=null,i,s,r,n=0;const{bufferPadding:o,fragments:c}=this;return Object.keys(c).forEach(u=>{const h=c[u];h&&Rs(h)&&(s=h.body.start-o,r=h.body.end+o,e>=s&&e<=r&&(i=Math.min(e-s,r-e),n<=i&&(t=h.body,n=i)))}),t}isEndListAppended(e){const t=this.endListFragments[e];return t!==void 0&&(t.buffered||Rs(t))}getState(e){const t=wi(e),i=this.fragments[t];return i?i.buffered?Rs(i)?Qe.PARTIAL:Qe.OK:Qe.APPENDING:Qe.NOT_LOADED}isTimeBuffered(e,t,i){let s,r;for(let n=0;n<i.length;n++){if(s=i.start(n)-this.bufferPadding,r=i.end(n)+this.bufferPadding,e>=s&&t<=r)return!0;if(t<=s)return!1}return!1}onManifestLoading(){this.removeAllFragments()}onFragLoaded(e,t){if(t.frag.sn==="initSegment"||t.frag.bitrateTest)return;const i=t.frag,s=t.part?null:t,r=wi(i);this.fragments[r]={body:i,appendedPTS:null,loaded:s,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){const{frag:i,part:s,timeRanges:r,type:n}=t;if(i.sn==="initSegment")return;const o=i.type;if(s){let u=this.activePartLists[o];u||(this.activePartLists[o]=u=[]),u.push(s)}this.timeRanges=r;const c=r[n];this.detectEvictedFragments(n,c,o,s)}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){const t=wi(e);return!!this.fragments[t]}hasFragments(e){const{fragments:t}=this,i=Object.keys(t);if(!e)return i.length>0;for(let s=i.length;s--;){const r=t[i[s]];if(r?.body.type===e)return!0}return!1}hasParts(e){var t;return!!((t=this.activePartLists[e])!=null&&t.length)}removeFragmentsInRange(e,t,i,s,r){s&&!this.hasGaps||Object.keys(this.fragments).forEach(n=>{const o=this.fragments[n];if(!o)return;const c=o.body;c.type!==i||s&&!c.gap||c.start<t&&c.end>e&&(o.buffered||r)&&this.removeFragment(c)})}removeFragment(e){const t=wi(e);e.clearElementaryStreamInfo();const i=this.activePartLists[e.type];if(i){const s=e.sn;this.activePartLists[e.type]=Pa(i,r=>r.fragment.sn!==s)}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){var e;this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1;const t=(e=this.hls)==null||(e=e.latestLevelDetails)==null?void 0:e.partList;t&&t.forEach(i=>i.clearElementaryStreamInfo())}}function Rs(a){var e,t,i;return a.buffered&&!!(a.body.gap||(e=a.range.video)!=null&&e.partial||(t=a.range.audio)!=null&&t.partial||(i=a.range.audiovideo)!=null&&i.partial)}function wi(a){return`${a.type}_${a.level}_${a.sn}`}function Pa(a,e){return a.filter(t=>{const i=e(t);return i||t.clearElementaryStreamInfo(),i})}var ni={cbc:0,ctr:1};class Cc{constructor(e,t,i){this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=e,this.aesIV=t,this.aesMode=i}decrypt(e,t){switch(this.aesMode){case ni.cbc:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e);case ni.ctr:return this.subtle.decrypt({name:"AES-CTR",counter:this.aesIV,length:64},t,e);default:throw new Error(`[AESCrypto] invalid aes mode ${this.aesMode}`)}}}function yc(a){const e=a.byteLength,t=e&&new DataView(a.buffer).getUint8(e-1);return t?a.slice(0,e-t):a}class Ec{constructor(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}uint8ArrayToUint32Array_(e){const t=new DataView(e),i=new Uint32Array(4);for(let s=0;s<4;s++)i[s]=t.getUint32(s*4);return i}initTable(){const e=this.sBox,t=this.invSBox,i=this.subMix,s=i[0],r=i[1],n=i[2],o=i[3],c=this.invSubMix,u=c[0],h=c[1],f=c[2],g=c[3],I=new Uint32Array(256);let m=0,E=0,v=0;for(v=0;v<256;v++)v<128?I[v]=v<<1:I[v]=v<<1^283;for(v=0;v<256;v++){let x=E^E<<1^E<<2^E<<3^E<<4;x=x>>>8^x&255^99,e[m]=x,t[x]=m;const D=I[m],L=I[D],w=I[L];let N=I[x]*257^x*16843008;s[m]=N<<24|N>>>8,r[m]=N<<16|N>>>16,n[m]=N<<8|N>>>24,o[m]=N,N=w*16843009^L*65537^D*257^m*16843008,u[x]=N<<24|N>>>8,h[x]=N<<16|N>>>16,f[x]=N<<8|N>>>24,g[x]=N,m?(m=D^I[I[I[w^D]]],E^=I[I[E]]):m=E=1}}expandKey(e){const t=this.uint8ArrayToUint32Array_(e);let i=!0,s=0;for(;s<t.length&&i;)i=t[s]===this.key[s],s++;if(i)return;this.key=t;const r=this.keySize=t.length;if(r!==4&&r!==6&&r!==8)throw new Error("Invalid aes key size="+r);const n=this.ksRows=(r+6+1)*4;let o,c;const u=this.keySchedule=new Uint32Array(n),h=this.invKeySchedule=new Uint32Array(n),f=this.sBox,g=this.rcon,I=this.invSubMix,m=I[0],E=I[1],v=I[2],x=I[3];let D,L;for(o=0;o<n;o++){if(o<r){D=u[o]=t[o];continue}L=D,o%r===0?(L=L<<8|L>>>24,L=f[L>>>24]<<24|f[L>>>16&255]<<16|f[L>>>8&255]<<8|f[L&255],L^=g[o/r|0]<<24):r>6&&o%r===4&&(L=f[L>>>24]<<24|f[L>>>16&255]<<16|f[L>>>8&255]<<8|f[L&255]),u[o]=D=(u[o-r]^L)>>>0}for(c=0;c<n;c++)o=n-c,c&3?L=u[o]:L=u[o-4],c<4||o<=4?h[c]=L:h[c]=m[f[L>>>24]]^E[f[L>>>16&255]]^v[f[L>>>8&255]]^x[f[L&255]],h[c]=h[c]>>>0}networkToHostOrderSwap(e){return e<<24|(e&65280)<<8|(e&16711680)>>8|e>>>24}decrypt(e,t,i){const s=this.keySize+6,r=this.invKeySchedule,n=this.invSBox,o=this.invSubMix,c=o[0],u=o[1],h=o[2],f=o[3],g=this.uint8ArrayToUint32Array_(i);let I=g[0],m=g[1],E=g[2],v=g[3];const x=new Int32Array(e),D=new Int32Array(x.length);let L,w,N,K,p,$,F,O,W,ie,X,ce,ue,Q;const ne=this.networkToHostOrderSwap;for(;t<x.length;){for(W=ne(x[t]),ie=ne(x[t+1]),X=ne(x[t+2]),ce=ne(x[t+3]),p=W^r[0],$=ce^r[1],F=X^r[2],O=ie^r[3],ue=4,Q=1;Q<s;Q++)L=c[p>>>24]^u[$>>16&255]^h[F>>8&255]^f[O&255]^r[ue],w=c[$>>>24]^u[F>>16&255]^h[O>>8&255]^f[p&255]^r[ue+1],N=c[F>>>24]^u[O>>16&255]^h[p>>8&255]^f[$&255]^r[ue+2],K=c[O>>>24]^u[p>>16&255]^h[$>>8&255]^f[F&255]^r[ue+3],p=L,$=w,F=N,O=K,ue=ue+4;L=n[p>>>24]<<24^n[$>>16&255]<<16^n[F>>8&255]<<8^n[O&255]^r[ue],w=n[$>>>24]<<24^n[F>>16&255]<<16^n[O>>8&255]<<8^n[p&255]^r[ue+1],N=n[F>>>24]<<24^n[O>>16&255]<<16^n[p>>8&255]<<8^n[$&255]^r[ue+2],K=n[O>>>24]<<24^n[p>>16&255]<<16^n[$>>8&255]<<8^n[F&255]^r[ue+3],D[t]=ne(L^I),D[t+1]=ne(K^m),D[t+2]=ne(N^E),D[t+3]=ne(w^v),I=W,m=ie,E=X,v=ce,t=t+4}return D.buffer}}class vc{constructor(e,t,i){this.subtle=void 0,this.key=void 0,this.aesMode=void 0,this.subtle=e,this.key=t,this.aesMode=i}expandKey(){const e=Tc(this.aesMode);return this.subtle.importKey("raw",this.key,{name:e},!1,["encrypt","decrypt"])}}function Tc(a){switch(a){case ni.cbc:return"AES-CBC";case ni.ctr:return"AES-CTR";default:throw new Error(`[FastAESKey] invalid aes mode ${a}`)}}const Sc=16;class Rr{constructor(e,{removePKCS7Padding:t=!0}={}){if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.enableSoftwareAES=void 0,this.enableSoftwareAES=e.enableSoftwareAES,this.removePKCS7Padding=t,t)try{const i=self.crypto;i&&(this.subtle=i.subtle||i.webkitSubtle)}catch{}this.useSoftware=!this.subtle}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}isSync(){return this.useSoftware}flush(){const{currentResult:e,remainderData:t}=this;if(!e||t)return this.reset(),null;const i=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?yc(i):i}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,t,i,s){return this.useSoftware?new Promise((r,n)=>{const o=ArrayBuffer.isView(e)?e:new Uint8Array(e);this.softwareDecrypt(o,t,i,s);const c=this.flush();c?r(c.buffer):n(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,i,s)}softwareDecrypt(e,t,i,s){const{currentIV:r,currentResult:n,remainderData:o}=this;if(s!==ni.cbc||t.byteLength!==16)return Oe.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),o&&(e=St(o,e),this.remainderData=null);const c=this.getValidChunk(e);if(!c.length)return null;r&&(i=r);let u=this.softwareDecrypter;u||(u=this.softwareDecrypter=new Ec),u.expandKey(t);const h=n;return this.currentResult=u.decrypt(c.buffer,0,i),this.currentIV=c.slice(-16).buffer,h||null}webCryptoDecrypt(e,t,i,s){if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,i,s));this.key=t,this.fastAesKey=new vc(this.subtle,t,s)}return this.fastAesKey.expandKey().then(r=>this.subtle?(this.logOnce("WebCrypto AES decrypt"),new Cc(this.subtle,new Uint8Array(i),s).decrypt(e.buffer,r)):Promise.reject(new Error("web crypto not initialized"))).catch(r=>(Oe.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${r.name}: ${r.message}`),this.onWebCryptoError(e,t,i,s)))}onWebCryptoError(e,t,i,s){const r=this.enableSoftwareAES;if(r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,i,s);const n=this.flush();if(n)return n.buffer}throw new Error("WebCrypto"+(r?" and softwareDecrypt":"")+": failed to decrypt data")}getValidChunk(e){let t=e;const i=e.length-e.length%Sc;return i!==e.length&&(t=e.slice(0,i),this.remainderData=e.slice(i)),t}logOnce(e){this.logEnabled&&(Oe.log(`[decrypter]: ${e}`),this.logEnabled=!1)}}const _a=Math.pow(2,17);class xc{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 i=e.url;if(!i)return Promise.reject(new zt({type:de.NETWORK_ERROR,details:U.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error(`Fragment does not have a ${i?"part list":"url"}`),networkDetails:null}));this.abort();const s=this.config,r=s.fLoader,n=s.loader;return new Promise((o,c)=>{if(this.loader&&this.loader.destroy(),e.gap)if(e.tagList.some(m=>m[0]==="GAP")){c(ka(e));return}else e.gap=!1;const u=this.loader=r?new r(s):new n(s),h=wa(e);e.loader=u;const f=Da(s.fragLoadPolicy.default),g={loadPolicy:f,timeout:f.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:_a};e.stats=u.stats;const I={onSuccess:(m,E,v,x)=>{this.resetLoader(e,u);let D=m.data;v.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(D.slice(0,16)),D=D.slice(16)),o({frag:e,part:null,payload:D,networkDetails:x})},onError:(m,E,v,x)=>{this.resetLoader(e,u),c(new zt({type:de.NETWORK_ERROR,details:U.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:Be({url:i,data:void 0},m),error:new Error(`HTTP Error ${m.code} ${m.text}`),networkDetails:v,stats:x}))},onAbort:(m,E,v)=>{this.resetLoader(e,u),c(new zt({type:de.NETWORK_ERROR,details:U.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:v,stats:m}))},onTimeout:(m,E,v)=>{this.resetLoader(e,u),c(new zt({type:de.NETWORK_ERROR,details:U.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${g.timeout}ms`),networkDetails:v,stats:m}))}};t&&(I.onProgress=(m,E,v,x)=>t({frag:e,part:null,payload:v,networkDetails:x})),u.load(h,g,I)})}loadPart(e,t,i){this.abort();const s=this.config,r=s.fLoader,n=s.loader;return new Promise((o,c)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap){c(ka(e,t));return}const u=this.loader=r?new r(s):new n(s),h=wa(e,t);e.loader=u;const f=Da(s.fragLoadPolicy.default),g={loadPolicy:f,timeout:f.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:_a};t.stats=u.stats,u.load(h,g,{onSuccess:(I,m,E,v)=>{this.resetLoader(e,u),this.updateStatsFromPart(e,t);const x={frag:e,part:t,payload:I.data,networkDetails:v};i(x),o(x)},onError:(I,m,E,v)=>{this.resetLoader(e,u),c(new zt({type:de.NETWORK_ERROR,details:U.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:Be({url:h.url,data:void 0},I),error:new Error(`HTTP Error ${I.code} ${I.text}`),networkDetails:E,stats:v}))},onAbort:(I,m,E)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,u),c(new zt({type:de.NETWORK_ERROR,details:U.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:E,stats:I}))},onTimeout:(I,m,E)=>{this.resetLoader(e,u),c(new zt({type:de.NETWORK_ERROR,details:U.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${g.timeout}ms`),networkDetails:E,stats:I}))}})})}updateStatsFromPart(e,t){const i=e.stats,s=t.stats,r=s.total;if(i.loaded+=s.loaded,r){const c=Math.round(e.duration/t.duration),u=Math.min(Math.round(i.loaded/r),c),f=(c-u)*Math.round(i.loaded/u);i.total=i.loaded+f}else i.total=Math.max(i.loaded,i.total);const n=i.loading,o=s.loading;n.start?n.first+=o.first-o.start:(n.start=o.start,n.first=o.first),n.end=o.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}function wa(a,e=null){const t=e||a,i={frag:a,part:e,responseType:"arraybuffer",url:t.url,headers:{},rangeStart:0,rangeEnd:0},s=t.byteRangeStartOffset,r=t.byteRangeEndOffset;if(se(s)&&se(r)){var n;let o=s,c=r;if(a.sn==="initSegment"&&bc((n=a.decryptdata)==null?void 0:n.method)){const u=r-s;u%16&&(c=r+(16-u%16)),s!==0&&(i.resetIV=!0,o=s-16)}i.rangeStart=o,i.rangeEnd=c}return i}function ka(a,e){const t=new Error(`GAP ${a.gap?"tag":"attribute"} found`),i={type:de.MEDIA_ERROR,details:U.FRAG_GAP,fatal:!1,frag:a,error:t,networkDetails:null};return e&&(i.part=e),(e||a).stats.aborted=!0,new zt(i)}function bc(a){return a==="AES-128"||a==="AES-256"}class zt extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}}class Ma extends Tt{constructor(e,t){super(e,t),this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(e){return this._tickInterval?!1:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)}clearInterval(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1}clearNextTick(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1}tick(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}class Dr{constructor(e,t,i,s=0,r=-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=Ds(),this.buffering={audio:Ds(),video:Ds(),audiovideo:Ds()},this.level=e,this.sn=t,this.id=i,this.size=s,this.part=r,this.partial=n}}function Ds(){return{start:0,executeStart:0,executeEnd:0,end:0}}const Oa={length:0,start:()=>0,end:()=>0};class ye{static isBuffered(e,t){if(e){const i=ye.getBuffered(e);for(let s=i.length;s--;)if(t>=i.start(s)&&t<=i.end(s))return!0}return!1}static bufferedRanges(e){if(e){const t=ye.getBuffered(e);return ye.timeRangesToArray(t)}return[]}static timeRangesToArray(e){const t=[];for(let i=0;i<e.length;i++)t.push({start:e.start(i),end:e.end(i)});return t}static bufferInfo(e,t,i){if(e){const s=ye.bufferedRanges(e);if(s.length)return ye.bufferedInfo(s,t,i)}return{len:0,start:t,end:t,bufferedIndex:-1}}static bufferedInfo(e,t,i){t=Math.max(0,t),e.length>1&&e.sort((h,f)=>h.start-f.start||f.end-h.end);let s=-1,r=[];if(i)for(let h=0;h<e.length;h++){t>=e[h].start&&t<=e[h].end&&(s=h);const f=r.length;if(f){const g=r[f-1].end;e[h].start-g<i?e[h].end>g&&(r[f-1].end=e[h].end):r.push(e[h])}else r.push(e[h])}else r=e;let n=0,o,c=t,u=t;for(let h=0;h<r.length;h++){const f=r[h].start,g=r[h].end;if(s===-1&&t>=f&&t<=g&&(s=h),t+i>=f&&t<g)c=f,u=g,n=u-t;else if(t+i<f){o=f;break}}return{len:n,start:c||0,end:u||0,nextStart:o,buffered:e,bufferedIndex:s}}static getBuffered(e){try{return e.buffered||Oa}catch(t){return Oe.log("failed to get media.buffered",t),Oa}}}const Fa=/\{\$([a-zA-Z0-9-_]+)\}/g;function Na(a){return Fa.test(a)}function Pr(a,e){if(a.variableList!==null||a.hasVariableRefs){const t=a.variableList;return e.replace(Fa,i=>{const s=i.substring(2,i.length-1),r=t?.[s];return r===void 0?(a.playlistParsingError||(a.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${s}"`)),i):r})}return e}function Ba(a,e,t){let i=a.variableList;i||(a.variableList=i={});let s,r;if("QUERYPARAM"in e){s=e.QUERYPARAM;try{const n=new self.URL(t).searchParams;if(n.has(s))r=n.get(s);else throw new Error(`"${s}" does not match any query parameter in URI: "${t}"`)}catch(n){a.playlistParsingError||(a.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${n.message}`))}}else s=e.NAME,r=e.VALUE;s in i?a.playlistParsingError||(a.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${s}"`)):i[s]=r||""}function Lc(a,e,t){const i=e.IMPORT;if(t&&i in t){let s=a.variableList;s||(a.variableList=s={}),s[i]=t[i]}else a.playlistParsingError||(a.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${i}"`))}const Rc=/^(\d+)x(\d+)$/,Ua=/(.+?)=(".*?"|.*?)(?:,|$)/g;class He{constructor(e,t){typeof e=="string"&&(e=He.parseAttrList(e,t)),Ne(this,e)}get clientAttrs(){return Object.keys(this).filter(e=>e.substring(0,2)==="X-")}decimalInteger(e){const t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}hexadecimalInteger(e){if(this[e]){let t=(this[e]||"0x").slice(2);t=(t.length&1?"0":"")+t;const i=new Uint8Array(t.length/2);for(let s=0;s<t.length/2;s++)i[s]=parseInt(t.slice(s*2,s*2+2),16);return i}return null}hexadecimalIntegerAsNumber(e){const t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,t){const i=this[e];return i?parseFloat(i):t}enumeratedString(e){return this[e]}enumeratedStringList(e,t){const i=this[e];return(i?i.split(/[ ,]+/):[]).reduce((s,r)=>(s[r.toLowerCase()]=!0,s),t)}bool(e){return this[e]==="YES"}decimalResolution(e){const t=Rc.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e,t){let i;const s={};for(Ua.lastIndex=0;(i=Ua.exec(e))!==null;){const n=i[1].trim();let o=i[2];const c=o.indexOf('"')===0&&o.lastIndexOf('"')===o.length-1;let u=!1;if(c)o=o.slice(1,-1);else switch(n){case"IV":case"SCTE35-CMD":case"SCTE35-IN":case"SCTE35-OUT":u=!0}if(t&&(c||u))o=Pr(t,o);else if(!u&&!c)switch(n){case"CLOSED-CAPTIONS":if(o==="NONE")break;case"ALLOWED-CPC":case"CLASS":case"ASSOC-LANGUAGE":case"AUDIO":case"BYTERANGE":case"CHANNELS":case"CHARACTERISTICS":case"CODECS":case"DATA-ID":case"END-DATE":case"GROUP-ID":case"ID":case"IMPORT":case"INSTREAM-ID":case"KEYFORMAT":case"KEYFORMATVERSIONS":case"LANGUAGE":case"NAME":case"PATHWAY-ID":case"QUERYPARAM":case"RECENTLY-REMOVED-DATERANGES":case"SERVER-URI":case"STABLE-RENDITION-ID":case"STABLE-VARIANT-ID":case"START-DATE":case"SUBTITLES":case"SUPPLEMENTAL-CODECS":case"URI":case"VALUE":case"VIDEO":case"X-ASSET-LIST":case"X-ASSET-URI":Oe.warn(`${e}: attribute ${n} is missing quotes`)}s[n]=o}return s}}const Dc="com.apple.hls.interstitial";function Pc(a){return a!=="ID"&&a!=="CLASS"&&a!=="CUE"&&a!=="START-DATE"&&a!=="DURATION"&&a!=="END-DATE"&&a!=="END-ON-NEXT"}function _c(a){return a==="SCTE35-OUT"||a==="SCTE35-IN"||a==="SCTE35-CMD"}class $a{constructor(e,t,i=0){var s;if(this.attr=void 0,this.tagAnchor=void 0,this.tagOrder=void 0,this._startDate=void 0,this._endDate=void 0,this._dateAtEnd=void 0,this._cue=void 0,this._badValueForSameId=void 0,this.tagAnchor=t?.tagAnchor||null,this.tagOrder=(s=t?.tagOrder)!=null?s:i,t){const r=t.attr;for(const n in r)if(Object.prototype.hasOwnProperty.call(e,n)&&e[n]!==r[n]){Oe.warn(`DATERANGE tag attribute: "${n}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=n;break}e=Ne(new He({}),r,e)}if(this.attr=e,t?(this._startDate=t._startDate,this._cue=t._cue,this._endDate=t._endDate,this._dateAtEnd=t._dateAtEnd):this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){const r=t?.endDate||new Date(this.attr["END-DATE"]);se(r.getTime())&&(this._endDate=r)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get cue(){const e=this._cue;return e===void 0?this._cue=this.attr.enumeratedStringList(this.attr.CUE?"CUE":"X-CUE",{pre:!1,post:!1,once:!1}):e}get startTime(){const{tagAnchor:e}=this;return e===null||e.programDateTime===null?(Oe.warn(`Expected tagAnchor Fragment with PDT set for DateRange "${this.id}": ${e}`),NaN):e.start+(this.startDate.getTime()-e.programDateTime)/1e3}get startDate(){return this._startDate}get endDate(){const e=this._endDate||this._dateAtEnd;if(e)return e;const t=this.duration;return t!==null?this._dateAtEnd=new Date(this._startDate.getTime()+t*1e3):null}get duration(){if("DURATION"in this.attr){const e=this.attr.decimalFloatingPoint("DURATION");if(se(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isInterstitial(){return this.class===Dc}get isValid(){return!!this.id&&!this._badValueForSameId&&se(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)&&(!this.attr.CUE||!this.cue.pre&&!this.cue.post||this.cue.pre!==this.cue.post)&&(!this.isInterstitial||"X-ASSET-URI"in this.attr||"X-ASSET-LIST"in this.attr)}}const wc=10;class kc{constructor(e){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.dateRangeTagCount=0,this.live=!0,this.requestScheduled=-1,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.appliedTimelineOffset=void 0,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}reloaded(e){if(!e){this.advanced=!0,this.updated=!0;return}const t=this.lastPartSn-e.lastPartSn,i=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!i||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||t===0&&i>0,this.updated||this.advanced?this.misses=Math.floor(e.misses*.6):this.misses=e.misses+1}hasKey(e){return this.encryptedFragments.some(t=>{let i=t.decryptdata;return i||(t.setKeyFormat(e.keyFormat),i=t.decryptdata),!!i&&e.matches(i)})}get hasProgramDateTime(){return this.fragments.length?se(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||wc}get drift(){const e=this.driftEndTime-this.driftStartTime;return e>0?(this.driftEnd-this.driftStart)*1e3/e:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){return this.fragments.length?this.fragments[this.fragments.length-1].end:0}get fragmentStart(){return this.fragments.length?this.fragments[0].start:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].index:-1}get maxPartIndex(){const e=this.partList;if(e){const t=this.lastPartIndex;if(t!==-1){for(let i=e.length;i--;)if(e[i].index>t)return e[i].index;return t}}return 0}get lastPartSn(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}get expired(){if(this.live&&this.age&&this.misses<3){const e=this.partEnd-this.fragmentStart;return this.age>Math.max(e,this.totalduration)+this.levelTargetDuration}return!1}}function Ga(a,e){return a.length===e.length?!a.some((t,i)=>t!==e[i]):!1}function Ha(a,e){return!a&&!e?!0:!a||!e?!1:Ga(a,e)}function ki(a){return a==="AES-128"||a==="AES-256"||a==="AES-256-CTR"}function _r(a){switch(a){case"AES-128":case"AES-256":return ni.cbc;case"AES-256-CTR":return ni.ctr;default:throw new Error(`invalid full segment method ${a}`)}}function wr(a){return Uint8Array.from(atob(a),e=>e.charCodeAt(0))}function kr(a){return Uint8Array.from(unescape(encodeURIComponent(a)),e=>e.charCodeAt(0))}function Mc(a){const e=kr(a).subarray(0,16),t=new Uint8Array(16);return t.set(e,16-e.length),t}function Oc(a){const e=function(i,s,r){const n=i[s];i[s]=i[r],i[r]=n};e(a,0,3),e(a,1,2),e(a,4,5),e(a,6,7)}function Fc(a){const e=a.split(":");let t=null;if(e[0]==="data"&&e.length===2){const i=e[1].split(";"),s=i[i.length-1].split(",");if(s.length===2){const r=s[0]==="base64",n=s[1];r?(i.splice(-1,1),t=wr(n)):t=Mc(n)}}return t}const Ps=typeof self<"u"?self:void 0;var Ve={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},ct={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function _s(a){switch(a){case ct.FAIRPLAY:return Ve.FAIRPLAY;case ct.PLAYREADY:return Ve.PLAYREADY;case ct.WIDEVINE:return Ve.WIDEVINE;case ct.CLEARKEY:return Ve.CLEARKEY}}function Mr(a){switch(a){case Ve.FAIRPLAY:return ct.FAIRPLAY;case Ve.PLAYREADY:return ct.PLAYREADY;case Ve.WIDEVINE:return ct.WIDEVINE;case Ve.CLEARKEY:return ct.CLEARKEY}}function Qi(a){const{drmSystems:e,widevineLicenseUrl:t}=a,i=e?[Ve.FAIRPLAY,Ve.WIDEVINE,Ve.PLAYREADY,Ve.CLEARKEY].filter(s=>!!e[s]):[];return!i[Ve.WIDEVINE]&&t&&i.push(Ve.WIDEVINE),i}const Va=(function(a){return Ps!=null&&(a=Ps.navigator)!=null&&a.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null})();function Nc(a,e,t,i){let s;switch(a){case Ve.FAIRPLAY:s=["cenc","sinf"];break;case Ve.WIDEVINE:case Ve.PLAYREADY:s=["cenc"];break;case Ve.CLEARKEY:s=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${a}`)}return Bc(s,e,t,i)}function Bc(a,e,t,i){return[{initDataTypes:a,persistentState:i.persistentState||"optional",distinctiveIdentifier:i.distinctiveIdentifier||"optional",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:e.map(r=>({contentType:`audio/mp4; codecs=${r}`,robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null})),videoCapabilities:t.map(r=>({contentType:`video/mp4; codecs=${r}`,robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null}))}]}function Uc(a){var e;return!!a&&(a.sessionType==="persistent-license"||!!((e=a.sessionTypes)!=null&&e.some(t=>t==="persistent-license")))}function $c(a){const e=new Uint16Array(a.buffer,a.byteOffset,a.byteLength/2),t=String.fromCharCode.apply(null,Array.from(e)),i=t.substring(t.indexOf("<"),t.length),n=new DOMParser().parseFromString(i,"text/xml").getElementsByTagName("KID")[0];if(n){const o=n.childNodes[0]?n.childNodes[0].nodeValue:n.getAttribute("VALUE");if(o){const c=wr(o).subarray(0,16);return Oc(c),c}}return null}let ws={};class ks{static clearKeyUriToKeyIdMap(){ws={}}constructor(e,t,i,s=[1],r=null,n){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=i,this.keyFormatVersions=s,this.iv=r,this.encrypted=e?e!=="NONE":!1,this.isCommonEncryption=this.encrypted&&!ki(e),n!=null&&n.startsWith("0x")&&(this.keyId=new Uint8Array(Qn(n)))}matches(e){return e.uri===this.uri&&e.method===this.method&&e.encrypted===this.encrypted&&e.keyFormat===this.keyFormat&&Ga(e.keyFormatVersions,this.keyFormatVersions)&&Ha(e.iv,this.iv)&&Ha(e.keyId,this.keyId)}isSupported(){if(this.method){if(ki(this.method)||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES";switch(this.keyFormat){case ct.FAIRPLAY:case ct.WIDEVINE:case ct.PLAYREADY:case ct.CLEARKEY:return["SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1}getDecryptData(e){if(!this.encrypted||!this.uri)return null;if(ki(this.method)&&this.uri&&!this.iv){typeof e!="number"&&(Oe.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0);const i=Gc(e);return new ks(this.method,this.uri,"identity",this.keyFormatVersions,i)}if(this.pssh&&this.keyId)return this;const t=Fc(this.uri);if(t)switch(this.keyFormat){case ct.WIDEVINE:if(this.pssh=t,!this.keyId&&t.length>=22){const i=t.length-22;this.keyId=t.subarray(i,i+16)}break;case ct.PLAYREADY:{const i=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=Vu(i,null,t),this.keyId=$c(t);break}default:{let i=t.subarray(0,16);if(i.length!==16){const s=new Uint8Array(16);s.set(i,16-i.length),i=s}this.keyId=i;break}}if(!this.keyId||this.keyId.byteLength!==16){let i=ws[this.uri];if(!i){const s=Object.keys(ws).length%Number.MAX_SAFE_INTEGER;i=new Uint8Array(16),new DataView(i.buffer,12,4).setUint32(0,s),ws[this.uri]=i}this.keyId=i}return this}}function Gc(a){const e=new Uint8Array(16);for(let t=12;t<16;t++)e[t]=a>>8*(15-t)&255;return e}const Ka=/#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,Ya=/#EXT-X-MEDIA:(.*)/g,Hc=/^#EXT(?:INF|-X-TARGETDURATION):/m,Or=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),Vc=new RegExp([/#EXT-X-(PROGRAM-DATE-TIME|BYTERANGE|DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|"));class Nt{static findGroup(e,t){for(let i=0;i<e.length;i++){const s=e[i];if(s.id===t)return s}}static resolve(e,t){return pr.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return Hc.test(e)}static parseMasterPlaylist(e,t){const i=Na(e),s={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:i},r=[];Ka.lastIndex=0;let n;for(;(n=Ka.exec(e))!=null;)if(n[1]){var o;const u=new He(n[1],s),h=Pr(s,n[2]),f={attrs:u,bitrate:u.decimalInteger("BANDWIDTH")||u.decimalInteger("AVERAGE-BANDWIDTH"),name:u.NAME,url:Nt.resolve(h,t)},g=u.decimalResolution("RESOLUTION");g&&(f.width=g.width,f.height=g.height),qa(u.CODECS,f);const I=u["SUPPLEMENTAL-CODECS"];I&&(f.supplemental={},qa(I,f.supplemental)),(o=f.unknownCodecs)!=null&&o.length||r.push(f),s.levels.push(f)}else if(n[3]){const u=n[3],h=n[4];switch(u){case"SESSION-DATA":{const f=new He(h,s),g=f["DATA-ID"];g&&(s.sessionData===null&&(s.sessionData={}),s.sessionData[g]=f);break}case"SESSION-KEY":{const f=ja(h,t,s);f.encrypted&&f.isSupported()?(s.sessionKeys===null&&(s.sessionKeys=[]),s.sessionKeys.push(f)):Oe.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${h}"`);break}case"DEFINE":{{const f=new He(h,s);Ba(s,f,t)}break}case"CONTENT-STEERING":{const f=new He(h,s);s.contentSteering={uri:Nt.resolve(f["SERVER-URI"],t),pathwayId:f["PATHWAY-ID"]||"."};break}case"START":{s.startTimeOffset=za(h);break}}}const c=r.length>0&&r.length<s.levels.length;return s.levels=c?r:s.levels,s.levels.length===0&&(s.playlistParsingError=new Error("no levels found in manifest")),s}static parseMasterPlaylistMedia(e,t,i){let s;const r={},n=i.levels,o={AUDIO:n.map(u=>({id:u.attrs.AUDIO,audioCodec:u.audioCodec})),SUBTITLES:n.map(u=>({id:u.attrs.SUBTITLES,textCodec:u.textCodec})),"CLOSED-CAPTIONS":[]};let c=0;for(Ya.lastIndex=0;(s=Ya.exec(e))!==null;){const u=new He(s[1],i),h=u.TYPE;if(h){const f=o[h],g=r[h]||[];r[h]=g;const I=u.LANGUAGE,m=u["ASSOC-LANGUAGE"],E=u.CHANNELS,v=u.CHARACTERISTICS,x=u["INSTREAM-ID"],D={attrs:u,bitrate:0,id:c++,groupId:u["GROUP-ID"]||"",name:u.NAME||I||"",type:h,default:u.bool("DEFAULT"),autoselect:u.bool("AUTOSELECT"),forced:u.bool("FORCED"),lang:I,url:u.URI?Nt.resolve(u.URI,t):""};if(m&&(D.assocLang=m),E&&(D.channels=E),v&&(D.characteristics=v),x&&(D.instreamId=x),f!=null&&f.length){const L=Nt.findGroup(f,D.groupId)||f[0];Xa(D,L,"audioCodec"),Xa(D,L,"textCodec")}g.push(D)}}return r}static parseLevelPlaylist(e,t,i,s,r,n){var o;const c={url:t},u=new kc(t),h=u.fragments,f=[];let g=null,I=0,m=0,E=0,v=0,x=0,D=null,L=new mr(s,c),w,N,K,p=-1,$=!1,F=null,O;if(Or.lastIndex=0,u.m3u8=e,u.hasVariableRefs=Na(e),((o=Or.exec(e))==null?void 0:o[0])!=="#EXTM3U")return u.playlistParsingError=new Error("Missing format identifier #EXTM3U"),u;for(;(w=Or.exec(e))!==null;){$&&($=!1,L=new mr(s,c),L.playlistOffset=E,L.setStart(E),L.sn=I,L.cc=v,x&&(L.bitrate=x),L.level=i,g&&(L.initSegment=g,g.rawProgramDateTime&&(L.rawProgramDateTime=g.rawProgramDateTime,g.rawProgramDateTime=null),F&&(L.setByteRange(F),F=null)));const ce=w[1];if(ce){L.duration=parseFloat(ce);const ue=(" "+w[2]).slice(1);L.title=ue||null,L.tagList.push(ue?["INF",ce,ue]:["INF",ce])}else if(w[3]){if(se(L.duration)){L.playlistOffset=E,L.setStart(E),K&&Qa(L,K,u),L.sn=I,L.level=i,L.cc=v,h.push(L);const ue=(" "+w[3]).slice(1);L.relurl=Pr(u,ue),Fr(L,D,f),D=L,E+=L.duration,I++,m=0,$=!0}}else{if(w=w[0].match(Vc),!w){Oe.warn("No matches on slow regex match for level playlist!");continue}for(N=1;N<w.length&&w[N]===void 0;N++);const ue=(" "+w[N]).slice(1),Q=(" "+w[N+1]).slice(1),ne=w[N+2]?(" "+w[N+2]).slice(1):null;switch(ue){case"BYTERANGE":D?L.setByteRange(Q,D):L.setByteRange(Q);break;case"PROGRAM-DATE-TIME":L.rawProgramDateTime=Q,L.tagList.push(["PROGRAM-DATE-TIME",Q]),p===-1&&(p=h.length);break;case"PLAYLIST-TYPE":u.type&&qt(u,ue,w),u.type=Q.toUpperCase();break;case"MEDIA-SEQUENCE":u.startSN!==0?qt(u,ue,w):h.length>0&&Ja(u,ue,w),I=u.startSN=parseInt(Q);break;case"SKIP":{u.skippedSegments&&qt(u,ue,w);const re=new He(Q,u),le=re.decimalInteger("SKIPPED-SEGMENTS");if(se(le)){u.skippedSegments+=le;for(let J=le;J--;)h.push(null);I+=le}const pe=re.enumeratedString("RECENTLY-REMOVED-DATERANGES");pe&&(u.recentlyRemovedDateranges=(u.recentlyRemovedDateranges||[]).concat(pe.split(" ")));break}case"TARGETDURATION":u.targetduration!==0&&qt(u,ue,w),u.targetduration=Math.max(parseInt(Q),1);break;case"VERSION":u.version!==null&&qt(u,ue,w),u.version=parseInt(Q);break;case"INDEPENDENT-SEGMENTS":break;case"ENDLIST":u.live||qt(u,ue,w),u.live=!1;break;case"#":(Q||ne)&&L.tagList.push(ne?[Q,ne]:[Q]);break;case"DISCONTINUITY":v++,L.tagList.push(["DIS"]);break;case"GAP":L.gap=!0,L.tagList.push([ue]);break;case"BITRATE":L.tagList.push([ue,Q]),x=parseInt(Q)*1e3,se(x)?L.bitrate=x:x=0;break;case"DATERANGE":{const re=new He(Q,u),le=new $a(re,u.dateRanges[re.ID],u.dateRangeTagCount);u.dateRangeTagCount++,le.isValid||u.skippedSegments?u.dateRanges[le.id]=le:Oe.warn(`Ignoring invalid DATERANGE tag: "${Q}"`),L.tagList.push(["EXT-X-DATERANGE",Q]);break}case"DEFINE":{{const re=new He(Q,u);"IMPORT"in re?Lc(u,re,n):Ba(u,re,t)}break}case"DISCONTINUITY-SEQUENCE":u.startCC!==0?qt(u,ue,w):h.length>0&&Ja(u,ue,w),u.startCC=v=parseInt(Q);break;case"KEY":{const re=ja(Q,t,u);if(re.isSupported()){if(re.method==="NONE"){K=void 0;break}K||(K={});const le=K[re.keyFormat];le!=null&&le.matches(re)||(le&&(K=Ne({},K)),K[re.keyFormat]=re)}else Oe.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${Q}"`);break}case"START":u.startTimeOffset=za(Q);break;case"MAP":{const re=new He(Q,u);if(L.duration){const le=new mr(s,c);Za(le,re,i,K),g=le,L.initSegment=g,g.rawProgramDateTime&&!L.rawProgramDateTime&&(L.rawProgramDateTime=g.rawProgramDateTime)}else{const le=L.byteRangeEndOffset;if(le){const pe=L.byteRangeStartOffset;F=`${le-pe}@${pe}`}else F=null;Za(L,re,i,K),g=L,$=!0}g.cc=v;break}case"SERVER-CONTROL":{O&&qt(u,ue,w),O=new He(Q),u.canBlockReload=O.bool("CAN-BLOCK-RELOAD"),u.canSkipUntil=O.optionalFloat("CAN-SKIP-UNTIL",0),u.canSkipDateRanges=u.canSkipUntil>0&&O.bool("CAN-SKIP-DATERANGES"),u.partHoldBack=O.optionalFloat("PART-HOLD-BACK",0),u.holdBack=O.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{u.partTarget&&qt(u,ue,w);const re=new He(Q);u.partTarget=re.decimalFloatingPoint("PART-TARGET");break}case"PART":{let re=u.partList;re||(re=u.partList=[]);const le=m>0?re[re.length-1]:void 0,pe=m++,J=new He(Q,u),ee=new Pu(J,L,c,pe,le);re.push(ee),L.duration+=ee.duration;break}case"PRELOAD-HINT":{const re=new He(Q,u);u.preloadHint=re;break}case"RENDITION-REPORT":{const re=new He(Q,u);u.renditionReports=u.renditionReports||[],u.renditionReports.push(re);break}default:Oe.warn(`line parsed but not handled: ${w}`);break}}}D&&!D.relurl?(h.pop(),E-=D.duration,u.partList&&(u.fragmentHint=D)):u.partList&&(Fr(L,D,f),L.cc=v,u.fragmentHint=L,K&&Qa(L,K,u)),u.targetduration||(u.playlistParsingError=new Error("#EXT-X-TARGETDURATION is required"));const W=h.length,ie=h[0],X=h[W-1];if(E+=u.skippedSegments*u.targetduration,E>0&&W&&X){u.averagetargetduration=E/W;const ce=X.sn;u.endSN=ce!=="initSegment"?ce:0,u.live||(X.endList=!0),p>0&&(Yc(h,p),ie&&f.unshift(ie))}return u.fragmentHint&&(E+=u.fragmentHint.duration),u.totalduration=E,f.length&&u.dateRangeTagCount&&ie&&Wa(f,u),u.endCC=v,u}}function Wa(a,e){let t=a.length;if(!t)if(e.hasProgramDateTime){const o=e.fragments[e.fragments.length-1];a.push(o),t++}else return;const i=a[t-1],s=e.live?1/0:e.totalduration,r=Object.keys(e.dateRanges);for(let o=r.length;o--;){const c=e.dateRanges[r[o]],u=c.startDate.getTime();c.tagAnchor=i.ref;for(let h=t;h--;){var n;if(((n=a[h])==null?void 0:n.sn)<e.startSN)break;const f=Kc(e,u,a,h,s);if(f!==-1){c.tagAnchor=e.fragments[f].ref;break}}}}function Kc(a,e,t,i,s){const r=t[i];if(r){const o=r.programDateTime;if(e>=o||i===0){var n;const c=(((n=t[i+1])==null?void 0:n.start)||s)-r.start;if(e<=o+c*1e3){const u=t[i].sn-a.startSN;if(u<0)return-1;const h=a.fragments;if(h.length>t.length){const g=(t[i+1]||h[h.length-1]).sn-a.startSN;for(let I=g;I>u;I--){const m=h[I].programDateTime;if(e>=m&&e<m+h[I].duration*1e3)return I}}return u}}}return-1}function ja(a,e,t){var i,s;const r=new He(a,t),n=(i=r.METHOD)!=null?i:"",o=r.URI,c=r.hexadecimalInteger("IV"),u=r.KEYFORMATVERSIONS,h=(s=r.KEYFORMAT)!=null?s:"identity";o&&r.IV&&!c&&Oe.error(`Invalid IV: ${r.IV}`);const f=o?Nt.resolve(o,e):"",g=(u||"1").split("/").map(Number).filter(Number.isFinite);return new ks(n,f,h,g,c,r.KEYID)}function za(a){const t=new He(a).decimalFloatingPoint("TIME-OFFSET");return se(t)?t:null}function qa(a,e){let t=(a||"").split(/[ ,]+/).filter(i=>i);["video","audio","text"].forEach(i=>{const s=t.filter(r=>yr(r,i));s.length&&(e[`${i}Codec`]=s.map(r=>r.split("/")[0]).join(","),t=t.filter(r=>s.indexOf(r)===-1))}),e.unknownCodecs=t}function Xa(a,e,t){const i=e[t];i&&(a[t]=i)}function Yc(a,e){let t=a[e];for(let i=e;i--;){const s=a[i];if(!s)return;s.programDateTime=t.programDateTime-s.duration*1e3,t=s}}function Fr(a,e,t){a.rawProgramDateTime?t.push(a):e!=null&&e.programDateTime&&(a.programDateTime=e.endProgramDateTime)}function Za(a,e,t,i){a.relurl=e.URI,e.BYTERANGE&&a.setByteRange(e.BYTERANGE),a.level=t,a.sn="initSegment",i&&(a.levelkeys=i),a.initSegment=null}function Qa(a,e,t){a.levelkeys=e;const{encryptedFragments:i}=t;(!i.length||i[i.length-1].levelkeys!==e)&&Object.keys(e).some(s=>e[s].isCommonEncryption)&&i.push(a)}function qt(a,e,t){a.playlistParsingError=new Error(`#EXT-X-${e} must not appear more than once (${t[0]})`)}function Ja(a,e,t){a.playlistParsingError=new Error(`#EXT-X-${e} must appear before the first Media Segment (${t[0]})`)}function Nr(a,e){const t=e.startPTS;if(se(t)){let i=0,s;e.sn>a.sn?(i=t-a.start,s=a):(i=a.start-t,s=e),s.duration!==i&&s.setDuration(i)}else e.sn>a.sn?a.cc===e.cc&&a.minEndPTS?e.setStart(a.start+(a.minEndPTS-a.start)):e.setStart(a.start+a.duration):e.setStart(Math.max(a.start-e.duration,0))}function eo(a,e,t,i,s,r,n){i-t<=0&&(n.warn("Fragment should have a positive duration",e),i=t+e.duration,r=s+e.duration);let c=t,u=i;const h=e.startPTS,f=e.endPTS;if(se(h)){const x=Math.abs(h-t);a&&x>a.totalduration?n.warn(`media timestamps and playlist times differ by ${x}s for level ${e.level} ${a.url}`):se(e.deltaPTS)?e.deltaPTS=Math.max(x,e.deltaPTS):e.deltaPTS=x,c=Math.max(t,h),t=Math.min(t,h),s=e.startDTS!==void 0?Math.min(s,e.startDTS):s,u=Math.min(i,f),i=Math.max(i,f),r=e.endDTS!==void 0?Math.max(r,e.endDTS):r}const g=t-e.start;e.start!==0&&e.setStart(t),e.setDuration(i-e.start),e.startPTS=t,e.maxStartPTS=c,e.startDTS=s,e.endPTS=i,e.minEndPTS=u,e.endDTS=r;const I=e.sn;if(!a||I<a.startSN||I>a.endSN)return 0;let m;const E=I-a.startSN,v=a.fragments;for(v[E]=e,m=E;m>0;m--)Nr(v[m],v[m-1]);for(m=E;m<v.length-1;m++)Nr(v[m],v[m+1]);return a.fragmentHint&&Nr(v[v.length-1],a.fragmentHint),a.PTSKnown=a.alignedSliding=!0,g}function Wc(a,e,t){if(a===e)return;let i=null;const s=a.fragments;for(let h=s.length-1;h>=0;h--){const f=s[h].initSegment;if(f){i=f;break}}a.fragmentHint&&delete a.fragmentHint.endPTS;let r;qc(a,e,(h,f,g,I)=>{if((!e.startCC||e.skippedSegments)&&f.cc!==h.cc){const m=h.cc-f.cc;for(let E=g;E<I.length;E++)I[E].cc+=m;e.endCC=I[I.length-1].cc}se(h.startPTS)&&se(h.endPTS)&&(f.setStart(f.startPTS=h.startPTS),f.startDTS=h.startDTS,f.maxStartPTS=h.maxStartPTS,f.endPTS=h.endPTS,f.endDTS=h.endDTS,f.minEndPTS=h.minEndPTS,f.setDuration(h.endPTS-h.startPTS),f.duration&&(r=f),e.PTSKnown=e.alignedSliding=!0),h.hasStreams&&(f.elementaryStreams=h.elementaryStreams),f.loader=h.loader,h.hasStats&&(f.stats=h.stats),h.initSegment&&(f.initSegment=h.initSegment,i=h.initSegment)});const n=e.fragments,o=e.fragmentHint?n.concat(e.fragmentHint):n;if(i&&o.forEach(h=>{var f;h&&(!h.initSegment||h.initSegment.relurl===((f=i)==null?void 0:f.relurl))&&(h.initSegment=i)}),e.skippedSegments){if(e.deltaUpdateFailed=n.some(h=>!h),e.deltaUpdateFailed){t.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let h=e.skippedSegments;h--;)n.shift();e.startSN=n[0].sn}else{e.canSkipDateRanges&&(e.dateRanges=jc(a.dateRanges,e,t));const h=a.fragments.filter(f=>f.rawProgramDateTime);if(a.hasProgramDateTime&&!e.hasProgramDateTime)for(let f=1;f<o.length;f++)o[f].programDateTime===null&&Fr(o[f],o[f-1],h);Wa(h,e)}e.endCC=n[n.length-1].cc}if(!e.startCC){var c;const h=ro(a,e.startSN-1);e.startCC=(c=h?.cc)!=null?c:n[0].cc}zc(a.partList,e.partList,(h,f)=>{f.elementaryStreams=h.elementaryStreams,f.stats=h.stats}),r?eo(e,r,r.startPTS,r.endPTS,r.startDTS,r.endDTS,t):io(a,e),n.length&&(e.totalduration=e.edge-n[0].start),e.driftStartTime=a.driftStartTime,e.driftStart=a.driftStart;const u=e.advancedDateTime;if(e.advanced&&u){const h=e.edge;e.driftStart||(e.driftStartTime=u,e.driftStart=h),e.driftEndTime=u,e.driftEnd=h}else e.driftEndTime=a.driftEndTime,e.driftEnd=a.driftEnd,e.advancedDateTime=a.advancedDateTime;e.requestScheduled===-1&&(e.requestScheduled=a.requestScheduled)}function jc(a,e,t){const{dateRanges:i,recentlyRemovedDateranges:s}=e,r=Ne({},a);s&&s.forEach(c=>{delete r[c]});const o=Object.keys(r).length;return o?(Object.keys(i).forEach(c=>{const u=r[c],h=new $a(i[c].attr,u);h.isValid?(r[c]=h,u||(h.tagOrder+=o)):t.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${Ge(i[c].attr)}"`)}),r):i}function zc(a,e,t){if(a&&e){let i=0;for(let s=0,r=a.length;s<=r;s++){const n=a[s],o=e[s+i];n&&o&&n.index===o.index&&n.fragment.sn===o.fragment.sn?t(n,o):i--}}}function qc(a,e,t){const i=e.skippedSegments,s=Math.max(a.startSN,e.startSN)-e.startSN,r=(a.fragmentHint?1:0)+(i?e.endSN:Math.min(a.endSN,e.endSN))-e.startSN,n=e.startSN-a.startSN,o=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,c=a.fragmentHint?a.fragments.concat(a.fragmentHint):a.fragments;for(let u=s;u<=r;u++){const h=c[n+u];let f=o[u];if(i&&!f&&h&&(f=e.fragments[u]=h),h&&f){t(h,f,u,o);const g=h.relurl,I=f.relurl;if(g&&Xc(g,I)){e.playlistParsingError=to(`media sequence mismatch ${f.sn}:`,a,e,h,f);return}else if(h.cc!==f.cc){e.playlistParsingError=to(`discontinuity sequence mismatch (${h.cc}!=${f.cc})`,a,e,h,f);return}}}}function to(a,e,t,i,s){return new Error(`${a} ${s.url}
11
+ Time to underbuffer: ${_e.toFixed(3)} s`),s.abortRequests(),this.fragCurrent=this.partCurrent=null,he>m){let ye=this.findBestLevel(Ie.levels[m].bitrate,m,he,0,_e,1,1);ye===-1&&(ye=m),Ie.nextLoadLevel=Ie.nextAutoLevel=ye,this.firstAutoFloor=Math.min(ye,Ie.firstLevel),this.resetEstimator(Ie.levels[ye].bitrate)}}};v||ne>ee*2?Ee():this.timer=self.setInterval(Ee,ee*1e3),a.trigger(E.FRAG_LOAD_EMERGENCY_ABORTED,{frag:s,part:n,stats:h})},this.hls=e,this.bwEstimator=this.initEstimator(),this.registerListeners()}resetEstimator(e){this.hls&&(e&&(this.log(`setting initial bwe to ${e}`),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator())}initEstimator(){const e=this.hls.config;return new rh(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}registerListeners(){const e=this.hls;e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.FRAG_LOADING,this.onFragLoading,this),e.on(E.FRAG_LOADED,this.onFragLoaded,this),e.on(E.FRAG_BUFFERED,this.onFragBuffered,this),e.on(E.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(E.LEVEL_LOADED,this.onLevelLoaded,this),e.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(E.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(E.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e&&(e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.FRAG_LOADING,this.onFragLoading,this),e.off(E.FRAG_LOADED,this.onFragLoaded,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this),e.off(E.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(E.LEVEL_LOADED,this.onLevelLoaded,this),e.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(E.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(E.ERROR,this.onError,this))}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=this.supportedCache=null,this.audioTracksByGroup=this.codecTiers=this.fragCurrent=this.partCurrent=null}onManifestLoading(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.firstAutoFloor=-1,this.lastLevelLoadSec=0,this.supportedCache={},this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()}onLevelsUpdated(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null}onMaxAutoLevelUpdated(){this.firstSelection=-1,this.nextAutoLevelKey=""}onFragLoading(e,t){const i=t.frag;if(!this.ignoreFragment(i)){if(!i.bitrateTest){var s;this.fragCurrent=i,this.partCurrent=(s=t.part)!=null?s:null}this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)}}onLevelSwitching(e,t){this.clearTimer()}onError(e,t){if(!t.fatal)switch(t.details){case U.BUFFER_ADD_CODEC_ERROR:case U.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case U.FRAG_LOAD_TIMEOUT:{const i=t.frag,{fragCurrent:s,partCurrent:n}=this;if(i&&Yn(i,s)){const a=performance.now(),o=n?n.stats:i.stats,l=a-o.loading.start,u=o.loading.first?o.loading.first-o.loading.start:-1;if(o.loaded&&u>-1){const d=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(l-Math.min(d,u),o.loaded)}else this.bwEstimator.sampleTTFB(l)}break}}}getTimeToLoadFrag(e,t,i,s){const n=e+i/t,a=s?e+this.lastLevelLoadSec:0;return n+a}onLevelLoaded(e,t){const i=this.hls.config,{loading:s}=t.stats,n=s.end-s.first;se(n)&&(this.lastLevelLoadSec=n/1e3),t.details.live?this.bwEstimator.update(i.abrEwmaSlowLive,i.abrEwmaFastLive):this.bwEstimator.update(i.abrEwmaSlowVoD,i.abrEwmaFastVoD),this.timer>-1&&this._abandonRulesCheck(t.levelInfo)}onFragLoaded(e,t){var i;const{frag:s,part:n}=t,a=n?n.stats:s.stats;if(s.type===ge.MAIN&&this.bwEstimator.sampleTTFB(a.loading.first-a.loading.start),!this.ignoreFragment(s)){if(this.clearTimer(),s.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,(i=this.hls)!=null&&i.config.abrMaxWithRealBitrate){const o=n?n.duration:s.duration,l=this.hls.levels[s.level],u=(l.loaded?l.loaded.bytes:0)+a.loaded,h=(l.loaded?l.loaded.duration:0)+o;l.loaded={bytes:u,duration:h},l.realBitrate=Math.round(8*u/h)}if(s.bitrateTest){const o={stats:a,frag:s,part:n,id:s.type};this.onFragBuffered(E.FRAG_BUFFERED,o),s.bitrateTest=!1}else this.lastLoadedFragLevel=s.level}}onFragBuffered(e,t){const{frag:i,part:s}=t,n=s!=null&&s.stats.loaded?s.stats:i.stats;if(n.aborted||this.ignoreFragment(i))return;const o=((i.bitrate||0)>=1e5?n.parsing.end:n.loading.end)-n.loading.start-Math.min(n.loading.first-n.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(o,n.loaded),n.bwEstimate=this.getBwEstimate(),i.bitrateTest?this.bitrateTestDelay=o/1e3:(this.bitrateTestDelay=0,this.firstAutoFloor>-1&&this.bwEstimator.canEstimate()&&(this.firstAutoFloor=-1))}ignoreFragment(e){return e.type!==ge.MAIN||e.sn==="initSegment"}clearTimer(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}get firstAutoLevel(){const{hls:e}=this;if(!e)return 0;const{maxAutoLevel:t,minAutoLevel:i}=e,s=this.getBwEstimate(),n=this.getStarvationDelay(),a=e.config.maxStarvationDelay,o=this.findBestLevel(s,i,t,n/2,a,1,1);if(o>-1)return o;const l=e.firstLevel,u=this.firstAutoFloor===-1?1/0:this.firstAutoFloor,h=Math.min(Math.max(l,i),t,u);return this.warn(`Could not find best starting auto level. Defaulting to first in playlist ${l} clamped to ${h}`),h}get forcedAutoLevel(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}get nextAutoLevel(){if(!this.hls)return-1;const e=this.forcedAutoLevel,i=this.bwEstimator.canEstimate(),s=this.lastLoadedFragLevel>-1;if(e!==-1&&(!i||!s||this.nextAutoLevelKey===this.getAutoLevelKey()))return e;const n=i&&s?this.getNextABRAutoLevel():this.firstAutoLevel;if(e!==-1){const a=this.hls.levels;if(a.length>Math.max(e,n)&&a[e].loadError<=a[n].loadError)return e}return this._nextAutoLevel=n,this.nextAutoLevelKey=this.getAutoLevelKey(),n}getAutoLevelKey(){return`${this.getBwEstimate()}_${this.getStarvationDelay().toFixed(2)}`}getNextABRAutoLevel(){const{fragCurrent:e,partCurrent:t,hls:i}=this;if(!i)return-1;if(i.levels.length<=1)return i.loadLevel;const{maxAutoLevel:s,config:n,minAutoLevel:a}=i,o=t?t.duration:e?e.duration:0,l=this.getBwEstimate(),u=this.getStarvationDelay();let h=n.abrBandWidthFactor,d=n.abrBandWidthUpFactor;if(u){const v=this.findBestLevel(l,a,s,u,0,h,d);if(v>=0)return this.rebufferNotice=-1,v}let g=o?Math.min(o,n.maxStarvationDelay):n.maxStarvationDelay;if(!u){const v=this.bitrateTestDelay;v&&(g=(o?Math.min(o,n.maxLoadingDelay):n.maxLoadingDelay)-v,this.info(`bitrate test took ${Math.round(1e3*v)}ms, set first fragment max fetchDuration to ${Math.round(1e3*g)} ms`),h=d=1)}const m=this.findBestLevel(l,a,s,u,g,h,d);if(this.rebufferNotice!==m&&(this.rebufferNotice=m,this.info(`${u?"rebuffering expected":"buffer is empty"}, optimal quality level ${m}`)),m>-1)return m;const A=i.levels[a],C=i.loadLevelObj;return C&&A?.bitrate<C.bitrate?a:i.loadLevel}getStarvationDelay(){const e=this.hls,t=e?.media;if(!t)return 1/0;const i=t&&t.playbackRate!==0?Math.abs(t.playbackRate):1,s=e.mainForwardBufferInfo;return(s?s.len:0)/i}getBwEstimate(){return this.bwEstimator.getEstimate()}findBestLevel(e,t,i,s,n,a,o){const{hls:l,lastLoadedFragLevel:u,fragCurrent:h,partCurrent:d}=this;if(!l)return-1;const g=s+n,m=u===-1?l.firstLevel:u,{levels:A,allAudioTracks:C,loadLevel:v,latestLevelDetails:S,config:R}=l;if(A.length===1)return 0;const b=A[m],D=!!(S!=null&&S.live),_=v===-1||u===-1;let M,p="SDR",$=b?.frameRate||0;const{audioPreference:N,videoPreference:O}=R,W=this.audioTracksByGroup||(this.audioTracksByGroup=Do(C));let q=-1;if(_){if(this.firstSelection!==-1)return this.firstSelection;const Z=this.codecTiers||(this.codecTiers=pd(A,W,t,i)),Q=gd(Z,p,e,N,O),{codecSet:ee,videoRanges:he,minFramerate:te,minBitrate:re,minIndex:Ee,preferHDR:Ie}=Q;q=Ee,M=ee,p=Ie?he[he.length-1]:he[0],$=te,e=Math.max(e,re),this.log(`picked start tier ${Xe(Q)}`)}else M=b?.codecSet,p=b?.videoRange;const z=d?d.duration:h?h.duration:0,oe=this.bwEstimator.getEstimateTTFB()/1e3,ne=[];for(let Z=i;Z>=t;Z--){var J;const Q=A[Z],ee=Z>m;if(!Q)continue;if(R.useMediaCapabilities&&!Q.supportedResult&&!Q.supportedPromise){const ye=navigator.mediaCapabilities;typeof ye?.decodingInfo=="function"&&rd(Q,W,p,$,e,N)?(Q.supportedPromise=To(Q,W,ye,this.supportedCache),Q.supportedPromise.then(Oe=>{if(!this.hls)return;Q.supportedResult=Oe;const Le=this.hls.levels,Fe=Le.indexOf(Q);Oe.error?this.warn(`MediaCapabilities decodingInfo error: "${Oe.error}" for level ${Fe} ${Xe(Oe)}`):Oe.supported?Oe.decodingInfoResults.some(Ye=>Ye.smooth===!1||Ye.powerEfficient===!1)&&this.log(`MediaCapabilities decodingInfo for level ${Fe} not smooth or powerEfficient: ${Xe(Oe)}`):(this.warn(`Unsupported MediaCapabilities decodingInfo result for level ${Fe} ${Xe(Oe)}`),Fe>-1&&Le.length>1&&(this.log(`Removing unsupported level ${Fe}`),this.hls.removeLevel(Fe),this.hls.loadLevel===-1&&(this.hls.nextLoadLevel=0)))}).catch(Oe=>{this.warn(`Error handling MediaCapabilities decodingInfo: ${Oe}`)})):Q.supportedResult=vo}if((M&&Q.codecSet!==M||p&&Q.videoRange!==p||ee&&$>Q.frameRate||!ee&&$>0&&$<Q.frameRate||(J=Q.supportedResult)!=null&&(J=J.decodingInfoResults)!=null&&J.some(ye=>ye.smooth===!1))&&(!_||Z!==q)){ne.push(Z);continue}const he=Q.details,te=(d?he?.partTarget:he?.averagetargetduration)||z||1;let re;ee?re=o*e:re=a*e;const Ee=z&&s>=z*2&&n===0?Q.averageBitrate:Q.maxBitrate,Ie=this.getTimeToLoadFrag(oe,re,Ee*te,!he||he.live);if(re>=Ee&&(Z===u||Q.loadError===0&&Q.fragmentError===0||Ya(Q,R.errorPenaltyExpireMs))&&(Ie<=oe||!se(Ie)||D&&!this.bitrateTestDelay||Ie<g)){const ye=this.forcedAutoLevel;return Z!==v&&(ye===-1||ye!==v)&&(ne.length&&this.trace(`Skipped level(s) ${ne.join(",")} of ${i} max with CODECS and VIDEO-RANGE:"${A[ne[0]].codecs}" ${A[ne[0]].videoRange}; not compatible with "${M}" ${p}`),this.info(`switch candidate:${m}->${Z} adjustedbw(${Math.round(re)})-bitrate=${Math.round(re-Ee)} ttfb:${oe.toFixed(1)} avgDuration:${te.toFixed(1)} maxFetchDuration:${g.toFixed(1)} fetchDuration:${Ie.toFixed(1)} firstSelection:${_} codecSet:${Q.codecSet} videoRange:${Q.videoRange} hls.loadLevel:${v}`)),_&&(this.firstSelection=Z),Z}}return-1}set nextAutoLevel(e){const t=this.deriveNextAutoLevel(e);this._nextAutoLevel!==t&&(this.nextAutoLevelKey="",this._nextAutoLevel=t)}deriveNextAutoLevel(e){if(!this.hls)return-1;const{maxAutoLevel:t,minAutoLevel:i}=this.hls;return Math.min(Math.max(e,i),t)}}const wo={search:function(r,e){let t=0,i=r.length-1,s=null,n=null;for(;t<=i;){s=(t+i)/2|0,n=r[s];const a=e(n);if(a>0)t=s+1;else if(a<0)i=s-1;else return n}return null}};function yd(r,e,t){if(e===null||!Array.isArray(r)||!r.length||!se(e))return null;const i=r[0].programDateTime;if(e<(i||0))return null;const s=r[r.length-1].endProgramDateTime;if(e>=(s||0))return null;for(let n=0;n<r.length;++n){const a=r[n];if(Ed(e,t,a))return a}return null}function ji(r,e,t=0,i=0,s=.005){let n=null;if(r){n=e[1+r.sn-e[0].sn]||null;const o=r.endDTS-t;o>0&&o<15e-7&&(t+=15e-7),n&&r.level!==n.level&&n.end<=r.end&&(n=e[2+r.sn-e[0].sn]||null)}else t===0&&e[0].start===0&&(n=e[0]);if(n&&((!r||r.level===n.level)&&Mo(t,i,n)===0||vd(n,r,Math.min(s,i))))return n;const a=wo.search(e,Mo.bind(null,t,i));return a&&(a!==r||!n)?a:n}function vd(r,e,t){if(e?.start===0&&e.level<r.level&&(e.endPTS||0)>0){const i=e.tagList.reduce((s,n)=>(n[0]==="INF"&&(s+=parseFloat(n[1])),s),t);return r.start<=i}return!1}function Mo(r=0,e=0,t){if(t.start<=r&&t.start+t.duration>r)return 0;const i=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0));return t.start+t.duration-i<=r?1:t.start-i>r&&t.start?-1:0}function Ed(r,e,t){const i=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0))*1e3;return(t.endProgramDateTime||0)-i>r}function Oo(r,e,t){if(r&&r.startCC<=e&&r.endCC>=e){let i=r.fragments;const{fragmentHint:s}=r;s&&(i=i.concat(s));let n;return wo.search(i,a=>a.cc<e?1:a.cc>e?-1:(n=a,a.end<=t?1:a.start>t?-1:0)),n||null}return null}function Fo(r,e){return e===r.endSN&&r.fragmentHint?r.fragmentHint:r.fragments[1+e-r.startSN]||null}var gt={DoNothing:0,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,RetryRequest:5},dt={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,MoveAllAlternatesMatchingKey:4,SwitchToSDR:8,ResetMediaSource:16};class Td extends wt{constructor(e){super("error-controller",e.logger),this.hls=void 0,this.playlistError=0,this.hls=e,this.registerListeners()}registerListeners(){const e=this.hls;e.on(E.ERROR,this.onError,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const e=this.hls;e&&(e.off(E.ERROR,this.onError,this),e.off(E.ERROR,this.onErrorOut,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null}startLoad(e){}stopLoad(){this.playlistError=0}getVariantLevelIndex(e){return e?.type===ge.MAIN?e.level:this.getVariantIndex()}getVariantIndex(){var e;const t=this.hls,i=t.currentLevel;return(e=t.loadLevelObj)!=null&&e.details||i===-1?t.loadLevel:i}variantHasKey(e,t){if(e){var i;if((i=e.details)!=null&&i.hasKey(t))return!0;const s=e.audioGroups;if(s)return this.hls.allAudioTracks.filter(a=>s.indexOf(a.groupId)>=0).some(a=>{var o;return(o=a.details)==null?void 0:o.hasKey(t)})}return!1}onManifestLoading(){this.playlistError=0}onLevelUpdated(){this.playlistError=0}onError(e,t){var i;if(t.fatal)return;const s=this.hls,n=t.context;switch(t.details){case U.FRAG_LOAD_ERROR:case U.FRAG_LOAD_TIMEOUT:case U.KEY_LOAD_ERROR:case U.KEY_LOAD_TIMEOUT:t.errorAction=this.getFragRetryOrSwitchAction(t);return;case U.FRAG_PARSING_ERROR:if((i=t.frag)!=null&&i.gap){t.errorAction=ys();return}case U.FRAG_GAP:case U.FRAG_DECRYPT_ERROR:{t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=gt.SendAlternateToPenaltyBox;return}case U.PLAYLIST_UNCHANGED_ERROR:case U.LEVEL_EMPTY_ERROR:case U.LEVEL_PARSING_ERROR:{var a;const o=t.parent===ge.MAIN?t.level:s.loadLevel;t.details===U.LEVEL_EMPTY_ERROR&&((a=t.context)!=null&&(a=a.levelDetails)!=null&&a.live)?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,o):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,o))}return;case U.LEVEL_LOAD_ERROR:case U.LEVEL_LOAD_TIMEOUT:typeof n?.level=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.level));return;case U.AUDIO_TRACK_LOAD_ERROR:case U.AUDIO_TRACK_LOAD_TIMEOUT:case U.SUBTITLE_LOAD_ERROR:case U.SUBTITLE_TRACK_LOAD_TIMEOUT:if(n){const o=s.loadLevelObj;if(o&&(n.type===ke.AUDIO_TRACK&&o.hasAudioGroup(n.groupId)||n.type===ke.SUBTITLE_TRACK&&o.hasSubtitleGroup(n.groupId))){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,s.loadLevel),t.errorAction.action=gt.SendAlternateToPenaltyBox,t.errorAction.flags=dt.MoveAllAlternatesMatchingHost;return}}return;case U.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:t.errorAction={action:gt.SendAlternateToPenaltyBox,flags:dt.MoveAllAlternatesMatchingHDCP};return;case U.KEY_SYSTEM_SESSION_UPDATE_FAILED:case U.KEY_SYSTEM_STATUS_INTERNAL_ERROR:case U.KEY_SYSTEM_NO_SESSION:t.errorAction={action:gt.SendAlternateToPenaltyBox,flags:dt.MoveAllAlternatesMatchingKey};return;case U.BUFFER_ADD_CODEC_ERROR:case U.REMUX_ALLOC_ERROR:case U.BUFFER_APPEND_ERROR:t.errorAction||(t.errorAction=this.getLevelSwitchAction(t,t.level));return;case U.MEDIA_SOURCE_REQUIRES_RESET:t.errorAction||(t.errorAction=this.getLevelSwitchAction(t,t.level)),t.errorAction.flags|=dt.ResetMediaSource|dt.SwitchToSDR;return;case U.INTERNAL_EXCEPTION:case U.BUFFER_APPENDING_ERROR:case U.BUFFER_APPEND_NO_PROGRESS:case U.BUFFER_FULL_ERROR:case U.LEVEL_SWITCH_ERROR:case U.BUFFER_STALLED_ERROR:case U.BUFFER_SEEK_OVER_HOLE:case U.BUFFER_NUDGE_ON_STALL:t.errorAction=ys();return}t.type===me.KEY_SYSTEM_ERROR&&(t.levelRetry=!1,t.errorAction=ys())}getPlaylistRetryOrSwitchAction(e,t){const i=this.hls,s=Va(i.config.playlistLoadPolicy,e),n=this.playlistError++;if(cs(s,n,Vs(e),e.response))return{action:gt.RetryRequest,flags:dt.None,retryConfig:s,retryCount:n};const o=this.getLevelSwitchAction(e,t);return s&&(o.retryConfig=s,o.retryCount=n),o}getFragRetryOrSwitchAction(e){const t=this.hls,i=this.getVariantLevelIndex(e.frag),s=t.levels[i],{fragLoadPolicy:n,keyLoadPolicy:a}=t.config,o=Va(Ga(e)?a:n,e),l=t.levels.reduce((h,d)=>h+d.fragmentError,0);if(s&&(e.details!==U.FRAG_GAP&&s.fragmentError++,!Ha(e)&&cs(o,l,Vs(e),e.response)))return{action:gt.RetryRequest,flags:dt.None,retryConfig:o,retryCount:l};const u=this.getLevelSwitchAction(e,i);return o&&(u.retryConfig=o,u.retryCount=l),u}getLevelSwitchAction(e,t){const i=this.hls;t==null&&(t=i.loadLevel);const s=this.hls.levels[t];if(s){var n,a;const u=e.details;s.loadError++,s.loadErrorTime=self.performance.now(),u===U.BUFFER_APPEND_ERROR&&s.fragmentError++;let h=-1;const{levels:d,loadLevel:g,minAutoLevel:m,maxAutoLevel:A}=i;!i.autoLevelEnabled&&!i.config.preserveManualLevelOnError&&(i.loadLevel=-1);const C=(n=e.frag)==null?void 0:n.type,S=(C===ge.AUDIO&&u===U.FRAG_PARSING_ERROR||e.sourceBufferName==="audio"&&No(e))&&d.some(({audioCodec:M})=>s.audioCodec!==M),b=e.sourceBufferName==="video"&&No(e)&&d.some(({codecSet:M,audioCodec:p})=>s.codecSet!==M&&s.audioCodec===p),{type:D,groupId:_}=(a=e.context)!=null?a:{};for(let M=d.length;M--;){const p=(M+g)%d.length;if(p!==g&&p>=m&&p<=A&&(d[p].loadError===0||Ya(d[p],i.config.errorPenaltyExpireMs))){var o,l;const $=d[p];if(u===U.FRAG_GAP&&C===ge.MAIN&&e.frag){const N=d[p].details;if(N){const O=ji(e.frag,N.fragments,e.frag.start);if(O!=null&&O.gap)continue}}else{if(D===ke.AUDIO_TRACK&&$.hasAudioGroup(_)||D===ke.SUBTITLE_TRACK&&$.hasSubtitleGroup(_))continue;if(C===ge.AUDIO&&(o=s.audioGroups)!=null&&o.some(N=>$.hasAudioGroup(N))||C===ge.SUBTITLE&&(l=s.subtitleGroups)!=null&&l.some(N=>$.hasSubtitleGroup(N))||S&&s.audioCodec===$.audioCodec||b&&s.codecSet===$.codecSet||!S&&s.audioCodec!==$.audioCodec)continue}h=p;break}}if(h>-1&&i.loadLevel!==h)return e.levelRetry=!0,this.playlistError=0,{action:gt.SendAlternateToPenaltyBox,flags:dt.None,nextAutoLevel:h}}return{action:gt.SendAlternateToPenaltyBox,flags:dt.MoveAllAlternatesMatchingHost}}onErrorOut(e,t){var i,s;switch((i=t.errorAction)==null?void 0:i.action){case gt.DoNothing:break;case gt.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t),!t.errorAction.resolved&&t.details!==U.FRAG_GAP&&t.details!==U.PLAYLIST_UNCHANGED_ERROR&&!Bo(t)&&(t.fatal=!0);break}if((((s=t.errorAction)==null?void 0:s.flags)||0)&dt.ResetMediaSource&&this.hls.recoverMediaError(),t.fatal){this.hls.stopLoad();return}}sendAlternateToPenaltyBox(e){const t=this.hls,i=e.errorAction;if(!i)return;let s=i.nextAutoLevel;if(i.flags===dt.None)this.switchLevel(e,s);else if(i.flags&dt.SwitchToSDR){const o=this.hls.levels,l=o.length;for(let u=l;u--;)o[u].videoRange!=="SDR"?(o[u].fragmentError++,o[u].loadError++):s===void 0&&(s=u)}else if(i.flags&dt.MoveAllAlternatesMatchingHDCP){const o=this.getVariantLevelIndex(e.frag),l=t.levels[o],u=l?.attrs["HDCP-LEVEL"];i.hdcpLevel=u;const h=u==="NONE";u&&!h?(t.maxHdcpLevel=cr[cr.indexOf(u)-1],i.resolved=!0,this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`)):(h&&this.warn("HDCP policy resticted output with HDCP-LEVEL=NONE"),i.flags|=dt.MoveAllAlternatesMatchingKey)}if(i.flags&dt.MoveAllAlternatesMatchingKey){const o=e.decryptdata;if(o){const l=this.hls.levels,u=l.length;for(let d=u;d--;)if(this.variantHasKey(l[d],o)){var n,a;this.log(`Banned key found in level ${d} (${l[d].bitrate}bps) or audio group "${(n=l[d].audioGroups)==null?void 0:n.join(",")}" (${(a=e.frag)==null?void 0:a.type} fragment) ${ut(o.keyId||[])}`),l[d].fragmentError++,l[d].loadError++,this.log(`Removing level ${d} with key error (${e.error})`),this.hls.removeLevel(d)}const h=e.frag;if(this.hls.levels.length<u)i.resolved=!0;else if(h&&h.type!==ge.MAIN){const d=h.decryptdata;d&&!o.matches(d)&&(i.resolved=!0)}}}i.resolved||this.switchLevel(e,s)}switchLevel(e,t){if(t!==void 0&&e.errorAction&&(this.warn(`switching to level ${t} after ${e.details}`),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel,e.details===U.BUFFER_ADD_CODEC_ERROR&&e.mimeType&&e.sourceBufferName!=="audiovideo")){const i=ur(e.mimeType),s=this.hls.levels;for(let n=s.length;n--;)s[n][`${e.sourceBufferName}Codec`]===i&&(this.log(`Removing level ${n} for ${e.details} ("${i}" not supported)`),this.hls.removeLevel(n))}}}function No(r){const e=r.details;return e===U.BUFFER_ADD_CODEC_ERROR||e===U.MEDIA_SOURCE_REQUIRES_RESET||e===U.BUFFER_APPEND_ERROR&&!Bo(r)}function Bo(r){return r.details===U.BUFFER_APPEND_ERROR&&(r.error.name==="QuotaExceededError"||r.error.name==="InvalidStateError")}function ys(r){const e={action:gt.DoNothing,flags:dt.None};return r&&(e.resolved=!0),e}var et={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};class Sd{constructor(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}_registerListeners(){const{hls:e}=this;e&&(e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.BUFFER_APPENDED,this.onBufferAppended,this),e.on(E.FRAG_BUFFERED,this.onFragBuffered,this),e.on(E.FRAG_LOADED,this.onFragLoaded,this))}_unregisterListeners(){const{hls:e}=this;e&&(e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.BUFFER_APPENDED,this.onBufferAppended,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this),e.off(E.FRAG_LOADED,this.onFragLoaded,this))}destroy(){this._unregisterListeners(),this.hls=this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){const i=this.activePartLists[t];if(i)for(let s=i.length;s--;){const n=i[s];if(!n)break;if(n.start<=e&&e<=n.end&&n.loaded)return n}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){return this.getFragAtPos(e,t,!0)}getFragAtPos(e,t,i){const{fragments:s}=this,n=Object.keys(s);for(let a=n.length;a--;){const o=s[n[a]];if(o?.body.type===t&&(!i||o.buffered)){const l=o.body;if(l.start<=e&&e<=l.end)return l}}return null}detectEvictedFragments(e,t,i,s,n,a){this.timeRanges&&(this.timeRanges[e]=t);const o=n?.fragment.sn||-1;Object.keys(this.fragments).forEach(l=>{const u=this.fragments[l];if(!u||!this.hls)return;const h=u.body;if(o>=h.sn)return;if(!u.buffered&&(!u.loaded||a)){h.type===i&&this.removeFragment(h);return}const d=u.range[e];if(d){if(d.time.length===0){this.removeFragment(h);return}if(d.time.some(g=>{const m=!this.isTimeBuffered(g.startPTS,g.endPTS,t);return m&&this.removeFragment(h),m}),s&&s!==h&&ps()){const g=s.endPTS,m=h.startPTS;if(g&&m&&u.range.video){const A=m-g;A<0&&A>-.1&&(this.removeFragment(h),this.hls.trigger(E.BUFFER_FLUSHING,{startOffset:g+.004,endOffset:1/0,type:"video"}))}}}})}detectPartialFragments(e){const t=this.timeRanges,{frag:i,part:s,id:n}=e;if(!t||!st(i))return;const a=qi(i),o=this.fragments[a];if(!o||o.buffered&&i.gap)return;const l=!i.relurl;Object.keys(t).forEach(h=>{const d=i.elementaryStreams[h];if(!d)return;const g=t[h],m=l||d.partial===!0;o.range[h]=this.getBufferedTimes(i,s,m,g),this.detectEvictedFragments(h,g,n,i,s)}),o.loaded=null;const u=Object.keys(o.range);if(u.length){if(this.bufferedEnd(o,i),nn(o)||this.removeParts(i.sn-1,i.type),!s){const h=Math.min(.004,i.duration);u.some(d=>{var g;const m=(g=o.range[d])==null?void 0:g.time,A=m.length===0||m.length===1&&m[0].endPTS-m[0].startPTS<h;return A&&this.addAsGap(i),A})}}else this.removeFragment(i)}addAsGap(e){e.gap=!0,this.removeFragment(e),this.fragBuffered(e,!0)}bufferedEnd(e,t){e.buffered=!0,(e.body.endList=t.endList||e.body.endList)&&!t.gap&&(this.endListFragments[e.body.type]=e)}removeParts(e,t){const i=this.activePartLists[t];i&&(this.activePartLists[t]=Uo(i,s=>s.fragment.sn>=e))}fragBuffered(e,t){const i=qi(e);let s=this.fragments[i];return!s&&t&&(s=this.fragments[i]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),s&&(s.loaded=null,this.bufferedEnd(s,e)),s}getBufferedTimes(e,t,i,s){const n={time:[],partial:i},a=e.start,o=e.end,l=e.minEndPTS||o,u=e.maxStartPTS||a;for(let h=0;h<s.length;h++){const d=s.start(h)-this.bufferPadding,g=s.end(h)+this.bufferPadding;if(u>=d&&l<=g){n.time.push({startPTS:Math.max(a,s.start(h)),endPTS:Math.min(o,s.end(h))});break}else if(a<g&&o>d){const m=Math.max(a,s.start(h)),A=Math.min(o,s.end(h));A>m&&(n.partial=!0,n.time.push({startPTS:m,endPTS:A}))}else if(o<=d)break}return n}getPartialFragment(e){let t=null,i,s,n,a=0;const{bufferPadding:o,fragments:l}=this;return Object.keys(l).forEach(u=>{const h=l[u];h&&nn(h)&&(s=h.body.start-o,n=h.body.end+o,e>=s&&e<=n&&(i=Math.min(e-s,n-e),a<=i&&(t=h.body,a=i)))}),t}isEndListAppended(e){const t=this.endListFragments[e];return t!==void 0&&(t.buffered||nn(t))}getState(e){const t=qi(e),i=this.fragments[t];return i?i.buffered?nn(i)?et.PARTIAL:et.OK:et.APPENDING:et.NOT_LOADED}isTimeBuffered(e,t,i){let s,n;for(let a=0;a<i.length;a++){if(s=i.start(a)-this.bufferPadding,n=i.end(a)+this.bufferPadding,e>=s&&t<=n)return!0;if(t<=s)return!1}return!1}onManifestLoading(){this.removeAllFragments()}onFragLoaded(e,t){if(!st(t.frag)||t.frag.bitrateTest)return;const i=t.frag,s=t.part?null:t,n=qi(i);this.fragments[n]={body:i,appendedPTS:null,loaded:s,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){const{frag:i,part:s,timeRanges:n}=t;if(!st(i))return;const a=i.type;if(s){let o=this.activePartLists[a];o||(this.activePartLists[a]=o=[]),o.push(s)}this.timeRanges=n}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){const t=qi(e);return!!this.fragments[t]}hasFragments(e){const{fragments:t}=this,i=Object.keys(t);if(!e)return i.length>0;for(let s=i.length;s--;){const n=t[i[s]];if(n?.body.type===e)return!0}return!1}hasParts(e){var t;return!!((t=this.activePartLists[e])!=null&&t.length)}getBackBufferEvictionEnd(e,t,i){const{fragments:s}=this;let n=0,a=0;const o=Object.keys(s);for(let l=0;l<o.length;l++){const u=s[o[l]];if(!u||!u.buffered||u.body.type!==t)continue;const h=u.body;if(h.gap)return 0;const d=h.hasStats&&h.stats.loaded||h.byteLength||h.bitrate&&h.bitrate*8*h.duration;if(h.end<=e&&d&&(n+=d,a=Math.max(a,h.end),n>=i))return a}return a>0?a:0}removeFragmentsInRange(e,t,i,s,n){s&&!this.hasGaps||Object.keys(this.fragments).forEach(a=>{const o=this.fragments[a];if(!o)return;const l=o.body;l.type!==i||s&&!l.gap||l.start<t&&l.end>e&&(o.buffered||n)&&this.removeFragment(l)})}removeFragment(e){const t=qi(e);e.clearElementaryStreamInfo();const i=this.activePartLists[e.type];if(i){const s=e.sn;this.activePartLists[e.type]=Uo(i,n=>n.fragment.sn!==s)}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){var e;this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1;const t=(e=this.hls)==null||(e=e.latestLevelDetails)==null?void 0:e.partList;t&&t.forEach(i=>i.clearElementaryStreamInfo())}}function nn(r){var e,t,i,s;return r.buffered&&!!(r.body.gap||(e=r.range.video)!=null&&e.partial||(t=r.range.audio)!=null&&t.partial||(i=r.range.audiovideo)!=null&&i.partial||(s=r.range.subs)!=null&&s.partial)}function qi(r){return`${r.type}_${r.level}_${r.sn}`}function Uo(r,e){return r.filter(t=>{const i=e(t);return i||t.clearElementaryStreamInfo(),i})}var Si={cbc:0,ctr:1};class xd{constructor(e,t,i){this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=e,this.aesIV=t,this.aesMode=i}decrypt(e,t){switch(this.aesMode){case Si.cbc:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e);case Si.ctr:return this.subtle.decrypt({name:"AES-CTR",counter:this.aesIV,length:64},t,e);default:throw new Error(`[AESCrypto] invalid aes mode ${this.aesMode}`)}}}function bd(r){const e=r.byteLength,t=e&&new DataView(r.buffer).getUint8(e-1);return t?r.slice(0,e-t):r}class Ld{constructor(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}uint8ArrayToUint32Array_(e){const t=new DataView(e),i=new Uint32Array(4);for(let s=0;s<4;s++)i[s]=t.getUint32(s*4);return i}initTable(){const e=this.sBox,t=this.invSBox,i=this.subMix,s=i[0],n=i[1],a=i[2],o=i[3],l=this.invSubMix,u=l[0],h=l[1],d=l[2],g=l[3],m=new Uint32Array(256);let A=0,C=0,v=0;for(v=0;v<256;v++)v<128?m[v]=v<<1:m[v]=v<<1^283;for(v=0;v<256;v++){let S=C^C<<1^C<<2^C<<3^C<<4;S=S>>>8^S&255^99,e[A]=S,t[S]=A;const R=m[A],b=m[R],D=m[b];let _=m[S]*257^S*16843008;s[A]=_<<24|_>>>8,n[A]=_<<16|_>>>16,a[A]=_<<8|_>>>24,o[A]=_,_=D*16843009^b*65537^R*257^A*16843008,u[S]=_<<24|_>>>8,h[S]=_<<16|_>>>16,d[S]=_<<8|_>>>24,g[S]=_,A?(A=R^m[m[m[D^R]]],C^=m[m[C]]):A=C=1}}expandKey(e){const t=this.uint8ArrayToUint32Array_(e);let i=!0,s=0;for(;s<t.length&&i;)i=t[s]===this.key[s],s++;if(i)return;this.key=t;const n=this.keySize=t.length;if(n!==4&&n!==6&&n!==8)throw new Error("Invalid aes key size="+n);const a=this.ksRows=(n+6+1)*4;let o,l;const u=this.keySchedule=new Uint32Array(a),h=this.invKeySchedule=new Uint32Array(a),d=this.sBox,g=this.rcon,m=this.invSubMix,A=m[0],C=m[1],v=m[2],S=m[3];let R,b;for(o=0;o<a;o++){if(o<n){R=u[o]=t[o];continue}b=R,o%n===0?(b=b<<8|b>>>24,b=d[b>>>24]<<24|d[b>>>16&255]<<16|d[b>>>8&255]<<8|d[b&255],b^=g[o/n|0]<<24):n>6&&o%n===4&&(b=d[b>>>24]<<24|d[b>>>16&255]<<16|d[b>>>8&255]<<8|d[b&255]),u[o]=R=(u[o-n]^b)>>>0}for(l=0;l<a;l++)o=a-l,l&3?b=u[o]:b=u[o-4],l<4||o<=4?h[l]=b:h[l]=A[d[b>>>24]]^C[d[b>>>16&255]]^v[d[b>>>8&255]]^S[d[b&255]],h[l]=h[l]>>>0}networkToHostOrderSwap(e){return e<<24|(e&65280)<<8|(e&16711680)>>8|e>>>24}decrypt(e,t,i){const s=this.keySize+6,n=this.invKeySchedule,a=this.invSBox,o=this.invSubMix,l=o[0],u=o[1],h=o[2],d=o[3],g=this.uint8ArrayToUint32Array_(i);let m=g[0],A=g[1],C=g[2],v=g[3];const S=new Int32Array(e),R=new Int32Array(S.length);let b,D,_,M,p,$,N,O,W,q,z,oe,ne,J;const Z=this.networkToHostOrderSwap;for(;t<S.length;){for(W=Z(S[t]),q=Z(S[t+1]),z=Z(S[t+2]),oe=Z(S[t+3]),p=W^n[0],$=oe^n[1],N=z^n[2],O=q^n[3],ne=4,J=1;J<s;J++)b=l[p>>>24]^u[$>>16&255]^h[N>>8&255]^d[O&255]^n[ne],D=l[$>>>24]^u[N>>16&255]^h[O>>8&255]^d[p&255]^n[ne+1],_=l[N>>>24]^u[O>>16&255]^h[p>>8&255]^d[$&255]^n[ne+2],M=l[O>>>24]^u[p>>16&255]^h[$>>8&255]^d[N&255]^n[ne+3],p=b,$=D,N=_,O=M,ne=ne+4;b=a[p>>>24]<<24^a[$>>16&255]<<16^a[N>>8&255]<<8^a[O&255]^n[ne],D=a[$>>>24]<<24^a[N>>16&255]<<16^a[O>>8&255]<<8^a[p&255]^n[ne+1],_=a[N>>>24]<<24^a[O>>16&255]<<16^a[p>>8&255]<<8^a[$&255]^n[ne+2],M=a[O>>>24]<<24^a[p>>16&255]<<16^a[$>>8&255]<<8^a[N&255]^n[ne+3],R[t]=Z(b^m),R[t+1]=Z(M^A),R[t+2]=Z(_^C),R[t+3]=Z(D^v),m=W,A=q,C=z,v=oe,t=t+4}return R.buffer}}class Rd{constructor(e,t,i){this.subtle=void 0,this.key=void 0,this.aesMode=void 0,this.subtle=e,this.key=t,this.aesMode=i}expandKey(){const e=Dd(this.aesMode);return this.subtle.importKey("raw",this.key,{name:e},!1,["encrypt","decrypt"])}}function Dd(r){switch(r){case Si.cbc:return"AES-CBC";case Si.ctr:return"AES-CTR";default:throw new Error(`[FastAESKey] invalid aes mode ${r}`)}}const Pd=16;class hr{constructor(e,t){if(this.logEnabled=!0,this.decryptRange=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.enableSoftwareAES=void 0,this.enableSoftwareAES=e.enableSoftwareAES,t!==!0)try{const i=self.crypto;i&&(this.subtle=i.subtle||i.webkitSubtle)}catch{}this.useSoftware=!this.subtle}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}isSync(){return this.useSoftware}flush(){const{currentResult:e,remainderData:t}=this;if(!e||t)return this.reset(),null;const i=new Uint8Array(e);this.reset();const s=this.decryptRange;return s?s.start===0&&s.end>=i.length?i:i.slice(s.start,s.end):bd(i)}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,t,i,s,n){return this.decryptRange=n,this.useSoftware||n?new Promise((a,o)=>{const l=ArrayBuffer.isView(e)?e:new Uint8Array(e);this.softwareDecrypt(l,t,i,s);const u=this.flush();u?a(u.buffer):o(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,i,s)}softwareDecrypt(e,t,i,s){const{currentIV:n,currentResult:a,remainderData:o}=this;if(s!==Si.cbc||t.byteLength!==16)return Ge.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),o&&(e=Ut(o,e),this.remainderData=null);const l=this.getValidChunk(e);if(!l.length)return null;n&&(i=n);let u=this.softwareDecrypter;u||(u=this.softwareDecrypter=new Ld),u.expandKey(t);const h=a;return this.currentResult=u.decrypt(l.buffer,0,i),this.currentIV=l.slice(-16).buffer,h||null}webCryptoDecrypt(e,t,i,s){if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,i,s));this.key=t,this.fastAesKey=new Rd(this.subtle,t,s)}return this.fastAesKey.expandKey().then(n=>this.subtle?(this.logOnce("WebCrypto AES decrypt"),new xd(this.subtle,new Uint8Array(i),s).decrypt(e.buffer,n)):Promise.reject(new Error("web crypto not initialized"))).catch(n=>(Ge.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${n.name}: ${n.message}`),this.onWebCryptoError(e,t,i,s)))}onWebCryptoError(e,t,i,s){const n=this.enableSoftwareAES;if(n){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,i,s);const a=this.flush();if(a)return a.buffer}throw new Error("WebCrypto"+(n?" and softwareDecrypt":"")+": failed to decrypt data")}getValidChunk(e){let t=e;const i=e.length-e.length%Pd;return i!==e.length&&(t=e.slice(0,i),this.remainderData=e.slice(i)),t}logOnce(e){this.logEnabled&&(Ge.log(`[decrypter]: ${e}`),this.logEnabled=!1)}}const $o=Math.pow(2,17);class Go{constructor(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(e,t,i,s){const n=e.url;if(!n)return Promise.reject(new si({type:me.NETWORK_ERROR,details:U.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error(`Fragment does not have a ${n?"part list":"url"}`),networkDetails:null}));this.abort();const a=this.config,o=a.fLoader,l=a.loader;return new Promise((u,h)=>{if(this.loader&&this.loader.destroy(),e.gap)if(e.tagList.some(v=>v[0]==="GAP")){h(Vo(e));return}else e.gap=!1;const d=this.loader=o?new o(a):new l(a),g=Ho(e,null,t);e.loader=d;const m=Ka(a.fragLoadPolicy.default),A={loadPolicy:m,timeout:m.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:$o};d.stats.retry=e.stats.retry,e.stats=d.stats;const C={onSuccess:(v,S,R,b)=>{this.resetLoader(e,d);let D=v.data;R.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(D.slice(0,16)),D=D.slice(16)),u({frag:e,part:null,payload:D,networkDetails:b})},onError:(v,S,R,b)=>{this.resetLoader(e,d),h(new si({type:me.NETWORK_ERROR,details:U.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:Ae({url:n,data:void 0},v),error:new Error(`HTTP Error ${v.code} ${v.text}`),networkDetails:R,stats:b}))},onAbort:(v,S,R)=>{this.resetLoader(e,d),h(new si({type:me.NETWORK_ERROR,details:U.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:R,stats:v}))},onTimeout:(v,S,R)=>{this.resetLoader(e,d),h(new si({type:me.NETWORK_ERROR,details:U.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${A.timeout}ms`),networkDetails:R,stats:v}))}};if(i){const v=this.gateProgress(i,s);C.onProgress=(S,R,b,D)=>v({frag:e,part:null,payload:b,networkDetails:D})}d.load(g,A,C)})}gateProgress(e,t){let i=e;if(t){const s=[];let n=!1;t.then(()=>{n=!0,s.forEach(a=>e(a)),s.length=0}).catch(()=>{}),i=a=>{n?e(a):s.push(a)}}return i}loadPart(e,t,i){this.abort();const s=this.config,n=s.fLoader,a=s.loader;return new Promise((o,l)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap){l(Vo(e,t));return}const u=this.loader=n?new n(s):new a(s),h=Ho(e,t);e.loader=u;const d=Ka(s.fragLoadPolicy.default),g={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:$o};t.stats=u.stats,u.load(h,g,{onSuccess:(m,A,C,v)=>{this.resetLoader(e,u),this.updateStatsFromPart(e,t);const S={frag:e,part:t,payload:m.data,networkDetails:v};i(S),o(S)},onError:(m,A,C,v)=>{this.resetLoader(e,u),l(new si({type:me.NETWORK_ERROR,details:U.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:Ae({url:h.url,data:void 0},m),error:new Error(`HTTP Error ${m.code} ${m.text}`),networkDetails:C,stats:v}))},onAbort:(m,A,C)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,u),l(new si({type:me.NETWORK_ERROR,details:U.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:C,stats:m}))},onTimeout:(m,A,C)=>{this.resetLoader(e,u),l(new si({type:me.NETWORK_ERROR,details:U.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${g.timeout}ms`),networkDetails:C,stats:m}))}})})}updateStatsFromPart(e,t){const i=e.stats,s=t.stats,n=s.total;if(i.loaded+=s.loaded,n){const l=Math.round(e.duration/t.duration),u=Math.min(Math.round(i.loaded/n),l),d=(l-u)*Math.round(i.loaded/u);i.total=i.loaded+d}else i.total=Math.max(i.loaded,i.total);const a=i.loading,o=s.loading;a.start?a.first+=o.first-o.start:(a.start=o.start,a.first=o.first),a.end=o.end}resetLoader(e,t){e.loader=null,e.url=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}function Ho(r,e=null,t){const i=e||r,s={type:ke.MEDIA_FRAGMENT,frag:r,part:e,responseType:"arraybuffer",url:i.url,headers:{},rangeStart:0,rangeEnd:0},n=rn(r,e,t);return n.resetIV&&(s.resetIV=!0),n.byteRange&&(s.rangeStart=n.byteRange.start,s.rangeEnd=n.byteRange.end),s}function rn(r,e=null,t){const i={},s=e||r,n=s.byteRangeStartOffset,a=s.byteRangeEndOffset;if(se(n)&&se(a)){var o;if((r.sn==="initSegment"||t)&&_d((o=r.decryptdata)==null?void 0:o.method)){let l=Math.floor(n/16)*16;const u=Math.ceil(a/16)*16;i.decryptRange={start:n-l,end:a-l},l>=16&&(i.resetIV=!0,l=l-16),i.byteRange={start:l,end:u}}else i.byteRange={start:n,end:a}}return i}function Vo(r,e){const t=new Error(`GAP ${r.gap?"tag":"attribute"} found`),i={type:me.MEDIA_ERROR,details:U.FRAG_GAP,fatal:!1,frag:r,error:t,networkDetails:null};return e&&(i.part=e),(e||r).stats.aborted=!0,new si(i)}function _d(r){return r==="AES-128"||r==="AES-256"}class si extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}}class Ko extends wt{constructor(e,t){super(e,t),this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(e){return this._tickInterval?!1:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)}clearInterval(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1}clearNextTick(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1}tick(){this._tickCallCount++,this._tickCallCount===1?(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0):(this.log(`possible exception thrown in task-loop (${this.constructor.name}.doTick)`),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}class dr{constructor(e,t,i,s=0,n=-1,a=!1,o,l,u){this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.iframe=void 0,this.duration=void 0,this.decryptRange=void 0,this.transmuxing=an(),this.buffering={audio:an(),video:an(),audiovideo:an()},this.level=e,this.sn=t,this.id=i,this.size=s,this.part=n,this.partial=a,this.duration=o||0,this.decryptRange=u,this.iframe=l||!1}}function an(){return{start:0,executeStart:0,executeEnd:0,end:0}}const Yo={length:0,start:()=>0,end:()=>0};class ve{static isBuffered(e,t){if(e){const i=ve.getBuffered(e);for(let s=i.length;s--;)if(t>=i.start(s)&&t<=i.end(s))return!0}return!1}static bufferedRanges(e){if(e){const t=ve.getBuffered(e);return ve.timeRangesToArray(t)}return[]}static timeRangesToArray(e){const t=[];for(let i=0;i<e.length;i++)t.push({start:e.start(i),end:e.end(i)});return t}static bufferInfo(e,t,i){if(e){const s=ve.bufferedRanges(e);if(s.length)return ve.bufferedInfo(s,t,i)}return{len:0,start:t,end:t,bufferedIndex:-1}}static bufferedInfo(e,t,i){t=Math.max(0,t),e.length>1&&e.sort((h,d)=>h.start-d.start||d.end-h.end);let s=-1,n=[];if(i)for(let h=0;h<e.length;h++){t>=e[h].start&&t<=e[h].end&&(s=h);const d=n.length;if(d){const g=n[d-1].end;e[h].start-g<i?e[h].end>g&&(n[d-1].end=e[h].end):n.push(e[h])}else n.push(e[h])}else n=e;let a=0,o,l=t,u=t;for(let h=0;h<n.length;h++){const d=n[h].start,g=n[h].end;if(s===-1&&t>=d&&t<=g&&(s=h),t+i>=d&&t<g)l=d,u=g,a=u-t;else if(t+i<d){o=d;break}}return{len:a,start:l||0,end:u||0,nextStart:o,buffered:e,bufferedIndex:s}}static getBuffered(e){try{return e.buffered||Yo}catch(t){return Ge.log("failed to get media.buffered",t),Yo}}}const fr=/\{\$([a-zA-Z0-9-_]+)\}/g;function Wo(r){return fr.lastIndex=0,fr.test(r)}function gr(r,e){if(r.variableList!==null||r.hasVariableRefs){const t=r.variableList;return e.replace(fr,i=>{const s=i.substring(2,i.length-1),n=t?.[s];return n===void 0?(r.playlistParsingError||(r.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${s}"`)),i):n})}return e}function jo(r,e,t){let i=r.variableList;i||(r.variableList=i={});let s,n;if("QUERYPARAM"in e){s=e.QUERYPARAM;try{const a=new self.URL(t).searchParams;if(a.has(s))n=a.get(s);else throw new Error(`"${s}" does not match any query parameter in URI: "${t}"`)}catch(a){r.playlistParsingError||(r.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${a.message}`))}}else s=e.NAME,n=e.VALUE;s in i?r.playlistParsingError||(r.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${s}"`)):i[s]=n||""}function kd(r,e,t){const i=e.IMPORT;if(t&&i in t){let s=r.variableList;s||(r.variableList=s={}),s[i]=t[i]}else r.playlistParsingError||(r.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${i}"`))}const wd=/^(\d+)x(\d+)$/,qo=/(.+?)=(".*?"|.*?)(?:,|$)/g;class tt{constructor(e,t){typeof e=="string"&&(e=tt.parseAttrList(e,t)),je(this,e)}get clientAttrs(){return Object.keys(this).filter(e=>e.substring(0,2)==="X-")}decimalInteger(e){const t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}hexadecimalInteger(e){if(this[e]){let t=(this[e]||"0x").slice(2);t=(t.length&1?"0":"")+t;const i=new Uint8Array(t.length/2);for(let s=0;s<t.length/2;s++)i[s]=parseInt(t.slice(s*2,s*2+2),16);return i}return null}hexadecimalIntegerAsNumber(e){const t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,t){const i=this[e];return i?parseFloat(i):t}enumeratedString(e){return this[e]}enumeratedStringList(e,t){const i=this[e];return(i?i.split(/[ ,]+/):[]).reduce((s,n)=>(s[n.toLowerCase()]=!0,s),t)}bool(e){return this[e]==="YES"}decimalResolution(e){const t=wd.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e,t){let i;const s={};for(qo.lastIndex=0;(i=qo.exec(e))!==null;){const a=i[1].trim();let o=i[2];const l=o.indexOf('"')===0&&o.lastIndexOf('"')===o.length-1;let u=!1;if(l)o=o.slice(1,-1);else switch(a){case"IV":case"SCTE35-CMD":case"SCTE35-IN":case"SCTE35-OUT":u=!0}if(t&&(l||u))o=gr(t,o);else if(!u&&!l)switch(a){case"CLOSED-CAPTIONS":if(o==="NONE")break;case"ALLOWED-CPC":case"CLASS":case"ASSOC-LANGUAGE":case"AUDIO":case"BYTERANGE":case"CHANNELS":case"CHARACTERISTICS":case"CODECS":case"DATA-ID":case"END-DATE":case"GROUP-ID":case"ID":case"IMPORT":case"INSTREAM-ID":case"KEYFORMAT":case"KEYFORMATVERSIONS":case"LANGUAGE":case"NAME":case"PATHWAY-ID":case"QUERYPARAM":case"RECENTLY-REMOVED-DATERANGES":case"SERVER-URI":case"STABLE-RENDITION-ID":case"STABLE-VARIANT-ID":case"START-DATE":case"SUBTITLES":case"SUPPLEMENTAL-CODECS":case"URI":case"VALUE":case"VIDEO":case"X-ASSET-LIST":case"X-ASSET-URI":Ge.warn(`${e}: attribute ${a} is missing quotes`)}s[a]=o}return s}}const Md="com.apple.hls.interstitial";function Od(r){return r!=="ID"&&r!=="CLASS"&&r!=="CUE"&&r!=="START-DATE"&&r!=="DURATION"&&r!=="END-DATE"&&r!=="END-ON-NEXT"}function Fd(r){return r==="SCTE35-OUT"||r==="SCTE35-IN"||r==="SCTE35-CMD"}class zo{constructor(e,t,i=0){var s;if(this.attr=void 0,this.tagAnchor=void 0,this.tagOrder=void 0,this._startDate=void 0,this._endDate=void 0,this._dateAtEnd=void 0,this._cue=void 0,this._badValueForSameId=void 0,this.tagAnchor=t?.tagAnchor||null,this.tagOrder=(s=t?.tagOrder)!=null?s:i,t){const n=t.attr;for(const a in n)if(Object.prototype.hasOwnProperty.call(e,a)&&e[a]!==n[a]){Ge.warn(`DATERANGE tag attribute: "${a}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=a;break}e=je(new tt({}),n,e)}if(this.attr=e,t?(this._startDate=t._startDate,this._cue=t._cue,this._endDate=t._endDate,this._dateAtEnd=t._dateAtEnd):this._startDate=new Date(e["START-DATE"]),"END-DATE"in e){const n=t?.endDate||new Date(e["END-DATE"]);se(n.getTime())&&(this._endDate=n)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get cue(){const e=this._cue;return e===void 0?this._cue=this.attr.enumeratedStringList(this.attr.CUE?"CUE":"X-CUE",{pre:!1,post:!1,once:!1}):e}get startTime(){const{tagAnchor:e}=this;return e===null||e.programDateTime===null?(Ge.warn(`Expected tagAnchor Fragment with PDT set for DateRange "${this.id}": ${e}`),NaN):e.start+(this.startDate.getTime()-e.programDateTime)/1e3}get startDate(){return this._startDate}get endDate(){const e=this._endDate||this._dateAtEnd;if(e)return e;const t=this.duration;return t!==null?this._dateAtEnd=new Date(this._startDate.getTime()+t*1e3):null}get duration(){if("DURATION"in this.attr){const e=this.attr.decimalFloatingPoint("DURATION");if(se(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isInterstitial(){return this.class===Md}get isValid(){return!!this.id&&!this._badValueForSameId&&se(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)&&(!this.attr.CUE||!this.cue.pre&&!this.cue.post||this.cue.pre!==this.cue.post)&&(!this.isInterstitial||"X-ASSET-URI"in this.attr||"X-ASSET-LIST"in this.attr)}get invalidReason(){return this.id?this._badValueForSameId?`Date range ${this._badValueForSameId} mismatch`:se(this.startDate.getTime())?this.isInterstitial&&!("X-ASSET-URI"in this.attr||"X-ASSET-LIST"in this.attr)?"Interstitial Date range missing X-ASSET-(LIST|URI)":this.isValid?null:"Unknown (check DURATION(|END|NEXT), CLASS, and CUE)":"Date range invalid start date":"Missing ID"}}const Xo=10;class Nd{constructor(e){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.dateRangeTagCount=0,this.live=!0,this.iframesOnly=!1,this.requestScheduled=-1,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.appliedTimelineOffset=void 0,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}reloaded(e){if(!e){this.advanced=!0,this.updated=!0;return}const t=this.lastPartSn-e.lastPartSn,i=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!i||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||t===0&&i>0,this.updated||this.advanced?this.misses=0:this.misses=e.misses+1}hasKey(e){return this.encryptedFragments.some(t=>{let i=t.decryptdata;return i||(t.setKeyFormat(e.keyFormat),i=t.decryptdata),!!i&&e.matches(i)})}get hasProgramDateTime(){return this.fragments.length?se(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||Xo}get drift(){const e=this.driftEndTime-this.driftStartTime;return e>0?(this.driftEnd-this.driftStart)*1e3/e:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){return this.fragments.length?this.fragments[this.fragments.length-1].end:0}get fragmentStart(){return this.fragments.length?this.fragments[0].start:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].index:-1}get maxPartIndex(){const e=this.partList;if(e){const t=this.lastPartIndex;if(t!==-1){for(let i=e.length;i--;)if(e[i].index>t)return e[i].index;return t}}return 0}get lastPartSn(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}get expired(){if(this.live&&this.age&&this.misses<3){const e=this.partEnd-this.fragmentStart;return this.age>Math.max(e,this.totalduration)+this.levelTargetDuration}return!1}}function on(r,e){return r.length===e.length?!r.some((t,i)=>t!==e[i]):!1}function Zo(r,e){return!r&&!e?!0:!r||!e?!1:on(r,e)}function zi(r){return r==="AES-128"||r==="AES-256"||r==="AES-256-CTR"}function pr(r){switch(r){case"AES-128":case"AES-256":return Si.cbc;case"AES-256-CTR":return Si.ctr;default:throw new Error(`invalid full segment method ${r}`)}}function mr(r){return Uint8Array.from(unescape(encodeURIComponent(r)),e=>e.charCodeAt(0))}function Bd(r){const e=mr(r).subarray(0,16),t=new Uint8Array(16);return t.set(e,16-e.length),t}function Qo(r){const e=function(i,s,n){const a=i[s];i[s]=i[n],i[n]=a};e(r,0,3),e(r,1,2),e(r,4,5),e(r,6,7)}function Jo(r){const e=r.split(":");let t=null;if(e[0]==="data"&&e.length===2){const i=e[1].split(";"),s=i[i.length-1].split(",");if(s.length===2){const n=s[0]==="base64",a=s[1];n?(i.splice(-1,1),t=Jn(a)):t=Bd(a)}}return t}const ln=typeof self<"u"?self:void 0;var Je={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},pt={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function un(r){switch(r){case pt.FAIRPLAY:return Je.FAIRPLAY;case pt.PLAYREADY:return Je.PLAYREADY;case pt.WIDEVINE:return Je.WIDEVINE;case pt.CLEARKEY:return Je.CLEARKEY}}var el={WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function Ar(r){switch(r){case Je.FAIRPLAY:return pt.FAIRPLAY;case Je.PLAYREADY:return pt.PLAYREADY;case Je.WIDEVINE:return pt.WIDEVINE;case Je.CLEARKEY:return pt.CLEARKEY}}function vs(r){const{drmSystems:e,widevineLicenseUrl:t}=r,i=e?[Je.FAIRPLAY,Je.WIDEVINE,Je.PLAYREADY,Je.CLEARKEY].filter(s=>!!e[s]):[];return!i[Je.WIDEVINE]&&t&&i.push(Je.WIDEVINE),i}const tl=(function(r){return ln!=null&&(r=ln.navigator)!=null&&r.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null})();function Ud(r,e,t,i){let s;switch(r){case Je.FAIRPLAY:s=["cenc","sinf"];break;case Je.WIDEVINE:case Je.PLAYREADY:s=["cenc"];break;case Je.CLEARKEY:s=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${r}`)}return $d(s,e,t,i)}function $d(r,e,t,i){return[{initDataTypes:r,persistentState:i.persistentState||"optional",distinctiveIdentifier:i.distinctiveIdentifier||"optional",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:e.map(n=>({contentType:`audio/mp4; codecs=${n}`,robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null})),videoCapabilities:t.map(n=>({contentType:`video/mp4; codecs=${n}`,robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null}))}]}function Gd(r){var e;return!!r&&(r.sessionType==="persistent-license"||!!((e=r.sessionTypes)!=null&&e.some(t=>t==="persistent-license")))}function Ir(r){const e=new Uint16Array(r.buffer,r.byteOffset,r.byteLength/2),t=Yt(e),i=t.substring(t.indexOf("<"),t.length),a=new DOMParser().parseFromString(i,"text/xml").getElementsByTagName("KID")[0];if(a){const o=a.childNodes[0]?a.childNodes[0].nodeValue:a.getAttribute("VALUE");if(o){const l=Jn(o).subarray(0,16);return Qo(l),l}}return null}let Xi={};class gi{static clearKeyUriToKeyIdMap(){Xi={}}static setKeyIdForUri(e,t){Xi[e]=t}static addKeyIdForUri(e){const t=Object.keys(Xi).length%Number.MAX_SAFE_INTEGER,i=new Uint8Array(16);return new DataView(i.buffer,12,4).setUint32(0,t),Xi[e]=i,i}constructor(e,t,i,s=[1],n=null,a){this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.scheme=void 0,this.method=e,this.uri=t,this.keyFormat=i,this.keyFormatVersions=s,this.iv=n,this.encrypted=e?e!=="NONE":!1,this.isCommonEncryption=this.encrypted&&!zi(e),a!=null&&a.startsWith("0x")&&(this.keyId=new Uint8Array(eo(a)))}matches(e){return e.uri===this.uri&&e.method===this.method&&e.encrypted===this.encrypted&&e.keyFormat===this.keyFormat&&on(e.keyFormatVersions,this.keyFormatVersions)&&Zo(e.iv,this.iv)&&Zo(e.keyId,this.keyId)}isSupported(){if(this.method){if(zi(this.method)||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES";switch(this.keyFormat){case pt.FAIRPLAY:case pt.WIDEVINE:case pt.PLAYREADY:case pt.CLEARKEY:return["SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1}getDecryptData(e,t){var i;if(!this.encrypted||!this.uri)return null;if(zi(this.method)){let a=this.iv;return a||(typeof e!="number"&&(Ge.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0),a=Vd(e)),new gi(this.method,this.uri,"identity",this.keyFormatVersions,a)}if(this.keyId){const a=Xi[this.uri];if(a&&!on(this.keyId,a)&&gi.setKeyIdForUri(this.uri,this.keyId),this.pssh)return this}const s=Jo(this.uri);if(s)switch(this.keyFormat){case pt.WIDEVINE:if(this.pssh=s,!this.keyId){const a=po(s.buffer).filter(o=>o.systemId===el.WIDEVINE);if(a.length){var n;const o=a[0];this.keyId=(n=o.kids)!=null&&n.length?o.kids[0]:null}}this.keyId||(this.keyId=il(t));break;case pt.PLAYREADY:{const a=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=Kh(a,null,s),this.keyId=Ir(s);break}default:{let a=s.subarray(0,16);if(a.length!==16){const o=new Uint8Array(16);o.set(a,16-a.length),a=o}this.keyId=a;break}}if(((i=this.keyId)==null?void 0:i.byteLength)!==16){let a;a=Hd(t),a||(a=il(t),a||(a=Xi[this.uri])),a&&(this.keyId=a,gi.setKeyIdForUri(this.uri,a))}return this}}function Hd(r){const e=r?.[pt.WIDEVINE];return e?e.keyId:null}function il(r){const e=r?.[pt.PLAYREADY];if(e){const t=Jo(e.uri);if(t)return Ir(t)}return null}function Vd(r){const e=new Uint8Array(16);for(let t=12;t<16;t++)e[t]=r>>8*(15-t)&255;return e}const sl=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(I-FRAME-STREAM-INF|SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)(?:[\r\n]+|$)/g,nl=/#EXT-X-MEDIA:(.*)/g,Kd=/^#EXT(?:INF|-X-TARGETDURATION):/m,Cr=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),Yd=new RegExp([/#EXT-X-(PROGRAM-DATE-TIME|BYTERANGE|DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP|INDEPENDENT-SEGMENTS|I-FRAMES-ONLY)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|"));class ni{static findGroup(e,t){for(let i=0;i<e.length;i++){const s=e[i];if(s.id===t)return s}}static resolve(e,t){return Vn.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return Kd.test(e)}static parseMasterPlaylist(e,t){const i=Wo(e),s={contentSteering:null,levels:[],iframeVariants:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:i},n=[];if(sl.lastIndex=0,!e.startsWith("#EXTM3U"))return s.playlistParsingError=new Error("no EXTM3U delimiter"),s;let a;for(;(a=sl.exec(e))!=null;)if(a[1]){const l=new tt(a[1],s),u=rl(l,a[2],t,s,n);u&&s.levels.push(u)}else if(a[3]){const l=a[3],u=a[4];switch(l){case"I-FRAME-STREAM-INF":{const h=new tt(u,s),d=rl(h,h.URI,t,s,n,!0);d&&s.iframeVariants.push(d)}break;case"SESSION-DATA":{const h=new tt(u,s),d=h["DATA-ID"];d&&(s.sessionData===null&&(s.sessionData={}),s.sessionData[d]=h);break}case"SESSION-KEY":{const h=ol(u,t,s);h.encrypted&&h.isSupported()?(s.sessionKeys===null&&(s.sessionKeys=[]),s.sessionKeys.push(h)):Ge.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${u}"`);break}case"DEFINE":{{const h=new tt(u,s);jo(s,h,t)}break}case"CONTENT-STEERING":{const h=new tt(u,s);s.contentSteering={uri:ni.resolve(h["SERVER-URI"],t),pathwayId:h["PATHWAY-ID"]||"."};break}case"START":{s.startTimeOffset=ll(u);break}}}const o=n.length>0&&n.length<s.levels.length;return s.levels=o?n:s.levels,s.levels.length===0&&(s.playlistParsingError=new Error("no levels found in manifest")),s}static parseMasterPlaylistMedia(e,t,i){let s;const n={},a=i.levels,o={AUDIO:a.map(u=>({id:u.attrs.AUDIO,audioCodec:u.audioCodec})),SUBTITLES:a.map(u=>({id:u.attrs.SUBTITLES,textCodec:u.textCodec})),"CLOSED-CAPTIONS":[]};let l=0;for(nl.lastIndex=0;(s=nl.exec(e))!==null;){const u=new tt(s[1],i),h=u.TYPE;if(h){const d=o[h],g=n[h]||[];n[h]=g;const m=u.LANGUAGE,A=u["ASSOC-LANGUAGE"],C=u.CHANNELS,v=u.CHARACTERISTICS,S=u["INSTREAM-ID"],R={attrs:u,bitrate:0,id:l++,groupId:u["GROUP-ID"]||"",name:u.NAME||m||"",type:h,default:u.bool("DEFAULT"),autoselect:u.bool("AUTOSELECT"),forced:u.bool("FORCED"),lang:m,url:u.URI?ni.resolve(u.URI,t):""};if(A&&(R.assocLang=A),C&&(R.channels=C),v&&(R.characteristics=v),S&&(R.instreamId=S),d!=null&&d.length){const b=ni.findGroup(d,R.groupId)||d[0];cl(R,b,"audioCodec"),cl(R,b,"textCodec")}g.push(R)}}return n}static parseLevelPlaylist(e,t,i,s,n,a){var o;const l={url:t},u=new Nd(t),h=u.fragments,d=[];let g=null,m=0,A=0,C=0,v=0,S=0,R=null,b=new Gs(s,l),D,_,M,p=-1,$=!1,N=null,O;if(Cr.lastIndex=0,u.m3u8=e,u.hasVariableRefs=Wo(e),((o=Cr.exec(e))==null?void 0:o[0])!=="#EXTM3U")return u.playlistParsingError=new Error("Missing format identifier #EXTM3U"),u;for(;(D=Cr.exec(e))!==null;){$&&($=!1,b=new Gs(s,l),b.playlistOffset=C,b.setStart(C),b.sn=m,b.cc=v,S&&(b.bitrate=S),b.level=i,g&&(b.initSegment=g,g.rawProgramDateTime&&(b.rawProgramDateTime=g.rawProgramDateTime,g.rawProgramDateTime=null),N&&(b.setByteRange(N),N=null)));const ne=D[1];if(ne){b.duration=parseFloat(ne);const J=(" "+D[2]).slice(1);b.title=J||null,b.tagList.push(J?["INF",ne,J]:["INF",ne])}else if(D[3]){if(se(b.duration)){var W;b.playlistOffset=C,b.setStart(C),M&&dl(b,M,u),b.sn=m,b.level=i,b.cc=v;const J=(" "+D[3]).slice(1);b.relurl=gr(u,J),yr(b,R,d),R=b,C+=b.duration,m++,A=0;const Z=b.byteRange;if(Z.length===2&&(b.bitrate=(Z[1]-Z[0])*8/b.duration|0),u.iframesOnly&&Z[0]&&((W=g)==null?void 0:W.cc)!==v){const Q=new Gs(s,l);Q.relurl=b.relurl,Q.setByteRange(`${Math.min(Z[0],1316)}@0`),Q.level=i,Q.sn="initSegment",M&&(Q.levelkeys=M,M.identity&&(Q._decryptdata=M.identity.getDecryptData(0))),g=Q,b.initSegment=g}h.push(b),$=!0}}else{if(D=D[0].match(Yd),!D){Ge.warn("No matches on slow regex match for level playlist!");continue}for(_=1;_<D.length&&D[_]===void 0;_++);const J=(" "+D[_]).slice(1),Z=(" "+D[_+1]).slice(1),Q=D[_+2]?(" "+D[_+2]).slice(1):null;switch(J){case"BYTERANGE":R?b.setByteRange(Z,R):b.setByteRange(Z);break;case"PROGRAM-DATE-TIME":b.rawProgramDateTime=Z,b.tagList.push(["PROGRAM-DATE-TIME",Z]),p===-1&&(p=h.length);break;case"PLAYLIST-TYPE":u.type&&pi(u,J,D),u.type=Z.toUpperCase();break;case"MEDIA-SEQUENCE":u.startSN!==0?pi(u,J,D):R!==null&&qd(u,J,D),u.startSN=parseInt(Z),m=u.startSN+u.skippedSegments;break;case"SKIP":{u.skippedSegments&&pi(u,J,D);const ee=new tt(Z,u),he=ee.decimalInteger("SKIPPED-SEGMENTS");if(se(he)){u.skippedSegments+=he;for(let re=he;re--;)h.push(null);m+=he}const te=ee.enumeratedString("RECENTLY-REMOVED-DATERANGES");te&&(u.recentlyRemovedDateranges=(u.recentlyRemovedDateranges||[]).concat(te.split(" ")));break}case"TARGETDURATION":u.targetduration!==0&&pi(u,J,D),u.targetduration=Math.max(parseInt(Z),1);break;case"VERSION":u.version!==null&&pi(u,J,D),u.version=parseInt(Z);break;case"INDEPENDENT-SEGMENTS":break;case"I-FRAMES-ONLY":u.iframesOnly=!0;break;case"ENDLIST":u.live||pi(u,J,D),u.live=!1;break;case"#":(Z||Q)&&b.tagList.push(Q?[Z,Q]:[Z]);break;case"DISCONTINUITY":v++,b.tagList.push(["DIS"]);break;case"GAP":b.gap=!0,b.tagList.push([J]);break;case"BITRATE":b.tagList.push([J,Z]),S=parseInt(Z)*1e3,se(S)?b.bitrate=S:S=0;break;case"DATERANGE":{const ee=new tt(Z,u),he=new zo(ee,u.dateRanges[ee.ID],u.dateRangeTagCount);u.dateRangeTagCount++,he.isValid||u.skippedSegments?u.dateRanges[he.id]=he:Ge.log(`Ignoring invalid DATERANGE tag: ${he.invalidReason}: ${Z}`),b.tagList.push(["EXT-X-DATERANGE",Z]);break}case"DEFINE":{{const ee=new tt(Z,u);"IMPORT"in ee?kd(u,ee,a):jo(u,ee,t)}break}case"DISCONTINUITY-SEQUENCE":u.startCC!==0&&pi(u,J,D),u.startCC=v=parseInt(Z),h.forEach(ee=>ee&&(ee.cc=v));break;case"KEY":{const ee=ol(Z,t,u);if(ee.isSupported()){if(ee.method==="NONE"){M=void 0;break}M||(M={});const he=M[ee.keyFormat];he!=null&&he.matches(ee)||(he&&(M=je({},M)),M[ee.keyFormat]=ee)}else Ge.warn(`[Keys] Ignoring unsupported EXT-X-KEY tag: "${Z}"`);break}case"START":u.startTimeOffset=ll(Z);break;case"MAP":{const ee=new tt(Z,u);if(b.duration){const he=new Gs(s,l);hl(he,ee,i,M),g=he,b.initSegment=g,g.rawProgramDateTime&&!b.rawProgramDateTime&&(b.rawProgramDateTime=g.rawProgramDateTime)}else{const he=b.byteRangeEndOffset;if(he){const te=b.byteRangeStartOffset;N=`${he-te}@${te}`}else N=null;hl(b,ee,i,M),g=b,$=!0}g.cc=v;break}case"SERVER-CONTROL":{O&&pi(u,J,D),O=new tt(Z),u.canBlockReload=O.bool("CAN-BLOCK-RELOAD"),u.canSkipUntil=O.optionalFloat("CAN-SKIP-UNTIL",0),u.canSkipDateRanges=u.canSkipUntil>0&&O.bool("CAN-SKIP-DATERANGES"),u.partHoldBack=O.optionalFloat("PART-HOLD-BACK",0),u.holdBack=O.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{u.partTarget&&pi(u,J,D);const ee=new tt(Z);u.partTarget=ee.decimalFloatingPoint("PART-TARGET");break}case"PART":{let ee=u.partList;ee||(ee=u.partList=[]);const he=A>0?ee[ee.length-1]:void 0,te=A++,re=new tt(Z,u),Ee=new Qc(re,b,l,te,he);ee.push(Ee),b.duration+=Ee.duration;break}case"PRELOAD-HINT":{const ee=new tt(Z,u);u.preloadHint=ee;break}case"RENDITION-REPORT":{const ee=new tt(Z,u);u.renditionReports=u.renditionReports||[],u.renditionReports.push(ee);break}default:Ge.warn(`line parsed but not handled: ${D}`);break}}}R&&!R.relurl?(h.pop(),C-=R.duration,u.partList&&(u.fragmentHint=R)):u.partList&&(yr(b,R,d),b.cc=v,u.fragmentHint=b,M&&dl(b,M,u)),u.targetduration||(u.playlistParsingError=new Error("Missing Target Duration"));const q=h.length,z=h[0],oe=h[q-1];if(C+=u.skippedSegments*u.targetduration,C>0&&q&&oe){u.averagetargetduration=C/q;const ne=oe.sn;u.endSN=ne!=="initSegment"?ne:0,u.live||(oe.endList=!0),p>0&&(jd(h,p,p>q-1?b:null),z&&d.unshift(z))}return u.fragmentHint&&(C+=u.fragmentHint.duration),u.totalduration=C,d.length&&u.dateRangeTagCount&&z&&al(d,u),u.endCC=v,u}}function rl(r,e,t,i,s,n){var a;if(e===void 0)return null;const o=gr(i,e),l={attrs:r,bitrate:r.decimalInteger("BANDWIDTH")||r.decimalInteger("AVERAGE-BANDWIDTH"),name:r.NAME,url:ni.resolve(o,t)},u=r.decimalResolution("RESOLUTION");u&&(l.width=u.width,l.height=u.height),ul(r.CODECS,l);const h=r["SUPPLEMENTAL-CODECS"];return h&&(l.supplemental={},ul(h,l.supplemental)),(a=l.unknownCodecs)!=null&&a.length||s.push(l),n&&(l.iframes=!0),l}function al(r,e){let t=r.length;if(!t)if(e.hasProgramDateTime){const o=e.fragments[e.fragments.length-1];r.push(o),t++}else return;const i=r[t-1],s=e.live?1/0:e.totalduration,n=Object.keys(e.dateRanges);for(let o=n.length;o--;){const l=e.dateRanges[n[o]],u=l.startDate.getTime();l.tagAnchor=i.ref;for(let h=t;h--;){var a;if(((a=r[h])==null?void 0:a.sn)<e.startSN)break;const d=Wd(e,u,r,h,s);if(d){l.tagAnchor=d.ref;break}}}}function Wd(r,e,t,i,s){const n=t[i];if(n){const o=n.programDateTime;if(e>=o||i===0){var a;const l=(((a=t[i+1])==null?void 0:a.start)||s)-n.start;if(e<=o+l*1e3){const u=n.sn-r.startSN,h=r.fragments;if(u>=0&&u<h.length){if(h.length>t.length){const d=t[i+1]||h[h.length-1],g=Math.min(d.sn-r.startSN,h.length-1);for(let m=g;m>u;m--){const A=h[m].programDateTime;if(e>=A&&e<A+h[m].duration*1e3)return h[m]}}return h[u]}}}}return null}function ol(r,e,t){var i,s;const n=new tt(r,t),a=(i=n.METHOD)!=null?i:"",o=n.URI,l=n.hexadecimalInteger("IV"),u=n.KEYFORMATVERSIONS,h=(s=n.KEYFORMAT)!=null?s:"identity";o&&n.IV&&!l&&Ge.error(`Invalid IV: ${n.IV}`);const d=o?ni.resolve(o,e):"",g=(u||"1").split("/").map(Number).filter(Number.isFinite);return new gi(a,d,h,g,l,n.KEYID)}function ll(r){const t=new tt(r).decimalFloatingPoint("TIME-OFFSET");return se(t)?t:null}function ul(r,e){let t=(r||"").split(/[ ,]+/).filter(i=>i);["video","audio","text","image"].forEach(i=>{const s=t.filter(n=>ar(n,i));s.length&&(e[`${i}Codec`]=s.map(n=>n.split("/")[0]).join(","),t=t.filter(n=>s.indexOf(n)===-1))}),e.unknownCodecs=t}function cl(r,e,t){const i=e[t];i&&(r[t]=i)}function jd(r,e,t){if(t||(t=r[e]),!!t)for(let i=e;i--;){const s=r[i];if(!s)return;s.programDateTime=t.programDateTime-s.duration*1e3,t=s}}function yr(r,e,t){r.rawProgramDateTime?t.push(r):e!=null&&e.programDateTime&&(r.programDateTime=e.endProgramDateTime)}function hl(r,e,t,i){r.relurl=e.URI,e.BYTERANGE&&r.setByteRange(e.BYTERANGE),r.level=t,r.sn="initSegment",i&&(r.levelkeys=i),r.initSegment=null}function dl(r,e,t){r.levelkeys=e;const{encryptedFragments:i}=t;(!i.length||i[i.length-1].levelkeys!==e)&&Object.keys(e).some(s=>e[s].isCommonEncryption)&&i.push(r)}function pi(r,e,t){r.playlistParsingError=new Error(`#EXT-X-${e} must not appear more than once (${t[0]})`)}function qd(r,e,t){r.playlistParsingError=new Error(`#EXT-X-${e} must appear before the first Media Segment (${t[0]})`)}function vr(r,e){const t=e.startPTS;if(se(t)){let i=0,s;e.sn>r.sn?(i=t-r.start,s=r):(i=r.start-t,s=e),s.duration!==i&&s.setDuration(i)}else e.sn>r.sn?r.cc===e.cc&&r.minEndPTS?e.setStart(r.start+(r.minEndPTS-r.start)):e.setStart(r.start+r.duration):e.setStart(Math.max(r.start-e.duration,0))}function fl(r,e,t,i,s,n,a,o){i-t<=0&&(o.warn("Fragment should have a positive duration",e),i=t+e.duration,n=s+e.duration);let u=t,h=i;const d=e.startPTS,g=e.endPTS;if(se(d)){const R=Math.abs(d-t);r&&R>r.totalduration?o.warn(`media timestamps and playlist times differ by ${R}s for level ${e.level} ${r.url}`):se(e.deltaPTS)?e.deltaPTS=Math.max(R,e.deltaPTS):e.deltaPTS=R,u=Math.max(t,d),t=Math.min(t,d),s=e.startDTS!==void 0?Math.min(s,e.startDTS):s,h=Math.min(i,g),i=Math.max(i,g),n=e.endDTS!==void 0?Math.max(n,e.endDTS):n}const m=t-e.start;e.start!==0&&e.setStart(t),e.setDuration(i-e.start),e.startPTS=t,e.maxStartPTS=u,e.startDTS=s,e.endPTS=i,e.minEndPTS=h,e.endDTS=n;const A=e.sn;if(!r||A<r.startSN||A>r.endSN)return 0;let C;const v=A-r.startSN,S=r.fragments;for(S[v]=e,C=v;C>0;C--)vr(S[C],S[C-1]);for(C=v;C<S.length-1;C++)vr(S[C],S[C+1]);return r.fragmentHint&&vr(S[S.length-1],r.fragmentHint),r.PTSKnown=r.alignedSliding=!0,m}function zd(r,e,t){if(r===e)return;let i=null;const s=r.fragments;for(let h=s.length-1;h>=0;h--){const d=s[h].initSegment;if(d){i=d;break}}r.fragmentHint&&delete r.fragmentHint.endPTS;let n;Qd(r,e,(h,d,g,m)=>{if((!e.startCC||e.skippedSegments)&&d.cc!==h.cc){const A=h.cc-d.cc;for(let C=g;C<m.length;C++)m[C].cc+=A;e.endCC=m[m.length-1].cc}se(h.startPTS)&&se(h.endPTS)&&(d.setStart(d.startPTS=h.startPTS),d.startDTS=h.startDTS,d.maxStartPTS=h.maxStartPTS,d.endPTS=h.endPTS,d.endDTS=h.endDTS,d.minEndPTS=h.minEndPTS,d.setDuration(h.endPTS-h.startPTS),d.duration&&(n=d),e.PTSKnown=e.alignedSliding=!0),h.hasStreams&&(d.elementaryStreams=h.elementaryStreams),d.loader=h.loader,h.hasStats&&(d.stats=h.stats),h.initSegment&&(d.initSegment=h.initSegment,i=h.initSegment)});const a=e.fragments,o=e.fragmentHint?a.concat(e.fragmentHint):a;if(i&&o.forEach(h=>{var d;h&&(!h.initSegment||h.initSegment.relurl===((d=i)==null?void 0:d.relurl))&&(h.initSegment=i)}),e.skippedSegments){if(e.deltaUpdateFailed=a.some(h=>!h),e.deltaUpdateFailed){t.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let h=e.skippedSegments;h--;)a.shift();e.startSN=a[0].sn}else{e.canSkipDateRanges&&(e.dateRanges=Xd(r.dateRanges,e,t));const h=r.fragments.filter(d=>d.rawProgramDateTime);if(r.hasProgramDateTime&&!e.hasProgramDateTime)for(let d=1;d<o.length;d++)o[d].programDateTime===null&&yr(o[d],o[d-1],h);al(h,e)}e.endCC=a[a.length-1].cc}if(!e.startCC){var l;const h=Al(r,e.startSN-1);e.startCC=(l=h?.cc)!=null?l:a[0].cc}if(Zd(r.partList,e.partList,(h,d)=>{d.elementaryStreams=h.elementaryStreams,d.stats=h.stats,d.gap=h.gap||d.gap}),n){const h=e.iframesOnly&&n.type===ge.MAIN;fl(e,n,n.startPTS,n.endPTS,n.startDTS,n.endDTS,h,t)}else pl(r,e);a.length&&(e.totalduration=e.edge-a[0].start),e.driftStartTime=r.driftStartTime,e.driftStart=r.driftStart;const u=e.advancedDateTime;if(e.advanced&&u){const h=e.edge;e.driftStart||(e.driftStartTime=u,e.driftStart=h),e.driftEndTime=u,e.driftEnd=h}else e.driftEndTime=r.driftEndTime,e.driftEnd=r.driftEnd,e.advancedDateTime=r.advancedDateTime;e.requestScheduled===-1&&(e.requestScheduled=r.requestScheduled)}function Xd(r,e,t){const{dateRanges:i,recentlyRemovedDateranges:s}=e,n=je({},r);s&&s.forEach(l=>{delete n[l]});const o=Object.keys(n).length;return o?(Object.keys(i).forEach(l=>{const u=n[l],h=new zo(i[l].attr,u);h.isValid?(n[l]=h,u||(h.tagOrder+=o)):t.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${Xe(i[l].attr)}"`)}),n):i}function Zd(r,e,t){if(r&&e){let i=0;for(let s=0,n=r.length;s<n;s++){const a=r[s],o=e[s+i];a&&o&&a.index===o.index&&a.fragment.sn===o.fragment.sn?t(a,o):i--}}}function Qd(r,e,t){var i;const s=e.skippedSegments,n=Math.max(r.startSN,e.startSN)-e.startSN,a=(r.fragmentHint?1:0)+(s?e.endSN:Math.min(r.endSN,e.endSN))-e.startSN,o=e.startSN-r.startSN,l=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,u=(i=r.fragmentHint)!=null&&i.duration?r.fragments.concat(r.fragmentHint):r.fragments;for(let h=n;h<=a;h++){const d=u[o+h];let g=l[h];if(s&&!g&&d&&(g=e.fragments[h]=d),d&&g){t(d,g,h,l);const m=d.relurl,A=g.relurl;if(m&&ef(m,A)){e.playlistParsingError=gl(`media sequence mismatch ${g.sn}:`,r,e,d,g);return}else if(d.cc!==g.cc){e.playlistParsingError=gl(`discontinuity sequence mismatch (${d.cc}!=${g.cc})`,r,e,d,g);return}}}}function gl(r,e,t,i,s){return new Error(`${r} ${s.url}
12
12
  Playlist starting @${e.startSN}
13
13
  ${e.m3u8}
14
14
 
15
15
  Playlist starting @${t.startSN}
16
- ${t.m3u8}`)}function io(a,e,t=!0){const i=e.startSN+e.skippedSegments-a.startSN,s=a.fragments,r=i>=0;let n=0;if(r&&i<s.length)n=s[i].start;else if(r&&e.startSN===a.endSN+1)n=a.fragmentEnd;else if(r&&t)n=a.fragmentStart+i*e.levelTargetDuration;else if(!e.skippedSegments&&e.fragmentStart===0)n=a.fragmentStart;else return;Br(e,n)}function Br(a,e){if(e){const t=a.fragments;for(let i=a.skippedSegments;i<t.length;i++)t[i].addStart(e);a.fragmentHint&&a.fragmentHint.addStart(e)}}function so(a,e=1/0){let t=1e3*a.targetduration;if(a.updated){const i=a.fragments;if(i.length&&t*4>e){const r=i[i.length-1].duration*1e3;r<t&&(t=r)}}else t/=2;return Math.round(t)}function ro(a,e,t){if(!a)return null;let i=a.fragments[e-a.startSN];return i||(i=a.fragmentHint,i&&i.sn===e)?i:e<a.startSN&&t&&t.sn===e?t:null}function no(a,e,t){return a?ao(a.partList,e,t):null}function ao(a,e,t){if(a)for(let i=a.length;i--;){const s=a[i];if(s.index===t&&s.fragment.sn===e)return s}return null}function oo(a){a.forEach((e,t)=>{var i;(i=e.details)==null||i.fragments.forEach(s=>{s.level=t,s.initSegment&&(s.initSegment.level=t)})})}function Xc(a,e){return a!==e&&e?lo(a)!==lo(e):!1}function lo(a){return a.replace(/\?[^?]*$/,"")}function Ji(a,e){for(let i=0,s=a.length;i<s;i++){var t;if(((t=a[i])==null?void 0:t.cc)===e)return a[i]}return null}function Zc(a,e){return!!(a&&e.startCC<a.endCC&&e.endCC>a.startCC)}function uo(a,e){const t=a.start+e;a.startPTS=t,a.setStart(t),a.endPTS=t+a.duration}function co(a,e){const t=e.fragments;for(let i=0,s=t.length;i<s;i++)uo(t[i],a);e.fragmentHint&&uo(e.fragmentHint,a),e.alignedSliding=!0}function Qc(a,e){a&&(ho(e,a),e.alignedSliding||Ms(e,a),!e.alignedSliding&&!e.skippedSegments&&io(a,e,!1))}function ho(a,e){if(!Zc(e,a))return;const t=Math.min(e.endCC,a.endCC),i=Ji(e.fragments,t),s=Ji(a.fragments,t);if(!i||!s)return;Oe.log(`Aligning playlist at start of dicontinuity sequence ${t}`);const r=i.start-s.start;co(r,a)}function Ms(a,e){if(!a.hasProgramDateTime||!e.hasProgramDateTime)return;const t=a.fragments,i=e.fragments;if(!t.length||!i.length)return;let s,r;const n=Math.min(e.endCC,a.endCC);e.startCC<n&&a.startCC<n&&(s=Ji(i,n),r=Ji(t,n)),(!s||!r)&&(s=i[Math.floor(i.length/2)],r=Ji(t,s.cc)||t[Math.floor(t.length/2)]);const o=s.programDateTime,c=r.programDateTime;if(!o||!c)return;const u=(c-o)/1e3-(r.start-s.start);co(u,a)}function ot(a,e,t){ht(a,e,t),a.addEventListener(e,t)}function ht(a,e,t){a.removeEventListener(e,t)}const Jc={toString:function(a){let e="";const t=a.length;for(let i=0;i<t;i++)e+=`[${a.start(i).toFixed(3)}-${a.end(i).toFixed(3)}]`;return e}},j={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 Ur extends Ma{constructor(e,t,i,s,r){super(s,e.logger),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=j.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.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.buffering=!0,this.loadingParts=!1,this.loopSn=void 0,this.onMediaSeeking=()=>{const{config:n,fragCurrent:o,media:c,mediaBuffer:u,state:h}=this,f=c?c.currentTime:0,g=ye.bufferInfo(u||c,f,n.maxBufferHole),I=!g.len;if(this.log(`Media seeking to ${se(f)?f.toFixed(3):f}, state: ${h}, ${I?"out of":"in"} buffer`),this.state===j.ENDED)this.resetLoadingState();else if(o){const m=n.maxFragLookUpTolerance,E=o.start-m,v=o.start+o.duration+m;if(I||v<g.start||E>g.end){const x=f>v;(f<E||x)&&(x&&o.loader&&(this.log(`Cancelling fragment load for seek (sn: ${o.sn})`),o.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}if(c){this.fragmentTracker.removeFragmentsInRange(f,1/0,this.playlistType,!0);const m=this.lastCurrentTime;if(f>m&&(this.lastCurrentTime=f),!this.loadingParts){const E=Math.max(g.end,f),v=this.shouldLoadParts(this.getLevelDetails(),E);v&&(this.log(`LL-Part loading ON after seeking to ${f.toFixed(2)} with buffer @${E.toFixed(2)}`),this.loadingParts=v)}}this.hls.hasEnoughToStart||(this.log(`Setting ${I?"startPosition":"nextLoadPosition"} to ${f} for seek without enough to start`),this.nextLoadPosition=f,I&&(this.startPosition=f)),I&&this.state===j.IDLE&&this.tickImmediate()},this.onMediaEnded=()=>{this.log("setting startPosition to 0 because media ended"),this.startPosition=this.lastCurrentTime=0},this.playlistType=r,this.hls=e,this.fragmentLoader=new xc(e.config),this.keyLoader=i,this.fragmentTracker=t,this.config=e.config,this.decrypter=new Rr(e.config)}registerListeners(){const{hls:e}=this;e.on(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(y.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(y.ERROR,this.onError,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){if(this.state===j.STOPPED)return;this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);const e=this.fragCurrent;e!=null&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=j.STOPPED}get startPositionValue(){const{nextLoadPosition:e,startPosition:t}=this;return t===-1&&e?e:t}get bufferingEnabled(){return this.buffering}pauseBuffering(){this.buffering=!1}resumeBuffering(){this.buffering=!0}get inFlightFrag(){return{frag:this.fragCurrent,state:this.state}}_streamEnded(e,t){if(t.live||!this.media)return!1;const i=e.end||0,s=this.config.timelineOffset||0;if(i<=s)return!1;const r=e.buffered;this.config.maxBufferHole&&r&&r.length>1&&(e=ye.bufferedInfo(r,e.start,0));const n=e.nextStart;if(n&&n>s&&n<t.edge||this.media.currentTime<e.start)return!1;const c=t.partList;if(c!=null&&c.length){const h=c[c.length-1];return ye.isBuffered(this.media,h.start+h.duration/2)}const u=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(u)}getLevelDetails(){if(this.levels&&this.levelLastLoaded!==null)return this.levelLastLoaded.details}get timelineOffset(){const e=this.config.timelineOffset;if(e){var t;return((t=this.getLevelDetails())==null?void 0:t.appliedTimelineOffset)||e}return 0}onMediaAttached(e,t){const i=this.media=this.mediaBuffer=t.media;ot(i,"seeking",this.onMediaSeeking),ot(i,"ended",this.onMediaEnded);const s=this.config;this.levels&&s.autoStartLoad&&this.state===j.STOPPED&&this.startLoad(s.startPosition)}onMediaDetaching(e,t){const i=!!t.transferMedia,s=this.media;if(s!==null){if(s.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),ht(s,"seeking",this.onMediaSeeking),ht(s,"ended",this.onMediaEnded),this.keyLoader&&!i&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loopSn=void 0,i){this.resetLoadingState(),this.resetTransmuxer();return}this.loadingParts=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}}onManifestLoading(){this.initPTS=[],this.levels=this.levelLastLoaded=this.fragCurrent=null,this.lastCurrentTime=this.startPosition=0,this.startFragRequested=!1}onError(e,t){}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset}onHandlerDestroying(){this.stopLoad(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),super.onHandlerDestroying(),this.hls=this.onMediaSeeking=this.onMediaEnded=null}onHandlerDestroyed(){this.state=j.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,i){this.startFragRequested=!0,this._loadFragForPlayback(e,t,i)}_loadFragForPlayback(e,t,i){const s=r=>{const n=r.frag;if(this.fragContextChanged(n)){this.warn(`${n.type} sn: ${n.sn}${r.part?" part: "+r.part.index:""} of ${this.fragInfo(n,!1,r.part)}) was dropped during download.`),this.fragmentTracker.removeFragment(n);return}n.stats.chunkCount++,this._handleFragmentLoadProgress(r)};this._doFragLoad(e,t,i,s).then(r=>{if(!r)return;const n=this.state,o=r.frag;if(this.fragContextChanged(o)){(n===j.FRAG_LOADING||!this.fragCurrent&&n===j.PARSING)&&(this.fragmentTracker.removeFragment(o),this.state=j.IDLE);return}"payload"in r&&(this.log(`Loaded ${o.type} sn: ${o.sn} of ${this.playlistLabel()} ${o.level}`),this.hls.trigger(y.FRAG_LOADED,r)),this._handleFragmentLoadComplete(r)}).catch(r=>{this.state===j.STOPPED||this.state===j.ERROR||(this.warn(`Frag error: ${r?.message||r}`),this.resetFragmentLoading(e))})}clearTrackerIfNeeded(e){var t;const{fragmentTracker:i}=this;if(i.getState(e)===Qe.APPENDING){const r=e.type,n=this.getFwdBufferInfo(this.mediaBuffer,r),o=Math.max(e.duration,n?n.len:this.config.maxBufferLength),c=this.backtrackFragment;((c?e.sn-c.sn:0)===1||this.reduceMaxBufferLength(o,e.duration))&&i.removeFragment(e)}else((t=this.mediaBuffer)==null?void 0:t.buffered.length)===0?i.removeAllFragments():i.hasParts(e.type)&&(i.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),i.getState(e)===Qe.PARTIAL&&i.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)}waitForLive(e){const t=e.details;return t?.live&&t.type!=="EVENT"&&(this.levelLastLoaded!==e||t.expired)}flushMainBuffer(e,t,i=null){if(!(e-t))return;const s={startOffset:e,endOffset:t,type:i};this.hls.trigger(y.BUFFER_FLUSHING,s)}_loadInitSegment(e,t){this._doFragLoad(e,t).then(i=>{const s=i?.frag;if(!s||this.fragContextChanged(s)||!this.levels)throw new Error("init load aborted");return i}).then(i=>{const{hls:s}=this,{frag:r,payload:n}=i,o=r.decryptdata;if(n&&n.byteLength>0&&o!=null&&o.key&&o.iv&&ki(o.method)){const c=self.performance.now();return this.decrypter.decrypt(new Uint8Array(n),o.key.buffer,o.iv.buffer,_r(o.method)).catch(u=>{throw s.trigger(y.ERROR,{type:de.MEDIA_ERROR,details:U.FRAG_DECRYPT_ERROR,fatal:!1,error:u,reason:u.message,frag:r}),u}).then(u=>{const h=self.performance.now();return s.trigger(y.FRAG_DECRYPTED,{frag:r,payload:u,stats:{tstart:c,tdecrypt:h}}),i.payload=u,this.completeInitSegmentLoad(i)})}return this.completeInitSegmentLoad(i)}).catch(i=>{this.state===j.STOPPED||this.state===j.ERROR||(this.warn(i),this.resetFragmentLoading(e))})}completeInitSegmentLoad(e){const{levels:t}=this;if(!t)throw new Error("init load aborted, missing levels");const i=e.frag.stats;this.state!==j.STOPPED&&(this.state=j.IDLE),e.frag.data=new Uint8Array(e.payload),i.parsing.start=i.buffering.start=self.performance.now(),i.parsing.end=i.buffering.end=self.performance.now(),this.tick()}unhandledEncryptionError(e,t){var i,s;const r=e.tracks;if(r&&!t.encrypted&&((i=r.audio)!=null&&i.encrypted||(s=r.video)!=null&&s.encrypted)&&(!this.config.emeEnabled||!this.keyLoader.emeController)){const n=this.media,o=new Error(`Encrypted track with no key in ${this.fragInfo(t)} (media ${n?"attached mediaKeys: "+n.mediaKeys:"detached"})`);return this.warn(o.message),!n||n.mediaKeys?!1:(this.hls.trigger(y.ERROR,{type:de.KEY_SYSTEM_ERROR,details:U.KEY_SYSTEM_NO_KEYS,fatal:!1,error:o,frag:t}),this.resetTransmuxer(),!0)}return!1}fragContextChanged(e){const{fragCurrent:t}=this;return!e||!t||e.sn!==t.sn||e.level!==t.level}fragBufferedComplete(e,t){const i=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)} > buffer:${i?Jc.toString(ye.getBuffered(i)):"(detached)"})`),qe(e)){var s;if(e.type!==he.SUBTITLE){const n=e.elementaryStreams;if(!Object.keys(n).some(o=>!!n[o])){this.state=j.IDLE;return}}const r=(s=this.levels)==null?void 0:s[e.level];r!=null&&r.fragmentError&&(this.log(`Resetting level fragment error count of ${r.fragmentError} on frag buffered`),r.fragmentError=0)}this.state=j.IDLE}_handleFragmentLoadComplete(e){const{transmuxer:t}=this;if(!t)return;const{frag:i,part:s,partsLoaded:r}=e,n=!r||r.length===0||r.some(c=>!c),o=new Dr(i.level,i.sn,i.stats.chunkCount+1,0,s?s.index:-1,!n);t.flush(o)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,i=null,s){var r;this.fragCurrent=e;const n=t.details;if(!this.levels||!n)throw new Error(`frag load aborted, missing level${n?"":" detail"}s`);let o=null;if(e.encrypted&&!((r=e.decryptdata)!=null&&r.key)){if(this.log(`Loading key for ${e.sn} of [${n.startSN}-${n.endSN}], ${this.playlistLabel()} ${e.level}`),this.state=j.KEY_LOADING,this.fragCurrent=e,o=this.keyLoader.load(e).then(g=>{if(!this.fragContextChanged(g.frag))return this.hls.trigger(y.KEY_LOADED,g),this.state===j.KEY_LOADING&&(this.state=j.IDLE),g}),this.hls.trigger(y.KEY_LOADING,{frag:e}),this.fragCurrent===null)return this.log("context changed in KEY_LOADING"),Promise.resolve(null)}else e.encrypted||(o=this.keyLoader.loadClear(e,n.encryptedFragments,this.startFragRequested),o&&this.log("[eme] blocking frag load until media-keys acquired"));const c=this.fragPrevious;if(qe(e)&&(!c||e.sn!==c.sn)){const g=this.shouldLoadParts(t.details,e.end);g!==this.loadingParts&&(this.log(`LL-Part loading ${g?"ON":"OFF"} loading sn ${c?.sn}->${e.sn}`),this.loadingParts=g)}if(i=Math.max(e.start,i||0),this.loadingParts&&qe(e)){const g=n.partList;if(g&&s){i>n.fragmentEnd&&n.fragmentHint&&(e=n.fragmentHint);const I=this.getNextPart(g,e,i);if(I>-1){const m=g[I];e=this.fragCurrent=m.fragment,this.log(`Loading ${e.type} sn: ${e.sn} part: ${m.index} (${I}/${g.length-1}) of ${this.fragInfo(e,!1,m)}) cc: ${e.cc} [${n.startSN}-${n.endSN}], target: ${parseFloat(i.toFixed(3))}`),this.nextLoadPosition=m.start+m.duration,this.state=j.FRAG_LOADING;let E;return o?E=o.then(v=>!v||this.fragContextChanged(v.frag)?null:this.doFragPartsLoad(e,m,t,s)).catch(v=>this.handleFragLoadError(v)):E=this.doFragPartsLoad(e,m,t,s).catch(v=>this.handleFragLoadError(v)),this.hls.trigger(y.FRAG_LOADING,{frag:e,part:m,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):E}else if(!e.url||this.loadedEndOfParts(g,i))return Promise.resolve(null)}}if(qe(e)&&this.loadingParts){var u;this.log(`LL-Part loading OFF after next part miss @${i.toFixed(2)} Check buffer at sn: ${e.sn} loaded parts: ${(u=n.partList)==null?void 0:u.filter(g=>g.loaded).map(g=>`[${g.start}-${g.end}]`)}`),this.loadingParts=!1}else if(!e.url)return Promise.resolve(null);this.log(`Loading ${e.type} sn: ${e.sn} of ${this.fragInfo(e,!1)}) cc: ${e.cc} ${"["+n.startSN+"-"+n.endSN+"]"}, target: ${parseFloat(i.toFixed(3))}`),se(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=j.FRAG_LOADING;const h=this.config.progressive;let f;return h&&o?f=o.then(g=>!g||this.fragContextChanged(g.frag)?null:this.fragmentLoader.load(e,s)).catch(g=>this.handleFragLoadError(g)):f=Promise.all([this.fragmentLoader.load(e,h?s:void 0),o]).then(([g])=>(!h&&s&&s(g),g)).catch(g=>this.handleFragLoadError(g)),this.hls.trigger(y.FRAG_LOADING,{frag:e,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):f}doFragPartsLoad(e,t,i,s){return new Promise((r,n)=>{var o;const c=[],u=(o=i.details)==null?void 0:o.partList,h=f=>{this.fragmentLoader.loadPart(e,f,s).then(g=>{c[f.index]=g;const I=g.part;this.hls.trigger(y.FRAG_LOADED,g);const m=no(i.details,e.sn,f.index+1)||ao(u,e.sn,f.index+1);if(m)h(m);else return r({frag:e,part:I,partsLoaded:c})}).catch(n)};h(t)})}handleFragLoadError(e){if("data"in e){const t=e.data;t.frag&&t.details===U.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):t.frag&&t.type===de.KEY_SYSTEM_ERROR?(t.frag.abortRequests(),this.resetFragmentLoading(t.frag)):this.hls.trigger(y.ERROR,t)}else this.hls.trigger(y.ERROR,{type:de.OTHER_ERROR,details:U.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){const t=this.getCurrentContext(e);if(!t||this.state!==j.PARSING){!this.fragCurrent&&this.state!==j.STOPPED&&this.state!==j.ERROR&&(this.state=j.IDLE);return}const{frag:i,part:s,level:r}=t,n=self.performance.now();i.stats.parsing.end=n,s&&(s.stats.parsing.end=n);const o=this.getLevelDetails(),u=o&&i.sn>o.endSN||this.shouldLoadParts(o,i.end);u!==this.loadingParts&&(this.log(`LL-Part loading ${u?"ON":"OFF"} after parsing segment ending @${i.end.toFixed(2)}`),this.loadingParts=u),this.updateLevelTiming(i,s,r,e.partial)}shouldLoadParts(e,t){if(this.config.lowLatencyMode){if(!e)return this.loadingParts;if(e.partList){var i;const r=e.partList[0];if(r.fragment.type===he.SUBTITLE)return!1;const n=r.end+(((i=e.fragmentHint)==null?void 0:i.duration)||0);if(t>=n){var s;if((this.hls.hasEnoughToStart?((s=this.media)==null?void 0:s.currentTime)||this.lastCurrentTime:this.getLoadPosition())>r.start-r.fragment.duration)return!0}}}return!1}getCurrentContext(e){const{levels:t,fragCurrent:i}=this,{level:s,sn:r,part:n}=e;if(!(t!=null&&t[s]))return this.warn(`Levels object was unset while buffering fragment ${r} of ${this.playlistLabel()} ${s}. The current chunk will not be buffered.`),null;const o=t[s],c=o.details,u=n>-1?no(c,r,n):null,h=u?u.fragment:ro(c,r,i);return h?(i&&i!==h&&(h.stats=i.stats),{frag:h,part:u,level:o}):null}bufferFragmentData(e,t,i,s,r){if(this.state!==j.PARSING)return;const{data1:n,data2:o}=e;let c=n;if(o&&(c=St(n,o)),!c.length)return;const u=this.initPTS[t.cc],h=u?-u.baseTime/u.timescale:void 0,f={type:e.type,frag:t,part:i,chunkMeta:s,offset:h,parent:t.type,data:c};if(this.hls.trigger(y.BUFFER_APPENDING,f),e.dropped&&e.independent&&!i){if(r)return;this.flushBufferGap(t)}}flushBufferGap(e){const t=this.media;if(!t)return;if(!ye.isBuffered(t,t.currentTime)){this.flushMainBuffer(0,e.start);return}const i=t.currentTime,s=ye.bufferInfo(t,i,0),r=e.duration,n=Math.min(this.config.maxFragLookUpTolerance*2,r*.25),o=Math.max(Math.min(e.start-n,s.end-n),i+n);e.start-o>n&&this.flushMainBuffer(o,e.start)}getFwdBufferInfo(e,t){var i;const s=this.getLoadPosition();if(!se(s))return null;const n=this.lastCurrentTime>s||(i=this.media)!=null&&i.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(e,s,t,n)}getFwdBufferInfoAtPos(e,t,i,s){const r=ye.bufferInfo(e,t,s);if(r.len===0&&r.nextStart!==void 0){const n=this.fragmentTracker.getBufferedFrag(t,i);if(n&&(r.nextStart<=n.end||n.gap)){const o=Math.max(Math.min(r.nextStart,n.end)-t,s);return ye.bufferInfo(e,t,o)}}return r}getMaxBufferLength(e){const{config:t}=this;let i;return e?i=Math.max(8*t.maxBufferSize/e,t.maxBufferLength):i=t.maxBufferLength,Math.min(i,t.maxMaxBufferLength)}reduceMaxBufferLength(e,t){const i=this.config,s=Math.max(Math.min(e-t,i.maxBufferLength),t),r=Math.max(e-t*3,i.maxMaxBufferLength/2,s);return r>=s?(i.maxMaxBufferLength=r,this.warn(`Reduce max buffer length to ${r}s`),!0):!1}getAppendedFrag(e,t=he.MAIN){const i=this.fragmentTracker?this.fragmentTracker.getAppendedFrag(e,t):null;return i&&"fragment"in i?i.fragment:i}getNextFragment(e,t){const i=t.fragments,s=i.length;if(!s)return null;const{config:r}=this,n=i[0].start,o=r.lowLatencyMode&&!!t.partList;let c=null;if(t.live){const f=r.initialLiveManifestSize;if(s<f)return this.warn(`Not enough fragments to start playback (have: ${s}, need: ${f})`),null;if(!t.PTSKnown&&!this.startFragRequested&&this.startPosition===-1||e<n){var u;o&&!this.loadingParts&&(this.log("LL-Part loading ON for initial live fragment"),this.loadingParts=!0),c=this.getInitialLiveFragment(t);const g=this.hls.startPosition,I=this.hls.liveSyncPosition,m=c?(g!==-1&&g>=n?g:I)||c.start:e;this.log(`Setting startPosition to ${m} to match start frag at live edge. mainStart: ${g} liveSyncPosition: ${I} frag.start: ${(u=c)==null?void 0:u.start}`),this.startPosition=this.nextLoadPosition=m}}else e<=n&&(c=i[0]);if(!c){const f=this.loadingParts?t.partEnd:t.fragmentEnd;c=this.getFragmentAtPosition(e,f,t)}let h=this.filterReplacedPrimary(c,t);if(!h&&c){const f=c.sn-t.startSN;h=this.filterReplacedPrimary(i[f+1]||null,t)}return this.mapToInitFragWhenRequired(h)}isLoopLoading(e,t){const i=this.fragmentTracker.getState(e);return(i===Qe.OK||i===Qe.PARTIAL&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,i,s,r){let n=null;if(e.gap&&(n=this.getNextFragment(this.nextLoadPosition,t),n&&!n.gap&&i.nextStart)){const o=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,s,0);if(o!==null&&i.len+o.len>=r){const c=n.sn;return this.loopSn!==c&&(this.log(`buffer full after gaps in "${s}" playlist starting at sn: ${c}`),this.loopSn=c),null}}return this.loopSn=void 0,n}get primaryPrefetch(){if(fo(this.config)){var e;if((e=this.hls.interstitialsManager)==null||(e=e.playingItem)==null?void 0:e.event)return!0}return!1}filterReplacedPrimary(e,t){if(!e)return e;if(fo(this.config)&&e.type!==he.SUBTITLE){const i=this.hls.interstitialsManager,s=i?.bufferingItem;if(s){const n=s.event;if(n){if(n.appendInPlace||Math.abs(e.start-s.start)>1||s.start===0)return null}else if(e.end<=s.start&&t?.live===!1||e.start>s.end&&s.nextEvent&&(s.nextEvent.appendInPlace||e.start-s.end>1))return null}const r=i?.playerQueue;if(r)for(let n=r.length;n--;){const o=r[n].interstitial;if(o.appendInPlace&&e.start>=o.startTime&&e.end<=o.resumeTime)return null}}return e}mapToInitFragWhenRequired(e){return e!=null&&e.initSegment&&!e.initSegment.data&&!this.bitrateTest?e.initSegment:e}getNextPart(e,t,i){let s=-1,r=!1,n=!0;for(let o=0,c=e.length;o<c;o++){const u=e[o];if(n=n&&!u.independent,s>-1&&i<u.start)break;const h=u.loaded;h?s=-1:(r||(u.independent||n)&&u.fragment===t)&&(u.fragment!==t&&this.warn(`Need buffer at ${i} but next unloaded part starts at ${u.start}`),s=o),r=h}return s}loadedEndOfParts(e,t){let i;for(let s=e.length;s--;){if(i=e[s],!i.loaded)return!1;if(t>i.start)return!0}return!1}getInitialLiveFragment(e){const t=e.fragments,i=this.fragPrevious;let s=null;if(i){if(e.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${i.programDateTime}`),s=fc(t,i.endProgramDateTime,this.config.maxFragLookUpTolerance)),!s){const r=i.sn+1;if(r>=e.startSN&&r<=e.endSN){const n=t[r-e.startSN];i.cc===n.cc&&(s=n,this.log(`Live playlist, switching playlist, load frag with next SN: ${s.sn}`))}s||(s=La(e,i.cc,i.end),s&&this.log(`Live playlist, switching playlist, load frag with same CC: ${s.sn}`))}}else{const r=this.hls.liveSyncPosition;r!==null&&(s=this.getFragmentAtPosition(r,this.bitrateTest?e.fragmentEnd:e.edge,e))}return s}getFragmentAtPosition(e,t,i){const{config:s}=this;let{fragPrevious:r}=this,{fragments:n,endSN:o}=i;const{fragmentHint:c}=i,{maxFragLookUpTolerance:u}=s,h=i.partList,f=!!(this.loadingParts&&h!=null&&h.length&&c);f&&!this.bitrateTest&&h[h.length-1].fragment.sn===c.sn&&(n=n.concat(c),o=c.sn);let g;if(e<t){var I;const E=e<this.lastCurrentTime||e>t-u||(I=this.media)!=null&&I.paused||!this.startFragRequested?0:u;g=yi(r,n,e,E)}else g=n[n.length-1];if(g){const m=g.sn-i.startSN,E=this.fragmentTracker.getState(g);if((E===Qe.OK||E===Qe.PARTIAL&&g.gap)&&(r=g),r&&g.sn===r.sn&&(!f||h[0].fragment.sn>g.sn||!i.live)&&g.level===r.level){const x=n[m+1];g.sn<o&&this.fragmentTracker.getState(x)!==Qe.OK?g=x:g=null}}return g}alignPlaylists(e,t,i){const s=e.fragments.length;if(!s)return this.warn("No fragments in live playlist"),0;const r=e.fragmentStart,n=!t,o=e.alignedSliding&&se(r);if(n||!o&&!r){Qc(i,e);const c=e.fragmentStart;return this.log(`Live playlist sliding: ${c.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} fragments: ${s}`),c}return r}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,e.partTarget*3)}setStartPosition(e,t){let i=this.startPosition;i<t&&(i=-1);const s=this.timelineOffset;if(i===-1){const r=this.startTimeOffset!==null,n=r?this.startTimeOffset:e.startTimeOffset;n!==null&&se(n)?(i=t+n,n<0&&(i+=e.edge),i=Math.min(Math.max(t,i),t+e.totalduration),this.log(`Setting startPosition to ${i} for start time offset ${n} found in ${r?"multivariant":"media"} playlist`),this.startPosition=i):e.live?(i=this.hls.liveSyncPosition||t,this.log(`Setting startPosition to -1 to start at live edge ${i}`),this.startPosition=-1):(this.log("setting startPosition to 0 by default"),this.startPosition=i=0),this.lastCurrentTime=i+s}this.nextLoadPosition=i+s}getLoadPosition(){var e;const{media:t}=this;let i=0;return(e=this.hls)!=null&&e.hasEnoughToStart&&t?i=t.currentTime:this.nextLoadPosition>=0&&(i=this.nextLoadPosition),i}handleFragLoadAborted(e,t){this.transmuxer&&e.type===this.playlistType&&qe(e)&&e.stats.aborted&&(this.log(`Fragment ${e.sn}${t?" part "+t.index:""} of ${this.playlistLabel()} ${e.level} was aborted`),this.resetFragmentLoading(e))}resetFragmentLoading(e){(!this.fragCurrent||!this.fragContextChanged(e)&&this.state!==j.FRAG_LOADING_WAITING_RETRY)&&(this.state=j.IDLE)}onFragmentOrKeyLoadError(e,t){var i;if(t.chunkMeta&&!t.frag){const x=this.getCurrentContext(t.chunkMeta);x&&(t.frag=x.frag)}const s=t.frag;if(!s||s.type!==e||!this.levels)return;if(this.fragContextChanged(s)){var r;this.warn(`Frag load error must match current frag to retry ${s.url} > ${(r=this.fragCurrent)==null?void 0:r.url}`);return}const n=t.details===U.FRAG_GAP;n&&this.fragmentTracker.fragBuffered(s,!0);const o=t.errorAction;if(!o){this.state=j.ERROR;return}const{action:c,flags:u,retryCount:h=0,retryConfig:f}=o,g=!!f,I=g&&c===rt.RetryRequest,m=g&&!o.resolved&&u===Ct.MoveAllAlternatesMatchingHost,E=(i=this.hls.latestLevelDetails)==null?void 0:i.live;if(!I&&m&&qe(s)&&!s.endList&&E)this.resetFragmentErrors(e),this.treatAsGap(s),o.resolved=!0;else if((I||m)&&h<f.maxNumRetry){var v;const x=Lr((v=t.response)==null?void 0:v.code),D=br(f,h);if(this.resetStartWhenNotLoaded(),this.retryDate=self.performance.now()+D,this.state=j.FRAG_LOADING_WAITING_RETRY,o.resolved=!0,x){this.log("Waiting for connection (offline)"),this.retryDate=1/0,t.reason="offline";return}this.warn(`Fragment ${s.sn} of ${e} ${s.level} errored with ${t.details}, retrying loading ${h+1}/${f.maxNumRetry} in ${D}ms`)}else if(f)if(this.resetFragmentErrors(e),h<f.maxNumRetry)!n&&c!==rt.RemoveAlternatePermanently&&(o.resolved=!0);else{this.warn(`${t.details} reached or exceeded max retry (${h})`);return}else c===rt.SendAlternateToPenaltyBox?this.state=j.WAITING_LEVEL:this.state=j.ERROR;this.tickImmediate()}checkRetryDate(){const e=self.performance.now(),t=this.retryDate,i=t===1/0;(!t||e>=t||i&&!Lr(0))&&(i&&this.log("Connection restored (online)"),this.resetStartWhenNotLoaded(),this.state=j.IDLE)}reduceLengthAndFlushBuffer(e){if(this.state===j.PARSING||this.state===j.PARSED){const t=e.frag,i=e.parent,s=this.getFwdBufferInfo(this.mediaBuffer,i),r=s&&s.len>.5;r&&this.reduceMaxBufferLength(s.len,t?.duration||10);const n=!r;return n&&this.warn(`Buffer full error while media.currentTime (${this.getLoadPosition()}) is not buffered, flush ${i} buffer`),t&&(this.fragmentTracker.removeFragment(t),this.nextLoadPosition=t.start),this.resetLoadingState(),n}return!1}resetFragmentErrors(e){e===he.AUDIO&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==j.STOPPED&&(this.state=j.IDLE)}afterBufferFlushed(e,t,i){if(!e)return;const s=ye.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,s,i),this.state===j.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==j.STOPPED&&(this.state=j.IDLE)}resetStartWhenNotLoaded(){if(!this.hls.hasEnoughToStart){this.startFragRequested=!1;const e=this.levelLastLoaded,t=e?e.details:null;t!=null&&t.live?(this.log("resetting startPosition for live start"),this.startPosition=-1,this.setStartPosition(t,t.fragmentStart),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(e){this.log(`Loading context changed while buffering sn ${e.sn} of ${this.playlistLabel()} ${e.level===-1?"<removed>":e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(),this.resetLoadingState()}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(e,t,i,s){const r=i.details;if(!r){this.warn("level.details undefined");return}if(!Object.keys(e.elementaryStreams).reduce((c,u)=>{const h=e.elementaryStreams[u];if(h){const f=h.endPTS-h.startPTS;if(f<=0)return this.warn(`Could not parse fragment ${e.sn} ${u} duration reliably (${f})`),c||!1;const g=s?0:eo(r,e,h.startPTS,h.endPTS,h.startDTS,h.endDTS,this);return this.hls.trigger(y.LEVEL_PTS_UPDATED,{details:r,level:i,drift:g,type:u,frag:e,start:h.startPTS,end:h.endPTS}),!0}return c},!1)){var o;if(i.fragmentError===0&&this.treatAsGap(e,i),((o=this.transmuxer)==null?void 0:o.error)===null){const c=new Error(`Found no media in fragment ${e.sn} of ${this.playlistLabel()} ${e.level} resetting transmuxer to fallback to playlist timing`);if(this.warn(c.message),this.hls.trigger(y.ERROR,{type:de.MEDIA_ERROR,details:U.FRAG_PARSING_ERROR,fatal:!1,error:c,frag:e,reason:`Found no media in msn ${e.sn} of ${this.playlistLabel()} "${i.url}"`}),!this.hls)return;this.resetTransmuxer()}}this.state=j.PARSED,this.log(`Parsed ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)})`),this.hls.trigger(y.FRAG_PARSED,{frag:e,part:t})}playlistLabel(){return this.playlistType===he.MAIN?"level":"track"}fragInfo(e,t=!0,i){var s,r;return`${this.playlistLabel()} ${e.level} (${i?"part":"frag"}:[${((s=t&&!i?e.startPTS:(i||e).start)!=null?s:NaN).toFixed(3)}-${((r=t&&!i?e.endPTS:(i||e).end)!=null?r:NaN).toFixed(3)}]${i&&e.type==="main"?"INDEPENDENT="+(i.independent?"YES":"NO"):""}`}treatAsGap(e,t){t&&t.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)}resetTransmuxer(){var e;(e=this.transmuxer)==null||e.reset()}recoverWorkerError(e){e.event==="demuxerWorker"&&(this.fragmentTracker.removeAllFragments(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),this.resetStartWhenNotLoaded(),this.resetLoadingState())}set state(e){const t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}get state(){return this._state}}function fo(a){return!!a.interstitialsController&&a.enableInterstitialPlayback!==!1}class go{constructor(){this.chunks=[],this.dataLength=0}push(e){this.chunks.push(e),this.dataLength+=e.length}flush(){const{chunks:e,dataLength:t}=this;let i;if(e.length)e.length===1?i=e[0]:i=eh(e,t);else return new Uint8Array(0);return this.reset(),i}reset(){this.chunks.length=0,this.dataLength=0}}function eh(a,e){const t=new Uint8Array(e);let i=0;for(let s=0;s<a.length;s++){const r=a[s];t.set(r,i),i+=r.length}return t}var $r={exports:{}},po;function th(){return po||(po=1,(function(a){var e=Object.prototype.hasOwnProperty,t="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(t=!1));function s(c,u,h){this.fn=c,this.context=u,this.once=h||!1}function r(c,u,h,f,g){if(typeof h!="function")throw new TypeError("The listener must be a function");var I=new s(h,f||c,g),m=t?t+u:u;return c._events[m]?c._events[m].fn?c._events[m]=[c._events[m],I]:c._events[m].push(I):(c._events[m]=I,c._eventsCount++),c}function n(c,u){--c._eventsCount===0?c._events=new i:delete c._events[u]}function o(){this._events=new i,this._eventsCount=0}o.prototype.eventNames=function(){var u=[],h,f;if(this._eventsCount===0)return u;for(f in h=this._events)e.call(h,f)&&u.push(t?f.slice(1):f);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(h)):u},o.prototype.listeners=function(u){var h=t?t+u:u,f=this._events[h];if(!f)return[];if(f.fn)return[f.fn];for(var g=0,I=f.length,m=new Array(I);g<I;g++)m[g]=f[g].fn;return m},o.prototype.listenerCount=function(u){var h=t?t+u:u,f=this._events[h];return f?f.fn?1:f.length:0},o.prototype.emit=function(u,h,f,g,I,m){var E=t?t+u:u;if(!this._events[E])return!1;var v=this._events[E],x=arguments.length,D,L;if(v.fn){switch(v.once&&this.removeListener(u,v.fn,void 0,!0),x){case 1:return v.fn.call(v.context),!0;case 2:return v.fn.call(v.context,h),!0;case 3:return v.fn.call(v.context,h,f),!0;case 4:return v.fn.call(v.context,h,f,g),!0;case 5:return v.fn.call(v.context,h,f,g,I),!0;case 6:return v.fn.call(v.context,h,f,g,I,m),!0}for(L=1,D=new Array(x-1);L<x;L++)D[L-1]=arguments[L];v.fn.apply(v.context,D)}else{var w=v.length,N;for(L=0;L<w;L++)switch(v[L].once&&this.removeListener(u,v[L].fn,void 0,!0),x){case 1:v[L].fn.call(v[L].context);break;case 2:v[L].fn.call(v[L].context,h);break;case 3:v[L].fn.call(v[L].context,h,f);break;case 4:v[L].fn.call(v[L].context,h,f,g);break;default:if(!D)for(N=1,D=new Array(x-1);N<x;N++)D[N-1]=arguments[N];v[L].fn.apply(v[L].context,D)}}return!0},o.prototype.on=function(u,h,f){return r(this,u,h,f,!1)},o.prototype.once=function(u,h,f){return r(this,u,h,f,!0)},o.prototype.removeListener=function(u,h,f,g){var I=t?t+u:u;if(!this._events[I])return this;if(!h)return n(this,I),this;var m=this._events[I];if(m.fn)m.fn===h&&(!g||m.once)&&(!f||m.context===f)&&n(this,I);else{for(var E=0,v=[],x=m.length;E<x;E++)(m[E].fn!==h||g&&!m[E].once||f&&m[E].context!==f)&&v.push(m[E]);v.length?this._events[I]=v.length===1?v[0]:v:n(this,I)}return this},o.prototype.removeAllListeners=function(u){var h;return u?(h=t?t+u:u,this._events[h]&&n(this,h)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=t,o.EventEmitter=o,a.exports=o})($r)),$r.exports}var ih=th(),Gr=Ru(ih);const es="1.6.11",Mi={};function sh(){return typeof __HLS_WORKER_BUNDLE__=="function"}function rh(){const a=Mi[es];if(a)return a.clientCount++,a;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),s={worker:new self.Worker(t),objectURL:t,clientCount:1};return Mi[es]=s,s}function nh(a){const e=Mi[a];if(e)return e.clientCount++,e;const t=new self.URL(a,self.location.href).href,s={worker:new self.Worker(t),scriptURL:t,clientCount:1};return Mi[a]=s,s}function ah(a){const e=Mi[a||es];if(e&&e.clientCount--===1){const{worker:i,objectURL:s}=e;delete Mi[a||es],s&&self.URL.revokeObjectURL(s),i.terminate()}}function Ao(a,e){return e+10<=a.length&&a[e]===51&&a[e+1]===68&&a[e+2]===73&&a[e+3]<255&&a[e+4]<255&&a[e+6]<128&&a[e+7]<128&&a[e+8]<128&&a[e+9]<128}function Hr(a,e){return e+10<=a.length&&a[e]===73&&a[e+1]===68&&a[e+2]===51&&a[e+3]<255&&a[e+4]<255&&a[e+6]<128&&a[e+7]<128&&a[e+8]<128&&a[e+9]<128}function Os(a,e){let t=0;return t=(a[e]&127)<<21,t|=(a[e+1]&127)<<14,t|=(a[e+2]&127)<<7,t|=a[e+3]&127,t}function ts(a,e){const t=e;let i=0;for(;Hr(a,e);){i+=10;const s=Os(a,e+6);i+=s,Ao(a,e+10)&&(i+=10),e+=i}if(i>0)return a.subarray(t,t+i)}function oh(a,e,t,i){const s=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],r=e[t+2],n=r>>2&15;if(n>12){const I=new Error(`invalid ADTS sampling index:${n}`);a.emit(y.ERROR,y.ERROR,{type:de.MEDIA_ERROR,details:U.FRAG_PARSING_ERROR,fatal:!0,error:I,reason:I.message});return}const o=(r>>6&3)+1,c=e[t+3]>>6&3|(r&1)<<2,u="mp4a.40."+o,h=s[n];let f=n;(o===5||o===29)&&(f-=3);const g=[o<<3|(f&14)>>1,(f&1)<<7|c<<3];return Oe.log(`manifest codec:${i}, parsed codec:${u}, channels:${c}, rate:${h} (ADTS object type:${o} sampling index:${n})`),{config:g,samplerate:h,channelCount:c,codec:u,parsedCodec:u,manifestCodec:i}}function mo(a,e){return a[e]===255&&(a[e+1]&246)===240}function Io(a,e){return a[e+1]&1?7:9}function Vr(a,e){return(a[e+3]&3)<<11|a[e+4]<<3|(a[e+5]&224)>>>5}function lh(a,e){return e+5<a.length}function Fs(a,e){return e+1<a.length&&mo(a,e)}function uh(a,e){return lh(a,e)&&mo(a,e)&&Vr(a,e)<=a.length-e}function ch(a,e){if(Fs(a,e)){const t=Io(a,e);if(e+t>=a.length)return!1;const i=Vr(a,e);if(i<=t)return!1;const s=e+i;return s===a.length||Fs(a,s)}return!1}function Co(a,e,t,i,s){if(!a.samplerate){const r=oh(e,t,i,s);if(!r)return;Ne(a,r)}}function yo(a){return 1024*9e4/a}function hh(a,e){const t=Io(a,e);if(e+t<=a.length){const i=Vr(a,e)-t;if(i>0)return{headerLength:t,frameLength:i}}}function Eo(a,e,t,i,s){const r=yo(a.samplerate),n=i+s*r,o=hh(e,t);let c;if(o){const{frameLength:f,headerLength:g}=o,I=g+f,m=Math.max(0,t+I-e.length);m?(c=new Uint8Array(I-g),c.set(e.subarray(t+g,e.length),0)):c=e.subarray(t+g,t+I);const E={unit:c,pts:n};return m||a.samples.push(E),{sample:E,length:I,missing:m}}const u=e.length-t;return c=new Uint8Array(u),c.set(e.subarray(t,e.length),0),{sample:{unit:c,pts:n},length:u,missing:-1}}function dh(a,e){return Hr(a,e)&&Os(a,e+6)+10<=a.length-e}function fh(a){return a instanceof ArrayBuffer?a:a.byteOffset==0&&a.byteLength==a.buffer.byteLength?a.buffer:new Uint8Array(a).buffer}function Kr(a,e=0,t=1/0){return gh(a,e,t,Uint8Array)}function gh(a,e,t,i){const s=ph(a);let r=1;"BYTES_PER_ELEMENT"in i&&(r=i.BYTES_PER_ELEMENT);const n=Ah(a)?a.byteOffset:0,o=(n+a.byteLength)/r,c=(n+e)/r,u=Math.floor(Math.max(0,Math.min(c,o))),h=Math.floor(Math.min(u+Math.max(t,0),o));return new i(s,u,h-u)}function ph(a){return a instanceof ArrayBuffer?a:a.buffer}function Ah(a){return a&&a.buffer instanceof ArrayBuffer&&a.byteLength!==void 0&&a.byteOffset!==void 0}function mh(a){const e={key:a.type,description:"",data:"",mimeType:null,pictureType:null},t=3;if(a.size<2)return;if(a.data[0]!==t){console.log("Ignore frame with unrecognized character encoding");return}const i=a.data.subarray(1).indexOf(0);if(i===-1)return;const s=mt(Kr(a.data,1,i)),r=a.data[2+i],n=a.data.subarray(3+i).indexOf(0);if(n===-1)return;const o=mt(Kr(a.data,3+i,n));let c;return s==="-->"?c=mt(Kr(a.data,4+i+n)):c=fh(a.data.subarray(4+i+n)),e.mimeType=s,e.pictureType=r,e.description=o,e.data=c,e}function Ih(a){if(a.size<2)return;const e=mt(a.data,!0),t=new Uint8Array(a.data.subarray(e.length+1));return{key:a.type,info:e,data:t.buffer}}function Ch(a){if(a.size<2)return;if(a.type==="TXXX"){let t=1;const i=mt(a.data.subarray(t),!0);t+=i.length+1;const s=mt(a.data.subarray(t));return{key:a.type,info:i,data:s}}const e=mt(a.data.subarray(1));return{key:a.type,info:"",data:e}}function yh(a){if(a.type==="WXXX"){if(a.size<2)return;let t=1;const i=mt(a.data.subarray(t),!0);t+=i.length+1;const s=mt(a.data.subarray(t));return{key:a.type,info:i,data:s}}const e=mt(a.data);return{key:a.type,info:"",data:e}}function Eh(a){return a.type==="PRIV"?Ih(a):a.type[0]==="W"?yh(a):a.type==="APIC"?mh(a):Ch(a)}function vh(a){const e=String.fromCharCode(a[0],a[1],a[2],a[3]),t=Os(a,4),i=10;return{type:e,size:t,data:a.subarray(i,i+t)}}const Ns=10,Th=10;function vo(a){let e=0;const t=[];for(;Hr(a,e);){const i=Os(a,e+6);a[e+5]>>6&1&&(e+=Ns),e+=Ns;const s=e+i;for(;e+Th<s;){const r=vh(a.subarray(e)),n=Eh(r);n&&t.push(n),e+=r.size+Ns}Ao(a,e)&&(e+=Ns)}return t}function To(a){return a&&a.key==="PRIV"&&a.info==="com.apple.streaming.transportStreamTimestamp"}function Sh(a){if(a.data.byteLength===8){const e=new Uint8Array(a.data),t=e[3]&1;let i=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return i/=45,t&&(i+=4772185884e-2),Math.round(i)}}function Yr(a){const e=vo(a);for(let t=0;t<e.length;t++){const i=e[t];if(To(i))return Sh(i)}}let yt=(function(a){return a.audioId3="org.id3",a.dateRange="com.apple.quicktime.HLS",a.emsg="https://aomedia.org/emsg/ID3",a.misbklv="urn:misb:KLV:bin:1910.1",a})({});function Bt(a="",e=9e4){return{type:a,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}class Wr{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(e,t,i,s){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(e){this.initPTS=e,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(e,t){return!1}appendFrame(e,t,i){}demux(e,t){this.cachedData&&(e=St(this.cachedData,e),this.cachedData=null);let i=ts(e,0),s=i?i.length:0,r;const n=this._audioTrack,o=this._id3Track,c=i?Yr(i):void 0,u=e.length;for((this.basePTS===null||this.frameIndex===0&&se(c))&&(this.basePTS=xh(c,t,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),i&&i.length>0&&o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:yt.audioId3,duration:Number.POSITIVE_INFINITY});s<u;){if(this.canParse(e,s)){const h=this.appendFrame(n,e,s);h?(this.frameIndex++,this.lastPTS=h.sample.pts,s+=h.length,r=s):s=u}else dh(e,s)?(i=ts(e,s),o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:yt.audioId3,duration:Number.POSITIVE_INFINITY}),s+=i.length,r=s):s++;if(s===u&&r!==u){const h=e.slice(r);this.cachedData?this.cachedData=St(this.cachedData,h):this.cachedData=h}}return{audioTrack:n,videoTrack:Bt(),id3Track:o,textTrack:Bt()}}demuxSampleAes(e,t,i){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(e){const t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:Bt(),id3Track:this._id3Track,textTrack:Bt()}}destroy(){this.cachedData=null,this._audioTrack=this._id3Track=void 0}}const xh=(a,e,t)=>{if(se(a))return a*90;const i=t?t.baseTime*9e4/t.timescale:0;return e*9e4+i};let Bs=null;const bh=[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],Lh=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],Rh=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],Dh=[0,1,1,4];function So(a,e,t,i,s){if(t+24>e.length)return;const r=xo(e,t);if(r&&t+r.frameLength<=e.length){const n=r.samplesPerFrame*9e4/r.sampleRate,o=i+s*n,c={unit:e.subarray(t,t+r.frameLength),pts:o,dts:o};return a.config=[],a.channelCount=r.channelCount,a.samplerate=r.sampleRate,a.samples.push(c),{sample:c,length:r.frameLength,missing:0}}}function xo(a,e){const t=a[e+1]>>3&3,i=a[e+1]>>1&3,s=a[e+2]>>4&15,r=a[e+2]>>2&3;if(t!==1&&s!==0&&s!==15&&r!==3){const n=a[e+2]>>1&1,o=a[e+3]>>6,c=t===3?3-i:i===3?3:4,u=bh[c*14+s-1]*1e3,f=Lh[(t===3?0:t===2?1:2)*3+r],g=o===3?1:2,I=Rh[t][i],m=Dh[i],E=I*8*m,v=Math.floor(I*u/f+n)*m;if(Bs===null){const L=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Bs=L?parseInt(L[1]):0}return!!Bs&&Bs<=87&&i===2&&u>=224e3&&o===0&&(a[e+3]=a[e+3]|128),{sampleRate:f,channelCount:g,frameLength:v,samplesPerFrame:E}}}function jr(a,e){return a[e]===255&&(a[e+1]&224)===224&&(a[e+1]&6)!==0}function bo(a,e){return e+1<a.length&&jr(a,e)}function Ph(a,e){return jr(a,e)&&4<=a.length-e}function Lo(a,e){if(e+1<a.length&&jr(a,e)){const i=xo(a,e);let s=4;i!=null&&i.frameLength&&(s=i.frameLength);const r=e+s;return r===a.length||bo(a,r)}return!1}class _h extends Wr{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t}resetInitSegment(e,t,i,s){super.resetInitSegment(e,t,i,s),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}static probe(e,t){if(!e)return!1;const i=ts(e,0);let s=i?.length||0;if(Lo(e,s))return!1;for(let r=e.length;s<r;s++)if(ch(e,s))return t.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return uh(e,t)}appendFrame(e,t,i){Co(e,this.observer,t,i,e.manifestCodec);const s=Eo(e,t,i,this.basePTS,this.frameIndex);if(s&&s.missing===0)return s}}const Ro=(a,e)=>{let t=0,i=5;e+=i;const s=new Uint32Array(1),r=new Uint32Array(1),n=new Uint8Array(1);for(;i>0;){n[0]=a[e];const o=Math.min(i,8),c=8-o;r[0]=4278190080>>>24+c<<c,s[0]=(n[0]&r[0])>>c,t=t?t<<o|s[0]:s[0],e+=1,i-=o}return t};class wh extends Wr{constructor(e){super(),this.observer=void 0,this.observer=e}resetInitSegment(e,t,i,s){super.resetInitSegment(e,t,i,s),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}canParse(e,t){return t+64<e.length}appendFrame(e,t,i){const s=Do(e,t,i,this.basePTS,this.frameIndex);if(s!==-1)return{sample:e.samples[e.samples.length-1],length:s,missing:0}}static probe(e){if(!e)return!1;const t=ts(e,0);if(!t)return!1;const i=t.length;return e[i]===11&&e[i+1]===119&&Yr(t)!==void 0&&Ro(e,i)<16}}function Do(a,e,t,i,s){if(t+8>e.length||e[t]!==11||e[t+1]!==119)return-1;const r=e[t+4]>>6;if(r>=3)return-1;const o=[48e3,44100,32e3][r],c=e[t+4]&63,h=[64,69,96,64,70,96,80,87,120,80,88,120,96,104,144,96,105,144,112,121,168,112,122,168,128,139,192,128,140,192,160,174,240,160,175,240,192,208,288,192,209,288,224,243,336,224,244,336,256,278,384,256,279,384,320,348,480,320,349,480,384,417,576,384,418,576,448,487,672,448,488,672,512,557,768,512,558,768,640,696,960,640,697,960,768,835,1152,768,836,1152,896,975,1344,896,976,1344,1024,1114,1536,1024,1115,1536,1152,1253,1728,1152,1254,1728,1280,1393,1920,1280,1394,1920][c*3+r]*2;if(t+h>e.length)return-1;const f=e[t+6]>>5;let g=0;f===2?g+=2:(f&1&&f!==1&&(g+=2),f&4&&(g+=2));const I=(e[t+6]<<8|e[t+7])>>12-g&1,E=[2,1,2,3,3,4,4,5][f]+I,v=e[t+5]>>3,x=e[t+5]&7,D=new Uint8Array([r<<6|v<<1|x>>2,(x&3)<<6|f<<3|I<<2|c>>4,c<<4&224]),L=1536/o*9e4,w=i+s*L,N=e.subarray(t,t+h);return a.config=D,a.channelCount=E,a.samplerate=o,a.samples.push({unit:N,pts:w}),h}class kh extends Wr{resetInitSegment(e,t,i,s){super.resetInitSegment(e,t,i,s),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;const t=ts(e,0);let i=t?.length||0;if(t&&e[i]===11&&e[i+1]===119&&Yr(t)!==void 0&&Ro(e,i)<=16)return!1;for(let s=e.length;i<s;i++)if(Lo(e,i))return Oe.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return Ph(e,t)}appendFrame(e,t,i){if(this.basePTS!==null)return So(e,t,i,this.basePTS,this.frameIndex)}}const Mh=/\/emsg[-/]ID3/i;class Oh{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,i,s){const r=this.videoTrack=Bt("video",1),n=this.audioTrack=Bt("audio",1),o=this.txtTrack=Bt("text",1);if(this.id3Track=Bt("id3",1),this.timeOffset=0,!(e!=null&&e.byteLength))return;const c=oa(e);if(c.video){const{id:u,timescale:h,codec:f,supplemental:g}=c.video;r.id=u,r.timescale=o.timescale=h,r.codec=f,r.supplemental=g}if(c.audio){const{id:u,timescale:h,codec:f}=c.audio;n.id=u,n.timescale=h,n.codec=f}o.id=sa.text,r.sampleDuration=0,r.duration=n.duration=s}resetContiguity(){this.remainderData=null}static probe(e){return ku(e)}demux(e,t){this.timeOffset=t;let i=e;const s=this.videoTrack,r=this.txtTrack;if(this.config.progressive){this.remainderData&&(i=St(this.remainderData,e));const o=Uu(i);this.remainderData=o.remainder,s.samples=o.valid||new Uint8Array}else s.samples=i;const n=this.extractID3Track(s,t);return r.samples=ua(t,s),{videoTrack:s,audioTrack:this.audioTrack,id3Track:n,textTrack:this.txtTrack}}flush(){const e=this.timeOffset,t=this.videoTrack,i=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;const s=this.extractID3Track(t,this.timeOffset);return i.samples=ua(e,t),{videoTrack:t,audioTrack:Bt(),id3Track:s,textTrack:Bt()}}extractID3Track(e,t){const i=this.id3Track;if(e.samples.length){const s=xe(e.samples,["emsg"]);s&&s.forEach(r=>{const n=Gu(r);if(Mh.test(n.schemeIdUri)){const o=Po(n,t);let c=n.eventDuration===4294967295?Number.POSITIVE_INFINITY:n.eventDuration/n.timeScale;c<=.001&&(c=Number.POSITIVE_INFINITY);const u=n.payload;i.samples.push({data:u,len:u.byteLength,dts:o,pts:o,type:yt.emsg,duration:c})}else if(this.config.enableEmsgKLVMetadata&&n.schemeIdUri.startsWith("urn:misb:KLV:bin:1910.1")){const o=Po(n,t);i.samples.push({data:n.payload,len:n.payload.byteLength,dts:o,pts:o,type:yt.misbklv,duration:Number.POSITIVE_INFINITY})}})}return i}demuxSampleAes(e,t,i){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){this.config=null,this.remainderData=null,this.videoTrack=this.audioTrack=this.id3Track=this.txtTrack=void 0}}function Po(a,e){return se(a.presentationTime)?a.presentationTime/a.timeScale:e+a.presentationTimeDelta/a.timeScale}class Fh{constructor(e,t,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new Rr(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,ni.cbc)}decryptAacSample(e,t,i){const s=e[t].unit;if(s.length<=16)return;const r=s.subarray(16,s.length-s.length%16),n=r.buffer.slice(r.byteOffset,r.byteOffset+r.length);this.decryptBuffer(n).then(o=>{const c=new Uint8Array(o);s.set(c,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,i)}).catch(i)}decryptAacSamples(e,t,i){for(;;t++){if(t>=e.length){i();return}if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,i),!this.decrypter.isSync()))return}}getAvcEncryptedData(e){const t=Math.floor((e.length-48)/160)*16+16,i=new Int8Array(t);let s=0;for(let r=32;r<e.length-16;r+=160,s+=16)i.set(e.subarray(r,r+16),s);return i}getAvcDecryptedUnit(e,t){const i=new Uint8Array(t);let s=0;for(let r=32;r<e.length-16;r+=160,s+=16)e.set(i.subarray(s,s+16),r);return e}decryptAvcSample(e,t,i,s,r){const n=ca(r.data),o=this.getAvcEncryptedData(n);this.decryptBuffer(o.buffer).then(c=>{r.data=this.getAvcDecryptedUnit(n,c),this.decrypter.isSync()||this.decryptAvcSamples(e,t,i+1,s)}).catch(s)}decryptAvcSamples(e,t,i,s){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,i=0){if(t>=e.length){s();return}const r=e[t].units;for(;!(i>=r.length);i++){const n=r[i];if(!(n.data.length<=48||n.type!==1&&n.type!==5)&&(this.decryptAvcSample(e,t,i,s,n),!this.decrypter.isSync()))return}}}}class _o{constructor(){this.VideoSample=null}createVideoSample(e,t,i){return{key:e,frame:!1,pts:t,dts:i,units:[],length:0}}getLastNalUnit(e){var t;let i=this.VideoSample,s;if((!i||i.units.length===0)&&(i=e[e.length-1]),(t=i)!=null&&t.units){const r=i.units;s=r[r.length-1]}return s}pushAccessUnit(e,t){if(e.units.length&&e.frame){if(e.pts===void 0){const i=t.samples,s=i.length;if(s){const r=i[s-1];e.pts=r.pts,e.dts=r.dts}else{t.dropped++;return}}t.samples.push(e)}}parseNALu(e,t,i){const s=t.byteLength;let r=e.naluState||0;const n=r,o=[];let c=0,u,h,f,g=-1,I=0;for(r===-1&&(g=0,I=this.getNALuType(t,0),r=0,c=1);c<s;){if(u=t[c++],!r){r=u?0:1;continue}if(r===1){r=u?0:2;continue}if(!u)r=3;else if(u===1){if(h=c-r-1,g>=0){const m={data:t.subarray(g,h),type:I};o.push(m)}else{const m=this.getLastNalUnit(e.samples);m&&(n&&c<=4-n&&m.state&&(m.data=m.data.subarray(0,m.data.byteLength-n)),h>0&&(m.data=St(m.data,t.subarray(0,h)),m.state=0))}c<s?(f=this.getNALuType(t,c),g=c,I=f,r=0):r=-1}else r=0}if(g>=0&&r>=0){const m={data:t.subarray(g,s),type:I,state:r};o.push(m)}if(o.length===0){const m=this.getLastNalUnit(e.samples);m&&(m.data=St(m.data,t))}return e.naluState=r,o}}class is{constructor(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){const e=this.data,t=this.bytesAvailable,i=e.byteLength-t,s=new Uint8Array(4),r=Math.min(4,t);if(r===0)throw new Error("no bytes available");s.set(e.subarray(i,i+r)),this.word=new DataView(s.buffer).getUint32(0),this.bitsAvailable=r*8,this.bytesAvailable-=r}skipBits(e){let t;e=Math.min(e,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,t=e>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}readBits(e){let t=Math.min(this.bitsAvailable,e);const i=this.word>>>32-t;if(e>32&&Oe.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return t=e-t,t>0&&this.bitsAvailable?i<<t|this.readBits(t):i}skipLZ(){let e;for(e=0;e<this.bitsAvailable;++e)if((this.word&2147483648>>>e)!==0)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){const e=this.skipLZ();return this.readBits(e+1)-1}readEG(){const e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}readBoolean(){return this.readBits(1)===1}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}}class Nh extends _o{parsePES(e,t,i,s){const r=this.parseNALu(e,i.data,s);let n=this.VideoSample,o,c=!1;i.data=null,n&&r.length&&!e.audFound&&(this.pushAccessUnit(n,e),n=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),r.forEach(u=>{var h,f;switch(u.type){case 1:{let E=!1;o=!0;const v=u.data;if(c&&v.length>4){const x=this.readSliceType(v);(x===2||x===4||x===7||x===9)&&(E=!0)}if(E){var g;(g=n)!=null&&g.frame&&!n.key&&(this.pushAccessUnit(n,e),n=this.VideoSample=null)}n||(n=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),n.frame=!0,n.key=E;break}case 5:o=!0,(h=n)!=null&&h.frame&&!n.key&&(this.pushAccessUnit(n,e),n=this.VideoSample=null),n||(n=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),n.key=!0,n.frame=!0;break;case 6:{o=!0,Cr(u.data,1,i.pts,t.samples);break}case 7:{var I,m;o=!0,c=!0;const E=u.data,v=this.readSPS(E);if(!e.sps||e.width!==v.width||e.height!==v.height||((I=e.pixelRatio)==null?void 0:I[0])!==v.pixelRatio[0]||((m=e.pixelRatio)==null?void 0:m[1])!==v.pixelRatio[1]){e.width=v.width,e.height=v.height,e.pixelRatio=v.pixelRatio,e.sps=[E];const x=E.subarray(1,4);let D="avc1.";for(let L=0;L<3;L++){let w=x[L].toString(16);w.length<2&&(w="0"+w),D+=w}e.codec=D}break}case 8:o=!0,e.pps=[u.data];break;case 9:o=!0,e.audFound=!0,(f=n)!=null&&f.frame&&(this.pushAccessUnit(n,e),n=null),n||(n=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts));break;case 12:o=!0;break;default:o=!1;break}n&&o&&n.units.push(u)}),s&&n&&(this.pushAccessUnit(n,e),this.VideoSample=null)}getNALuType(e,t){return e[t]&31}readSliceType(e){const t=new is(e);return t.readUByte(),t.readUEG(),t.readUEG()}skipScalingList(e,t){let i=8,s=8,r;for(let n=0;n<e;n++)s!==0&&(r=t.readEG(),s=(i+r+256)%256),i=s===0?i:s}readSPS(e){const t=new is(e);let i=0,s=0,r=0,n=0,o,c,u;const h=t.readUByte.bind(t),f=t.readBits.bind(t),g=t.readUEG.bind(t),I=t.readBoolean.bind(t),m=t.skipBits.bind(t),E=t.skipEG.bind(t),v=t.skipUEG.bind(t),x=this.skipScalingList.bind(this);h();const D=h();if(f(5),m(3),h(),v(),D===100||D===110||D===122||D===244||D===44||D===83||D===86||D===118||D===128){const $=g();if($===3&&m(1),v(),v(),m(1),I())for(c=$!==3?8:12,u=0;u<c;u++)I()&&(u<6?x(16,t):x(64,t))}v();const L=g();if(L===0)g();else if(L===1)for(m(1),E(),E(),o=g(),u=0;u<o;u++)E();v(),m(1);const w=g(),N=g(),K=f(1);K===0&&m(1),m(1),I()&&(i=g(),s=g(),r=g(),n=g());let p=[1,1];if(I()&&I())switch(h()){case 1:p=[1,1];break;case 2:p=[12,11];break;case 3:p=[10,11];break;case 4:p=[16,11];break;case 5:p=[40,33];break;case 6:p=[24,11];break;case 7:p=[20,11];break;case 8:p=[32,11];break;case 9:p=[80,33];break;case 10:p=[18,11];break;case 11:p=[15,11];break;case 12:p=[64,33];break;case 13:p=[160,99];break;case 14:p=[4,3];break;case 15:p=[3,2];break;case 16:p=[2,1];break;case 255:{p=[h()<<8|h(),h()<<8|h()];break}}return{width:Math.ceil((w+1)*16-i*2-s*2),height:(2-K)*(N+1)*16-(K?2:4)*(r+n),pixelRatio:p}}}class Bh extends _o{constructor(...e){super(...e),this.initVPS=null}parsePES(e,t,i,s){const r=this.parseNALu(e,i.data,s);let n=this.VideoSample,o,c=!1;i.data=null,n&&r.length&&!e.audFound&&(this.pushAccessUnit(n,e),n=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),r.forEach(u=>{var h,f;switch(u.type){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:n||(n=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),n.frame=!0,o=!0;break;case 16:case 17:case 18:case 21:if(o=!0,c){var g;(g=n)!=null&&g.frame&&!n.key&&(this.pushAccessUnit(n,e),n=this.VideoSample=null)}n||(n=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),n.key=!0,n.frame=!0;break;case 19:case 20:o=!0,(h=n)!=null&&h.frame&&!n.key&&(this.pushAccessUnit(n,e),n=this.VideoSample=null),n||(n=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),n.key=!0,n.frame=!0;break;case 39:o=!0,Cr(u.data,2,i.pts,t.samples);break;case 32:o=!0,e.vps||(typeof e.params!="object"&&(e.params={}),e.params=Ne(e.params,this.readVPS(u.data)),this.initVPS=u.data),e.vps=[u.data];break;case 33:if(o=!0,c=!0,e.vps!==void 0&&e.vps[0]!==this.initVPS&&e.sps!==void 0&&!this.matchSPS(e.sps[0],u.data)&&(this.initVPS=e.vps[0],e.sps=e.pps=void 0),!e.sps){const I=this.readSPS(u.data);e.width=I.width,e.height=I.height,e.pixelRatio=I.pixelRatio,e.codec=I.codecString,e.sps=[],typeof e.params!="object"&&(e.params={});for(const m in I.params)e.params[m]=I.params[m]}this.pushParameterSet(e.sps,u.data,e.vps),n||(n=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),n.key=!0;break;case 34:if(o=!0,typeof e.params=="object"){if(!e.pps){e.pps=[];const I=this.readPPS(u.data);for(const m in I)e.params[m]=I[m]}this.pushParameterSet(e.pps,u.data,e.vps)}break;case 35:o=!0,e.audFound=!0,(f=n)!=null&&f.frame&&(this.pushAccessUnit(n,e),n=null),n||(n=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts));break;default:o=!1;break}n&&o&&n.units.push(u)}),s&&n&&(this.pushAccessUnit(n,e),this.VideoSample=null)}pushParameterSet(e,t,i){(i&&i[0]===this.initVPS||!i&&!e.length)&&e.push(t)}getNALuType(e,t){return(e[t]&126)>>>1}ebsp2rbsp(e){const t=new Uint8Array(e.byteLength);let i=0;for(let s=0;s<e.byteLength;s++)s>=2&&e[s]===3&&e[s-1]===0&&e[s-2]===0||(t[i]=e[s],i++);return new Uint8Array(t.buffer,0,i)}pushAccessUnit(e,t){super.pushAccessUnit(e,t),this.initVPS&&(this.initVPS=null)}readVPS(e){const t=new is(e);t.readUByte(),t.readUByte(),t.readBits(4),t.skipBits(2),t.readBits(6);const i=t.readBits(3),s=t.readBoolean();return{numTemporalLayers:i+1,temporalIdNested:s}}readSPS(e){const t=new is(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.readBits(4);const i=t.readBits(3);t.readBoolean();const s=t.readBits(2),r=t.readBoolean(),n=t.readBits(5),o=t.readUByte(),c=t.readUByte(),u=t.readUByte(),h=t.readUByte(),f=t.readUByte(),g=t.readUByte(),I=t.readUByte(),m=t.readUByte(),E=t.readUByte(),v=t.readUByte(),x=t.readUByte(),D=[],L=[];for(let Pe=0;Pe<i;Pe++)D.push(t.readBoolean()),L.push(t.readBoolean());if(i>0)for(let Pe=i;Pe<8;Pe++)t.readBits(2);for(let Pe=0;Pe<i;Pe++)D[Pe]&&(t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte()),L[Pe]&&t.readUByte();t.readUEG();const w=t.readUEG();w==3&&t.skipBits(1);const N=t.readUEG(),K=t.readUEG(),p=t.readBoolean();let $=0,F=0,O=0,W=0;p&&($+=t.readUEG(),F+=t.readUEG(),O+=t.readUEG(),W+=t.readUEG());const ie=t.readUEG(),X=t.readUEG(),ce=t.readUEG(),ue=t.readBoolean();for(let Pe=ue?0:i;Pe<=i;Pe++)t.skipUEG(),t.skipUEG(),t.skipUEG();if(t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.readBoolean()&&t.readBoolean())for(let ze=0;ze<4;ze++)for(let Ye=0;Ye<(ze===3?2:6);Ye++)if(!t.readBoolean())t.readUEG();else{const vt=Math.min(64,1<<4+(ze<<1));ze>1&&t.readEG();for(let di=0;di<vt;di++)t.readEG()}t.readBoolean(),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.skipUEG(),t.skipUEG(),t.readBoolean());const re=t.readUEG();let le=0;for(let Pe=0;Pe<re;Pe++){let ze=!1;if(Pe!==0&&(ze=t.readBoolean()),ze){Pe===re&&t.readUEG(),t.readBoolean(),t.readUEG();let Ye=0;for(let Jt=0;Jt<=le;Jt++){const vt=t.readBoolean();let di=!1;vt||(di=t.readBoolean()),(vt||di)&&Ye++}le=Ye}else{const Ye=t.readUEG(),Jt=t.readUEG();le=Ye+Jt;for(let vt=0;vt<Ye;vt++)t.readUEG(),t.readBoolean();for(let vt=0;vt<Jt;vt++)t.readUEG(),t.readBoolean()}}if(t.readBoolean()){const Pe=t.readUEG();for(let ze=0;ze<Pe;ze++){for(let Ye=0;Ye<ce+4;Ye++)t.readBits(1);t.readBits(1)}}let J=0,ee=1,ve=1,ke=!0,Te=1,Le=0;t.readBoolean(),t.readBoolean();let it=!1;if(t.readBoolean()){if(t.readBoolean()){const st=t.readUByte(),fi=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2],Ht=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1];st>0&&st<16?(ee=fi[st-1],ve=Ht[st-1]):st===255&&(ee=t.readBits(16),ve=t.readBits(16))}if(t.readBoolean()&&t.readBoolean(),t.readBoolean()&&(t.readBits(3),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.readUByte(),t.readUByte())),t.readBoolean()&&(t.readUEG(),t.readUEG()),t.readBoolean(),t.readBoolean(),t.readBoolean(),it=t.readBoolean(),it&&(t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG()),t.readBoolean()&&(Te=t.readBits(32),Le=t.readBits(32),t.readBoolean()&&t.readUEG(),t.readBoolean())){const Ht=t.readBoolean(),fe=t.readBoolean();let Xe=!1;(Ht||fe)&&(Xe=t.readBoolean(),Xe&&(t.readUByte(),t.readBits(5),t.readBoolean(),t.readBits(5)),t.readBits(4),t.readBits(4),Xe&&t.readBits(4),t.readBits(5),t.readBits(5),t.readBits(5));for(let tr=0;tr<=i;tr++){ke=t.readBoolean();const Ln=ke||t.readBoolean();let ir=!1;Ln?t.readEG():ir=t.readBoolean();const os=ir?1:t.readUEG()+1;if(Ht)for(let gi=0;gi<os;gi++)t.readUEG(),t.readUEG(),Xe&&(t.readUEG(),t.readUEG()),t.skipBits(1);if(fe)for(let gi=0;gi<os;gi++)t.readUEG(),t.readUEG(),Xe&&(t.readUEG(),t.readUEG()),t.skipBits(1)}}t.readBoolean()&&(t.readBoolean(),t.readBoolean(),t.readBoolean(),J=t.readUEG())}let lt=N,je=K;if(p){let Pe=1,ze=1;w===1?Pe=ze=2:w==2&&(Pe=2),lt=N-Pe*F-Pe*$,je=K-ze*W-ze*O}const Qt=s?["A","B","C"][s]:"",ci=o<<24|c<<16|u<<8|h;let hi=0;for(let Pe=0;Pe<32;Pe++)hi=(hi|(ci>>Pe&1)<<31-Pe)>>>0;let Gi=hi.toString(16);return n===1&&Gi==="2"&&(Gi="6"),{codecString:`hvc1.${Qt}${n}.${Gi}.${r?"H":"L"}${x}.B0`,params:{general_tier_flag:r,general_profile_idc:n,general_profile_space:s,general_profile_compatibility_flags:[o,c,u,h],general_constraint_indicator_flags:[f,g,I,m,E,v],general_level_idc:x,bit_depth:ie+8,bit_depth_luma_minus8:ie,bit_depth_chroma_minus8:X,min_spatial_segmentation_idc:J,chroma_format_idc:w,frame_rate:{fixed:ke,fps:Le/Te}},width:lt,height:je,pixelRatio:[ee,ve]}}readPPS(e){const t=new is(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.skipUEG(),t.skipUEG(),t.skipBits(2),t.skipBits(3),t.skipBits(2),t.skipUEG(),t.skipUEG(),t.skipEG(),t.skipBits(2),t.readBoolean()&&t.skipUEG(),t.skipEG(),t.skipEG(),t.skipBits(4);const s=t.readBoolean(),r=t.readBoolean();let n=1;return r&&s?n=0:r?n=3:s&&(n=2),{parallelismType:n}}matchSPS(e,t){return String.fromCharCode.apply(null,e).substr(3)===String.fromCharCode.apply(null,t).substr(3)}}const tt=188;class ai{constructor(e,t,i,s){this.logger=void 0,this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=e,this.config=t,this.typeSupported=i,this.logger=s,this.videoParser=null}static probe(e,t){const i=ai.syncOffset(e);return i>0&&t.warn(`MPEG2-TS detected but first sync word found @ offset ${i}`),i!==-1}static syncOffset(e){const t=e.length;let i=Math.min(tt*5,t-tt)+1,s=0;for(;s<i;){let r=!1,n=-1,o=0;for(let c=s;c<t;c+=tt)if(e[c]===71&&(t-c===tt||e[c+tt]===71)){if(o++,n===-1&&(n=c,n!==0&&(i=Math.min(n+tt*99,e.length-tt)+1)),r||(r=zr(e,c)===0),r&&o>1&&(n===0&&o>2||c+tt>i))return n}else{if(o)return-1;break}s++}return-1}static createTrack(e,t){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:sa[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}}resetInitSegment(e,t,i,s){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=ai.createTrack("video"),this._videoTrack.duration=s,this._audioTrack=ai.createTrack("audio",s),this._id3Track=ai.createTrack("id3"),this._txtTrack=ai.createTrack("text"),this._audioTrack.segmentCodec="aac",this.videoParser=null,this.aacOverFlow=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=i}resetTimeStamp(){}resetContiguity(){const{_audioTrack:e,_videoTrack:t,_id3Track:i}=this;e&&(e.pesData=null),t&&(t.pesData=null),i&&(i.pesData=null),this.aacOverFlow=null,this.remainderData=null}demux(e,t,i=!1,s=!1){i||(this.sampleAes=null);let r;const n=this._videoTrack,o=this._audioTrack,c=this._id3Track,u=this._txtTrack;let h=n.pid,f=n.pesData,g=o.pid,I=c.pid,m=o.pesData,E=c.pesData,v=null,x=this.pmtParsed,D=this._pmtId,L=e.length;if(this.remainderData&&(e=St(this.remainderData,e),L=e.length,this.remainderData=null),L<tt&&!s)return this.remainderData=e,{audioTrack:o,videoTrack:n,id3Track:c,textTrack:u};const w=Math.max(0,ai.syncOffset(e));L-=(L-w)%tt,L<e.byteLength&&!s&&(this.remainderData=new Uint8Array(e.buffer,L,e.buffer.byteLength-L));let N=0;for(let p=w;p<L;p+=tt)if(e[p]===71){const $=!!(e[p+1]&64),F=zr(e,p),O=(e[p+3]&48)>>4;let W;if(O>1){if(W=p+5+e[p+4],W===p+tt)continue}else W=p+4;switch(F){case h:$&&(f&&(r=Oi(f,this.logger))&&(this.readyVideoParser(n.segmentCodec),this.videoParser!==null&&this.videoParser.parsePES(n,u,r,!1)),f={data:[],size:0}),f&&(f.data.push(e.subarray(W,p+tt)),f.size+=p+tt-W);break;case g:if($){if(m&&(r=Oi(m,this.logger)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,r);break;case"mp3":this.parseMPEGPES(o,r);break;case"ac3":this.parseAC3PES(o,r);break}m={data:[],size:0}}m&&(m.data.push(e.subarray(W,p+tt)),m.size+=p+tt-W);break;case I:$&&(E&&(r=Oi(E,this.logger))&&this.parseID3PES(c,r),E={data:[],size:0}),E&&(E.data.push(e.subarray(W,p+tt)),E.size+=p+tt-W);break;case 0:$&&(W+=e[W]+1),D=this._pmtId=Uh(e,W);break;case D:{$&&(W+=e[W]+1);const ie=$h(e,W,this.typeSupported,i,this.observer,this.logger);h=ie.videoPid,h>0&&(n.pid=h,n.segmentCodec=ie.segmentVideoCodec),g=ie.audioPid,g>0&&(o.pid=g,o.segmentCodec=ie.segmentAudioCodec),I=ie.id3Pid,I>0&&(c.pid=I),v!==null&&!x&&(this.logger.warn(`MPEG-TS PMT found at ${p} after unknown PID '${v}'. Backtracking to sync byte @${w} to parse all TS packets.`),v=null,p=w-188),x=this.pmtParsed=!0;break}case 17:case 8191:break;default:v=F;break}}else N++;N>0&&qr(this.observer,new Error(`Found ${N} TS packet/s that do not start with 0x47`),void 0,this.logger),n.pesData=f,o.pesData=m,c.pesData=E;const K={audioTrack:o,videoTrack:n,id3Track:c,textTrack:u};return s&&this.extractRemainingSamples(K),K}flush(){const{remainderData:e}=this;this.remainderData=null;let t;return e?t=this.demux(e,-1,!1,!0):t={videoTrack:this._videoTrack,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:i,id3Track:s,textTrack:r}=e,n=i.pesData,o=t.pesData,c=s.pesData;let u;if(n&&(u=Oi(n,this.logger))?(this.readyVideoParser(i.segmentCodec),this.videoParser!==null&&(this.videoParser.parsePES(i,r,u,!0),i.pesData=null)):i.pesData=n,o&&(u=Oi(o,this.logger))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,u);break;case"mp3":this.parseMPEGPES(t,u);break;case"ac3":this.parseAC3PES(t,u);break}t.pesData=null}else o!=null&&o.size&&this.logger.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=o;c&&(u=Oi(c,this.logger))?(this.parseID3PES(s,u),s.pesData=null):s.pesData=c}demuxSampleAes(e,t,i){const s=this.demux(e,i,!0,!this.config.progressive),r=this.sampleAes=new Fh(this.observer,this.config,t);return this.decrypt(s,r)}readyVideoParser(e){this.videoParser===null&&(e==="avc"?this.videoParser=new Nh:e==="hevc"&&(this.videoParser=new Bh))}decrypt(e,t){return new Promise(i=>{const{audioTrack:s,videoTrack:r}=e;s.samples&&s.segmentCodec==="aac"?t.decryptAacSamples(s.samples,0,()=>{r.samples?t.decryptAvcSamples(r.samples,0,0,()=>{i(e)}):i(e)}):r.samples&&t.decryptAvcSamples(r.samples,0,0,()=>{i(e)})})}destroy(){this.observer&&this.observer.removeAllListeners(),this.config=this.logger=this.observer=null,this.aacOverFlow=this.videoParser=this.remainderData=this.sampleAes=null,this._videoTrack=this._audioTrack=this._id3Track=this._txtTrack=void 0}parseAACPES(e,t){let i=0;const s=this.aacOverFlow;let r=t.data;if(s){this.aacOverFlow=null;const f=s.missing,g=s.sample.unit.byteLength;if(f===-1)r=St(s.sample.unit,r);else{const I=g-f;s.sample.unit.set(r.subarray(0,f),I),e.samples.push(s.sample),i=s.missing}}let n,o;for(n=i,o=r.length;n<o-1&&!Fs(r,n);n++);if(n!==i){let f;const g=n<o-1;if(g?f=`AAC PES did not start with ADTS header,offset:${n}`:f="No ADTS header found in AAC PES",qr(this.observer,new Error(f),g,this.logger),!g)return}Co(e,this.observer,r,n,this.audioCodec);let c;if(t.pts!==void 0)c=t.pts;else if(s){const f=yo(e.samplerate);c=s.sample.pts+f}else{this.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}let u=0,h;for(;n<o;)if(h=Eo(e,r,n,c,u),n+=h.length,h.missing){this.aacOverFlow=h;break}else for(u++;n<o-1&&!Fs(r,n);n++);}parseMPEGPES(e,t){const i=t.data,s=i.length;let r=0,n=0;const o=t.pts;if(o===void 0){this.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;n<s;)if(bo(i,n)){const c=So(e,i,n,o,r);if(c)n+=c.length,r++;else break}else n++}parseAC3PES(e,t){{const i=t.data,s=t.pts;if(s===void 0){this.logger.warn("[tsdemuxer]: AC3 PES unknown PTS");return}const r=i.length;let n=0,o=0,c;for(;o<r&&(c=Do(e,i,o,s,n++))>0;)o+=c}}parseID3PES(e,t){if(t.pts===void 0){this.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}const i=Ne({},t,{type:this._videoTrack?yt.emsg:yt.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(i)}}function zr(a,e){return((a[e+1]&31)<<8)+a[e+2]}function Uh(a,e){return(a[e+10]&31)<<8|a[e+11]}function $h(a,e,t,i,s,r){const n={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},o=(a[e+1]&15)<<8|a[e+2],c=e+3+o-4,u=(a[e+10]&15)<<8|a[e+11];for(e+=12+u;e<c;){const h=zr(a,e),f=(a[e+3]&15)<<8|a[e+4];switch(a[e]){case 207:if(!i){Xr("ADTS AAC",r);break}case 15:n.audioPid===-1&&(n.audioPid=h);break;case 21:n.id3Pid===-1&&(n.id3Pid=h);break;case 219:if(!i){Xr("H.264",r);break}case 27:n.videoPid===-1&&(n.videoPid=h);break;case 3:case 4:!t.mpeg&&!t.mp3?r.log("MPEG audio found, not supported in this browser"):n.audioPid===-1&&(n.audioPid=h,n.segmentAudioCodec="mp3");break;case 193:if(!i){Xr("AC-3",r);break}case 129:t.ac3?n.audioPid===-1&&(n.audioPid=h,n.segmentAudioCodec="ac3"):r.log("AC-3 audio found, not supported in this browser");break;case 6:if(n.audioPid===-1&&f>0){let g=e+5,I=f;for(;I>2;){switch(a[g]){case 106:t.ac3!==!0?r.log("AC-3 audio found, not supported in this browser for now"):(n.audioPid=h,n.segmentAudioCodec="ac3");break}const E=a[g+1]+2;g+=E,I-=E}}break;case 194:case 135:return qr(s,new Error("Unsupported EC-3 in M2TS found"),void 0,r),n;case 36:n.videoPid===-1&&(n.videoPid=h,n.segmentVideoCodec="hevc",r.log("HEVC in M2TS found"));break}e+=f+5}return n}function qr(a,e,t,i){i.warn(`parsing error: ${e.message}`),a.emit(y.ERROR,y.ERROR,{type:de.MEDIA_ERROR,details:U.FRAG_PARSING_ERROR,fatal:!1,levelRetry:t,error:e,reason:e.message})}function Xr(a,e){e.log(`${a} with AES-128-CBC encryption found in unencrypted stream`)}function Oi(a,e){let t=0,i,s,r,n,o;const c=a.data;if(!a||a.size===0)return null;for(;c[0].length<19&&c.length>1;)c[0]=St(c[0],c[1]),c.splice(1,1);if(i=c[0],(i[0]<<16)+(i[1]<<8)+i[2]===1){if(s=(i[4]<<8)+i[5],s&&s>a.size-6)return null;const h=i[7];h&192&&(n=(i[9]&14)*536870912+(i[10]&255)*4194304+(i[11]&254)*16384+(i[12]&255)*128+(i[13]&254)/2,h&64?(o=(i[14]&14)*536870912+(i[15]&255)*4194304+(i[16]&254)*16384+(i[17]&255)*128+(i[18]&254)/2,n-o>60*9e4&&(e.warn(`${Math.round((n-o)/9e4)}s delta between PTS and DTS, align them`),n=o)):o=n),r=i[8];let f=r+9;if(a.size<=f)return null;a.size-=f;const g=new Uint8Array(a.size);for(let I=0,m=c.length;I<m;I++){i=c[I];let E=i.byteLength;if(f)if(f>E){f-=E;continue}else i=i.subarray(f),E-=f,f=0;g.set(i,t),t+=E}return s&&(s-=r+3),{data:g,pts:n,dts:o,len:s}}return null}class Gh{static getSilentFrame(e,t){switch(e){case"mp4a.40.2":if(t===1)return new Uint8Array([0,200,0,128,35,128]);if(t===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(t===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(t===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(t===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(t===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(t===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}}}const oi=Math.pow(2,32)-1;class B{static init(){B.types={avc1:[],avcC:[],hvc1:[],hvcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};let e;for(e in B.types)B.types.hasOwnProperty(e)&&(B.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]),i=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]);B.HDLR_TYPES={video:t,audio:i};const s=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),r=new Uint8Array([0,0,0,0,0,0,0,0]);B.STTS=B.STSC=B.STCO=r,B.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),B.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),B.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),B.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const n=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),c=new Uint8Array([0,0,0,1]);B.FTYP=B.box(B.types.ftyp,n,c,n,o),B.DINF=B.box(B.types.dinf,B.box(B.types.dref,s))}static box(e,...t){let i=8,s=t.length;const r=s;for(;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]=i&255,n.set(e,4),s=0,i=8;s<r;s++)n.set(t[s],i),i+=t[s].byteLength;return n}static hdlr(e){return B.box(B.types.hdlr,B.HDLR_TYPES[e])}static mdat(e){return B.box(B.types.mdat,e)}static mdhd(e,t){t*=e;const i=Math.floor(t/(oi+1)),s=Math.floor(t%(oi+1));return B.box(B.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,e&255,i>>24,i>>16&255,i>>8&255,i&255,s>>24,s>>16&255,s>>8&255,s&255,85,196,0,0]))}static mdia(e){return B.box(B.types.mdia,B.mdhd(e.timescale||0,e.duration||0),B.hdlr(e.type),B.minf(e))}static mfhd(e){return B.box(B.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255]))}static minf(e){return e.type==="audio"?B.box(B.types.minf,B.box(B.types.smhd,B.SMHD),B.DINF,B.stbl(e)):B.box(B.types.minf,B.box(B.types.vmhd,B.VMHD),B.DINF,B.stbl(e))}static moof(e,t,i){return B.box(B.types.moof,B.mfhd(e),B.traf(i,t))}static moov(e){let t=e.length;const i=[];for(;t--;)i[t]=B.trak(e[t]);return B.box.apply(null,[B.types.moov,B.mvhd(e[0].timescale||0,e[0].duration||0)].concat(i).concat(B.mvex(e)))}static mvex(e){let t=e.length;const i=[];for(;t--;)i[t]=B.trex(e[t]);return B.box.apply(null,[B.types.mvex,...i])}static mvhd(e,t){t*=e;const i=Math.floor(t/(oi+1)),s=Math.floor(t%(oi+1)),r=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,i>>24,i>>16&255,i>>8&255,i&255,s>>24,s>>16&255,s>>8&255,s&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return B.box(B.types.mvhd,r)}static sdtp(e){const t=e.samples||[],i=new Uint8Array(4+t.length);let s,r;for(s=0;s<t.length;s++)r=t[s].flags,i[s+4]=r.dependsOn<<4|r.isDependedOn<<2|r.hasRedundancy;return B.box(B.types.sdtp,i)}static stbl(e){return B.box(B.types.stbl,B.stsd(e),B.box(B.types.stts,B.STTS),B.box(B.types.stsc,B.STSC),B.box(B.types.stsz,B.STSZ),B.box(B.types.stco,B.STCO))}static avc1(e){let t=[],i=[],s,r,n;for(s=0;s<e.sps.length;s++)r=e.sps[s],n=r.byteLength,t.push(n>>>8&255),t.push(n&255),t=t.concat(Array.prototype.slice.call(r));for(s=0;s<e.pps.length;s++)r=e.pps[s],n=r.byteLength,i.push(n>>>8&255),i.push(n&255),i=i.concat(Array.prototype.slice.call(r));const o=B.box(B.types.avcC,new Uint8Array([1,t[3],t[4],t[5],255,224|e.sps.length].concat(t).concat([e.pps.length]).concat(i))),c=e.width,u=e.height,h=e.pixelRatio[0],f=e.pixelRatio[1];return B.box(B.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,c>>8&255,c&255,u>>8&255,u&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,B.box(B.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),B.box(B.types.pasp,new Uint8Array([h>>24,h>>16&255,h>>8&255,h&255,f>>24,f>>16&255,f>>8&255,f&255])))}static esds(e){const t=e.config;return new Uint8Array([0,0,0,0,3,25,0,1,0,4,17,64,21,0,0,0,0,0,0,0,0,0,0,0,5,2,...t,6,1,2])}static audioStsd(e){const t=e.samplerate||0;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount||0,0,16,0,0,0,0,t>>8&255,t&255,0,0])}static mp4a(e){return B.box(B.types.mp4a,B.audioStsd(e),B.box(B.types.esds,B.esds(e)))}static mp3(e){return B.box(B.types[".mp3"],B.audioStsd(e))}static ac3(e){return B.box(B.types["ac-3"],B.audioStsd(e),B.box(B.types.dac3,e.config))}static stsd(e){const{segmentCodec:t}=e;if(e.type==="audio"){if(t==="aac")return B.box(B.types.stsd,B.STSD,B.mp4a(e));if(t==="ac3"&&e.config)return B.box(B.types.stsd,B.STSD,B.ac3(e));if(t==="mp3"&&e.codec==="mp3")return B.box(B.types.stsd,B.STSD,B.mp3(e))}else if(e.pps&&e.sps){if(t==="avc")return B.box(B.types.stsd,B.STSD,B.avc1(e));if(t==="hevc"&&e.vps)return B.box(B.types.stsd,B.STSD,B.hvc1(e))}else throw new Error("video track missing pps or sps");throw new Error(`unsupported ${e.type} segment codec (${t}/${e.codec})`)}static tkhd(e){const t=e.id,i=(e.duration||0)*(e.timescale||0),s=e.width||0,r=e.height||0,n=Math.floor(i/(oi+1)),o=Math.floor(i%(oi+1));return B.box(B.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,t&255,0,0,0,0,n>>24,n>>16&255,n>>8&255,n&255,o>>24,o>>16&255,o>>8&255,o&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,s>>8&255,s&255,0,0,r>>8&255,r&255,0,0]))}static traf(e,t){const i=B.sdtp(e),s=e.id,r=Math.floor(t/(oi+1)),n=Math.floor(t%(oi+1));return B.box(B.types.traf,B.box(B.types.tfhd,new Uint8Array([0,0,0,0,s>>24,s>>16&255,s>>8&255,s&255])),B.box(B.types.tfdt,new Uint8Array([1,0,0,0,r>>24,r>>16&255,r>>8&255,r&255,n>>24,n>>16&255,n>>8&255,n&255])),B.trun(e,i.length+16+20+8+16+8+8),i)}static trak(e){return e.duration=e.duration||4294967295,B.box(B.types.trak,B.tkhd(e),B.mdia(e))}static trex(e){const t=e.id;return B.box(B.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,t){const i=e.samples||[],s=i.length,r=12+16*s,n=new Uint8Array(r);let o,c,u,h,f,g;for(t+=8+r,n.set([e.type==="video"?1:0,0,15,1,s>>>24&255,s>>>16&255,s>>>8&255,s&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255],0),o=0;o<s;o++)c=i[o],u=c.duration,h=c.size,f=c.flags,g=c.cts,n.set([u>>>24&255,u>>>16&255,u>>>8&255,u&255,h>>>24&255,h>>>16&255,h>>>8&255,h&255,f.isLeading<<2|f.dependsOn,f.isDependedOn<<6|f.hasRedundancy<<4|f.paddingValue<<1|f.isNonSync,f.degradPrio&61440,f.degradPrio&15,g>>>24&255,g>>>16&255,g>>>8&255,g&255],12+16*o);return B.box(B.types.trun,n)}static initSegment(e){B.types||B.init();const t=B.moov(e);return St(B.FTYP,t)}static hvc1(e){const t=e.params,i=[e.vps,e.sps,e.pps],s=4,r=new Uint8Array([1,t.general_profile_space<<6|(t.general_tier_flag?32:0)|t.general_profile_idc,t.general_profile_compatibility_flags[0],t.general_profile_compatibility_flags[1],t.general_profile_compatibility_flags[2],t.general_profile_compatibility_flags[3],t.general_constraint_indicator_flags[0],t.general_constraint_indicator_flags[1],t.general_constraint_indicator_flags[2],t.general_constraint_indicator_flags[3],t.general_constraint_indicator_flags[4],t.general_constraint_indicator_flags[5],t.general_level_idc,240|t.min_spatial_segmentation_idc>>8,255&t.min_spatial_segmentation_idc,252|t.parallelismType,252|t.chroma_format_idc,248|t.bit_depth_luma_minus8,248|t.bit_depth_chroma_minus8,0,parseInt(t.frame_rate.fps),s-1|t.temporal_id_nested<<2|t.num_temporal_layers<<3|(t.frame_rate.fixed?64:0),i.length]);let n=r.length;for(let m=0;m<i.length;m+=1){n+=3;for(let E=0;E<i[m].length;E+=1)n+=2+i[m][E].length}const o=new Uint8Array(n);o.set(r,0),n=r.length;const c=i.length-1;for(let m=0;m<i.length;m+=1){o.set(new Uint8Array([32+m|(m===c?128:0),0,i[m].length]),n),n+=3;for(let E=0;E<i[m].length;E+=1)o.set(new Uint8Array([i[m][E].length>>8,i[m][E].length&255]),n),n+=2,o.set(i[m][E],n),n+=i[m][E].length}const u=B.box(B.types.hvcC,o),h=e.width,f=e.height,g=e.pixelRatio[0],I=e.pixelRatio[1];return B.box(B.types.hvc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,h>>8&255,h&255,f>>8&255,f&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),u,B.box(B.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),B.box(B.types.pasp,new Uint8Array([g>>24,g>>16&255,g>>8&255,g&255,I>>24,I>>16&255,I>>8&255,I&255])))}}B.types=void 0,B.HDLR_TYPES=void 0,B.STTS=void 0,B.STSC=void 0,B.STCO=void 0,B.STSZ=void 0,B.VMHD=void 0,B.SMHD=void 0,B.STSD=void 0,B.FTYP=void 0,B.DINF=void 0;const wo=9e4;function Zr(a,e,t=1,i=!1){const s=a*e*t;return i?Math.round(s):s}function Hh(a,e,t=1,i=!1){return Zr(a,e,1/t,i)}function ss(a,e=!1){return Zr(a,1e3,1/wo,e)}function Vh(a,e=1){return Zr(a,wo,1/e)}const Kh=10*1e3,Yh=1024,Wh=1152,jh=1536;let Fi=null,Qr=null;function ko(a,e,t,i){return{duration:e,size:t,cts:i,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:a?2:1,isNonSync:a?0:1}}}class Us extends Tt{constructor(e,t,i,s){if(super("mp4-remuxer",s),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextVideoTs=null,this.nextAudioTs=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=e,this.config=t,this.typeSupported=i,this.ISGenerated=!1,Fi===null){const n=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Fi=n?parseInt(n[1]):0}if(Qr===null){const r=navigator.userAgent.match(/Safari\/(\d+)/i);Qr=r?parseInt(r[1]):0}}destroy(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}resetTimeStamp(e){this.log("initPTS & initDTS reset"),this._initPTS=this._initDTS=e}resetNextTimestamp(){this.log("reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){this.log("ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}getVideoStartPts(e){let t=!1;const i=e[0].pts,s=e.reduce((r,n)=>{let o=n.pts,c=o-r;return c<-4294967296&&(t=!0,o=xt(o,i),c=o-r),c>0?r:o},i);return t&&this.debug("PTS rollover detected"),s}remux(e,t,i,s,r,n,o,c){let u,h,f,g,I,m,E=r,v=r;const x=e.pid>-1,D=t.pid>-1,L=t.samples.length,w=e.samples.length>0,N=o&&L>0||L>1;if((!x||w)&&(!D||N)||this.ISGenerated||o){if(this.ISGenerated){var p,$,F,O;const ce=this.videoTrackConfig;(ce&&(t.width!==ce.width||t.height!==ce.height||((p=t.pixelRatio)==null?void 0:p[0])!==(($=ce.pixelRatio)==null?void 0:$[0])||((F=t.pixelRatio)==null?void 0:F[1])!==((O=ce.pixelRatio)==null?void 0:O[1]))||!ce&&N||this.nextAudioTs===null&&w)&&this.resetInitSegment()}this.ISGenerated||(f=this.generateIS(e,t,r,n));const W=this.isVideoContiguous;let ie=-1,X;if(N&&(ie=zh(t.samples),!W&&this.config.forceKeyFrameOnDiscontinuity))if(m=!0,ie>0){this.warn(`Dropped ${ie} out of ${L} video samples due to a missing keyframe`);const ce=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(ie),t.dropped+=ie,v+=(t.samples[0].pts-ce)/t.inputTimeScale,X=v}else ie===-1&&(this.warn(`No keyframe found out of ${L} video samples`),m=!1);if(this.ISGenerated){if(w&&N){const ce=this.getVideoStartPts(t.samples),Q=(xt(e.samples[0].pts,ce)-ce)/t.inputTimeScale;E+=Math.max(0,Q),v+=Math.max(0,-Q)}if(w){if(e.samplerate||(this.warn("regenerate InitSegment as audio detected"),f=this.generateIS(e,t,r,n)),h=this.remuxAudio(e,E,this.isAudioContiguous,n,D||N||c===he.AUDIO?v:void 0),N){const ce=h?h.endPTS-h.startPTS:0;t.inputTimeScale||(this.warn("regenerate InitSegment as video detected"),f=this.generateIS(e,t,r,n)),u=this.remuxVideo(t,v,W,ce)}}else N&&(u=this.remuxVideo(t,v,W,0));u&&(u.firstKeyFrame=ie,u.independent=ie!==-1,u.firstKeyFramePTS=X)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(I=Mo(i,r,this._initPTS,this._initDTS)),s.samples.length&&(g=Oo(s,r,this._initPTS))),{audio:h,video:u,initSegment:f,independent:m,text:g,id3:I}}generateIS(e,t,i,s){const r=e.samples,n=t.samples,o=this.typeSupported,c={},u=this._initPTS;let h=!u||s,f="audio/mp4",g,I,m,E=-1;if(h&&(g=I=1/0),e.config&&r.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":o.mpeg?(f="audio/mpeg",e.codec=""):o.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3";break}c.audio={id:"audio",container:f,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&o.mpeg?new Uint8Array(0):B.initSegment([e]),metadata:{channelCount:e.channelCount}},h&&(E=e.id,m=e.inputTimeScale,!u||m!==u.timescale?g=I=r[0].pts-Math.round(m*i):h=!1)}if(t.sps&&t.pps&&n.length){if(t.timescale=t.inputTimeScale,c.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:B.initSegment([t]),metadata:{width:t.width,height:t.height}},h)if(E=t.id,m=t.inputTimeScale,!u||m!==u.timescale){const v=this.getVideoStartPts(n),x=Math.round(m*i);I=Math.min(I,xt(n[0].dts,v)-x),g=Math.min(g,v-x)}else h=!1;this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(c).length)return this.ISGenerated=!0,h?(u&&this.warn(`Timestamps at playlist time: ${s?"":"~"}${i} ${g/m} != initPTS: ${u.baseTime/u.timescale} (${u.baseTime}/${u.timescale}) trackId: ${u.trackId}`),this.log(`Found initPTS at playlist time: ${i} offset: ${g/m} (${g}/${m}) trackId: ${E}`),this._initPTS={baseTime:g,timescale:m,trackId:E},this._initDTS={baseTime:I,timescale:m,trackId:E}):g=m=void 0,{tracks:c,initPTS:g,timescale:m,trackId:E}}remuxVideo(e,t,i,s){const r=e.inputTimeScale,n=e.samples,o=[],c=n.length,u=this._initPTS,h=u.baseTime*r/u.timescale;let f=this.nextVideoTs,g=8,I=this.videoSampleDuration,m,E,v=Number.POSITIVE_INFINITY,x=Number.NEGATIVE_INFINITY,D=!1;if(!i||f===null){const J=h+t*r,ee=n[0].pts-xt(n[0].dts,n[0].pts);Fi&&f!==null&&Math.abs(J-ee-(f+h))<15e3?i=!0:f=J-ee-h}const L=f+h;for(let J=0;J<c;J++){const ee=n[J];ee.pts=xt(ee.pts,L),ee.dts=xt(ee.dts,L),ee.dts<n[J>0?J-1:J].dts&&(D=!0)}D&&n.sort(function(J,ee){const ve=J.dts-ee.dts,ke=J.pts-ee.pts;return ve||ke}),m=n[0].dts,E=n[n.length-1].dts;const w=E-m,N=w?Math.round(w/(c-1)):I||e.inputTimeScale/30;if(i){const J=m-L,ee=J>N,ve=J<-1;if((ee||ve)&&(ee?this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${ss(J,!0)} ms (${J}dts) hole between fragments detected at ${t.toFixed(3)}`):this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${ss(-J,!0)} ms (${J}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!ve||L>=n[0].pts||Fi)){m=L;const ke=n[0].pts-J;if(ee)n[0].dts=m,n[0].pts=ke;else{let Te=!0;for(let Le=0;Le<n.length&&!(n[Le].dts>ke&&Te);Le++){const it=n[Le].pts;if(n[Le].dts-=J,n[Le].pts-=J,Le<n.length-1){const Je=n[Le+1].pts,lt=n[Le].pts,je=Je<=lt,Qt=Je<=it;Te=je==Qt}}}this.log(`Video: Initial PTS/DTS adjusted: ${ss(ke,!0)}/${ss(m,!0)}, delta: ${ss(J,!0)} ms`)}}m=Math.max(0,m);let K=0,p=0,$=m;for(let J=0;J<c;J++){const ee=n[J],ve=ee.units,ke=ve.length;let Te=0;for(let Le=0;Le<ke;Le++)Te+=ve[Le].data.length;p+=Te,K+=ke,ee.length=Te,ee.dts<$?(ee.dts=$,$+=N/4|0||1):$=ee.dts,v=Math.min(ee.pts,v),x=Math.max(ee.pts,x)}E=n[c-1].dts;const F=p+4*K+8;let O;try{O=new Uint8Array(F)}catch(J){this.observer.emit(y.ERROR,y.ERROR,{type:de.MUX_ERROR,details:U.REMUX_ALLOC_ERROR,fatal:!1,error:J,bytes:F,reason:`fail allocating video mdat ${F}`});return}const W=new DataView(O.buffer);W.setUint32(0,F),O.set(B.types.mdat,4);let ie=!1,X=Number.POSITIVE_INFINITY,ce=Number.POSITIVE_INFINITY,ue=Number.NEGATIVE_INFINITY,Q=Number.NEGATIVE_INFINITY;for(let J=0;J<c;J++){const ee=n[J],ve=ee.units;let ke=0;for(let it=0,Je=ve.length;it<Je;it++){const lt=ve[it],je=lt.data,Qt=lt.data.byteLength;W.setUint32(g,Qt),g+=4,O.set(je,g),g+=Qt,ke+=4+Qt}let Te;if(J<c-1)I=n[J+1].dts-ee.dts,Te=n[J+1].pts-ee.pts;else{const it=this.config,Je=J>0?ee.dts-n[J-1].dts:N;if(Te=J>0?ee.pts-n[J-1].pts:N,it.stretchShortVideoTrack&&this.nextAudioTs!==null){const lt=Math.floor(it.maxBufferHole*r),je=(s?v+s*r:this.nextAudioTs+h)-ee.pts;je>lt?(I=je-Je,I<0?I=Je:ie=!0,this.log(`It is approximately ${je/90} ms to the next segment; using duration ${I/90} ms for the last video frame.`)):I=Je}else I=Je}const Le=Math.round(ee.pts-ee.dts);X=Math.min(X,I),ue=Math.max(ue,I),ce=Math.min(ce,Te),Q=Math.max(Q,Te),o.push(ko(ee.key,I,ke,Le))}if(o.length){if(Fi){if(Fi<70){const J=o[0].flags;J.dependsOn=2,J.isNonSync=0}}else if(Qr&&Q-ce<ue-X&&N/ue<.025&&o[0].cts===0){this.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let J=m;for(let ee=0,ve=o.length;ee<ve;ee++){const ke=J+o[ee].duration,Te=J+o[ee].cts;if(ee<ve-1){const Le=ke+o[ee+1].cts;o[ee].duration=Le-Te}else o[ee].duration=ee?o[ee-1].duration:N;o[ee].cts=0,J=ke}}}I=ie||!I?N:I;const ne=E+I;this.nextVideoTs=f=ne-h,this.videoSampleDuration=I,this.isVideoContiguous=!0;const pe={data1:B.moof(e.sequenceNumber++,m,Ne(e,{samples:o})),data2:O,startPTS:(v-h)/r,endPTS:(x+I-h)/r,startDTS:(m-h)/r,endDTS:f/r,type:"video",hasAudio:!1,hasVideo:!0,nb:o.length,dropped:e.dropped};return e.samples=[],e.dropped=0,pe}getSamplesPerFrame(e){switch(e.segmentCodec){case"mp3":return Wh;case"ac3":return jh;default:return Yh}}remuxAudio(e,t,i,s,r){const n=e.inputTimeScale,o=e.samplerate?e.samplerate:n,c=n/o,u=this.getSamplesPerFrame(e),h=u*c,f=this._initPTS,g=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,I=[],m=r!==void 0;let E=e.samples,v=g?0:8,x=this.nextAudioTs||-1;const D=f.baseTime*n/f.timescale,L=D+t*n;if(this.isAudioContiguous=i=i||E.length&&x>0&&(s&&Math.abs(L-(x+D))<9e3||Math.abs(xt(E[0].pts,L)-(x+D))<20*h),E.forEach(function(Q){Q.pts=xt(Q.pts,L)}),!i||x<0){if(E=E.filter(Q=>Q.pts>=0),!E.length)return;r===0?x=0:s&&!m?x=Math.max(0,L-D):x=E[0].pts-D}if(e.segmentCodec==="aac"){const Q=this.config.maxAudioFramesDrift;for(let ne=0,re=x+D;ne<E.length;ne++){const le=E[ne],pe=le.pts,J=pe-re,ee=Math.abs(1e3*J/n);if(J<=-Q*h&&m)ne===0&&(this.warn(`Audio frame @ ${(pe/n).toFixed(3)}s overlaps marker by ${Math.round(1e3*J/n)} ms.`),this.nextAudioTs=x=pe-D,re=pe);else if(J>=Q*h&&ee<Kh&&m){let ve=Math.round(J/h);for(re=pe-ve*h;re<0&&ve&&h;)ve--,re+=h;ne===0&&(this.nextAudioTs=x=re-D),this.warn(`Injecting ${ve} audio frames @ ${((re-D)/n).toFixed(3)}s due to ${Math.round(1e3*J/n)} ms gap.`);for(let ke=0;ke<ve;ke++){let Te=Gh.getSilentFrame(e.parsedCodec||e.manifestCodec||e.codec,e.channelCount);Te||(this.log("Unable to get silent frame for given audio codec; duplicating last frame instead."),Te=le.unit.subarray()),E.splice(ne,0,{unit:Te,pts:re}),re+=h,ne++}}le.pts=re,re+=h}}let w=null,N=null,K,p=0,$=E.length;for(;$--;)p+=E[$].unit.byteLength;for(let Q=0,ne=E.length;Q<ne;Q++){const re=E[Q],le=re.unit;let pe=re.pts;if(N!==null){const ee=I[Q-1];ee.duration=Math.round((pe-N)/c)}else if(i&&e.segmentCodec==="aac"&&(pe=x+D),w=pe,p>0){p+=v;try{K=new Uint8Array(p)}catch(ee){this.observer.emit(y.ERROR,y.ERROR,{type:de.MUX_ERROR,details:U.REMUX_ALLOC_ERROR,fatal:!1,error:ee,bytes:p,reason:`fail allocating audio mdat ${p}`});return}g||(new DataView(K.buffer).setUint32(0,p),K.set(B.types.mdat,4))}else return;K.set(le,v);const J=le.byteLength;v+=J,I.push(ko(!0,u,J,0)),N=pe}const F=I.length;if(!F)return;const O=I[I.length-1];x=N-D,this.nextAudioTs=x+c*O.duration;const W=g?new Uint8Array(0):B.moof(e.sequenceNumber++,w/c,Ne({},e,{samples:I}));e.samples=[];const ie=(w-D)/n,X=x/n,ue={data1:W,data2:K,startPTS:ie,endPTS:X,startDTS:ie,endDTS:X,type:"audio",hasAudio:!0,hasVideo:!1,nb:F};return this.isAudioContiguous=!0,ue}}function xt(a,e){let t;if(e===null)return a;for(e<a?t=-8589934592:t=8589934592;Math.abs(a-e)>4294967296;)a+=t;return a}function zh(a){for(let e=0;e<a.length;e++)if(a[e].key)return e;return-1}function Mo(a,e,t,i){const s=a.samples.length;if(!s)return;const r=a.inputTimeScale;for(let o=0;o<s;o++){const c=a.samples[o];c.pts=xt(c.pts-t.baseTime*r/t.timescale,e*r)/r,c.dts=xt(c.dts-i.baseTime*r/i.timescale,e*r)/r}const n=a.samples;return a.samples=[],{samples:n}}function Oo(a,e,t){const i=a.samples.length;if(!i)return;const s=a.inputTimeScale;for(let n=0;n<i;n++){const o=a.samples[n];o.pts=xt(o.pts-t.baseTime*s/t.timescale,e*s)/s}a.samples.sort((n,o)=>n.pts-o.pts);const r=a.samples;return a.samples=[],{samples:r}}class qh extends Tt{constructor(e,t,i,s){super("passthrough-remuxer",s),this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null,this.isVideoContiguous=!1}destroy(){}resetTimeStamp(e){this.lastEndTime=null;const t=this.initPTS;t&&e&&t.baseTime===e.baseTime&&t.timescale===e.timescale||(this.initPTS=e)}resetNextTimestamp(){this.isVideoContiguous=!1,this.lastEndTime=null}resetInitSegment(e,t,i,s){this.audioCodec=t,this.videoCodec=i,this.generateInitSegment(e,s),this.emitInitSegment=!0}generateInitSegment(e,t){let{audioCodec:i,videoCodec:s}=this;if(!(e!=null&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}const{audio:r,video:n}=this.initData=oa(e);if(t)Nu(e,t);else{const c=r||n;c!=null&&c.encrypted&&this.warn(`Init segment with encrypted track with has no key ("${c.codec}")!`)}r&&(i=Fo(r,Ue.AUDIO,this)),n&&(s=Fo(n,Ue.VIDEO,this));const o={};r&&n?o.audiovideo={container:"video/mp4",codec:i+","+s,supplemental:n.supplemental,encrypted:n.encrypted,initSegment:e,id:"main"}:r?o.audio={container:"audio/mp4",codec:i,encrypted:r.encrypted,initSegment:e,id:"audio"}:n?o.video={container:"video/mp4",codec:s,supplemental:n.supplemental,encrypted:n.encrypted,initSegment:e,id:"main"}:this.warn("initSegment does not contain moov or trak boxes."),this.initTracks=o}remux(e,t,i,s,r,n){var o,c;let{initPTS:u,lastEndTime:h}=this;const f={audio:void 0,video:void 0,text:s,id3:i,initSegment:void 0};se(h)||(h=this.lastEndTime=r||0);const g=t.samples;if(!g.length)return f;const I={initPTS:void 0,timescale:void 0,trackId:void 0};let m=this.initData;if((o=m)!=null&&o.length||(this.generateInitSegment(g),m=this.initData),!((c=m)!=null&&c.length))return this.warn("Failed to generate initSegment."),f;this.emitInitSegment&&(I.tracks=this.initTracks,this.emitInitSegment=!1);const E=Bu(g,m,this),v=m.audio?E[m.audio.id]:null,x=m.video?E[m.video.id]:null,D=$s(x,1/0),L=$s(v,1/0),w=$s(x,0,!0),N=$s(v,0,!0);let K=r,p=0;const $=v&&(!x||!u&&L<D||u&&u.trackId===m.audio.id),F=$?v:x;if(F){const re=F.timescale,le=F.start-r*re,pe=$?m.audio.id:m.video.id;K=F.start/re,p=$?N-L:w-D,(n||!u)&&(Xh(u,K,r,p)||re!==u.timescale)&&(u&&this.warn(`Timestamps at playlist time: ${n?"":"~"}${r} ${le/re} != initPTS: ${u.baseTime/u.timescale} (${u.baseTime}/${u.timescale}) trackId: ${u.trackId}`),this.log(`Found initPTS at playlist time: ${r} offset: ${K-r} (${le}/${re}) trackId: ${pe}`),u=null,I.initPTS=le,I.timescale=re,I.trackId=pe)}else this.warn(`No audio or video samples found for initPTS at playlist time: ${r}`);u?(I.initPTS=u.baseTime,I.timescale=u.timescale,I.trackId=u.trackId):((!I.timescale||I.trackId===void 0||I.initPTS===void 0)&&(this.warn("Could not set initPTS"),I.initPTS=K,I.timescale=1,I.trackId=-1),this.initPTS=u={baseTime:I.initPTS,timescale:I.timescale,trackId:I.trackId});const O=K-u.baseTime/u.timescale,W=O+p;p>0?this.lastEndTime=W:(this.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const ie=!!m.audio,X=!!m.video;let ce="";ie&&(ce+="audio"),X&&(ce+="video");const ue=(m.audio?m.audio.encrypted:!1)||(m.video?m.video.encrypted:!1),Q={data1:g,startPTS:O,startDTS:O,endPTS:W,endDTS:W,type:ce,hasAudio:ie,hasVideo:X,nb:1,dropped:0,encrypted:ue};f.audio=ie&&!X?Q:void 0,f.video=X?Q:void 0;const ne=x?.sampleCount;if(ne){const re=x.keyFrameIndex,le=re!==-1;Q.nb=ne,Q.dropped=re===0||this.isVideoContiguous?0:le?re:ne,Q.independent=le,Q.firstKeyFrame=re,le&&x.keyFrameStart&&(Q.firstKeyFramePTS=(x.keyFrameStart-u.baseTime)/u.timescale),this.isVideoContiguous||(f.independent=le),this.isVideoContiguous||(this.isVideoContiguous=le),Q.dropped&&this.warn(`fmp4 does not start with IDR: firstIDR ${re}/${ne} dropped: ${Q.dropped} start: ${Q.firstKeyFramePTS||"NA"}`)}return f.initSegment=I,f.id3=Mo(i,r,u,u),s.samples.length&&(f.text=Oo(s,r,u)),f}}function $s(a,e,t=!1){return a?.start!==void 0?(a.start+(t?a.duration:0))/a.timescale:e}function Xh(a,e,t,i){if(a===null)return!0;const s=Math.max(i,1),r=e-a.baseTime/a.timescale;return Math.abs(r-t)>s}function Fo(a,e,t){const i=a.codec;return i&&i.length>4?i:e===Ue.AUDIO?i==="ec-3"||i==="ac-3"||i==="alac"?i:i==="fLaC"||i==="Opus"?Es(i,!1):(t.warn(`Unhandled audio codec "${i}" in mp4 MAP`),i||"mp4a"):(t.warn(`Unhandled video codec "${i}" in mp4 MAP`),i||"avc1")}let Xt;try{Xt=self.performance.now.bind(self.performance)}catch{Xt=Date.now}const Gs=[{demux:Oh,remux:qh},{demux:ai,remux:Us},{demux:_h,remux:Us},{demux:kh,remux:Us}];Gs.splice(2,0,{demux:wh,remux:Us});class No{constructor(e,t,i,s,r,n){this.asyncResult=!1,this.logger=void 0,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=e,this.typeSupported=t,this.config=i,this.id=r,this.logger=n}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,i,s){const r=i.transmuxing;r.executeStart=Xt();let n=new Uint8Array(e);const{currentTransmuxState:o,transmuxConfig:c}=this;s&&(this.currentTransmuxState=s);const{contiguous:u,discontinuity:h,trackSwitch:f,accurateTimeOffset:g,timeOffset:I,initSegmentChange:m}=s||o,{audioCodec:E,videoCodec:v,defaultInitPts:x,duration:D,initSegmentData:L}=c,w=Zh(n,t);if(w&&ki(w.method)){const $=this.getDecrypter(),F=_r(w.method);if($.isSync()){let O=$.softwareDecrypt(n,w.key.buffer,w.iv.buffer,F);if(i.part>-1){const ie=$.flush();O=ie&&ie.buffer}if(!O)return r.executeEnd=Xt(),Jr(i);n=new Uint8Array(O)}else return this.asyncResult=!0,this.decryptionPromise=$.webCryptoDecrypt(n,w.key.buffer,w.iv.buffer,F).then(O=>{const W=this.push(O,null,i);return this.decryptionPromise=null,W}),this.decryptionPromise}const N=this.needsProbing(h,f);if(N){const $=this.configureTransmuxer(n);if($)return this.logger.warn(`[transmuxer] ${$.message}`),this.observer.emit(y.ERROR,y.ERROR,{type:de.MEDIA_ERROR,details:U.FRAG_PARSING_ERROR,fatal:!1,error:$,reason:$.message}),r.executeEnd=Xt(),Jr(i)}(h||f||m||N)&&this.resetInitSegment(L,E,v,D,t),(h||m||N)&&this.resetInitialTimestamp(x),u||this.resetContiguity();const K=this.transmux(n,w,I,g,i);this.asyncResult=rs(K);const p=this.currentTransmuxState;return p.contiguous=!0,p.discontinuity=!1,p.trackSwitch=!1,r.executeEnd=Xt(),K}flush(e){const t=e.transmuxing;t.executeStart=Xt();const{decrypter:i,currentTransmuxState:s,decryptionPromise:r}=this;if(r)return this.asyncResult=!0,r.then(()=>this.flush(e));const n=[],{timeOffset:o}=s;if(i){const f=i.flush();f&&n.push(this.push(f.buffer,null,e))}const{demuxer:c,remuxer:u}=this;if(!c||!u){t.executeEnd=Xt();const f=[Jr(e)];return this.asyncResult?Promise.resolve(f):f}const h=c.flush(o);return rs(h)?(this.asyncResult=!0,h.then(f=>(this.flushRemux(n,f,e),n))):(this.flushRemux(n,h,e),this.asyncResult?Promise.resolve(n):n)}flushRemux(e,t,i){const{audioTrack:s,videoTrack:r,id3Track:n,textTrack:o}=t,{accurateTimeOffset:c,timeOffset:u}=this.currentTransmuxState;this.logger.log(`[transmuxer.ts]: Flushed ${this.id} sn: ${i.sn}${i.part>-1?" part: "+i.part:""} of ${this.id===he.MAIN?"level":"track"} ${i.level}`);const h=this.remuxer.remux(s,r,n,o,u,c,!0,this.id);e.push({remuxResult:h,chunkMeta:i}),i.transmuxing.executeEnd=Xt()}resetInitialTimestamp(e){const{demuxer:t,remuxer:i}=this;!t||!i||(t.resetTimeStamp(e),i.resetTimeStamp(e))}resetContiguity(){const{demuxer:e,remuxer:t}=this;!e||!t||(e.resetContiguity(),t.resetNextTimestamp())}resetInitSegment(e,t,i,s,r){const{demuxer:n,remuxer:o}=this;!n||!o||(n.resetInitSegment(e,t,i,s),o.resetInitSegment(e,t,i,r))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,i,s,r){let n;return t&&t.method==="SAMPLE-AES"?n=this.transmuxSampleAes(e,t,i,s,r):n=this.transmuxUnencrypted(e,i,s,r),n}transmuxUnencrypted(e,t,i,s){const{audioTrack:r,videoTrack:n,id3Track:o,textTrack:c}=this.demuxer.demux(e,t,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(r,n,o,c,t,i,!1,this.id),chunkMeta:s}}transmuxSampleAes(e,t,i,s,r){return this.demuxer.demuxSampleAes(e,t,i).then(n=>({remuxResult:this.remuxer.remux(n.audioTrack,n.videoTrack,n.id3Track,n.textTrack,i,s,!1,this.id),chunkMeta:r}))}configureTransmuxer(e){const{config:t,observer:i,typeSupported:s}=this;let r;for(let f=0,g=Gs.length;f<g;f++){var n;if((n=Gs[f].demux)!=null&&n.probe(e,this.logger)){r=Gs[f];break}}if(!r)return new Error("Failed to find demuxer by probing fragment data");const o=this.demuxer,c=this.remuxer,u=r.remux,h=r.demux;(!c||!(c instanceof u))&&(this.remuxer=new u(i,t,s,this.logger)),(!o||!(o instanceof h))&&(this.demuxer=new h(i,t,s,this.logger),this.probe=h.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new Rr(this.config)),e}}function Zh(a,e){let t=null;return a.byteLength>0&&e?.key!=null&&e.iv!==null&&e.method!=null&&(t=e),t}const Jr=a=>({remuxResult:{},chunkMeta:a});function rs(a){return"then"in a&&a.then instanceof Function}class Qh{constructor(e,t,i,s,r){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=i,this.duration=s,this.defaultInitPts=r||null}}class Jh{constructor(e,t,i,s,r,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=i,this.trackSwitch=s,this.timeOffset=r,this.initSegmentChange=n}}let Bo=0;class Uo{constructor(e,t,i,s){this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=Bo++,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.onWorkerMessage=c=>{const u=c.data,h=this.hls;if(!(!h||!(u!=null&&u.event)||u.instanceNo!==this.instanceNo))switch(u.event){case"init":{var f;const g=(f=this.workerContext)==null?void 0:f.objectURL;g&&self.URL.revokeObjectURL(g);break}case"transmuxComplete":{this.handleTransmuxComplete(u.data);break}case"flush":{this.onFlush(u.data);break}case"workerLog":{h.logger[u.data.logType]&&h.logger[u.data.logType](u.data.message);break}default:{u.data=u.data||{},u.data.frag=this.frag,u.data.part=this.part,u.data.id=this.id,h.trigger(u.event,u.data);break}}},this.onWorkerError=c=>{if(!this.hls)return;const u=new Error(`${c.message} (${c.filename}:${c.lineno})`);this.hls.config.enableWorker=!1,this.hls.logger.warn(`Error in "${this.id}" Web Worker, fallback to inline`),this.hls.trigger(y.ERROR,{type:de.OTHER_ERROR,details:U.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:u})};const r=e.config;this.hls=e,this.id=t,this.useWorker=!!r.enableWorker,this.onTransmuxComplete=i,this.onFlush=s;const n=(c,u)=>{u=u||{},u.frag=this.frag||void 0,c===y.ERROR&&(u=u,u.parent=this.id,u.part=this.part,this.error=u.error),this.hls.trigger(c,u)};this.observer=new Gr,this.observer.on(y.FRAG_DECRYPTED,n),this.observer.on(y.ERROR,n);const o=ga(r.preferManagedMediaSource);if(this.useWorker&&typeof Worker<"u"){const c=this.hls.logger;if(r.workerPath||sh()){try{r.workerPath?(c.log(`loading Web Worker ${r.workerPath} for "${t}"`),this.workerContext=nh(r.workerPath)):(c.log(`injecting Web Worker for "${t}"`),this.workerContext=rh());const{worker:h}=this.workerContext;h.addEventListener("message",this.onWorkerMessage),h.addEventListener("error",this.onWorkerError),h.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:o,id:t,config:Ge(r)})}catch(h){c.warn(`Error setting up "${t}" Web Worker, fallback to inline`,h),this.terminateWorker(),this.error=null,this.transmuxer=new No(this.observer,o,r,"",t,e.logger)}return}}this.transmuxer=new No(this.observer,o,r,"",t,e.logger)}reset(){if(this.frag=null,this.part=null,this.workerContext){const e=this.instanceNo;this.instanceNo=Bo++;const t=this.hls.config,i=ga(t.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:e,typeSupported:i,id:this.id,config:Ge(t)})}}terminateWorker(){if(this.workerContext){const{worker:e}=this.workerContext;this.workerContext=null,e.removeEventListener("message",this.onWorkerMessage),e.removeEventListener("error",this.onWorkerError),ah(this.hls.config.workerPath)}}destroy(){if(this.workerContext)this.terminateWorker(),this.onWorkerMessage=this.onWorkerError=null;else{const t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}const e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.part=null,this.observer=null,this.hls=null}push(e,t,i,s,r,n,o,c,u,h){var f,g;u.transmuxing.start=self.performance.now();const{instanceNo:I,transmuxer:m}=this,E=n?n.start:r.start,v=r.decryptdata,x=this.frag,D=!(x&&r.cc===x.cc),L=!(x&&u.level===x.level),w=x?u.sn-x.sn:-1,N=this.part?u.part-this.part.index:-1,K=w===0&&u.id>1&&u.id===x?.stats.chunkCount,p=!L&&(w===1||w===0&&(N===1||K&&N<=0)),$=self.performance.now();(L||w||r.stats.parsing.start===0)&&(r.stats.parsing.start=$),n&&(N||!p)&&(n.stats.parsing.start=$);const F=!(x&&((f=r.initSegment)==null?void 0:f.url)===((g=x.initSegment)==null?void 0:g.url)),O=new Jh(D,p,c,L,E,F);if(!p||D||F){this.hls.logger.log(`[transmuxer-interface]: Starting new transmux session for ${r.type} sn: ${u.sn}${u.part>-1?" part: "+u.part:""} ${this.id===he.MAIN?"level":"track"}: ${u.level} id: ${u.id}
17
- discontinuity: ${D}
18
- trackSwitch: ${L}
16
+ ${t.m3u8}`)}function pl(r,e,t=!0,i){const s=e.startSN+e.skippedSegments-r.startSN,n=r.fragments,a=s>=0;let o=0;if(a&&s<n.length)o=n[s].start,i?.log(`Aligning playlists based on SN ${e.startSN} (diff: ${o})`);else if(a&&e.startSN===r.endSN+1)o=r.fragmentEnd,i?.log(`Aligning playlists based on first/last SN ${e.startSN} (diff: ${o})`);else if(a&&t)o=r.fragmentStart+s*e.levelTargetDuration;else if(!e.skippedSegments&&e.fragmentStart===0)o=r.fragmentStart,i?.log(`Aligning playlists based on first SN ${e.startSN} (diff: ${o})`);else return o;return Jd(e,o),o}function Jd(r,e){if(e){const t=r.fragments;for(let i=r.skippedSegments;i<t.length;i++)t[i].addStart(e);r.fragmentHint&&r.fragmentHint.addStart(e)}}function ml(r,e=1/0){let t=1e3*r.targetduration;if(r.updated){const i=r.fragments;if(i.length&&t*4>e){const n=i[i.length-1].duration*1e3;n>0&&n<t&&(t=n)}}else t/=2;return Math.round(t)}function Al(r,e,t){var i;if(!r)return null;let s=r.fragments[e-r.startSN];return s||(s=r.fragmentHint,((i=s)==null?void 0:i.sn)===e)?s:t&&e<r.startSN&&t.sn===e?t:null}function Il(r,e,t){return r?Cl(r.partList,e,t):null}function Cl(r,e,t){if(r)for(let i=r.length;i--;){const s=r[i];if(s.index===t&&s.fragment.sn===e)return s}return null}function yl(r){r.forEach((e,t)=>{var i;(i=e.details)==null||i.fragments.forEach(s=>{s.level=t,s.initSegment&&(s.initSegment.level=t)})})}function ef(r,e){return r!==e&&e?vl(r)!==vl(e):!1}function vl(r){return r.replace(/\?[^?]*$/,"")}function Es(r,e){for(let i=0,s=r.length;i<s;i++){var t;if(((t=r[i])==null?void 0:t.cc)===e)return r[i]}return null}function tf(r,e){return!!(r&&e.startCC<r.endCC&&e.endCC>r.startCC)}function El(r,e){const t=r.start+e;r.setStart(t)}function Tl(r,e){const t=e.fragments;for(let i=0,s=t.length;i<s;i++)El(t[i],r);e.fragmentHint&&El(e.fragmentHint,r),e.alignedSliding=!0}function cn(r,e,t){r&&(sf(e,r,t),e.alignedSliding||nf(e,r,t),!e.alignedSliding&&!e.skippedSegments&&pl(r,e,!1,t))}function sf(r,e,t){if(!tf(e,r))return;const i=Math.min(e.endCC,r.endCC),s=Es(e.fragments,i),n=Es(r.fragments,i);if(!s||!n)return;const a=s.start-n.start;t.log(`Aligning playlists using dicontinuity sequence ${i} (diff: ${a})`),Tl(a,r)}function nf(r,e,t){if(!r.hasProgramDateTime||!e.hasProgramDateTime)return;const i=r.fragments,s=e.fragments;if(!i.length||!s.length)return;let n,a;const o=Math.min(e.endCC,r.endCC);e.startCC<o&&r.startCC<o&&(n=Es(s,o),a=Es(i,o)),(!n||!a)&&(n=s[Math.floor(s.length/2)]||s.filter(g=>!!g)[0],a=Es(i,n.cc)||i[Math.floor(i.length/2)]);const l=n.programDateTime,u=a.programDateTime;if(!l||!u)return;const h=(u-l)/1e3;if(Math.abs(h)>Math.max(60,r.totalduration)){t.log(`Cannot align playlists using PDT without overlap (${Math.abs(h)} > ${r.totalduration})`);return}const d=h-(a.start-n.start);t.log(`Aligning playlists using PDT (diff: ${d})`),Tl(d,r)}function Ke(r,e,t){Ve(r,e,t),r.addEventListener(e,t)}function Ve(r,e,t){r.removeEventListener(e,t)}function hn(r){let e="";const t=r.length;for(let i=0;i<t;i++)e+=`[${r.start(i).toFixed(3)}-${r.end(i).toFixed(3)}]`;return e}const Y={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 Er extends Ko{constructor(e,t,i,s,n){super(s,e.logger),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragPlaying=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=Y.STOPPED,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=-1,this.startTimeOffset=null,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.initFragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.buffering=!0,this.loadingParts=!1,this.loopSn=void 0,this.onMediaSeeking=()=>{const{config:a,fragCurrent:o,media:l,mediaBuffer:u,state:h}=this,d=l?l.currentTime:0,g=ve.bufferInfo(u||l,d,a.maxBufferHole),m=g.len;if(this.log(`Media seeking to ${d}, state: ${h}, ${m?"in":"out of"} buffer`),this.state===Y.ENDED)this.resetLoadingState();else if(o){const C=a.maxFragLookUpTolerance,v=o.start-C,S=o.start+o.duration+C;if(!m||S<g.start||v>g.end){const R=d<v,b=d>S;(R||b)&&(o.loader&&(b||!this.isFragmentNearlyDownloaded(o))?(this.log(`Cancelling fragment load for seek (sn: ${o.sn}) - ${R?"backward":"forward"} seek`),o.abortRequests(),this.resetLoadingState()):this.fragPrevious=null)}}if(l){this.fragmentTracker.removeFragmentsInRange(d,1/0,this.playlistType,!0);const C=this.lastCurrentTime;if(d>C&&(this.lastCurrentTime=d),!this.loadingParts){const v=Math.max(g.end,d),S=this.shouldLoadParts(this.getLevelDetails(),v);S&&(this.log(`LL-Part loading ON after seeking to ${d} with buffer @${v}`),this.loadingParts=S)}}const A=!ve.isBuffered(l,d);(!this.hls.hasEnoughToStart||A)&&(this.log(`Setting ${A?"startPosition":"nextLoadPosition"} to ${d} for seek without enough to start`),this.nextLoadPosition=d,A&&(this.startPosition=d)),m<1&&this.state===Y.IDLE&&this.tickImmediate()},this.onMediaEnded=()=>{this.log("setting startPosition to 0 because media ended"),this.startPosition=this.lastCurrentTime=0},this.playlistType=n,this.hls=e,this.fragmentLoader=new Go(e.config),this.initFragmentLoader=new Go(e.config),this.keyLoader=i,this.fragmentTracker=t,this.config=e.config,this.decrypter=new hr(e.config)}registerListeners(){const{hls:e}=this;e.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(E.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(E.ERROR,this.onError,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){if(this.state===Y.STOPPED)return;this.fragmentLoader.abort(),this.initFragmentLoader.abort(),this.keyLoader.abort(this.playlistType);const e=this.fragCurrent;e!=null&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=Y.STOPPED}get startPositionValue(){const{nextLoadPosition:e,startPosition:t}=this;if(t===-1&&e){const i=this.getLevelDetails();return i!=null&&i.live?(this.hls.liveSyncPosition||i.fragmentStart)+this.timelineOffset:e}return t}get bufferingEnabled(){return this.buffering}get backtrackFragment(){}set backtrackFragment(e){}get couldBacktrack(){return!1}set couldBacktrack(e){}pauseBuffering(){this.buffering=!1}resumeBuffering(){this.buffering=!0}get inFlightFrag(){return{frag:this.fragCurrent,state:this.state}}_streamEnded(e,t){if(t.live||!this.media)return!1;const i=e.end||0,s=this.config.timelineOffset||0;if(i<=s)return!1;const n=e.buffered;this.config.maxBufferHole&&n&&n.length>1&&(e=ve.bufferedInfo(n,e.start,0));const a=e.nextStart;if(a&&a>s&&a<t.edge||this.media.currentTime<e.start)return!1;const l=t.partList;if(l!=null&&l.length){const h=l[l.length-1];return ve.isBuffered(this.media,h.start+h.duration/2)}const u=t.fragments[t.fragments.length-1];return this.fragmentTracker.isEndListAppended(u.type)}getLevelDetails(){if(this.levels&&this.levelLastLoaded!==null)return this.levelLastLoaded.details}get timelineOffset(){const e=this.config.timelineOffset;if(e){var t;return((t=this.getLevelDetails())==null?void 0:t.appliedTimelineOffset)||e}return 0}onMediaAttached(e,t){const i=this.media=this.mediaBuffer=t.media;Ke(i,"seeking",this.onMediaSeeking),Ke(i,"ended",this.onMediaEnded);const s=this.config;this.levels&&s.autoStartLoad&&this.state===Y.STOPPED&&this.startLoad(s.startPosition)}onMediaDetaching(e,t){this.fragPlaying=null;const i=!!t.transferMedia,s=this.media;if(s!==null){if(s.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),Ve(s,"seeking",this.onMediaSeeking),Ve(s,"ended",this.onMediaEnded),this.media=this.mediaBuffer=null,this.loopSn=void 0,i){this.resetLoadingState(),this.resetTransmuxer();return}this.loadingParts=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}}onManifestLoading(){this.initPTS=[],this.fragPlaying=this.levels=this.levelLastLoaded=this.fragCurrent=null,this.lastCurrentTime=0,this.startPosition=-1,this.startFragRequested=!1}onError(e,t){}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset}onHandlerDestroying(){this.stopLoad(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),super.onHandlerDestroying(),this.hls=this.onMediaSeeking=this.onMediaEnded=null}onHandlerDestroyed(){this.state=Y.STOPPED,this.fragmentLoader&&this.fragmentLoader.destroy(),this.initFragmentLoader&&this.initFragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.decrypter=this.keyLoader=null,this.fragmentLoader=this.initFragmentLoader=this.fragmentTracker=null,super.onHandlerDestroyed()}loadFragment(e,t,i){this.startFragRequested=!0,this._loadFragForPlayback(e,t,i)}_loadFragForPlayback(e,t,i){const s=n=>{const a=n.frag;if(this.fragContextChanged(a)){this.warn(`${a.type} sn: ${a.sn}${n.part?" part: "+n.part.index:""} of ${this.fragInfo(a,!1,n.part)} was dropped during download.`),this.fragmentTracker.removeFragment(a);return}const o=++a.stats.chunkCount;this.log(`load progress ${a.type} sn: ${a.sn}${n.part?" part: "+n.part.index:""} of ${this.fragInfo(a,!1,n.part)} chunk: ${o}`),this._handleFragmentLoadProgress(n)};this._doFragLoad(e,t,i,s).then(n=>{if(!n)return;const a=this.state,o=n.frag;if(this.fragContextChanged(o)){(a===Y.FRAG_LOADING||!this.fragCurrent&&a===Y.PARSING)&&(this.fragmentTracker.removeFragment(o),this.state=Y.IDLE);return}"payload"in n&&(this.log(`Loaded ${o.type} sn: ${o.sn} of ${this.playlistLabel()} ${o.level} (bytes ${o.stats.loaded})`),this.hls.trigger(E.FRAG_LOADED,n)),this._handleFragmentLoadComplete(n)}).catch(n=>{this.state===Y.STOPPED||this.state===Y.ERROR||(this.log(`Frag error ${e.type} sn:${e.sn} cc:${e.cc}: ${n?.message||n}`),this.resetFragmentLoading(e))})}clearTrackerIfNeeded(e){var t;const{fragmentTracker:i}=this;if(i.getState(e)===et.APPENDING){const n=e.type,a=this.getFwdBufferInfo(this.mediaBuffer,n),o=Math.max(e.duration,a?a.len:this.config.maxBufferLength),l=this.backtrackFragment;((l?e.sn-l.sn:0)===1||this.reduceMaxBufferLength(o,e.duration))&&i.removeFragment(e)}else((t=this.mediaBuffer)==null?void 0:t.buffered.length)===0?i.removeAllFragments():i.hasParts(e.type)&&(i.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),i.getState(e)===et.PARTIAL&&i.removeFragment(e))}checkLiveUpdate(e){if(e.updated&&!e.live){const t=this.fragmentTracker,i=e.fragments[e.fragments.length-1];if(i.endList&&!t.isEndListAppended(this.playlistType)){const s=t.getPartialFragment(i.end);s&&(t.removeFragment(s),t.fragBuffered(i,!0))}t.detectPartialFragments({frag:i,part:null,stats:i.stats,id:i.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)}waitForLive(e){const t=e.details;return t?.live&&t.type!=="EVENT"&&(this.levelLastLoaded!==e||t.expired)}flushMainBuffer(e,t,i=null){if(!(e-t))return;const s={startOffset:e,endOffset:t,type:i};this.hls.trigger(E.BUFFER_FLUSHING,s)}_loadInitSegment(e){const{hls:t}=this;return this.initFragmentLoader.abort(),t.trigger(E.FRAG_LOADING,{frag:e,targetBufferTime:0}),this.initFragmentLoader.load(e).then(i=>{var s;const n=i.frag;if(!this.levels||!Yn(n,(s=this.fragCurrent)==null?void 0:s.initSegment))throw new si({type:me.NETWORK_ERROR,details:U.INTERNAL_ABORTED,error:new Error("init load aborted"),fatal:!1,frag:n,networkDetails:null});return i}).then(i=>{const{frag:s,payload:n}=i,a=s.decryptdata;if(n&&n.byteLength>0&&a!=null&&a.key&&a.iv&&zi(a.method)){const o=self.performance.now(),{decryptRange:l}=rn(s,null,this.iframesOnly);return this.decrypter.decrypt(new Uint8Array(n),a.key.buffer,a.iv.buffer,pr(a.method),l).catch(u=>{throw t.trigger(E.ERROR,{type:me.MEDIA_ERROR,details:U.FRAG_DECRYPT_ERROR,fatal:!1,error:u,reason:u.message,frag:s}),this.fragmentLoader.abort(),u}).then(u=>{const h=self.performance.now();return t.trigger(E.FRAG_DECRYPTED,{frag:s,part:null,payload:u,stats:{tstart:o,tdecrypt:h}}),i.payload=u,this.completeInitSegmentLoad(i)})}return this.completeInitSegmentLoad(i)})}completeInitSegmentLoad(e){const t=e.frag.stats;e.frag.data=new Uint8Array(e.payload),t.parsing.start=t.buffering.start=self.performance.now(),t.parsing.end=t.buffering.end=self.performance.now()}loadInitSegmentIfNeeded(e){const{initSegment:t}=e;if(!this.bitrateTest&&st(e)&&t&&!t.data){var i;return(t.encrypted&&!((i=t.decryptdata)!=null&&i.key)?this.keyLoader.load(t).then(()=>this._loadInitSegment(t)):this._loadInitSegment(t)).catch(n=>{throw this.state===Y.STOPPED||this.state===Y.ERROR||("data"in n&&(n.data.frag=e,this.fragmentLoader.abort(),this.handleFragLoadError(n)),this.resetFragmentLoading(e)),n})}}unhandledEncryptionError(e,t){var i,s;const n=e.tracks;if(n&&!t.encrypted&&((i=n.audio)!=null&&i.encrypted||(s=n.video)!=null&&s.encrypted)&&(!this.config.emeEnabled||!this.keyLoader.emeController)){const a=this.media,o=new Error(`Encrypted track with no key in ${this.fragInfo(t)} (media ${a?"attached mediaKeys: "+a.mediaKeys:"detached"})`);return this.warn(o.message),!a||a.mediaKeys?!1:(this.hls.trigger(E.ERROR,{type:me.KEY_SYSTEM_ERROR,details:U.KEY_SYSTEM_NO_KEYS,fatal:!1,error:o,frag:t}),this.resetTransmuxer(),!0)}return!1}fragContextChanged(e){const{fragCurrent:t}=this;return!e||!Yn(e,t)}fragBufferedComplete(e,t){const i=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)} > buffer:${i?hn(ve.getBuffered(i)):"(detached)"})`),st(e)){var s;if(e.type!==ge.SUBTITLE){const a=e.elementaryStreams;if(!Object.keys(a).some(o=>!!a[o])){this.state=Y.IDLE;return}}const n=(s=this.levels)==null?void 0:s[e.level];n!=null&&n.fragmentError&&(t||this.fragmentTracker.getState(e)!==et.PARTIAL)&&(this.log(`Resetting level fragment error count of ${n.fragmentError} on frag buffered`),n.fragmentError=0,e.stats.retry=0)}this.state=Y.IDLE}_handleFragmentLoadComplete(e){const{transmuxer:t}=this;if(!t)return;const i=e.frag,{part:s,partsLoaded:n}=e,a=!n||n.length===0||n.some(u=>!u),{decryptRange:o}=rn(i,s),l=new dr(i.level,i.sn,i.stats.chunkCount+1,0,s?s.index:-1,!a,i.duration,this.iframesOnly,o);this.log(`load complete ${i.type} sn: ${i.sn}${s?" part: "+s.index:""} of ${this.fragInfo(i,!1,s)}`),t.flush(l)}_handleFragmentLoadProgress(e){}loadKeyFor(e,t,i){var s;let n=null;return e.encrypted&&!((s=e.decryptdata)!=null&&s.key)?(this.log(`Loading key for ${e.sn} of [${t.startSN}-${t.endSN}], ${this.playlistLabel()} ${e.level}`),this.state=Y.KEY_LOADING,n=this.keyLoader.load(e,i).then(a=>{if(!this.fragContextChanged(a.frag))return this.hls.trigger(E.KEY_LOADED,a),this.state===Y.KEY_LOADING&&(this.state=Y.IDLE),a}),this.hls.trigger(E.KEY_LOADING,{frag:e})):e.encrypted||(n=this.keyLoader.loadClear(e,t.encryptedFragments,this.startFragRequested),n&&this.log(`[eme] blocking frag sn: ${e.sn} load until media-keys acquired`)),n}_doFragLoad(e,t,i=null,s){this.fragCurrent=e;const n=t.details;if(!this.levels||!n)throw new Error(`frag load aborted, missing level${n?"":" detail"}s`);const a=this.fragPrevious;if(!us(e,a)){const m=this.shouldLoadParts(t.details,e.end);m!==this.loadingParts&&(this.log(`LL-Part loading ${m?"ON":"OFF"} loading sn ${a?.sn}->${e.sn}`),this.loadingParts=m)}if(i=Math.max(e.start,i||0),this.loadingParts){const m=n.partList;if(m&&s){i>n.fragmentEnd&&n.fragmentHint&&(e=n.fragmentHint);const A=this.getNextPart(m,e,i);if(A>-1){const C=m[A];if(e=this.fragCurrent=C.fragment,!us(e,a)&&!this.shouldLoadParts(t.details,e.end))return this.log(`LL-Part loading OFF @${this.playhead} next part: ${this.fragInfo(e,!1,C)}`),this.loadingParts=!1,Promise.resolve(null);if(!this.filterReplacedPrimary(C,t.details))return Promise.resolve(null);const v=this.loadKeyFor(e,n);if(this.fragContextChanged(e))return Promise.resolve(null);this.log(`Loading ${e.type} sn: ${e.sn} part: ${C.index} (${A}/${m.length-1}) of ${this.fragInfo(e,!1,C)} cc: ${e.cc} [${n.startSN}-${n.endSN}], target: ${i}${C.byteRange.length?` range:${C.byteRange.join("-")}`:""}`),this.nextLoadPosition=C.start+C.duration,this.state=Y.FRAG_LOADING;let S;const R=this.loadInitSegmentIfNeeded(e);if(v||R){const b=!!v;S=Promise.all([v,R]).then(([D])=>b&&(!D||this.fragContextChanged(D.frag))?null:this.doFragPartsLoad(e,C,t,s)).catch(D=>this.handleFragLoadError(D))}else S=this.doFragPartsLoad(e,C,t,s).catch(b=>this.handleFragLoadError(b));return this.hls.trigger(E.FRAG_LOADING,{frag:e,part:C,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):S}else if(!e.url||this.loadedEndOfParts(m,i))return Promise.resolve(null)}}if(this.loadingParts){var o;this.log(`LL-Part loading OFF after next part miss @${i} Check buffer at sn: ${e.sn} loaded parts: ${(o=n.partList)==null?void 0:o.filter(m=>m.loaded).map(m=>`[${m.start}-${m.end}]`)}`),this.loadingParts=!1}else if(!e.url)return Promise.resolve(null);if(!this.filterReplacedPrimary(e,t.details))return Promise.resolve(null);const l=this.loadInitSegmentIfNeeded(e),u=this.loadKeyFor(e,n,l);if(this.fragContextChanged(e)){var h;return this.log(`Context changed in KEY_LOADING sn: ${e.sn} ${e.relurl} > ${(h=this.fragCurrent)==null?void 0:h.relurl}`),l?.catch(()=>null),u?.catch(()=>null),Promise.resolve(null)}this.log(`Loading ${e.type} sn: ${e.sn} of ${this.fragInfo(e,!1)} cc: ${e.cc} ${"["+n.startSN+"-"+n.endSN+"]"}, target: ${i}${e.byteRange.length?` range:${e.byteRange.join("-")}`:""}`),se(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=Y.FRAG_LOADING;const d=this.config.progressive&&e.type!==ge.SUBTITLE;let g;return d&&u?g=u.then(m=>!m||this.fragContextChanged(m.frag)?null:this.fragmentLoader.load(e,this.iframesOnly,s,l)).catch(m=>this.handleFragLoadError(m)):g=Promise.all([this.fragmentLoader.load(e,this.iframesOnly,d?s:void 0,d?l:void 0),u,l]).then(([m])=>(!d&&s&&s(m),m)).catch(m=>this.handleFragLoadError(m)),this.hls.trigger(E.FRAG_LOADING,{frag:e,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):Promise.all([g,l]).then(([m])=>m)}doFragPartsLoad(e,t,i,s){return new Promise((n,a)=>{var o;const l=[],u=(o=i.details)==null?void 0:o.partList,h=d=>{this.fragmentLoader.loadPart(e,d,s).then(g=>{l[d.index]=g;const m=g.part;this.hls.trigger(E.FRAG_LOADED,g);const A=Il(i.details,e.sn,d.index+1)||Cl(u,e.sn,d.index+1);if(A)h(A);else return n({frag:e,part:m,partsLoaded:l})}).catch(a)};h(t)})}handleFragLoadError(e){if("data"in e){const t=e.data;t.frag&&t.details===U.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):t.frag&&t.type===me.KEY_SYSTEM_ERROR&&!t.fatal&&(t.frag.abortRequests(),this.resetStartWhenNotLoaded(),this.resetFragmentLoading(t.frag)),this.hls.trigger(E.ERROR,t)}else this.hls.trigger(E.ERROR,{type:me.OTHER_ERROR,details:U.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){const t=this.getCurrentContext(e);if(!t||this.state!==Y.PARSING){!this.fragCurrent&&this.state!==Y.STOPPED&&this.state!==Y.ERROR&&(this.state=Y.IDLE);return}const{frag:i,part:s,level:n}=t,a=self.performance.now();i.stats.parsing.end=a,s&&(s.stats.parsing.end=a);const o=this.getLevelDetails(),u=o&&i.sn>o.endSN||this.shouldLoadParts(o,i.end);u!==this.loadingParts&&(this.log(`LL-Part loading ${u?"ON":"OFF"} after parsing segment ending @${i.end}`),this.loadingParts=u),this.updateLevelTiming(i,s,n,e)}shouldLoadParts(e,t){if(this.config.lowLatencyMode){if(!e)return this.loadingParts;if(e.partList&&!this.iframesOnly){var i;const s=e.partList[0],n=s.end+(((i=e.fragmentHint)==null?void 0:i.duration)||0);if(t>=n&&this.playhead>s.start-s.fragment.duration)return!0}}return!1}getCurrentContext(e){const{levels:t,fragCurrent:i}=this,{level:s,sn:n,part:a}=e;if(!(t!=null&&t[s]))return this.warn(`Levels object was unset while buffering fragment ${n} of ${this.playlistLabel()} ${s}. The current chunk will not be buffered.`),null;const o=t[s],l=o.details,u=a>-1?Il(l,n,a):null,h=u?u.fragment:Al(l,n,i);return h?(i&&i!==h&&(h.stats=i.stats),{frag:h,part:u,level:o}):null}bufferFragmentData(e,t,i,s,n){if(this.state!==Y.PARSING)return;st(t)&&!this.fragContextChanged(t)&&(this.fragPrevious=t);const{data1:a,data2:o}=e;let l=a;if(o&&(l=Ut(a,o)),!l.length)return;const u=this.initPTS[t.cc],h=u?-u.baseTime/u.timescale:void 0,d={type:e.type,frag:t,part:i,chunkMeta:s,offset:h,parent:t.type,data:l};if(this.hls.trigger(E.BUFFER_APPENDING,d),e.dropped&&e.independent&&!i){if(n)return;this.flushBufferGap(t)}}flushBufferGap(e){const t=this.media;if(!t)return;if(!ve.isBuffered(t,t.currentTime)){this.flushMainBuffer(0,e.start);return}const i=t.currentTime,s=ve.bufferInfo(t,i,0),n=e.duration,a=Math.min(this.config.maxFragLookUpTolerance*2,n*.25),o=Math.max(Math.min(e.start-a,s.end-a),i+a);e.start-o>a&&this.flushMainBuffer(o,e.start)}getFwdBufferInfo(e,t){var i;const s=this.playhead,a=this.lastCurrentTime>s||(i=this.media)!=null&&i.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(e,s,t,a)}getFwdBufferInfoAtPos(e,t,i,s){const n=ve.bufferInfo(e,t,s);if(n.len===0&&n.nextStart!==void 0){const a=this.fragmentTracker.getBufferedFrag(t,i);if(a&&(n.nextStart<=a.end||a.gap)){const o=Math.max(Math.min(n.nextStart,a.end)-t,s);return ve.bufferInfo(e,t,o)}}return n}getMaxBufferLength(e){const{config:t}=this;let i;return e?i=Math.max(8*t.maxBufferSize/e,t.maxBufferLength):i=t.maxBufferLength,Math.min(i,t.maxMaxBufferLength)}exceedsMaxBuffer(e,t,i){const s=e.nextStart;if(s&&i.start>s){const n=e.buffered;if(n){let a=e.len;const o=e.bufferedIndex;for(let l=n.length-1;l>o;l--)n[l].start<i.start&&(a+=n[l].end-n[l].start);return a>=t}}return!1}reduceMaxBufferLength(e,t){const i=this.config,s=Math.max(Math.min(e-t,i.maxBufferLength),t/2),n=Math.max(e-t*3,i.maxMaxBufferLength/2,s);return n>=s?(i.maxMaxBufferLength=n,this.warn(`Reduce max buffer length to ${n}s`),!0):!1}getAppendedFrag(e){const t=this.fragmentTracker?this.fragmentTracker.getAppendedFrag(e,this.playlistType):null;return t&&"fragment"in t?t.fragment:t}getNextFragment(e,t){const i=t.fragments,s=i.length;if(!s)return null;const{config:n}=this,a=t.fragmentStart,o=n.lowLatencyMode&&!!t.partList;let l=null;if(t.live){const d=n.initialLiveManifestSize;if(s<d)return this.warn(`Not enough fragments to start playback (have: ${s}, need: ${d})`),null;if(!this.startFragRequested&&o&&!this.loadingParts&&(this.log("LL-Part loading ON for initial live fragment"),this.loadingParts=!0),!t.PTSKnown&&!this.startFragRequested&&this.startPosition===-1||e<a){var u;l=this.getInitialLiveFragment(t);const g=this.config.startPosition,m=this.hls.startPosition,A=this.hls.liveSyncPosition,C=((u=l)==null?void 0:u.start)||0;let v,S;if(m!==-1&&m>=a?(v=m,S=m===g?"config":"next load start"):A?(v=A,S="live edge"):(v=e,S="buffer pos"),v<C&&(v=C,S="live frag start"),v<a&&(v=a,S="playlist start"),this.startPosition!=v||this.nextLoadPosition!=v){const b=t.live&&!this.filterReplacedPrimary(l,t)?-1:v;this.log(`Setting startPosition to ${b} next load ${v} ${m===-1?"":`(from ${g}) `}based on ${S}. live edge: ${A} live frag start: ${C} playlist start: ${a} buffer pos: ${e}`),this.startPosition=b,this.nextLoadPosition=v}}}else e<=a&&(l=i[0]);if(!l){const d=this.loadingParts?t.partEnd:t.fragmentEnd;l=this.getFragmentAtPosition(e,d,t)}let h=this.filterReplacedPrimary(l,t);return!h&&l&&(h=Fo(t,l.sn),h&&(this.nextLoadPosition=h.start)),h}isLoopLoading(e,t){if(this.nextLoadPosition<=t)return!1;const i=this.fragmentTracker.getState(e);return!!(i===et.OK||i===et.PARTIAL&&(e.gap||e.stats.retry>1))}getNextFragmentLoopLoading(e,t,i,s,n){let a=null;if(e.gap&&(a=this.getNextFragment(this.nextLoadPosition,t),a&&!a.gap&&i.nextStart)){const o=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,s,0);if(o!==null&&i.len+o.len>=n){const l=a.sn;return this.loopSn!==l&&(this.log(`buffer full after gaps in "${s}" playlist starting at sn: ${l}`),this.loopSn=l),null}}return this.loopSn=void 0,a}get primaryPrefetch(){if(dn(this.config)){var e;if((e=this.hls.interstitialsManager)==null||(e=e.playingItem)==null?void 0:e.event)return!0}return!1}filterReplacedPrimary(e,t){if(!e)return e;if(dn(this.config)&&("type"in e?e:e.fragment).type!==ge.SUBTITLE){const i=this.hls.interstitialsManager,s=i?.bufferingItem;if(s){const n=s.event;if(n){if(!n.appendInPlace&&(Math.abs(e.start-s.start)>1||s.start===0))return null}else if(e.end<=s.start&&t?.live===!1||e.start>=s.end&&s.nextEvent&&(s.nextEvent.appendInPlace&&!s.nextEvent.hasPlayed||e.start-s.end>1))return null}if(Sl(e,i?.playerQueue,this.playhead))return null}return e}getNextPart(e,t,i){let s=-1,n=!1,a=!0;for(let l=0,u=e.length;l<u;l++){const h=e[l];if(a=a&&!h.independent,s>-1&&i<h.start)break;const d=h.loaded||h.gap;d?s=-1:(n||(h.independent||a)&&h.fragment===t)&&(s=l),n=d&&!h.gap}const o=e[s];return o&&o.fragment!==t&&this.log(`Need buffer at ${i} but next unloaded part starts at ${o.start} (sn: ${t.sn} -> ${o.fragment.sn})`),s}loadedEndOfParts(e,t){let i;for(let s=e.length;s--;){if(i=e[s],!i.loaded)return!1;if(t>i.start)return!0}return!1}getInitialLiveFragment(e){const t=e.fragments,i=this.fragPrevious;let s=null;if(i){if(e.hasProgramDateTime&&(s=yd(t,i.endProgramDateTime,this.config.maxFragLookUpTolerance),s&&this.log(`Live playlist, switching playlist, load frag with same PDT: ${i.programDateTime}`)),!s){const n=i.sn+1;if(n>=e.startSN&&n<=e.endSN){const a=t[n-e.startSN];i.cc===a.cc&&(s=a,this.log(`Live playlist, switching playlist, load frag with next SN: ${s.sn}`))}s||(s=Oo(e,i.cc,i.end),s&&this.log(`Live playlist, switching playlist, load frag with same CC: ${s.sn}`))}}else{const n=this.hls.liveSyncPosition;n!==null&&(s=this.getFragmentAtPosition(n,this.bitrateTest?e.fragmentEnd:e.edge,e))}return s}getFragmentAtPosition(e,t,i){const{config:s}=this;let{fragPrevious:n}=this,{fragments:a,endSN:o}=i;const{fragmentHint:l}=i,{maxFragLookUpTolerance:u}=s,h=i.partList,d=!!(this.loadingParts&&h!=null&&h.length&&l);d&&!this.bitrateTest&&h[h.length-1].fragment.sn===l.sn&&(a=a.concat(l),o=l.sn),n&&this.fragmentTracker.getState(n)===et.NOT_LOADED&&(n=null);let g;if(e<t){var m;const C=e<this.lastCurrentTime||e>t-u||(m=this.media)!=null&&m.paused||!this.startFragRequested?0:u;g=ji(n,a,e,C)}else g=a[a.length-1];if(g){const A=g.sn-i.startSN,C=this.fragmentTracker.getState(g);if((C===et.OK||C===et.PARTIAL&&g.gap)&&(n=g),us(g,n)&&(!d||h[0].fragment.sn>g.sn||!i.live)){const v=a[A+1];g.sn<o&&this.fragmentTracker.getState(v)!==et.OK?g=v:g=null}}return g}alignPlaylists(e,t,i){const s=e.fragments.length;if(!s)return this.warn("No fragments in live playlist"),0;const n=e.fragmentStart,a=!t,o=e.alignedSliding&&se(n);if(a||!o&&!n){cn(i,e,this);const l=e.fragmentStart;return this.log(`Live playlist sliding: ${l} start-sn: ${t?t.startSN:"na"}->${e.startSN} fragments: ${s}`),l}return n}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,e.partTarget*3)}setStartPosition(e,t){let i=this.startPosition;i<t&&(i=-1);const s=this.timelineOffset;if(i===-1){const n=this.startTimeOffset!==null,a=n?this.startTimeOffset:e.startTimeOffset;if(a!==null&&se(a))i=t+a,a<0&&(i+=e.edge),i=Math.min(Math.max(t,i),t+e.totalduration),this.log(`Setting startPosition to ${i} for start time offset ${a} found in ${n?"multivariant":"media"} playlist`),this.startPosition=i;else if(e.live){const o=this.hls.liveSyncPosition;i=o||t,this.log(`Setting startPosition to -1 to start at ${o?"live edge":"playlist start"} ${i}`),this.startPosition=-1}else this.log("setting startPosition to 0 by default"),this.startPosition=i=0;this.lastCurrentTime=i+s}this.nextLoadPosition=i+s}getLoadPosition(){var e;const{media:t}=this;let i=0;return(e=this.hls)!=null&&e.hasEnoughToStart&&t&&!this.iframesOnly?i=t.currentTime:this.nextLoadPosition>=0&&(i=this.nextLoadPosition),i}get playhead(){var e;if((e=this.hls)!=null&&e.hasEnoughToStart){var t;const i=(t=this.media)==null?void 0:t.currentTime;return se(i)?i:this.lastCurrentTime}return this.getLoadPosition()}get iframesOnly(){var e;if(this.playlistType!==ge.MAIN)return!1;const t=this.getLevelDetails();return t?t.iframesOnly:(e=this.levelLastLoaded)==null?void 0:e.iframes}handleFragLoadAborted(e,t){this.transmuxer&&e.type===this.playlistType&&st(e)&&e.stats.aborted&&(this.log(`Fragment ${e.sn}${t?" part "+t.index:""} of ${this.playlistLabel()} ${e.level} was aborted`),this.resetFragmentLoading(e))}resetFragmentLoading(e){(!this.fragCurrent||!this.fragContextChanged(e)&&this.state!==Y.FRAG_LOADING_WAITING_RETRY)&&(this.state=Y.IDLE)}onFragmentOrKeyLoadError(e,t){if(t.chunkMeta&&!t.frag){const R=this.getCurrentContext(t.chunkMeta);R&&(t.frag=R.frag)}const{frag:i,part:s}=t;if(!i||!this.levels||i.type!==e)return;if(this.fragContextChanged(i)){var n;this.warn(`Frag load error must match current frag to retry ${i.relurl} > ${(n=this.fragCurrent)==null?void 0:n.relurl}`);return}const a=t.details===U.FRAG_GAP;a&&this.fragmentTracker.addAsGap(i);const o=t.errorAction;if(!o){this.state=Y.ERROR;return}const{action:l,flags:u,retryCount:h=0,retryConfig:d}=o,g=!!d,m=g&&l===gt.RetryRequest,A=g&&!o.resolved&&u&dt.MoveAllAlternatesMatchingHost,C=this.hls.latestLevelDetails,v=C?.live;if(!m&&A&&st(i)&&v&&i.sn<C.endSN&&!Ha(t))this.resetFragmentErrors(e),s?s.gap=!0:this.treatAsGap(i),o.resolved=!0;else if((m||A)&&h<d.maxNumRetry){var S;const R=hs((S=t.response)==null?void 0:S.code),b=Wn(d,h);if(this.resetStartWhenNotLoaded(),this.retryDate=self.performance.now()+b,this.state=Y.FRAG_LOADING_WAITING_RETRY,o.resolved=!0,R){this.log("Waiting for connection (offline)"),this.retryDate=1/0,t.reason="offline";return}this.warn(`Fragment ${i.sn} of ${e} ${i.level} errored with ${t.details}, retrying loading ${h+1}/${d.maxNumRetry} in ${b}ms`)}else if(d)if(this.resetFragmentErrors(e),h<d.maxNumRetry)!a&&l!==gt.RemoveAlternatePermanently&&(o.resolved=!0);else{this.warn(`${t.details} reached or exceeded max retry (${h})`);return}else l===gt.SendAlternateToPenaltyBox?this.state=Y.WAITING_LEVEL:this.state=Y.ERROR;this.tickImmediate()}checkRetryDate(){const e=self.performance.now(),t=this.retryDate,i=t===1/0;(!t||e>=t||i&&!hs(0))&&(i&&this.log("Connection restored (online)"),this.resetStartWhenNotLoaded(),this.state=Y.IDLE)}reduceLengthAndFlushBuffer(e){if(this.state===Y.PARSING||this.state===Y.PARSED){const t=e.frag,i=e.parent,s=this.getFwdBufferInfo(this.mediaBuffer,i),n=s&&s.len>.5;n&&this.reduceMaxBufferLength(s.len,t?.duration||10);const a=!n;return a?this.warn(`Buffer full error while media.currentTime (${this.playhead}) is not buffered, flush ${i} buffer`):s.nextStart&&t&&s.nextStart>t.start&&this.flushMainBuffer(s.nextStart,Number.POSITIVE_INFINITY,i===ge.AUDIO?i:void 0),t&&(this.fragmentTracker.removeFragment(t),this.nextLoadPosition=t.start),this.resetLoadingState(),a}return!1}resetFragmentErrors(e){e===ge.AUDIO&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==Y.STOPPED&&(this.state=Y.IDLE)}afterBufferFlushed(e,t){if(!e)return;const i=ve.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,i,this.playlistType),this.state===Y.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==Y.STOPPED&&(this.state=Y.IDLE)}resetStartWhenNotLoaded(){if(!this.hls.hasEnoughToStart){this.startFragRequested=!1;const e=this.getLevelDetails();e!=null&&e.live?(this.log("resetting startPosition for live start"),this.startPosition=-1,this.setStartPosition(e,e.fragmentStart),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(e){this.log(`Loading context changed while buffering sn ${e.sn} of ${this.playlistLabel()} ${e.level===-1?"<removed>":e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(),this.resetLoadingState()}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(e,t,i,s){const n=i.details;if(!n){this.warn("level.details undefined");return}if(this.log(`update level timing ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)}`),!Object.keys(e.elementaryStreams).reduce((d,g)=>{const m=e.elementaryStreams[g];if(m){const A=m.endPTS-m.startPTS;if(A<=0)return this.warn(`Could not parse fragment ${e.sn} ${g} duration reliably (${A})`),d||!1;const C=s.partial?0:fl(n,e,m.startPTS,m.endPTS,m.startDTS,m.endDTS,this.iframesOnly,this);return this.hls.trigger(E.LEVEL_PTS_UPDATED,{details:n,level:i,drift:C,type:g,frag:e,start:m.startPTS,end:m.endPTS}),!0}return d},!1)){var o,l,u,h;const d=((o=this.transmuxer)==null?void 0:o.error)===null,g=((l=this.transmuxer)==null?void 0:l.error)!=null,m=((u=(h=this.levels)==null?void 0:h.length)!=null?u:0)>1;if((i.fragmentError===0||d&&(i.fragmentError<2||e.endList)||g&&m)&&this.treatAsGap(e,i),d){const A=new Error(`Found no media in ${this.playlistLabel()} ${e.level} ${t?`part: ${t.index} of `:""}sn: ${e.sn} at playlist time: ${e.start}. Resetting transmuxer to fallback to playlist timing`);if(this.warn(A.message),this.hls.trigger(E.ERROR,{type:me.MEDIA_ERROR,details:U.FRAG_PARSING_ERROR,fatal:!1,error:A,frag:e,reason:`Found no media in msn ${e.sn} of ${this.playlistLabel()} "${i.url}"`}),!this.hls)return;this.resetTransmuxer()}}this.state=Y.PARSED,this.log(`Parsed ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)}`),this.hls.trigger(E.FRAG_PARSED,{frag:e,part:t,chunkMeta:s})}playlistLabel(){return`${this.playlistType} playlist`}fragInfo(e,t=!0,i){var s,n;return`${this.playlistLabel()} ${e.level} (${i?"part":"frag"}:[${(s=t&&!i?e.startPTS:(i||e).start)!=null?s:NaN}-${(n=t&&!i?e.endPTS:(i||e).end)!=null?n:NaN}]${i&&e.type==="main"?"INDEPENDENT="+(i.independent?"YES":"NO"):""})`}treatAsGap(e,t){t&&t.fragmentError++,this.fragmentTracker.addAsGap(e)}resetTransmuxer(){var e;(e=this.transmuxer)==null||e.reset()}isFragmentNearlyDownloaded(e){var t;const i=(t=e.loader)==null?void 0:t.stats;if(!i)return!1;const s=i.loading.first>0,a=(i.total-i.loaded)/(this.hls.bandwidthEstimate||this.hls.config.abrEwmaDefaultEstimate);return s&&a<=.15}recoverWorkerError(e){e.event==="demuxerWorker"&&(this.fragmentTracker.removeAllFragments(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),this.resetStartWhenNotLoaded(),this.resetLoadingState())}set state(e){const t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}get state(){return this._state}calculateOptimalSwitchPoint(e,t){let i=0;const{hls:s,media:n,config:a,levels:o,playlistType:l}=this,u=this.getLevelDetails();if(n&&!n.paused&&o){var h;const m=l===ge.AUDIO?So(e.audioCodec,128e3):e.maxBitrate,A=1+s.ttfbEstimate/1e3,C=s.bandwidthEstimate*a.abrBandWidthUpFactor,v=u&&(this.loadingParts?u.partTarget:u.averagetargetduration)||((h=this.fragCurrent)==null?void 0:h.duration)||6;i=A+m*v/C,e.details||(i+=A)}const d=this.playhead,g=!(u!=null&&u.live)||t.end-d>i*1.5;return{fetchdelay:i,okToFlushForwardBuffer:g}}scheduleTrackSwitch(e,t,i){const{media:s,playlistType:n}=this;if(!s||!e)return;const a=i?this.getBufferedFrag(this.playhead+t):null;if(a){const l=this.followingBufferedFrag(a);if(l){var o;this.abortCurrentFrag();const u=l.maxStartPTS?l.maxStartPTS:l.start,h=l.duration,d=Math.max(a.end,u+Math.min(Math.max(h-this.config.maxFragLookUpTolerance,h*(this.couldBacktrack?.5:.125)),h*(this.couldBacktrack?.75:.25)));if((((o=this.getLevelDetails())==null?void 0:o.fragmentStart)||0)>d)return;const m=n===ge.MAIN?null:"audio";this.flushMainBuffer(d,Number.POSITIVE_INFINITY,m),this.cleanupBackBuffer()}}}cleanupBackBuffer(){const{media:e,playlistType:t}=this;if(!e)return;const i=this.getAppendedFrag(this.playhead);if(i&&i.start>1){const s=t===ge.AUDIO;this.flushMainBuffer(0,i.start-(s?0:1),s?"audio":null)}}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,this.playlistType)}followingBufferedFrag(e){return e?this.getBufferedFrag(e.end+.5):null}abortCurrentFrag(){const e=this.fragCurrent;switch(this.fragCurrent=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case Y.KEY_LOADING:case Y.FRAG_LOADING:case Y.FRAG_LOADING_WAITING_RETRY:case Y.PARSING:case Y.PARSED:this.state=Y.IDLE;break}this.nextLoadPosition=this.playhead}checkFragPlaying(){const e=this.media;let t=null;if(e&&e.readyState>1&&e.seeking===!1){const i=e.currentTime;if(ve.isBuffered(e,i)?t=this.getAppendedFrag(i):ve.isBuffered(e,i+.1)&&(t=this.getAppendedFrag(i+.1)),t&&(this.backtrackFragment=void 0,!us(t,this.fragPlaying)))return this.fragPlaying=t,!0}return!1}getBufferOutput(){return null}nextLevelSwitch(){const{levels:e,media:t,hls:i,config:s,playlistType:n}=this;if(t!=null&&t.readyState&&e&&i&&s){const a=this.getBufferOutput(),o=this.getFwdBufferInfo(a,n);if(!o)return;const l=n===ge.AUDIO?i.nextAudioTrack:i.nextLoadLevel,u=e[l],{fetchdelay:h,okToFlushForwardBuffer:d}=this.calculateOptimalSwitchPoint(u,o);this.scheduleTrackSwitch(o,h,d)}this.tickImmediate()}}function Sl(r,e,t){if(e)for(let i=e.length;i--;){const s=e[i].interstitial,n=s.startTime,a=Math.min(n+s.duration,s.resumeTime);if(s.appendInPlace&&(r.start>=n&&r.end<=a||t>r.start&&r.end>n&&r.start<a))return!0}return!1}function dn(r){return!!r.interstitialsController&&r.enableInterstitialPlayback!==!1}class xl{constructor(){this.chunks=[],this.dataLength=0}push(e){this.chunks.push(e),this.dataLength+=e.length}flush(){const{chunks:e,dataLength:t}=this;let i;if(e.length)e.length===1?i=e[0]:i=rf(e,t);else return new Uint8Array(0);return this.reset(),i}reset(){this.chunks.length=0,this.dataLength=0}}function rf(r,e){const t=new Uint8Array(e);let i=0;for(let s=0;s<r.length;s++){const n=r[s];t.set(n,i),i+=n.length}return t}var Tr={exports:{}},bl;function af(){return bl||(bl=1,(function(r){var e=Object.prototype.hasOwnProperty,t="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(t=!1));function s(l,u,h){this.fn=l,this.context=u,this.once=h||!1}function n(l,u,h,d,g){if(typeof h!="function")throw new TypeError("The listener must be a function");var m=new s(h,d||l,g),A=t?t+u:u;return l._events[A]?l._events[A].fn?l._events[A]=[l._events[A],m]:l._events[A].push(m):(l._events[A]=m,l._eventsCount++),l}function a(l,u){--l._eventsCount===0?l._events=new i:delete l._events[u]}function o(){this._events=new i,this._eventsCount=0}o.prototype.eventNames=function(){var u=[],h,d;if(this._eventsCount===0)return u;for(d in h=this._events)e.call(h,d)&&u.push(t?d.slice(1):d);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(h)):u},o.prototype.listeners=function(u){var h=t?t+u:u,d=this._events[h];if(!d)return[];if(d.fn)return[d.fn];for(var g=0,m=d.length,A=new Array(m);g<m;g++)A[g]=d[g].fn;return A},o.prototype.listenerCount=function(u){var h=t?t+u:u,d=this._events[h];return d?d.fn?1:d.length:0},o.prototype.emit=function(u,h,d,g,m,A){var C=t?t+u:u;if(!this._events[C])return!1;var v=this._events[C],S=arguments.length,R,b;if(v.fn){switch(v.once&&this.removeListener(u,v.fn,void 0,!0),S){case 1:return v.fn.call(v.context),!0;case 2:return v.fn.call(v.context,h),!0;case 3:return v.fn.call(v.context,h,d),!0;case 4:return v.fn.call(v.context,h,d,g),!0;case 5:return v.fn.call(v.context,h,d,g,m),!0;case 6:return v.fn.call(v.context,h,d,g,m,A),!0}for(b=1,R=new Array(S-1);b<S;b++)R[b-1]=arguments[b];v.fn.apply(v.context,R)}else{var D=v.length,_;for(b=0;b<D;b++)switch(v[b].once&&this.removeListener(u,v[b].fn,void 0,!0),S){case 1:v[b].fn.call(v[b].context);break;case 2:v[b].fn.call(v[b].context,h);break;case 3:v[b].fn.call(v[b].context,h,d);break;case 4:v[b].fn.call(v[b].context,h,d,g);break;default:if(!R)for(_=1,R=new Array(S-1);_<S;_++)R[_-1]=arguments[_];v[b].fn.apply(v[b].context,R)}}return!0},o.prototype.on=function(u,h,d){return n(this,u,h,d,!1)},o.prototype.once=function(u,h,d){return n(this,u,h,d,!0)},o.prototype.removeListener=function(u,h,d,g){var m=t?t+u:u;if(!this._events[m])return this;if(!h)return a(this,m),this;var A=this._events[m];if(A.fn)A.fn===h&&(!g||A.once)&&(!d||A.context===d)&&a(this,m);else{for(var C=0,v=[],S=A.length;C<S;C++)(A[C].fn!==h||g&&!A[C].once||d&&A[C].context!==d)&&v.push(A[C]);v.length?this._events[m]=v.length===1?v[0]:v:a(this,m)}return this},o.prototype.removeAllListeners=function(u){var h;return u?(h=t?t+u:u,this._events[h]&&a(this,h)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=t,o.EventEmitter=o,r.exports=o})(Tr)),Tr.exports}var of=af(),Sr=Xc(of);const Ts="1.7.3",Zi={};function lf(){return typeof __HLS_WORKER_BUNDLE__=="function"}function uf(){const r=Zi[Ts];if(r)return r.clientCount++,r;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),s={worker:new self.Worker(t),objectURL:t,clientCount:1};return Zi[Ts]=s,s}function cf(r){const e=Zi[r];if(e)return e.clientCount++,e;const t=new self.URL(r,self.location.href).href,s={worker:new self.Worker(t),scriptURL:t,clientCount:1};return Zi[r]=s,s}function hf(r){const e=Zi[r||Ts];if(e&&e.clientCount--===1){const{worker:i,objectURL:s}=e;delete Zi[r||Ts],s&&self.URL.revokeObjectURL(s),i.terminate()}}function df(r,e,t,i){const s=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],n=e[t+2],a=n>>2&15;if(a>12){const v=new Error(`invalid ADTS sampling index:${a}`);r.emit(E.ERROR,E.ERROR,{type:me.MEDIA_ERROR,details:U.FRAG_PARSING_ERROR,fatal:!0,error:v,reason:v.message});return}const o=(n>>6&3)+1,l=e[t+3]>>6&3|(n&1)<<2,u=s[a];let h=a;(o===5||o===29)&&(h-=3);let d;const g=(h&14)>>1,m=(h&1)<<7|l<<3;let A=0;if(o===1&&a>=6){A=5;const v=a-3;d=[A<<3|g,m|(v&14)>>1,(v&1)<<7|8,0]}else d=[o<<3|g,m];const C="mp4a.40."+(A||o);return Ge.log(`manifest codec:${i}, parsed codec:${C}, channels:${l}, rate:${u} (ADTS object type:${o} sampling index:${a} esds config:[${d.join(",")}])`),{config:d,samplerate:u,channelCount:l,codec:C,parsedCodec:C,manifestCodec:i}}function Ll(r,e){return r[e]===255&&(r[e+1]&246)===240}function Rl(r,e){return r[e+1]&1?7:9}function xr(r,e){return(r[e+3]&3)<<11|r[e+4]<<3|(r[e+5]&224)>>>5}function ff(r,e){return e+5<r.length}function fn(r,e){return e+1<r.length&&Ll(r,e)}function gf(r,e){return ff(r,e)&&Ll(r,e)&&xr(r,e)<=r.length-e}function pf(r,e){if(fn(r,e)){const t=Rl(r,e);if(e+t>=r.length)return!1;const i=xr(r,e);if(i<=t)return!1;const s=e+i;return s===r.length||fn(r,s)}return!1}function Dl(r,e,t,i,s){if(!r.samplerate){const n=df(e,t,i,s);if(!n)return;je(r,n)}}function Pl(r){return 1024*9e4/r}function mf(r,e){const t=Rl(r,e);if(e+t<=r.length){const i=xr(r,e)-t;if(i>0)return{headerLength:t,frameLength:i}}}function _l(r,e,t,i,s){const n=Pl(r.samplerate),a=i+s*n,o=mf(e,t);let l;if(o){const{frameLength:d,headerLength:g}=o,m=g+d,A=Math.max(0,t+m-e.length);A?(l=new Uint8Array(m-g),l.set(e.subarray(t+g,e.length),0)):l=e.subarray(t+g,t+m);const C={unit:l,pts:a};return A||r.samples.push(C),{sample:C,length:m,missing:A}}const u=e.length-t;return l=new Uint8Array(u),l.set(e.subarray(t,e.length),0),{sample:{unit:l,pts:a},length:u,missing:-1}}let Et=(function(r){return r.audioId3="org.id3",r.dateRange="com.apple.quicktime.HLS",r.emsg="https://aomedia.org/emsg/ID3",r.misbklv="urn:misb:KLV:bin:1910.1",r})({});function ri(r="",e=9e4){return{type:r,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}class br{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(e,t,i,s){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(e){this.initPTS=e,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(e,t){return!1}appendFrame(e,t,i){}demux(e,t){this.cachedData&&(e=Ut(this.cachedData,e),this.cachedData=null);let i=ds(e,0),s=i?i.length:0,n;const a=this._audioTrack,o=this._id3Track,l=i?Qn(i):void 0,u=e.length;for((this.basePTS===null||this.frameIndex===0&&se(l))&&(this.basePTS=Af(l,t,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),i&&i.length>0&&o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:Et.audioId3,duration:Number.POSITIVE_INFINITY});s<u;){if(this.canParse(e,s)){const h=this.appendFrame(a,e,s);h?(this.frameIndex++,this.lastPTS=h.sample.pts,s+=h.length,n=s):s=u}else ph(e,s)?(i=ds(e,s),o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:Et.audioId3,duration:Number.POSITIVE_INFINITY}),s+=i.length,n=s):s++;if(s===u&&n!==u){const h=e.slice(n);this.cachedData?this.cachedData=Ut(this.cachedData,h):this.cachedData=h}}return{audioTrack:a,videoTrack:ri(),id3Track:o,textTrack:ri()}}demuxSampleAes(e,t,i){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(e){const t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:ri(),id3Track:this._id3Track,textTrack:ri()}}destroy(){this.cachedData=null,this._audioTrack=this._id3Track=void 0}}const Af=(r,e,t)=>{if(se(r))return r*90;const i=t?t.baseTime*9e4/t.timescale:0;return e*9e4+i},If=[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],Cf=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],yf=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],vf=[0,1,1,4];function kl(r,e,t,i,s){if(t+24>e.length)return;const n=wl(e,t);if(n&&t+n.frameLength<=e.length){const a=n.samplesPerFrame*9e4/n.sampleRate,o=i+s*a,l={unit:e.subarray(t,t+n.frameLength),pts:o,dts:o};return r.config=[],r.channelCount=n.channelCount,r.samplerate=n.sampleRate,r.samples.push(l),{sample:l,length:n.frameLength,missing:0}}}function wl(r,e){const t=r[e+1]>>3&3,i=r[e+1]>>1&3,s=r[e+2]>>4&15,n=r[e+2]>>2&3;if(t!==1&&s!==0&&s!==15&&n!==3){const a=r[e+2]>>1&1,o=r[e+3]>>6,l=t===3?3-i:i===3?3:4,u=If[l*14+s-1]*1e3,d=Cf[(t===3?0:t===2?1:2)*3+n],g=o===3?1:2,m=yf[t][i],A=vf[i],C=m*8*A,v=Math.floor(m*u/d+a)*A,S=ps();return S&&S<=87&&i===2&&u>=224e3&&o===0&&(r[e+3]=r[e+3]|128),{sampleRate:d,channelCount:g,frameLength:v,samplesPerFrame:C}}}function Lr(r,e){return r[e]===255&&(r[e+1]&224)===224&&(r[e+1]&6)!==0}function Ml(r,e){return e+1<r.length&&Lr(r,e)}function Ef(r,e){return Lr(r,e)&&4<=r.length-e}function Ol(r,e){if(e+1<r.length&&Lr(r,e)){const i=wl(r,e);let s=4;i!=null&&i.frameLength&&(s=i.frameLength);const n=e+s;return n===r.length||Ml(r,n)}return!1}class Fl{constructor(e,t,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new hr(t,!0)}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,Si.cbc,{start:0,end:e.byteLength})}decryptAacSample(e,t,i){const s=e[t].unit;if(s.length<=16)return;const n=s.subarray(16,s.length-s.length%16),a=n.buffer.slice(n.byteOffset,n.byteOffset+n.length);this.decryptBuffer(a).then(o=>{const l=new Uint8Array(o);s.set(l,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,i)}).catch(i)}decryptAacSamples(e,t,i){for(;;t++){if(t>=e.length){i();return}if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,i),!this.decrypter.isSync()))return}}getAvcEncryptedData(e){const t=Math.floor((e.length-48)/160)*16+16,i=new Int8Array(t);let s=0;for(let n=32;n<e.length-16;n+=160,s+=16)i.set(e.subarray(n,n+16),s);return i}getAvcDecryptedUnit(e,t){const i=new Uint8Array(t);let s=0;for(let n=32;n<e.length-16;n+=160,s+=16)e.set(i.subarray(s,s+16),n);return e}decryptAvcSample(e,t,i,s,n){const a=go(n.data),o=this.getAvcEncryptedData(a);this.decryptBuffer(o.buffer).then(l=>{n.data=this.getAvcDecryptedUnit(a,l),this.decrypter.isSync()||this.decryptAvcSamples(e,t,i+1,s)}).catch(s)}decryptAvcSamples(e,t,i,s){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,i=0){if(t>=e.length){s();return}const n=e[t].units;for(;!(i>=n.length);i++){const a=n[i];if(!(a.data.length<=48||a.type!==1&&a.type!==5)&&(this.decryptAvcSample(e,t,i,s,a),!this.decrypter.isSync()))return}}}}class Tf extends br{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.sampleAes=null,this.observer=e,this.config=t}resetInitSegment(e,t,i,s){super.resetInitSegment(e,t,i,s),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}static probe(e,t){if(!e)return!1;const i=ds(e,0);let s=i?.length||0;if(Ol(e,s))return!1;for(let n=e.length;s<n;s++)if(pf(e,s))return t.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return gf(e,t)}appendFrame(e,t,i){Dl(e,this.observer,t,i,e.manifestCodec);const s=_l(e,t,i,this.basePTS,this.frameIndex);if(s?.missing===0)return s}demuxSampleAes(e,t,i){const s=this.demux(e,i),n=this.sampleAes=new Fl(this.observer,this.config,t);return new Promise(a=>{n.decryptAacSamples(s.audioTrack.samples,0,()=>{a(s)})})}}const Nl=(r,e)=>{let t=0,i=5;e+=i;const s=new Uint32Array(1),n=new Uint32Array(1),a=new Uint8Array(1);for(;i>0;){a[0]=r[e];const o=Math.min(i,8),l=8-o;n[0]=4278190080>>>24+l<<l,s[0]=(a[0]&n[0])>>l,t=t?t<<o|s[0]:s[0],e+=1,i-=o}return t};class Sf extends br{constructor(e){super(),this.observer=void 0,this.observer=e}resetInitSegment(e,t,i,s){super.resetInitSegment(e,t,i,s),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}canParse(e,t){return t+64<e.length}appendFrame(e,t,i){const s=Bl(e,t,i,this.basePTS,this.frameIndex);if(s!==-1)return{sample:e.samples[e.samples.length-1],length:s,missing:0}}static probe(e){if(!e)return!1;const t=ds(e,0);if(!t)return!1;const i=t.length;if(e[i]===11&&e[i+1]===119&&Qn(t)!==void 0){if(Nl(e,i)<16)return!0;throw new Error("Containerless ec-3 is not supported")}return!1}}function Bl(r,e,t,i,s){if(t+8>e.length||e[t]!==11||e[t+1]!==119)return-1;const n=e[t+4]>>6;if(n>=3)return-1;const o=[48e3,44100,32e3][n],l=e[t+4]&63,h=[64,69,96,64,70,96,80,87,120,80,88,120,96,104,144,96,105,144,112,121,168,112,122,168,128,139,192,128,140,192,160,174,240,160,175,240,192,208,288,192,209,288,224,243,336,224,244,336,256,278,384,256,279,384,320,348,480,320,349,480,384,417,576,384,418,576,448,487,672,448,488,672,512,557,768,512,558,768,640,696,960,640,697,960,768,835,1152,768,836,1152,896,975,1344,896,976,1344,1024,1114,1536,1024,1115,1536,1152,1253,1728,1152,1254,1728,1280,1393,1920,1280,1394,1920][l*3+n]*2;if(t+h>e.length)return-1;const d=e[t+6]>>5;let g=0;d===2?g+=2:(d&1&&d!==1&&(g+=2),d&4&&(g+=2));const m=(e[t+6]<<8|e[t+7])>>12-g&1,C=[2,1,2,3,3,4,4,5][d]+m,v=e[t+5]>>3,S=e[t+5]&7,R=new Uint8Array([n<<6|v<<1|S>>2,(S&3)<<6|d<<3|m<<2|l>>4,l<<4&224]),b=1536/o*9e4,D=i+s*b,_=e.subarray(t,t+h);return r.config=R,r.channelCount=C,r.samplerate=o,r.samples.push({unit:_,pts:D}),h}class xf extends br{resetInitSegment(e,t,i,s){super.resetInitSegment(e,t,i,s),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;const t=ds(e,0);let i=t?.length||0;if(t&&e[i]===11&&e[i+1]===119&&Qn(t)!==void 0&&Nl(e,i)<=16)return!1;for(let s=e.length;i<s;i++)if(Ol(e,i))return Ge.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return Ef(e,t)}appendFrame(e,t,i){if(this.basePTS!==null)return kl(e,t,i,this.basePTS,this.frameIndex)}}const bf=/\/emsg[-/]ID3/i;class Lf{constructor(e,t,i,s=Ge){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.initData=void 0,this.logger=void 0,this.config=t,this.logger=s}resetTimeStamp(){}resetInitSegment(e,t,i,s){const n=this.videoTrack=ri("video",1),a=this.audioTrack=ri("audio",1),o=this.txtTrack=ri("text",1);if(this.id3Track=ri("id3",1),this.initData=void 0,this.timeOffset=0,!(e!=null&&e.byteLength))return;const l=this.initData=oo(e);if(l.video){const{id:u,timescale:h,codec:d,supplemental:g}=l.video;n.id=u,n.timescale=o.timescale=h,n.codec=d,n.supplemental=g}if(l.audio){const{id:u,timescale:h,codec:d}=l.audio;a.id=u,a.timescale=h,a.codec=d}o.id=to.text,n.sampleDuration=0,n.duration=a.duration=s}resetContiguity(){this.remainderData=null}static probe(e){return Ph(e,"moof")}demux(e,t,i){this.timeOffset=t;let s=e;const n=this.videoTrack,a=this.txtTrack;if(this.config.progressive){this.remainderData&&(s=Ut(this.remainderData,e));const u=$h(s);this.remainderData=u.remainder,n.samples=u.valid||new Uint8Array}else n.samples=s;const o=this.extractID3Track(n,t),l=this.parseFragment(n,a,t,i);return{videoTrack:n,audioTrack:this.audioTrack,id3Track:o,textTrack:this.txtTrack,initData:this.initData,sampleData:l}}flush(e,t){const i=this.timeOffset,s=this.videoTrack,n=this.txtTrack;s.samples=this.remainderData||new Uint8Array,this.remainderData=null;const a=this.extractID3Track(s,this.timeOffset),o=this.parseFragment(s,n,i,t);return{videoTrack:s,audioTrack:ri(),id3Track:a,textTrack:ri(),initData:this.initData,sampleData:o}}parseFragment(e,t,i,s){const n=this.initData;if(n&&s){const{samples:a,sampleData:o}=Uh(i,e,n,this.logger,s.iframe);return t.samples=a,o}t.samples=Gh(i,e)}extractID3Track(e,t){const i=this.id3Track;if(e.samples.length){const s=xe(e.samples,["emsg"]);s&&s.forEach(n=>{const a=Hh(n);if(bf.test(a.schemeIdUri)){const o=Ul(a,t);let l=a.eventDuration===4294967295?Number.POSITIVE_INFINITY:a.eventDuration/a.timeScale;l<=.001&&(l=Number.POSITIVE_INFINITY);const u=a.payload;i.samples.push({data:u,len:u.byteLength,dts:o,pts:o,type:Et.emsg,duration:l})}else if(this.config.enableEmsgKLVMetadata){const o=this.config.emsgKLVSchemaUri||Et.misbklv;if(a.schemeIdUri.startsWith(o)){const l=Ul(a,t);i.samples.push({data:a.payload,len:a.payload.byteLength,dts:l,pts:l,type:Et.misbklv,duration:Number.POSITIVE_INFINITY})}}})}return i}demuxSampleAes(e,t,i){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){this.config=null,this.remainderData=null,this.videoTrack=this.audioTrack=this.id3Track=this.txtTrack=void 0,this.initData=void 0}}function Ul(r,e){return se(r.presentationTime)?r.presentationTime/r.timeScale:e+r.presentationTimeDelta/r.timeScale}const Rf=1,Df=2,Ss=-1;class $l{constructor(){this.VideoSample=null}createVideoSample(e,t,i){return{key:e,frame:!1,pts:t,dts:i,units:[],length:0}}getLastNalUnit(e){var t;let i=this.VideoSample,s;if((!i||i.units.length===0)&&(i=e[e.length-1]),(t=i)!=null&&t.units){const n=i.units;s=n[n.length-1]}return s}pushAccessUnit(e,t){if(e.units.length&&e.frame){if(e.pts===void 0){const i=t.samples,s=i.length;if(s){const n=i[s-1];e.pts=n.pts,e.dts=n.dts}else{t.dropped++;return}}t.samples.push(e)}}parseNALu(e,t,i){const s=t.byteLength;if(s===0)return[];const n=e.naluState||0,a=n===Ss?0:n,o=[];let l=0,u=0,h=-1,d=0;for(n===Ss&&(h=0,d=this.getNALuType(t,0),u=1);u<s;){const g=t.indexOf(Rf,u);if(g===-1)break;u=g+1;let m=g;for(;m>0&&t[m-1]===0;)m--;if(!(g-m+(m===0?a:0)<Df)){if(h>=0)o.push({data:t.subarray(h,m),type:d});else{const C=this.getLastNalUnit(e.samples);C&&(m>0?C.data=Ut(C.data,t.subarray(0,m)):a>0&&(C.data=C.data.subarray(0,C.data.byteLength-a)),C.state=0)}if(u<s)h=u,d=this.getNALuType(t,u);else{l=Ss,h=-1;break}}}if(l!==Ss){let g=s;for(;g>0&&t[g-1]===0;)g--;l=s-g+(g===0?a:0)}if(h>=0)o.push({data:t.subarray(h),type:d,state:l});else if(o.length===0&&l!==Ss){const g=this.getLastNalUnit(e.samples);g&&(g.data=Ut(g.data,t),g.state=l)}return e.naluState=l,o}}class xs{constructor(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){const e=this.data,t=this.bytesAvailable,i=e.byteLength-t,s=new Uint8Array(4),n=Math.min(4,t);if(n===0)throw new Error("no bytes available");s.set(e.subarray(i,i+n)),this.word=new DataView(s.buffer).getUint32(0),this.bitsAvailable=n*8,this.bytesAvailable-=n}skipBits(e){let t;e=Math.min(e,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,t=e>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}readBits(e){let t=Math.min(this.bitsAvailable,e);const i=this.word>>>32-t;if(e>32&&Ge.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return t=e-t,t>0&&this.bitsAvailable?i<<t|this.readBits(t):i}skipLZ(){let e;for(e=0;e<this.bitsAvailable;++e)if((this.word&2147483648>>>e)!==0)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){const e=this.skipLZ();return this.readBits(e+1)-1}readEG(){const e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}readBoolean(){return this.readBits(1)===1}readUByte(){return this.readBits(8)}}class Pf extends $l{parsePES(e,t,i,s,n){const a=n.iframe,o=this.parseNALu(e,i.data,s);let l=this.VideoSample,u,h=!1;i.data=null,l&&o.length&&!e.audFound&&(this.pushAccessUnit(l,e),l=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),o.forEach(d=>{var g,m;switch(d.type){case 1:{if(a)break;let S=!1;u=!0;const R=d.data;if(h&&R.length>4){const b=this.readSliceType(R);(b===2||b===4||b===7||b===9)&&(S=!0)}if(S){var A;(A=l)!=null&&A.frame&&!l.key&&(this.pushAccessUnit(l,e),l=this.VideoSample=null)}l||(l=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),l.frame=!0,l.key=S;break}case 5:u=!0,(g=l)!=null&&g.frame&&!l.key&&(this.pushAccessUnit(l,e),l=this.VideoSample=null),l||(l=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),l.key=!0,l.frame=!0;break;case 6:{if(a)break;u=!0,gs(d.data,1,i.pts,t.samples);break}case 7:{var C,v;u=!0,h=!0;const S=d.data,R=this.readSPS(S);if(!e.sps||e.width!==R.width||e.height!==R.height||((C=e.pixelRatio)==null?void 0:C[0])!==R.pixelRatio[0]||((v=e.pixelRatio)==null?void 0:v[1])!==R.pixelRatio[1]){e.width=R.width,e.height=R.height,e.pixelRatio=R.pixelRatio,e.sps=[S];const b=S.subarray(1,4);let D="avc1.";for(let _=0;_<3;_++){let M=b[_].toString(16);M.length<2&&(M="0"+M),D+=M}e.codec=D}break}case 8:u=!0,e.pps=[d.data];break;case 9:u=!0,e.audFound=!0,(m=l)!=null&&m.frame&&(this.pushAccessUnit(l,e),l=null),l||(l=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts));break;case 12:u=!0;break;default:u=!1;break}l&&u&&l.units.push(d)}),s&&l&&(this.pushAccessUnit(l,e),this.VideoSample=null)}getNALuType(e,t){return e[t]&31}readSliceType(e){const t=new xs(e);return t.readUByte(),t.readUEG(),t.readUEG()}skipScalingList(e,t){let i=8,s=8,n;for(let a=0;a<e;a++)s!==0&&(n=t.readEG(),s=(i+n+256)%256),i=s===0?i:s}readSPS(e){const t=new xs(e);let i=0,s=0,n=0,a=0,o,l,u;const h=t.readUByte.bind(t),d=t.readBits.bind(t),g=t.readUEG.bind(t),m=t.readBoolean.bind(t),A=t.skipBits.bind(t),C=t.skipEG.bind(t),v=t.skipUEG.bind(t),S=this.skipScalingList.bind(this);h();const R=h();if(d(5),A(3),h(),v(),R===100||R===110||R===122||R===244||R===44||R===83||R===86||R===118||R===128){const $=g();if($===3&&A(1),v(),v(),A(1),m())for(l=$!==3?8:12,u=0;u<l;u++)m()&&(u<6?S(16,t):S(64,t))}v();const b=g();if(b===0)g();else if(b===1)for(A(1),C(),C(),o=g(),u=0;u<o;u++)C();v(),A(1);const D=g(),_=g(),M=d(1);M===0&&A(1),A(1),m()&&(i=g(),s=g(),n=g(),a=g());let p=[1,1];if(m()&&m())switch(h()){case 1:p=[1,1];break;case 2:p=[12,11];break;case 3:p=[10,11];break;case 4:p=[16,11];break;case 5:p=[40,33];break;case 6:p=[24,11];break;case 7:p=[20,11];break;case 8:p=[32,11];break;case 9:p=[80,33];break;case 10:p=[18,11];break;case 11:p=[15,11];break;case 12:p=[64,33];break;case 13:p=[160,99];break;case 14:p=[4,3];break;case 15:p=[3,2];break;case 16:p=[2,1];break;case 255:{p=[h()<<8|h(),h()<<8|h()];break}}return{width:Math.ceil((D+1)*16-i*2-s*2),height:(2-M)*(_+1)*16-(M?2:4)*(n+a),pixelRatio:p}}}class _f extends $l{constructor(...e){super(...e),this.initVPS=null}parsePES(e,t,i,s){const n=this.parseNALu(e,i.data,s);let a=this.VideoSample,o,l=!1;i.data=null;const u=h=>(a=this.VideoSample=this.createVideoSample(h,i.pts,i.dts),a);n.forEach((h,d)=>{var g,m;if(this.startsNewAccessUnit(a,e,h,d)){this.pushAccessUnit(a,e);const C=h.type>=16&&h.type<=23;a=u(C),l=!1}switch(h.type){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:a||(a=u(!1)),a.frame=!0,o=!0;break;case 16:case 17:case 18:case 21:case 22:case 23:if(o=!0,l){var A;(A=a)!=null&&A.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null)}a||(a=u(!0)),a.key=!0,a.frame=!0;break;case 19:case 20:o=!0,(g=a)!=null&&g.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null),a||(a=u(!0)),a.key=!0,a.frame=!0;break;case 39:o=!0,gs(h.data,2,i.pts,t.samples);break;case 32:o=!0,e.vps||(typeof e.params!="object"&&(e.params={}),e.params=je(e.params,this.readVPS(h.data)),this.initVPS=h.data),e.vps=[h.data];break;case 33:if(o=!0,l=!0,e.vps!==void 0&&e.vps[0]!==this.initVPS&&e.sps!==void 0&&!this.matchSPS(e.sps[0],h.data)&&(this.initVPS=e.vps[0],e.sps=e.pps=void 0),!e.sps){const C=this.readSPS(h.data);e.width=C.width,e.height=C.height,e.pixelRatio=C.pixelRatio,e.codec=C.codecString,e.sps=[],typeof e.params!="object"&&(e.params={});for(const v in C.params)e.params[v]=C.params[v]}this.pushParameterSet(e.sps,h.data,e.vps),a||(a=u(!1));break;case 34:if(o=!0,typeof e.params=="object"){if(!e.pps){e.pps=[];const C=this.readPPS(h.data);for(const v in C)e.params[v]=C[v]}this.pushParameterSet(e.pps,h.data,e.vps)}break;case 35:o=!0,e.audFound=!0,(m=a)!=null&&m.frame&&(this.pushAccessUnit(a,e),a=null),a||(a=u(!1));break;default:o=!1;break}a&&o&&a.units.push(h)}),s&&a&&(this.pushAccessUnit(a,e),this.VideoSample=null)}pushParameterSet(e,t,i){(i&&i[0]===this.initVPS||!i&&!e.length)&&e.push(t)}startsNewAccessUnit(e,t,i,s){if(!e)return!1;if(!t.audFound&&s===0)return!0;if(!e.frame)return!1;const{type:n,data:a}=i;return n>=32&&n<=35||n===39||n>=41&&n<=44||n>=48&&n<=55?!0:n<=31&&a.length>2&&(a[2]&128)!==0}getNALuType(e,t){return(e[t]&126)>>>1}ebsp2rbsp(e){const t=new Uint8Array(e.byteLength);let i=0;for(let s=0;s<e.byteLength;s++)s>=2&&e[s]===3&&e[s-1]===0&&e[s-2]===0||(t[i]=e[s],i++);return new Uint8Array(t.buffer,0,i)}pushAccessUnit(e,t){super.pushAccessUnit(e,t),this.initVPS&&(this.initVPS=null)}readVPS(e){const t=new xs(e);t.readUByte(),t.readUByte(),t.readBits(4),t.skipBits(2),t.readBits(6);const i=t.readBits(3),s=t.readBoolean();return{numTemporalLayers:i+1,temporalIdNested:s}}readSPS(e){const t=new xs(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.readBits(4);const i=t.readBits(3);t.readBoolean();const s=t.readBits(2),n=t.readBoolean(),a=t.readBits(5),o=t.readUByte(),l=t.readUByte(),u=t.readUByte(),h=t.readUByte(),d=t.readUByte(),g=t.readUByte(),m=t.readUByte(),A=t.readUByte(),C=t.readUByte(),v=t.readUByte(),S=t.readUByte(),R=[],b=[];for(let pe=0;pe<i;pe++)R.push(t.readBoolean()),b.push(t.readBoolean());if(i>0)for(let pe=i;pe<8;pe++)t.readBits(2);for(let pe=0;pe<i;pe++)R[pe]&&(t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte()),b[pe]&&t.readUByte();t.readUEG();const D=t.readUEG();D==3&&t.skipBits(1);const _=t.readUEG(),M=t.readUEG(),p=t.readBoolean();let $=0,N=0,O=0,W=0;p&&($+=t.readUEG(),N+=t.readUEG(),O+=t.readUEG(),W+=t.readUEG());const q=t.readUEG(),z=t.readUEG(),oe=t.readUEG(),ne=t.readBoolean();for(let pe=ne?0:i;pe<=i;pe++)t.skipUEG(),t.skipUEG(),t.skipUEG();if(t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.readBoolean()&&t.readBoolean())for(let we=0;we<4;we++)for(let Re=0;Re<(we===3?2:6);Re++)if(!t.readBoolean())t.readUEG();else{const it=Math.min(64,1<<4+(we<<1));we>1&&t.readEG();for(let At=0;At<it;At++)t.readEG()}t.readBoolean(),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.skipUEG(),t.skipUEG(),t.readBoolean());const Q=t.readUEG();let ee=0;for(let pe=0;pe<Q;pe++){let we=!1;if(pe!==0&&(we=t.readBoolean()),we){pe===Q&&t.readUEG(),t.readBoolean(),t.readUEG();let Re=0;for(let rt=0;rt<=ee;rt++){const it=t.readBoolean();let At=!1;it||(At=t.readBoolean()),(it||At)&&Re++}ee=Re}else{const Re=t.readUEG(),rt=t.readUEG();ee=Re+rt;for(let it=0;it<Re;it++)t.readUEG(),t.readBoolean();for(let it=0;it<rt;it++)t.readUEG(),t.readBoolean()}}if(t.readBoolean()){const pe=t.readUEG();for(let we=0;we<pe;we++){for(let Re=0;Re<oe+4;Re++)t.readBits(1);t.readBits(1)}}let te=0,re=1,Ee=1,Ie=!0,_e=1,ye=0;t.readBoolean(),t.readBoolean();let Oe=!1;if(t.readBoolean()){if(t.readBoolean()){const at=t.readUByte(),Bt=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2],nt=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1];at>0&&at<16?(re=Bt[at-1],Ee=nt[at-1]):at===255&&(re=t.readBits(16),Ee=t.readBits(16))}if(t.readBoolean()&&t.readBoolean(),t.readBoolean()&&(t.readBits(3),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.readUByte(),t.readUByte())),t.readBoolean()&&(t.readUEG(),t.readUEG()),t.readBoolean(),t.readBoolean(),t.readBoolean(),Oe=t.readBoolean(),Oe&&(t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG()),t.readBoolean()&&(_e=t.readBits(32),ye=t.readBits(32),t.readBoolean()&&t.readUEG(),t.readBoolean())){const nt=t.readBoolean(),ue=t.readBoolean();let Ze=!1;(nt||ue)&&(Ze=t.readBoolean(),Ze&&(t.readUByte(),t.readBits(5),t.readBoolean(),t.readBits(5)),t.readBits(4),t.readBits(4),Ze&&t.readBits(4),t.readBits(5),t.readBits(5),t.readBits(5));for(let xt=0;xt<=i;xt++){Ie=t.readBoolean();const ft=Ie||t.readBoolean();let li=!1;ft?t.readEG():li=t.readBoolean();const Gt=li?1:t.readUEG()+1;if(nt)for(let Dt=0;Dt<Gt;Dt++)t.readUEG(),t.readUEG(),Ze&&(t.readUEG(),t.readUEG()),t.skipBits(1);if(ue)for(let Dt=0;Dt<Gt;Dt++)t.readUEG(),t.readUEG(),Ze&&(t.readUEG(),t.readUEG()),t.skipBits(1)}}t.readBoolean()&&(t.readBoolean(),t.readBoolean(),t.readBoolean(),te=t.readUEG())}let Fe=_,Ye=M;if(p){let pe=1,we=1;D===1?pe=we=2:D==2&&(pe=2),Fe=_-pe*N-pe*$,Ye=M-we*W-we*O}const Ct=s?["A","B","C"][s]:"",yt=o<<24|l<<16|u<<8|h;let We=0;for(let pe=0;pe<32;pe++)We=(We|(yt>>pe&1)<<31-pe)>>>0;let St=We.toString(16);return a===1&&St==="2"&&(St="6"),{codecString:`hvc1.${Ct}${a}.${St}.${n?"H":"L"}${S}.B0`,params:{general_tier_flag:n,general_profile_idc:a,general_profile_space:s,general_profile_compatibility_flags:[o,l,u,h],general_constraint_indicator_flags:[d,g,m,A,C,v],general_level_idc:S,bit_depth:q+8,bit_depth_luma_minus8:q,bit_depth_chroma_minus8:z,min_spatial_segmentation_idc:te,chroma_format_idc:D,frame_rate:{fixed:Ie,fps:ye/_e}},width:Fe,height:Ye,pixelRatio:[re,Ee]}}readPPS(e){const t=new xs(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.skipUEG(),t.skipUEG(),t.skipBits(2),t.skipBits(3),t.skipBits(2),t.skipUEG(),t.skipUEG(),t.skipEG(),t.skipBits(2),t.readBoolean()&&t.skipUEG(),t.skipEG(),t.skipEG(),t.skipBits(4);const s=t.readBoolean(),n=t.readBoolean();let a=1;return n&&s?a=0:n?a=3:s&&(a=2),{parallelismType:a}}matchSPS(e,t){return Yt(e).substring(3)===Yt(t).substring(3)}}const ct=188;class mi{constructor(e,t,i,s){this.logger=void 0,this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this._klvPid=-1,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.videoIntegrityChecker=null,this.observer=e,this.config=t,this.typeSupported=i,this.logger=s,this.videoParser=null}static probe(e,t){const i=mi.syncOffset(e);return i>0&&t.warn(`MPEG2-TS detected but first sync word found @ offset ${i}`),i!==-1}static syncOffset(e){const t=e.length;let i=Math.min(ct*5,t-ct)+1,s=0;for(;s<i;){let n=!1,a=-1,o=0;for(let l=s;l<t;l+=ct)if(e[l]===71&&(t-l===ct||e[l+ct]===71)){if(o++,a===-1&&(a=l,a!==0&&(i=Math.min(a+ct*99,e.length-ct)+1)),n||(n=gn(e,l)===0),n&&o>1&&(a===0&&o>2||l+ct>i))return a}else{if(o)return-1;break}s++}return-1}static createTrack(e,t){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:to[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}}resetInitSegment(e,t,i,s,n,a){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=mi.createTrack("video"),this._videoTrack.duration=s,this.videoIntegrityChecker=this.config.handleMpegTsVideoIntegrityErrors==="skip"?new Mf(this.logger):null,this._audioTrack=mi.createTrack("audio",s),this._id3Track=mi.createTrack("id3"),this._txtTrack=mi.createTrack("text"),this._audioTrack.segmentCodec="aac",this.videoParser=null,this.aacOverFlow=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=i,e&&this.demux(e,0,a,n?.method==="SAMPLE-AES")}resetTimeStamp(){}resetContiguity(){const{_audioTrack:e,_videoTrack:t,_id3Track:i}=this;e&&(e.pesData=null),t&&(t.pesData=null),i&&(i.pesData=null),this.aacOverFlow=null,this.remainderData=null}demux(e,t,i,s=!1,n=!1){s||(this.sampleAes=null);let a;const o=this._videoTrack,l=this.videoIntegrityChecker,u=this._audioTrack,h=this._id3Track,d=this._txtTrack,g=i.iframe;let m=o.pid,A=o.pesData,C=u.pid,v=h.pid,S=this._klvPid,R=u.pesData,b=h.pesData,D=null,_=null,M=this.pmtParsed,p=this._pmtId,$=e.length;if(this.remainderData&&(e=Ut(this.remainderData,e),$=e.length,this.remainderData=null),$<ct&&!n)return this.remainderData=e,{audioTrack:u,videoTrack:o,id3Track:h,textTrack:d};const N=Math.max(0,mi.syncOffset(e));$-=($-N)%ct,$<e.byteLength&&!n&&(this.remainderData=new Uint8Array(e.buffer,$,e.buffer.byteLength-$));let O=0;for(let q=N;q<$;q+=ct)if(e[q]===71){const z=!!(e[q+1]&64),oe=gn(e,q),ne=(e[q+3]&48)>>4;let J;if(ne>1){if(J=q+5+e[q+4],J===q+ct)continue}else J=q+4;switch(oe){case m:z&&(A&&!(l!=null&&l.isCorrupted)&&(a=Oi(A,this.logger))&&(this.readyVideoParser(o.segmentCodec),this.videoParser!==null&&this.videoParser.parsePES(o,d,a,!1,i)),A={data:[],size:0},l?.reset(m)),l?.handlePacket(e.subarray(q)),A&&(A.data.push(e.subarray(J,q+ct)),A.size+=q+ct-J);break;case C:if(g)break;if(z){if(R&&(a=Oi(R,this.logger)))switch(u.segmentCodec){case"aac":this.parseAACPES(u,a,i);break;case"mp3":this.parseMPEGPES(u,a);break;case"ac3":this.parseAC3PES(u,a);break}R={data:[],size:0}}R&&(R.data.push(e.subarray(J,q+ct)),R.size+=q+ct-J);break;case v:if(g)break;z&&(b&&(a=Oi(b,this.logger))&&this.parseID3PES(h,a),b={data:[],size:0}),b&&(b.data.push(e.subarray(J,q+ct)),b.size+=q+ct-J);break;case S:if(g)break;z&&(D&&(a=Oi(D,this.logger))&&this.parseKlvPES(h,a),D={data:[],size:0}),D&&(D.data.push(e.subarray(J,q+ct)),D.size+=q+ct-J);break;case 0:z&&(J+=e[J]+1),p=this._pmtId=kf(e,J);break;case p:{z&&(J+=e[J]+1);const Z=wf(e,J,this.typeSupported,s,this.observer,this.logger,this.config,i);m=Z.videoPid,m>0&&(o.pid=m,o.segmentCodec=Z.segmentVideoCodec),C=Z.audioPid,C>0&&(u.pid=C,u.segmentCodec=Z.segmentAudioCodec),v=Z.id3Pid,v>0&&(h.pid=v),S=Z.klvPid,S>0&&(this._klvPid=S),_!==null&&!M&&(this.logger.warn(`MPEG-TS PMT found at ${q} after unknown PID '${_}'. Backtracking to sync byte @${N} to parse all TS packets.`),_=null,q=N-188),M=this.pmtParsed=!0;break}case 17:case 8191:break;default:_=oe;break}}else O++;O>0&&Rr(this.observer,new Error(`Found ${O} TS packet/s that do not start with 0x47`),i,void 0,this.logger),o.pesData=A,u.pesData=R,h.pesData=b;const W={audioTrack:u,videoTrack:o,id3Track:h,textTrack:d};return n&&this.extractRemainingSamples(W,i),W}flush(e,t){const{remainderData:i}=this;this.remainderData=null;let s;return i?s=this.demux(i,0,t,!1,!0):s={videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(s,t),this.sampleAes?this.decrypt(s,this.sampleAes):s}extractRemainingSamples(e,t){const{audioTrack:i,videoTrack:s,id3Track:n,textTrack:a}=e,o=s.pesData,l=i.pesData,u=n.pesData,h=this.videoIntegrityChecker;let d;if(o&&!(h!=null&&h.isCorrupted)&&(d=Oi(o,this.logger))?(this.readyVideoParser(s.segmentCodec),this.videoParser!==null&&(this.videoParser.parsePES(s,a,d,!0,t),s.pesData=null)):s.pesData=o,l&&(d=Oi(l,this.logger))){switch(i.segmentCodec){case"aac":this.parseAACPES(i,d,t);break;case"mp3":this.parseMPEGPES(i,d);break;case"ac3":this.parseAC3PES(i,d);break}i.pesData=null}else l!=null&&l.size&&this.logger.log("last AAC PES packet truncated,might overlap between fragments"),i.pesData=l;u&&(d=Oi(u,this.logger))?(this.parseID3PES(n,d),n.pesData=null):n.pesData=u}demuxSampleAes(e,t,i,s){const n=this.demux(e,i,s,!0,!this.config.progressive),a=this.sampleAes=new Fl(this.observer,this.config,t);return this.decrypt(n,a)}readyVideoParser(e){this.videoParser===null&&(e==="avc"?this.videoParser=new Pf:e==="hevc"&&(this.videoParser=new _f))}decrypt(e,t){return new Promise(i=>{const{audioTrack:s,videoTrack:n}=e;s.samples&&s.segmentCodec==="aac"?t.decryptAacSamples(s.samples,0,()=>{n.samples?t.decryptAvcSamples(n.samples,0,0,()=>{i(e)}):i(e)}):n.samples&&t.decryptAvcSamples(n.samples,0,0,()=>{i(e)})})}destroy(){this.observer&&this.observer.removeAllListeners(),this.config=this.logger=this.observer=null,this.aacOverFlow=this.videoParser=this.remainderData=this.sampleAes=null,this._videoTrack=this._audioTrack=this._id3Track=this._txtTrack=void 0,this.videoIntegrityChecker=null}parseAACPES(e,t,i){let s=0;const n=this.aacOverFlow;let a=t.data;if(n){this.aacOverFlow=null;const g=n.missing,m=n.sample.unit.byteLength;if(g===-1)a=Ut(n.sample.unit,a);else{const A=m-g;n.sample.unit.set(a.subarray(0,g),A),e.samples.push(n.sample),s=n.missing}}let o,l;for(o=s,l=a.length;o<l-1&&!fn(a,o);o++);if(o!==s){let g;const m=o<l-1;if(m?g=`AAC PES did not start with ADTS header,offset:${o}`:g="No ADTS header found in AAC PES",Rr(this.observer,new Error(g),i,m,this.logger),!m)return}Dl(e,this.observer,a,o,this.audioCodec);let u;if(t.pts!==void 0)u=t.pts;else if(n){const g=Pl(e.samplerate);u=n.sample.pts+g}else{this.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}let h=0,d;for(;o<l;)if(d=_l(e,a,o,u,h),o+=d.length,d.missing){this.aacOverFlow=d;break}else for(h++;o<l-1&&!fn(a,o);o++);}parseMPEGPES(e,t){const i=t.data,s=i.length;let n=0,a=0;const o=t.pts;if(o===void 0){this.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<s;)if(Ml(i,a)){const l=kl(e,i,a,o,n);if(l)a+=l.length,n++;else break}else a++}parseAC3PES(e,t){{const i=t.data,s=t.pts;if(s===void 0){this.logger.warn("[tsdemuxer]: AC3 PES unknown PTS");return}const n=i.length;let a=0,o=0,l;for(;o<n&&(l=Bl(e,i,o,s,a++))>0;)o+=l}}parseID3PES(e,t){if(t.pts===void 0){this.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}const i=je({},t,{type:this._videoTrack?Et.emsg:Et.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(i)}parseKlvPES(e,t){var i;const s=(i=t.pts)!=null?i:t.dts;if(s===void 0){this.logger.warn("[tsdemuxer]: KLV PES unknown PTS and DTS");return}const n=t.data;if(n.length<16){this.logger.warn("[tsdemuxer]: KLV PES payload too short");return}let a=0;for(;a<n.length;){var o;if(a+16>n.length)break;const l=a;if(a+=16,a>=n.length)break;const u=n[a];a+=1;let h=0;if(u&128){const A=u&127;if(A===0||A>4||a+A>n.length){this.logger.warn("[tsdemuxer]: Invalid KLV length encoding");break}for(let C=0;C<A;C++)h=h<<8|n[a+C];a+=A}else h=u;if(a+h>n.length){this.logger.warn("[tsdemuxer]: KLV value extends beyond PES payload");break}const d=a+h,g=n.subarray(l,d),m={data:g,len:g.byteLength,pts:s,dts:(o=t.dts)!=null?o:s,type:Et.misbklv,duration:Number.POSITIVE_INFINITY};e.samples.push(m),a=d}}}function gn(r,e){return((r[e+1]&31)<<8)+r[e+2]}function kf(r,e){return(r[e+10]&31)<<8|r[e+11]}function wf(r,e,t,i,s,n,a,o){const l={audioPid:-1,videoPid:-1,id3Pid:-1,klvPid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},u=(r[e+1]&15)<<8|r[e+2],h=e+3+u-4,d=(r[e+10]&15)<<8|r[e+11];for(e+=12+d;e<h;){const g=gn(r,e),m=(r[e+3]&15)<<8|r[e+4];switch(r[e]){case 207:if(!i){Dr("ADTS AAC",n);break}case 15:l.audioPid===-1&&(l.audioPid=g);break;case 21:l.id3Pid===-1&&(l.id3Pid=g);break;case 219:if(!i){Dr("H.264",n);break}case 27:l.videoPid===-1&&(l.videoPid=g);break;case 3:case 4:!t.mpeg&&!t.mp3?n.log("MPEG audio found, not supported in this browser"):l.audioPid===-1&&(l.audioPid=g,l.segmentAudioCodec="mp3");break;case 193:if(!i){Dr("AC-3",n);break}case 129:t.ac3?l.audioPid===-1&&(l.audioPid=g,l.segmentAudioCodec="ac3"):n.log("AC-3 audio found, not supported in this browser");break;case 6:if(m>0){let A=e+5,C=m;for(;C>2;){switch(r[A]){case 106:l.audioPid===-1&&(t.ac3!==!0?n.log("AC-3 audio found, not supported in this browser for now"):(l.audioPid=g,l.segmentAudioCodec="ac3"));break;case 5:l.klvPid===-1&&a.enableEmsgKLVMetadata&&(l.klvPid=g,n.log(`KLV metadata PID found: ${g}`));break}const S=r[A+1]+2;A+=S,C-=S}}break;case 194:case 135:return Rr(s,new Error("Unsupported EC-3 in M2TS found"),o,void 0,n),l;case 36:l.videoPid===-1&&(l.videoPid=g,l.segmentVideoCodec="hevc",n.log("HEVC in M2TS found"));break}e+=m+5}return l}function Rr(r,e,t,i,s){s.warn(`parsing error: ${e.message}`),r.emit(E.ERROR,E.ERROR,{type:me.MEDIA_ERROR,details:U.FRAG_PARSING_ERROR,fatal:!1,levelRetry:i,chunkMeta:t,error:e,reason:e.message})}function Dr(r,e){e.log(`${r} with AES-128-CBC encryption found in unencrypted stream`)}function Oi(r,e){let t=0,i,s,n,a,o;const l=r.data;if(!r||r.size===0)return null;for(;l[0].length<19&&l.length>1;)l[0]=Ut(l[0],l[1]),l.splice(1,1);if(i=l[0],(i[0]<<16)+(i[1]<<8)+i[2]===1){if(s=(i[4]<<8)+i[5],s&&s>r.size-6)return null;const h=i[7];h&192&&(a=(i[9]&14)*536870912+(i[10]&255)*4194304+(i[11]&254)*16384+(i[12]&255)*128+(i[13]&254)/2,h&64?(o=(i[14]&14)*536870912+(i[15]&255)*4194304+(i[16]&254)*16384+(i[17]&255)*128+(i[18]&254)/2,a-o>60*9e4&&(e.warn(`${Math.round((a-o)/9e4)}s delta between PTS and DTS, align them`),a=o)):o=a),n=i[8];let d=n+9;if(r.size<=d)return null;r.size-=d;const g=new Uint8Array(r.size);for(let m=0,A=l.length;m<A;m++){i=l[m];let C=i.byteLength;if(d)if(d>C){d-=C;continue}else i=i.subarray(d),C-=d,d=0;g.set(i,t),t+=C}return s&&(s-=n+3),{data:g,pts:a,dts:o,len:s}}return null}class Mf{constructor(e){this.logger=void 0,this.pid=0,this.lastContinuityCounter=-1,this.integrityState="ok",this.logger=e}get isCorrupted(){return this.integrityState!=="ok"}reset(e){this.pid=e,this.lastContinuityCounter=-1,this.integrityState="ok"}handlePacket(e){if(e.byteLength<4)return;const t=gn(e,0);if(t!==this.pid){this.logger.debug(`Packet PID mismatch, expected ${this.pid} got ${t}`);return}const i=(e[3]&48)>>4;if(i===0)return;const s=e[3]&15,n=this.lastContinuityCounter;this.lastContinuityCounter=s;const a=(i&1)!=0;if((i&2)!=0&&e[4]!=0&&(e[5]&128)!=0||n<0)return;const u=a?n+1&15:n;if(s!==u){this.logger.warn(`MPEG-TS Continuity Counter check failed for PID='${t}', CC=${s}, Expected-CC=${u} Last-CC=${n}`),this.integrityState="cc-failed";return}if((e[1]&128)!==0){this.logger.warn(`MPEG-TS Packet had TEI flag set for PID='${t}'`),this.integrityState="tei-bit";return}}}class Of{static getSilentFrame(e,t){switch(e){case"mp4a.40.2":if(t===1)return new Uint8Array([0,200,0,128,35,128]);if(t===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(t===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(t===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(t===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(t===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(t===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}}}var pn;const Ff={video:new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),audio:new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0])},Pr=new Uint8Array([0,0,0,0,0,0,0,0]),Nf=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),Bf=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),Uf=new Uint8Array([0,0,0,0,0,0,0,0]),bs=new Uint8Array([0,0,0,0,0,0,0,1]),Gl=new Uint8Array([105,115,111,109]),$f=new Uint8Array([97,118,99,49]),Gf=new Uint8Array([0,0,0,1]);class le{static box(e,...t){let i=8,s=t.length;const n=s;for(;s--;)i+=t[s].byteLength;const a=new Uint8Array(i);for(lt(a,0,i),lt(a,4,e),s=0,i=8;s<n;s++)a.set(t[s],i),i+=t[s].byteLength;return a}static hdlr(e){return le.box(Te.hdlr,Ff[e])}static mdat(e){return le.box(Te.mdat,e)}static mdhd(e,t){t*=e;const i=Math.floor(t/(Jt+1)),s=Math.floor(t%(Jt+1));return le.box(Te.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,i>>24,i>>16&255,i>>8&255,i&255,s>>24,s>>16&255,s>>8&255,s&255,85,196,0,0]))}static mdia(e){return le.box(Te.mdia,le.mdhd(e.timescale||0,e.duration||0),le.hdlr(e.type),le.minf(e))}static mfhd(e){return le.box(Te.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255]))}static minf(e){return e.type==="audio"?le.box(Te.minf,le.box(Te.smhd,Uf),le.DINF,le.stbl(e)):le.box(Te.minf,le.box(Te.vmhd,Bf),le.DINF,le.stbl(e))}static moof(e,t,i){return le.box(Te.moof,le.mfhd(e),le.traf(i,t))}static moov(e){let t=e.length;const i=[];for(;t--;)i[t]=le.trak(e[t]);return le.box.apply(null,[Te.moov,le.mvhd(e[0].timescale||0,e[0].duration||0)].concat(i).concat(le.mvex(e)))}static mvex(e){let t=e.length;const i=[];for(;t--;)i[t]=le.trex(e[t]);return le.box.apply(null,[Te.mvex,...i])}static mvhd(e,t){t*=e;const i=Math.floor(t/(Jt+1)),s=Math.floor(t%(Jt+1)),n=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,i>>24,i>>16&255,i>>8&255,i&255,s>>24,s>>16&255,s>>8&255,s&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return le.box(Te.mvhd,n)}static sdtp(e){const t=e.samples||[],i=new Uint8Array(4+t.length);let s,n;for(s=0;s<t.length;s++)n=t[s].flags,i[s+4]=n.dependsOn<<4|n.isDependedOn<<2|n.hasRedundancy;return le.box(Te.sdtp,i)}static stbl(e){return le.box(Te.stbl,le.stsd(e),le.box(Te.stts,Pr),le.box(Te.stsc,Pr),le.box(Te.stsz,Nf),le.box(Te.stco,Pr))}static avc1(e){let t=[],i=[],s,n,a;for(s=0;s<e.sps.length;s++)n=e.sps[s],a=n.byteLength,t.push(a>>>8&255),t.push(a&255),t=t.concat(Array.prototype.slice.call(n));for(s=0;s<e.pps.length;s++)n=e.pps[s],a=n.byteLength,i.push(a>>>8&255),i.push(a&255),i=i.concat(Array.prototype.slice.call(n));const o=le.box(Te.avcC,new Uint8Array([1,t[3],t[4],t[5],255,224|e.sps.length].concat(t).concat([e.pps.length]).concat(i))),l=e.width,u=e.height,h=e.pixelRatio[0],d=e.pixelRatio[1];return le.box(Te.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,l>>8&255,l&255,u>>8&255,u&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,le.box(Te.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),le.box(Te.pasp,new Uint8Array([h>>24,h>>16&255,h>>8&255,h&255,d>>24,d>>16&255,d>>8&255,d&255])))}static esds(e){const t=e.config,i=t.length;return new Uint8Array([0,0,0,0,3,23+i,0,1,0,4,15+i,64,21,0,0,0,0,0,0,0,0,0,0,0,5,i,...t,6,1,2])}static audioStsd(e){const t=e.samplerate||0;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount||0,0,16,0,0,0,0,t>>8&255,t&255,0,0])}static mp4a(e){return le.box(Te.mp4a,le.audioStsd(e),le.box(Te.esds,le.esds(e)))}static mp3(e){return le.box(Te[".mp3"],le.audioStsd(e))}static ac3(e){return le.box(Te["ac-3"],le.audioStsd(e),le.box(Te.dac3,e.config))}static stsd(e){const{segmentCodec:t}=e;if(e.type==="audio"){if(t==="aac")return le.box(Te.stsd,bs,le.mp4a(e));if(t==="ac3"&&e.config)return le.box(Te.stsd,bs,le.ac3(e));if(t==="mp3"&&e.codec==="mp3")return le.box(Te.stsd,bs,le.mp3(e))}else if(e.pps&&e.sps){if(t==="avc")return le.box(Te.stsd,bs,le.avc1(e));if(t==="hevc"&&e.vps)return le.box(Te.stsd,bs,le.hvc1(e))}else throw new Error("video track missing pps or sps");throw new Error(`unsupported ${e.type} segment codec (${t}/${e.codec})`)}static tkhd(e){const t=e.id,i=(e.duration||0)*(e.timescale||0),s=e.width||0,n=e.height||0,a=Math.floor(i/(Jt+1)),o=Math.floor(i%(Jt+1));return le.box(Te.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,t&255,0,0,0,0,a>>24,a>>16&255,a>>8&255,a&255,o>>24,o>>16&255,o>>8&255,o&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,s>>8&255,s&255,0,0,n>>8&255,n&255,0,0]))}static traf(e,t){const i=le.sdtp(e),s=e.id,n=Math.floor(t/(Jt+1)),a=Math.floor(t%(Jt+1));return le.box(Te.traf,le.box(Te.tfhd,new Uint8Array([0,0,0,0,s>>24,s>>16&255,s>>8&255,s&255])),le.box(Te.tfdt,new Uint8Array([1,0,0,0,n>>24,n>>16&255,n>>8&255,n&255,a>>24,a>>16&255,a>>8&255,a&255])),le.trun(e,i.length+16+20+8+16+8+8),i)}static trak(e){return e.duration=e.duration||4294967295,le.box(Te.trak,le.tkhd(e),le.mdia(e))}static trex(e){const t=e.id;return le.box(Te.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,t){const i=e.samples||[],s=i.length,n=12+16*s,a=new Uint8Array(n);let o,l,u,h,d,g;for(t+=8+n,a.set([e.type==="video"?1:0,0,15,1,s>>>24&255,s>>>16&255,s>>>8&255,s&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255],0),o=0;o<s;o++)l=i[o],u=l.duration,h=l.size,d=l.flags,g=l.cts,a.set([u>>>24&255,u>>>16&255,u>>>8&255,u&255,h>>>24&255,h>>>16&255,h>>>8&255,h&255,d.isLeading<<2|d.dependsOn,d.isDependedOn<<6|d.hasRedundancy<<4|d.paddingValue<<1|d.isNonSync,d.degradPrio&61440,d.degradPrio&15,g>>>24&255,g>>>16&255,g>>>8&255,g&255],12+16*o);return le.box(Te.trun,a)}static initSegment(e){const t=le.moov(e);return Ut(le.FTYP,t)}static hvc1(e){const t=e.params,i=[e.vps,e.sps,e.pps],s=4,n=new Uint8Array([1,t.general_profile_space<<6|(t.general_tier_flag?32:0)|t.general_profile_idc,t.general_profile_compatibility_flags[0],t.general_profile_compatibility_flags[1],t.general_profile_compatibility_flags[2],t.general_profile_compatibility_flags[3],t.general_constraint_indicator_flags[0],t.general_constraint_indicator_flags[1],t.general_constraint_indicator_flags[2],t.general_constraint_indicator_flags[3],t.general_constraint_indicator_flags[4],t.general_constraint_indicator_flags[5],t.general_level_idc,240|t.min_spatial_segmentation_idc>>8,255&t.min_spatial_segmentation_idc,252|t.parallelismType,252|t.chroma_format_idc,248|t.bit_depth_luma_minus8,248|t.bit_depth_chroma_minus8,0,parseInt(t.frame_rate.fps),s-1|t.temporal_id_nested<<2|t.num_temporal_layers<<3|(t.frame_rate.fixed?64:0),i.length]);let a=n.length;for(let A=0;A<i.length;A+=1){a+=3;for(let C=0;C<i[A].length;C+=1)a+=2+i[A][C].length}const o=new Uint8Array(a);o.set(n,0),a=n.length;const l=i.length-1;for(let A=0;A<i.length;A+=1){o.set(new Uint8Array([32+A|(A===l?128:0),0,i[A].length]),a),a+=3;for(let C=0;C<i[A].length;C+=1)o.set(new Uint8Array([i[A][C].length>>8,i[A][C].length&255]),a),a+=2,o.set(i[A][C],a),a+=i[A][C].length}const u=le.box(Te.hvcC,o),h=e.width,d=e.height,g=e.pixelRatio[0],m=e.pixelRatio[1];return le.box(Te.hvc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,h>>8&255,h&255,d>>8&255,d&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),u,le.box(Te.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),le.box(Te.pasp,new Uint8Array([g>>24,g>>16&255,g>>8&255,g&255,m>>24,m>>16&255,m>>8&255,m&255])))}}pn=le,le.FTYP=pn.box(Te.ftyp,Gl,Gf,Gl,$f),le.DINF=pn.box(Te.dinf,pn.box(Te.dref,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1])));const Hl=9e4;function _r(r,e,t=1,i=!1){const s=r*e*t;return i?Math.round(s):s}function Hf(r,e,t=1,i=!1){return _r(r,e,1/t,i)}function Ls(r,e=!1){return _r(r,1e3,1/Hl,e)}function Vf(r,e=1){return _r(r,Hl,1/e)}function Vl(r){const{baseTime:e,timescale:t,trackId:i}=r;return`${e/t} (${e}/${t}) trackId: ${i}`}const Kf=10*1e3,Yf=1024,Wf=1152,jf=1536,kr=8589934592;function Kl(r,e,t,i){return{duration:e,size:t,cts:i,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:r?2:1,isNonSync:r?0:1,paddingValue:0}}}class mn extends wt{constructor(e,t,i,s){super("mp4-remuxer",s),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextVideoTs=null,this.nextAudioTs=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=e,this.config=t,this.typeSupported=i,this.ISGenerated=!1}destroy(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}resetTimeStamp(e){const t=this._initPTS;(!t||!e||e.trackId!==t.trackId||e.baseTime!==t.baseTime||e.timescale!==t.timescale)&&this.log(`Reset initPTS: ${t&&Vl(t)} > ${e&&Vl(e)}`),this._initPTS=this._initDTS=e}resetNextTimestamp(){this.log("reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){this.log("ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}getVideoStartPts(e){let t=!1;const i=e[0].pts,s=e.reduce((n,a)=>{let o=a.pts,l=o-n;return l<-4294967296&&(t=!0,o=Ot(o,i),l=o-n),l>0?n:o},i);return t&&this.debug("PTS rollover detected"),s}remux(e,t,i,s,n,a,o,l,u){let h,d,g,m,A,C,v=n,S=n;const b=!u.iframe&&e.pid>-1,D=t.pid>-1,_=t.samples.length,M=e.samples.length>0,p=o&&_>0||_>1;if((!b||M)&&(!D||p)||this.ISGenerated||o){if(this.ISGenerated){var N,O,W,q;const J=this.videoTrackConfig;(J&&(t.width!==J.width||t.height!==J.height||((N=t.pixelRatio)==null?void 0:N[0])!==((O=J.pixelRatio)==null?void 0:O[0])||((W=t.pixelRatio)==null?void 0:W[1])!==((q=J.pixelRatio)==null?void 0:q[1]))||!J&&p||this.nextAudioTs===null&&M)&&this.resetInitSegment()}this.ISGenerated||(g=this.generateIS(e,t,n,a));const z=this.isVideoContiguous;let oe=-1,ne;if(p&&(oe=qf(t.samples),!z&&this.config.forceKeyFrameOnDiscontinuity))if(C=!0,oe>0){this.warn(`Dropped ${oe} out of ${_} video samples due to a missing keyframe`);const J=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(oe),t.dropped+=oe,S+=(t.samples[0].pts-J)/t.inputTimeScale,ne=S}else oe===-1&&(this.warn(`No keyframe found out of ${_} video samples`),C=!1);if(this.ISGenerated){if(M&&p&&n){const J=this.getVideoStartPts(t.samples),Q=(Ot(e.samples[0].pts,J)-J)/t.inputTimeScale;v+=Math.max(0,Q),S+=Math.max(0,-Q)}if(M){if(e.samplerate||(this.warn("regenerate InitSegment as audio detected"),g=this.generateIS(e,t,n,a)),d=this.remuxAudio(e,v,this.isAudioContiguous,a,D||p||l===ge.AUDIO?S:void 0,u),p){const J=d?d.endPTS-d.startPTS:0;t.inputTimeScale||(this.warn("regenerate InitSegment as video detected"),g=this.generateIS(e,t,n,a)),h=this.remuxVideo(t,S,z,J,u)}}else p&&(h=this.remuxVideo(t,S,z,0,u));h&&(h.firstKeyFrame=oe,h.independent=oe!==-1,h.firstKeyFramePTS=ne)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(A=Yl(i,n,this._initPTS,this._initDTS)),s.samples.length&&(m=Wl(s,n,this._initPTS))),{audio:d,video:h,initSegment:g,independent:C,text:m,id3:A}}computeInitPts(e,t,i,s){const n=Math.round(i*t);let a=Ot(e,n);if(a<n)for(this.log(`Adjusting PTS for rollover in timeline near ${(n-a)/t} ${s}`);a<n;)a+=kr;return a-n}generateIS(e,t,i,s){const n=e.samples,a=t.samples,o=this.typeSupported,l={},u=this._initPTS,h=!u||s;let d="audio/mp4",g,m,A,C=-1;if(h&&(g=m=1/0),e.config&&n.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":o.mpeg?(d="audio/mpeg",e.codec=""):o.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3";break}if(l.audio={id:"audio",container:d,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&o.mpeg?new Uint8Array(0):le.initSegment([e]),metadata:{channelCount:e.channelCount}},h){C=e.id,A=e.inputTimeScale;const v=this.computeInitPts(n[0].pts,A,i,"audio");(!u||A!==u.timescale||i===0&&v<u.baseTime)&&(g=m=v)}}if(t.sps&&t.pps&&a.length){if(t.timescale=t.inputTimeScale,l.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:le.initSegment([t]),metadata:{width:t.width,height:t.height}},h){C=t.id,A=t.inputTimeScale;const v=this.getVideoStartPts(a),S=Ot(a[0].dts,v),R=this.computeInitPts(S,A,i,"video"),b=this.computeInitPts(v,A,i,"video");(!u||A!==u.timescale||se(g)||i===0&&b<u.baseTime)&&(m=Math.min(m,R),g=Math.min(g,R))}this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(l).length)return this.ISGenerated=!0,h&&se(g)?(u&&this.warn(`Timestamps at playlist time: ${s?"":"~"}${i} ${g/A} != initPTS: ${u.baseTime/u.timescale} (${u.baseTime}/${u.timescale}) trackId: ${u.trackId}`),this.log(`Found initPTS at playlist time: ${i} offset: ${g/A} (${g}/${A}) trackId: ${C}`),this._initPTS={baseTime:g,timescale:A,trackId:C},this._initDTS={baseTime:m,timescale:A,trackId:C}):g=A=void 0,{tracks:l,initPTS:g,timescale:A,trackId:C}}remuxVideo(e,t,i,s,n){const a=e.inputTimeScale,o=e.samples,l=[],u=o.length,h=this._initPTS,d=h.baseTime*a/h.timescale;let g=this.nextVideoTs,m=8,A=this.videoSampleDuration,C,v,S=Number.POSITIVE_INFINITY,R=Number.NEGATIVE_INFINITY,b=!1;if(!i||g===null){const te=d+t*a,re=o[0].pts-Ot(o[0].dts,o[0].pts);ps()&&g!==null&&Math.abs(te-re-(g+d))<15e3?i=!0:g=te-re-d}const D=g+d;for(let te=0;te<u;te++){const re=o[te];re.pts=Ot(re.pts,D),re.dts=Ot(re.dts,D),re.dts<o[te>0?te-1:te].dts&&(b=!0)}b&&o.sort(function(te,re){const Ee=te.dts-re.dts,Ie=te.pts-re.pts;return Ee||Ie}),C=o[0].dts,v=o[o.length-1].dts;const _=v-C,M=_?Math.round(_/(u-1)):A||e.inputTimeScale/30;if(i){const te=C-D,re=te>M,Ee=te<-1;if((re||Ee)&&(re?this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${Ls(te,!0)} ms (${te}dts) hole between fragments detected at ${t.toFixed(3)}`):this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${Ls(-te,!0)} ms (${te}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!Ee||D>=o[0].pts||ps())){C=D;const Ie=o[0].pts-te;if(re)o[0].dts=C,o[0].pts=Ie;else{let _e=!0;for(let ye=0;ye<o.length&&!(o[ye].dts>Ie&&_e);ye++){const Oe=o[ye].pts;if(o[ye].dts-=te,o[ye].pts-=te,ye<o.length-1){const Le=o[ye+1].pts,Fe=o[ye].pts,Ye=Le<=Fe,Ct=Le<=Oe;_e=Ye==Ct}}}this.log(`Video: Initial PTS/DTS adjusted: ${Ls(Ie,!0)}/${Ls(C,!0)}, delta: ${Ls(te,!0)} ms`)}}C=Math.max(0,C);let p=0,$=0,N=C;for(let te=0;te<u;te++){const re=o[te],Ee=re.units,Ie=Ee.length;let _e=0;for(let ye=0;ye<Ie;ye++)_e+=Ee[ye].data.length;$+=_e,p+=Ie,re.length=_e,re.dts<N?(re.dts=N,N+=M/4|0||1):N=re.dts,S=Math.min(re.pts,S),R=Math.max(re.pts,R)}v=o[u-1].dts;const O=$+4*p+8;let W;try{W=new Uint8Array(O)}catch(te){this.observer.emit(E.ERROR,E.ERROR,{type:me.MUX_ERROR,details:U.REMUX_ALLOC_ERROR,fatal:!1,chunkMeta:n,error:te,bytes:O,reason:`fail allocating video mdat ${O}`});return}lt(W,0,O),lt(W,4,Te.mdat);let q=!1,z=Number.POSITIVE_INFINITY,oe=Number.POSITIVE_INFINITY,ne=Number.NEGATIVE_INFINITY,J=Number.NEGATIVE_INFINITY;for(let te=0;te<u;te++){const re=o[te],Ee=re.units;let Ie=0;for(let Oe=0,Le=Ee.length;Oe<Le;Oe++){const Fe=Ee[Oe],Ye=Fe.data,Ct=Fe.data.byteLength;lt(W,m,Ct),m+=4,W.set(Ye,m),m+=Ct,Ie+=4+Ct}let _e;if(te<u-1)A=o[te+1].dts-re.dts,_e=o[te+1].pts-re.pts;else{const Oe=this.config,Le=te>0?re.dts-o[te-1].dts:M;if(_e=te>0?re.pts-o[te-1].pts:M,Oe.stretchShortVideoTrack&&this.nextAudioTs!==null){const Fe=Math.floor(Oe.maxBufferHole*a),Ye=(s?S+s*a:this.nextAudioTs+d)-re.pts;Ye>Fe?(A=Ye-Le,A<0?A=Le:q=!0,this.log(`It is approximately ${Ye/90} ms to the next segment; using duration ${A/90} ms for the last video frame.`)):A=Le}else A=Le}let ye=Math.round(re.pts-re.dts);if(z=Math.min(z,A),ne=Math.max(ne,A),oe=Math.min(oe,_e),J=Math.max(J,_e),!i&&te===0&&ye>A){const Oe=Math.round(ye/M)*M;Oe-ye===1&&(this.log(`pad first CTS ${ye} -> ${Oe} of sn: ${n.sn}`),ye=Oe)}l.push(Kl(re.key,A,Ie,ye))}if(l.length){const te=ps();if(te){if(te<70){const re=l[0].flags;re.dependsOn=2,re.isNonSync=0}}else if(qh()&&J-oe<ne-z&&M/ne<.025&&l[0].cts===0){this.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let re=C;for(let Ee=0,Ie=l.length;Ee<Ie;Ee++){const _e=re+l[Ee].duration,ye=re+l[Ee].cts;if(Ee<Ie-1){const Oe=_e+l[Ee+1].cts;l[Ee].duration=Oe-ye}else l[Ee].duration=Ee?l[Ee-1].duration:M;l[Ee].cts=0,re=_e}}}A=q||!A?M:A;const Z=v+A;this.nextVideoTs=g=Z-d,this.videoSampleDuration=A,this.isVideoContiguous=!0,n.iframe&&(l.length===1?(l[0].duration=A=n.duration*a,this.nextVideoTs=g=C+A-d):this.warn(`Not adjusting IFrame duration (sample count ${l.length})`));const he={data1:le.moof(n.sn,C,je(e,{samples:l})),data2:W,startPTS:(S-d)/a,endPTS:(R+A-d)/a,startDTS:(C-d)/a,endDTS:g/a,type:"video",hasAudio:!1,hasVideo:!0,nb:l.length,dropped:e.dropped};return e.samples=[],e.dropped=0,he}getSamplesPerFrame(e){switch(e.segmentCodec){case"mp3":return Wf;case"ac3":return jf;default:return Yf}}remuxAudio(e,t,i,s,n,a){const o=e.inputTimeScale,l=e.samplerate?e.samplerate:o,u=o/l,h=this.getSamplesPerFrame(e),d=h*u,g=this._initPTS,m=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,A=[],C=n!==void 0;let v=e.samples,S=m?0:8,R=this.nextAudioTs||-1;const b=g.baseTime*o/g.timescale,D=b+t*o;if(this.isAudioContiguous=i=i||v.length&&R>0&&(s&&Math.abs(D-(R+b))<9e3||Math.abs(Ot(v[0].pts,D)-(R+b))<20*d),v.forEach(function(Z){Z.pts=Ot(Z.pts,D)}),!i||R<0){const Z=v.length;if(v=v.filter(Q=>Q.pts>=0),Z!==v.length&&this.warn(`Removed ${v.length-Z} of ${Z} samples (initPTS ${b} / ${o})`),!v.length)return;n===0?R=0:s&&!C?R=Math.max(0,D-b):R=v[0].pts-b}if(e.segmentCodec==="aac"){const Z=this.config.maxAudioFramesDrift;for(let Q=0,ee=R+b;Q<v.length;Q++){const he=v[Q],te=he.pts,re=te-ee,Ee=Math.abs(1e3*re/o);if(re<=-Z*d&&C)Q===0&&(this.warn(`Audio frame @ ${(te/o).toFixed(3)}s overlaps marker by ${Math.round(1e3*re/o)} ms.`),this.nextAudioTs=R=te-b,ee=te);else if(re>=Z*d&&Ee<Kf&&C){let Ie=Math.round(re/d);for(ee=te-Ie*d;ee<0&&Ie&&d;)Ie--,ee+=d;Q===0&&(this.nextAudioTs=R=ee-b),this.warn(`Injecting ${Ie} audio frames @ ${((ee-b)/o).toFixed(3)}s due to ${Math.round(1e3*re/o)} ms gap.`);for(let _e=0;_e<Ie;_e++){let ye=Of.getSilentFrame(e.parsedCodec||e.manifestCodec||e.codec,e.channelCount);ye||(this.log("Unable to get silent frame for given audio codec; duplicating last frame instead."),ye=he.unit.subarray()),v.splice(Q,0,{unit:ye,pts:ee}),ee+=d,Q++}}he.pts=ee,ee+=d}}let _=null,M=null,p,$=0,N=v.length;for(;N--;)$+=v[N].unit.byteLength;for(let Z=0,Q=v.length;Z<Q;Z++){const ee=v[Z],he=ee.unit;let te=ee.pts;if(M!==null){const Ee=A[Z-1];Ee.duration=Math.round((te-M)/u)}else if(i&&e.segmentCodec==="aac"&&(te=R+b),_=te,$>0){$+=S;try{p=new Uint8Array($)}catch(Ee){this.observer.emit(E.ERROR,E.ERROR,{type:me.MUX_ERROR,details:U.REMUX_ALLOC_ERROR,fatal:!1,chunkMeta:a,error:Ee,bytes:$,reason:`fail allocating audio mdat ${$}`});return}m||(lt(p,0,$),lt(p,4,Te.mdat))}else return;p&&p.set(he,S);const re=he.byteLength;S+=re,A.push(Kl(!0,h,re,0)),M=te}const O=A.length;if(!O)return;const W=A[A.length-1];R=M-b,this.nextAudioTs=R+u*W.duration;const q=m?new Uint8Array(0):le.moof(e.sequenceNumber++,_/u,je({},e,{samples:A}));e.samples=[];const z=(_-b)/o,oe=this.nextAudioTs/o,J={data1:q,data2:p,startPTS:z,endPTS:oe,startDTS:z,endDTS:oe,type:"audio",hasAudio:!0,hasVideo:!1,nb:O};return this.isAudioContiguous=!0,J}}function Ot(r,e){let t;if(e===null)return r;for(e<r?t=-kr:t=kr;Math.abs(r-e)>4294967296;)r+=t;return r}function qf(r){for(let e=0;e<r.length;e++)if(r[e].key)return e;return-1}function Yl(r,e,t,i){const s=r.samples.length;if(!s)return;const n=r.inputTimeScale;for(let o=0;o<s;o++){const l=r.samples[o];l.pts=Ot(l.pts-t.baseTime*n/t.timescale,e*n)/n,l.dts=Ot(l.dts-i.baseTime*n/i.timescale,e*n)/n}const a=r.samples;return r.samples=[],{samples:a}}function Wl(r,e,t){const i=r.samples.length;if(!i)return;const s=r.inputTimeScale;for(let a=0;a<i;a++){const o=r.samples[a];o.pts=Ot(o.pts-t.baseTime*s/t.timescale,e*s)/s}r.samples.sort((a,o)=>a.pts-o.pts);const n=r.samples;return r.samples=[],{samples:n}}class zf extends wt{constructor(e,t,i,s){super("passthrough-remuxer",s),this.observer=void 0,this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null,this.isVideoContiguous=!1,this.videoOnlyRemux=!1,this.decryptdata=null,this.pendingInitSegment=void 0,this.observer=e}destroy(){this.observer&&this.observer.removeAllListeners(),this.observer=null}resetTimeStamp(e){this.lastEndTime=null;const t=this.initPTS;t&&e&&t.baseTime===e.baseTime&&t.timescale===e.timescale||(this.initPTS=e)}resetNextTimestamp(){this.isVideoContiguous=!1,this.lastEndTime=null}resetInitSegment(e,t,i,s){this.audioCodec=t,this.videoCodec=i,this.decryptdata=s,this.pendingInitSegment=e,this.videoOnlyRemux=!1,this.initTracks=void 0,this.initData=void 0,this.emitInitSegment=!0}generateInitSegment(e,t,i){this.videoOnlyRemux=!1;let{audioCodec:s,videoCodec:n}=this;if(!(e!=null&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}const{audio:a,video:o}=this.initData=i||oo(e);if(t)Mh(e,t);else{const u=a||o;u!=null&&u.encrypted&&this.warn(`Init segment with encrypted track with has no key ("${u.codec}")!`)}a&&(s=jl(a,ze.AUDIO,this)),o&&(n=jl(o,ze.VIDEO,this));const l={};a&&o?l.audiovideo={container:"video/mp4",codec:s+","+n,supplemental:o.supplemental,encrypted:o.encrypted,initSegment:e,id:"main"}:a?l.audio={container:"audio/mp4",codec:s,encrypted:a.encrypted,initSegment:e,id:"audio"}:o?l.video={container:"video/mp4",codec:n,supplemental:o.supplemental,encrypted:o.encrypted,initSegment:e,id:"main"}:this.warn("initSegment does not contain moov or trak boxes."),this.initTracks=l}remux(e,t,i,s,n,a,o,l,u,h,d){var g,m;let{initPTS:A,lastEndTime:C}=this;const v={audio:void 0,video:void 0,text:void 0,id3:i,initSegment:void 0};se(C)||(C=this.lastEndTime=n||0);const S=t.samples;if(!S.length)return v;const R=this.pendingInitSegment;R&&(this.pendingInitSegment=void 0,this.generateInitSegment(R,this.decryptdata,h));const b={initPTS:void 0,timescale:void 0,trackId:void 0};let D=this.initData;if((g=D)!=null&&g.length||(this.generateInitSegment(S),D=this.initData),!((m=D)!=null&&m.length))return this.warn("Failed to generate initSegment."),v;if(u.iframe&&D.audio&&D.video){var _;const pe=(_=this.initTracks)==null||(_=_.audiovideo)==null?void 0:_.initSegment,we=pe?Rh(pe):null;if(we){var M;this.log("Converted muxed init segment to video-only for I-Frame playback"),this.generateInitSegment(we,this.decryptdata),(M=this.initData)!=null&&M.length&&(D=this.initData,this.emitInitSegment=!0,this.videoOnlyRemux=!0)}}this.emitInitSegment&&(b.tracks=this.initTracks,v.initSegment=b,this.emitInitSegment=!1);const p=u.iframe,$=d&&(!p||d.includeSampleDetails)?d.tracks:Bh(S,D,u,this,p),N=D.audio?$[D.audio.id]:null,O=D.video?$[D.video.id]:null,W=!!D.audio,q=!!D.video;let z="";W&&(z+="audio"),q&&(z+="video");const oe=An(O,1/0),ne=An(N,1/0),J=An(O,0,!0),Z=An(N,0,!0);let Q=n,ee=0;O&&N&&D.audio&&(ne>J||oe>Z)&&this.warn(`audio and video track sample timestamps do not overlap. v: ${oe}-${J} a: ${ne}-${Z}}`,O,N);const he=!!N&&(!O||!A&&ne<oe||!!A&&A.trackId===D.audio.id),te=he?N:O;if(!te)return this.log(`No media samples found in ${l} ${u.level} ${u.part===-1?"":`part: ${u.part} of`} sn: ${u.sn} at playlist time: ${n}`),v;let re=S,Ee,Ie;if(O&&O.sampleCount>=1&&D.video&&u.iframe){const{trun:pe,start:we}=O,Re=pe.length===1,rt=pe.length?Re?pe[0].samples:pe[0].samples.concat(...pe.slice(1).map(it=>it.samples)):[];if(rt.length){const it=pe[0];let At=it;for(let xt=pe.length;xt--;)if(pe[xt].samples.length){At=pe[xt];break}const at=At.lastSampleDurationOffset,{defaultSampleDurationOffset:Bt}=it,nt=Math.abs(u.duration-(J-oe))>.05,ue=rt.length<O.sampleCount;if(!(nt||ue||this.videoOnlyRemux||!Re))ee=J-oe;else{const xt=ue?At.sampleOffset+At.samples.reduce((Dt,Di)=>Dt+Di.size,0):void 0,ft=nt?u.duration:J-oe,li=Zf(rt,ft*D.video.timescale,at,Bt),Gt=Dh(S,D.video.id,rt.length,xt,li);Gt?(re=Gt,Ie=Xf(we,rt)):this.warn(`IFrame remux skipped (sn ${u.sn}); using native sample duration`),ee=Gt&&li?ft:J-oe}}else this.warn(`Could not remux IFrame track fragment (no samples in range, trun count ${pe.length})`),ee=J-oe}else ee=he?Z-ne:J-oe;if(this.videoOnlyRemux&&re===S)return this.warn(`Dropping muxed I-Frame fragment that could not be remuxed to video-only (sn: ${u.sn})`),v;const _e=te.timescale,ye=te.start-n*_e,Oe=he?D.audio.id:D.video.id;if(Q=te.start/_e,(a||!A)&&(Qf(A,Q,n,ee)||_e!==A.timescale)){let pe=!1;const we=he?"audio":"video";if(A){const Re=n!==0?Q/n:1+Q/1;pe=Q>=0&&Math.abs(1-Re)<.001,this.log(`${we} timestamps in track ${Oe} at playlist time: ${a?"":"~"}${n} maps to ${Q} with initPTS: ${A.baseTime/A.timescale} (${ye/_e-A.baseTime/A.timescale}s diff) (${z}) drift estimate: ${Re} ${pe?"(ignoring drift)":"remapping timestamps (initPTS)"}`)}pe||(this.log(`Found initPTS in ${we} track ${Oe} at playlist time: ${n} offset: ${Q-n} (${ye}/${_e})`),A=null,b.initPTS=ye,b.timescale=_e,b.trackId=Oe)}A?(b.initPTS=A.baseTime,b.timescale=A.timescale,b.trackId=A.trackId):((!b.timescale||b.trackId===void 0||b.initPTS===void 0)&&(this.warn("Could not set initPTS"),b.initPTS=Q,b.timescale=1,b.trackId=-1),this.initPTS=A={baseTime:b.initPTS,timescale:b.timescale,trackId:b.trackId});const Le=Q-A.baseTime/A.timescale,Fe=Le+ee,Ye=q&&te?.ptsMin!==void 0?te.ptsMin/te.timescale-A.baseTime/A.timescale:Le,Ct=Ie!==void 0&&O?Ie/O.timescale-A.baseTime/A.timescale:q&&te!=null&&te.ptsMax?te.ptsMax/te.timescale-A.baseTime/A.timescale:Fe;ee>0?this.lastEndTime=Fe:(this.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const yt=(D.audio?D.audio.encrypted:!1)||(D.video?D.video.encrypted:!1),We={data1:re,data2:Ee,startPTS:Ye,startDTS:Le,endPTS:Ct,endDTS:Fe,type:z,hasAudio:W,hasVideo:q,nb:1,dropped:0,encrypted:yt};v.audio=W&&!q?We:void 0,v.video=q?We:void 0;const St=this.isVideoContiguous,$t=O?.sampleCount;if($t){const pe=O.keyFrameIndex,we=pe!==-1;We.nb=$t,We.dropped=pe===0||St?0:we?pe:$t,We.independent=we,We.firstKeyFrame=pe,we&&O.keyFrameStart&&(We.firstKeyFramePTS=(O.keyFrameStart-A.baseTime)/A.timescale),St||(v.independent=we),this.isVideoContiguous||(this.isVideoContiguous=we),We.dropped&&this.warn(`fmp4 does not start with IDR: firstIDR ${pe}/${$t} dropped: ${We.dropped} start: ${We.firstKeyFramePTS||"NA"}`)}return v.initSegment=b,v.id3=Yl(i,n,A,A),s.samples.length&&(v.text=Wl(s,n,A)),v}}function An(r,e,t=!1){return r?.start!==void 0?(r.start+(t?r.duration:0))/r.timescale:e}function Xf(r,e){let t=r,i=r;for(let s=0;s<e.length;s++){const{cts:n,duration:a}=e[s];i=Math.max(i,t+(n||0)+a),t+=a}return i}function Zf(r,e,t,i){if(t!==void 0){const n=r[r.length-1];let a=e;for(let o=0;o<r.length-1;o++)a-=r[o].duration;return a<=0&&(a=n.duration),n.duration=a,{durationOffset:t,value:a}}if(i===void 0)return;const s=Math.round(e/r.length);for(let n=0;n<r.length;n++)r[n].duration=s;return{durationOffset:i,value:s}}function Qf(r,e,t,i){if(r===null)return!0;const s=Math.max(i,1),n=e-r.baseTime/r.timescale;return Math.abs(n-t)>=s}function jl(r,e,t){const i=r.codec;return i&&i.length>4?i:e===ze.AUDIO?i==="ec-3"||i==="ac-3"||i==="alac"?i:i==="fLaC"||i==="Opus"?Qs(i,!1):(t.warn(`Unhandled audio codec "${i}" in mp4 MAP`),i||"mp4a"):i==="mjpg"?i:(t.warn(`Unhandled video codec "${i}" in mp4 MAP`),i||"avc1")}let xi;try{xi=self.performance.now.bind(self.performance)}catch{xi=Date.now}const In=[{demux:Lf,remux:zf},{demux:mi,remux:mn},{demux:Tf,remux:mn},{demux:xf,remux:mn}];In.splice(2,0,{demux:Sf,remux:mn});class ql{constructor(e,t,i,s,n,a){this.asyncResult=!1,this.logger=void 0,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=e,this.typeSupported=t,this.config=i,this.id=n,this.logger=a}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,i,s){if(!this.observer)return Cn(i);const n=i.transmuxing;n.executeStart=xi();const a=new Uint8Array(e),{currentTransmuxState:o,transmuxConfig:l}=this;s&&(this.currentTransmuxState=s);const{contiguous:u,discontinuity:h,trackSwitch:d,accurateTimeOffset:g,timeOffset:m,initSegmentChange:A}=s||o,{audioCodec:C,videoCodec:v,defaultInitPts:S,duration:R,initSegmentData:b}=l,D=Jf(a,t);if(D&&zi(D.method)){const $=this.getDecrypter(),N=pr(D.method);return this.asyncResult=!0,this.decryptionPromise=$.decrypt(a,D.key.buffer,D.iv.buffer,N,i.decryptRange).then(O=>{const W=this.push(O,null,i);return this.decryptionPromise=null,W}),this.decryptionPromise}const _=this.needsProbing(h,d);if(_){const $=i.iframe&&b&&mi.probe(b,this.logger)?b:a,N=this.configureTransmuxer($);if(N)return this.logger.warn(`[transmuxer] ${N.message}`),this.observer.emit(E.ERROR,E.ERROR,{type:me.MEDIA_ERROR,details:U.FRAG_PARSING_ERROR,fatal:!1,error:N,reason:N.message}),n.executeEnd=xi(),Cn(i)}(h||d||A||_)&&this.resetInitSegment(b,C,v,R,t,i),(h||A||_)&&this.resetInitialTimestamp(S),u||this.resetContiguity();const M=this.transmux(a,D,m,g,i);this.asyncResult=Rs(M);const p=this.currentTransmuxState;return p.contiguous=!0,p.discontinuity=!1,p.trackSwitch=!1,n.executeEnd=xi(),M}flush(e){const t=e.transmuxing;t.executeStart=xi();const{decrypter:i,currentTransmuxState:s,decryptionPromise:n}=this;if(n)return this.asyncResult=!0,n.then(()=>this.flush(e));const a=[],{timeOffset:o}=s;if(i){const d=i.flush();d&&a.push(this.push(d.buffer,null,e))}const{demuxer:l,remuxer:u}=this;if(!l||!u){t.executeEnd=xi();const d=[Cn(e)];return this.asyncResult?Promise.resolve(d):d}const h=l.flush(o,e);return Rs(h)?(this.asyncResult=!0,h.then(d=>(this.flushRemux(a,d,e),a))):(this.flushRemux(a,h,e),this.asyncResult?Promise.resolve(a):a)}flushRemux(e,t,i){if(!this.remuxer)return;const{audioTrack:s,videoTrack:n,id3Track:a,textTrack:o}=t,{accurateTimeOffset:l,timeOffset:u}=this.currentTransmuxState;this.logger.log(`[transmuxer.ts]: Flushed ${this.id} sn: ${i.sn}${i.part>-1?" part: "+i.part:""} of ${this.id} playlist ${i.level}`);const h=this.remuxer.remux(s,n,a,o,u,l,!0,this.id,i,t.initData,t.sampleData);e.push({remuxResult:h,chunkMeta:i}),i.transmuxing.executeEnd=xi()}resetInitialTimestamp(e){const{demuxer:t,remuxer:i}=this;!t||!i||(t.resetTimeStamp(e),i.resetTimeStamp(e))}resetContiguity(){const{demuxer:e,remuxer:t}=this;!e||!t||(e.resetContiguity(),t.resetNextTimestamp())}resetInitSegment(e,t,i,s,n,a){const{demuxer:o,remuxer:l}=this;!o||!l||(o.resetInitSegment(e,t,i,s,n,a),l.resetInitSegment(e,t,i,n))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0),this.observer&&this.observer.removeAllListeners(),this.decryptionPromise=null,this.decrypter=this.observer=void 0,this.logger=this.config=this.probe=void 0}transmux(e,t,i,s,n){let a;return t?.method==="SAMPLE-AES"?a=this.transmuxSampleAes(e,t,i,s,n):a=this.transmuxUnencrypted(e,i,s,n),a}transmuxUnencrypted(e,t,i,s){const{demuxer:n,remuxer:a}=this;if(!n||!a)return Cn(s);const o=n.demux(e,t,s,!1,!this.config.progressive),{audioTrack:l,videoTrack:u,id3Track:h,textTrack:d}=o;return{remuxResult:a.remux(l,u,h,d,t,i,!1,this.id,s,o.initData,o.sampleData),chunkMeta:s}}transmuxSampleAes(e,t,i,s,n){return this.demuxer?this.demuxer.demuxSampleAes(e,t,i,n).then(a=>({remuxResult:this.remuxer.remux(a.audioTrack,a.videoTrack,a.id3Track,a.textTrack,i,s,!1,this.id,n,a.initData,a.sampleData),chunkMeta:n})):Promise.reject(new Error("no demuxer"))}configureTransmuxer(e){const{config:t,observer:i,typeSupported:s}=this;if(!i)return;let n;try{for(let d=0,g=In.length;d<g;d++){var a;if((a=In[d].demux)!=null&&a.probe(e,this.logger)){n=In[d];break}}}catch(d){return d}if(!n)return new Error("Failed to find demuxer by probing fragment data");const o=this.demuxer,l=this.remuxer,u=n.demux,h=n.remux;(!o||!(o instanceof u))&&(this.logger.log(`Using ${u.name}`),this.demuxer=new u(i,t,s,this.logger),this.probe=u.probe),(!l||!(l instanceof h))&&(this.logger.log(`Using ${h.name}`),this.remuxer=new h(i,t,s,this.logger))}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new hr(this.config)),e}}function Jf(r,e){let t=null;return r.byteLength>0&&e?.key!=null&&e.iv!==null&&e.method!=null&&(t=e),t}const Cn=r=>({remuxResult:{},chunkMeta:r});function Rs(r){return"then"in r&&r.then instanceof Function}class eg{constructor(e,t,i,s,n){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=i,this.duration=s,this.defaultInitPts=n||null}}class tg{constructor(e,t,i,s,n,a){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=e,this.contiguous=t,this.accurateTimeOffset=i,this.trackSwitch=s,this.timeOffset=n,this.initSegmentChange=a}}let zl=0;class Xl{constructor(e,t,i,s){this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=zl++,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.onWorkerMessage=l=>{const u=l.data,h=this.hls;if(!(!h||!(u!=null&&u.event)||u.instanceNo!==this.instanceNo))switch(u.event){case"init":{var d;const g=(d=this.workerContext)==null?void 0:d.objectURL;g&&self.URL.revokeObjectURL(g);break}case"transmuxComplete":{this.handleTransmuxComplete(u.data);break}case"flush":{this.onFlush(u.data);break}case"workerLog":{h.logger[u.data.logType]&&h.logger[u.data.logType](u.data.message);break}default:{u.data=u.data||{},u.data.frag=this.frag,u.data.part=this.part,u.data.id=this.id,h.trigger(u.event,u.data);break}}},this.onWorkerError=l=>{if(!this.hls)return;const u=new Error(`${l.message} (${l.filename}:${l.lineno})`);this.hls.config.enableWorker=!1,this.hls.logger.warn(`Error in "${this.id}" Web Worker, fallback to inline`),this.hls.trigger(E.ERROR,{type:me.OTHER_ERROR,details:U.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:u})};const n=e.config;this.hls=e,this.id=t,this.useWorker=!!n.enableWorker,this.onTransmuxComplete=i,this.onFlush=s;const a=(l,u)=>{u=u||{},u.frag=this.frag||void 0,l===E.ERROR&&(u=u,u.parent=this.id,u.part=this.part,this.error=u.error),this.hls.trigger(l,u)};this.observer=new Sr,this.observer.on(E.FRAG_DECRYPTED,a),this.observer.on(E.ERROR,a);const o=yo(n.preferManagedMediaSource);if(this.useWorker&&typeof Worker<"u"){const l=this.hls.logger;if(n.workerPath||lf()){try{n.workerPath?(l.log(`loading Web Worker ${n.workerPath} for "${t}"`),this.workerContext=cf(n.workerPath)):(l.log(`injecting Web Worker for "${t}"`),this.workerContext=uf());const{worker:h}=this.workerContext;h.addEventListener("message",this.onWorkerMessage),h.addEventListener("error",this.onWorkerError),h.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:o,id:t,config:Xe(n)})}catch(h){l.warn(`Error setting up "${t}" Web Worker, fallback to inline`,h),this.terminateWorker(),this.error=null,this.transmuxer=new ql(this.observer,o,n,"",t,e.logger)}return}}this.transmuxer=new ql(this.observer,o,n,"",t,e.logger)}reset(){if(this.frag=null,this.part=null,this.workerContext){const e=this.instanceNo;this.instanceNo=zl++;const t=this.hls.config,i=yo(t.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:e,typeSupported:i,id:this.id,config:Xe(t)})}}terminateWorker(){if(this.workerContext){const{worker:e}=this.workerContext;this.workerContext=null,e.removeEventListener("message",this.onWorkerMessage),e.removeEventListener("error",this.onWorkerError),hf(this.hls.config.workerPath)}}destroy(){if(this.workerContext)this.terminateWorker(),this.onWorkerMessage=this.onWorkerError=null;else{const t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}const e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.part=null,this.observer=null,this.hls=null}push(e,t,i,s,n,a,o,l,u,h){var d,g;u.transmuxing.start=self.performance.now();const{instanceNo:m,transmuxer:A}=this,C=a?a.start:n.start,v=n.decryptdata,S=this.frag,R=S?n.cc!==S.cc:!0,b=S?u.level!==S.level:!0,D=S?u.sn-S.sn:-1,_=this.part?u.part-this.part.index:-1,M=D===0&&u.id>1&&u.id===S?.stats.chunkCount,p=!b&&(D===1||D===0&&(_===1||M&&_<=0)),$=self.performance.now();(b||D||n.stats.parsing.start===0)&&(n.stats.parsing.start=$),a&&(_||!p)&&(a.stats.parsing.start=$);const N=!(S&&((d=n.initSegment)==null?void 0:d.url)===((g=S.initSegment)==null?void 0:g.url)),O=new tg(R,p,l,b,C,N);if(!p||R||N){this.hls.logger.log(`[transmuxer-interface]: Starting new transmux session for ${n.type} sn: ${u.sn}${u.part>-1?" part: "+u.part:""} ${this.id} playlist: ${u.level} id: ${u.id}
17
+ discontinuity: ${R}
18
+ trackSwitch: ${b}
19
19
  contiguous: ${p}
20
- accurateTimeOffset: ${c}
21
- timeOffset: ${E}
22
- initSegmentChange: ${F}`);const W=new Qh(i,s,t,o,h);this.configureTransmuxer(W)}if(this.frag=r,this.part=n,this.workerContext)this.workerContext.worker.postMessage({instanceNo:I,cmd:"demux",data:e,decryptdata:v,chunkMeta:u,state:O},e instanceof ArrayBuffer?[e]:[]);else if(m){const W=m.push(e,v,u,O);rs(W)?W.then(ie=>{this.handleTransmuxComplete(ie)}).catch(ie=>{this.transmuxerError(ie,u,"transmuxer-interface push error")}):this.handleTransmuxComplete(W)}}flush(e){e.transmuxing.start=self.performance.now();const{instanceNo:t,transmuxer:i}=this;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:t,cmd:"flush",chunkMeta:e});else if(i){const s=i.flush(e);rs(s)?s.then(r=>{this.handleFlushResult(r,e)}).catch(r=>{this.transmuxerError(r,e,"transmuxer-interface flush error")}):this.handleFlushResult(s,e)}}transmuxerError(e,t,i){this.hls&&(this.error=e,this.hls.trigger(y.ERROR,{type:de.MEDIA_ERROR,details:U.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,part:this.part||void 0,fatal:!1,error:e,err:e,reason:i}))}handleFlushResult(e,t){e.forEach(i=>{this.handleTransmuxComplete(i)}),this.onFlush(t)}configureTransmuxer(e){const{instanceNo:t,transmuxer:i}=this;this.workerContext?this.workerContext.worker.postMessage({instanceNo:t,cmd:"configure",config:e}):i&&i.configure(e)}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}}const $o=100;class ed extends Ur{constructor(e,t,i){super(e,t,i,"audio-stream-controller",he.AUDIO),this.mainAnchor=null,this.mainFragLoading=null,this.audioOnly=!1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.flushing=!1,this.bufferFlushed=!1,this.cachedTrackLoadedData=null,this.registerListeners()}onHandlerDestroying(){this.unregisterListeners(),super.onHandlerDestroying(),this.resetItem()}resetItem(){this.mainDetails=this.mainAnchor=this.mainFragLoading=this.bufferedTrack=this.switchingTrack=this.waitingData=this.cachedTrackLoadedData=null}registerListeners(){super.registerListeners();const{hls:e}=this;e.on(y.LEVEL_LOADED,this.onLevelLoaded,this),e.on(y.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(y.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(y.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(y.BUFFER_RESET,this.onBufferReset,this),e.on(y.BUFFER_CREATED,this.onBufferCreated,this),e.on(y.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(y.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(y.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(y.FRAG_LOADING,this.onFragLoading,this),e.on(y.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){const{hls:e}=this;e&&(super.unregisterListeners(),e.off(y.LEVEL_LOADED,this.onLevelLoaded,this),e.off(y.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(y.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(y.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(y.BUFFER_RESET,this.onBufferReset,this),e.off(y.BUFFER_CREATED,this.onBufferCreated,this),e.off(y.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(y.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(y.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(y.FRAG_LOADING,this.onFragLoading,this),e.off(y.FRAG_BUFFERED,this.onFragBuffered,this))}onInitPtsFound(e,{frag:t,id:i,initPTS:s,timescale:r,trackId:n}){if(i===he.MAIN){const o=t.cc,c=this.fragCurrent;if(this.initPTS[o]={baseTime:s,timescale:r,trackId:n},this.log(`InitPTS for cc: ${o} found from main: ${s/r} (${s}/${r}) trackId: ${n}`),this.mainAnchor=t,this.state===j.WAITING_INIT_PTS){const u=this.waitingData;(!u&&!this.loadingParts||u&&u.frag.cc!==o)&&this.syncWithAnchor(t,u?.frag)}else!this.hls.hasEnoughToStart&&c&&c.cc!==o?(c.abortRequests(),this.syncWithAnchor(t,c)):this.state===j.IDLE&&this.tick()}}getLoadPosition(){return!this.startFragRequested&&this.nextLoadPosition>=0?this.nextLoadPosition:super.getLoadPosition()}syncWithAnchor(e,t){var i;const s=((i=this.mainFragLoading)==null?void 0:i.frag)||null;if(t&&s?.cc===t.cc)return;const r=(s||e).cc,n=this.getLevelDetails(),o=this.getLoadPosition(),c=La(n,r,o);c&&(this.log(`Syncing with main frag at ${c.start} cc ${c.cc}`),this.startFragRequested=!1,this.nextLoadPosition=c.start,this.resetLoadingState(),this.state===j.IDLE&&this.doTickIdle())}startLoad(e,t){if(!this.levels){this.startPosition=e,this.state=j.STOPPED;return}const i=this.lastCurrentTime;this.stopLoad(),this.setInterval($o),i>0&&e===-1?(this.log(`Override startPosition with lastCurrentTime @${i.toFixed(3)}`),e=i,this.state=j.IDLE):this.state=j.WAITING_TRACK,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}doTick(){switch(this.state){case j.IDLE:this.doTickIdle();break;case j.WAITING_TRACK:{const{levels:e,trackId:t}=this,i=e?.[t],s=i?.details;if(s&&!this.waitForLive(i)){if(this.waitForCdnTuneIn(s))break;this.state=j.WAITING_INIT_PTS}break}case j.FRAG_LOADING_WAITING_RETRY:{this.checkRetryDate();break}case j.WAITING_INIT_PTS:{const e=this.waitingData;if(e){const{frag:t,part:i,cache:s,complete:r}=e,n=this.mainAnchor;if(this.initPTS[t.cc]!==void 0){this.waitingData=null,this.state=j.FRAG_LOADING;const o=s.flush().buffer,c={frag:t,part:i,payload:o,networkDetails:null};this._handleFragmentLoadProgress(c),r&&super._handleFragmentLoadComplete(c)}else n&&n.cc!==e.frag.cc&&this.syncWithAnchor(n,e.frag)}else this.state=j.IDLE}}this.onTickEnd()}resetLoadingState(){const e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null),super.resetLoadingState()}onTickEnd(){const{media:e}=this;e!=null&&e.readyState&&(this.lastCurrentTime=e.currentTime)}doTickIdle(){var e;const{hls:t,levels:i,media:s,trackId:r}=this,n=t.config;if(!this.buffering||!s&&!this.primaryPrefetch&&(this.startFragRequested||!n.startFragPrefetch)||!(i!=null&&i[r]))return;const o=i[r],c=o.details;if(!c||this.waitForLive(o)||this.waitForCdnTuneIn(c)){this.state=j.WAITING_TRACK,this.startFragRequested=!1;return}const u=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&u&&(this.bufferFlushed=!1,this.afterBufferFlushed(u,Ue.AUDIO,he.AUDIO));const h=this.getFwdBufferInfo(u,he.AUDIO);if(h===null)return;if(!this.switchingTrack&&this._streamEnded(h,c)){t.trigger(y.BUFFER_EOS,{type:"audio"}),this.state=j.ENDED;return}const f=h.len,g=t.maxBufferLength,I=c.fragments,m=I[0].start,E=this.getLoadPosition(),v=this.flushing?E:h.end;if(this.switchingTrack&&s){const L=E;c.PTSKnown&&L<m&&(h.end>m||h.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),s.currentTime=m+.05)}if(f>=g&&!this.switchingTrack&&v<I[I.length-1].start)return;let x=this.getNextFragment(v,c);if(x&&this.isLoopLoading(x,v)&&(x=this.getNextFragmentLoopLoading(x,c,h,he.MAIN,g)),!x){this.bufferFlushed=!0;return}let D=((e=this.mainFragLoading)==null?void 0:e.frag)||null;if(!this.audioOnly&&this.startFragRequested&&D&&qe(x)&&!x.endList&&(!c.live||!this.loadingParts&&v<this.hls.liveSyncPosition)&&(this.fragmentTracker.getState(D)===Qe.OK&&(this.mainFragLoading=D=null),D&&qe(D))){if(x.start>D.end){const w=this.fragmentTracker.getFragAtPos(v,he.MAIN);w&&w.end>D.end&&(D=w,this.mainFragLoading={frag:w,targetBufferTime:null})}if(x.start>D.end)return}this.loadFragment(x,o,v)}onMediaDetaching(e,t){this.bufferFlushed=this.flushing=!1,super.onMediaDetaching(e,t)}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(i=>new Zi(i))}onAudioTrackSwitching(e,t){const i=!!t.url;this.trackId=t.id;const{fragCurrent:s}=this;s&&(s.abortRequests(),this.removeUnbufferedFrags(s.start)),this.resetLoadingState(),i?(this.switchingTrack=t,this.flushAudioIfNeeded(t),this.state!==j.STOPPED&&(this.setInterval($o),this.state=j.IDLE,this.tick())):(this.resetTransmuxer(),this.switchingTrack=null,this.bufferedTrack=t,this.clearInterval())}onManifestLoading(){super.onManifestLoading(),this.bufferFlushed=this.flushing=this.audioOnly=!1,this.resetItem(),this.trackId=-1}onLevelLoaded(e,t){this.mainDetails=t.details;const i=this.cachedTrackLoadedData;i&&(this.cachedTrackLoadedData=null,this.onAudioTrackLoaded(y.AUDIO_TRACK_LOADED,i))}onAudioTrackLoaded(e,t){var i;const{levels:s}=this,{details:r,id:n,groupId:o,track:c}=t;if(!s){this.warn(`Audio tracks reset while loading track ${n} "${c.name}" of "${o}"`);return}const u=this.mainDetails;if(!u||r.endCC>u.endCC||u.expired){this.cachedTrackLoadedData=t,this.state!==j.STOPPED&&(this.state=j.WAITING_TRACK);return}this.cachedTrackLoadedData=null,this.log(`Audio track ${n} "${c.name}" of "${o}" loaded [${r.startSN},${r.endSN}]${r.lastPartSn?`[part-${r.lastPartSn}-${r.lastPartIndex}]`:""},duration:${r.totalduration}`);const h=s[n];let f=0;if(r.live||(i=h.details)!=null&&i.live){if(this.checkLiveUpdate(r),r.deltaUpdateFailed)return;if(h.details){var g;f=this.alignPlaylists(r,h.details,(g=this.levelLastLoaded)==null?void 0:g.details)}r.alignedSliding||(ho(r,u),r.alignedSliding||Ms(r,u),f=r.fragmentStart)}h.details=r,this.levelLastLoaded=h,this.startFragRequested||this.setStartPosition(u,f),this.hls.trigger(y.AUDIO_TRACK_UPDATED,{details:r,id:n,groupId:t.groupId}),this.state===j.WAITING_TRACK&&!this.waitForCdnTuneIn(r)&&(this.state=j.IDLE),this.tick()}_handleFragmentLoadProgress(e){var t;const i=e.frag,{part:s,payload:r}=e,{config:n,trackId:o,levels:c}=this;if(!c){this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);return}const u=c[o];if(!u){this.warn("Audio track is undefined on fragment load progress");return}const h=u.details;if(!h){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(i.start);return}const f=n.defaultAudioCodec||u.audioCodec||"mp4a.40.2";let g=this.transmuxer;g||(g=this.transmuxer=new Uo(this.hls,he.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const I=this.initPTS[i.cc],m=(t=i.initSegment)==null?void 0:t.data;if(I!==void 0){const v=s?s.index:-1,x=v!==-1,D=new Dr(i.level,i.sn,i.stats.chunkCount,r.byteLength,v,x);g.push(r,m,f,"",i,s,h.totalduration,!1,D,I)}else{this.log(`Unknown video PTS for cc ${i.cc}, waiting for video PTS before demuxing audio frag ${i.sn} of [${h.startSN} ,${h.endSN}],track ${o}`);const{cache:E}=this.waitingData=this.waitingData||{frag:i,part:s,cache:new go,complete:!1};E.push(new Uint8Array(r)),this.state!==j.STOPPED&&(this.state=j.WAITING_INIT_PTS)}}_handleFragmentLoadComplete(e){if(this.waitingData){this.waitingData.complete=!0;return}super._handleFragmentLoadComplete(e)}onBufferReset(){this.mediaBuffer=null}onBufferCreated(e,t){this.bufferFlushed=this.flushing=!1;const i=t.tracks.audio;i&&(this.mediaBuffer=i.buffer||null)}onFragLoading(e,t){!this.audioOnly&&t.frag.type===he.MAIN&&qe(t.frag)&&(this.mainFragLoading=t,this.state===j.IDLE&&this.tick())}onFragBuffered(e,t){const{frag:i,part:s}=t;if(i.type!==he.AUDIO){!this.audioOnly&&i.type===he.MAIN&&!i.elementaryStreams.video&&!i.elementaryStreams.audiovideo&&(this.audioOnly=!0,this.mainFragLoading=null);return}if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${s?" p: "+s.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);return}if(qe(i)){this.fragPrevious=i;const r=this.switchingTrack;r&&(this.bufferedTrack=r,this.switchingTrack=null,this.hls.trigger(y.AUDIO_TRACK_SWITCHED,Be({},r)))}this.fragBufferedComplete(i,s),this.media&&this.tick()}onError(e,t){var i;if(t.fatal){this.state=j.ERROR;return}switch(t.details){case U.FRAG_GAP:case U.FRAG_PARSING_ERROR:case U.FRAG_DECRYPT_ERROR:case U.FRAG_LOAD_ERROR:case U.FRAG_LOAD_TIMEOUT:case U.KEY_LOAD_ERROR:case U.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(he.AUDIO,t);break;case U.AUDIO_TRACK_LOAD_ERROR:case U.AUDIO_TRACK_LOAD_TIMEOUT:case U.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===j.WAITING_TRACK&&((i=t.context)==null?void 0:i.type)===be.AUDIO_TRACK&&(this.state=j.IDLE);break;case U.BUFFER_ADD_CODEC_ERROR:case U.BUFFER_APPEND_ERROR:if(t.parent!=="audio")return;this.reduceLengthAndFlushBuffer(t)||this.resetLoadingState();break;case U.BUFFER_FULL_ERROR:if(t.parent!=="audio")return;this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case U.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onBufferFlushing(e,{type:t}){t!==Ue.VIDEO&&(this.flushing=!0)}onBufferFlushed(e,{type:t}){if(t!==Ue.VIDEO){this.flushing=!1,this.bufferFlushed=!0,this.state===j.ENDED&&(this.state=j.IDLE);const i=this.mediaBuffer||this.media;i&&(this.afterBufferFlushed(i,t,he.AUDIO),this.tick())}}_handleTransmuxComplete(e){var t;const i="audio",{hls:s}=this,{remuxResult:r,chunkMeta:n}=e,o=this.getCurrentContext(n);if(!o){this.resetWhenMissingContext(n);return}const{frag:c,part:u,level:h}=o,{details:f}=h,{audio:g,text:I,id3:m,initSegment:E}=r;if(this.fragContextChanged(c)||!f){this.fragmentTracker.removeFragment(c);return}if(this.state=j.PARSING,this.switchingTrack&&g&&this.completeAudioSwitch(this.switchingTrack),E!=null&&E.tracks){const v=c.initSegment||c;if(this.unhandledEncryptionError(E,c))return;this._bufferInitSegment(h,E.tracks,v,n),s.trigger(y.FRAG_PARSING_INIT_SEGMENT,{frag:v,id:i,tracks:E.tracks})}if(g){const{startPTS:v,endPTS:x,startDTS:D,endDTS:L}=g;u&&(u.elementaryStreams[Ue.AUDIO]={startPTS:v,endPTS:x,startDTS:D,endDTS:L}),c.setElementaryStreamInfo(Ue.AUDIO,v,x,D,L),this.bufferFragmentData(g,c,u,n)}if(m!=null&&(t=m.samples)!=null&&t.length){const v=Ne({id:i,frag:c,details:f},m);s.trigger(y.FRAG_PARSING_METADATA,v)}if(I){const v=Ne({id:i,frag:c,details:f},I);s.trigger(y.FRAG_PARSING_USERDATA,v)}}_bufferInitSegment(e,t,i,s){if(this.state!==j.PARSING||(t.video&&delete t.video,t.audiovideo&&delete t.audiovideo,!t.audio))return;const r=t.audio;r.id=he.AUDIO;const n=e.audioCodec;this.log(`Init audio buffer, container:${r.container}, codecs[level/parsed]=[${n}/${r.codec}]`),n&&n.split(",").length===1&&(r.levelCodec=n),this.hls.trigger(y.BUFFER_CODECS,t);const o=r.initSegment;if(o!=null&&o.byteLength){const c={type:"audio",frag:i,part:null,chunkMeta:s,parent:i.type,data:o};this.hls.trigger(y.BUFFER_APPENDING,c)}this.tickImmediate()}loadFragment(e,t,i){const s=this.fragmentTracker.getState(e);if(this.switchingTrack||s===Qe.NOT_LOADED||s===Qe.PARTIAL){var r;if(!qe(e))this._loadInitSegment(e,t);else if((r=t.details)!=null&&r.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=j.WAITING_INIT_PTS;const n=this.mainDetails;n&&n.fragmentStart!==t.details.fragmentStart&&Ms(t.details,n)}else super.loadFragment(e,t,i)}else this.clearTrackerIfNeeded(e)}flushAudioIfNeeded(e){if(this.media&&this.bufferedTrack){const{name:t,lang:i,assocLang:s,characteristics:r,audioCodec:n,channels:o}=this.bufferedTrack;Ii({name:t,lang:i,assocLang:s,characteristics:r,audioCodec:n,channels:o},e,Ci)||(xs(e.url,this.hls)?(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"),this.bufferedTrack=null):this.bufferedTrack=e)}}completeAudioSwitch(e){const{hls:t}=this;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(y.AUDIO_TRACK_SWITCHED,Be({},e))}}class en extends Tt{constructor(e,t){super(t,e.logger),this.hls=void 0,this.canLoad=!1,this.timer=-1,this.hls=e}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){this.timer!==-1&&(self.clearTimeout(this.timer),this.timer=-1)}startLoad(){this.canLoad=!0,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(e,t,i){const s=t?.renditionReports;if(s){let r=-1;for(let n=0;n<s.length;n++){const o=s[n];let c;try{c=new self.URL(o.URI,t.url).href}catch(u){this.warn(`Could not construct new URL for Rendition Report: ${u}`),c=o.URI||""}if(c===e){r=n;break}else c===e.substring(0,c.length)&&(r=n)}if(r!==-1){const n=s[r],o=parseInt(n["LAST-MSN"])||t.lastPartSn;let c=parseInt(n["LAST-PART"])||t.lastPartIndex;if(this.hls.config.lowLatencyMode){const h=Math.min(t.age-t.partTarget,t.targetduration);c>=0&&h>t.partTarget&&(c+=1)}const u=i&&Ca(i);return new ya(o,c>=0?c:void 0,u)}}}loadPlaylist(e){this.clearTimer()}loadingPlaylist(e,t){this.clearTimer()}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}getUrlWithDirectives(e,t){if(t)try{return t.addDirectives(e)}catch(i){this.warn(`Could not construct new URL with HLS Delivery Directives: ${i}`)}return e}playlistLoaded(e,t,i){const{details:s,stats:r}=t,n=self.performance.now(),o=r.loading.first?Math.max(0,n-r.loading.first):0;s.advancedDateTime=Date.now()-o;const c=this.hls.config.timelineOffset;if(c!==s.appliedTimelineOffset){const h=Math.max(c||0,0);s.appliedTimelineOffset=h,s.fragments.forEach(f=>{f.setStart(f.playlistOffset+h)})}if(s.live||i!=null&&i.live){const h="levelInfo"in t?t.levelInfo:t.track;if(s.reloaded(i),i&&s.fragments.length>0){Wc(i,s,this);const D=s.playlistParsingError;if(D){this.warn(D);const L=this.hls;if(!L.config.ignorePlaylistParsingErrors){var u;const{networkDetails:w}=t;L.trigger(y.ERROR,{type:de.NETWORK_ERROR,details:U.LEVEL_PARSING_ERROR,fatal:!1,url:s.url,error:D,reason:D.message,level:t.level||void 0,parent:(u=s.fragments[0])==null?void 0:u.type,networkDetails:w,stats:r});return}s.playlistParsingError=null}}s.requestScheduled===-1&&(s.requestScheduled=r.loading.start);const f=this.hls.mainForwardBufferInfo,g=f?f.end-f.len:0,I=(s.edge-g)*1e3,m=so(s,I);if(s.requestScheduled+m<n?s.requestScheduled=n:s.requestScheduled+=m,this.log(`live playlist ${e} ${s.advanced?"REFRESHED "+s.lastPartSn+"-"+s.lastPartIndex:s.updated?"UPDATED":"MISSED"}`),!this.canLoad||!s.live)return;let E,v,x;if(s.canBlockReload&&s.endSN&&s.advanced){const D=this.hls.config.lowLatencyMode,L=s.lastPartSn,w=s.endSN,N=s.lastPartIndex,K=N!==-1,p=L===w;K?p?(v=w+1,x=D?0:N):(v=L,x=D?N+1:s.maxPartIndex):v=w+1;const $=s.age,F=$+s.ageHeader;let O=Math.min(F-s.partTarget,s.targetduration*1.5);if(O>0){if(F>s.targetduration*3)this.log(`Playlist last advanced ${$.toFixed(2)}s ago. Omitting segment and part directives.`),v=void 0,x=void 0;else if(i!=null&&i.tuneInGoal&&F-s.partTarget>i.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${i.tuneInGoal} to: ${O} with playlist age: ${s.age}`),O=0;else{const W=Math.floor(O/s.targetduration);if(v+=W,x!==void 0){const ie=Math.round(O%s.targetduration/s.partTarget);x+=ie}this.log(`CDN Tune-in age: ${s.ageHeader}s last advanced ${$.toFixed(2)}s goal: ${O} skip sn ${W} to part ${x}`)}s.tuneInGoal=O}if(E=this.getDeliveryDirectives(s,t.deliveryDirectives,v,x),D||!p){s.requestScheduled=n,this.loadingPlaylist(h,E);return}}else(s.canBlockReload||s.canSkipUntil)&&(E=this.getDeliveryDirectives(s,t.deliveryDirectives,v,x));E&&v!==void 0&&s.canBlockReload&&(s.requestScheduled=r.loading.first+Math.max(m-o*2,m/2)),this.scheduleLoading(h,E,s)}else this.clearTimer()}scheduleLoading(e,t,i){const s=i||e.details;if(!s){this.loadingPlaylist(e,t);return}const r=self.performance.now(),n=s.requestScheduled;if(r>=n){this.loadingPlaylist(e,t);return}const o=n-r;this.log(`reload live playlist ${e.name||e.bitrate+"bps"} in ${Math.round(o)} ms`),this.clearTimer(),this.timer=self.setTimeout(()=>this.loadingPlaylist(e,t),o)}getDeliveryDirectives(e,t,i,s){let r=Ca(e);return t!=null&&t.skip&&e.deltaUpdateFailed&&(i=t.msn,s=t.part,r=Ss.No),new ya(i,s,r)}checkRetry(e){const t=e.details,i=bs(e),s=e.errorAction,{action:r,retryCount:n=0,retryConfig:o}=s||{},c=!!s&&!!o&&(r===rt.RetryRequest||!s.resolved&&r===rt.SendAlternateToPenaltyBox);if(c){var u;if(n>=o.maxNumRetry)return!1;if(i&&(u=e.context)!=null&&u.deliveryDirectives)this.warn(`Retrying playlist loading ${n+1}/${o.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{const h=br(o,n);this.clearTimer(),this.timer=self.setTimeout(()=>this.loadPlaylist(),h),this.warn(`Retrying playlist loading ${n+1}/${o.maxNumRetry} after "${t}" in ${h}ms`)}e.levelRetry=!0,s.resolved=!0}return c}}function Go(a,e){if(a.length!==e.length)return!1;for(let t=0;t<a.length;t++)if(!ns(a[t].attrs,e[t].attrs))return!1;return!0}function ns(a,e,t){const i=a["STABLE-RENDITION-ID"];return i&&!t?i===e["STABLE-RENDITION-ID"]:!(t||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).some(s=>a[s]!==e[s])}function tn(a,e){return e.label.toLowerCase()===a.name.toLowerCase()&&(!e.language||e.language.toLowerCase()===(a.lang||"").toLowerCase())}class td extends en{constructor(e){super(e,"audio-track-controller"),this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){const{hls:e}=this;e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_PARSED,this.onManifestParsed,this),e.on(y.LEVEL_LOADING,this.onLevelLoading,this),e.on(y.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(y.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(y.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_PARSED,this.onManifestParsed,this),e.off(y.LEVEL_LOADING,this.onLevelLoading,this),e.off(y.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(y.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(y.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.tracksInGroup=[],this.groupIds=null,this.currentTrack=null,this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.audioTracks||[]}onAudioTrackLoaded(e,t){const{id:i,groupId:s,details:r}=t,n=this.tracksInGroup[i];if(!n||n.groupId!==s){this.warn(`Audio track with id:${i} and group:${s} not found in active group ${n?.groupId}`);return}const o=n.details;n.details=t.details,this.log(`Audio track ${i} "${n.name}" lang:${n.lang} group:${s} loaded [${r.startSN}-${r.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(!t)return;const i=t.audioGroups||null,s=this.groupIds;let r=this.currentTrack;if(!i||s?.length!==i?.length||i!=null&&i.some(o=>s?.indexOf(o)===-1)){this.groupIds=i,this.trackId=-1,this.currentTrack=null;const o=this.tracks.filter(g=>!i||i.indexOf(g.groupId)!==-1);if(o.length)this.selectDefaultTrack&&!o.some(g=>g.default)&&(this.selectDefaultTrack=!1),o.forEach((g,I)=>{g.id=I});else if(!r&&!this.tracksInGroup.length)return;this.tracksInGroup=o;const c=this.hls.config.audioPreference;if(!r&&c){const g=Ft(c,o,Ci);if(g>-1)r=o[g];else{const I=Ft(c,this.tracks);r=this.tracks[I]}}let u=this.findTrackId(r);u===-1&&r&&(u=this.findTrackId(null));const h={audioTracks:o};this.log(`Updating audio tracks, ${o.length} track(s) found in group(s): ${i?.join(",")}`),this.hls.trigger(y.AUDIO_TRACKS_UPDATED,h);const f=this.trackId;if(u!==-1&&f===-1)this.setAudioTrack(u);else if(o.length&&f===-1){var n;const g=new Error(`No audio track selected for current audio group-ID(s): ${(n=this.groupIds)==null?void 0:n.join(",")} track count: ${o.length}`);this.warn(g.message),this.hls.trigger(y.ERROR,{type:de.MEDIA_ERROR,details:U.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:g})}}}onError(e,t){t.fatal||!t.context||t.context.type===be.AUDIO_TRACK&&t.context.id===this.trackId&&(!this.groupIds||this.groupIds.indexOf(t.context.groupId)!==-1)&&this.checkRetry(t)}get allAudioTracks(){return this.tracks}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}setAudioOption(e){const t=this.hls;if(t.config.audioPreference=e,e){const i=this.allAudioTracks;if(this.selectDefaultTrack=!1,i.length){const s=this.currentTrack;if(s&&Ii(e,s,Ci))return s;const r=Ft(e,this.tracksInGroup,Ci);if(r>-1){const n=this.tracksInGroup[r];return this.setAudioTrack(r),n}else if(s){let n=t.loadLevel;n===-1&&(n=t.firstAutoLevel);const o=hc(e,t.levels,i,n,Ci);if(o===-1)return null;t.nextLoadLevel=o}if(e.channels||e.audioCodec){const n=Ft(e,i);if(n>-1)return i[n]}}}return null}setAudioTrack(e){const t=this.tracksInGroup;if(e<0||e>=t.length){this.warn(`Invalid audio track id: ${e}`);return}this.selectDefaultTrack=!1;const i=this.currentTrack,s=t[e],r=s.details&&!s.details.live;if(e===this.trackId&&s===i&&r||(this.log(`Switching to audio-track ${e} "${s.name}" lang:${s.lang} group:${s.groupId} channels:${s.channels}`),this.trackId=e,this.currentTrack=s,this.hls.trigger(y.AUDIO_TRACK_SWITCHING,Be({},s)),r))return;const n=this.switchParams(s.url,i?.details,s.details);this.loadPlaylist(n)}findTrackId(e){const t=this.tracksInGroup;for(let i=0;i<t.length;i++){const s=t[i];if(!(this.selectDefaultTrack&&!s.default)&&(!e||Ii(e,s,Ci)))return i}if(e){const{name:i,lang:s,assocLang:r,characteristics:n,audioCodec:o,channels:c}=e;for(let u=0;u<t.length;u++){const h=t[u];if(Ii({name:i,lang:s,assocLang:r,characteristics:n,audioCodec:o,channels:c},h,Ci))return u}for(let u=0;u<t.length;u++){const h=t[u];if(ns(e.attrs,h.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return u}for(let u=0;u<t.length;u++){const h=t[u];if(ns(e.attrs,h.attrs,["LANGUAGE"]))return u}}return-1}loadPlaylist(e){super.loadPlaylist();const t=this.currentTrack;this.shouldLoadPlaylist(t)&&xs(t.url,this.hls)&&this.scheduleLoading(t,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);const i=e.id,s=e.groupId,r=this.getUrlWithDirectives(e.url,t),n=e.details,o=n?.age;this.log(`Loading audio-track ${i} "${e.name}" lang:${e.lang} group:${s}${t?.msn!==void 0?" at sn "+t.msn+" part "+t.part:""}${o&&n.live?" age "+o.toFixed(1)+(n.type&&" "+n.type||""):""} ${r}`),this.hls.trigger(y.AUDIO_TRACK_LOADING,{url:r,id:i,groupId:s,deliveryDirectives:t||null,track:e})}}class id{constructor(e){this.tracks=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.tracks=e}destroy(){this.tracks=this.queues=null}append(e,t,i){if(this.queues===null||this.tracks===null)return;const s=this.queues[t];s.push(e),s.length===1&&!i&&this.executeNext(t)}appendBlocker(e){return new Promise(t=>{const i={label:"async-blocker",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.append(i,e)})}prependBlocker(e){return new Promise(t=>{if(this.queues){const i={label:"async-blocker-prepend",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.queues[e].unshift(i)}})}removeBlockers(){this.queues!==null&&[this.queues.video,this.queues.audio,this.queues.audiovideo].forEach(e=>{var t;const i=(t=e[0])==null?void 0:t.label;(i==="async-blocker"||i==="async-blocker-prepend")&&(e[0].execute(),e.splice(0,1))})}unblockAudio(e){if(this.queues===null)return;this.queues.audio[0]===e&&this.shiftAndExecuteNext("audio")}executeNext(e){if(this.queues===null||this.tracks===null)return;const t=this.queues[e];if(t.length){const s=t[0];try{s.execute()}catch(r){var i;if(s.onError(r),this.queues===null||this.tracks===null)return;const n=(i=this.tracks[e])==null?void 0:i.buffer;n!=null&&n.updating||this.shiftAndExecuteNext(e)}}}shiftAndExecuteNext(e){this.queues!==null&&(this.queues[e].shift(),this.executeNext(e))}current(e){var t;return((t=this.queues)==null?void 0:t[e][0])||null}toString(){const{queues:e,tracks:t}=this;return e===null||t===null?"<destroyed>":`
20
+ accurateTimeOffset: ${l}
21
+ timeOffset: ${C}
22
+ initSegmentChange: ${N}`);const W=new eg(i,s,t,o,h);this.configureTransmuxer(W)}if(this.frag=n,this.part=a,this.workerContext)this.workerContext.worker.postMessage({instanceNo:m,cmd:"demux",data:e,decryptdata:v,chunkMeta:u,state:O},e instanceof ArrayBuffer?[e]:[]);else if(A){const W=A.push(e,v,u,O);Rs(W)?W.then(q=>{this.handleTransmuxComplete(q)}).catch(q=>{this.transmuxerError(q,u,"transmuxer-interface push error")}):this.handleTransmuxComplete(W)}}flush(e){e.transmuxing.start=self.performance.now();const{instanceNo:t,transmuxer:i}=this;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:t,cmd:"flush",chunkMeta:e});else if(i){const s=i.flush(e);Rs(s)?s.then(n=>{this.handleFlushResult(n,e)}).catch(n=>{this.transmuxerError(n,e,"transmuxer-interface flush error")}):this.handleFlushResult(s,e)}}transmuxerError(e,t,i){this.hls&&(this.error=e,this.hls.trigger(E.ERROR,{type:me.MEDIA_ERROR,details:U.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,part:this.part||void 0,fatal:!1,error:e,err:e,reason:i}))}handleFlushResult(e,t){e.forEach(i=>{this.handleTransmuxComplete(i)}),this.onFlush(t)}configureTransmuxer(e){const{instanceNo:t,transmuxer:i}=this;this.workerContext?this.workerContext.worker.postMessage({instanceNo:t,cmd:"configure",config:e}):i&&i.configure(e)}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}}const Zl=100;class ig extends Er{constructor(e,t,i){super(e,t,i,"audio-stream-controller",ge.AUDIO),this.mainAnchor=null,this.mainFragLoading=null,this.audioOnly=!1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.nextTrackId=-1,this.waitingData=null,this.mainDetails=null,this.flushing=!1,this.bufferFlushed=!1,this.cachedTrackLoadedData=null,this.registerListeners()}onHandlerDestroying(){this.unregisterListeners(),super.onHandlerDestroying(),this.resetItem()}resetItem(){this.mainDetails=this.mainAnchor=this.mainFragLoading=this.bufferedTrack=this.switchingTrack=this.waitingData=this.cachedTrackLoadedData=null}registerListeners(){super.registerListeners();const{hls:e}=this;e.on(E.LEVEL_LOADED,this.onLevelLoaded,this),e.on(E.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(E.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(E.BUFFER_RESET,this.onBufferReset,this),e.on(E.BUFFER_CREATED,this.onBufferCreated,this),e.on(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(E.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(E.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(E.FRAG_LOADING,this.onFragLoading,this),e.on(E.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){const{hls:e}=this;e&&(super.unregisterListeners(),e.off(E.LEVEL_LOADED,this.onLevelLoaded,this),e.off(E.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(E.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(E.BUFFER_RESET,this.onBufferReset,this),e.off(E.BUFFER_CREATED,this.onBufferCreated,this),e.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(E.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(E.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(E.FRAG_LOADING,this.onFragLoading,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this))}onInitPtsFound(e,t){const{frag:i,id:s,initPTS:n,timescale:a,trackId:o,timestampOffsets:l}=t;if(s===ge.MAIN){const u=i.cc,h=this.fragCurrent;if(this.initPTS=l,this.log(`InitPTS for cc: ${u} found from main: ${n/a} (${n}/${a}) trackId: ${o}`),this.mainAnchor=i,this.state===Y.WAITING_INIT_PTS){const d=this.waitingData;(!d&&!this.loadingParts||d&&d.frag.cc!==u)&&this.syncWithAnchor(i,d?.frag)}else!this.hls.hasEnoughToStart&&h&&h.cc!==u?(h.abortRequests(),this.syncWithAnchor(i,h)):this.state===Y.IDLE&&this.tick()}}getLoadPosition(){var e;return!this.startFragRequested&&this.nextLoadPosition>=0&&((e=this.switchingTrack)==null?void 0:e.flushImmediate)!==!1?this.nextLoadPosition:super.getLoadPosition()}syncWithAnchor(e,t){var i;const s=((i=this.mainFragLoading)==null?void 0:i.frag)||null;if(t&&s?.cc===t.cc)return;const n=(s||e).cc,a=this.getLevelDetails(),o=this.getLoadPosition(),l=Oo(a,n,o);l&&(this.log(`Syncing with main frag at ${l.start} cc ${l.cc}`),this.startFragRequested=!1,this.nextLoadPosition=l.start,this.resetLoadingState(),this.state===Y.IDLE&&this.doTickIdle())}startLoad(e,t){if(!this.levels){this.startPosition=e,this.state=Y.STOPPED;return}const i=this.lastCurrentTime;this.stopLoad(),this.setInterval(Zl),i>0&&e===-1&&!t&&this.initPTS.length&&(this.log(`Override startPosition with lastCurrentTime @${i.toFixed(3)}`),e=i),this.state=Y.IDLE,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,!t&&!this.fragmentTracker.hasFragments(this.playlistType)&&(this.startFragRequested=!1),this.tick()}doTick(){switch(this.state){case Y.IDLE:this.doTickIdle();break;case Y.WAITING_TRACK:{const{levels:e,trackId:t}=this,i=e?.[t],s=i?.details;if(s&&!this.waitForLive(i)){if(this.waitForCdnTuneIn(s))break;this.state=Y.WAITING_INIT_PTS}break}case Y.FRAG_LOADING_WAITING_RETRY:{this.checkRetryDate();break}case Y.WAITING_INIT_PTS:{const e=this.waitingData;if(e){const{frag:t,part:i,cache:s,complete:n}=e,a=this.mainAnchor;if(this.initPTS[t.cc]!==void 0){this.waitingData=null,this.state=Y.FRAG_LOADING;const o=s.flush().buffer,l={frag:t,part:i,payload:o,networkDetails:null};this._handleFragmentLoadProgress(l),n&&super._handleFragmentLoadComplete(l)}else a&&a.cc!==e.frag.cc&&this.syncWithAnchor(a,e.frag)}else this.state=Y.IDLE}}this.onTickEnd()}resetLoadingState(){const e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null),super.resetLoadingState()}onTickEnd(){const{media:e}=this;e!=null&&e.readyState&&(this.lastCurrentTime=e.currentTime,this.checkFragmentChanged())}doTickIdle(){var e;const{hls:t,levels:i,media:s,trackId:n}=this,a=t.config;if(!this.buffering||!s&&!this.primaryPrefetch&&(this.startFragRequested||!a.startFragPrefetch)||!(i!=null&&i[n]))return;const o=i[n],l=o.details;if(!l||this.waitForLive(o)||this.waitForCdnTuneIn(l)){this.state=Y.WAITING_TRACK,this.startFragRequested=!1;return}const u=this.getBufferOutput();this.bufferFlushed&&u&&(this.bufferFlushed=!1,this.afterBufferFlushed(u,ze.AUDIO));const h=this.getFwdBufferInfo();if(h===null)return;if(!this.switchingTrack&&this._streamEnded(h,l)){t.trigger(E.BUFFER_EOS,{type:"audio"}),this.state=Y.ENDED;return}const d=h.len,g=t.maxBufferLength,m=l.fragments,A=m[0].start,C=this.getLoadPosition(),v=this.flushing||this.switchingTrack&&!this.switchingTrack.flushImmediate?C:h.end;if(this.switchingTrack&&s){const b=C;l.PTSKnown&&b<A&&b>=this.timelineOffset&&(h.end>A||h.nextStart)&&(this.log(`Alt audio track ahead of main track, seek to start of alt audio track ${b} -> ${A} + 0.05`),s.currentTime=A+.05)}if(d>=g&&!this.switchingTrack&&v<m[m.length-1].start)return;let S=this.getNextFragment(v,l);if(S&&this.isLoopLoading(S,v)&&(S=this.getNextFragmentLoopLoading(S,l,h,ge.MAIN,g)),!S){this.bufferFlushed=!0;return}if(this.exceedsMaxBuffer(h,g,S))return;let R=((e=this.mainFragLoading)==null?void 0:e.frag)||null;if(!this.audioOnly&&this.startFragRequested&&R&&st(S)&&!S.endList&&(!l.live||!this.loadingParts&&v<this.hls.liveSyncPosition)&&(this.fragmentTracker.getState(R)===et.OK&&(this.mainFragLoading=R=null),R&&st(R))){if(S.start>R.end){const D=this.fragmentTracker.getFragAtPos(v,ge.MAIN);D&&D.end>R.end&&(R=D,this.mainFragLoading={frag:D,targetBufferTime:null})}if(S.start>R.end)return}this.loadFragment(S,o,v)}onMediaDetaching(e,t){this.bufferFlushed=this.flushing=!1,super.onMediaDetaching(e,t)}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(i=>new Is(i))}onAudioTrackSwitching(e,t){const i=!!t.url;this.trackId=t.id;const{fragCurrent:s}=this;s&&(s.abortRequests(),this.removeUnbufferedFrags(s.start)),this.resetLoadingState(),i?(this.switchingTrack=t,t.flushImmediate||(this.nextTrackId=t.id,this.nextLevelSwitch()),this.flushAudioIfNeeded(t),this.state!==Y.STOPPED&&(this.setInterval(Zl),this.state=Y.IDLE,this.tick())):(this.resetTransmuxer(),this.switchingTrack=null,this.bufferedTrack=t,this.clearInterval())}onManifestLoading(){super.onManifestLoading(),this.bufferFlushed=this.flushing=this.audioOnly=!1,this.resetItem(),this.trackId=-1}onLevelLoaded(e,t){this.mainDetails=t.details;const i=this.cachedTrackLoadedData;i&&(this.cachedTrackLoadedData=null,this.onAudioTrackLoaded(E.AUDIO_TRACK_LOADED,i))}onAudioTrackLoaded(e,t){var i;const{levels:s}=this,{details:n,id:a,groupId:o,track:l}=t;if(!s){this.warn(`Audio tracks reset while loading track ${a} "${l.name}" of "${o}"`);return}const u=this.mainDetails;if(!u||n.endCC>u.endCC||u.expired){this.cachedTrackLoadedData=t,this.state!==Y.STOPPED&&(this.state=Y.WAITING_TRACK);return}this.cachedTrackLoadedData=null,this.log(`Audio track ${a} "${l.name}" of "${o}" loaded [${n.startSN},${n.endSN}]${n.lastPartSn?`[part-${n.lastPartSn}-${n.lastPartIndex}]`:""},duration:${n.totalduration}`);const h=s[a];let d=0;if(n.live||(i=h.details)!=null&&i.live){if(this.checkLiveUpdate(n),n.deltaUpdateFailed)return;if(h.details){var g;d=this.alignPlaylists(n,h.details,(g=this.levelLastLoaded)==null?void 0:g.details)}n.alignedSliding||(cn(u,n,this),d=n.fragmentStart)}h.details=n,this.levelLastLoaded=h,this.startFragRequested||this.setStartPosition(u,d),this.hls.trigger(E.AUDIO_TRACK_UPDATED,{details:n,id:a,groupId:t.groupId}),this.state===Y.WAITING_TRACK&&!this.waitForCdnTuneIn(n)&&(this.state=Y.IDLE),this.tick()}_handleFragmentLoadProgress(e){var t;const i=e.frag,{part:s,payload:n}=e,{config:a,trackId:o,levels:l}=this;if(!l){this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);return}const u=l[o];if(!u){this.warn("Audio track is undefined on fragment load progress");return}const h=u.details;if(!h){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(i.start);return}const d=a.defaultAudioCodec||u.audioCodec||"mp4a.40.2";let g=this.transmuxer;g||(g=this.transmuxer=new Xl(this.hls,ge.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const m=this.initPTS[i.cc],A=(t=i.initSegment)==null?void 0:t.data;if(m!==void 0){const v=s?s.index:-1,S=v!==-1,R=new dr(i.level,i.sn,i.stats.chunkCount,n.byteLength,v,S,i.duration);g.push(n,A,d,"",i,s,h.totalduration,!1,R,m)}else{this.log(`Unknown video PTS for cc ${i.cc}, waiting for video PTS before demuxing audio frag ${i.sn} of [${h.startSN} ,${h.endSN}],track ${o}`);const{cache:C}=this.waitingData=this.waitingData||{frag:i,part:s,cache:new xl,complete:!1};C.push(new Uint8Array(n)),this.state!==Y.STOPPED&&(this.state=Y.WAITING_INIT_PTS)}}_handleFragmentLoadComplete(e){if(this.waitingData){this.waitingData.complete=!0;return}super._handleFragmentLoadComplete(e)}onBufferReset(){this.mediaBuffer=null}onBufferCreated(e,t){this.bufferFlushed=this.flushing=!1;const i=t.tracks.audio;i&&(this.mediaBuffer=i.buffer||null)}onFragLoading(e,t){!this.audioOnly&&t.frag.type===ge.MAIN&&st(t.frag)&&(this.mainFragLoading=t,this.state===Y.IDLE&&this.tick())}onFragBuffered(e,t){const{frag:i,part:s}=t;if(i.type!==ge.AUDIO){!this.audioOnly&&i.type===ge.MAIN&&!i.elementaryStreams.video&&!i.elementaryStreams.audiovideo&&(this.audioOnly=!0,this.mainFragLoading=null);return}if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${s?" p: "+s.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);return}if(st(i)){const n=this.switchingTrack;n&&(this.bufferedTrack=n)}this.fragBufferedComplete(i,s),this.media&&this.tick()}getFwdBufferInfo(){const e=this.getBufferOutput();return super.getFwdBufferInfo(e,ge.AUDIO)}getBufferOutput(){return this.mediaBuffer?this.mediaBuffer:this.media}checkFragmentChanged(){const e=this.fragPlaying;if(!this.checkFragPlaying())return!1;const i=this.fragPlaying,s=e?.level;return(!i||i.level!==s)&&(e&&this.cleanupBackBuffer(),this.switchingTrack&&this.completeAudioSwitch(this.switchingTrack)),!0}onError(e,t){var i;if(t.fatal){this.state=Y.ERROR;return}switch(t.details){case U.FRAG_GAP:case U.FRAG_PARSING_ERROR:case U.FRAG_DECRYPT_ERROR:case U.FRAG_LOAD_ERROR:case U.FRAG_LOAD_TIMEOUT:case U.KEY_LOAD_ERROR:case U.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(ge.AUDIO,t);break;case U.AUDIO_TRACK_LOAD_ERROR:case U.AUDIO_TRACK_LOAD_TIMEOUT:case U.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===Y.WAITING_TRACK&&((i=t.context)==null?void 0:i.type)===ke.AUDIO_TRACK&&(this.state=Y.IDLE);break;case U.BUFFER_APPEND_NO_PROGRESS:if(t.parent!=="audio")return;t.frag&&(t.appendsWithoutProgress||0)>=this.config.appendErrorMaxRetry&&(this.warn(`Marking fragment ${t.frag.sn} of track ${t.frag.level} as a gap after ${t.appendsWithoutProgress} appends without buffered range growth, to prevent loop loading`),this.fragmentTracker.addAsGap(t.frag));break;case U.BUFFER_ADD_CODEC_ERROR:case U.BUFFER_APPEND_ERROR:if(t.parent!=="audio")return;this.reduceLengthAndFlushBuffer(t)||this.resetLoadingState();break;case U.BUFFER_FULL_ERROR:if(t.parent!=="audio")return;this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case U.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onBufferFlushing(e,{type:t}){t!==ze.VIDEO&&(this.flushing=!0)}onBufferFlushed(e,{type:t}){if(t!==ze.VIDEO){this.flushing=!1,this.bufferFlushed=!0,this.state===Y.ENDED&&(this.state=Y.IDLE);const i=this.getBufferOutput();i&&(this.afterBufferFlushed(i,t),this.tick())}}_handleTransmuxComplete(e){var t;const i="audio",{hls:s}=this,{remuxResult:n,chunkMeta:a}=e,o=this.getCurrentContext(a);if(!o){this.resetWhenMissingContext(a);return}const{frag:l,part:u,level:h}=o,{details:d}=h,{audio:g,text:m,id3:A,initSegment:C}=n;if(this.fragContextChanged(l)||!d){this.fragmentTracker.removeFragment(l),C!=null&&C.tracks&&this.resetTransmuxer();return}if(this.state=Y.PARSING,g&&this.switchingTrack&&!this.switchingTrack.flushImmediate){const{config:v}=this,S=v.nextAudioTrackBufferFlushForwardOffset,R=Math.max(this.getLoadPosition()+S,l.start);super.flushMainBuffer(R,Number.POSITIVE_INFINITY,ge.AUDIO)}if(C!=null&&C.tracks){const v=l.initSegment||l;if(this.unhandledEncryptionError(C,l))return;this._bufferInitSegment(h,C.tracks,v,a),s.trigger(E.FRAG_PARSING_INIT_SEGMENT,{frag:v,id:i,tracks:C.tracks})}if(g){const{startPTS:v,endPTS:S,startDTS:R,endDTS:b}=g;u&&(u.elementaryStreams[ze.AUDIO]={startPTS:v,endPTS:S,startDTS:R,endDTS:b}),l.setElementaryStreamInfo(ze.AUDIO,v,S,R,b),this.bufferFragmentData(g,l,u,a)}if(A!=null&&(t=A.samples)!=null&&t.length){const v=je({id:i,frag:l,details:d},A);s.trigger(E.FRAG_PARSING_METADATA,v)}if(m){const v=je({id:i,frag:l,details:d},m);s.trigger(E.FRAG_PARSING_USERDATA,v)}}_bufferInitSegment(e,t,i,s){if(this.state!==Y.PARSING||(t.video&&delete t.video,t.audiovideo&&delete t.audiovideo,!t.audio))return;const n=t.audio;n.id=ge.AUDIO;const a=e.audioCodec;this.log(`Init audio buffer, container:${n.container}, codecs[level/parsed]=[${a}/${n.codec}]`),a?.split(",").length===1&&(n.levelCodec=a),this.hls.trigger(E.BUFFER_CODECS,t);const o=n.initSegment;if(o!=null&&o.byteLength){const l={type:"audio",frag:i,part:null,chunkMeta:s,parent:i.type,data:o};this.hls.trigger(E.BUFFER_APPENDING,l)}this.tickImmediate()}loadFragment(e,t,i){const s=this.fragmentTracker.getState(e);if(this.switchingTrack||s===et.NOT_LOADED||s===et.PARTIAL){var n;if((n=t.details)!=null&&n.live&&!this.initPTS[e.cc]){this.log(`Waiting for video PTS in continuity counter ${e.cc} of live stream before loading audio fragment ${e.sn} of level ${this.trackId}`),this.state=Y.WAITING_INIT_PTS;const a=this.mainDetails;a&&a.fragmentStart!==t.details.fragmentStart&&cn(a,t.details,this)}else super.loadFragment(e,t,i)}else this.clearTrackerIfNeeded(e)}flushAudioIfNeeded(e){if(this.media&&this.bufferedTrack&&e.flushImmediate){const{name:t,lang:i,assocLang:s,characteristics:n,audioCodec:a,channels:o}=this.bufferedTrack;wi({name:t,lang:i,assocLang:s,characteristics:n,audioCodec:a,channels:o},e,Mi)||(sn(e.url,this.hls)?(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"),this.bufferedTrack=null):this.bufferedTrack=e)}}completeAudioSwitch(e){const{hls:t}=this;this.bufferedTrack=e,this.switchingTrack=null,t.trigger(E.AUDIO_TRACK_SWITCHED,Ae({},e))}get nextAudioTrack(){return this.nextTrackId}}class wr extends wt{constructor(e,t){super(t,e.logger),this.hls=void 0,this.canLoad=!1,this.timer=-1,this.loadingSync=!1,this.hls=e}destroy(){this.clearTimer(),this.hls=null}clearTimer(){this.timer!==-1&&(self.clearTimeout(this.timer),this.timer=-1)}startLoad(){this.canLoad=!0,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(e,t,i){const s=t?.renditionReports;if(s){let n=-1;for(let a=0;a<s.length;a++){const o=s[a];let l;try{l=new self.URL(o.URI,t.url).href}catch(u){this.warn(`Could not construct new URL for Rendition Report: ${u}`),l=o.URI||""}if(l===e){n=a;break}else l===e.substring(0,l.length)&&(n=a)}if(n!==-1){const a=s[n],o=parseInt(a["LAST-MSN"])||t.lastPartSn;let l=parseInt(a["LAST-PART"])||t.lastPartIndex;if(this.hls.config.lowLatencyMode){const h=Math.min(t.age-t.partTarget,t.targetduration);l>=0&&h>t.partTarget&&(l+=1)}const u=i&&bo(i);return new Lo(o,l>=0?l:void 0,u)}}}loadPlaylist(e){this.clearTimer()}loadingPlaylist(e,t){this.clearTimer()}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}getUrlWithDirectives(e,t){if(t)try{return t.addDirectives(e)}catch(i){this.warn(`Could not construct new URL with HLS Delivery Directives: ${i}`)}return e}playlistLoaded(e,t,i){const{details:s,stats:n}=t,a=s.fragments,o=self.performance.now(),l=n.loading.first?Math.max(0,Math.floor(o-n.loading.first)):0;s.advancedDateTime=Date.now()-l;const u=this.hls.config.timelineOffset;if(u!==s.appliedTimelineOffset){const d=Math.max(u||0,0);s.appliedTimelineOffset=d,a.forEach(g=>{g?.setStart(g.playlistOffset+d)})}if(s.live||i!=null&&i.live){var h;const d="levelInfo"in t?t.levelInfo:t.track;s.reloaded(i);const g=(h=a[a.length-1])==null?void 0:h.type;if(s.misses>=this.hls.config.liveMaxUnchangedPlaylistRefresh){const _=new Error(`${g} playlist ${d.id} hit max allowed unchanged reloads.`);this.warn(_);const{networkDetails:M,context:p}=t;this.hls.trigger(E.ERROR,{type:me.NETWORK_ERROR,details:U.PLAYLIST_UNCHANGED_ERROR,fatal:!1,url:s.url,error:_,reason:_.message,level:t.level,parent:g,context:p,networkDetails:M,stats:n});return}if(i){zd(i,s,this);const _=s.playlistParsingError;if(_){this.warn(_);const M=this.hls;if(!M.config.ignorePlaylistParsingErrors){const{networkDetails:p}=t;M.trigger(E.ERROR,{type:me.NETWORK_ERROR,details:U.LEVEL_PARSING_ERROR,fatal:!1,url:s.url,error:_,reason:_.message,level:t.level,parent:g,networkDetails:p,stats:n});return}s.playlistParsingError=null}}s.requestScheduled===-1&&(s.requestScheduled=n.loading.start);const m=this.hls.mainForwardBufferInfo,A=m?m.end-m.len:0,C=(s.edge-A)*1e3,v=ml(s,C);s.requestScheduled+v<o?s.requestScheduled=o:s.requestScheduled<=o&&(s.requestScheduled+=v);const S=t.deliveryDirectives;if(this.log(`live playlist ${e} ${s.advanced?`REFRESHED ${s.lastPartSn} - ${s.lastPartIndex}`:s.updated?"UPDATED":`MISSED (received ${s.lastPartSn} - ${s.lastPartIndex}${S?` | requested ${S.msn} - ${S.part}`:""})`}`),!this.canLoad||!s.live)return;let R,b,D;if(s.canBlockReload&&s.advanced){const _=this.hls.config.lowLatencyMode,M=s.lastPartSn,p=s.endSN,$=s.lastPartIndex,N=$!==-1,O=M===p;N?O?(b=p+1,D=_?0:$):(b=M,D=_?$+1:s.maxPartIndex):b=p+1;const W=s.age,q=W+s.ageHeader;let z=Math.min(q-s.partTarget,s.targetduration*1.5);if(z>0){if(q>s.targetduration*3)this.log(`Playlist last advanced ${W.toFixed(2)}s ago. Omitting segment and part directives.`),b=void 0,D=void 0;else if(i!=null&&i.tuneInGoal&&q-s.partTarget>i.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${i.tuneInGoal} to: ${z} with playlist age: ${s.age}`),z=0;else{const oe=Math.floor(z/s.targetduration);if(b+=oe,D!==void 0){const ne=Math.round(z%s.targetduration/s.partTarget);D+=ne}this.log(`CDN Tune-in age: ${s.ageHeader}s last advanced ${W.toFixed(2)}s goal: ${z} skip sn ${oe} to part ${D}`)}s.tuneInGoal=z}if(R=this.getDeliveryDirectives(s,t.deliveryDirectives,b,D),_||!O){s.requestScheduled=o,this.loadingPlaylist(d,R);return}}else(s.canBlockReload||s.canSkipUntil)&&(R=this.getDeliveryDirectives(s,t.deliveryDirectives,b,D));R&&b!==void 0&&s.canBlockReload&&(s.requestScheduled=n.loading.first+Math.max(v-l*2,v/2)),this.scheduleLoading(d,R,s)}else this.clearTimer()}scheduleLoading(e,t,i){const s=i||e.details;if(!s){this.loadingPlaylist(e,t);return}const n=self.performance.now(),a=s.requestScheduled;if(n>=a&&!this.loadingSync){this.loadingSync=!0,this.loadingPlaylist(e,t),this.loadingSync=!1;return}const o=Math.max(a-n,0);this.log(`reload live playlist ${e.name||e.bitrate+"bps"} in ${Math.round(o)} ms`),this.clearTimer(),this.timer=self.setTimeout(()=>this.loadingPlaylist(e,t),o)}getDeliveryDirectives(e,t,i,s){let n=bo(e);return t!=null&&t.skip&&e.deltaUpdateFailed&&(i=t.msn,s=t.part,n=tn.No),new Lo(i,s,n)}checkRetry(e){const t=e.details,i=Vs(e),s=e.errorAction,{action:n,retryCount:a=0,retryConfig:o}=s||{},l=!!s&&!!o&&(n===gt.RetryRequest||!s.resolved&&n===gt.SendAlternateToPenaltyBox);if(l){var u;if(a>=o.maxNumRetry)return!1;if(i&&(u=e.context)!=null&&u.deliveryDirectives)this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{var h;const d=hs((h=e.response)==null?void 0:h.code);if(this.clearTimer(),d)this.log("Waiting for connection (offline)"),e.reason="offline",this.timer=self.setTimeout(()=>this.checkOfflineStatus(),1e3);else{const g=Wn(o,a);this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" in ${g}ms`),this.timer=self.setTimeout(()=>this.loadPlaylist(),g)}}e.levelRetry=!0,s.resolved=!0}return l}checkOfflineStatus(){this.clearTimer(),hs(0)?this.timer=self.setTimeout(()=>this.checkOfflineStatus(),1e3):(this.log("Connection restored (online)"),this.loadPlaylist())}}function Ql(r,e){if(r.length!==e.length)return!1;for(let t=0;t<r.length;t++)if(!Ds(r[t].attrs,e[t].attrs))return!1;return!0}function Ds(r,e,t){const i=r["STABLE-RENDITION-ID"];return i&&!t?i===e["STABLE-RENDITION-ID"]:!(t||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).some(s=>r[s]!==e[s])}class sg extends wr{constructor(e){super(e,"audio-track-controller"),this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){const{hls:e}=this;e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.LEVEL_LOADING,this.onLevelLoading,this),e.on(E.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(E.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(E.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.LEVEL_LOADING,this.onLevelLoading,this),e.off(E.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(E.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(E.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.tracksInGroup=[],this.groupIds=null,this.currentTrack=null,this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.audioTracks||[]}onAudioTrackLoaded(e,t){const{id:i,groupId:s,details:n}=t,a=this.tracksInGroup[i];if(!a||a.groupId!==s){this.warn(`Audio track with id:${i} and group:${s} not found in active group ${a?.groupId}`);return}const o=a.details;a.details=t.details,this.log(`Audio track ${i} "${a.name}" lang:${a.lang} group:${s} loaded [${n.startSN}-${n.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(!t)return;const i=t.audioGroups||null,s=this.groupIds;let n=this.currentTrack;if(!i||s?.length!==i?.length||i!=null&&i.some(o=>s?.indexOf(o)===-1)){this.groupIds=i,this.trackId=-1,this.currentTrack=null;const o=this.tracks.filter(g=>Cs(g.groupId,i));if(o.length)this.selectDefaultTrack&&!o.some(g=>g.default)&&(this.selectDefaultTrack=!1),o.forEach((g,m)=>{g.id=m});else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=o;const l=this.hls.config.audioPreference;if(!n&&l){const g=ii(l,o,Mi);if(g>-1)n=o[g];else{const m=ii(l,this.tracks);n=this.tracks[m]}}let u=this.findTrackId(n);u===-1&&n&&(u=this.findTrackId(null));const h={audioTracks:o};this.log(`Updating audio tracks, ${o.length} track(s) found in group(s): ${i?.join(",")}`),this.hls.trigger(E.AUDIO_TRACKS_UPDATED,h);const d=this.trackId;if(u!==-1&&d===-1)this.setAudioTrack(u);else if(o.length&&d===-1){var a;const g=new Error(`No audio track selected for current audio group-ID(s): ${(a=this.groupIds)==null?void 0:a.join(",")} track count: ${o.length}`);this.warn(g.message),this.hls.trigger(E.ERROR,{type:me.MEDIA_ERROR,details:U.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:g})}}}onError(e,t){t.fatal||!t.context||t.context.type===ke.AUDIO_TRACK&&t.context.id===this.trackId&&Cs(t.context.groupId,this.groupIds)&&this.checkRetry(t)}get allAudioTracks(){return this.tracks}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}get nextAudioTrack(){return this.trackId}set nextAudioTrack(e){this.selectDefaultTrack=!1,this.setAudioTrack(e,!1)}setAudioOption(e){const t=this.hls;if(t.config.audioPreference=e,e){const i=this.allAudioTracks;if(this.selectDefaultTrack=!1,i.length){const s=this.currentTrack;if(s&&wi(e,s,Mi))return s;const n=ii(e,this.tracksInGroup,Mi);if(n>-1){const a=this.tracksInGroup[n];return this.setAudioTrack(n,"flushImmediate"in e&&e.flushImmediate),a}else if(s){let a=t.loadLevel;a===-1&&(a=t.firstAutoLevel);const o=Id(e,t.levels,i,a,Mi);if(o===-1)return null;t.nextLoadLevel=o}if(e.channels||e.audioCodec){const a=ii(e,i);if(a>-1)return i[a]}}}return null}setAudioTrack(e,t=!0){const i=this.tracksInGroup;if(e<0||e>=i.length){this.warn(`Invalid audio track id: ${e}`);return}this.selectDefaultTrack=!1;const s=this.currentTrack,n=i[e],a=n.details&&!n.details.live;if(e===this.trackId&&n===s&&a||(this.log(`Switching to audio-track ${e} "${n.name}" lang:${n.lang} group:${n.groupId} channels:${n.channels}`),this.trackId=e,this.currentTrack=n,this.hls.trigger(E.AUDIO_TRACK_SWITCHING,Ae(Ae({},n),{},{flushImmediate:t})),a))return;const o=this.switchParams(n.url,s?.details,n.details);this.loadPlaylist(o)}findTrackId(e){const t=this.tracksInGroup;for(let i=0;i<t.length;i++){const s=t[i];if(!(this.selectDefaultTrack&&!s.default)&&(!e||wi(e,s,Mi)))return i}if(e){const{name:i,lang:s,assocLang:n,characteristics:a,audioCodec:o,channels:l}=e;for(let u=0;u<t.length;u++){const h=t[u];if(wi({name:i,lang:s,assocLang:n,characteristics:a,audioCodec:o,channels:l},h,Mi))return u}for(let u=0;u<t.length;u++){const h=t[u];if(Ds(e.attrs,h.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return u}for(let u=0;u<t.length;u++){const h=t[u];if(Ds(e.attrs,h.attrs,["LANGUAGE"]))return u}}return-1}loadPlaylist(e){super.loadPlaylist();const t=this.currentTrack;this.shouldLoadPlaylist(t)&&sn(t.url,this.hls)&&this.scheduleLoading(t,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);const i=e.id,s=e.groupId,n=this.getUrlWithDirectives(e.url,t),a=e.details,o=a?.age;this.log(`Loading audio-track ${i} "${e.name}" lang:${e.lang} group:${s}${t?.msn!==void 0?" at sn "+t.msn+" part "+t.part:""}${o&&a.live?" age "+o.toFixed(1)+(a.type&&" "+a.type||""):""} ${n}`),this.hls.trigger(E.AUDIO_TRACK_LOADING,{url:n,id:i,groupId:s,deliveryDirectives:t||null,track:e})}}class ng{constructor(e){this.tracks=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.tracks=e}destroy(){this.tracks=this.queues=null}append(e,t,i){if(this.queues===null||this.tracks===null)return;const s=this.queues[t];s.push(e),s.length===1&&!i&&this.executeNext(t)}appendBlocker(e){return new Promise(t=>{const i={label:"async-blocker",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.append(i,e)})}prependBlocker(e){return new Promise(t=>{if(this.queues){const i={label:"async-blocker-prepend",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.queues[e].unshift(i)}})}removeBlockers(){this.queues!==null&&[this.queues.video,this.queues.audio,this.queues.audiovideo].forEach(e=>{var t;const i=(t=e[0])==null?void 0:t.label;i==="async-blocker"||i==="async-blocker-prepend"?(e[0].execute(),e.splice(0,1)):i==="block-audio"&&e.splice(0,1)})}insertNext(e,t){this.queues!==null&&this.queues[t].splice(1,0,...e)}unblockAudio(){var e;this.queues!==null&&((e=this.current("audio"))==null?void 0:e.label)==="block-audio"&&this.shiftAndExecuteNext("audio")}audioBlocking(){return this.queues===null?!1:this.queues.audio.some(e=>e.label==="block-audio")}executeNext(e){if(this.queues===null||this.tracks===null)return;const t=this.queues[e];if(t.length){const s=t[0];try{s.execute()}catch(n){var i;if(s.onError(n),this.queues===null||this.tracks===null)return;const a=(i=this.tracks[e])==null?void 0:i.buffer;a!=null&&a.updating||this.shiftAndExecuteNext(e)}}}shiftAndExecuteNext(e){this.queues!==null&&(this.queues[e].shift(),this.executeNext(e))}current(e){var t;return((t=this.queues)==null?void 0:t[e][0])||null}toString(){const{queues:e,tracks:t}=this;return e===null||t===null?"<destroyed>":`
23
23
  ${this.list("video")}
24
24
  ${this.list("audio")}
25
- ${this.list("audiovideo")}}`}list(e){var t,i;return(t=this.queues)!=null&&t[e]||(i=this.tracks)!=null&&i[e]?`${e}: (${this.listSbInfo(e)}) ${this.listOps(e)}`:""}listSbInfo(e){var t;const i=(t=this.tracks)==null?void 0:t[e],s=i?.buffer;return s?`SourceBuffer${s.updating?" updating":""}${i.ended?" ended":""}${i.ending?" ending":""}`:"none"}listOps(e){var t;return((t=this.queues)==null?void 0:t[e].map(i=>i.label).join(", "))||""}}const Ho=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,Vo="HlsJsTrackRemovedError";class sd extends Error{constructor(e){super(e),this.name=Vo}}class rd extends Tt{constructor(e,t){super("buffer-controller",e.logger),this.hls=void 0,this.fragmentTracker=void 0,this.details=null,this._objectUrl=null,this.operationQueue=null,this.bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.blockedAudioAppend=null,this.lastVideoAppendEnd=0,this.appendSource=void 0,this.transferData=void 0,this.overrides=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.sourceBuffers=[[null,null],[null,null]],this._onEndStreaming=i=>{var s;this.hls&&((s=this.mediaSource)==null?void 0:s.readyState)==="open"&&this.hls.pauseBuffering()},this._onStartStreaming=i=>{this.hls&&this.hls.resumeBuffering()},this._onMediaSourceOpen=i=>{const{media:s,mediaSource:r}=this;i&&this.log("Media source opened"),!(!s||!r)&&(r.removeEventListener("sourceopen",this._onMediaSourceOpen),s.removeEventListener("emptied",this._onMediaEmptied),this.updateDuration(),this.hls.trigger(y.MEDIA_ATTACHED,{media:s,mediaSource:r}),this.mediaSource!==null&&this.checkPendingTracks())},this._onMediaSourceClose=()=>{this.log("Media source closed")},this._onMediaSourceEnded=()=>{this.log("Media source ended")},this._onMediaEmptied=()=>{const{mediaSrc:i,_objectUrl:s}=this;i!==s&&this.error(`Media element src was set while attaching MediaSource (${s} > ${i})`)},this.hls=e,this.fragmentTracker=t,this.appendSource=Lu(ri(e.config.preferManagedMediaSource)),this.initTracks(),this.registerListeners()}hasSourceTypes(){return Object.keys(this.tracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.transferData=this.overrides=void 0,this.operationQueue&&(this.operationQueue.destroy(),this.operationQueue=null),this.hls=this.fragmentTracker=null,this._onMediaSourceOpen=this._onMediaSourceClose=null,this._onMediaSourceEnded=null,this._onStartStreaming=this._onEndStreaming=null}registerListeners(){const{hls:e}=this;e.on(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_PARSED,this.onManifestParsed,this),e.on(y.BUFFER_RESET,this.onBufferReset,this),e.on(y.BUFFER_APPENDING,this.onBufferAppending,this),e.on(y.BUFFER_CODECS,this.onBufferCodecs,this),e.on(y.BUFFER_EOS,this.onBufferEos,this),e.on(y.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(y.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(y.FRAG_PARSED,this.onFragParsed,this),e.on(y.FRAG_CHANGED,this.onFragChanged,this),e.on(y.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_PARSED,this.onManifestParsed,this),e.off(y.BUFFER_RESET,this.onBufferReset,this),e.off(y.BUFFER_APPENDING,this.onBufferAppending,this),e.off(y.BUFFER_CODECS,this.onBufferCodecs,this),e.off(y.BUFFER_EOS,this.onBufferEos,this),e.off(y.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(y.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(y.FRAG_PARSED,this.onFragParsed,this),e.off(y.FRAG_CHANGED,this.onFragChanged,this),e.off(y.ERROR,this.onError,this)}transferMedia(){const{media:e,mediaSource:t}=this;if(!e)return null;const i={};if(this.operationQueue){const r=this.isUpdating();r||this.operationQueue.removeBlockers();const n=this.isQueued();(r||n)&&this.warn(`Transfering MediaSource with${n?" operations in queue":""}${r?" updating SourceBuffer(s)":""} ${this.operationQueue}`),this.operationQueue.destroy()}const s=this.transferData;return!this.sourceBufferCount&&s&&s.mediaSource===t?Ne(i,s.tracks):this.sourceBuffers.forEach(r=>{const[n]=r;n&&(i[n]=Ne({},this.tracks[n]),this.removeBuffer(n)),r[0]=r[1]=null}),{media:e,mediaSource:t,tracks:i}}initTracks(){const e={};this.sourceBuffers=[[null,null],[null,null]],this.tracks=e,this.resetQueue(),this.resetAppendErrors(),this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.lastVideoAppendEnd=0}onManifestLoading(){this.bufferCodecEventsTotal=0,this.details=null}onManifestParsed(e,t){var i;let s=2;(t.audio&&!t.video||!t.altAudio)&&(s=1),this.bufferCodecEventsTotal=s,this.log(`${s} bufferCodec event(s) expected.`),(i=this.transferData)!=null&&i.mediaSource&&this.sourceBufferCount&&s&&this.bufferCreated()}onMediaAttaching(e,t){const i=this.media=t.media;this.transferData=this.overrides=void 0;const s=ri(this.appendSource);if(s){const r=!!t.mediaSource;(r||t.overrides)&&(this.transferData=t,this.overrides=t.overrides);const n=this.mediaSource=t.mediaSource||new s;if(this.assignMediaSource(n),r)this._objectUrl=i.src,this.attachTransferred();else{const o=this._objectUrl=self.URL.createObjectURL(n);if(this.appendSource)try{i.removeAttribute("src");const c=self.ManagedMediaSource;i.disableRemotePlayback=i.disableRemotePlayback||c&&n instanceof c,Ko(i),nd(i,o),i.load()}catch{i.src=o}else i.src=o}i.addEventListener("emptied",this._onMediaEmptied)}}assignMediaSource(e){var t,i;this.log(`${((t=this.transferData)==null?void 0:t.mediaSource)===e?"transferred":"created"} media source: ${(i=e.constructor)==null?void 0:i.name}`),e.addEventListener("sourceopen",this._onMediaSourceOpen),e.addEventListener("sourceended",this._onMediaSourceEnded),e.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(e.addEventListener("startstreaming",this._onStartStreaming),e.addEventListener("endstreaming",this._onEndStreaming))}attachTransferred(){const e=this.media,t=this.transferData;if(!t||!e)return;const i=this.tracks,s=t.tracks,r=s?Object.keys(s):null,n=r?r.length:0,o=()=>{Promise.resolve().then(()=>{this.media&&this.mediaSourceOpenOrEnded&&this._onMediaSourceOpen()})};if(s&&r&&n){if(!this.tracksReady){this.hls.config.startFragPrefetch=!0,this.log("attachTransferred: waiting for SourceBuffer track info");return}if(this.log(`attachTransferred: (bufferCodecEventsTotal ${this.bufferCodecEventsTotal})
26
- required tracks: ${Ge(i,(c,u)=>c==="initSegment"?void 0:u)};
27
- transfer tracks: ${Ge(s,(c,u)=>c==="initSegment"?void 0:u)}}`),!Zn(s,i)){t.mediaSource=null,t.tracks=void 0;const c=e.currentTime,u=this.details,h=Math.max(c,u?.fragments[0].start||0);if(h-c>1){this.log(`attachTransferred: waiting for playback to reach new tracks start time ${c} -> ${h}`);return}this.warn(`attachTransferred: resetting MediaSource for incompatible tracks ("${Object.keys(s)}"->"${Object.keys(i)}") start time: ${h} currentTime: ${c}`),this.onMediaDetaching(y.MEDIA_DETACHING,{}),this.onMediaAttaching(y.MEDIA_ATTACHING,t),e.currentTime=h;return}this.transferData=void 0,r.forEach(c=>{const u=c,h=s[u];if(h){const f=h.buffer;if(f){const g=this.fragmentTracker,I=h.id;if(g.hasFragments(I)||g.hasParts(I)){const v=ye.getBuffered(f);g.detectEvictedFragments(u,v,I,null,!0)}const m=sn(u),E=[u,f];this.sourceBuffers[m]=E,f.updating&&this.operationQueue&&this.operationQueue.prependBlocker(u),this.trackSourceBuffer(u,h)}}}),o(),this.bufferCreated()}else this.log("attachTransferred: MediaSource w/o SourceBuffers"),o()}get mediaSourceOpenOrEnded(){var e;const t=(e=this.mediaSource)==null?void 0:e.readyState;return t==="open"||t==="ended"}onMediaDetaching(e,t){const i=!!t.transferMedia;this.transferData=this.overrides=void 0;const{media:s,mediaSource:r,_objectUrl:n}=this;if(r){if(this.log(`media source ${i?"transferring":"detaching"}`),i)this.sourceBuffers.forEach(([o])=>{o&&this.removeBuffer(o)}),this.resetQueue();else{if(this.mediaSourceOpenOrEnded){const o=r.readyState==="open";try{const c=r.sourceBuffers;for(let u=c.length;u--;)o&&c[u].abort(),r.removeSourceBuffer(c[u]);o&&r.endOfStream()}catch(c){this.warn(`onMediaDetaching: ${c.message} while calling endOfStream`)}}this.sourceBufferCount&&this.onBufferReset()}r.removeEventListener("sourceopen",this._onMediaSourceOpen),r.removeEventListener("sourceended",this._onMediaSourceEnded),r.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(r.removeEventListener("startstreaming",this._onStartStreaming),r.removeEventListener("endstreaming",this._onEndStreaming)),this.mediaSource=null,this._objectUrl=null}s&&(s.removeEventListener("emptied",this._onMediaEmptied),i||(n&&self.URL.revokeObjectURL(n),this.mediaSrc===n?(s.removeAttribute("src"),this.appendSource&&Ko(s),s.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null),this.hls.trigger(y.MEDIA_DETACHED,t)}onBufferReset(){this.sourceBuffers.forEach(([e])=>{e&&this.resetBuffer(e)}),this.initTracks()}resetBuffer(e){var t;const i=(t=this.tracks[e])==null?void 0:t.buffer;if(this.removeBuffer(e),i)try{var s;(s=this.mediaSource)!=null&&s.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(i)}catch(r){this.warn(`onBufferReset ${e}`,r)}delete this.tracks[e]}removeBuffer(e){this.removeBufferListeners(e),this.sourceBuffers[sn(e)]=[null,null];const t=this.tracks[e];t&&(t.buffer=void 0)}resetQueue(){this.operationQueue&&this.operationQueue.destroy(),this.operationQueue=new id(this.tracks)}onBufferCodecs(e,t){const i=this.tracks,s=Object.keys(t);this.log(`BUFFER_CODECS: "${s}" (current SB count ${this.sourceBufferCount})`);const r="audiovideo"in t&&(i.audio||i.video)||i.audiovideo&&("audio"in t||"video"in t),n=!r&&this.sourceBufferCount&&this.media&&s.some(o=>!i[o]);if(r||n){this.warn(`Unsupported transition between "${Object.keys(i)}" and "${s}" SourceBuffers`);return}s.forEach(o=>{var c,u;const h=t[o],{id:f,codec:g,levelCodec:I,container:m,metadata:E,supplemental:v}=h;let x=i[o];const D=(c=this.transferData)==null||(c=c.tracks)==null?void 0:c[o],L=D!=null&&D.buffer?D:x,w=L?.pendingCodec||L?.codec,N=L?.levelCodec;x||(x=i[o]={buffer:void 0,listeners:[],codec:g,supplemental:v,container:m,levelCodec:I,metadata:E,id:f});const K=vs(w,N),p=K?.replace(Ho,"$1");let $=vs(g,I);const F=(u=$)==null?void 0:u.replace(Ho,"$1");$&&K&&p!==F&&(o.slice(0,5)==="audio"&&($=Es($,this.appendSource)),this.log(`switching codec ${w} to ${$}`),$!==(x.pendingCodec||x.codec)&&(x.pendingCodec=$),x.container=m,this.appendChangeType(o,m,$))}),(this.tracksReady||this.sourceBufferCount)&&(t.tracks=this.sourceBufferTracks),!this.sourceBufferCount&&this.mediaSourceOpenOrEnded&&this.checkPendingTracks()}get sourceBufferTracks(){return Object.keys(this.tracks).reduce((e,t)=>{const i=this.tracks[t];return e[t]={id:i.id,container:i.container,codec:i.codec,levelCodec:i.levelCodec},e},{})}appendChangeType(e,t,i){const s=`${t};codecs=${i}`,r={label:`change-type=${s}`,execute:()=>{const n=this.tracks[e];if(n){const o=n.buffer;o!=null&&o.changeType&&(this.log(`changing ${e} sourceBuffer type to ${s}`),o.changeType(s),n.codec=i,n.container=t)}this.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:n=>{this.warn(`Failed to change ${e} SourceBuffer type`,n)}};this.append(r,e,this.isPending(this.tracks[e]))}blockAudio(e){var t;const i=e.start,s=i+e.duration*.05;if(((t=this.fragmentTracker.getAppendedFrag(i,he.MAIN))==null?void 0:t.gap)===!0)return;const n={label:"block-audio",execute:()=>{var o;const c=this.tracks.video;(this.lastVideoAppendEnd>s||c!=null&&c.buffer&&ye.isBuffered(c.buffer,s)||((o=this.fragmentTracker.getAppendedFrag(s,he.MAIN))==null?void 0:o.gap)===!0)&&(this.blockedAudioAppend=null,this.shiftAndExecuteNext("audio"))},onStart:()=>{},onComplete:()=>{},onError:o=>{this.warn("Error executing block-audio operation",o)}};this.blockedAudioAppend={op:n,frag:e},this.append(n,"audio",!0)}unblockAudio(){const{blockedAudioAppend:e,operationQueue:t}=this;e&&t&&(this.blockedAudioAppend=null,t.unblockAudio(e.op))}onBufferAppending(e,t){const{tracks:i}=this,{data:s,type:r,parent:n,frag:o,part:c,chunkMeta:u,offset:h}=t,f=u.buffering[r],{sn:g,cc:I}=o,m=self.performance.now();f.start=m;const E=o.stats.buffering,v=c?c.stats.buffering:null;E.start===0&&(E.start=m),v&&v.start===0&&(v.start=m);const x=i.audio;let D=!1;r==="audio"&&x?.container==="audio/mpeg"&&(D=!this.lastMpegAudioChunk||u.id===1||this.lastMpegAudioChunk.sn!==u.sn,this.lastMpegAudioChunk=u);const L=i.video,w=L?.buffer;if(w&&g!=="initSegment"){const p=c||o,$=this.blockedAudioAppend;if(r==="audio"&&n!=="main"&&!this.blockedAudioAppend&&!(L.ending||L.ended)){const O=p.start+p.duration*.05,W=w.buffered,ie=this.currentOp("video");!W.length&&!ie?this.blockAudio(p):!ie&&!ye.isBuffered(w,O)&&this.lastVideoAppendEnd<O&&this.blockAudio(p)}else if(r==="video"){const F=p.end;if($){const O=$.frag.start;(F>O||F<this.lastVideoAppendEnd||ye.isBuffered(w,O))&&this.unblockAudio()}this.lastVideoAppendEnd=F}}const N=(c||o).start,K={label:`append-${r}`,execute:()=>{var p;f.executeStart=self.performance.now();const $=(p=this.tracks[r])==null?void 0:p.buffer;$&&(D?this.updateTimestampOffset($,N,.1,r,g,I):h!==void 0&&se(h)&&this.updateTimestampOffset($,h,1e-6,r,g,I)),this.appendExecutor(s,r)},onStart:()=>{},onComplete:()=>{const p=self.performance.now();f.executeEnd=f.end=p,E.first===0&&(E.first=p),v&&v.first===0&&(v.first=p);const $={};this.sourceBuffers.forEach(([F,O])=>{F&&($[F]=ye.getBuffered(O))}),this.appendErrors[r]=0,r==="audio"||r==="video"?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger(y.BUFFER_APPENDED,{type:r,frag:o,part:c,chunkMeta:u,parent:o.type,timeRanges:$})},onError:p=>{var $;const F={type:de.MEDIA_ERROR,parent:o.type,details:U.BUFFER_APPEND_ERROR,sourceBufferName:r,frag:o,part:c,chunkMeta:u,error:p,err:p,fatal:!1},O=($=this.media)==null?void 0:$.error;if(p.code===DOMException.QUOTA_EXCEEDED_ERR||p.name=="QuotaExceededError"||"quota"in p)F.details=U.BUFFER_FULL_ERROR;else if(p.code===DOMException.INVALID_STATE_ERR&&this.mediaSourceOpenOrEnded&&!O)F.errorAction=_i(!0);else if(p.name===Vo&&this.sourceBufferCount===0)F.errorAction=_i(!0);else{const W=++this.appendErrors[r];this.warn(`Failed ${W}/${this.hls.config.appendErrorMaxRetry} times to append segment in "${r}" sourceBuffer (${O||"no media error"})`),(W>=this.hls.config.appendErrorMaxRetry||O)&&(F.fatal=!0)}this.hls.trigger(y.ERROR,F)}};this.append(K,r,this.isPending(this.tracks[r]))}getFlushOp(e,t,i){return this.log(`queuing "${e}" remove ${t}-${i}`),{label:"remove",execute:()=>{this.removeExecutor(e,t,i)},onStart:()=>{},onComplete:()=>{this.hls.trigger(y.BUFFER_FLUSHED,{type:e})},onError:s=>{this.warn(`Failed to remove ${t}-${i} from "${e}" SourceBuffer`,s)}}}onBufferFlushing(e,t){const{type:i,startOffset:s,endOffset:r}=t;i?this.append(this.getFlushOp(i,s,r),i):this.sourceBuffers.forEach(([n])=>{n&&this.append(this.getFlushOp(n,s,r),n)})}onFragParsed(e,t){const{frag:i,part:s}=t,r=[],n=s?s.elementaryStreams:i.elementaryStreams;n[Ue.AUDIOVIDEO]?r.push("audiovideo"):(n[Ue.AUDIO]&&r.push("audio"),n[Ue.VIDEO]&&r.push("video"));const o=()=>{const c=self.performance.now();i.stats.buffering.end=c,s&&(s.stats.buffering.end=c);const u=s?s.stats:i.stats;this.hls.trigger(y.FRAG_BUFFERED,{frag:i,part:s,stats:u,id:i.type})};r.length===0&&this.warn(`Fragments must have at least one ElementaryStreamType set. type: ${i.type} level: ${i.level} sn: ${i.sn}`),this.blockBuffers(o,r).catch(c=>{this.warn(`Fragment buffered callback ${c}`),this.stepOperationQueue(this.sourceBufferTypes)})}onFragChanged(e,t){this.trimBuffers()}get bufferedToEnd(){return this.sourceBufferCount>0&&!this.sourceBuffers.some(([e])=>{if(e){const t=this.tracks[e];if(t)return!t.ended||t.ending}return!1})}onBufferEos(e,t){var i;this.sourceBuffers.forEach(([n])=>{if(n){const o=this.tracks[n];(!t.type||t.type===n)&&(o.ending=!0,o.ended||(o.ended=!0,this.log(`${n} buffer reached EOS`)))}});const s=((i=this.overrides)==null?void 0:i.endOfStream)!==!1;this.sourceBufferCount>0&&!this.sourceBuffers.some(([n])=>{var o;return n&&!((o=this.tracks[n])!=null&&o.ended)})?s?(this.log("Queueing EOS"),this.blockUntilOpen(()=>{this.tracksEnded();const{mediaSource:n}=this;if(!n||n.readyState!=="open"){n&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${n.readyState}`);return}this.log("Calling mediaSource.endOfStream()"),n.endOfStream(),this.hls.trigger(y.BUFFERED_TO_END,void 0)})):(this.tracksEnded(),this.hls.trigger(y.BUFFERED_TO_END,void 0)):t.type==="video"&&this.unblockAudio()}tracksEnded(){this.sourceBuffers.forEach(([e])=>{if(e!==null){const t=this.tracks[e];t&&(t.ending=!1)}})}onLevelUpdated(e,{details:t}){t.fragments.length&&(this.details=t,this.updateDuration())}updateDuration(){this.blockUntilOpen(()=>{const e=this.getDurationAndRange();e&&this.updateMediaSource(e)})}onError(e,t){if(t.details===U.BUFFER_APPEND_ERROR&&t.frag){var i;const s=(i=t.errorAction)==null?void 0:i.nextAutoLevel;se(s)&&s!==t.frag.level&&this.resetAppendErrors()}}resetAppendErrors(){this.appendErrors={audio:0,video:0,audiovideo:0}}trimBuffers(){const{hls:e,details:t,media:i}=this;if(!i||t===null||!this.sourceBufferCount)return;const s=e.config,r=i.currentTime,n=t.levelTargetDuration,o=t.live&&s.liveBackBufferLength!==null?s.liveBackBufferLength:s.backBufferLength;if(se(o)&&o>=0){const u=Math.max(o,n),h=Math.floor(r/n)*n-u;this.flushBackBuffer(r,n,h)}const c=s.frontBufferFlushThreshold;if(se(c)&&c>0){const u=Math.max(s.maxBufferLength,c),h=Math.max(u,n),f=Math.floor(r/n)*n+h;this.flushFrontBuffer(r,n,f)}}flushBackBuffer(e,t,i){this.sourceBuffers.forEach(([s,r])=>{if(r){const o=ye.getBuffered(r);if(o.length>0&&i>o.start(0)){var n;this.hls.trigger(y.BACK_BUFFER_REACHED,{bufferEnd:i});const c=this.tracks[s];if((n=this.details)!=null&&n.live)this.hls.trigger(y.LIVE_BACK_BUFFER_REACHED,{bufferEnd:i});else if(c!=null&&c.ended){this.log(`Cannot flush ${s} back buffer while SourceBuffer is in ended state`);return}this.hls.trigger(y.BUFFER_FLUSHING,{startOffset:0,endOffset:i,type:s})}}})}flushFrontBuffer(e,t,i){this.sourceBuffers.forEach(([s,r])=>{if(r){const n=ye.getBuffered(r),o=n.length;if(o<2)return;const c=n.start(o-1),u=n.end(o-1);if(i>c||e>=c&&e<=u)return;this.hls.trigger(y.BUFFER_FLUSHING,{startOffset:c,endOffset:1/0,type:s})}})}getDurationAndRange(){var e;const{details:t,mediaSource:i}=this;if(!t||!this.media||i?.readyState!=="open")return null;const s=t.edge;if(t.live&&this.hls.config.liveDurationInfinity){if(t.fragments.length&&i.setLiveSeekableRange){const u=Math.max(0,t.fragmentStart),h=Math.max(u,s);return{duration:1/0,start:u,end:h}}return{duration:1/0}}const r=(e=this.overrides)==null?void 0:e.duration;if(r)return se(r)?{duration:r}:null;const n=this.media.duration,o=se(i.duration)?i.duration:0;return s>o&&s>n||!se(n)?{duration:s}:null}updateMediaSource({duration:e,start:t,end:i}){const s=this.mediaSource;!this.media||!s||s.readyState!=="open"||(s.duration!==e&&(se(e)&&this.log(`Updating MediaSource duration to ${e.toFixed(3)}`),s.duration=e),t!==void 0&&i!==void 0&&(this.log(`MediaSource duration is set to ${s.duration}. Setting seekable range to ${t}-${i}.`),s.setLiveSeekableRange(t,i)))}get tracksReady(){const e=this.pendingTrackCount;return e>0&&(e>=this.bufferCodecEventsTotal||this.isPending(this.tracks.audiovideo))}checkPendingTracks(){const{bufferCodecEventsTotal:e,pendingTrackCount:t,tracks:i}=this;if(this.log(`checkPendingTracks (pending: ${t} codec events expected: ${e}) ${Ge(i)}`),this.tracksReady){var s;const r=(s=this.transferData)==null?void 0:s.tracks;r&&Object.keys(r).length?this.attachTransferred():this.createSourceBuffers()}}bufferCreated(){if(this.sourceBufferCount){const e={};this.sourceBuffers.forEach(([t,i])=>{if(t){const s=this.tracks[t];e[t]={buffer:i,container:s.container,codec:s.codec,supplemental:s.supplemental,levelCodec:s.levelCodec,id:s.id,metadata:s.metadata}}}),this.hls.trigger(y.BUFFER_CREATED,{tracks:e}),this.log(`SourceBuffers created. Running queue: ${this.operationQueue}`),this.sourceBuffers.forEach(([t])=>{this.executeNext(t)})}else{const e=new Error("could not create source buffer for media codec(s)");this.hls.trigger(y.ERROR,{type:de.MEDIA_ERROR,details:U.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:e,reason:e.message})}}createSourceBuffers(){const{tracks:e,sourceBuffers:t,mediaSource:i}=this;if(!i)throw new Error("createSourceBuffers called when mediaSource was null");for(const r in e){const n=r,o=e[n];if(this.isPending(o)){const c=this.getTrackCodec(o,n),u=`${o.container};codecs=${c}`;o.codec=c,this.log(`creating sourceBuffer(${u})${this.currentOp(n)?" Queued":""} ${Ge(o)}`);try{const h=i.addSourceBuffer(u),f=sn(n),g=[n,h];t[f]=g,o.buffer=h}catch(h){var s;this.error(`error while trying to add sourceBuffer: ${h.message}`),this.shiftAndExecuteNext(n),(s=this.operationQueue)==null||s.removeBlockers(),delete this.tracks[n],this.hls.trigger(y.ERROR,{type:de.MEDIA_ERROR,details:U.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:h,sourceBufferName:n,mimeType:u,parent:o.id});return}this.trackSourceBuffer(n,o)}}this.bufferCreated()}getTrackCodec(e,t){const i=e.supplemental;let s=e.codec;i&&(t==="video"||t==="audiovideo")&&Er(i,"video")&&(s=Wu(s,i));const r=vs(s,e.levelCodec);return r?t.slice(0,5)==="audio"?Es(r,this.appendSource):r:""}trackSourceBuffer(e,t){const i=t.buffer;if(!i)return;const s=this.getTrackCodec(t,e);this.tracks[e]={buffer:i,codec:s,container:t.container,levelCodec:t.levelCodec,supplemental:t.supplemental,metadata:t.metadata,id:t.id,listeners:[]},this.removeBufferListeners(e),this.addBufferListener(e,"updatestart",this.onSBUpdateStart),this.addBufferListener(e,"updateend",this.onSBUpdateEnd),this.addBufferListener(e,"error",this.onSBUpdateError),this.appendSource&&this.addBufferListener(e,"bufferedchange",(r,n)=>{const o=n.removedRanges;o!=null&&o.length&&this.hls.trigger(y.BUFFER_FLUSHED,{type:r})})}get mediaSrc(){var e,t;const i=((e=this.media)==null||(t=e.querySelector)==null?void 0:t.call(e,"source"))||this.media;return i?.src}onSBUpdateStart(e){const t=this.currentOp(e);t&&t.onStart()}onSBUpdateEnd(e){var t;if(((t=this.mediaSource)==null?void 0:t.readyState)==="closed"){this.resetBuffer(e);return}const i=this.currentOp(e);i&&(i.onComplete(),this.shiftAndExecuteNext(e))}onSBUpdateError(e,t){var i;const s=new Error(`${e} SourceBuffer error. MediaSource readyState: ${(i=this.mediaSource)==null?void 0:i.readyState}`);this.error(`${s}`,t),this.hls.trigger(y.ERROR,{type:de.MEDIA_ERROR,details:U.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:s,fatal:!1});const r=this.currentOp(e);r&&r.onError(s)}updateTimestampOffset(e,t,i,s,r,n){const o=t-e.timestampOffset;Math.abs(o)>=i&&(this.log(`Updating ${s} SourceBuffer timestampOffset to ${t} (sn: ${r} cc: ${n})`),e.timestampOffset=t)}removeExecutor(e,t,i){const{media:s,mediaSource:r}=this,n=this.tracks[e],o=n?.buffer;if(!s||!r||!o){this.warn(`Attempting to remove from the ${e} SourceBuffer, but it does not exist`),this.shiftAndExecuteNext(e);return}const c=se(s.duration)?s.duration:1/0,u=se(r.duration)?r.duration:1/0,h=Math.max(0,t),f=Math.min(i,c,u);f>h&&(!n.ending||n.ended)?(n.ended=!1,this.log(`Removing [${h},${f}] from the ${e} SourceBuffer`),o.remove(h,f)):this.shiftAndExecuteNext(e)}appendExecutor(e,t){const i=this.tracks[t],s=i?.buffer;if(!s)throw new sd(`Attempting to append to the ${t} SourceBuffer, but it does not exist`);i.ending=!1,i.ended=!1,s.appendBuffer(e)}blockUntilOpen(e){if(this.isUpdating()||this.isQueued())this.blockBuffers(e).catch(t=>{this.warn(`SourceBuffer blocked callback ${t}`),this.stepOperationQueue(this.sourceBufferTypes)});else try{e()}catch(t){this.warn(`Callback run without blocking ${this.operationQueue} ${t}`)}}isUpdating(){return this.sourceBuffers.some(([e,t])=>e&&t.updating)}isQueued(){return this.sourceBuffers.some(([e])=>e&&!!this.currentOp(e))}isPending(e){return!!e&&!e.buffer}blockBuffers(e,t=this.sourceBufferTypes){if(!t.length)return this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);const{operationQueue:i}=this,s=t.map(n=>this.appendBlocker(n));return t.length>1&&!!this.blockedAudioAppend&&this.unblockAudio(),Promise.all(s).then(n=>{i===this.operationQueue&&(e(),this.stepOperationQueue(this.sourceBufferTypes))})}stepOperationQueue(e){e.forEach(t=>{var i;const s=(i=this.tracks[t])==null?void 0:i.buffer;!s||s.updating||this.shiftAndExecuteNext(t)})}append(e,t,i){this.operationQueue&&this.operationQueue.append(e,t,i)}appendBlocker(e){if(this.operationQueue)return this.operationQueue.appendBlocker(e)}currentOp(e){return this.operationQueue?this.operationQueue.current(e):null}executeNext(e){e&&this.operationQueue&&this.operationQueue.executeNext(e)}shiftAndExecuteNext(e){this.operationQueue&&this.operationQueue.shiftAndExecuteNext(e)}get pendingTrackCount(){return Object.keys(this.tracks).reduce((e,t)=>e+(this.isPending(this.tracks[t])?1:0),0)}get sourceBufferCount(){return this.sourceBuffers.reduce((e,[t])=>e+(t?1:0),0)}get sourceBufferTypes(){return this.sourceBuffers.map(([e])=>e).filter(e=>!!e)}addBufferListener(e,t,i){const s=this.tracks[e];if(!s)return;const r=s.buffer;if(!r)return;const n=i.bind(this,e);s.listeners.push({event:t,listener:n}),r.addEventListener(t,n)}removeBufferListeners(e){const t=this.tracks[e];if(!t)return;const i=t.buffer;i&&(t.listeners.forEach(s=>{i.removeEventListener(s.event,s.listener)}),t.listeners.length=0)}}function Ko(a){const e=a.querySelectorAll("source");[].slice.call(e).forEach(t=>{a.removeChild(t)})}function nd(a,e){const t=self.document.createElement("source");t.type="video/mp4",t.src=e,a.appendChild(t)}function sn(a){return a==="audio"?1:0}class rn{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.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){const{hls:e}=this;e.on(y.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(y.MANIFEST_PARSED,this.onManifestParsed,this),e.on(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(y.BUFFER_CODECS,this.onBufferCodecs,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:e}=this;e.off(y.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(y.MANIFEST_PARSED,this.onManifestParsed,this),e.off(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(y.BUFFER_CODECS,this.onBufferCodecs,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(e,t){const i=this.hls.levels[t.droppedLevel];this.isLevelAllowed(i)&&this.restrictedLevels.push({bitrate:i.bitrate,height:i.height,width:i.width})}onMediaAttaching(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()}onManifestParsed(e,t){const i=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,i.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onLevelsUpdated(e,t){this.timer&&se(this.autoLevelCapping)&&this.detectPlayerSize()}onBufferCodecs(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onMediaDetaching(){this.stopCapping(),this.media=null}detectPlayerSize(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0){this.clientRect=null;return}const e=this.hls.levels;if(e.length){const t=this.hls,i=this.getMaxLevel(e.length-1);i!==this.autoLevelCapping&&t.logger.log(`Setting autoLevelCapping to ${i}: ${e[i].height}p@${e[i].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),t.autoLevelCapping=i,t.autoLevelEnabled&&t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}}getMaxLevel(e){const t=this.hls.levels;if(!t.length)return-1;const i=t.filter((s,r)=>this.isLevelAllowed(s)&&r<=e);return this.clientRect=null,rn.getMaxLevelByMediaSize(i,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,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 i=e.getBoundingClientRect();t.width=i.width,t.height=i.height,!t.width&&!t.height&&(t.width=i.right-i.left||e.width||0,t.height=i.bottom-i.top||e.height||0)}return this.clientRect=t,t}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch{}return Math.min(e,this.hls.config.maxDevicePixelRatio)}isLevelAllowed(e){return!this.restrictedLevels.some(i=>e.bitrate===i.bitrate&&e.width===i.width&&e.height===i.height)}static getMaxLevelByMediaSize(e,t,i){if(!(e!=null&&e.length))return-1;const s=(o,c)=>c?o.width!==c.width||o.height!==c.height:!0;let r=e.length-1;const n=Math.max(t,i);for(let o=0;o<e.length;o+=1){const c=e[o];if((c.width>=n||c.height>=n)&&s(c,e[o+1])){r=o;break}}return r}}const dt={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"},ad={HLS:"h"};class Ut{constructor(e,t){Array.isArray(e)&&(e=e.map(i=>i instanceof Ut?i:new Ut(i))),this.value=e,this.params=t}}const od="Dict";function ld(a){return Array.isArray(a)?JSON.stringify(a):a instanceof Map?"Map{}":a instanceof Set?"Set{}":typeof a=="object"?JSON.stringify(a):String(a)}function ud(a,e,t,i){return new Error(`failed to ${a} "${ld(e)}" as ${t}`,{cause:i})}function $t(a,e,t){return ud("serialize",a,e,t)}class Yo{constructor(e){this.description=e}}const Wo="Bare Item",cd="Boolean";function hd(a){if(typeof a!="boolean")throw $t(a,cd);return a?"?1":"?0"}function dd(a){return btoa(String.fromCharCode(...a))}const fd="Byte Sequence";function gd(a){if(ArrayBuffer.isView(a)===!1)throw $t(a,fd);return`:${dd(a)}:`}const pd="Integer";function Ad(a){return a<-999999999999999||999999999999999<a}function jo(a){if(Ad(a))throw $t(a,pd);return a.toString()}function md(a){return`@${jo(a.getTime()/1e3)}`}function zo(a,e){if(a<0)return-zo(-a,e);const t=Math.pow(10,e);if(Math.abs(a*t%1-.5)<Number.EPSILON){const s=Math.floor(a*t);return(s%2===0?s:s+1)/t}else return Math.round(a*t)/t}const Id="Decimal";function Cd(a){const e=zo(a,3);if(Math.floor(Math.abs(e)).toString().length>12)throw $t(a,Id);const t=e.toString();return t.includes(".")?t:`${t}.0`}const yd="String",Ed=/[\x00-\x1f\x7f]+/;function vd(a){if(Ed.test(a))throw $t(a,yd);return`"${a.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function Td(a){return a.description||a.toString().slice(7,-1)}const Sd="Token";function qo(a){const e=Td(a);if(/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(e)===!1)throw $t(e,Sd);return e}function nn(a){switch(typeof a){case"number":if(!se(a))throw $t(a,Wo);return Number.isInteger(a)?jo(a):Cd(a);case"string":return vd(a);case"symbol":return qo(a);case"boolean":return hd(a);case"object":if(a instanceof Date)return md(a);if(a instanceof Uint8Array)return gd(a);if(a instanceof Yo)return qo(a);default:throw $t(a,Wo)}}const xd="Key";function an(a){if(/^[a-z*][a-z0-9\-_.*]*$/.test(a)===!1)throw $t(a,xd);return a}function on(a){return a==null?"":Object.entries(a).map(([e,t])=>t===!0?`;${an(e)}`:`;${an(e)}=${nn(t)}`).join("")}function Xo(a){return a instanceof Ut?`${nn(a.value)}${on(a.params)}`:nn(a)}function bd(a){return`(${a.value.map(Xo).join(" ")})${on(a.params)}`}function Ld(a,e={whitespace:!0}){if(typeof a!="object"||a==null)throw $t(a,od);const t=a instanceof Map?a.entries():Object.entries(a),i=e?.whitespace?" ":"";return Array.from(t).map(([s,r])=>{r instanceof Ut||(r=new Ut(r));let n=an(s);return r.value===!0?n+=on(r.params):(n+="=",Array.isArray(r.value)?n+=bd(r):n+=Xo(r)),n}).join(`,${i}`)}function Zo(a,e){return Ld(a,e)}const Gt="CMCD-Object",Ke="CMCD-Request",Ei="CMCD-Session",li="CMCD-Status",Rd={br:Gt,ab:Gt,d:Gt,ot:Gt,tb:Gt,tpb:Gt,lb:Gt,tab:Gt,lab:Gt,url:Gt,pb:Ke,bl:Ke,tbl:Ke,dl:Ke,ltc:Ke,mtp:Ke,nor:Ke,nrr:Ke,rc:Ke,sn:Ke,sta:Ke,su:Ke,ttfb:Ke,ttfbb:Ke,ttlb:Ke,cmsdd:Ke,cmsds:Ke,smrt:Ke,df:Ke,cs:Ke,ts:Ke,cid:Ei,pr:Ei,sf:Ei,sid:Ei,st:Ei,v:Ei,msd:Ei,bs:li,bsd:li,cdn:li,rtp:li,bg:li,pt:li,ec:li,e:li},Dd={REQUEST:Ke};function Pd(a){return Object.keys(a).reduce((e,t)=>{var i;return(i=a[t])===null||i===void 0||i.forEach(s=>e[s]=t),e},{})}function _d(a,e){const t={};if(!a)return t;const i=Object.keys(a),s=e?Pd(e):{};return i.reduce((r,n)=>{var o;const c=Rd[n]||s[n]||Dd.REQUEST,u=(o=r[c])!==null&&o!==void 0?o:r[c]={};return u[n]=a[n],r},t)}function wd(a){return["ot","sf","st","e","sta"].includes(a)}function kd(a){return typeof a=="number"?se(a):a!=null&&a!==""&&a!==!1}const Qo="event";function Md(a,e){const t=new URL(a),i=new URL(e);if(t.origin!==i.origin)return a;const s=t.pathname.split("/").slice(1),r=i.pathname.split("/").slice(1,-1);for(;s[0]===r[0];)s.shift(),r.shift();for(;r.length;)r.shift(),s.unshift("..");return s.join("/")+t.search+t.hash}const Hs=a=>Math.round(a),ln=(a,e)=>Array.isArray(a)?a.map(t=>ln(t,e)):a instanceof Ut&&typeof a.value=="string"?new Ut(ln(a.value,e),a.params):(e.baseUrl&&(a=Md(a,e.baseUrl)),e.version===1?encodeURIComponent(a):a),Vs=a=>Hs(a/100)*100,Od={br:Hs,d:Hs,bl:Vs,dl:Vs,mtp:Vs,nor:(a,e)=>{let t=a;return e.version>=2&&(a instanceof Ut&&typeof a.value=="string"?t=new Ut([a]):typeof a=="string"&&(t=[a])),ln(t,e)},rtp:Vs,tb:Hs},Jo="request",el="response",un=["ab","bg","bl","br","bs","bsd","cdn","cid","cs","df","ec","lab","lb","ltc","msd","mtp","pb","pr","pt","sf","sid","sn","st","sta","tab","tb","tbl","tpb","ts","v"],Fd=["e"],Nd=/^[a-zA-Z0-9-.]+-[a-zA-Z0-9-.]+$/;function Ks(a){return Nd.test(a)}function Bd(a){return un.includes(a)||Fd.includes(a)||Ks(a)}const tl=["d","dl","nor","ot","rtp","su"];function Ud(a){return un.includes(a)||tl.includes(a)||Ks(a)}const $d=["cmsdd","cmsds","rc","smrt","ttfb","ttfbb","ttlb","url"];function Gd(a){return un.includes(a)||tl.includes(a)||$d.includes(a)||Ks(a)}const Hd=["bl","br","bs","cid","d","dl","mtp","nor","nrr","ot","pr","rtp","sf","sid","st","su","tb","v"];function Vd(a){return Hd.includes(a)||Ks(a)}const Kd={[el]:Gd,[Qo]:Bd,[Jo]:Ud};function il(a,e={}){const t={};if(a==null||typeof a!="object")return t;const i=e.version||a.v||1,s=e.reportingMode||Jo,r=i===1?Vd:Kd[s];let n=Object.keys(a).filter(r);const o=e.filter;typeof o=="function"&&(n=n.filter(o));const c=s===el||s===Qo;c&&!n.includes("ts")&&n.push("ts"),i>1&&!n.includes("v")&&n.push("v");const u=Ne({},Od,e.formatters),h={version:i,reportingMode:s,baseUrl:e.baseUrl};return n.sort().forEach(f=>{let g=a[f];const I=u[f];if(typeof I=="function"&&(g=I(g,h)),f==="v"){if(i===1)return;g=i}f=="pr"&&g===1||(c&&f==="ts"&&!se(g)&&(g=Date.now()),kd(g)&&(wd(f)&&typeof g=="string"&&(g=new Yo(g)),t[f]=g))}),t}function Yd(a,e={}){const t={};if(!a)return t;const i=il(a,e),s=_d(i,e?.customHeaderMap);return Object.entries(s).reduce((r,[n,o])=>{const c=Zo(o,{whitespace:!1});return c&&(r[n]=c),r},t)}function Wd(a,e,t){return Ne(a,Yd(e,t))}const jd="CMCD";function zd(a,e={}){return a?Zo(il(a,e),{whitespace:!1}):""}function qd(a,e={}){if(!a)return"";const t=zd(a,e);return encodeURIComponent(t)}function Xd(a,e={}){if(!a)return"";const t=qd(a,e);return`${jd}=${t}`}const sl=/CMCD=[^&#]+/;function Zd(a,e,t){const i=Xd(e,t);if(!i)return a;if(sl.test(a))return a.replace(sl,i);const s=a.includes("?")?"&":"?";return`${a}${s}${i}`}class Qd{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.includeKeys=void 0,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=s=>{try{this.apply(s,{ot:dt.MANIFEST,su:!this.initialized})}catch(r){this.hls.logger.warn("Could not generate manifest CMCD data.",r)}},this.applyFragmentData=s=>{try{const{frag:r,part:n}=s,o=this.hls.levels[r.level],c=this.getObjectType(r),u={d:(n||r).duration*1e3,ot:c};(c===dt.VIDEO||c===dt.AUDIO||c==dt.MUXED)&&(u.br=o.bitrate/1e3,u.tb=this.getTopBandwidth(c)/1e3,u.bl=this.getBufferLength(c));const h=n?this.getNextPart(n):this.getNextFrag(r);h!=null&&h.url&&h.url!==r.url&&(u.nor=h.url),this.apply(s,u)}catch(r){this.hls.logger.warn("Could not generate segment CMCD data.",r)}},this.hls=e;const t=this.config=e.config,{cmcd:i}=t;i!=null&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=i.sessionId||e.sessionId,this.cid=i.contentId,this.useHeaders=i.useHeaders===!0,this.includeKeys=i.includeKeys,this.registerListeners())}registerListeners(){const e=this.hls;e.on(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(y.MEDIA_DETACHED,this.onMediaDetached,this),e.on(y.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const e=this.hls;e.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(y.MEDIA_DETACHED,this.onMediaDetached,this),e.off(y.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=this.media=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 i,s;this.audioBuffer=(i=t.tracks.audio)==null?void 0:i.buffer,this.videoBuffer=(s=t.tracks.video)==null?void 0:s.buffer}createData(){var e;return{v:1,sf:ad.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){Ne(t,this.createData());const i=t.ot===dt.INIT||t.ot===dt.VIDEO||t.ot===dt.MUXED;this.starved&&i&&(t.bs=!0,t.su=!0,this.starved=!1),t.su==null&&(t.su=this.buffering);const{includeKeys:s}=this;s&&(t=Object.keys(t).reduce((n,o)=>(s.includes(o)&&(n[o]=t[o]),n),{}));const r={baseUrl:e.url};this.useHeaders?(e.headers||(e.headers={}),Wd(e.headers,t,r)):e.url=Zd(e.url,t,r)}getNextFrag(e){var t;const i=(t=this.hls.levels[e.level])==null?void 0:t.details;if(i){const s=e.sn-i.startSN;return i.fragments[s+1]}}getNextPart(e){var t;const{index:i,fragment:s}=e,r=(t=this.hls.levels[s.level])==null||(t=t.details)==null?void 0:t.partList;if(r){const{sn:n}=s;for(let o=r.length-1;o>=0;o--){const c=r[o];if(c.index===i&&c.fragment.sn===n)return r[o+1]}}}getObjectType(e){const{type:t}=e;if(t==="subtitle")return dt.TIMED_TEXT;if(e.sn==="initSegment")return dt.INIT;if(t==="audio")return dt.AUDIO;if(t==="main")return this.hls.audioTracks.length?dt.VIDEO:dt.MUXED}getTopBandwidth(e){let t=0,i;const s=this.hls;if(e===dt.AUDIO)i=s.audioTracks;else{const r=s.maxAutoLevel,n=r>-1?r+1:s.levels.length;i=s.levels.slice(0,n)}return i.forEach(r=>{r.bitrate>t&&(t=r.bitrate)}),t>0?t:NaN}getBufferLength(e){const t=this.media,i=e===dt.AUDIO?this.audioBuffer:this.videoBuffer;return!i||!t?NaN:ye.bufferInfo(i,t.currentTime,this.config.maxBufferHole).len*1e3}createPlaylistLoader(){const{pLoader:e}=this.config,t=this.applyPlaylistData,i=e||this.config.loader;return class{constructor(r){this.loader=void 0,this.loader=new i(r)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(r,n,o){t(r),this.loader.load(r,n,o)}}}createFragmentLoader(){const{fLoader:e}=this.config,t=this.applyFragmentData,i=e||this.config.loader;return class{constructor(r){this.loader=void 0,this.loader=new i(r)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(r,n,o){t(r),this.loader.load(r,n,o)}}}}const Jd=3e5;class ef extends Tt{constructor(e){super("content-steering",e.logger),this.hls=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this._pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.registerListeners()}registerListeners(){const e=this.hls;e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(y.MANIFEST_PARSED,this.onManifestParsed,this),e.on(y.ERROR,this.onError,this)}unregisterListeners(){const e=this.hls;e&&(e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(y.MANIFEST_PARSED,this.onManifestParsed,this),e.off(y.ERROR,this.onError,this))}pathways(){return(this.levels||[]).reduce((e,t)=>(e.indexOf(t.pathwayId)===-1&&e.push(t.pathwayId),e),[])}get pathwayPriority(){return this._pathwayPriority}set pathwayPriority(e){this.updatePathwayPriority(e)}startLoad(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){const e=this.timeToLoad*1e3-(performance.now()-this.updated);if(e>0){this.scheduleRefresh(this.uri,e);return}}this.loadSteeringManifest(this.uri)}}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}clearTimeout(){this.reloadTimer!==-1&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(e){const t=this.levels;t&&(this.levels=t.filter(i=>i!==e))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(e,t){const{contentSteering:i}=t;i!==null&&(this.pathwayId=i.pathwayId,this.uri=i.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){const{errorAction:i}=t;if(i?.action===rt.SendAlternateToPenaltyBox&&i.flags===Ct.MoveAllAlternatesMatchingHost){const s=this.levels;let r=this._pathwayPriority,n=this.pathwayId;if(t.context){const{groupId:o,pathwayId:c,type:u}=t.context;o&&s?n=this.getPathwayForGroupId(o,u,n):c&&(n=c)}n in this.penalizedPathways||(this.penalizedPathways[n]=performance.now()),!r&&s&&(r=this.pathways()),r&&r.length>1&&(this.updatePathwayPriority(r),i.resolved=this.pathwayId!==n),t.details===U.BUFFER_APPEND_ERROR&&!t.fatal?i.resolved=!0:i.resolved||this.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${n} levels: ${s&&s.length} priorities: ${Ge(r)} penalized: ${Ge(this.penalizedPathways)}`)}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){const i=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${i}"`),t=this.getLevelsForPathway(i),this.pathwayId=i}return t.length!==e.length&&this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t}getLevelsForPathway(e){return this.levels===null?[]:this.levels.filter(t=>e===t.pathwayId)}updatePathwayPriority(e){this._pathwayPriority=e;let t;const i=this.penalizedPathways,s=performance.now();Object.keys(i).forEach(r=>{s-i[r]>Jd&&delete i[r]});for(let r=0;r<e.length;r++){const n=e[r];if(n in i)continue;if(n===this.pathwayId)return;const o=this.hls.nextLoadLevel,c=this.hls.levels[o];if(t=this.getLevelsForPathway(n),t.length>0){this.log(`Setting Pathway to "${n}"`),this.pathwayId=n,oo(t),this.hls.trigger(y.LEVELS_UPDATED,{levels:t});const u=this.hls.levels[o];c&&u&&this.levels&&(u.attrs["STABLE-VARIANT-ID"]!==c.attrs["STABLE-VARIANT-ID"]&&u.bitrate!==c.bitrate&&this.log(`Unstable Pathways change from bitrate ${c.bitrate} to ${u.bitrate}`),this.hls.nextLoadLevel=o);break}}}getPathwayForGroupId(e,t,i){const s=this.getLevelsForPathway(i).concat(this.levels||[]);for(let r=0;r<s.length;r++)if(t===be.AUDIO_TRACK&&s[r].hasAudioGroup(e)||t===be.SUBTITLE_TRACK&&s[r].hasSubtitleGroup(e))return s[r].pathwayId;return i}clonePathways(e){const t=this.levels;if(!t)return;const i={},s={};e.forEach(r=>{const{ID:n,"BASE-ID":o,"URI-REPLACEMENT":c}=r;if(t.some(h=>h.pathwayId===n))return;const u=this.getLevelsForPathway(o).map(h=>{const f=new He(h.attrs);f["PATHWAY-ID"]=n;const g=f.AUDIO&&`${f.AUDIO}_clone_${n}`,I=f.SUBTITLES&&`${f.SUBTITLES}_clone_${n}`;g&&(i[f.AUDIO]=g,f.AUDIO=g),I&&(s[f.SUBTITLES]=I,f.SUBTITLES=I);const m=nl(h.uri,f["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",c),E=new Zi({attrs:f,audioCodec:h.audioCodec,bitrate:h.bitrate,height:h.height,name:h.name,url:m,videoCodec:h.videoCodec,width:h.width});if(h.audioGroups)for(let v=1;v<h.audioGroups.length;v++)E.addGroupId("audio",`${h.audioGroups[v]}_clone_${n}`);if(h.subtitleGroups)for(let v=1;v<h.subtitleGroups.length;v++)E.addGroupId("text",`${h.subtitleGroups[v]}_clone_${n}`);return E});t.push(...u),rl(this.audioTracks,i,c,n),rl(this.subtitleTracks,s,c,n)})}loadSteeringManifest(e){const t=this.hls.config,i=t.loader;this.loader&&this.loader.destroy(),this.loader=new i(t);let s;try{s=new self.URL(e)}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${e}`);return}if(s.protocol!=="data:"){const h=(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate)|0;s.searchParams.set("_HLS_pathway",this.pathwayId),s.searchParams.set("_HLS_throughput",""+h)}const r={responseType:"json",url:s.href},n=t.steeringManifestLoadPolicy.default,o=n.errorRetry||n.timeoutRetry||{},c={loadPolicy:n,timeout:n.maxLoadTimeMs,maxRetry:o.maxNumRetry||0,retryDelay:o.retryDelayMs||0,maxRetryDelay:o.maxRetryDelayMs||0},u={onSuccess:(h,f,g,I)=>{this.log(`Loaded steering manifest: "${s}"`);const m=h.data;if(m?.VERSION!==1){this.log(`Steering VERSION ${m.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=m.TTL;const{"RELOAD-URI":E,"PATHWAY-CLONES":v,"PATHWAY-PRIORITY":x}=m;if(E)try{this.uri=new self.URL(E,s).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${E}`);return}this.scheduleRefresh(this.uri||g.url),v&&this.clonePathways(v);const D={steeringManifest:m,url:s.toString()};this.hls.trigger(y.STEERING_MANIFEST_LOADED,D),x&&this.updatePathwayPriority(x)},onError:(h,f,g,I)=>{if(this.log(`Error loading steering manifest: ${h.code} ${h.text} (${f.url})`),this.stopLoad(),h.code===410){this.enabled=!1,this.log(`Steering manifest ${f.url} no longer available`);return}let m=this.timeToLoad*1e3;if(h.code===429){const E=this.loader;if(typeof E?.getResponseHeader=="function"){const v=E.getResponseHeader("Retry-After");v&&(m=parseFloat(v)*1e3)}this.log(`Steering manifest ${f.url} rate limited`);return}this.scheduleRefresh(this.uri||f.url,m)},onTimeout:(h,f,g)=>{this.log(`Timeout loading steering manifest (${f.url})`),this.scheduleRefresh(this.uri||f.url)}};this.log(`Requesting steering manifest: ${s}`),this.loader.load(r,c,u)}scheduleRefresh(e,t=this.timeToLoad*1e3){this.clearTimeout(),this.reloadTimer=self.setTimeout(()=>{var i;const s=(i=this.hls)==null?void 0:i.media;if(s&&!s.ended){this.loadSteeringManifest(e);return}this.scheduleRefresh(e,this.timeToLoad*1e3)},t)}}function rl(a,e,t,i){a&&Object.keys(e).forEach(s=>{const r=a.filter(n=>n.groupId===s).map(n=>{const o=Ne({},n);return o.details=void 0,o.attrs=new He(o.attrs),o.url=o.attrs.URI=nl(n.url,n.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",t),o.groupId=o.attrs["GROUP-ID"]=e[s],o.attrs["PATHWAY-ID"]=i,o});a.push(...r)})}function nl(a,e,t,i){const{HOST:s,PARAMS:r,[t]:n}=i;let o;e&&(o=n?.[e],o&&(a=o));const c=new self.URL(a);return s&&!o&&(c.host=s),r&&Object.keys(r).sort().forEach(u=>{u&&c.searchParams.set(u,r[u])}),c.href}class Ni extends Tt{constructor(e){super("eme",e.logger),this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.mediaKeys=null,this.setMediaKeysQueue=Ni.CDMCleanupPromise?[Ni.CDMCleanupPromise]:[],this.bannedKeyIds={},this.onMediaEncrypted=t=>{const{initDataType:i,initData:s}=t,r=`"${t.type}" event: init data type: "${i}"`;if(this.debug(r),s!==null){if(!this.keyFormatPromise){let n=Object.keys(this.keySystemAccessPromises);n.length||(n=Qi(this.config));const o=n.map(Mr).filter(c=>!!c);this.keyFormatPromise=this.getKeyFormatPromise(o)}this.keyFormatPromise.then(n=>{const o=_s(n);if(i!=="sinf"||o!==Ve.FAIRPLAY){this.log(`Ignoring "${t.type}" event with init data type: "${i}" for selected key-system ${o}`);return}let c;try{const I=Ze(new Uint8Array(s)),m=wr(JSON.parse(I).sinf),E=la(m);if(!E)throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");c=new Uint8Array(E.subarray(8,24))}catch(I){this.warn(`${r} Failed to parse sinf: ${I}`);return}const u=It(c),{keyIdToKeySessionPromise:h,mediaKeySessions:f}=this;let g=h[u];for(let I=0;I<f.length;I++){const m=f[I],E=m.decryptdata;if(!E.keyId)continue;const v=It(E.keyId);if(u===v||E.uri.replace(/-/g,"").indexOf(u)!==-1){if(g=h[v],!g)continue;if(E.pssh)break;delete h[v],E.pssh=new Uint8Array(s),E.keyId=c,g=h[u]=g.then(()=>this.generateRequestWithPreferredKeySession(m,i,s,"encrypted-event-key-match")),g.catch(x=>this.handleError(x));break}}g||this.handleError(new Error(`Key ID ${u} not encountered in playlist. Key-system sessions ${f.length}.`))}).catch(n=>this.handleError(n))}},this.onWaitingForKey=t=>{this.log(`"${t.type}" event`)},this.hls=e,this.config=e.config,this.registerListeners()}destroy(){this.onDestroying(),this.onMediaDetached();const e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.config=this.keyIdToKeySessionPromise=null,this.onMediaEncrypted=this.onWaitingForKey=null}registerListeners(){this.hls.on(y.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(y.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(y.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(y.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.on(y.DESTROYING,this.onDestroying,this)}unregisterListeners(){this.hls.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(y.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(y.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(y.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.off(y.DESTROYING,this.onDestroying,this)}getLicenseServerUrl(e){const{drmSystems:t,widevineLicenseUrl:i}=this.config,s=t?.[e];if(s)return s.licenseUrl;if(e===Ve.WIDEVINE&&i)return i}getLicenseServerUrlOrThrow(e){const t=this.getLicenseServerUrl(e);if(t===void 0)throw new Error(`no license server URL configured for key-system "${e}"`);return t}getServerCertificateUrl(e){const{drmSystems:t}=this.config,i=t?.[e];if(i)return i.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}attemptKeySystemAccess(e){const t=this.hls.levels,i=(n,o,c)=>!!n&&c.indexOf(n)===o,s=t.map(n=>n.audioCodec).filter(i),r=t.map(n=>n.videoCodec).filter(i);return s.length+r.length===0&&r.push("avc1.42e01e"),new Promise((n,o)=>{const c=u=>{const h=u.shift();this.getMediaKeysPromise(h,s,r).then(f=>n({keySystem:h,mediaKeys:f})).catch(f=>{u.length?c(u):f instanceof Dt?o(f):o(new Dt({type:de.KEY_SYSTEM_ERROR,details:U.KEY_SYSTEM_NO_ACCESS,error:f,fatal:!0},f.message))})};c(e)})}requestMediaKeySystemAccess(e,t){const{requestMediaKeySystemAccessFunc:i}=this.config;if(typeof i!="function"){let s=`Configured requestMediaKeySystemAccess is not a function ${i}`;return Va===null&&self.location.protocol==="http:"&&(s=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(s))}return i(e,t)}getMediaKeysPromise(e,t,i){var s;const r=Nc(e,t,i,this.config.drmSystemOptions||{});let n=this.keySystemAccessPromises[e],o=(s=n)==null?void 0:s.keySystemAccess;if(!o){this.log(`Requesting encrypted media "${e}" key-system access with config: ${Ge(r)}`),o=this.requestMediaKeySystemAccess(e,r);const c=n=this.keySystemAccessPromises[e]={keySystemAccess:o};return o.catch(u=>{this.log(`Failed to obtain access to key-system "${e}": ${u}`)}),o.then(u=>{this.log(`Access for key-system "${u.keySystem}" obtained`);const h=this.fetchServerCertificate(e);this.log(`Create media-keys for "${e}"`);const f=c.mediaKeys=u.createMediaKeys().then(g=>(this.log(`Media-keys created for "${e}"`),c.hasMediaKeys=!0,h.then(I=>I?this.setMediaKeysServerCertificate(g,e,I):g)));return f.catch(g=>{this.error(`Failed to create media-keys for "${e}"}: ${g}`)}),f})}return o.then(()=>n.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:i}){this.log(`Creating key-system session "${t}" keyId: ${It(e.keyId||[])}`);const s=i.createSession(),r={decryptdata:e,keySystem:t,mediaKeys:i,mediaKeysSession:s,keyStatus:"status-pending"};return this.mediaKeySessions.push(r),r}renewKeySession(e){const t=e.decryptdata;if(t.pssh){const i=this.createMediaKeySessionContext(e),s=this.getKeyIdString(t),r="cenc";this.keyIdToKeySessionPromise[s]=this.generateRequestWithPreferredKeySession(i,r,t.pssh.buffer,"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(e.keyId===null)throw new Error("keyId is null");return It(e.keyId)}updateKeySession(e,t){const i=e.mediaKeysSession;return this.log(`Updating key-session "${i.sessionId}" for keyId ${It(e.decryptdata.keyId||[])}
28
- } (data length: ${t.byteLength})`),i.update(t)}getSelectedKeySystemFormats(){return Object.keys(this.keySystemAccessPromises).map(e=>({keySystem:e,hasMediaKeys:this.keySystemAccessPromises[e].hasMediaKeys})).filter(({hasMediaKeys:e})=>!!e).map(({keySystem:e})=>Mr(e)).filter(e=>!!e)}getKeySystemAccess(e){return this.getKeySystemSelectionPromise(e).then(({keySystem:t,mediaKeys:i})=>this.attemptSetMediaKeys(t,i))}selectKeySystem(e){return new Promise((t,i)=>{this.getKeySystemSelectionPromise(e).then(({keySystem:s})=>{const r=Mr(s);r?t(r):i(new Error(`Unable to find format for key-system "${s}"`))}).catch(i)})}selectKeySystemFormat(e){const t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${e.sn} ${e.type}: ${e.level}) key formats ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}getKeyFormatPromise(e){const t=Qi(this.config),i=e.map(_s).filter(s=>!!s&&t.indexOf(s)!==-1);return this.selectKeySystem(i)}loadKey(e){const t=e.keyInfo.decryptdata,i=this.getKeyIdString(t),s=this.bannedKeyIds[i];if(s){const o=al(s,t);return this.handleError(o,e.frag),Promise.reject(o)}const r=`(keyId: ${i} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${r}`);const n=this.keyIdToKeySessionPromise[i];if(!n){const o=this.getKeySystemForKeyPromise(t).then(({keySystem:c,mediaKeys:u})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${r}`),this.attemptSetMediaKeys(c,u).then(()=>(this.throwIfDestroyed(),this.createMediaKeySessionContext({keySystem:c,mediaKeys:u,decryptdata:t}))))).then(c=>{const u="cenc",h=t.pssh?t.pssh.buffer:null;return this.generateRequestWithPreferredKeySession(c,u,h,"playlist-key")});return o.catch(c=>this.handleError(c,e.frag)),this.keyIdToKeySessionPromise[i]=o,o}return n}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e,t){this.hls&&(this.error(e.message),e instanceof Dt?(t&&(e.data.frag=t),this.hls.trigger(y.ERROR,e.data)):this.hls.trigger(y.ERROR,{type:de.KEY_SYSTEM_ERROR,details:U.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))}getKeySystemForKeyPromise(e){const t=this.getKeyIdString(e),i=this.keyIdToKeySessionPromise[t];if(!i){const s=_s(e.keyFormat),r=s?[s]:Qi(this.config);return this.attemptKeySystemAccess(r)}return i}getKeySystemSelectionPromise(e){if(e.length||(e=Qi(this.config)),e.length===0)throw new Dt({type:de.KEY_SYSTEM_ERROR,details:U.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${Ge({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}attemptSetMediaKeys(e,t){if(this.mediaKeys===t)return Promise.resolve();const i=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);const s=Promise.all(i).then(()=>{if(!this.media)throw this.mediaKeys=null,new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(t)});return this.mediaKeys=t,this.setMediaKeysQueue.push(s),s.then(()=>{this.log(`Media-keys set for "${e}"`),i.push(s),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(r=>i.indexOf(r)===-1)})}generateRequestWithPreferredKeySession(e,t,i,s){var r;const n=(r=this.config.drmSystems)==null||(r=r[e.keySystem])==null?void 0:r.generateRequest;if(n)try{const g=n.call(this.hls,t,i,e);if(!g)throw new Error("Invalid response from configured generateRequest filter");t=g.initDataType,i=g.initData?g.initData:null,e.decryptdata.pssh=i?new Uint8Array(i):null}catch(g){if(this.warn(g.message),this.hls&&this.hls.config.debug)throw g}if(i===null)return this.log(`Skipping key-session request for "${s}" (no initData)`),Promise.resolve(e);const o=this.getKeyIdString(e.decryptdata);this.log(`Generating key-session request for "${s}": ${o} (init data type: ${t} length: ${i.byteLength})`);const c=new Gr,u=e._onmessage=g=>{const I=e.mediaKeysSession;if(!I){c.emit("error",new Error("invalid state"));return}const{messageType:m,message:E}=g;this.log(`"${m}" message event for session "${I.sessionId}" message size: ${E.byteLength}`),m==="license-request"||m==="license-renewal"?this.renewLicense(e,E).catch(v=>{c.eventNames().length?c.emit("error",v):this.handleError(v)}):m==="license-release"?e.keySystem===Ve.FAIRPLAY&&(this.updateKeySession(e,kr("acknowledged")),this.removeSession(e)):this.warn(`unhandled media key message type "${m}"`)},h=e._onkeystatuseschange=g=>{if(!e.mediaKeysSession){c.emit("error",new Error("invalid state"));return}const m=e.keyStatus;this.onKeyStatusChange(e);const E=e.keyStatus;E!==m&&(c.emit("keyStatus",E,e),E==="expired"&&(this.log(`${e.keySystem} expired for key ${o}`),this.renewKeySession(e)))};ot(e.mediaKeysSession,"message",u),ot(e.mediaKeysSession,"keystatuseschange",h);const f=new Promise((g,I)=>{c.on("error",I),c.on("keyStatus",(m,{decryptdata:E})=>{m.startsWith("usable")?g():m==="internal-error"||m==="output-restricted"?I(al(m,E)):m==="expired"?I(new Error(`key expired while generating request (keyId: ${o})`)):this.warn(`unhandled key status change "${m}" (keyId: ${o})`)})});return e.mediaKeysSession.generateRequest(t,i).then(()=>{this.log(`Request generated for key-session "${e.mediaKeysSession.sessionId}" keyId: ${o}`)}).catch(g=>{throw new Dt({type:de.KEY_SYSTEM_ERROR,details:U.KEY_SYSTEM_NO_SESSION,error:g,decryptdata:e.decryptdata,fatal:!1},`Error generating key-session request: ${g}`)}).then(()=>f).catch(g=>{throw c.removeAllListeners(),this.removeSession(e),g}).then(()=>(c.removeAllListeners(),e))}onKeyStatusChange(e){const t=It(new Uint8Array(e.decryptdata.keyId||[]));e.mediaKeysSession.keyStatuses.forEach((i,s)=>{if(typeof s=="string"&&typeof i=="object"){const o=s;s=i,i=o}const r=It("buffer"in s?new Uint8Array(s.buffer,s.byteOffset,s.byteLength):new Uint8Array(s));i==="internal-error"&&(this.bannedKeyIds[r]=i);const n=r===t;this.log(`${n?"":"un"}matched key status change "${i}" for keyStatuses keyId: ${r} session keyId: ${t} uri: ${e.decryptdata.uri}`),n&&(e.keyStatus=i)})}fetchServerCertificate(e){const t=this.config,i=t.loader,s=new i(t),r=this.getServerCertificateUrl(e);return r?(this.log(`Fetching server certificate for "${e}"`),new Promise((n,o)=>{const c={responseType:"arraybuffer",url:r},u=t.certLoadPolicy.default,h={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},f={onSuccess:(g,I,m,E)=>{n(g.data)},onError:(g,I,m,E)=>{o(new Dt({type:de.KEY_SYSTEM_ERROR,details:U.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:m,response:Be({url:c.url,data:void 0},g)},`"${e}" certificate request failed (${r}). Status: ${g.code} (${g.text})`))},onTimeout:(g,I,m)=>{o(new Dt({type:de.KEY_SYSTEM_ERROR,details:U.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:m,response:{url:c.url,data:void 0}},`"${e}" certificate request timed out (${r})`))},onAbort:(g,I,m)=>{o(new Error("aborted"))}};s.load(c,h,f)})):Promise.resolve()}setMediaKeysServerCertificate(e,t,i){return new Promise((s,r)=>{e.setServerCertificate(i).then(n=>{this.log(`setServerCertificate ${n?"success":"not supported by CDM"} (${i.byteLength}) on "${t}"`),s(e)}).catch(n=>{r(new Dt({type:de.KEY_SYSTEM_ERROR,details:U.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:n,fatal:!0},n.message))})})}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then(i=>this.updateKeySession(e,new Uint8Array(i)).catch(s=>{throw new Dt({type:de.KEY_SYSTEM_ERROR,details:U.KEY_SYSTEM_SESSION_UPDATE_FAILED,decryptdata:e.decryptdata,error:s,fatal:!1},s.message)}))}unpackPlayReadyKeyMessage(e,t){const i=String.fromCharCode.apply(null,new Uint16Array(t.buffer));if(!i.includes("PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;const s=new DOMParser().parseFromString(i,"application/xml"),r=s.querySelectorAll("HttpHeader");if(r.length>0){let h;for(let f=0,g=r.length;f<g;f++){var n,o;h=r[f];const I=(n=h.querySelector("name"))==null?void 0:n.textContent,m=(o=h.querySelector("value"))==null?void 0:o.textContent;I&&m&&e.setRequestHeader(I,m)}}const c=s.querySelector("Challenge"),u=c?.textContent;if(!u)throw new Error("Cannot find <Challenge> in key message");return kr(atob(u))}setupLicenseXHR(e,t,i,s){const r=this.config.licenseXhrSetup;return r?Promise.resolve().then(()=>{if(!i.decryptdata)throw new Error("Key removed");return r.call(this.hls,e,t,i,s)}).catch(n=>{if(!i.decryptdata)throw n;return e.open("POST",t,!0),r.call(this.hls,e,t,i,s)}).then(n=>(e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:n||s})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:s}))}requestLicense(e,t){const i=this.config.keyLoadPolicy.default;return new Promise((s,r)=>{const n=this.getLicenseServerUrlOrThrow(e.keySystem);this.log(`Sending license request to URL: ${n}`);const o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return r(new Error("invalid state"));if(o.readyState===4)if(o.status===200){this._requestLicenseFailureCount=0;let c=o.response;this.log(`License received ${c instanceof ArrayBuffer?c.byteLength:c}`);const u=this.config.licenseResponseCallback;if(u)try{c=u.call(this.hls,o,n,e)}catch(h){this.error(h)}s(c)}else{const c=i.errorRetry,u=c?c.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>u||o.status>=400&&o.status<500)r(new Dt({type:de.KEY_SYSTEM_ERROR,details:U.KEY_SYSTEM_LICENSE_REQUEST_FAILED,decryptdata:e.decryptdata,fatal:!0,networkDetails:o,response:{url:n,data:void 0,code:o.status,text:o.statusText}},`License Request XHR failed (${n}). Status: ${o.status} (${o.statusText})`));else{const h=u-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${h} attempts left`),this.requestLicense(e,t).then(s,r)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,this.setupLicenseXHR(o,n,e,t).then(({xhr:c,licenseChallenge:u})=>{e.keySystem==Ve.PLAYREADY&&(u=this.unpackPlayReadyKeyMessage(c,u)),c.send(u)}).catch(r)})}onDestroying(){this.unregisterListeners(),this._clear()}onMediaAttached(e,t){if(!this.config.emeEnabled)return;const i=t.media;this.media=i,ot(i,"encrypted",this.onMediaEncrypted),ot(i,"waitingforkey",this.onWaitingForKey)}onMediaDetached(){const e=this.media;e&&(ht(e,"encrypted",this.onMediaEncrypted),ht(e,"waitingforkey",this.onWaitingForKey),this.media=null,this.mediaKeys=null)}_clear(){var e;if(this._requestLicenseFailureCount=0,this.keyIdToKeySessionPromise={},this.bannedKeyIds={},!this.mediaKeys&&!this.mediaKeySessions.length)return;const t=this.media,i=this.mediaKeySessions.slice();this.mediaKeySessions=[],this.mediaKeys=null,ks.clearKeyUriToKeyIdMap();const s=i.length;Ni.CDMCleanupPromise=Promise.all(i.map(r=>this.removeSession(r)).concat(t==null||(e=t.setMediaKeys(null))==null?void 0:e.catch(r=>{this.log(`Could not clear media keys: ${r}`),this.hls&&this.hls.trigger(y.ERROR,{type:de.OTHER_ERROR,details:U.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR,fatal:!1,error:new Error(`Could not clear media keys: ${r}`)})}))).catch(r=>{this.log(`Could not close sessions and clear media keys: ${r}`),this.hls&&this.hls.trigger(y.ERROR,{type:de.OTHER_ERROR,details:U.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close sessions and clear media keys: ${r}`)})}).then(()=>{s&&this.log("finished closing key sessions and clearing media keys")})}onManifestLoading(){this.keyFormatPromise=null,this.bannedKeyIds={}}onManifestLoaded(e,{sessionKeys:t}){if(!(!t||!this.config.emeEnabled)&&!this.keyFormatPromise){const i=t.reduce((s,r)=>(s.indexOf(r.keyFormat)===-1&&s.push(r.keyFormat),s),[]);this.log(`Selecting key-system from session-keys ${i.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(i)}}removeSession(e){const{mediaKeysSession:t,licenseXhr:i,decryptdata:s}=e;if(t){this.log(`Remove licenses and keys and close session "${t.sessionId}" keyId: ${It(s?.keyId||[])}`),e._onmessage&&(t.removeEventListener("message",e._onmessage),e._onmessage=void 0),e._onkeystatuseschange&&(t.removeEventListener("keystatuseschange",e._onkeystatuseschange),e._onkeystatuseschange=void 0),i&&i.readyState!==XMLHttpRequest.DONE&&i.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;const r=this.mediaKeySessions.indexOf(e);r>-1&&this.mediaKeySessions.splice(r,1);const{drmSystemOptions:n}=this.config;return(Uc(n)?new Promise((c,u)=>{self.setTimeout(()=>u(new Error("MediaKeySession.remove() timeout")),8e3),t.remove().then(c).catch(u)}):Promise.resolve()).catch(c=>{this.log(`Could not remove session: ${c}`),this.hls&&this.hls.trigger(y.ERROR,{type:de.OTHER_ERROR,details:U.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR,fatal:!1,error:new Error(`Could not remove session: ${c}`)})}).then(()=>t.close()).catch(c=>{this.log(`Could not close session: ${c}`),this.hls&&this.hls.trigger(y.ERROR,{type:de.OTHER_ERROR,details:U.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close session: ${c}`)})})}}}Ni.CDMCleanupPromise=void 0;class Dt 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}}function al(a,e){const t=a==="output-restricted",i=t?U.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:U.KEY_SYSTEM_STATUS_INTERNAL_ERROR;return new Dt({type:de.KEY_SYSTEM_ERROR,details:i,fatal:!1,decryptdata:e},t?"HDCP level output restricted":`key status changed to "${a}"`)}class tf{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(y.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(y.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListeners(){this.hls.off(y.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(y.MEDIA_DETACHING,this.onMediaDetaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){const i=this.hls.config;if(i.capLevelOnFPSDrop){const s=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=s,s&&typeof s.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),i.fpsDroppedMonitoringPeriod)}}onMediaDetaching(){this.media=null}checkFPS(e,t,i){const s=performance.now();if(t){if(this.lastTime){const r=s-this.lastTime,n=i-this.lastDroppedFrames,o=t-this.lastDecodedFrames,c=1e3*n/r,u=this.hls;if(u.trigger(y.FPS_DROP,{currentDropped:n,currentDecoded:o,totalDroppedFrames:i}),c>0&&n>u.config.fpsDroppedMonitoringThreshold*o){let h=u.currentLevel;u.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+h),h>0&&(u.autoLevelCapping===-1||u.autoLevelCapping>=h)&&(h=h-1,u.trigger(y.FPS_DROP_LEVEL_CAPPING,{level:h,droppedLevel:u.currentLevel}),u.autoLevelCapping=h,this.streamController.nextLevelSwitch())}}this.lastTime=s,this.lastDroppedFrames=i,this.lastDecodedFrames=t}}checkFPSInterval(){const e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){const t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}}function ol(a,e){let t;try{t=new Event("addtrack")}catch{t=document.createEvent("Event"),t.initEvent("addtrack",!1,!1)}t.track=a,e.dispatchEvent(t)}function ll(a,e){const t=a.mode;if(t==="disabled"&&(a.mode="hidden"),a.cues&&!a.cues.getCueById(e.id))try{if(a.addCue(e),!a.cues.getCueById(e.id))throw new Error(`addCue is failed for: ${e}`)}catch(i){Oe.debug(`[texttrack-utils]: ${i}`);try{const s=new self.TextTrackCue(e.startTime,e.endTime,e.text);s.id=e.id,a.addCue(s)}catch(s){Oe.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${s}`)}}t==="disabled"&&(a.mode=t)}function Bi(a,e){const t=a.mode;if(t==="disabled"&&(a.mode="hidden"),a.cues)for(let i=a.cues.length;i--;)e&&a.cues[i].removeEventListener("enter",e),a.removeCue(a.cues[i]);t==="disabled"&&(a.mode=t)}function cn(a,e,t,i){const s=a.mode;if(s==="disabled"&&(a.mode="hidden"),a.cues&&a.cues.length>0){const r=rf(a.cues,e,t);for(let n=0;n<r.length;n++)(!i||i(r[n]))&&a.removeCue(r[n])}s==="disabled"&&(a.mode=s)}function sf(a,e){if(e<=a[0].startTime)return 0;const t=a.length-1;if(e>a[t].endTime)return-1;let i=0,s=t,r;for(;i<=s;)if(r=Math.floor((s+i)/2),e<a[r].startTime)s=r-1;else if(e>a[r].startTime&&i<t)i=r+1;else return r;return a[i].startTime-e<e-a[s].startTime?i:s}function rf(a,e,t){const i=[],s=sf(a,e);if(s>-1)for(let r=s,n=a.length;r<n;r++){const o=a[r];if(o.startTime>=e&&o.endTime<=t)i.push(o);else if(o.startTime>t)return i}return i}function Ys(a){const e=[];for(let t=0;t<a.length;t++){const i=a[t];(i.kind==="subtitles"||i.kind==="captions")&&i.label&&e.push(a[t])}return e}class nf extends en{constructor(e){super(e,"subtitle-track-controller"),this.media=null,this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.onTextTracksChanged=()=>{if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let t=null;const i=Ys(this.media.textTracks);for(let r=0;r<i.length;r++)if(i[r].mode==="hidden")t=i[r];else if(i[r].mode==="showing"){t=i[r];break}const s=this.findTrackForTextTrack(t);this.subtitleTrack!==s&&this.setSubtitleTrack(s)},this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,this.onTextTracksChanged=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes()}registerListeners(){const{hls:e}=this;e.on(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_PARSED,this.onManifestParsed,this),e.on(y.LEVEL_LOADING,this.onLevelLoading,this),e.on(y.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(y.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(y.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_PARSED,this.onManifestParsed,this),e.off(y.LEVEL_LOADING,this.onLevelLoading,this),e.off(y.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(y.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(y.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.onTextTracksChanged,e)}onMediaDetaching(e,t){const i=this.media;if(!i)return;const s=!!t.transferMedia;if(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||i.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),this.subtitleTrack=-1,this.media=null,s)return;Ys(i.textTracks).forEach(n=>{Bi(n)})}onManifestLoading(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.subtitleTracks}onSubtitleTrackLoaded(e,t){const{id:i,groupId:s,details:r}=t,n=this.tracksInGroup[i];if(!n||n.groupId!==s){this.warn(`Subtitle track with id:${i} and group:${s} not found in active group ${n?.groupId}`);return}const o=n.details;n.details=t.details,this.log(`Subtitle track ${i} "${n.name}" lang:${n.lang} group:${s} loaded [${r.startSN}-${r.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(!t)return;const i=t.subtitleGroups||null,s=this.groupIds;let r=this.currentTrack;if(!i||s?.length!==i?.length||i!=null&&i.some(n=>s?.indexOf(n)===-1)){this.groupIds=i,this.trackId=-1,this.currentTrack=null;const n=this.tracks.filter(h=>!i||i.indexOf(h.groupId)!==-1);if(n.length)this.selectDefaultTrack&&!n.some(h=>h.default)&&(this.selectDefaultTrack=!1),n.forEach((h,f)=>{h.id=f});else if(!r&&!this.tracksInGroup.length)return;this.tracksInGroup=n;const o=this.hls.config.subtitlePreference;if(!r&&o){this.selectDefaultTrack=!1;const h=Ft(o,n);if(h>-1)r=n[h];else{const f=Ft(o,this.tracks);r=this.tracks[f]}}let c=this.findTrackId(r);c===-1&&r&&(c=this.findTrackId(null));const u={subtitleTracks:n};this.log(`Updating subtitle tracks, ${n.length} track(s) found in "${i?.join(",")}" group-id`),this.hls.trigger(y.SUBTITLE_TRACKS_UPDATED,u),c!==-1&&this.trackId===-1&&this.setSubtitleTrack(c)}}findTrackId(e){const t=this.tracksInGroup,i=this.selectDefaultTrack;for(let s=0;s<t.length;s++){const r=t[s];if(!(i&&!r.default||!i&&!e)&&(!e||Ii(r,e)))return s}if(e){for(let s=0;s<t.length;s++){const r=t[s];if(ns(e.attrs,r.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return s}for(let s=0;s<t.length;s++){const r=t[s];if(ns(e.attrs,r.attrs,["LANGUAGE"]))return s}}return-1}findTrackForTextTrack(e){if(e){const t=this.tracksInGroup;for(let i=0;i<t.length;i++){const s=t[i];if(tn(s,e))return i}}return-1}onError(e,t){t.fatal||!t.context||t.context.type===be.SUBTITLE_TRACK&&t.context.id===this.trackId&&(!this.groupIds||this.groupIds.indexOf(t.context.groupId)!==-1)&&this.checkRetry(t)}get allSubtitleTracks(){return this.tracks}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(e){this.selectDefaultTrack=!1,this.setSubtitleTrack(e)}setSubtitleOption(e){if(this.hls.config.subtitlePreference=e,e){if(e.id===-1)return this.setSubtitleTrack(-1),null;const t=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,t.length){const i=this.currentTrack;if(i&&Ii(e,i))return i;const s=Ft(e,this.tracksInGroup);if(s>-1){const r=this.tracksInGroup[s];return this.setSubtitleTrack(s),r}else{if(i)return null;{const r=Ft(e,t);if(r>-1)return t[r]}}}}return null}loadPlaylist(e){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentTrack)&&this.scheduleLoading(this.currentTrack,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);const i=e.id,s=e.groupId,r=this.getUrlWithDirectives(e.url,t),n=e.details,o=n?.age;this.log(`Loading subtitle ${i} "${e.name}" lang:${e.lang} group:${s}${t?.msn!==void 0?" at sn "+t.msn+" part "+t.part:""}${o&&n.live?" age "+o.toFixed(1)+(n.type&&" "+n.type||""):""} ${r}`),this.hls.trigger(y.SUBTITLE_TRACK_LOADING,{url:r,id:i,groupId:s,deliveryDirectives:t||null,track:e})}toggleTrackModes(){const{media:e}=this;if(!e)return;const t=Ys(e.textTracks),i=this.currentTrack;let s;if(i&&(s=t.filter(r=>tn(i,r))[0],s||this.warn(`Unable to find subtitle TextTrack with name "${i.name}" and language "${i.lang}"`)),[].slice.call(t).forEach(r=>{r.mode!=="disabled"&&r!==s&&(r.mode="disabled")}),s){const r=this.subtitleDisplay?"showing":"hidden";s.mode!==r&&(s.mode=r)}}setSubtitleTrack(e){const t=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(e<-1||e>=t.length||!se(e)){this.warn(`Invalid subtitle track id: ${e}`);return}this.selectDefaultTrack=!1;const i=this.currentTrack,s=t[e]||null;if(this.trackId=e,this.currentTrack=s,this.toggleTrackModes(),!s){this.hls.trigger(y.SUBTITLE_TRACK_SWITCH,{id:e});return}const r=!!s.details&&!s.details.live;if(e===this.trackId&&s===i&&r)return;this.log(`Switching to subtitle-track ${e}`+(s?` "${s.name}" lang:${s.lang} group:${s.groupId}`:""));const{id:n,groupId:o="",name:c,type:u,url:h}=s;this.hls.trigger(y.SUBTITLE_TRACK_SWITCH,{id:n,groupId:o,name:c,type:u,url:h});const f=this.switchParams(s.url,i?.details,s.details);this.loadPlaylist(f)}}function af(){try{return crypto.randomUUID()}catch{try{const e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch{let t=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,s=>{const r=(t+Math.random()*16)%16|0;return t=Math.floor(t/16),(s=="x"?r:r&3|8).toString(16)})}}}function as(a){let e=5381,t=a.length;for(;t;)e=e*33^a.charCodeAt(--t);return(e>>>0).toString()}const Ui=.025;let Ws=(function(a){return a[a.Point=0]="Point",a[a.Range=1]="Range",a})({});function of(a,e,t){return`${a.identifier}-${t+1}-${as(e)}`}class lf{constructor(e,t){this.base=void 0,this._duration=null,this._timelineStart=null,this.appendInPlaceDisabled=void 0,this.appendInPlaceStarted=void 0,this.dateRange=void 0,this.hasPlayed=!1,this.cumulativeDuration=0,this.resumeOffset=NaN,this.playoutLimit=NaN,this.restrictions={skip:!1,jump:!1},this.snapOptions={out:!1,in:!1},this.assetList=[],this.assetListLoader=void 0,this.assetListResponse=null,this.resumeAnchor=void 0,this.error=void 0,this.resetOnResume=void 0,this.base=t,this.dateRange=e,this.setDateRange(e)}setDateRange(e){this.dateRange=e,this.resumeOffset=e.attr.optionalFloat("X-RESUME-OFFSET",this.resumeOffset),this.playoutLimit=e.attr.optionalFloat("X-PLAYOUT-LIMIT",this.playoutLimit),this.restrictions=e.attr.enumeratedStringList("X-RESTRICT",this.restrictions),this.snapOptions=e.attr.enumeratedStringList("X-SNAP",this.snapOptions)}reset(){var e;this.appendInPlaceStarted=!1,(e=this.assetListLoader)==null||e.destroy(),this.assetListLoader=void 0,this.supplementsPrimary||(this.assetListResponse=null,this.assetList=[],this._duration=null)}isAssetPastPlayoutLimit(e){var t;if(e>0&&e>=this.assetList.length)return!0;const i=this.playoutLimit;return e<=0||isNaN(i)?!1:i===0?!0:(((t=this.assetList[e])==null?void 0:t.startOffset)||0)>i}findAssetIndex(e){return this.assetList.indexOf(e)}get identifier(){return this.dateRange.id}get startDate(){return this.dateRange.startDate}get startTime(){const e=this.dateRange.startTime;if(this.snapOptions.out){const t=this.dateRange.tagAnchor;if(t)return hn(e,t)}return e}get startOffset(){return this.cue.pre?0:this.startTime}get startIsAligned(){if(this.startTime===0||this.snapOptions.out)return!0;const e=this.dateRange.tagAnchor;if(e){const t=this.dateRange.startTime,i=hn(t,e);return t-i<.1}return!1}get resumptionOffset(){const e=this.resumeOffset,t=se(e)?e:this.duration;return this.cumulativeDuration+t}get resumeTime(){const e=this.startOffset+this.resumptionOffset;if(this.snapOptions.in){const t=this.resumeAnchor;if(t)return hn(e,t)}return e}get appendInPlace(){return this.appendInPlaceStarted?!0:this.appendInPlaceDisabled?!1:!!(!this.cue.once&&!this.cue.pre&&this.startIsAligned&&(isNaN(this.playoutLimit)&&isNaN(this.resumeOffset)||this.resumeOffset&&this.duration&&Math.abs(this.resumeOffset-this.duration)<Ui))}set appendInPlace(e){if(this.appendInPlaceStarted){this.resetOnResume=!e;return}this.appendInPlaceDisabled=!e}get timelineStart(){return this._timelineStart!==null?this._timelineStart:this.startTime}set timelineStart(e){this._timelineStart=e}get duration(){const e=this.playoutLimit;let t;return this._duration!==null?t=this._duration:this.dateRange.duration?t=this.dateRange.duration:t=this.dateRange.plannedDuration||0,!isNaN(e)&&e<t&&(t=e),t}set duration(e){this._duration=e}get cue(){return this.dateRange.cue}get timelineOccupancy(){return this.dateRange.attr["X-TIMELINE-OCCUPIES"]==="RANGE"?Ws.Range:Ws.Point}get supplementsPrimary(){return this.dateRange.attr["X-TIMELINE-STYLE"]==="PRIMARY"}get contentMayVary(){return this.dateRange.attr["X-CONTENT-MAY-VARY"]!=="NO"}get assetUrl(){return this.dateRange.attr["X-ASSET-URI"]}get assetListUrl(){return this.dateRange.attr["X-ASSET-LIST"]}get baseUrl(){return this.base.url}get assetListLoaded(){return this.assetList.length>0||this.assetListResponse!==null}toString(){return uf(this)}}function hn(a,e){return a-e.start<e.duration/2&&!(Math.abs(a-(e.start+e.duration))<Ui)?e.start:e.start+e.duration}function ul(a,e,t){const i=new self.URL(a,t);return i.protocol!=="data:"&&i.searchParams.set("_HLS_primary_id",e),i}function dn(a,e){for(;(t=a.assetList[++e])!=null&&t.error;)var t;return e}function uf(a){return`["${a.identifier}" ${a.cue.pre?"<pre>":a.cue.post?"<post>":""}${a.timelineStart.toFixed(2)}-${a.resumeTime.toFixed(2)}]`}function $i(a){const e=a.timelineStart,t=a.duration||0;return`["${a.identifier}" ${e.toFixed(2)}-${(e+t).toFixed(2)}]`}class cf{constructor(e,t,i,s){this.hls=void 0,this.interstitial=void 0,this.assetItem=void 0,this.tracks=null,this.hasDetails=!1,this.mediaAttached=null,this._currentTime=void 0,this._bufferedEosTime=void 0,this.checkPlayout=()=>{this.reachedPlayout(this.currentTime)&&this.hls&&this.hls.trigger(y.PLAYOUT_LIMIT_REACHED,{})};const r=this.hls=new e(t);this.interstitial=i,this.assetItem=s;const n=()=>{this.hasDetails=!0};r.once(y.LEVEL_LOADED,n),r.once(y.AUDIO_TRACK_LOADED,n),r.once(y.SUBTITLE_TRACK_LOADED,n),r.on(y.MEDIA_ATTACHING,(o,{media:c})=>{this.removeMediaListeners(),this.mediaAttached=c,this.interstitial.playoutLimit&&(c.addEventListener("timeupdate",this.checkPlayout),this.appendInPlace&&r.on(y.BUFFER_APPENDED,()=>{const h=this.bufferedEnd;this.reachedPlayout(h)&&(this._bufferedEosTime=h,r.trigger(y.BUFFERED_TO_END,void 0))}))})}get appendInPlace(){return this.interstitial.appendInPlace}loadSource(){const e=this.hls;if(e)if(e.url)e.levels.length&&!e.started&&e.startLoad(-1,!0);else{let t=this.assetItem.uri;try{t=ul(t,e.config.primarySessionId||"").href}catch{}e.loadSource(t)}}bufferedInPlaceToEnd(e){var t;if(!this.appendInPlace)return!1;if((t=this.hls)!=null&&t.bufferedToEnd)return!0;if(!e)return!1;const i=Math.min(this._bufferedEosTime||1/0,this.duration),s=this.timelineOffset,r=ye.bufferInfo(e,s,0);return this.getAssetTime(r.end)>=i-.02}reachedPlayout(e){const i=this.interstitial.playoutLimit;return this.startOffset+e>=i}get destroyed(){var e;return!((e=this.hls)!=null&&e.userConfig)}get assetId(){return this.assetItem.identifier}get interstitialId(){return this.assetItem.parentIdentifier}get media(){var e;return((e=this.hls)==null?void 0:e.media)||null}get bufferedEnd(){const e=this.media||this.mediaAttached;if(!e)return this._bufferedEosTime?this._bufferedEosTime:this.currentTime;const t=ye.bufferInfo(e,e.currentTime,.001);return this.getAssetTime(t.end)}get currentTime(){const e=this.media||this.mediaAttached;return e?this.getAssetTime(e.currentTime):this._currentTime||0}get duration(){const e=this.assetItem.duration;if(!e)return 0;const t=this.interstitial.playoutLimit;if(t){const i=t-this.startOffset;if(i>0&&i<e)return i}return e}get remaining(){const e=this.duration;return e?Math.max(0,e-this.currentTime):0}get startOffset(){return this.assetItem.startOffset}get timelineOffset(){var e;return((e=this.hls)==null?void 0:e.config.timelineOffset)||0}set timelineOffset(e){const t=this.timelineOffset;if(e!==t){const i=e-t;if(Math.abs(i)>1/9e4&&this.hls){if(this.hasDetails)throw new Error("Cannot set timelineOffset after playlists are loaded");this.hls.config.timelineOffset=e}}}getAssetTime(e){const t=this.timelineOffset,i=this.duration;return Math.min(Math.max(0,e-t),i)}removeMediaListeners(){const e=this.mediaAttached;e&&(this._currentTime=e.currentTime,this.bufferSnapShot(),e.removeEventListener("timeupdate",this.checkPlayout))}bufferSnapShot(){if(this.mediaAttached){var e;(e=this.hls)!=null&&e.bufferedToEnd&&(this._bufferedEosTime=this.bufferedEnd)}}destroy(){this.removeMediaListeners(),this.hls&&this.hls.destroy(),this.hls=null,this.tracks=this.mediaAttached=this.checkPlayout=null}attachMedia(e){var t;this.loadSource(),(t=this.hls)==null||t.attachMedia(e)}detachMedia(){var e;this.removeMediaListeners(),this.mediaAttached=null,(e=this.hls)==null||e.detachMedia()}resumeBuffering(){var e;(e=this.hls)==null||e.resumeBuffering()}pauseBuffering(){var e;(e=this.hls)==null||e.pauseBuffering()}transferMedia(){var e;return this.bufferSnapShot(),((e=this.hls)==null?void 0:e.transferMedia())||null}resetDetails(){const e=this.hls;if(e&&this.hasDetails){e.stopLoad();const t=i=>delete i.details;e.levels.forEach(t),e.allAudioTracks.forEach(t),e.allSubtitleTracks.forEach(t),this.hasDetails=!1}}on(e,t,i){var s;(s=this.hls)==null||s.on(e,t)}once(e,t,i){var s;(s=this.hls)==null||s.once(e,t)}off(e,t,i){var s;(s=this.hls)==null||s.off(e,t)}toString(){var e;return`HlsAssetPlayer: ${$i(this.assetItem)} ${(e=this.hls)==null?void 0:e.sessionId} ${this.appendInPlace?"append-in-place":""}`}}const cl=.033;class hf extends Tt{constructor(e,t){super("interstitials-sched",t),this.onScheduleUpdate=void 0,this.eventMap={},this.events=null,this.items=null,this.durations={primary:0,playout:0,integrated:0},this.onScheduleUpdate=e}destroy(){this.reset(),this.onScheduleUpdate=null}reset(){this.eventMap={},this.setDurations(0,0,0),this.events&&this.events.forEach(e=>e.reset()),this.events=this.items=null}resetErrorsInRange(e,t){return this.events?this.events.reduce((i,s)=>e<=s.startOffset&&t>s.startOffset?(delete s.error,i+1):i,0):0}get duration(){const e=this.items;return e?e[e.length-1].end:0}get length(){return this.items?this.items.length:0}getEvent(e){return e&&this.eventMap[e]||null}hasEvent(e){return e in this.eventMap}findItemIndex(e,t){if(e.event)return this.findEventIndex(e.event.identifier);let i=-1;e.nextEvent?i=this.findEventIndex(e.nextEvent.identifier)-1:e.previousEvent&&(i=this.findEventIndex(e.previousEvent.identifier)+1);const s=this.items;if(s)for(s[i]||(t===void 0&&(t=e.start),i=this.findItemIndexAtTime(t));i>=0&&(r=s[i])!=null&&r.event;){var r;i--}return i}findItemIndexAtTime(e,t){const i=this.items;if(i)for(let s=0;s<i.length;s++){let r=i[s];if(t&&t!=="primary"&&(r=r[t]),e===r.start||e>r.start&&e<r.end)return s}return-1}findJumpRestrictedIndex(e,t){const i=this.items;if(i)for(let s=e;s<=t&&i[s];s++){const r=i[s].event;if(r!=null&&r.restrictions.jump&&!r.appendInPlace)return s}return-1}findEventIndex(e){const t=this.items;if(t)for(let s=t.length;s--;){var i;if(((i=t[s].event)==null?void 0:i.identifier)===e)return s}return-1}findAssetIndex(e,t){const i=e.assetList,s=i.length;if(s>1)for(let r=0;r<s;r++){const n=i[r];if(!n.error){const o=n.timelineStart;if(t===o||t>o&&(t<o+(n.duration||0)||r===s-1))return r}}return 0}get assetIdAtEnd(){var e;const t=(e=this.items)==null||(e=e[this.length-1])==null?void 0:e.event;if(t){const i=t.assetList,s=i[i.length-1];if(s)return s.identifier}return null}parseInterstitialDateRanges(e,t){const i=e.main.details,{dateRanges:s}=i,r=this.events,n=this.parseDateRanges(s,{url:i.url},t),o=Object.keys(s),c=r?r.filter(u=>!o.includes(u.identifier)):[];n.length&&n.sort((u,h)=>{const f=u.cue.pre,g=u.cue.post,I=h.cue.pre,m=h.cue.post;if(f&&!I)return-1;if(I&&!f||g&&!m)return 1;if(m&&!g)return-1;if(!f&&!I&&!g&&!m){const E=u.startTime,v=h.startTime;if(E!==v)return E-v}return u.dateRange.tagOrder-h.dateRange.tagOrder}),this.events=n,c.forEach(u=>{this.removeEvent(u)}),this.updateSchedule(e,c)}updateSchedule(e,t=[],i=!1){const s=this.events||[];if(s.length||t.length||this.length<2){const r=this.items,n=this.parseSchedule(s,e);(i||t.length||r?.length!==n.length||n.some((c,u)=>Math.abs(c.playout.start-r[u].playout.start)>.005||Math.abs(c.playout.end-r[u].playout.end)>.005))&&(this.items=n,this.onScheduleUpdate(t,r))}}parseDateRanges(e,t,i){const s=[],r=Object.keys(e);for(let n=0;n<r.length;n++){const o=r[n],c=e[o];if(c.isInterstitial){let u=this.eventMap[o];u?u.setDateRange(c):(u=new lf(c,t),this.eventMap[o]=u,i===!1&&(u.appendInPlace=i)),s.push(u)}}return s}parseSchedule(e,t){const i=[],s=t.main.details,r=s.live?1/0:s.edge;let n=0;if(e=e.filter(c=>!c.error&&!(c.cue.once&&c.hasPlayed)),e.length){this.resolveOffsets(e,t);let c=0,u=0;if(e.forEach((h,f)=>{const g=h.cue.pre,I=h.cue.post,m=e[f-1]||null,E=h.appendInPlace,v=I?r:h.startOffset,x=h.duration,D=h.timelineOccupancy===Ws.Range?x:0,L=h.resumptionOffset,w=m?.startTime===v,N=v+h.cumulativeDuration;let K=E?N+x:v+L;if(g||!I&&v<=0){const $=u;u+=D,h.timelineStart=N;const F=n;n+=x,i.push({event:h,start:N,end:K,playout:{start:F,end:n},integrated:{start:$,end:u}})}else if(v<=r){if(!w){const O=v-c;if(O>cl){const W=c,ie=u;u+=O;const X=n;n+=O;const ce={previousEvent:e[f-1]||null,nextEvent:h,start:W,end:W+O,playout:{start:X,end:n},integrated:{start:ie,end:u}};i.push(ce)}else O>0&&m&&(m.cumulativeDuration+=O,i[i.length-1].end=v)}I&&(K=N),h.timelineStart=N;const $=u;u+=D;const F=n;n+=x,i.push({event:h,start:N,end:K,playout:{start:F,end:n},integrated:{start:$,end:u}})}else return;const p=h.resumeTime;I||p>r?c=r:c=p}),c<r){var o;const h=c,f=u,g=r-c;u+=g;const I=n;n+=g,i.push({previousEvent:((o=i[i.length-1])==null?void 0:o.event)||null,nextEvent:null,start:c,end:h+g,playout:{start:I,end:n},integrated:{start:f,end:u}})}this.setDurations(r,n,u)}else i.push({previousEvent:null,nextEvent:null,start:0,end:r,playout:{start:0,end:r},integrated:{start:0,end:r}}),this.setDurations(r,r,r);return i}setDurations(e,t,i){this.durations={primary:e,playout:t,integrated:i}}resolveOffsets(e,t){const i=t.main.details,s=i.live?1/0:i.edge;let r=0,n=-1;e.forEach((o,c)=>{const u=o.cue.pre,h=o.cue.post,f=u?0:h?s:o.startTime;this.updateAssetDurations(o),n===f?o.cumulativeDuration=r:(r=0,n=f),!h&&o.snapOptions.in&&(o.resumeAnchor=yi(null,i.fragments,o.startOffset+o.resumptionOffset,0,0)||void 0),o.appendInPlace&&!o.appendInPlaceStarted&&(this.primaryCanResumeInPlaceAt(o,t)||(o.appendInPlace=!1)),!o.appendInPlace&&c+1<e.length&&e[c+1].startTime-e[c].resumeTime<cl&&(e[c+1].appendInPlace=!1,e[c+1].appendInPlace&&this.warn(`Could not change append strategy for abutting event ${o}`));const I=se(o.resumeOffset)?o.resumeOffset:o.duration;r+=I})}primaryCanResumeInPlaceAt(e,t){const i=e.resumeTime,s=e.startTime+e.resumptionOffset;return Math.abs(i-s)>Ui?(this.log(`"${e.identifier}" resumption ${i} not aligned with estimated timeline end ${s}`),!1):!Object.keys(t).some(n=>{const o=t[n].details,c=o.edge;if(i>=c)return this.log(`"${e.identifier}" resumption ${i} past ${n} playlist end ${c}`),!1;const u=yi(null,o.fragments,i);if(!u)return this.log(`"${e.identifier}" resumption ${i} does not align with any fragments in ${n} playlist (${o.fragStart}-${o.fragmentEnd})`),!0;const h=n==="audio"?.175:0;return Math.abs(u.start-i)<Ui+h||Math.abs(u.end-i)<Ui+h?!1:(this.log(`"${e.identifier}" resumption ${i} not aligned with ${n} fragment bounds (${u.start}-${u.end} sn: ${u.sn} cc: ${u.cc})`),!0)})}updateAssetDurations(e){if(!e.assetListLoaded)return;const t=e.timelineStart;let i=0,s=!1,r=!1;for(let n=0;n<e.assetList.length;n++){const o=e.assetList[n],c=t+i;o.startOffset=i,o.timelineStart=c,s||(s=o.duration===null),r||(r=!!o.error);const u=o.error?0:o.duration||0;i+=u}s&&!r?e.duration=Math.max(i,e.duration):e.duration=i}removeEvent(e){e.reset(),delete this.eventMap[e.identifier]}}function Pt(a){return`[${a.event?'"'+a.event.identifier+'"':"primary"}: ${a.start.toFixed(2)}-${a.end.toFixed(2)}]`}class df{constructor(e){this.hls=void 0,this.hls=e}destroy(){this.hls=null}loadAssetList(e,t){const i=e.assetListUrl;let s;try{s=ul(i,this.hls.sessionId,e.baseUrl)}catch(g){const I=this.assignAssetListError(e,U.ASSET_LIST_LOAD_ERROR,g,i);this.hls.trigger(y.ERROR,I);return}t&&s.protocol!=="data:"&&s.searchParams.set("_HLS_start_offset",""+t);const r=this.hls.config,n=r.loader,o=new n(r),c={responseType:"json",url:s.href},u=r.interstitialAssetListLoadPolicy.default,h={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},f={onSuccess:(g,I,m,E)=>{const v=g.data,x=v?.ASSETS;if(!Array.isArray(x)){const D=this.assignAssetListError(e,U.ASSET_LIST_PARSING_ERROR,new Error("Invalid interstitial asset list"),m.url,I,E);this.hls.trigger(y.ERROR,D);return}e.assetListResponse=v,this.hls.trigger(y.ASSET_LIST_LOADED,{event:e,assetListResponse:v,networkDetails:E})},onError:(g,I,m,E)=>{const v=this.assignAssetListError(e,U.ASSET_LIST_LOAD_ERROR,new Error(`Error loading X-ASSET-LIST: HTTP status ${g.code} ${g.text} (${I.url})`),I.url,E,m);this.hls.trigger(y.ERROR,v)},onTimeout:(g,I,m)=>{const E=this.assignAssetListError(e,U.ASSET_LIST_LOAD_TIMEOUT,new Error(`Timeout loading X-ASSET-LIST (${I.url})`),I.url,g,m);this.hls.trigger(y.ERROR,E)}};return o.load(c,h,f),this.hls.trigger(y.ASSET_LIST_LOADING,{event:e}),o}assignAssetListError(e,t,i,s,r,n){return e.error=i,{type:de.NETWORK_ERROR,details:t,fatal:!1,interstitial:e,url:s,error:i,networkDetails:n,stats:r}}}function hl(a){a?.play().catch(()=>{})}function js(a,e){return`[${a}] Advancing timeline position to ${e}`}class ff extends Tt{constructor(e,t){super("interstitials",e.logger),this.HlsPlayerClass=void 0,this.hls=void 0,this.assetListLoader=void 0,this.mediaSelection=null,this.altSelection=null,this.media=null,this.detachedData=null,this.requiredTracks=null,this.manager=null,this.playerQueue=[],this.bufferedPos=-1,this.timelinePos=-1,this.schedule=void 0,this.playingItem=null,this.bufferingItem=null,this.waitingItem=null,this.endedItem=null,this.playingAsset=null,this.endedAsset=null,this.bufferingAsset=null,this.shouldPlay=!1,this.onPlay=()=>{this.shouldPlay=!0},this.onPause=()=>{this.shouldPlay=!1},this.onSeeking=()=>{const i=this.currentTime;if(i===void 0||this.playbackDisabled||!this.schedule)return;const s=i-this.timelinePos;if(Math.abs(s)<1/7056e5)return;const n=s<=-.01;this.timelinePos=i,this.bufferedPos=i;const o=this.playingItem;if(!o){this.checkBuffer();return}if(n&&this.schedule.resetErrorsInRange(i,i-s)&&this.updateSchedule(!0),this.checkBuffer(),n&&i<o.start||i>=o.end){var c;const I=this.findItemIndex(o);let m=this.schedule.findItemIndexAtTime(i);if(m===-1&&(m=I+(n?-1:1),this.log(`seeked ${n?"back ":""}to position not covered by schedule ${i} (resolving from ${I} to ${m})`)),!this.isInterstitial(o)&&(c=this.media)!=null&&c.paused&&(this.shouldPlay=!1),!n&&m>I){const E=this.schedule.findJumpRestrictedIndex(I+1,m);if(E>I){this.setSchedulePosition(E);return}}this.setSchedulePosition(m);return}const u=this.playingAsset;if(!u){if(this.playingLastItem&&this.isInterstitial(o)){const I=o.event.assetList[0];I&&(this.endedItem=this.playingItem,this.playingItem=null,this.setScheduleToAssetAtTime(i,I))}return}const h=u.timelineStart,f=u.duration||0;if(n&&i<h||i>=h+f){var g;(g=o.event)!=null&&g.appendInPlace&&(this.clearInterstitial(o.event,o),this.flushFrontBuffer(i)),this.setScheduleToAssetAtTime(i,u)}},this.onTimeupdate=()=>{const i=this.currentTime;if(i===void 0||this.playbackDisabled)return;if(i>this.timelinePos)this.timelinePos=i,i>this.bufferedPos&&this.checkBuffer();else return;const s=this.playingItem;if(!s||this.playingLastItem)return;if(i>=s.end){this.timelinePos=s.end;const o=this.findItemIndex(s);this.setSchedulePosition(o+1)}const r=this.playingAsset;if(!r)return;const n=r.timelineStart+(r.duration||0);i>=n&&this.setScheduleToAssetAtTime(i,r)},this.onScheduleUpdate=(i,s)=>{const r=this.schedule;if(!r)return;const n=this.playingItem,o=r.events||[],c=r.items||[],u=r.durations,h=i.map(E=>E.identifier),f=!!(o.length||h.length);(f||s)&&this.log(`INTERSTITIALS_UPDATED (${o.length}): ${o}
29
- Schedule: ${c.map(E=>Pt(E))} pos: ${this.timelinePos}`),h.length&&this.log(`Removed events ${h}`);let g=null,I=null;n&&(g=this.updateItem(n,this.timelinePos),this.itemsMatch(n,g)?this.playingItem=g:this.waitingItem=this.endedItem=null),this.waitingItem=this.updateItem(this.waitingItem),this.endedItem=this.updateItem(this.endedItem);const m=this.bufferingItem;if(m&&(I=this.updateItem(m,this.bufferedPos),this.itemsMatch(m,I)?this.bufferingItem=I:m.event&&(this.bufferingItem=this.playingItem,this.clearInterstitial(m.event,null))),i.forEach(E=>{E.assetList.forEach(v=>{this.clearAssetPlayer(v.identifier,null)})}),this.playerQueue.forEach(E=>{if(E.interstitial.appendInPlace){const v=E.assetItem.timelineStart,x=E.timelineOffset-v;if(x)try{E.timelineOffset=v}catch(D){Math.abs(x)>Ui&&this.warn(`${D} ("${E.assetId}" ${E.timelineOffset}->${v})`)}}}),f||s){if(this.hls.trigger(y.INTERSTITIALS_UPDATED,{events:o.slice(0),schedule:c.slice(0),durations:u,removedIds:h}),this.isInterstitial(n)&&h.includes(n.event.identifier)){this.warn(`Interstitial "${n.event.identifier}" removed while playing`),this.primaryFallback(n.event);return}n&&this.trimInPlace(g,n),m&&I!==g&&this.trimInPlace(I,m),this.checkBuffer()}},this.hls=e,this.HlsPlayerClass=t,this.assetListLoader=new df(e),this.schedule=new hf(this.onScheduleUpdate,e.logger),this.registerListeners()}registerListeners(){const e=this.hls;e&&(e.on(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(y.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(y.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.on(y.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(y.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.on(y.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.on(y.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.on(y.BUFFER_APPENDED,this.onBufferAppended,this),e.on(y.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(y.BUFFERED_TO_END,this.onBufferedToEnd,this),e.on(y.MEDIA_ENDED,this.onMediaEnded,this),e.on(y.ERROR,this.onError,this),e.on(y.DESTROYING,this.onDestroying,this))}unregisterListeners(){const e=this.hls;e&&(e.off(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(y.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(y.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.off(y.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(y.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.off(y.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.off(y.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.off(y.BUFFER_CODECS,this.onBufferCodecs,this),e.off(y.BUFFER_APPENDED,this.onBufferAppended,this),e.off(y.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(y.BUFFERED_TO_END,this.onBufferedToEnd,this),e.off(y.MEDIA_ENDED,this.onMediaEnded,this),e.off(y.ERROR,this.onError,this),e.off(y.DESTROYING,this.onDestroying,this))}startLoad(){this.resumeBuffering()}stopLoad(){this.pauseBuffering()}resumeBuffering(){var e;(e=this.getBufferingPlayer())==null||e.resumeBuffering()}pauseBuffering(){var e;(e=this.getBufferingPlayer())==null||e.pauseBuffering()}destroy(){this.unregisterListeners(),this.stopLoad(),this.assetListLoader&&this.assetListLoader.destroy(),this.emptyPlayerQueue(),this.clearScheduleState(),this.schedule&&this.schedule.destroy(),this.media=this.detachedData=this.mediaSelection=this.requiredTracks=this.altSelection=this.schedule=this.manager=null,this.hls=this.HlsPlayerClass=this.log=null,this.assetListLoader=null,this.onPlay=this.onPause=this.onSeeking=this.onTimeupdate=null,this.onScheduleUpdate=null}onDestroying(){const e=this.primaryMedia||this.media;e&&this.removeMediaListeners(e)}removeMediaListeners(e){ht(e,"play",this.onPlay),ht(e,"pause",this.onPause),ht(e,"seeking",this.onSeeking),ht(e,"timeupdate",this.onTimeupdate)}onMediaAttaching(e,t){const i=this.media=t.media;ot(i,"seeking",this.onSeeking),ot(i,"timeupdate",this.onTimeupdate),ot(i,"play",this.onPlay),ot(i,"pause",this.onPause)}onMediaAttached(e,t){const i=this.effectivePlayingItem,s=this.detachedData;if(this.detachedData=null,i===null)this.checkStart();else if(!s){this.clearScheduleState();const r=this.findItemIndex(i);this.setSchedulePosition(r)}}clearScheduleState(){this.log("clear schedule state"),this.playingItem=this.bufferingItem=this.waitingItem=this.endedItem=this.playingAsset=this.endedAsset=this.bufferingAsset=null}onMediaDetaching(e,t){const i=!!t.transferMedia,s=this.media;if(this.media=null,!i&&(s&&this.removeMediaListeners(s),this.detachedData)){const r=this.getBufferingPlayer();r&&(this.log(`Removing schedule state for detachedData and ${r}`),this.playingAsset=this.endedAsset=this.bufferingAsset=this.bufferingItem=this.waitingItem=this.detachedData=null,r.detachMedia()),this.shouldPlay=!1}}get interstitialsManager(){if(!this.hls)return null;if(this.manager)return this.manager;const e=this,t=()=>e.bufferingItem||e.waitingItem,i=f=>f&&e.getAssetPlayer(f.identifier),s=(f,g,I,m,E)=>{if(f){let v=f[g].start;const x=f.event;if(x){if(g==="playout"||x.timelineOccupancy!==Ws.Point){const D=i(I);D?.interstitial===x&&(v+=D.assetItem.startOffset+D[E])}}else{const D=m==="bufferedPos"?n():e[m];v+=D-f.start}return v}return 0},r=(f,g)=>{var I;if(f!==0&&g!=="primary"&&(I=e.schedule)!=null&&I.length){var m;const E=e.schedule.findItemIndexAtTime(f),v=(m=e.schedule.items)==null?void 0:m[E];if(v){const x=v[g].start-v.start;return f+x}}return f},n=()=>{const f=e.bufferedPos;return f===Number.MAX_VALUE?o("primary"):Math.max(f,0)},o=f=>{var g,I;return(g=e.primaryDetails)!=null&&g.live?e.primaryDetails.edge:((I=e.schedule)==null?void 0:I.durations[f])||0},c=(f,g)=>{var I,m;const E=e.effectivePlayingItem;if(E!=null&&(I=E.event)!=null&&I.restrictions.skip||!e.schedule)return;e.log(`seek to ${f} "${g}"`);const v=e.effectivePlayingItem,x=e.schedule.findItemIndexAtTime(f,g),D=(m=e.schedule.items)==null?void 0:m[x],L=e.getBufferingPlayer(),w=L?.interstitial,N=w?.appendInPlace,K=v&&e.itemsMatch(v,D);if(v&&(N||K)){const p=i(e.playingAsset),$=p?.media||e.primaryMedia;if($){const F=g==="primary"?$.currentTime:s(v,g,e.playingAsset,"timelinePos","currentTime"),O=f-F,W=(N?F:$.currentTime)+O;if(W>=0&&(!p||N||W<=p.duration)){$.currentTime=W;return}}}if(D){let p=f;if(g!=="primary"){const F=D[g].start,O=f-F;p=D.start+O}const $=!e.isInterstitial(D);if((!e.isInterstitial(v)||v.event.appendInPlace)&&($||D.event.appendInPlace)){const F=e.media||(N?L?.media:null);F&&(F.currentTime=p)}else if(v){const F=e.findItemIndex(v);if(x>F){const W=e.schedule.findJumpRestrictedIndex(F+1,x);if(W>F){e.setSchedulePosition(W);return}}let O=0;if($)e.timelinePos=p,e.checkBuffer();else{const W=D.event.assetList,ie=f-(D[g]||D).start;for(let X=W.length;X--;){const ce=W[X];if(ce.duration&&ie>=ce.startOffset&&ie<ce.startOffset+ce.duration){O=X;break}}}e.setSchedulePosition(x,O)}}},u=()=>{const f=e.effectivePlayingItem;if(e.isInterstitial(f))return f;const g=t();return e.isInterstitial(g)?g:null},h={get bufferedEnd(){const f=t(),g=e.bufferingItem;if(g&&g===f){var I;return s(g,"playout",e.bufferingAsset,"bufferedPos","bufferedEnd")-g.playout.start||((I=e.bufferingAsset)==null?void 0:I.startOffset)||0}return 0},get currentTime(){const f=u(),g=e.effectivePlayingItem;return g&&g===f?s(g,"playout",e.effectivePlayingAsset,"timelinePos","currentTime")-g.playout.start:0},set currentTime(f){const g=u(),I=e.effectivePlayingItem;I&&I===g&&c(f+I.playout.start,"playout")},get duration(){const f=u();return f?f.playout.end-f.playout.start:0},get assetPlayers(){var f;const g=(f=u())==null?void 0:f.event.assetList;return g?g.map(I=>e.getAssetPlayer(I.identifier)):[]},get playingIndex(){var f;const g=(f=u())==null?void 0:f.event;return g&&e.effectivePlayingAsset?g.findAssetIndex(e.effectivePlayingAsset):-1},get scheduleItem(){return u()}};return this.manager={get events(){var f;return((f=e.schedule)==null||(f=f.events)==null?void 0:f.slice(0))||[]},get schedule(){var f;return((f=e.schedule)==null||(f=f.items)==null?void 0:f.slice(0))||[]},get interstitialPlayer(){return u()?h:null},get playerQueue(){return e.playerQueue.slice(0)},get bufferingAsset(){return e.bufferingAsset},get bufferingItem(){return t()},get bufferingIndex(){const f=t();return e.findItemIndex(f)},get playingAsset(){return e.effectivePlayingAsset},get playingItem(){return e.effectivePlayingItem},get playingIndex(){const f=e.effectivePlayingItem;return e.findItemIndex(f)},primary:{get bufferedEnd(){return n()},get currentTime(){const f=e.timelinePos;return f>0?f:0},set currentTime(f){c(f,"primary")},get duration(){return o("primary")},get seekableStart(){var f;return((f=e.primaryDetails)==null?void 0:f.fragmentStart)||0}},integrated:{get bufferedEnd(){return s(t(),"integrated",e.bufferingAsset,"bufferedPos","bufferedEnd")},get currentTime(){return s(e.effectivePlayingItem,"integrated",e.effectivePlayingAsset,"timelinePos","currentTime")},set currentTime(f){c(f,"integrated")},get duration(){return o("integrated")},get seekableStart(){var f;return r(((f=e.primaryDetails)==null?void 0:f.fragmentStart)||0,"integrated")}},skip:()=>{const f=e.effectivePlayingItem,g=f?.event;if(g&&!g.restrictions.skip){const I=e.findItemIndex(f);if(g.appendInPlace){const m=f.playout.start+f.event.duration;c(m+.001,"playout")}else e.advanceAfterAssetEnded(g,I,1/0)}}}}get effectivePlayingItem(){return this.waitingItem||this.playingItem||this.endedItem}get effectivePlayingAsset(){return this.playingAsset||this.endedAsset}get playingLastItem(){var e;const t=this.playingItem,i=(e=this.schedule)==null?void 0:e.items;return!this.playbackStarted||!t||!i?!1:this.findItemIndex(t)===i.length-1}get playbackStarted(){return this.effectivePlayingItem!==null}get currentTime(){var e,t;if(this.mediaSelection===null)return;const i=this.waitingItem||this.playingItem;if(this.isInterstitial(i)&&!i.event.appendInPlace)return;let s=this.media;!s&&(e=this.bufferingItem)!=null&&(e=e.event)!=null&&e.appendInPlace&&(s=this.primaryMedia);const r=(t=s)==null?void 0:t.currentTime;if(!(r===void 0||!se(r)))return r}get primaryMedia(){var e;return this.media||((e=this.detachedData)==null?void 0:e.media)||null}isInterstitial(e){return!!(e!=null&&e.event)}retreiveMediaSource(e,t){const i=this.getAssetPlayer(e);i&&this.transferMediaFromPlayer(i,t)}transferMediaFromPlayer(e,t){const i=e.interstitial.appendInPlace,s=e.media;if(i&&s===this.primaryMedia){if(this.bufferingAsset=null,(!t||this.isInterstitial(t)&&!t.event.appendInPlace)&&t&&s){this.detachedData={media:s};return}const r=e.transferMedia();this.log(`transfer MediaSource from ${e} ${Ge(r)}`),this.detachedData=r}else t&&s&&(this.shouldPlay||(this.shouldPlay=!s.paused))}transferMediaTo(e,t){var i,s;if(e.media===t)return;let r=null;const n=this.hls,o=e!==n,c=o&&e.interstitial.appendInPlace,u=(i=this.detachedData)==null?void 0:i.mediaSource;let h;if(n.media)c&&(r=n.transferMedia(),this.detachedData=r),h="Primary";else if(u){const m=this.getBufferingPlayer();m?(r=m.transferMedia(),h=`${m}`):h="detached MediaSource"}else h="detached media";if(!r){if(u)r=this.detachedData,this.log(`using detachedData: MediaSource ${Ge(r)}`);else if(!this.detachedData||n.media===t){const m=this.playerQueue;m.length>1&&m.forEach(E=>{if(o&&E.interstitial.appendInPlace!==c){const v=E.interstitial;this.clearInterstitial(E.interstitial,null),v.appendInPlace=!1,v.appendInPlace&&this.warn(`Could not change append strategy for queued assets ${v}`)}}),this.hls.detachMedia(),this.detachedData={media:t}}}const f=r&&"mediaSource"in r&&((s=r.mediaSource)==null?void 0:s.readyState)!=="closed",g=f&&r?r:t;this.log(`${f?"transfering MediaSource":"attaching media"} to ${o?e:"Primary"} from ${h} (media.currentTime: ${t.currentTime})`);const I=this.schedule;if(g===r&&I){const m=o&&e.assetId===I.assetIdAtEnd;g.overrides={duration:I.duration,endOfStream:!o||m,cueRemoval:!o}}e.attachMedia(g)}onInterstitialCueEnter(){this.onTimeupdate()}checkStart(){const e=this.schedule,t=e?.events;if(!t||this.playbackDisabled||!this.media)return;this.bufferedPos===-1&&(this.bufferedPos=0);const i=this.timelinePos,s=this.effectivePlayingItem;if(i===-1){const r=this.hls.startPosition;if(this.log(js("checkStart",r)),this.timelinePos=r,t.length&&t[0].cue.pre){const n=e.findEventIndex(t[0].identifier);this.setSchedulePosition(n)}else if(r>=0||!this.primaryLive){const n=this.timelinePos=r>0?r:0,o=e.findItemIndexAtTime(n);this.setSchedulePosition(o)}}else if(s&&!this.playingItem){const r=e.findItemIndex(s);this.setSchedulePosition(r)}}advanceAssetBuffering(e,t){const i=e.event,s=i.findAssetIndex(t),r=dn(i,s);if(!i.isAssetPastPlayoutLimit(r))this.bufferedToEvent(e,r);else if(this.schedule){var n;const o=(n=this.schedule.items)==null?void 0:n[this.findItemIndex(e)+1];o&&this.bufferedToItem(o)}}advanceAfterAssetEnded(e,t,i){const s=dn(e,i);if(e.isAssetPastPlayoutLimit(s)){if(this.schedule){const r=this.schedule.items;if(r){const n=t+1,o=r.length;if(n>=o){this.setSchedulePosition(-1);return}const c=e.resumeTime;this.timelinePos<c&&(this.log(js("advanceAfterAssetEnded",c)),this.timelinePos=c,e.appendInPlace&&this.advanceInPlace(c),this.checkBuffer(this.bufferedPos<c)),this.setSchedulePosition(n)}}}else{if(e.appendInPlace){const r=e.assetList[s];r&&this.advanceInPlace(r.timelineStart)}this.setSchedulePosition(t,s)}}setScheduleToAssetAtTime(e,t){const i=this.schedule;if(!i)return;const s=t.parentIdentifier,r=i.getEvent(s);if(r){const n=i.findEventIndex(s),o=i.findAssetIndex(r,e);this.advanceAfterAssetEnded(r,n,o-1)}}setSchedulePosition(e,t){var i;const s=(i=this.schedule)==null?void 0:i.items;if(!s||this.playbackDisabled)return;const r=e>=0?s[e]:null;this.log(`setSchedulePosition ${e}, ${t} (${r&&Pt(r)}) pos: ${this.timelinePos}`);const n=this.waitingItem||this.playingItem,o=this.playingLastItem;if(this.isInterstitial(n)){const h=n.event,f=this.playingAsset,g=f?.identifier,I=g?this.getAssetPlayer(g):null;if(I&&g&&(!this.eventItemsMatch(n,r)||t!==void 0&&g!==h.assetList[t].identifier)){var c;const m=h.findAssetIndex(f);if(this.log(`INTERSTITIAL_ASSET_ENDED ${m+1}/${h.assetList.length} ${$i(f)}`),this.endedAsset=f,this.playingAsset=null,this.hls.trigger(y.INTERSTITIAL_ASSET_ENDED,{asset:f,assetListIndex:m,event:h,schedule:s.slice(0),scheduleIndex:e,player:I}),n!==this.playingItem){this.itemsMatch(n,this.playingItem)&&!this.playingAsset&&this.advanceAfterAssetEnded(h,this.findItemIndex(this.playingItem),m);return}this.retreiveMediaSource(g,r),I.media&&!((c=this.detachedData)!=null&&c.mediaSource)&&I.detachMedia()}if(!this.eventItemsMatch(n,r)&&(this.endedItem=n,this.playingItem=null,this.log(`INTERSTITIAL_ENDED ${h} ${Pt(n)}`),h.hasPlayed=!0,this.hls.trigger(y.INTERSTITIAL_ENDED,{event:h,schedule:s.slice(0),scheduleIndex:e}),h.cue.once)){var u;this.updateSchedule();const m=(u=this.schedule)==null?void 0:u.items;if(r&&m){const E=this.findItemIndex(r);this.advanceSchedule(E,m,t,n,o)}return}}this.advanceSchedule(e,s,t,n,o)}advanceSchedule(e,t,i,s,r){const n=this.schedule;if(!n)return;const o=t[e]||null,c=this.primaryMedia,u=this.playerQueue;if(u.length&&u.forEach(h=>{const f=h.interstitial,g=n.findEventIndex(f.identifier);(g<e||g>e+1)&&this.clearInterstitial(f,o)}),this.isInterstitial(o)){this.timelinePos=Math.min(Math.max(this.timelinePos,o.start),o.end);const h=o.event;if(i===void 0){i=n.findAssetIndex(h,this.timelinePos);const m=dn(h,i-1);if(h.isAssetPastPlayoutLimit(m)||h.appendInPlace&&this.timelinePos===o.end){this.advanceAfterAssetEnded(h,e,i);return}i=m}const f=this.waitingItem;this.assetsBuffered(o,c)||this.setBufferingItem(o);let g=this.preloadAssets(h,i);if(this.eventItemsMatch(o,f||s)||(this.waitingItem=o,this.log(`INTERSTITIAL_STARTED ${Pt(o)} ${h.appendInPlace?"append in place":""}`),this.hls.trigger(y.INTERSTITIAL_STARTED,{event:h,schedule:t.slice(0),scheduleIndex:e})),!h.assetListLoaded){this.log(`Waiting for ASSET-LIST to complete loading ${h}`);return}if(h.assetListLoader&&(h.assetListLoader.destroy(),h.assetListLoader=void 0),!c){this.log(`Waiting for attachMedia to start Interstitial ${h}`);return}this.waitingItem=this.endedItem=null,this.playingItem=o;const I=h.assetList[i];if(!I){this.advanceAfterAssetEnded(h,e,i||0);return}if(g||(g=this.getAssetPlayer(I.identifier)),g===null||g.destroyed){const m=h.assetList.length;this.warn(`asset ${i+1}/${m} player destroyed ${h}`),g=this.createAssetPlayer(h,I,i),g.loadSource()}if(!this.eventItemsMatch(o,this.bufferingItem)&&h.appendInPlace&&this.isAssetBuffered(I))return;this.startAssetPlayer(g,i,t,e,c),this.shouldPlay&&hl(g.media)}else o?(this.resumePrimary(o,e,s),this.shouldPlay&&hl(this.hls.media)):r&&this.isInterstitial(s)&&(this.endedItem=null,this.playingItem=s,s.event.appendInPlace||this.attachPrimary(n.durations.primary,null))}get playbackDisabled(){return this.hls.config.enableInterstitialPlayback===!1}get primaryDetails(){var e;return(e=this.mediaSelection)==null?void 0:e.main.details}get primaryLive(){var e;return!!((e=this.primaryDetails)!=null&&e.live)}resumePrimary(e,t,i){var s,r;if(this.playingItem=e,this.playingAsset=this.endedAsset=null,this.waitingItem=this.endedItem=null,this.bufferedToItem(e),this.log(`resuming ${Pt(e)}`),!((s=this.detachedData)!=null&&s.mediaSource)){let o=this.timelinePos;(o<e.start||o>=e.end)&&(o=this.getPrimaryResumption(e,t),this.log(js("resumePrimary",o)),this.timelinePos=o),this.attachPrimary(o,e)}if(!i)return;const n=(r=this.schedule)==null?void 0:r.items;n&&(this.log(`INTERSTITIALS_PRIMARY_RESUMED ${Pt(e)}`),this.hls.trigger(y.INTERSTITIALS_PRIMARY_RESUMED,{schedule:n.slice(0),scheduleIndex:t}),this.checkBuffer())}getPrimaryResumption(e,t){const i=e.start;if(this.primaryLive){const s=this.primaryDetails;if(t===0)return this.hls.startPosition;if(s&&(i<s.fragmentStart||i>s.edge))return this.hls.liveSyncPosition||-1}return i}isAssetBuffered(e){const t=this.getAssetPlayer(e.identifier);return t!=null&&t.hls?t.hls.bufferedToEnd:ye.bufferInfo(this.primaryMedia,this.timelinePos,0).end+1>=e.timelineStart+(e.duration||0)}attachPrimary(e,t,i){t?this.setBufferingItem(t):this.bufferingItem=this.playingItem,this.bufferingAsset=null;const s=this.primaryMedia;if(!s)return;const r=this.hls;r.media?this.checkBuffer():(this.transferMediaTo(r,s),i&&this.startLoadingPrimaryAt(e,i)),i||(this.log(js("attachPrimary",e)),this.timelinePos=e,this.startLoadingPrimaryAt(e,i))}startLoadingPrimaryAt(e,t){var i;const s=this.hls;!s.loadingEnabled||!s.media||Math.abs((((i=s.mainForwardBufferInfo)==null?void 0:i.start)||s.media.currentTime)-e)>.5?s.startLoad(e,t):s.bufferingEnabled||s.resumeBuffering()}onManifestLoading(){var e;this.stopLoad(),(e=this.schedule)==null||e.reset(),this.emptyPlayerQueue(),this.clearScheduleState(),this.shouldPlay=!1,this.bufferedPos=this.timelinePos=-1,this.mediaSelection=this.altSelection=this.manager=this.requiredTracks=null,this.hls.off(y.BUFFER_CODECS,this.onBufferCodecs,this),this.hls.on(y.BUFFER_CODECS,this.onBufferCodecs,this)}onLevelUpdated(e,t){if(t.level===-1||!this.schedule)return;const i=this.hls.levels[t.level],s=Be(Be({},this.mediaSelection||this.altSelection),{},{main:i});this.mediaSelection=s,this.schedule.parseInterstitialDateRanges(s,this.hls.config.interstitialAppendInPlace),!this.effectivePlayingItem&&this.schedule.items&&this.checkStart()}onAudioTrackUpdated(e,t){const i=this.hls.audioTracks[t.id],s=this.mediaSelection;if(!s){this.altSelection=Be(Be({},this.altSelection),{},{audio:i});return}const r=Be(Be({},s),{},{audio:i});this.mediaSelection=r}onSubtitleTrackUpdated(e,t){const i=this.hls.subtitleTracks[t.id],s=this.mediaSelection;if(!s){this.altSelection=Be(Be({},this.altSelection),{},{subtitles:i});return}const r=Be(Be({},s),{},{subtitles:i});this.mediaSelection=r}onAudioTrackSwitching(e,t){const i=Ta(t);this.playerQueue.forEach(({hls:s})=>s&&(s.setAudioOption(t)||s.setAudioOption(i)))}onSubtitleTrackSwitch(e,t){const i=Ta(t);this.playerQueue.forEach(({hls:s})=>s&&(s.setSubtitleOption(t)||t.id!==-1&&s.setSubtitleOption(i)))}onBufferCodecs(e,t){const i=t.tracks;i&&(this.requiredTracks=i)}onBufferAppended(e,t){this.checkBuffer()}onBufferFlushed(e,t){const i=this.playingItem;if(i&&!this.itemsMatch(i,this.bufferingItem)&&!this.isInterstitial(i)){const s=this.timelinePos;this.bufferedPos=s,this.checkBuffer()}}onBufferedToEnd(e){if(!this.schedule)return;const t=this.schedule.events;if(this.bufferedPos<Number.MAX_VALUE&&t){for(let s=0;s<t.length;s++){const r=t[s];if(r.cue.post){var i;const n=this.schedule.findEventIndex(r.identifier),o=(i=this.schedule.items)==null?void 0:i[n];this.isInterstitial(o)&&this.eventItemsMatch(o,this.bufferingItem)&&this.bufferedToItem(o,0);break}}this.bufferedPos=Number.MAX_VALUE}}onMediaEnded(e){const t=this.playingItem;if(!this.playingLastItem&&t){const i=this.findItemIndex(t);this.setSchedulePosition(i+1)}else this.shouldPlay=!1}updateItem(e,t){var i;const s=(i=this.schedule)==null?void 0:i.items;if(e&&s){const r=this.findItemIndex(e,t);return s[r]||null}return null}trimInPlace(e,t){if(this.isInterstitial(e)&&e.event.appendInPlace&&t.end-e.end>.25){e.event.assetList.forEach((r,n)=>{e.event.isAssetPastPlayoutLimit(n)&&this.clearAssetPlayer(r.identifier,null)});const i=e.end+.25,s=ye.bufferInfo(this.primaryMedia,i,0);(s.end>i||(s.nextStart||0)>i)&&(this.log(`trim buffered interstitial ${Pt(e)} (was ${Pt(t)})`),this.attachPrimary(i,null,!0),this.flushFrontBuffer(i))}}itemsMatch(e,t){return!!t&&(e===t||e.event&&t.event&&this.eventItemsMatch(e,t)||!e.event&&!t.event&&this.findItemIndex(e)===this.findItemIndex(t))}eventItemsMatch(e,t){var i;return!!t&&(e===t||e.event.identifier===((i=t.event)==null?void 0:i.identifier))}findItemIndex(e,t){return e&&this.schedule?this.schedule.findItemIndex(e,t):-1}updateSchedule(e=!1){var t;const i=this.mediaSelection;i&&((t=this.schedule)==null||t.updateSchedule(i,[],e))}checkBuffer(e){var t;const i=(t=this.schedule)==null?void 0:t.items;if(!i)return;const s=ye.bufferInfo(this.primaryMedia,this.timelinePos,0);e&&(this.bufferedPos=this.timelinePos),e||(e=s.len<1),this.updateBufferedPos(s.end,i,e)}updateBufferedPos(e,t,i){const s=this.schedule,r=this.bufferingItem;if(this.bufferedPos>e||!s)return;if(t.length===1&&this.itemsMatch(t[0],r)){this.bufferedPos=e;return}const n=this.playingItem,o=this.findItemIndex(n);let c=s.findItemIndexAtTime(e);if(this.bufferedPos<e){var u;const h=this.findItemIndex(r),f=Math.min(h+1,t.length-1),g=t[f];if((c===-1&&r&&e>=r.end||(u=g.event)!=null&&u.appendInPlace&&e+.01>=g.start)&&(c=f),this.isInterstitial(r)){const I=r.event;if(f-o>1&&I.appendInPlace===!1||I.assetList.length===0&&I.assetListLoader)return}if(this.bufferedPos=e,c>h&&c>o)this.bufferedToItem(g);else{const I=this.primaryDetails;this.primaryLive&&I&&e>I.edge-I.targetduration&&g.start<I.edge+this.hls.config.interstitialLiveLookAhead&&this.isInterstitial(g)&&this.preloadAssets(g.event,0)}}else i&&n&&!this.itemsMatch(n,r)&&(c===o?this.bufferedToItem(n):c===o+1&&this.bufferedToItem(t[c]))}assetsBuffered(e,t){return e.event.assetList.length===0?!1:!e.event.assetList.some(s=>{const r=this.getAssetPlayer(s.identifier);return!(r!=null&&r.bufferedInPlaceToEnd(t))})}setBufferingItem(e){const t=this.bufferingItem,i=this.schedule;if(!this.itemsMatch(e,t)&&i){const{items:s,events:r}=i;if(!s||!r)return t;const n=this.isInterstitial(e),o=this.getBufferingPlayer();this.bufferingItem=e,this.bufferedPos=Math.max(e.start,Math.min(e.end,this.timelinePos));const c=o?o.remaining:t?t.end-this.timelinePos:0;if(this.log(`INTERSTITIALS_BUFFERED_TO_BOUNDARY ${Pt(e)}`+(t?` (${c.toFixed(2)} remaining)`:"")),!this.playbackDisabled)if(n){const u=i.findAssetIndex(e.event,this.bufferedPos);e.event.assetList.forEach((h,f)=>{const g=this.getAssetPlayer(h.identifier);g&&(f===u&&g.loadSource(),g.resumeBuffering())})}else this.hls.resumeBuffering(),this.playerQueue.forEach(u=>u.pauseBuffering());this.hls.trigger(y.INTERSTITIALS_BUFFERED_TO_BOUNDARY,{events:r.slice(0),schedule:s.slice(0),bufferingIndex:this.findItemIndex(e),playingIndex:this.findItemIndex(this.playingItem)})}else this.bufferingItem!==e&&(this.bufferingItem=e);return t}bufferedToItem(e,t=0){const i=this.setBufferingItem(e);if(!this.playbackDisabled){if(this.isInterstitial(e))this.bufferedToEvent(e,t);else if(i!==null){this.bufferingAsset=null;const s=this.detachedData;s?s.mediaSource?this.attachPrimary(e.start,e,!0):this.preloadPrimary(e):this.preloadPrimary(e)}}}preloadPrimary(e){const t=this.findItemIndex(e),i=this.getPrimaryResumption(e,t);this.startLoadingPrimaryAt(i)}bufferedToEvent(e,t){const i=e.event,s=i.assetList.length===0&&!i.assetListLoader,r=i.cue.once;if(s||!r){const n=this.preloadAssets(i,t);if(n!=null&&n.interstitial.appendInPlace){const o=this.primaryMedia;o&&this.bufferAssetPlayer(n,o)}}}preloadAssets(e,t){const i=e.assetUrl,s=e.assetList.length,r=s===0&&!e.assetListLoader,n=e.cue.once;if(r){const c=e.timelineStart;if(e.appendInPlace){var o;const g=this.playingItem;!this.isInterstitial(g)&&(g==null||(o=g.nextEvent)==null?void 0:o.identifier)===e.identifier&&this.flushFrontBuffer(c+.25)}let u,h=0;if(!this.playingItem&&this.primaryLive&&(h=this.hls.startPosition,h===-1&&(h=this.hls.liveSyncPosition||0)),h&&!(e.cue.pre||e.cue.post)){const g=h-c;g>0&&(u=Math.round(g*1e3)/1e3)}if(this.log(`Load interstitial asset ${t+1}/${i?1:s} ${e}${u?` live-start: ${h} start-offset: ${u}`:""}`),i)return this.createAsset(e,0,0,c,e.duration,i);const f=this.assetListLoader.loadAssetList(e,u);f&&(e.assetListLoader=f)}else if(!n&&s){for(let u=t;u<s;u++){const h=e.assetList[u],f=this.getAssetPlayerQueueIndex(h.identifier);(f===-1||this.playerQueue[f].destroyed)&&!h.error&&this.createAssetPlayer(e,h,u)}const c=e.assetList[t];if(c){const u=this.getAssetPlayer(c.identifier);return u&&u.loadSource(),u}}return null}flushFrontBuffer(e){const t=this.requiredTracks;if(!t)return;this.log(`Removing front buffer starting at ${e}`),Object.keys(t).forEach(s=>{this.hls.trigger(y.BUFFER_FLUSHING,{startOffset:e,endOffset:1/0,type:s})})}getAssetPlayerQueueIndex(e){const t=this.playerQueue;for(let i=0;i<t.length;i++)if(e===t[i].assetId)return i;return-1}getAssetPlayer(e){const t=this.getAssetPlayerQueueIndex(e);return this.playerQueue[t]||null}getBufferingPlayer(){const{playerQueue:e,primaryMedia:t}=this;if(t){for(let i=0;i<e.length;i++)if(e[i].media===t)return e[i]}return null}createAsset(e,t,i,s,r,n){const o={parentIdentifier:e.identifier,identifier:of(e,n,t),duration:r,startOffset:i,timelineStart:s,uri:n};return this.createAssetPlayer(e,o,t)}createAssetPlayer(e,t,i){const s=this.hls,r=s.userConfig;let n=r.videoPreference;const o=s.loadLevelObj||s.levels[s.currentLevel];(n||o)&&(n=Ne({},n),o.videoCodec&&(n.videoCodec=o.videoCodec),o.videoRange&&(n.allowedVideoRanges=[o.videoRange]));const c=s.audioTracks[s.audioTrack],u=s.subtitleTracks[s.subtitleTrack];let h=0;if(this.primaryLive||e.appendInPlace){const w=this.timelinePos-t.timelineStart;if(w>1){const N=t.duration;N&&w<N&&(h=w)}}const f=t.identifier,g=Be(Be({},r),{},{maxMaxBufferLength:Math.min(180,s.config.maxMaxBufferLength),autoStartLoad:!0,startFragPrefetch:!0,primarySessionId:s.sessionId,assetPlayerId:f,abrEwmaDefaultEstimate:s.bandwidthEstimate,interstitialsController:void 0,startPosition:h,liveDurationInfinity:!1,testBandwidth:!1,videoPreference:n,audioPreference:c||r.audioPreference,subtitlePreference:u||r.subtitlePreference});e.appendInPlace&&(e.appendInPlaceStarted=!0,t.timelineStart&&(g.timelineOffset=t.timelineStart));const I=g.cmcd;I!=null&&I.sessionId&&I.contentId&&(g.cmcd=Ne({},I,{contentId:as(t.uri)})),this.getAssetPlayer(f)&&this.warn(`Duplicate date range identifier ${e} and asset ${f}`);const m=new cf(this.HlsPlayerClass,g,e,t);this.playerQueue.push(m),e.assetList[i]=t;let E=!0;const v=w=>{if(w.live){var N;const $=new Error(`Interstitials MUST be VOD assets ${e}`),F={fatal:!0,type:de.OTHER_ERROR,details:U.INTERSTITIAL_ASSET_ITEM_ERROR,error:$},O=((N=this.schedule)==null?void 0:N.findEventIndex(e.identifier))||-1;this.handleAssetItemError(F,e,O,i,$.message);return}const K=w.edge-w.fragmentStart,p=t.duration;(E||p===null||K>p)&&(E=!1,this.log(`Interstitial asset "${f}" duration change ${p} > ${K}`),t.duration=K,this.updateSchedule())};m.on(y.LEVEL_UPDATED,(w,{details:N})=>v(N)),m.on(y.LEVEL_PTS_UPDATED,(w,{details:N})=>v(N)),m.on(y.EVENT_CUE_ENTER,()=>this.onInterstitialCueEnter());const x=(w,N)=>{const K=this.getAssetPlayer(f);if(K&&N.tracks){K.off(y.BUFFER_CODECS,x),K.tracks=N.tracks;const p=this.primaryMedia;this.bufferingAsset===K.assetItem&&p&&!K.media&&this.bufferAssetPlayer(K,p)}};m.on(y.BUFFER_CODECS,x);const D=()=>{var w;const N=this.getAssetPlayer(f);if(this.log(`buffered to end of asset ${N}`),!N||!this.schedule)return;const K=this.schedule.findEventIndex(e.identifier),p=(w=this.schedule.items)==null?void 0:w[K];this.isInterstitial(p)&&this.advanceAssetBuffering(p,t)};m.on(y.BUFFERED_TO_END,D);const L=w=>()=>{if(!this.getAssetPlayer(f)||!this.schedule)return;this.shouldPlay=!0;const K=this.schedule.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,K,w)};return m.once(y.MEDIA_ENDED,L(i)),m.once(y.PLAYOUT_LIMIT_REACHED,L(1/0)),m.on(y.ERROR,(w,N)=>{if(!this.schedule)return;const K=this.getAssetPlayer(f);if(N.details===U.BUFFER_STALLED_ERROR){if(K!=null&&K.appendInPlace){this.handleInPlaceStall(e);return}this.onTimeupdate(),this.checkBuffer(!0);return}this.handleAssetItemError(N,e,this.schedule.findEventIndex(e.identifier),i,`Asset player error ${N.error} ${e}`)}),m.on(y.DESTROYING,()=>{if(!this.getAssetPlayer(f)||!this.schedule)return;const N=new Error(`Asset player destroyed unexpectedly ${f}`),K={fatal:!0,type:de.OTHER_ERROR,details:U.INTERSTITIAL_ASSET_ITEM_ERROR,error:N};this.handleAssetItemError(K,e,this.schedule.findEventIndex(e.identifier),i,N.message)}),this.log(`INTERSTITIAL_ASSET_PLAYER_CREATED ${$i(t)}`),this.hls.trigger(y.INTERSTITIAL_ASSET_PLAYER_CREATED,{asset:t,assetListIndex:i,event:e,player:m}),m}clearInterstitial(e,t){e.assetList.forEach(i=>{this.clearAssetPlayer(i.identifier,t)}),e.reset()}resetAssetPlayer(e){const t=this.getAssetPlayerQueueIndex(e);if(t!==-1){this.log(`reset asset player "${e}" after error`);const i=this.playerQueue[t];this.transferMediaFromPlayer(i,null),i.resetDetails()}}clearAssetPlayer(e,t){const i=this.getAssetPlayerQueueIndex(e);if(i!==-1){const s=this.playerQueue[i];this.log(`clear ${s} toSegment: ${t&&Pt(t)}`),this.transferMediaFromPlayer(s,t),this.playerQueue.splice(i,1),s.destroy()}}emptyPlayerQueue(){let e;for(;e=this.playerQueue.pop();)e.destroy();this.playerQueue=[]}startAssetPlayer(e,t,i,s,r){const{interstitial:n,assetItem:o,assetId:c}=e,u=n.assetList.length,h=this.playingAsset;this.endedAsset=null,this.playingAsset=o,(!h||h.identifier!==c)&&(h&&(this.clearAssetPlayer(h.identifier,i[s]),delete h.error),this.log(`INTERSTITIAL_ASSET_STARTED ${t+1}/${u} ${$i(o)}`),this.hls.trigger(y.INTERSTITIAL_ASSET_STARTED,{asset:o,assetListIndex:t,event:n,schedule:i.slice(0),scheduleIndex:s,player:e})),this.bufferAssetPlayer(e,r)}bufferAssetPlayer(e,t){var i,s;if(!this.schedule)return;const{interstitial:r,assetItem:n}=e,o=this.schedule.findEventIndex(r.identifier),c=(i=this.schedule.items)==null?void 0:i[o];if(!c)return;e.loadSource(),this.setBufferingItem(c),this.bufferingAsset=n;const u=this.getBufferingPlayer();if(u===e)return;const h=r.appendInPlace;if(h&&u?.interstitial.appendInPlace===!1)return;const f=u?.tracks||((s=this.detachedData)==null?void 0:s.tracks)||this.requiredTracks;if(h&&n!==this.playingAsset){if(!e.tracks){this.log(`Waiting for track info before buffering ${e}`);return}if(f&&!Zn(f,e.tracks)){const g=new Error(`Asset ${$i(n)} SourceBuffer tracks ('${Object.keys(e.tracks)}') are not compatible with primary content tracks ('${Object.keys(f)}')`),I={fatal:!0,type:de.OTHER_ERROR,details:U.INTERSTITIAL_ASSET_ITEM_ERROR,error:g},m=r.findAssetIndex(n);this.handleAssetItemError(I,r,o,m,g.message);return}}this.transferMediaTo(e,t)}handleInPlaceStall(e){const t=this.schedule,i=this.primaryMedia;if(!t||!i)return;const s=i.currentTime,r=t.findAssetIndex(e,s),n=e.assetList[r];if(n){const o=this.getAssetPlayer(n.identifier);if(o){const c=o.currentTime||s-n.timelineStart,u=o.duration-c;if(this.warn(`Stalled at ${c} of ${c+u} in ${o} ${e} (media.currentTime: ${s})`),c&&(u/i.playbackRate<.5||o.bufferedInPlaceToEnd(i))&&o.hls){const h=t.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,h,r)}}}}advanceInPlace(e){const t=this.primaryMedia;t&&t.currentTime<e&&(t.currentTime=e)}handleAssetItemError(e,t,i,s,r){if(e.details===U.BUFFER_STALLED_ERROR)return;const n=t.assetList[s]||null;if(this.warn(`INTERSTITIAL_ASSET_ERROR ${n&&$i(n)} ${e.error}`),!this.schedule)return;const o=n?.identifier||"",c=this.getAssetPlayerQueueIndex(o),u=this.playerQueue[c]||null,h=this.schedule.items,f=Ne({},e,{fatal:!1,errorAction:_i(!0),asset:n,assetListIndex:s,event:t,schedule:h,scheduleIndex:i,player:u});if(this.hls.trigger(y.INTERSTITIAL_ASSET_ERROR,f),!e.fatal)return;const g=this.playingAsset,I=this.bufferingAsset,m=new Error(r);if(n&&(this.clearAssetPlayer(o,null),n.error=m),!t.assetList.some(E=>!E.error))t.error=m;else for(let E=s;E<t.assetList.length;E++)this.resetAssetPlayer(t.assetList[E].identifier);this.updateSchedule(!0),t.error?this.primaryFallback(t):g&&g.identifier===o?this.advanceAfterAssetEnded(t,i,s):I&&I.identifier===o&&this.isInterstitial(this.bufferingItem)&&this.advanceAssetBuffering(this.bufferingItem,I)}primaryFallback(e){const t=e.timelineStart,i=this.effectivePlayingItem;if(i){this.log(`Fallback to primary from event "${e.identifier}" start: ${t} pos: ${this.timelinePos} playing: ${Pt(i)} error: ${e.error}`);let s=this.timelinePos;s===-1&&(s=this.hls.startPosition);const r=this.updateItem(i,s);if(this.itemsMatch(i,r)&&this.clearInterstitial(e,null),e.appendInPlace&&(this.attachPrimary(t,null),this.flushFrontBuffer(t)),!this.schedule)return;const n=this.schedule.findItemIndexAtTime(s);this.setSchedulePosition(n)}else this.checkStart()}onAssetListLoaded(e,t){var i,s;const r=t.event,n=r.identifier,o=t.assetListResponse.ASSETS;if(!((i=this.schedule)!=null&&i.hasEvent(n)))return;const c=r.timelineStart,u=r.duration;let h=0;o.forEach((E,v)=>{const x=parseFloat(E.DURATION);this.createAsset(r,v,h,c+h,x,E.URI),h+=x}),r.duration=h,this.log(`Loaded asset-list with duration: ${h} (was: ${u}) ${r}`);const f=this.waitingItem,g=f?.event.identifier===n;this.updateSchedule();const I=(s=this.bufferingItem)==null?void 0:s.event;if(g){var m;const E=this.schedule.findEventIndex(n),v=(m=this.schedule.items)==null?void 0:m[E];if(v){if(!this.playingItem&&this.timelinePos>v.end&&this.schedule.findItemIndexAtTime(this.timelinePos)!==E){r.error=new Error(`Interstitial no longer within playback range ${this.timelinePos} ${r}`),this.updateSchedule(!0),this.primaryFallback(r);return}this.setBufferingItem(v)}this.setSchedulePosition(E)}else if(I?.identifier===n){const E=r.assetList[0];if(E){const v=this.getAssetPlayer(E.identifier);if(I.appendInPlace){const x=this.primaryMedia;v&&x&&this.bufferAssetPlayer(v,x)}else v&&v.loadSource()}}}onError(e,t){if(this.schedule)switch(t.details){case U.ASSET_LIST_PARSING_ERROR:case U.ASSET_LIST_LOAD_ERROR:case U.ASSET_LIST_LOAD_TIMEOUT:{const i=t.interstitial;i&&(this.updateSchedule(!0),this.primaryFallback(i));break}case U.BUFFER_STALLED_ERROR:{const i=this.endedItem||this.waitingItem||this.playingItem;if(this.isInterstitial(i)&&i.event.appendInPlace){this.handleInPlaceStall(i.event);return}this.log(`Primary player stall @${this.timelinePos} bufferedPos: ${this.bufferedPos}`),this.onTimeupdate(),this.checkBuffer(!0);break}}}}const dl=500;class gf extends Ur{constructor(e,t,i){super(e,t,i,"subtitle-stream-controller",he.SUBTITLE),this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this.registerListeners()}onHandlerDestroying(){this.unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null}registerListeners(){super.registerListeners();const{hls:e}=this;e.on(y.LEVEL_LOADED,this.onLevelLoaded,this),e.on(y.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(y.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(y.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(y.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(y.BUFFER_FLUSHING,this.onBufferFlushing,this)}unregisterListeners(){super.unregisterListeners();const{hls:e}=this;e.off(y.LEVEL_LOADED,this.onLevelLoaded,this),e.off(y.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(y.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(y.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(y.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(y.BUFFER_FLUSHING,this.onBufferFlushing,this)}startLoad(e,t){this.stopLoad(),this.state=j.IDLE,this.setInterval(dl),this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}onManifestLoading(){super.onManifestLoading(),this.mainDetails=null}onMediaDetaching(e,t){this.tracksBuffered=[],super.onMediaDetaching(e,t)}onLevelLoaded(e,t){this.mainDetails=t.details}onSubtitleFragProcessed(e,t){const{frag:i,success:s}=t;if(this.fragContextChanged(i)||(qe(i)&&(this.fragPrevious=i),this.state=j.IDLE),!s)return;const r=this.tracksBuffered[this.currentTrackId];if(!r)return;let n;const o=i.start;for(let u=0;u<r.length;u++)if(o>=r[u].start&&o<=r[u].end){n=r[u];break}const c=i.start+i.duration;n?n.end=c:(n={start:o,end:c},r.push(n)),this.fragmentTracker.fragBuffered(i),this.fragBufferedComplete(i,null),this.media&&this.tick()}onBufferFlushing(e,t){const{startOffset:i,endOffset:s}=t;if(i===0&&s!==Number.POSITIVE_INFINITY){const r=s-1;if(r<=0)return;t.endOffsetSubtitles=Math.max(0,r),this.tracksBuffered.forEach(n=>{for(let o=0;o<n.length;){if(n[o].end<=r){n.shift();continue}else if(n[o].start<r)n[o].start=r;else break;o++}}),this.fragmentTracker.removeFragmentsInRange(i,r,he.SUBTITLE)}}onError(e,t){const i=t.frag;i?.type===he.SUBTITLE&&(t.details===U.FRAG_GAP&&this.fragmentTracker.fragBuffered(i,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==j.STOPPED&&(this.state=j.IDLE))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){if(this.levels&&Go(this.levels,t)){this.levels=t.map(i=>new Zi(i));return}this.tracksBuffered=[],this.levels=t.map(i=>{const s=new Zi(i);return this.tracksBuffered[s.id]=[],s}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,he.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null}onSubtitleTrackSwitch(e,t){var i;if(this.currentTrackId=t.id,!((i=this.levels)!=null&&i.length)||this.currentTrackId===-1){this.clearInterval();return}const s=this.levels[this.currentTrackId];s!=null&&s.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,s&&this.state!==j.STOPPED&&this.setInterval(dl)}onSubtitleTrackLoaded(e,t){var i;const{currentTrackId:s,levels:r}=this,{details:n,id:o}=t;if(!r){this.warn(`Subtitle tracks were reset while loading level ${o}`);return}const c=r[o];if(o>=r.length||!c)return;this.log(`Subtitle track ${o} loaded [${n.startSN},${n.endSN}]${n.lastPartSn?`[part-${n.lastPartSn}-${n.lastPartIndex}]`:""},duration:${n.totalduration}`),this.mediaBuffer=this.mediaBufferTimeRanges;let u=0;if(n.live||(i=c.details)!=null&&i.live){if(n.deltaUpdateFailed)return;const f=this.mainDetails;if(!f){this.startFragRequested=!1;return}const g=f.fragments[0];if(!c.details)n.hasProgramDateTime&&f.hasProgramDateTime?(Ms(n,f),u=n.fragmentStart):g&&(u=g.start,Br(n,u));else{var h;u=this.alignPlaylists(n,c.details,(h=this.levelLastLoaded)==null?void 0:h.details),u===0&&g&&(u=g.start,Br(n,u))}f&&!this.startFragRequested&&this.setStartPosition(f,u)}c.details=n,this.levelLastLoaded=c,o===s&&(this.hls.trigger(y.SUBTITLE_TRACK_UPDATED,{details:n,id:o,groupId:t.groupId}),this.tick(),n.live&&!this.fragCurrent&&this.media&&this.state===j.IDLE&&(yi(null,n.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),c.details=void 0)))}_handleFragmentLoadComplete(e){const{frag:t,payload:i}=e,s=t.decryptdata,r=this.hls;if(!this.fragContextChanged(t)&&i&&i.byteLength>0&&s!=null&&s.key&&s.iv&&ki(s.method)){const n=performance.now();this.decrypter.decrypt(new Uint8Array(i),s.key.buffer,s.iv.buffer,_r(s.method)).catch(o=>{throw r.trigger(y.ERROR,{type:de.MEDIA_ERROR,details:U.FRAG_DECRYPT_ERROR,fatal:!1,error:o,reason:o.message,frag:t}),o}).then(o=>{const c=performance.now();r.trigger(y.FRAG_DECRYPTED,{frag:t,payload:o,stats:{tstart:n,tdecrypt:c}})}).catch(o=>{this.warn(`${o.name}: ${o.message}`),this.state=j.IDLE})}}doTick(){if(!this.media){this.state=j.IDLE;return}if(this.state===j.IDLE){const{currentTrackId:e,levels:t}=this,i=t?.[e];if(!i||!t.length||!i.details||this.waitForLive(i))return;const{config:s}=this,r=this.getLoadPosition(),n=ye.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],r,s.maxBufferHole),{end:o,len:c}=n,u=i.details,h=this.hls.maxBufferLength+u.levelTargetDuration;if(c>h)return;const f=u.fragments,g=f.length,I=u.edge;let m=null;const E=this.fragPrevious;if(o<I){const D=s.maxFragLookUpTolerance,L=o>I-D?0:D;m=yi(E,f,Math.max(f[0].start,o),L),!m&&E&&E.start<f[0].start&&(m=f[0])}else m=f[g-1];if(m=this.filterReplacedPrimary(m,i.details),!m)return;const v=m.sn-u.startSN,x=f[v-1];if(x&&x.cc===m.cc&&this.fragmentTracker.getState(x)===Qe.NOT_LOADED&&(m=x),this.fragmentTracker.getState(m)===Qe.NOT_LOADED){const D=this.mapToInitFragWhenRequired(m);D&&this.loadFragment(D,i,o)}}}loadFragment(e,t,i){qe(e)?super.loadFragment(e,t,i):this._loadInitSegment(e,t)}get mediaBufferTimeRanges(){return new pf(this.tracksBuffered[this.currentTrackId]||[])}}class pf{constructor(e){this.buffered=void 0;const t=(i,s,r)=>{if(s=s>>>0,s>r-1)throw new DOMException(`Failed to execute '${i}' on 'TimeRanges': The index provided (${s}) is greater than the maximum bound (${r})`);return e[s][i]};this.buffered={get length(){return e.length},end(i){return t("end",i,e.length)},start(i){return t("start",i,e.length)}}}}const Af={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},fl=a=>String.fromCharCode(Af[a]||a),_t=15,Zt=100,mf={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},If={17:2,18:4,21:6,22:8,23:10,19:13,20:15},Cf={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},yf={25:2,26:4,29:6,30:8,31:10,27:13,28:15},Ef=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class vf{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){const i=typeof t=="function"?t():t;Oe.log(`${this.time} [${e}] ${i}`)}}}const vi=function(e){const t=[];for(let i=0;i<e.length;i++)t.push(e[i].toString(16));return t};class gl{constructor(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!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 i=0;i<t.length;i++){const s=t[i];e.hasOwnProperty(s)&&(this[s]=e[s])}}isDefault(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!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 Tf{constructor(){this.uchar=" ",this.penState=new gl}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 Sf{constructor(e){this.chars=[],this.pos=0,this.currPenState=new gl,this.cueStartTime=null,this.logger=void 0;for(let t=0;t<Zt;t++)this.chars.push(new Tf);this.logger=e}equals(e){for(let t=0;t<Zt;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}copy(e){for(let t=0;t<Zt;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<Zt;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>Zt&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=Zt)}moveCursor(e){const t=this.pos+e;if(e>1)for(let i=this.pos+1;i<t+1;i++)this.chars[i].setPenState(this.currPenState);this.setCursor(t)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(e){e>=144&&this.backSpace();const t=fl(e);if(this.pos>=Zt){this.logger.log(0,()=>"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1)}clearFromPos(e){let t;for(t=e;t<Zt;t++)this.chars[t].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){const e=[];let t=!0;for(let i=0;i<Zt;i++){const s=this.chars[i].uchar;s!==" "&&(t=!1),e.push(s)}return t?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)}}class fn{constructor(e){this.rows=[],this.currRow=_t-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let t=0;t<_t;t++)this.rows.push(new Sf(e));this.logger=e}reset(){for(let e=0;e<_t;e++)this.rows[e].clear();this.currRow=_t-1}equals(e){let t=!0;for(let i=0;i<_t;i++)if(!this.rows[i].equals(e.rows[i])){t=!1;break}return t}copy(e){for(let t=0;t<_t;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<_t;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e}backSpace(){this.rows[this.currRow].backSpace()}clearToEndOfRow(){this.rows[this.currRow].clearToEndOfRow()}insertChar(e){this.rows[this.currRow].insertChar(e)}setPen(e){this.rows[this.currRow].setPenStyles(e)}moveCursor(e){this.rows[this.currRow].moveCursor(e)}setCursor(e){this.logger.log(2,"setCursor: "+e),this.rows[this.currRow].setCursor(e)}setPAC(e){this.logger.log(2,()=>"pacData = "+Ge(e));let t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(let o=0;o<_t;o++)this.rows[o].clear();const r=this.currRow+1-this.nrRollUpRows,n=this.lastOutputScreen;if(n){const o=n.rows[r].cueStartTime,c=this.logger.time;if(o!==null&&c!==null&&o<c)for(let u=0;u<this.nrRollUpRows;u++)this.rows[t-this.nrRollUpRows+u+1].copy(n.rows[r+u])}}this.currRow=t;const i=this.rows[this.currRow];if(e.indent!==null){const r=e.indent,n=Math.max(r-1,0);i.setCursor(e.indent),e.color=i.chars[n].penState.foreground}const s={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(s)}setBkgData(e){this.logger.log(2,()=>"bkgData = "+Ge(e)),this.backSpace(),this.setPen(e),this.insertChar(32)}setRollUpRows(e){this.nrRollUpRows=e}rollUp(){if(this.nrRollUpRows===null){this.logger.log(3,"roll_up but nrRollUpRows not set yet");return}this.logger.log(1,()=>this.getDisplayText());const e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(2,"Rolling up")}getDisplayText(e){e=e||!1;const t=[];let i="",s=-1;for(let r=0;r<_t;r++){const n=this.rows[r].getTextString();n&&(s=r+1,e?t.push("Row "+s+": '"+n+"'"):t.push(n.trim()))}return t.length>0&&(e?i="["+t.join(" | ")+"]":i=t.join(`
30
- `)),i}getTextAndFormat(){return this.rows}}class pl{constructor(e,t,i){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new fn(i),this.nonDisplayedMemory=new fn(i),this.lastOutputScreen=new fn(i),this.currRollUpRow=this.displayedMemory.rows[_t-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=i}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[_t-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(e){this.outputFilter=e}setPAC(e){this.writeScreen.setPAC(e)}setBkgData(e){this.writeScreen.setBkgData(e)}setMode(e){e!==this.mode&&(this.mode=e,this.logger.log(2,()=>"MODE="+e),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)}insertChars(e){for(let i=0;i<e.length;i++)this.writeScreen.insertChar(e[i]);const t=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>t+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(1,()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())}ccRCL(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}ccBS(){this.logger.log(2,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}ccAOF(){}ccAON(){}ccDER(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}ccRU(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}ccEOC(){if(this.logger.log(2,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){const e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}ccTO(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}ccMIDROW(e){const t={flash:!1};if(t.underline=e%2===1,t.italics=e>=46,t.italics)t.foreground="white";else{const i=Math.floor(e/2)-16,s=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=s[i]}this.logger.log(2,"MIDROW: "+Ge(t)),this.writeScreen.setPen(t)}outputDataUpdate(e=!1){const t=this.logger.time;t!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=t:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t),this.lastOutputScreen.copy(this.displayedMemory))}cueSplitAtTime(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))}}class Al{constructor(e,t,i){this.channels=void 0,this.currentChannel=0,this.cmdHistory=bf(),this.logger=void 0;const s=this.logger=new vf;this.channels=[null,new pl(e,t,s),new pl(e+1,i,s)]}getHandler(e){return this.channels[e].getHandler()}setHandler(e,t){this.channels[e].setHandler(t)}addData(e,t){this.logger.time=e;for(let i=0;i<t.length;i+=2){const s=t[i]&127,r=t[i+1]&127;let n=!1,o=null;if(s===0&&r===0)continue;this.logger.log(3,()=>"["+vi([t[i],t[i+1]])+"] -> ("+vi([s,r])+")");const c=this.cmdHistory;if(s>=16&&s<=31){if(xf(s,r,c)){zs(null,null,c),this.logger.log(3,()=>"Repeated command ("+vi([s,r])+") is dropped");continue}zs(s,r,this.cmdHistory),n=this.parseCmd(s,r),n||(n=this.parseMidrow(s,r)),n||(n=this.parsePAC(s,r)),n||(n=this.parseBackgroundAttributes(s,r))}else zs(null,null,c);if(!n&&(o=this.parseChars(s,r),o)){const h=this.currentChannel;h&&h>0?this.channels[h].insertChars(o):this.logger.log(2,"No channel found yet. TEXT-MODE?")}!n&&!o&&this.logger.log(2,()=>"Couldn't parse cleaned data "+vi([s,r])+" orig: "+vi([t[i],t[i+1]]))}}parseCmd(e,t){const i=(e===20||e===28||e===21||e===29)&&t>=32&&t<=47,s=(e===23||e===31)&&t>=33&&t<=35;if(!(i||s))return!1;const r=e===20||e===21||e===23?1:2,n=this.channels[r];return e===20||e===21||e===28||e===29?t===32?n.ccRCL():t===33?n.ccBS():t===34?n.ccAOF():t===35?n.ccAON():t===36?n.ccDER():t===37?n.ccRU(2):t===38?n.ccRU(3):t===39?n.ccRU(4):t===40?n.ccFON():t===41?n.ccRDC():t===42?n.ccTR():t===43?n.ccRTD():t===44?n.ccEDM():t===45?n.ccCR():t===46?n.ccENM():t===47&&n.ccEOC():n.ccTO(t-32),this.currentChannel=r,!0}parseMidrow(e,t){let i=0;if((e===17||e===25)&&t>=32&&t<=47){if(e===17?i=1:i=2,i!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;const s=this.channels[i];return s?(s.ccMIDROW(t),this.logger.log(3,()=>"MIDROW ("+vi([e,t])+")"),!0):!1}return!1}parsePAC(e,t){let i;const s=(e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127,r=(e===16||e===24)&&t>=64&&t<=95;if(!(s||r))return!1;const n=e<=23?1:2;t>=64&&t<=95?i=n===1?mf[e]:Cf[e]:i=n===1?If[e]:yf[e];const o=this.channels[n];return o?(o.setPAC(this.interpretPAC(i,t)),this.currentChannel=n,!0):!1}interpretPAC(e,t){let i;const s={color:null,italics:!1,indent:null,underline:!1,row:e};return t>95?i=t-96:i=t-64,s.underline=(i&1)===1,i<=13?s.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(i/2)]:i<=15?(s.italics=!0,s.color="white"):s.indent=Math.floor((i-16)/2)*4,s}parseChars(e,t){let i,s=null,r=null;if(e>=25?(i=2,r=e-8):(i=1,r=e),r>=17&&r<=19){let n;r===17?n=t+80:r===18?n=t+112:n=t+144,this.logger.log(2,()=>"Special char '"+fl(n)+"' in channel "+i),s=[n]}else e>=32&&e<=127&&(s=t===0?[e]:[e,t]);return s&&this.logger.log(3,()=>"Char codes = "+vi(s).join(",")),s}parseBackgroundAttributes(e,t){const i=(e===16||e===24)&&t>=32&&t<=47,s=(e===23||e===31)&&t>=45&&t<=47;if(!(i||s))return!1;let r;const n={};e===16||e===24?(r=Math.floor((t-32)/2),n.background=Ef[r],t%2===1&&(n.background=n.background+"_semi")):t===45?n.background="transparent":(n.foreground="black",t===47&&(n.underline=!0));const o=e<=23?1:2;return this.channels[o].setBkgData(n),!0}reset(){for(let e=0;e<Object.keys(this.channels).length;e++){const t=this.channels[e];t&&t.reset()}zs(null,null,this.cmdHistory)}cueSplitAtTime(e){for(let t=0;t<this.channels.length;t++){const i=this.channels[t];i&&i.cueSplitAtTime(e)}}}function zs(a,e,t){t.a=a,t.b=e}function xf(a,e,t){return t.a===a&&t.b===e}function bf(){return{a:null,b:null}}var gn=(function(){if(Ps!=null&&Ps.VTTCue)return self.VTTCue;const a=["","lr","rl"],e=["start","middle","end","left","right"];function t(o,c){if(typeof c!="string"||!Array.isArray(o))return!1;const u=c.toLowerCase();return~o.indexOf(u)?u:!1}function i(o){return t(a,o)}function s(o){return t(e,o)}function r(o,...c){let u=1;for(;u<arguments.length;u++){const h=arguments[u];for(const f in h)o[f]=h[f]}return o}function n(o,c,u){const h=this,f={enumerable:!0};h.hasBeenReset=!1;let g="",I=!1,m=o,E=c,v=u,x=null,D="",L=!0,w="auto",N="start",K=50,p="middle",$=50,F="middle";Object.defineProperty(h,"id",r({},f,{get:function(){return g},set:function(O){g=""+O}})),Object.defineProperty(h,"pauseOnExit",r({},f,{get:function(){return I},set:function(O){I=!!O}})),Object.defineProperty(h,"startTime",r({},f,{get:function(){return m},set:function(O){if(typeof O!="number")throw new TypeError("Start time must be set to a number.");m=O,this.hasBeenReset=!0}})),Object.defineProperty(h,"endTime",r({},f,{get:function(){return E},set:function(O){if(typeof O!="number")throw new TypeError("End time must be set to a number.");E=O,this.hasBeenReset=!0}})),Object.defineProperty(h,"text",r({},f,{get:function(){return v},set:function(O){v=""+O,this.hasBeenReset=!0}})),Object.defineProperty(h,"region",r({},f,{get:function(){return x},set:function(O){x=O,this.hasBeenReset=!0}})),Object.defineProperty(h,"vertical",r({},f,{get:function(){return D},set:function(O){const W=i(O);if(W===!1)throw new SyntaxError("An invalid or illegal string was specified.");D=W,this.hasBeenReset=!0}})),Object.defineProperty(h,"snapToLines",r({},f,{get:function(){return L},set:function(O){L=!!O,this.hasBeenReset=!0}})),Object.defineProperty(h,"line",r({},f,{get:function(){return w},set:function(O){if(typeof O!="number"&&O!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");w=O,this.hasBeenReset=!0}})),Object.defineProperty(h,"lineAlign",r({},f,{get:function(){return N},set:function(O){const W=s(O);if(!W)throw new SyntaxError("An invalid or illegal string was specified.");N=W,this.hasBeenReset=!0}})),Object.defineProperty(h,"position",r({},f,{get:function(){return K},set:function(O){if(O<0||O>100)throw new Error("Position must be between 0 and 100.");K=O,this.hasBeenReset=!0}})),Object.defineProperty(h,"positionAlign",r({},f,{get:function(){return p},set:function(O){const W=s(O);if(!W)throw new SyntaxError("An invalid or illegal string was specified.");p=W,this.hasBeenReset=!0}})),Object.defineProperty(h,"size",r({},f,{get:function(){return $},set:function(O){if(O<0||O>100)throw new Error("Size must be between 0 and 100.");$=O,this.hasBeenReset=!0}})),Object.defineProperty(h,"align",r({},f,{get:function(){return F},set:function(O){const W=s(O);if(!W)throw new SyntaxError("An invalid or illegal string was specified.");F=W,this.hasBeenReset=!0}})),h.displayState=void 0}return n.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},n})();class Lf{decode(e,t){if(!e)return"";if(typeof e!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}function ml(a){function e(i,s,r,n){return(i|0)*3600+(s|0)*60+(r|0)+parseFloat(n||0)}const t=a.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return t?parseFloat(t[2])>59?e(t[2],t[3],0,t[4]):e(t[1],t[2],t[3],t[4]):null}class Rf{constructor(){this.values=Object.create(null)}set(e,t){!this.get(e)&&t!==""&&(this.values[e]=t)}get(e,t,i){return i?this.has(e)?this.values[e]:t[i]:this.has(e)?this.values[e]:t}has(e){return e in this.values}alt(e,t,i){for(let s=0;s<i.length;++s)if(t===i[s]){this.set(e,t);break}}integer(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))}percent(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){const i=parseFloat(t);if(i>=0&&i<=100)return this.set(e,i),!0}return!1}}function Il(a,e,t,i){const s=i?a.split(i):[a];for(const r in s){if(typeof s[r]!="string")continue;const n=s[r].split(t);if(n.length!==2)continue;const o=n[0],c=n[1];e(o,c)}}const pn=new gn(0,0,""),qs=pn.align==="middle"?"middle":"center";function Df(a,e,t){const i=a;function s(){const o=ml(a);if(o===null)throw new Error("Malformed timestamp: "+i);return a=a.replace(/^[^\sa-zA-Z-]+/,""),o}function r(o,c){const u=new Rf;Il(o,function(g,I){let m;switch(g){case"region":for(let E=t.length-1;E>=0;E--)if(t[E].id===I){u.set(g,t[E].region);break}break;case"vertical":u.alt(g,I,["rl","lr"]);break;case"line":m=I.split(","),u.integer(g,m[0]),u.percent(g,m[0])&&u.set("snapToLines",!1),u.alt(g,m[0],["auto"]),m.length===2&&u.alt("lineAlign",m[1],["start",qs,"end"]);break;case"position":m=I.split(","),u.percent(g,m[0]),m.length===2&&u.alt("positionAlign",m[1],["start",qs,"end","line-left","line-right","auto"]);break;case"size":u.percent(g,I);break;case"align":u.alt(g,I,["start",qs,"end","left","right"]);break}},/:/,/\s/),c.region=u.get("region",null),c.vertical=u.get("vertical","");let h=u.get("line","auto");h==="auto"&&pn.line===-1&&(h=-1),c.line=h,c.lineAlign=u.get("lineAlign","start"),c.snapToLines=u.get("snapToLines",!0),c.size=u.get("size",100),c.align=u.get("align",qs);let f=u.get("position","auto");f==="auto"&&pn.position===50&&(f=c.align==="start"||c.align==="left"?0:c.align==="end"||c.align==="right"?100:50),c.position=f}function n(){a=a.replace(/^\s+/,"")}if(n(),e.startTime=s(),n(),a.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+i);a=a.slice(3),n(),e.endTime=s(),n(),r(a,e)}function Cl(a){return a.replace(/<br(?: \/)?>/gi,`
31
- `)}class Pf{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new Lf,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(e){const t=this;e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));function i(){let r=t.buffer,n=0;for(r=Cl(r);n<r.length&&r[n]!=="\r"&&r[n]!==`
32
- `;)++n;const o=r.slice(0,n);return r[n]==="\r"&&++n,r[n]===`
33
- `&&++n,t.buffer=r.slice(n),o}function s(r){Il(r,function(n,o){},/:/)}try{let r="";if(t.state==="INITIAL"){if(!/\r\n|\n/.test(t.buffer))return this;r=i();const o=r.match(/^()?WEBVTT([ \t].*)?$/);if(!(o!=null&&o[0]))throw new Error("Malformed WebVTT signature.");t.state="HEADER"}let n=!1;for(;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(n?n=!1:r=i(),t.state){case"HEADER":/:/.test(r)?s(r):r||(t.state="ID");continue;case"NOTE":r||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(r)){t.state="NOTE";break}if(!r)continue;if(t.cue=new gn(0,0,""),t.state="CUE",r.indexOf("-->")===-1){t.cue.id=r;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{Df(r,t.cue,t.regionList)}catch{t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":{const o=r.indexOf("-->")!==-1;if(!r||o&&(n=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(t.cue===null)continue;t.cue.text&&(t.cue.text+=`
34
- `),t.cue.text+=r}continue;case"BADCUE":r||(t.state="ID")}}}catch{t.state==="CUETEXT"&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state=t.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this}flush(){const e=this;try{if((e.cue||e.state==="HEADER")&&(e.buffer+=`
25
+ ${this.list("audiovideo")}}`}list(e){var t,i;return(t=this.queues)!=null&&t[e]||(i=this.tracks)!=null&&i[e]?`${e}: (${this.listSbInfo(e)}) ${this.listOps(e)}`:""}listSbInfo(e){var t;const i=(t=this.tracks)==null?void 0:t[e],s=i?.buffer;return s?`SourceBuffer${s.updating?" updating":""}${i.ended?" ended":""}${i.ending?" ending":""}`:"none"}listOps(e){var t;return((t=this.queues)==null?void 0:t[e].map(i=>i.label).join(", "))||""}}const Jl=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,eu="HlsJsTrackRemovedError",rg=.25,ag=.001;class og extends Error{constructor(e){super(e),this.name=eu}}class lg extends wt{constructor(e,t){super("buffer-controller",e.logger),this.hls=void 0,this.fragmentTracker=void 0,this.fragmentAppendProgress=Object.create(null),this.appendsWithoutProgress=Object.create(null),this.details=null,this._objectUrl=null,this.operationQueue=null,this.bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.lastVideoAppendEnd=0,this.appendSource=void 0,this.transferData=void 0,this.overrides=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.appendError=void 0,this._quotaEvictionPending={},this.tracks={},this.sourceBuffers=[[null,null],[null,null]],this._onEndStreaming=i=>{var s;this.hls&&((s=this.mediaSource)==null?void 0:s.readyState)==="open"&&(!this.media||this.media.seeking||this.hls.pauseBuffering())},this._onStartStreaming=i=>{this.hls&&this.hls.resumeBuffering()},this._onMediaSourceOpen=i=>{const{media:s,mediaSource:n}=this;i&&this.log("Media source opened"),!(!s||!n)&&(Ve(n,"sourceopen",this._onMediaSourceOpen),Ve(s,"emptied",this._onMediaEmptied),this.updateDuration(),this.hls.trigger(E.MEDIA_ATTACHED,{media:s,mediaSource:n}),this.mediaSource!==null&&this.checkPendingTracks())},this._onMediaSourceClose=()=>{if(this.log("Media source closed"),this.media){const i=this.media.error,{appendError:s,appendErrors:n}=this;let a=!1;!s&&i&&(a=Math.max(++n.audio,++n.video,++n.audiovideo)>=this.hls.config.appendErrorMaxRetry);const o=new Error(`MediaSource closed while media attached${iu(a,i)}`);this.warn(o),this.hls.trigger(E.ERROR,je({fatal:a},s,{type:me.MEDIA_ERROR,details:U.MEDIA_SOURCE_REQUIRES_RESET,error:o}))}},this._onMediaSourceEnded=()=>{this.log("Media source ended")},this._onMediaEmptied=()=>{const{mediaSrc:i,_objectUrl:s}=this;i!==s&&this.error(`Media element src was set while attaching MediaSource (${s} > ${i})`)},this._onMediaError=()=>{const{media:i}=this;if(i){var s,n;this.log(`Media error (code: ${(s=i.error)==null?void 0:s.code}): ${(n=i.error)==null?void 0:n.message}`)}},this.hls=e,this.fragmentTracker=t,this.appendSource=uh(Ei(e.config.preferManagedMediaSource)),this.initTracks(),this.registerListeners()}hasSourceTypes(){return Object.keys(this.tracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null,this.transferData=this.overrides=void 0,this.operationQueue&&(this.operationQueue.destroy(),this.operationQueue=null),this.hls=this.fragmentTracker=null,this._onMediaSourceOpen=this._onMediaSourceClose=null,this._onMediaSourceEnded=null,this._onStartStreaming=this._onEndStreaming=null,this._onMediaEmptied=this._onMediaError=null}registerListeners(){const{hls:e}=this;e.on(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.BUFFER_RESET,this.onBufferReset,this),e.on(E.BUFFER_APPENDING,this.onBufferAppending,this),e.on(E.BUFFER_CODECS,this.onBufferCodecs,this),e.on(E.BUFFER_EOS,this.onBufferEos,this),e.on(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(E.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(E.FRAG_PARSED,this.onFragParsed,this),e.on(E.FRAG_CHANGED,this.onFragChanged,this),e.on(E.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.BUFFER_RESET,this.onBufferReset,this),e.off(E.BUFFER_APPENDING,this.onBufferAppending,this),e.off(E.BUFFER_CODECS,this.onBufferCodecs,this),e.off(E.BUFFER_EOS,this.onBufferEos,this),e.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(E.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(E.FRAG_PARSED,this.onFragParsed,this),e.off(E.FRAG_CHANGED,this.onFragChanged,this),e.off(E.ERROR,this.onError,this)}transferMedia(){const{media:e,mediaSource:t}=this;if(!e)return null;const i={};if(this.operationQueue){const n=this.isUpdating();n||this.operationQueue.removeBlockers();const a=this.isQueued();(n||a)&&this.warn(`Transfering MediaSource with${a?" operations in queue":""}${n?" updating SourceBuffer(s)":""} ${this.operationQueue}`),this.operationQueue.destroy()}const s=this.transferData;return s&&!this.sourceBufferCount&&s.mediaSource===t?je(i,s.tracks):this.sourceBuffers.forEach(n=>{const[a]=n;a&&(i[a]=je({},this.tracks[a]),this.removeBuffer(a)),n[0]=n[1]=null}),{media:e,mediaSource:t,tracks:i}}initTracks(){const e={};this.resetAppendProgress(),this.sourceBuffers=[[null,null],[null,null]],this.tracks=e,this.resetQueue(),this.lastMpegAudioChunk=null,this.lastVideoAppendEnd=0}onManifestLoading(){this.bufferCodecEventsTotal=0,this.details=null,this.resetAppendErrors(),this.resetAppendProgress()}onManifestParsed(e,t){var i;let s=2;(t.audio&&!t.video||!t.altAudio)&&(s=1),this.bufferCodecEventsTotal=s,this.log(`${s} bufferCodec event(s) expected.`),(i=this.transferData)!=null&&i.mediaSource&&this.sourceBufferCount&&s&&this.bufferCreated()}onMediaAttaching(e,t){const i=this.media=t.media;this.transferData=this.overrides=void 0;const s=Ei(this.appendSource);if(s){const n=!!t.mediaSource;(n||t.overrides)&&(this.transferData=t,this.overrides=t.overrides);const a=this.mediaSource=t.mediaSource||new s;if(this.assignMediaSource(a),n)this._objectUrl=i.src,this.attachTransferred();else{const o=this._objectUrl=self.URL.createObjectURL(a);if(this.appendSource)try{i.removeAttribute("src");const l=self.ManagedMediaSource;i.disableRemotePlayback=i.disableRemotePlayback||l&&a instanceof l,tu(i),ug(i,o),i.load()}catch{i.src=o}else i.src=o}Ke(i,"emptied",this._onMediaEmptied),Ke(i,"error",this._onMediaError),this.appendSource&&Ke(i,"seeking",this._onStartStreaming)}}assignMediaSource(e){var t,i;this.log(`${((t=this.transferData)==null?void 0:t.mediaSource)===e?"transferred":"created"} media source: ${(i=e.constructor)==null?void 0:i.name}`),Ke(e,"sourceopen",this._onMediaSourceOpen),Ke(e,"sourceended",this._onMediaSourceEnded),Ke(e,"sourceclose",this._onMediaSourceClose),this.appendSource&&(Ke(e,"startstreaming",this._onStartStreaming),Ke(e,"endstreaming",this._onEndStreaming))}attachTransferred(){const e=this.media,t=this.transferData;if(!t||!e)return;const i=this.tracks,s=t.tracks,n=s?Object.keys(s):null,a=n?n.length:0,o=()=>{Promise.resolve().then(()=>{this.media&&this.mediaSourceOpenOrEnded&&this._onMediaSourceOpen()})};if(s&&n&&a){if(!this.tracksReady){this.hls.config.startFragPrefetch=!0,this.log("attachTransferred: waiting for SourceBuffer track info");return}if(this.log(`attachTransferred: (bufferCodecEventsTotal ${this.bufferCodecEventsTotal})
26
+ required tracks: ${Xe(i,(l,u)=>l==="initSegment"?void 0:u)};
27
+ transfer tracks: ${Xe(s,(l,u)=>l==="initSegment"?void 0:u)}}`),!ja(s,i)){t.mediaSource=null,t.tracks=void 0;const l=e.currentTime,u=this.details,h=Math.max(l,u?.fragments[0].start||0);if(h-l>1){this.log(`attachTransferred: waiting for playback to reach new tracks start time ${l} -> ${h}`);return}this.warn(`attachTransferred: resetting MediaSource for incompatible tracks ("${Object.keys(s)}"->"${Object.keys(i)}") start time: ${h} currentTime: ${l}`),this.onMediaDetaching(E.MEDIA_DETACHING,{}),this.onMediaAttaching(E.MEDIA_ATTACHING,t),e.currentTime=h;return}this.transferData=void 0,n.forEach(l=>{const u=l,h=s[u];if(h){const d=h.buffer;if(d){const g=this.fragmentTracker,m=h.id;if(g.hasFragments(m)||g.hasParts(m)){const v=ve.getBuffered(d);g.detectEvictedFragments(u,v,m,null,null,!0)}const A=Mr(u),C=[u,d];this.sourceBuffers[A]=C,d.updating&&this.operationQueue&&this.operationQueue.prependBlocker(u),this.trackSourceBuffer(u,h)}}}),o(),this.bufferCreated()}else this.log("attachTransferred: MediaSource w/o SourceBuffers"),o()}get mediaSourceOpenOrEnded(){var e;const t=(e=this.mediaSource)==null?void 0:e.readyState;return t==="open"||t==="ended"}onMediaDetaching(e,t){const i=!!t.transferMedia;this.transferData=this.overrides=void 0;const{media:s,mediaSource:n,_objectUrl:a}=this;if(n){if(this.log(`media source ${i?"transferring":"detaching"}`),i)this.sourceBuffers.forEach(([o])=>{o&&this.removeBuffer(o)}),this.resetQueue();else{if(this.mediaSourceOpenOrEnded){const o=n.readyState==="open";try{const l=n.sourceBuffers;for(let u=l.length;u--;)o&&l[u].abort(),n.removeSourceBuffer(l[u]);o&&n.endOfStream()}catch(l){this.warn(`onMediaDetaching: ${l.message} while calling endOfStream`)}}this.sourceBufferCount&&this.onBufferReset()}Ve(n,"sourceopen",this._onMediaSourceOpen),Ve(n,"sourceended",this._onMediaSourceEnded),Ve(n,"sourceclose",this._onMediaSourceClose),this.appendSource&&(Ve(n,"startstreaming",this._onStartStreaming),Ve(n,"endstreaming",this._onEndStreaming)),this.mediaSource=null,this._objectUrl=null}s&&(Ve(s,"emptied",this._onMediaEmptied),Ve(s,"error",this._onMediaError),Ve(s,"seeking",this._onStartStreaming),i||(a&&self.URL.revokeObjectURL(a),this.mediaSrc===a?(s.removeAttribute("src"),this.appendSource&&tu(s),s.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null)}onBufferReset(){this.sourceBuffers.forEach(([e])=>{e&&this.resetBuffer(e)}),this.initTracks()}resetBuffer(e){var t;const i=(t=this.tracks[e])==null?void 0:t.buffer;if(this.removeBuffer(e),i)try{var s;(s=this.mediaSource)!=null&&s.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(i)}catch(n){this.warn(`onBufferReset ${e}`,n)}delete this.tracks[e]}removeBuffer(e){this.removeBufferListeners(e),this.sourceBuffers[Mr(e)]=[null,null];const t=this.tracks[e];t&&(this.clearBufferAppendTimeoutId(t),t.buffer=void 0)}resetQueue(){this.operationQueue&&this.operationQueue.destroy(),this.operationQueue=new ng(this.tracks)}onBufferCodecs(e,t){var i;const s=this.tracks,n=Object.keys(t);this.log(`BUFFER_CODECS: "${n}" (current SB count ${this.sourceBufferCount})`);const a="audiovideo"in t&&(s.audio||s.video)||s.audiovideo&&("audio"in t||"video"in t),o=!a&&this.sourceBufferCount&&this.media&&n.some(l=>!s[l]);if(a||o){this.warn(`Unsupported transition between "${Object.keys(s)}" and "${n}" SourceBuffers`);return}n.forEach(l=>{var u,h;const d=t[l],{id:g,codec:m,levelCodec:A,container:C,metadata:v,supplemental:S}=d;let R=s[l];const b=(u=this.transferData)==null||(u=u.tracks)==null?void 0:u[l],D=b!=null&&b.buffer?b:R,_=D?.pendingCodec||D?.codec,M=D?.levelCodec;R||(R=s[l]={buffer:void 0,listeners:[],codec:m,supplemental:S,container:C,levelCodec:A,metadata:v,id:g});const p=Js(_,M),$=p?.replace(Jl,"$1");let N=Js(m,A);const O=(h=N)==null?void 0:h.replace(Jl,"$1");N&&p&&$!==O&&(l.slice(0,5)==="audio"&&(N=Qs(N,this.appendSource)),this.log(`switching codec ${_} to ${N}`),N!==(R.pendingCodec||R.codec)&&(R.pendingCodec=N),R.container=C,this.appendChangeType(l,C,N))}),(this.tracksReady||this.sourceBufferCount)&&(t.tracks=this.sourceBufferTracks),!this.sourceBufferCount&&(this.bufferCodecEventsTotal>1&&!this.tracks.video&&!t.video&&((i=t.audio)==null?void 0:i.id)==="main"&&(this.log("Main audio-only"),this.bufferCodecEventsTotal=1),this.mediaSourceOpenOrEnded&&this.checkPendingTracks())}get sourceBufferTracks(){return Object.keys(this.tracks).reduce((e,t)=>{const i=this.tracks[t];return e[t]={id:i.id,container:i.container,codec:i.codec,levelCodec:i.levelCodec},e},{})}appendChangeType(e,t,i){const s=`${t};codecs=${i}`,n={label:`change-type=${s}`,execute:()=>{const a=this.tracks[e];if(a){const o=a.buffer;o!=null&&o.changeType&&(this.log(`changing ${e} sourceBuffer type to ${s}`),o.changeType(s),a.codec=i,a.container=t)}this.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:a=>{this.warn(`Failed to change ${e} SourceBuffer type`,a)}};this.append(n,e,this.isPending(this.tracks[e]))}blockAudio(e){var t;const i=e.start,s=i+e.duration*.05;if(((t=this.fragmentTracker.getAppendedFrag(i,ge.MAIN))==null?void 0:t.gap)===!0)return;const a={label:"block-audio",execute:()=>{var o,l;(this.lastVideoAppendEnd>s||ve.isBuffered((o=this.tracks.video)==null?void 0:o.buffer,s)||((l=this.fragmentTracker.getAppendedFrag(s,ge.MAIN))==null?void 0:l.gap)===!0)&&this.unblockAudio()},onStart:()=>{},onComplete:()=>{},onError:o=>{this.warn("Error executing block-audio operation",o)}};this.append(a,"audio",!0)}unblockAudio(){this.operationQueue&&this.operationQueue.unblockAudio()}onBufferAppending(e,t){const{tracks:i}=this,{data:s,type:n,parent:a,frag:o,part:l,chunkMeta:u,offset:h}=t,d=u.buffering[n],g=st(o)&&!l&&!o.gap&&!u.partial&&!u.iframe;let m=null,A=!1;const{sn:C,cc:v}=o,S=self.performance.now();d.start=S;const R=o.stats.buffering,b=l?l.stats.buffering:null;R.start===0&&(R.start=S),b?.start===0&&(b.start=S);const D=i.audio;let _=!1;n==="audio"&&D?.container==="audio/mpeg"&&(_=!this.lastMpegAudioChunk||u.id===1||this.lastMpegAudioChunk.sn!==u.sn,this.lastMpegAudioChunk=u);const M=i.video,p=M?.buffer;if(p&&C!=="initSegment"&&h!==void 0){const O=D?.buffer,W=l||o;if(n==="audio"&&a!=="main"&&!(M.ending||M.ended)&&O&&ve.getBuffered(O).length){const z=W.start+W.duration*.05,oe=ve.getBuffered(p),ne=this.currentOp("video");!oe.length&&!ne?this.blockAudio(W):!ve.isBuffered(p,z)&&this.lastVideoAppendEnd<z&&this.blockAudio(W)}else if(n==="video"){const q=W.end,z=this.lastVideoAppendEnd-q;this.lastVideoAppendEnd=q,z<0||z>W.duration?this.unblockAudio():this.isAudioBlocked()&&this.executeNext("audio")}}const $=(l||o).start,N={label:`append-${n}`,execute:()=>{var O;d.executeStart=self.performance.now();const W=(O=this.tracks[n])==null?void 0:O.buffer;W&&(g&&(m=ve.timeRangesToArray(ve.getBuffered(W)),A=nu(Or(m,o),o)),_?this.updateTimestampOffset(W,$,.1,n,C,v):h!==void 0&&se(h)&&this.updateTimestampOffset(W,h,1e-6,n,C,v)),this.appendExecutor(s,n)},onStart:()=>{},onComplete:()=>{this.clearBufferAppendTimeoutId(this.tracks[n]);const O=self.performance.now();d.executeEnd=d.end=O,R.first===0&&(R.first=O),b?.first===0&&(b.first=O);const W={};if(this.sourceBuffers.forEach(([q,z])=>{q&&(W[q]=ve.getBuffered(z))}),g){const q=this.getFragmentAppendProgress(o),z=W[n];if(z&&m){const oe=ve.timeRangesToArray(z),ne=Or(oe,o);q.progressed||(q.progressed=ne-Or(m,o)>ag);const J=A&&nu(ne,o);q.fullyBuffered[n]=(q.fullyBuffered[n]===void 0||q.fullyBuffered[n])&&J}}this.hls.trigger(E.BUFFER_APPENDED,{type:n,frag:o,part:l,chunkMeta:u,parent:a,timeRanges:W})},onError:O=>{var W;this.clearBufferAppendTimeoutId(this.tracks[n]);const q=O.code===DOMException.QUOTA_EXCEEDED_ERR||O.name=="QuotaExceededError"||"quota"in O;if(q&&!this._quotaEvictionPending[n]){const J=this.getBackBufferEvictionTarget(n,s.byteLength,o.type);if(J>0){this._quotaEvictionPending[n]=!0,this.log(`QuotaExceededError on "${n}" append sn: ${C} - evicting back buffer to ${J.toFixed(3)}s and retrying`);const Z=this.getFlushOp(n,0,J),Q=this.getClearEvictionPendingOp(n);this.insertNext([Z,N,Q],n);return}this.warn(`QuotaExceededError on "${n}" sn: ${C} - no back buffer available to evict`)}g&&(this.getFragmentAppendProgress(o).errored=!0);const z={type:me.MEDIA_ERROR,parent:a,details:U.BUFFER_APPEND_ERROR,sourceBufferName:n,frag:o,part:l,chunkMeta:u,error:O,err:O,fatal:!1},oe=(W=this.media)==null?void 0:W.error;if(O.name===eu&&this.sourceBufferCount===0&&(!this.media||this.pendingTrackCount===0))z.errorAction=ys(!0);else{var ne;q&&(z.details=U.BUFFER_FULL_ERROR);const J=++this.appendErrors[n],Z=this.hls.config.appendErrorMaxRetry;this.warn(`Failed ${J}/${Z+1} times to append segment in "${n}" sourceBuffer with error: ${O.message}`),J>=Z&&(z.fatal=!q);const Q=(ne=this.mediaSource)==null?void 0:ne.readyState;(Q==="ended"||Q==="closed"||oe)&&(this.warn(`MediaSource readyState "${Q}" during SourceBuffer${iu(z.fatal,oe)}`),z.details=U.MEDIA_SOURCE_REQUIRES_RESET)}this.appendError=z,this.hls.trigger(E.ERROR,z),q&&this.hls&&this.trimBuffers(o.start,1)}};this.log(`queuing "${n}" append sn: ${C}${l?" p: "+l.index:""} of ${a} playlist ${o.level} cc: ${v} offset: ${h} bytes: ${s.byteLength}`),this.append(N,n,this.isPending(this.tracks[n]))}getClearEvictionPendingOp(e){return{label:"clear",execute:()=>{this._quotaEvictionPending[e]=!1,this.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:()=>{}}}getFlushOp(e,t,i){return this.log(`queuing "${e}" remove ${t}-${i}`),{label:"remove",execute:()=>{this.removeExecutor(e,t,i)},onStart:()=>{},onComplete:()=>{var s;const n=(s=this.tracks[e])==null?void 0:s.buffer;this.log(`Remove request ${t}-${i} from ${e} Source Buffer complete > buffer: ${n?hn(ve.getBuffered(n)):"(detached)"}`),this.hls.trigger(E.BUFFER_FLUSHED,{type:e,start:t,end:i})},onError:s=>{this.warn(`Failed to remove ${t}-${i} from "${e}" SourceBuffer`,s),this.hls.trigger(E.BUFFER_FLUSHED,{type:e,start:0,end:0,error:s})}}}onBufferFlushing(e,t){const{type:i,startOffset:s,endOffset:n}=t;(!i||i==="audio")&&this.unblockAudio(),i?this.append(this.getFlushOp(i,s,n),i):this.sourceBuffers.forEach(([a])=>{a&&this.append(this.getFlushOp(a,s,n),a)})}onFragParsed(e,t){const{frag:i,part:s,chunkMeta:n}=t,a=[],o=s?s.elementaryStreams:i.elementaryStreams;o[ze.AUDIOVIDEO]?a.push("audiovideo"):(o[ze.AUDIO]&&a.push("audio"),o[ze.VIDEO]&&a.push("video"));const l=()=>{const u=self.performance.now();i.stats.buffering.end=u,s&&(s.stats.buffering.end=u);const h=s?s.stats:i.stats;this.checkAppendProgress(i,s,n,a),this.hls&&(this.hls.trigger(E.FRAG_BUFFERED,{frag:i,part:s,stats:h,id:i.type,chunkMeta:n}),!s&&i.gap&&h.retry&&this.log(`Nothing buffered for ${i.type} level: ${i.level} sn: ${i.sn} retries ${h.retry}`))};a.length===0&&this.log(`Fragments must have at least one ElementaryStreamType set. ${i.type} ${i.level} ${s?`part: ${s.index} of `:""}sn: ${i.sn}`),this.blockBuffers(l,a).catch(u=>{this.warn(`Fragment buffered callback ${u.message}`),this.stepOperationQueue(this.sourceBufferTypes)})}onFragChanged(e,t){var i,s;const n=(i=this.hls)==null?void 0:i.config;if(!n)return;const{backBufferLength:a,frontBufferFlushThreshold:o}=n;this.trimBuffers(o,a,t.frag,t.previousFrag);const l=t.frag.elementaryStreams,{appendErrors:u}=this,h=(s=this.appendError)==null?void 0:s.sourceBufferName;Object.keys(l).forEach(d=>{l[d]&&(u[d]=0,d===h&&(this.appendError=void 0),d==="audio"||d==="video"?(u.audiovideo=0,h==="audiovideo"&&(this.appendError=void 0)):(u.audio=0,u.video=0,h!=="audiovideo"&&(this.appendError=void 0)))})}get bufferedToEnd(){return this.sourceBufferCount>0&&!this.sourceBuffers.some(([e])=>{if(e){const t=this.tracks[e];if(t)return!t.ended||t.ending}return!1})}onBufferEos(e,t){var i;this.sourceBuffers.forEach(([a])=>{if(a){const o=this.tracks[a];(!t.type||t.type===a)&&(o.ending=!0,o.ended||(o.ended=!0,this.log(`${a} buffer reached EOS`)))}});const s=((i=this.overrides)==null?void 0:i.endOfStream)!==!1;this.sourceBufferCount>0&&!this.sourceBuffers.some(([a])=>{var o;return a&&!((o=this.tracks[a])!=null&&o.ended)})?(this.unblockAudio(),s?(this.log("Queueing EOS"),this.blockUntilOpen(()=>{this.tracksEnded();const{mediaSource:a}=this;if(a?.readyState!=="open"){a&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${a.readyState}`);return}this.log("Calling mediaSource.endOfStream()"),a.endOfStream(),this.hls.trigger(E.BUFFERED_TO_END,void 0)})):(this.tracksEnded(),this.hls.trigger(E.BUFFERED_TO_END,void 0))):t.type==="video"&&this.unblockAudio()}tracksEnded(){this.sourceBuffers.forEach(([e])=>{if(e!==null){const t=this.tracks[e];t&&(t.ending=!1)}})}onLevelUpdated(e,{details:t}){t.fragments.length&&(this.details=t,this.updateDuration())}updateDuration(){this.blockUntilOpen(()=>{const e=this.getDurationAndRange();e&&this.updateMediaSource(e)})}onError(e,t){if(t.details===U.BUFFER_APPEND_ERROR&&t.frag){var i;const s=(i=t.errorAction)==null?void 0:i.nextAutoLevel;se(s)&&s!==t.frag.level&&this.resetAppendErrors()}}getBackBufferEvictionTarget(e,t,i){const{media:s}=this;return s?this.fragmentTracker.getBackBufferEvictionEnd(s.currentTime,i,t):0}getFragmentAppendProgress(e){var t;const i=su(e);let s=this.fragmentAppendProgress[i];return((t=s)==null?void 0:t.stats)!==e.stats&&(s={stats:e.stats,progressed:!1,errored:!1,fullyBuffered:Object.create(null)},this.fragmentAppendProgress[i]=s),s}checkAppendProgress(e,t,i,s){if(t||!st(e)||e.gap||i.iframe||i.partial)return;const n=su(e),a=this.fragmentAppendProgress[n];delete this.fragmentAppendProgress[n];const o=e.stats.buffering;if(o.start&&!o.first)return;const l=a?.stats===e.stats?a:void 0;if(l!=null&&l.errored)return;const u=s.length>0&&s.every(m=>l?.fullyBuffered[m]===!0);if(l!=null&&l.progressed||u){delete this.appendsWithoutProgress[n];return}if(!l&&s.length===0)return;const h=(this.appendsWithoutProgress[n]||0)+1,d=this.hls;h>=d.config.appendErrorMaxRetry?delete this.appendsWithoutProgress[n]:this.appendsWithoutProgress[n]=h,this.warn(`Fragment ${e.sn} of ${e.type} playlist ${e.level} appended ${h} time${h>1?"s":""} without buffered range growth`),d.trigger(E.ERROR,{type:me.MEDIA_ERROR,details:U.BUFFER_APPEND_NO_PROGRESS,fatal:!1,frag:e,chunkMeta:i,parent:e.type,appendsWithoutProgress:h,error:new Error(`Fragment append did not increase buffered coverage (${h})`)})}resetAppendProgress(){this.fragmentAppendProgress=Object.create(null),this.appendsWithoutProgress=Object.create(null)}resetAppendErrors(){this.appendErrors={audio:0,video:0,audiovideo:0},this.appendError=void 0}trimBuffers(e,t,i,s){const{hls:n,details:a,media:o}=this;if(!o||a===null||!this.sourceBufferCount)return;const l=n.config,u=o.currentTime,h=a.levelTargetDuration;t=a.live&&l.liveBackBufferLength!==null?l.liveBackBufferLength:t;let d=-1/0;if(se(t)&&t>=0){const g=Math.max(t,h);d=Math.floor(u/h)*h-g}if(i){const g=this.getLoopBackBufferFlushEnd(i,s??null);g>0&&(d=Math.max(d,g))}if(d>0&&this.flushBackBuffer(u,h,d),se(e)&&e>0){const g=Math.max(l.maxBufferLength,e),m=Math.max(g,h),A=Math.floor(u/h)*h+m;this.flushFrontBuffer(u,h,A)}}getLoopBackBufferFlushEnd(e,t){var i;const{media:s}=this;if(((i=this.hls)==null?void 0:i.config.loopBackBufferFlush)===!1||!(s!=null&&s.loop)||!t||e.level<=t.level)return 0;const{video:n,audiovideo:a}=e.elementaryStreams;if(n!=null&&n.partial||a!=null&&a.partial)return 0;const o=this.getEarliestElementaryStreamStart(e)-rg;return o<=0?0:(this.log(`Flushing lower quality back buffer for loop: level ${e.level}, range [0-${o.toFixed(3)}]`),o)}getEarliestElementaryStreamStart(e){const{audio:t,video:i,audiovideo:s}=e.elementaryStreams;let n=e.start;return s?n=Math.min(n,s.startDTS):(t&&(n=Math.min(n,t.startDTS)),i&&(n=Math.min(n,i.startDTS))),n}flushBackBuffer(e,t,i){this.sourceBuffers.forEach(([s,n])=>{if(n){const u=ve.getBuffered(n);if(u.length>0&&i>u.start(0)){var a,o,l;this.hls.trigger(E.BACK_BUFFER_REACHED,{bufferEnd:i});const h=this.tracks[s];if((a=this.details)!=null&&a.live)this.hls.trigger(E.LIVE_BACK_BUFFER_REACHED,{bufferEnd:i});else if(h!=null&&h.ended&&!((o=this.media)!=null&&o.loop&&((l=this.hls)==null?void 0:l.config.loopBackBufferFlush)!==!1)){this.log(`Cannot flush ${s} back buffer while SourceBuffer is in ended state`);return}this.hls.trigger(E.BUFFER_FLUSHING,{startOffset:0,endOffset:i,type:s})}}})}flushFrontBuffer(e,t,i){this.sourceBuffers.forEach(([s,n])=>{if(n){const a=ve.getBuffered(n),o=a.length;if(o<2)return;const l=a.start(o-1),u=a.end(o-1);if(i>l||e>=l&&e<=u)return;this.hls.trigger(E.BUFFER_FLUSHING,{startOffset:l,endOffset:1/0,type:s})}})}getDurationAndRange(){var e;const{details:t,mediaSource:i}=this;if(!t||!this.media||i?.readyState!=="open")return null;const s=t.edge;if(t.live&&this.hls.config.liveDurationInfinity){if(t.fragments.length&&i.setLiveSeekableRange){const u=Math.max(0,t.fragmentStart),h=Math.max(u,s);return{duration:1/0,start:u,end:h}}return{duration:1/0}}const n=(e=this.overrides)==null?void 0:e.duration;if(n)return se(n)?{duration:n}:null;const a=this.media.duration,o=se(i.duration)?i.duration:0;return s>o&&s>a||!se(a)?{duration:s}:null}updateMediaSource({duration:e,start:t,end:i}){const s=this.mediaSource;!s||!this.media||s.readyState!=="open"||(s.duration!==e&&(se(e)&&this.log(`Updating MediaSource duration to ${e.toFixed(3)}`),s.duration=e),t!==void 0&&i!==void 0&&(this.log(`MediaSource duration is set to ${s.duration}. Setting seekable range to ${t}-${i}.`),s.setLiveSeekableRange(t,i)))}get tracksReady(){const e=this.pendingTrackCount;return e>0&&(e>=this.bufferCodecEventsTotal||this.isPending(this.tracks.audiovideo))}checkPendingTracks(){const{bufferCodecEventsTotal:e,pendingTrackCount:t,tracks:i}=this;if(this.log(`checkPendingTracks (pending: ${t} codec events expected: ${e}) ${Xe(i)}`),this.tracksReady){var s;const n=(s=this.transferData)==null?void 0:s.tracks;n&&Object.keys(n).length?this.attachTransferred():this.createSourceBuffers()}}bufferCreated(){if(this.sourceBufferCount){const e={};this.sourceBuffers.forEach(([t,i])=>{if(t){const s=this.tracks[t];e[t]={buffer:i,container:s.container,codec:s.codec,supplemental:s.supplemental,levelCodec:s.levelCodec,id:s.id,metadata:s.metadata}}}),this.hls.trigger(E.BUFFER_CREATED,{tracks:e}),this.log(`SourceBuffers created. Running queue: ${this.operationQueue}`),this.sourceBuffers.forEach(([t])=>{this.executeNext(t)})}else{const e=new Error("could not create source buffer for media codec(s)");this.hls.trigger(E.ERROR,{type:me.MEDIA_ERROR,details:U.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:e,reason:e.message})}}createSourceBuffers(){const{tracks:e,sourceBuffers:t,mediaSource:i}=this;if(!i)throw new Error("createSourceBuffers called when mediaSource was null");for(const n in e){const a=n,o=e[a];if(this.isPending(o)){const l=this.getTrackCodec(o,a),u=`${o.container};codecs=${l}`;o.codec=l,this.log(`creating sourceBuffer(${u})${this.currentOp(a)?" Queued":""} ${Xe(o)}`);try{const h=i.addSourceBuffer(u),d=Mr(a),g=[a,h];t[d]=g,o.buffer=h}catch(h){var s;this.error(`error while trying to add sourceBuffer: ${h.message}`),this.shiftAndExecuteNext(a),(s=this.operationQueue)==null||s.removeBlockers(),delete this.tracks[a],this.hls.trigger(E.ERROR,{type:me.MEDIA_ERROR,details:U.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:h,sourceBufferName:a,mimeType:u,parent:o.id});return}this.trackSourceBuffer(a,o)}}this.bufferCreated()}clearBufferAppendTimeoutId(e){e&&(self.clearTimeout(e.bufferAppendTimeoutId),e.bufferAppendTimeoutId=void 0)}getTrackCodec(e,t){const i=e.supplemental;let s=e.codec;i&&(t==="video"||t==="audiovideo")&&ms(i,"video")&&(s=ed(s,i));const n=Js(s,e.levelCodec);return n?t.slice(0,5)==="audio"?Qs(n,this.appendSource):n:""}trackSourceBuffer(e,t){const i=t.buffer;if(!i)return;const s=this.getTrackCodec(t,e);this.tracks[e]={buffer:i,codec:s,container:t.container,levelCodec:t.levelCodec,supplemental:t.supplemental,metadata:t.metadata,id:t.id,listeners:[]},this.removeBufferListeners(e),this.addBufferListener(e,"updatestart",this.onSBUpdateStart),this.addBufferListener(e,"updateend",this.onSBUpdateEnd),this.addBufferListener(e,"error",this.onSBUpdateError),this.appendSource&&this.addBufferListener(e,"bufferedchange",(n,a)=>{const o=a.removedRanges;o!=null&&o.length&&(this.log(`${n} buffer removed ${hn(o)}`),this.hls.trigger(E.BUFFER_FLUSHED,{type:n,start:o.start(0),end:o.end(o.length-1)}))})}get mediaSrc(){var e,t;const i=((e=this.media)==null||(t=e.querySelector)==null?void 0:t.call(e,"source"))||this.media;return i?.src}onSBUpdateStart(e){const t=this.currentOp(e);t&&t.onStart()}onSBUpdateEnd(e){var t,i;if(((t=this.mediaSource)==null?void 0:t.readyState)==="closed"){this.resetBuffer(e);return}const s=this.currentOp(e);if(!s)return;if(s.onComplete(),(i=this.tracks[e])==null||(i=i.buffer)==null?void 0:i.updating){this.log(`${e} SourceBuffer updating on "updateend"`),this.blockUntilOpen(()=>{this.shiftAndExecuteNext(e)});return}this.shiftAndExecuteNext(e)}onSBUpdateError(e,t){var i;const s=(i=this.mediaSource)==null?void 0:i.readyState,n=new Error(`${e} SourceBuffer error. MediaSource readyState: ${s}`);this.error(`${n.message}`,t),this.hls.trigger(E.ERROR,{type:me.MEDIA_ERROR,details:U.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:n,fatal:!1});const a=this.currentOp(e);a&&a.onError(n)}updateTimestampOffset(e,t,i,s,n,a){const o=t-e.timestampOffset;Math.abs(o)>=i&&(this.log(`Updating ${s} SourceBuffer timestampOffset to ${t} (sn: ${n} cc: ${a})`),e.timestampOffset=t)}removeExecutor(e,t,i){const{media:s,mediaSource:n}=this,a=this.tracks[e],o=a?.buffer;if(!s||!n||!o)throw new Error(`Attempting to remove from the ${e} SourceBuffer, but it does not exist`);const l=se(s.duration)?s.duration:1/0,u=se(n.duration)?n.duration:1/0,h=Math.max(0,t);if(h>=u){var d;(d=this.currentOp(e))==null||d.onComplete(),this.shiftAndExecuteNext(e);return}const g=Math.min(i,l,u);if(g>h&&(!a.ending||a.ended))a.ended=!1,this.log(`Removing [${h},${g}] from the ${e} SourceBuffer`),o.remove(h,g);else throw new Error(`Cannot remove ${g<=h?`invalid range (${h} >= ${g}) `:""}from the ${e} SourceBuffer${a.ending?" while track ending":""}`)}appendExecutor(e,t){const i=this.tracks[t],s=i?.buffer;if(!s)throw new og(`Attempting to append to the ${t} SourceBuffer, but it does not exist`);if(i.ending=!1,i.ended=!1,this.hls.config.appendTimeout!==1/0){const n=this.calculateAppendTimeoutTime(s);i.bufferAppendTimeoutId=self.setTimeout(()=>this.appendTimeoutHandler(t,s,n),n)}s.appendBuffer(e)}appendTimeoutHandler(e,t,i){this.log(`Received timeout after ${i}ms for append on ${e} source buffer. Aborting and triggering error.`);try{t.abort()}catch{this.log(`Failed to abort append on ${e} source buffer after timeout.`)}const s=this.currentOp(e);s&&s.onError(new Error(`${e}-append-timeout`))}calculateAppendTimeoutTime(e){let t=Xo;this.details&&(t=this.details.levelTargetDuration);let i=2*t*1e3;if(this.media===null)return i;const s=ve.bufferInfo(e,this.media.currentTime,0);return s.len?(i=Math.max(s.len*1e3,i),Math.max(this.hls.config.appendTimeout,i)):i}blockUntilOpen(e){if(this.isUpdating()||this.isQueued())this.blockBuffers(e).catch(t=>{this.warn(`SourceBuffer blocked callback ${t}`),this.stepOperationQueue(this.sourceBufferTypes)});else try{e()}catch(t){this.warn(`Callback run without blocking ${this.operationQueue} ${t}`)}}isUpdating(){return this.sourceBuffers.some(([e,t])=>e&&t.updating)}isQueued(){return this.sourceBuffers.some(([e])=>e&&!!this.currentOp(e))}isPending(e){return!!e&&!e.buffer}isAudioBlocked(){var e;return((e=this.currentOp("audio"))==null?void 0:e.label)==="block-audio"}isAudioBlocking(){return this.operationQueue?this.operationQueue.audioBlocking():!1}blockBuffers(e,t=this.sourceBufferTypes){if(!t.length)return this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);const{operationQueue:i}=this,n=t.length===2&&this.isAudioBlocking()?[this.appendBlocker("video")]:t.map(a=>this.appendBlocker(a));return Promise.all(n).then(a=>{i===this.operationQueue&&(e(),this.stepOperationQueue(this.sourceBufferTypes))})}stepOperationQueue(e){e.forEach(t=>{var i;const s=(i=this.tracks[t])==null?void 0:i.buffer;!s||s.updating||t==="audio"&&this.isAudioBlocked()||this.shiftAndExecuteNext(t)})}append(e,t,i){this.operationQueue&&this.operationQueue.append(e,t,i)}insertNext(e,t){this.operationQueue&&this.operationQueue.insertNext(e,t)}appendBlocker(e){if(this.operationQueue)return this.operationQueue.appendBlocker(e)}currentOp(e){return this.operationQueue?this.operationQueue.current(e):null}executeNext(e){e&&this.operationQueue&&this.operationQueue.executeNext(e)}shiftAndExecuteNext(e){this.operationQueue&&this.operationQueue.shiftAndExecuteNext(e)}get pendingTrackCount(){return Object.keys(this.tracks).reduce((e,t)=>e+(this.isPending(this.tracks[t])?1:0),0)}get sourceBufferCount(){return this.sourceBuffers.reduce((e,[t])=>e+(t?1:0),0)}get sourceBufferTypes(){return this.sourceBuffers.map(([e])=>e).filter(e=>!!e)}addBufferListener(e,t,i){const s=this.tracks[e];if(!s)return;const n=s.buffer;if(!n)return;const a=i.bind(this,e);s.listeners.push({event:t,listener:a}),Ke(n,t,a)}removeBufferListeners(e){const t=this.tracks[e];if(!t)return;const i=t.buffer;i&&(t.listeners.forEach(s=>{Ve(i,s.event,s.listener)}),t.listeners.length=0)}}function tu(r){const e=r.querySelectorAll("source");[].slice.call(e).forEach(t=>{r.removeChild(t)})}function ug(r,e){const t=self.document.createElement("source");t.type="video/mp4",t.src=e,r.appendChild(t)}function Mr(r){return r==="audio"?1:0}function iu(r,e){return`${r?"":" - triggering recovery"}${e?" with HTMLMediaElement Error: "+e.message:""}`}function su(r){return`${r.type}_${r.sn}_${r.level}`}function Or(r,e){const{start:t,end:i}=e;let s=0;for(let n=0;n<r.length;n++){const a=r[n];if(a.start>=i)break;const o=Math.max(t,a.start),l=Math.min(i,a.end);l>o&&(s+=l-o)}return s}function nu(r,e){return e.duration-r<=.05}class Fr{constructor(e){this.hls=null,this.autoLevelCapping=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.observer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.media=null,this.restrictedLevels=[],this.clientRect=null,this.registerListeners()}setStreamController(e){this.streamController=e}destroy(){this.hls&&this.unregisterListener(),(this.timer||this.observer)&&this.stopCapping(),this.media=this.clientRect=this.hls=null,this.streamController=void 0}registerListeners(){const{hls:e}=this;e&&(e.on(E.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(E.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(E.BUFFER_CODECS,this.onBufferCodecs,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this))}unregisterListener(){const{hls:e}=this;e&&(e.off(E.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(E.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(E.BUFFER_CODECS,this.onBufferCodecs,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this))}onFpsDropLevelCapping(e,t){if(!this.hls)return;const i=this.hls.levels[t.droppedLevel];this.isLevelAllowed(i)&&this.restrictedLevels.push({bitrate:i.bitrate,height:i.height,width:i.width})}onMediaAttaching(e,t){const i=t.media;this.clientRect=null,this.hls&&(i instanceof HTMLVideoElement?(this.media=i,this.hls.config.capLevelToPlayerSize&&this.observe()):this.media=null,(this.timer||this.observer)&&this.hls.levels.length>1&&this.detectPlayerSize())}onManifestParsed(e,t){this.restrictedLevels=[],t.video&&this.startCapping(),this.onLevelsUpdated()}onLevelsUpdated(){if(this.hls){if((this.timer||this.observer)&&(se(this.autoLevelCapping)||this.clientRect))this.detectPlayerSize();else if(this.observer===void 0&&this.timer===void 0){const e=this.hls.levels;e.length>1&&e.some(t=>!!t.videoCodec)&&this.startCapping()}}}onBufferCodecs(e,t){t.video&&this.startCapping()}onMediaDetaching(){this.stopCapping(),this.media=null}detectPlayerSize(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0||!this.hls){this.clientRect=null;return}const e=this.hls.levels;if(e.length>1){const t=this.hls,i=this.getMaxLevel(e.length-1);i!==this.autoLevelCapping&&t.logger.log(`Setting autoLevelCapping to ${i}: ${e[i].height}p@${e[i].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),t.autoLevelCapping=i,t.autoLevelEnabled&&t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}else e.length===1&&this.stopCapping()}}getMaxLevel(e){if(!this.hls)return-1;const t=this.hls.levels;if(!t.length)return-1;const i=t.filter((s,n)=>this.isLevelAllowed(s)&&n<=e);return this.observer||(this.clientRect=null),Fr.getMaxLevelByMediaSize(i,this.mediaWidth,this.mediaHeight)}observe(){const e=self.ResizeObserver;e&&(this.observer=new e(t=>{var i;const s=(i=t[0])==null?void 0:i.contentRect;s&&(this.clientRect=s,this.detectPlayerSize())})),this.observer&&this.media&&this.observer.observe(this.media)}startCapping(){var e;this.timer||this.observer||!((e=this.hls)!=null&&e.config.capLevelToPlayerSize)||(self.clearInterval(this.timer),this.timer=void 0,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.observe(),this.observer||(this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3)),this.detectPlayerSize())}stopCapping(){this.restrictedLevels=[],this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0),this.observer&&(this.observer.disconnect(),this.observer=void 0)}getDimensions(){if(this.clientRect)return this.clientRect;const e=this.media,t={width:0,height:0};if(e){const i=e.getBoundingClientRect();t.width=i.width,t.height=i.height,!t.width&&!t.height&&(t.width=i.right-i.left||e.width||0,t.height=i.bottom-i.top||e.height||0)}return this.clientRect=t,t}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let e=1;if(!this.hls)return e;const{ignoreDevicePixelRatio:t,maxDevicePixelRatio:i}=this.hls.config;if(!t)try{e=self.devicePixelRatio}catch{}return Math.min(e,i)}isLevelAllowed(e){return!this.restrictedLevels.some(i=>e.bitrate===i.bitrate&&e.width===i.width&&e.height===i.height)}static getMaxLevelByMediaSize(e,t,i){if(!(e!=null&&e.length))return-1;const s=(o,l)=>l?o.width!==l.width||o.height!==l.height:!0;let n=e.length-1;const a=Math.max(t,i);for(let o=0;o<e.length;o+=1){const l=e[o];if((l.width>=a||l.height>=a)&&s(l,e[o+1])){n=o;break}}return n}}var Lt=class Fa{constructor(e,t){Array.isArray(e)&&(e=e.map(i=>i instanceof Fa?i:new Fa(i))),this.value=e,this.params=t}};const cg="Dict";function hg(r){return Array.isArray(r)?JSON.stringify(r):r instanceof Map?"Map{}":r instanceof Set?"Set{}":typeof r=="object"?JSON.stringify(r):String(r)}function dg(r,e,t,i){return new Error(`failed to ${r} "${hg(e)}" as ${t}`,{cause:i})}const ru="Bare Item",fg="Boolean",gg="Byte Sequence",pg="Decimal",mg="Integer";function Ag(r){return r<-999999999999999||999999999999999<r}const Ig="String",Cg=/[\x00-\x1f\x7f]+/;var au=class{constructor(r){this.description=r}};const yg="Token",vg="Key";function ai(r,e,t){return dg("serialize",r,e,t)}function Eg(r){if(typeof r!="boolean")throw ai(r,fg);return r?"?1":"?0"}function Tg(r){if(ArrayBuffer.isView(r)===!1)throw ai(r,gg);return`:${ch(r)}:`}function ou(r){if(Ag(r))throw ai(r,mg);return r.toString()}function Sg(r){return`@${ou(r.getTime()/1e3)}`}function xg(r){const e=za(r,3);if(Math.floor(Math.abs(e)).toString().length>12)throw ai(r,pg);const t=e.toString();return t.includes(".")?t:`${t}.0`}function bg(r){if(Cg.test(r))throw ai(r,Ig);return`"${r.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function Lg(r){return r.description||r.toString().slice(7,-1)}function lu(r){const e=Lg(r);if(/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(e)===!1)throw ai(e,yg);return e}function Nr(r){switch(typeof r){case"number":if(!se(r))throw ai(r,ru);return Number.isInteger(r)?ou(r):xg(r);case"string":return bg(r);case"symbol":return lu(r);case"boolean":return Eg(r);case"object":if(r instanceof Date)return Sg(r);if(r instanceof Uint8Array)return Tg(r);if(r instanceof au)return lu(r);default:throw ai(r,ru)}}function Br(r){if(/^[a-z*][a-z0-9\-_.*]*$/.test(r)===!1)throw ai(r,vg);return r}function Ur(r){return r==null?"":Object.entries(r).map(([e,t])=>t===!0?`;${Br(e)}`:`;${Br(e)}=${Nr(t)}`).join("")}function uu(r){return r instanceof Lt?`${Nr(r.value)}${Ur(r.params)}`:Nr(r)}function Rg(r){return`(${r.value.map(uu).join(" ")})${Ur(r.params)}`}function Dg(r,e={whitespace:!0}){if(typeof r!="object"||r==null)throw ai(r,cg);const t=r instanceof Map?r.entries():Object.entries(r),i=e!=null&&e.whitespace?" ":"";return Array.from(t).map(([s,n])=>{n instanceof Lt||(n=new Lt(n));let a=Br(s);return n.value===!0?a+=Ur(n.params):(a+="=",Array.isArray(n.value)?a+=Rg(n):a+=uu(n)),a}).join(`,${i}`)}function cu(r,e){return Dg(r,e)}const Pg=["url"],_g=["version","eventTargets","sid","transmissionMode"],kg=["customData","headers"],hu=r=>r instanceof Lt?new Lt(Math.round(r.value),r.params):Math.round(r),$r=r=>Array.isArray(r)?r.map(hu):hu(r),Gr=(r,e)=>Array.isArray(r)?r.map(t=>Gr(t,e)):r instanceof Lt&&typeof r.value=="string"?new Lt(Gr(r.value,e),r.params):(e.baseUrl&&(r=gh(r,fh(e.baseUrl))),e.version===1?encodeURIComponent(r):r),du=r=>r instanceof Lt?new Lt(Math.round(r.value/100)*100,r.params):Math.round(r/100)*100,yn=r=>Array.isArray(r)?r.map(du):du(r),wg={br:$r,d:$r,bl:yn,dl:yn,mtp:yn,nor:(r,e)=>{let t=r;return e.version>=2&&(r instanceof Lt&&typeof r.value=="string"?t=new Lt([r]):typeof r=="string"&&(t=[r])),Gr(t,e)},rtp:yn,tb:$r},Ps=2,fu="bc",Mg="ps",gu="pr",Og="e",pu="t",Fg="c",mu="b",Hr="rr",Au="ce",vn={BITRATE_CHANGE:fu,ERROR:Og,RESPONSE_RECEIVED:Hr,CUSTOM_EVENT:Au},Iu=new Map([[Mg,"sta"],[gu,"pr"],[Fg,"cid"],[mu,"bg"],[fu,"br"]]),Vr="event",Kr="request",Cu=["cen","e","h","ts"],yu=["ab","bg","bl","br","bs","bsa","bsd","bsda","cdn","cid","cs","d","dfa","dl","ec","lab","lb","ltc","msd","mtp","nor","nr","ot","pb","pr","pt","rtp","sf","sid","sn","st","sta","su","tab","tb","tbl","tpb","v"],Ng=/^[a-zA-Z0-9-.]+-[a-zA-Z0-9-.]+$/;function Yr(r){return Ng.test(r)}const Bg=new Set(yu);function vu(r){return Bg.has(r)||Yr(r)}const Eu=["cmsdd","cmsds","rc","smrt","ttfb","ttfbb","ttlb","url"],Ug=new Set(Eu);function Tu(r){return Ug.has(r)}const $g=new Set(Cu);function Gg(r){return vu(r)||Tu(r)||$g.has(r)}const Hg=new Set(["ab","bl","br","bsa","bsd","bsda","lab","lb","mtp","pb","tab","tb","tbl","tpb"]),En=["bl","br","bs","cid","d","dl","mtp","nor","nrr","ot","pr","rtp","sf","sid","st","su","tb","v"],Vg=new Set(En);function Kg(r){return Vg.has(r)||Yr(r)}const Yg=new Set(["ot","sf","st","e","sta"]);function Wg(r){return Yg.has(r)}function jg(r){return typeof r=="number"?se(r):r!=null&&r!==""&&r!==!1}const qg={[Vr]:Gg,[Kr]:vu};function Su(r,e){if(Array.isArray(r)){let t;return e&&(t=r.find(i=>{var s;return((s=i.params)==null?void 0:s.ot)===e})),t||(t=r[0]),Su(t)}return r instanceof Lt?r.value:r}function zg(r){const e={};for(const[i,s]of Object.entries(r)){if(s==null){e[i]=s;continue}if(i==="nor"){const n=(Array.isArray(s)?s:[s])[0];if(n instanceof Lt){var t;e.nor=n.value,(t=n.params)!=null&&t.r&&(e.nrr=n.params.r)}else e.nor=n}else Hg.has(i)?e[i]=Su(s,r.ot):e[i]=s}return e}function xu(r,e={}){const t={};if(r==null||typeof r!="object")return t;const i=e.version||r.v||Ps,s=e.reportingMode||Kr,n=i===1?zg(r):r,a=i===1?Kg:qg[s];let o=Object.keys(n).filter(a);n.e&&n.e!==Hr&&(o=o.filter(m=>!Tu(m)));const l=e.filter;typeof l=="function"&&(o=o.filter(l));const u=s===Vr;if(u){const m=n.e;!o.includes("e")&&m!=null&&o.push("e"),o.includes("ts")||o.push("ts"),!o.includes("cen")&&n.cen!=null&&m===Au&&o.push("cen");const A=m?Iu.get(m):void 0;A&&n[A]!=null&&!o.includes(A)&&o.push(A)}if(o.length===0)return t;i>1&&!o.includes("v")&&o.push("v");const h={version:i,reportingMode:s,baseUrl:e.baseUrl};o.sort();for(const m of o){var d,g;let A=n[m];const C=(d=(g=e.formatters)==null?void 0:g[m])!=null?d:wg[m];if(typeof C=="function"&&(A=C(A,h)),m==="v"){if(i===1)continue;A=i}if(m==="pr"&&A===1&&!(u&&n.e===gu))continue;u&&m==="ts"&&!se(A)&&(A=Date.now());const v=u&&A===!1&&m==="bg"&&n.e===mu;!jg(A)&&!v||(Wg(m)&&typeof A=="string"&&(A=new au(A)),t[m]=A)}return t}const Ai="CMCD-Object",Rt="CMCD-Request",Qi="CMCD-Session",Wt="CMCD-Status",Xg={REQUEST:Rt},Zg={ab:Ai,br:Ai,d:Ai,lab:Ai,lb:Ai,ot:Ai,tab:Ai,tb:Ai,tpb:Ai,bl:Rt,cs:Rt,dfa:Rt,dl:Rt,ltc:Rt,mtp:Rt,nor:Rt,nrr:Rt,pb:Rt,sn:Rt,sta:Rt,su:Rt,tbl:Rt,cid:Qi,msd:Qi,sf:Qi,sid:Qi,st:Qi,v:Qi,bg:Wt,bs:Wt,bsa:Wt,bsd:Wt,bsda:Wt,cdn:Wt,ec:Wt,nr:Wt,pr:Wt,pt:Wt,rtp:Wt};function Qg(r){return Object.keys(r).reduce((e,t)=>{var i;return(i=r[t])==null||i.forEach(s=>e[s]=t),e},{})}function Jg(r,e){const t={};if(!r)return t;const i=Object.keys(r),s=e?Qg(e):{};for(const a of i){var n;const o=Zg[a]||s[a]||Xg.REQUEST,l=(n=t[o])!=null?n:t[o]={};l[a]=r[a]}return t}function ep(r,e){const t={},i=Jg(r,e);for(const[s,n]of Object.entries(i)){const a=cu(n,{whitespace:!1});a&&(t[s]=a)}return t}const bu="CMCD";function Lu(r){return cu(r,{whitespace:!1})}function tp(r,e={}){return r?Lu(xu(r,e)):""}const ip=30,Wr=[...En,...yu,...Eu,...Cu].filter((r,e,t)=>t.indexOf(r)===e),sp="application/cmcd",np=1,mt={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"},jt={STARTING:"s",PLAYING:"p",SEEKING:"k",REBUFFERING:"r",PAUSED:"a",ENDED:"e",FATAL_ERROR:"f",PRELOADING:"d"},jr="query",Ru="headers";function Du(r,e,t){var i;const s=new Set((i=e.enabledKeys)!=null?i:[]);return{version:e.version||Ps,reportingMode:r,filter:n=>s.has(n),baseUrl:t}}function rp(r,e){if(r===e)return!0;if(r.length!==e.length)return!1;for(let t=0;t<r.length;t++){const i=r[t],s=e[t];if(i===s)continue;if(typeof i=="number"||typeof s=="number"||i.value!==s.value)return!1;const n=i.params,a=s.params,o=n&&Object.keys(n)[0],l=a&&Object.keys(a)[0];if(o!==l||o!==void 0&&l!==void 0&&n&&a&&n[o]!==a[l])return!1}return!0}const ap=Object.is,op=r=>r,Pu=Array.from(Iu,([r,e])=>e==="br"?{event:r,field:e,equal:(t,i)=>t===void 0||i===void 0?t===i:rp(t,i),snapshot:t=>t.slice()}:{event:r,field:e,equal:ap,snapshot:op}),lp=new Map(Pu.map(r=>[r.event,r]));function up(r){const{url:e}=r,t=Hs(r,Pg);return fetch(e,t)}function cp(r){const{version:e=Ps,eventTargets:t=[],sid:i=Xa(),transmissionMode:s=jr}=r,n=Hs(r,_g);return Ae(Ae({},n),{},{version:e,transmissionMode:s,sid:i,eventTargets:t.reduce((a,o)=>{var l,u,h;return o!=null&&o.url&&(l=o.events)!=null&&l.length&&a.push({version:o.version||Ps,enabledKeys:((u=o.enabledKeys)==null?void 0:u.slice())||[],url:o.url,events:o.events.slice(),interval:(h=o.interval)!=null?h:ip,batchSize:o.batchSize||1}),a},[])})}var hp=class{constructor(r,e=up){var t;this.timeOrigin=performance.timeOrigin||((t=performance.timing)==null?void 0:t.fetchStart)||Date.now()-performance.now(),this.data={},this.msd=NaN,this.eventTargets=new Map,this.lastEmitted={},this.requestTarget={sn:0,msdSent:!1},this.config=cp(r),this.data={cid:this.config.cid,sid:this.config.sid,v:this.config.version},this.requester=e;for(const i of this.config.eventTargets)this.eventTargets.set(i,{intervalId:void 0,sn:0,msdSent:!1,queue:[]})}start(){this.eventTargets.forEach((r,e)=>{if(this.disarmInterval(r),e.interval===0||!e.events.includes(pu))return;const t=()=>{this.recordTargetEvent(r,e,pu),this.processEventTargets()};r.intervalId=setInterval(t,e.interval*1e3),t()})}stop(r=!1){r&&this.flush(),this.eventTargets.forEach(e=>{this.disarmInterval(e)})}flush(){this.processEventTargets(!0)}update(r){r.sid&&r.sid!==this.data.sid&&this.resetSession(),r.msd&&!isNaN(r.msd)&&(this.msd=r.msd),this.data=Ae(Ae(Ae({},this.data),r),{},{msd:void 0});for(const e of Pu)e.field in r&&!e.equal(this.data[e.field],this.lastEmitted[e.field])&&this.recordEvent(e.event)}recordEvent(r,e={}){const t=lp.get(r);if(t){const i=t.field,s=e[i];s!==void 0&&je(this.data,{[i]:s});const n=this.data[i];if(n===void 0||t.equal(n,this.lastEmitted[i]))return;je(this.lastEmitted,{[i]:t.snapshot(n)})}this.eventTargets.forEach((i,s)=>{this.recordTargetEvent(i,s,r,e)}),this.processEventTargets()}recordTargetEvent(r,e,t,i={}){var s;if(!e.events.includes(t))return;const n=Ae(Ae(Ae({},this.data),i),{},{e:t,ts:(s=i.ts)!=null?s:Date.now(),sn:r.sn++});!isNaN(this.msd)&&!r.msdSent&&(n.msd=this.msd,r.msdSent=!0),r.queue.push(n)}recordResponseReceived(r,e={}){var t,i,s;const{request:n}=r,a=(t=e.url)!=null?t:n?.url;if(!a)return;const o=new URL(a);o.searchParams.delete(bu);const l={url:o.toString(),rc:r.status},u=r.resourceTiming;u&&(u.startTime!=null&&(l.ts=Math.round(this.timeOrigin+u.startTime),u.responseStart!=null&&(l.ttfb=Math.round(u.responseStart-u.startTime))),u.duration!=null&&(l.ttlb=Math.round(u.duration)));const h=(i=(s=n.customData)==null?void 0:s.cmcd)!=null?i:{};this.recordEvent(Hr,Ae(Ae(Ae({},h),l),e))}applyRequestReport(r){var e;return(e=this.createRequestReport(r))!=null?e:r}isRequestReportingEnabled(){var r;return!!((r=this.config.enabledKeys)!=null&&r.length)}createRequestReport(r,e){var t;const{customData:i={},headers:s={}}=r,n=Hs(r,kg),a=Ae(Ae({},n),{},{headers:Ae({},s),customData:Ae(Ae({},i),{},{cmcd:{}})});if(!((t=this.config.enabledKeys)!=null&&t.length)||!a.url)return a;const o=new URL(a.url),l=Ae(Ae(Ae({},this.data),e),{},{sn:this.requestTarget.sn++}),u=Du(Kr,this.config,a.url);!isNaN(this.msd)&&!this.requestTarget.msdSent&&(l.msd=this.msd,this.requestTarget.msdSent=!0);const h=a.customData.cmcd=xu(l,u);switch(this.config.transmissionMode){case jr:const d=Lu(h);d&&(o.searchParams.set(bu,d),a.url=o.toString());break;case Ru:je(a.headers,ep(h,u.customHeaderMap));break}return a}processEventTargets(r=!1){let e=!1;this.eventTargets.forEach((t,i)=>{const{queue:s}=t;if(!s.length||s.length<i.batchSize&&!r)return;const n=r?s.length:i.batchSize,a=s.splice(0,n);this.sendEventReport(i,a).catch(()=>{t.queue.unshift(...a)}),e||(e=s.length>0)}),e&&this.processEventTargets()}async sendEventReport(r,e){const t=Du(Vr,r),{status:i}=await this.requester({url:r.url,method:"POST",headers:{"Content-Type":sp},body:e.map(s=>tp(s,t)).join(`
28
+ `)+`
29
+ `});if(i===410)this.disposeEventTarget(r);else if(i===429||i>499&&i<600)throw new Error(`Event report failed with status ${i}`)}disarmInterval(r){clearInterval(r.intervalId),r.intervalId=void 0}disposeEventTarget(r){const e=this.eventTargets.get(r);e&&(this.disarmInterval(e),this.eventTargets.delete(r))}resetSession(){this.eventTargets.forEach(r=>r.sn=0),this.requestTarget.sn=0,this.lastEmitted={}}};const dp={HLS:"h"},qr={VOD:"v",LIVE:"l",LOW_LATENCY:"ll"};function fp(r,e){return new Lt(r,e)}new Set(En),new Set(Wr);const gp=["includeKeys"];function _u(r){return Object.keys(r).every(Yr)}class pp{constructor(e){this.hls=void 0,this.config=void 0,this.media=void 0,this.initialized=!1,this.starved=!1,this.buffering=!0,this.playerState=void 0,this.reporter=void 0,this.playheadLevel=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0,this.setPlayerState(jt.REBUFFERING)),this.buffering=!0},this.onPlay=()=>{this.initialized||this.setPlayerState(jt.STARTING)},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1,this.setPlayerState(jt.PLAYING)},this.onPause=()=>{this.media&&!this.media.ended&&this.setPlayerState(jt.PAUSED)},this.onSeeking=()=>{this.initialized&&this.setPlayerState(jt.SEEKING)},this.onSeeked=()=>{var s;this.initialized&&(s=this.media)!=null&&s.paused&&this.setPlayerState(jt.PAUSED)},this.onRateChange=()=>{this.reporter&&this.media&&this.reporter.update({pr:this.media.playbackRate})},this.applyPlaylistData=s=>{try{this.apply(s,{ot:mt.MANIFEST,su:!this.initialized})}catch(n){this.hls.logger.warn("Could not generate manifest CMCD data.",n)}},this.applyFragmentData=s=>{try{const{frag:o,part:l}=s,u=this.hls.levels[o.level],h=this.getObjectType(o,u),d={d:(l||o).duration*1e3,ot:h};if(h===mt.VIDEO||h===mt.AUDIO||h===mt.MUXED||h==null&&(o.type==="main"||o.type==="audio")){var n;const m=u.bitrate/1e3;d.br=[m];const{cmcd:A}=this.config,C=(n=A?.rtpSafetyFactor)!=null?n:5;if(d.rtp=Math.round(m*C/100)*100,h===mt.MUXED||h==null&&o.type==="main"){const R=this.getTopBandwidth()/1e3;se(R)&&(d.tb=[R]);const b=this.getLowestBandwidth()/1e3;se(b)&&(d.lb=[b])}const v=this.getBufferLength(o);if(se(v)){var a;d.bl=[v];const R=((a=this.media)==null?void 0:a.playbackRate)||1;d.dl=Math.round(v/R/100)*100}this.playheadLevel&&(d.pb=[this.playheadLevel.bitrate/1e3]);const S=this.hls.maxAutoLevel;if(S>=0){const R=this.hls.levels[S];R&&(d.tpb=[R.bitrate/1e3])}}const g=l?this.getNextPart(l):this.getNextFrag(o);g!=null&&g.url&&g.url!==o.url&&(g.byteRange.length>0?d.nor=[fp(g.url,{r:`${g.byteRange[0]}-${g.byteRange[1]}`})]:d.nor=[g.url]),this.apply(s,d)}catch(o){this.hls.logger.warn("Could not generate segment CMCD data.",o)}},this.recordFragmentResponse=(s,n,a)=>{var o;const{cmcd:l}=this.config,u=l==null||(o=l.eventTargets)==null?void 0:o.some(h=>{var d;return(d=h.events)==null?void 0:d.includes(vn.RESPONSE_RECEIVED)});if(!(!this.reporter||!(a.loading.first>0)||!u))try{this.reporter.recordResponseReceived({request:{url:s},status:n.code,resourceTiming:{startTime:a.loading.start,responseStart:a.loading.first,duration:a.loading.end-a.loading.start,encodedBodySize:a.total}})}catch(h){this.hls.logger.warn("Could not record fragment response CMCD data.",h)}},this.hls=e;const t=this.config=e.config,{cmcd:i}=t;i!=null&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.registerListeners())}createReporter(){var e,t;const{cmcd:i}=this.config;if(i==null)return;const s=i.version||np;if(this.reporter=new hp({sid:i.sessionId||this.hls.sessionId,cid:i.contentId,version:s,transmissionMode:i.useHeaders===!0?Ru:jr,enabledKeys:(e=i.includeKeys)!=null?e:[...s>=Ps?Wr:En],eventTargets:((t=i.eventTargets)!=null?t:[]).map(n=>{let{includeKeys:a}=n,o=Hs(n,gp);return Ae(Ae({},o),{},{enabledKeys:a??Wr})})},i.loader),this.reporter.update({sf:dp.HLS,sta:this.playerState}),i.reporterCallback){const n=this.reporter,a={updateCustomData:o=>{_u(o)&&n.update(o)},recordCustomEvent:(o,l={})=>{_u(l)&&n.recordEvent(vn.CUSTOM_EVENT,Ae({cen:o},l))}};i.reporterCallback(a)}this.reporter.start()}registerListeners(){const e=this.hls;e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(E.MEDIA_DETACHED,this.onMediaDetached,this),e.on(E.MEDIA_ENDED,this.onMediaEnded,this),e.on(E.ERROR,this.onError,this),e.on(E.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(E.LEVEL_SWITCHED,this.onLevelSwitched,this),e.on(E.BUFFER_APPENDED,this.onBufferInfoChange,this),e.on(E.BUFFER_FLUSHED,this.onBufferInfoChange,this)}unregisterListeners(){const e=this.hls;e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(E.MEDIA_DETACHED,this.onMediaDetached,this),e.off(E.MEDIA_ENDED,this.onMediaEnded,this),e.off(E.ERROR,this.onError,this),e.off(E.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(E.LEVEL_SWITCHED,this.onLevelSwitched,this),e.off(E.BUFFER_APPENDED,this.onBufferInfoChange,this),e.off(E.BUFFER_FLUSHED,this.onBufferInfoChange,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.reporter&&(this.reporter.stop(!0),this.reporter=void 0),this.hls=this.config=null,this.onWaiting=this.onPlay=this.onPlaying=this.onPause=null,this.onSeeking=this.onSeeked=this.onRateChange=this.media=null}onMediaAttaching(e,t){const i=this.media=t.media;this.setPlayerState(this.media.autoplay?jt.STARTING:jt.PRELOADING),Ke(i,"waiting",this.onWaiting),Ke(i,"play",this.onPlay),Ke(i,"playing",this.onPlaying),Ke(i,"pause",this.onPause),Ke(i,"seeking",this.onSeeking),Ke(i,"seeked",this.onSeeked),Ke(i,"ratechange",this.onRateChange)}onMediaDetached(){const e=this.media;e&&(Ve(e,"waiting",this.onWaiting),Ve(e,"play",this.onPlay),Ve(e,"playing",this.onPlaying),Ve(e,"pause",this.onPause),Ve(e,"seeking",this.onSeeking),Ve(e,"seeked",this.onSeeked),Ve(e,"ratechange",this.onRateChange),this.media=null)}onMediaEnded(e,t){this.setPlayerState(jt.ENDED)}onManifestLoading(e,t){this.initialized=!1,this.starved=!1,this.buffering=!0,this.reporter&&(this.reporter.stop(!0),this.reporter=void 0),this.createReporter(),this.media||this.setPlayerState(jt.PRELOADING)}onError(e,t){t.fatal&&(this.setPlayerState(jt.FATAL_ERROR),this.reporter&&this.reporter.recordEvent(vn.ERROR,{ec:[t.details]}))}onLevelSwitching(e,t){var i;if(!this.reporter)return;const s={br:[t.bitrate/1e3]},n=(i=t.details)==null?void 0:i.fragments[0];n&&(s.ot=this.getObjectType(n,t)),this.reporter.recordEvent(vn.BITRATE_CHANGE,s)}onLevelSwitched(e,t){const i=this.hls.levels[t.level];i&&(this.playheadLevel=i)}setPlayerState(e){this.playerState=e,this.reporter&&this.reporter.update({sta:e})}getStreamType(){const e=this.hls.latestLevelDetails;if(e)return e.live?e.partList&&e.canBlockReload?qr.LOW_LATENCY:qr.LIVE:qr.VOD}apply(e,t={}){var i;if(!this.reporter)return;this.reporter.update({mtp:[this.hls.bandwidthEstimate/1e3],pr:(i=this.media)==null?void 0:i.playbackRate,st:this.getStreamType()});const s=t.ot===mt.INIT||t.ot===mt.VIDEO||t.ot===mt.MUXED;this.starved&&s&&(t.bs=!0,t.su=!0,this.starved=!1),t.su==null&&(t.su=this.buffering);const n=this.reporter.createRequestReport({url:e.url,headers:e.headers},t);e.url=n.url,e.headers=n.headers}getNextFrag(e){var t;const i=(t=this.hls.levels[e.level])==null?void 0:t.details;if(i){const s=e.sn-i.startSN;return i.fragments[s+1]}}getNextPart(e){var t;const{index:i,fragment:s}=e,n=(t=this.hls.levels[s.level])==null||(t=t.details)==null?void 0:t.partList;if(n){const{sn:a}=s;for(let o=n.length-1;o>=0;o--){const l=n[o];if(l.index===i&&l.fragment.sn===a)return n[o+1]}}}getObjectType(e,t){const{type:i}=e;if(i==="subtitle")return mt.TIMED_TEXT;if(e.sn==="initSegment")return mt.INIT;if(i==="audio")return mt.AUDIO;if(i==="main"){if(e.hasStreams){const s=e.elementaryStreams;if(s.audiovideo)return mt.MUXED;if(s.video)return mt.VIDEO;if(s.audio)return mt.AUDIO}if(t){const{audioCodec:s,videoCodec:n}=t;if(!this.hls.audioTracks.length){if(s&&n)return mt.MUXED;if(s)return mt.AUDIO}if(n)return mt.VIDEO}}}getTopBandwidth(){let e=0;const t=this.hls,i=t.maxAutoLevel,s=i>-1?i+1:t.levels.length;return t.levels.slice(0,s).forEach(a=>{a.bitrate>e&&(e=a.bitrate)}),e>0?e:NaN}getLowestBandwidth(){let e=1/0;const t=this.hls,i=t.maxAutoLevel,s=i>-1?i+1:t.levels.length;return t.levels.slice(0,s).forEach(a=>{a.bitrate<e&&(e=a.bitrate)}),se(e)?e:NaN}getBufferLength(e){if(!this.media)return NaN;const t=e.type==="audio"?this.hls.audioForwardBufferInfo:this.hls.mainForwardBufferInfo;return t?t.len*1e3:NaN}getEventBufferLength(){if(!this.media)return NaN;const e=this.hls.mainForwardBufferInfo,t=this.hls.audioForwardBufferInfo;if(e&&t)return Math.min(e.len,t.len)*1e3;const i=e||t;return i?i.len*1e3:NaN}onBufferInfoChange(e,t){if(!this.reporter)return;const i=this.getEventBufferLength();se(i)&&this.reporter.update({bl:[i]})}createPlaylistLoader(){const{pLoader:e}=this.config,t=this.applyPlaylistData,i=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new i(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,a,o){t(n),this.loader.load(n,a,o)}}}createFragmentLoader(){const{fLoader:e}=this.config,t=this.applyFragmentData,i=this.recordFragmentResponse,s=e||this.config.loader;return class{constructor(a){this.loader=void 0,this.loader=new s(a)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(a,o,l){t(a);const{onSuccess:u}=l;this.loader.load(a,o,Ae(Ae({},l),{},{onSuccess:(h,d,g,m)=>{u(h,d,g,m),i(a.url,h,d)}}))}}}}const mp=3e5;class Ap extends wt{constructor(e){super("content-steering",e.logger),this.hls=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this._pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.registerListeners()}registerListeners(){const e=this.hls;e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(E.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.ERROR,this.onError,this)}unregisterListeners(){const e=this.hls;e&&(e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(E.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.ERROR,this.onError,this))}pathways(){return(this.levels||[]).reduce((e,t)=>(e.indexOf(t.pathwayId)===-1&&e.push(t.pathwayId),e),[])}get pathwayPriority(){return this._pathwayPriority}set pathwayPriority(e){this.updatePathwayPriority(e)}startLoad(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){const e=this.timeToLoad*1e3-(performance.now()-this.updated);if(e>0){this.scheduleRefresh(this.uri,e);return}}this.loadSteeringManifest(this.uri)}}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}clearTimeout(){this.reloadTimer!==-1&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(e){const t=this.levels;t&&(this.levels=t.filter(i=>i!==e))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(e,t){const{contentSteering:i}=t;i!==null&&(this.pathwayId=i.pathwayId,this.uri=i.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){const{errorAction:i}=t;if(i?.action===gt.SendAlternateToPenaltyBox&&i.flags&dt.MoveAllAlternatesMatchingHost){const s=this.levels;let n=this._pathwayPriority,a=this.pathwayId;if(t.context){const{groupId:o,pathwayId:l,type:u}=t.context;o&&s?a=this.getPathwayForGroupId(o,u,a):l&&(a=l)}a in this.penalizedPathways||(this.penalizedPathways[a]=performance.now()),!n&&s&&(n=this.pathways()),n&&n.length>1&&(this.updatePathwayPriority(n),i.resolved=this.pathwayId!==a,!i.resolved&&(t.details!==U.BUFFER_APPEND_ERROR||t.fatal)&&this.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${a} levels: ${s&&s.length} priorities: ${Xe(n)} penalized: ${Xe(this.penalizedPathways)}`))}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){const i=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${i}"`),t=this.getLevelsForPathway(i),this.pathwayId=i}return t.length!==e.length&&this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t}getLevelsForPathway(e){return this.levels===null?[]:this.levels.filter(t=>e===t.pathwayId)}updatePathwayPriority(e){this._pathwayPriority=e;let t;const i=this.penalizedPathways,s=performance.now();Object.keys(i).forEach(n=>{s-i[n]>mp&&delete i[n]});for(let n=0;n<e.length;n++){const a=e[n];if(a in i)continue;if(a===this.pathwayId)return;const o=this.hls.nextLoadLevel,l=this.hls.levels[o];if(t=this.getLevelsForPathway(a),t.length>0){this.log(`Setting Pathway to "${a}"`),this.pathwayId=a,yl(t),this.hls.trigger(E.LEVELS_UPDATED,{levels:t});const u=this.hls.levels[o];l&&u&&this.levels&&(u.attrs["STABLE-VARIANT-ID"]!==l.attrs["STABLE-VARIANT-ID"]&&u.bitrate!==l.bitrate&&this.log(`Unstable Pathways change from bitrate ${l.bitrate} to ${u.bitrate}`),this.hls.nextLoadLevel=o);break}}}getPathwayForGroupId(e,t,i){const s=this.getLevelsForPathway(i).concat(this.levels||[]);for(let n=0;n<s.length;n++)if(t===ke.AUDIO_TRACK&&s[n].hasAudioGroup(e)||t===ke.SUBTITLE_TRACK&&s[n].hasSubtitleGroup(e))return s[n].pathwayId;return i}clonePathways(e){const t=this.levels;if(!t)return;const i={},s={};e.forEach(n=>{const{ID:a,"BASE-ID":o,"URI-REPLACEMENT":l}=n;if(t.some(h=>h.pathwayId===a))return;const u=this.getLevelsForPathway(o).map(h=>{const d=new tt(h.attrs);d["PATHWAY-ID"]=a;const g=d.AUDIO&&`${d.AUDIO}_clone_${a}`,m=d.SUBTITLES&&`${d.SUBTITLES}_clone_${a}`;g&&(i[d.AUDIO]=g,d.AUDIO=g),m&&(s[d.SUBTITLES]=m,d.SUBTITLES=m);const A=wu(h.uri,d["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",l),C=new Is({attrs:d,audioCodec:h.audioCodec,bitrate:h.bitrate,height:h.height,name:h.name,url:A,videoCodec:h.videoCodec,width:h.width});if(h.audioGroups)for(let v=1;v<h.audioGroups.length;v++)C.addGroupId("audio",`${h.audioGroups[v]}_clone_${a}`);if(h.subtitleGroups)for(let v=1;v<h.subtitleGroups.length;v++)C.addGroupId("text",`${h.subtitleGroups[v]}_clone_${a}`);return C});t.push(...u),ku(this.audioTracks,i,l,a),ku(this.subtitleTracks,s,l,a)})}loadSteeringManifest(e){const t=this.hls.config,i=t.loader;this.loader&&this.loader.destroy(),this.loader=new i(t);let s;try{s=new self.URL(e)}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${e}`);return}if(s.protocol!=="data:"){const h=(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate)|0;Ti(s,"_HLS_pathway",this.pathwayId),Ti(s,"_HLS_throughput",""+h)}const n={type:ke.STEERING_MANIFEST,responseType:"json",url:s.href},a=t.steeringManifestLoadPolicy.default,o=a.errorRetry||a.timeoutRetry||{},l={loadPolicy:a,timeout:a.maxLoadTimeMs,maxRetry:o.maxNumRetry||0,retryDelay:o.retryDelayMs||0,maxRetryDelay:o.maxRetryDelayMs||0},u={onSuccess:(h,d,g,m)=>{this.log(`Loaded steering manifest: "${s}"`);const A=h.data;if(A?.VERSION!==1){this.log(`Steering VERSION ${A.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=A.TTL;const{"RELOAD-URI":C,"PATHWAY-CLONES":v,"PATHWAY-PRIORITY":S}=A;if(C)try{this.uri=new self.URL(C,s).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${C}`);return}this.scheduleRefresh(this.uri||g.url),v&&this.clonePathways(v);const R={steeringManifest:A,url:s.toString()};this.hls.trigger(E.STEERING_MANIFEST_LOADED,R),S&&this.updatePathwayPriority(S)},onError:(h,d,g,m)=>{if(this.log(`Error loading steering manifest: ${h.code} ${h.text} (${d.url})`),this.stopLoad(),h.code===410){this.enabled=!1,this.log(`Steering manifest ${d.url} no longer available`);return}let A=this.timeToLoad*1e3;if(h.code===429){const C=this.loader;if(typeof C?.getResponseHeader=="function"){const v=C.getResponseHeader("Retry-After");v&&(A=parseFloat(v)*1e3)}this.log(`Steering manifest ${d.url} rate limited`);return}this.scheduleRefresh(this.uri||d.url,A)},onTimeout:(h,d,g)=>{this.log(`Timeout loading steering manifest (${d.url})`),this.scheduleRefresh(this.uri||d.url)}};this.log(`Requesting steering manifest: ${s}`),this.loader.load(n,l,u)}scheduleRefresh(e,t=this.timeToLoad*1e3){this.clearTimeout(),this.reloadTimer=self.setTimeout(()=>{var i;const s=(i=this.hls)==null?void 0:i.media;if(s&&!s.ended){this.loadSteeringManifest(e);return}this.scheduleRefresh(e,this.timeToLoad*1e3)},t)}}function ku(r,e,t,i){r&&Object.keys(e).forEach(s=>{const n=r.filter(a=>a.groupId===s).map(a=>{const o=je({},a);return o.details=void 0,o.attrs=new tt(o.attrs),o.url=o.attrs.URI=wu(a.url,a.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",t),o.groupId=o.attrs["GROUP-ID"]=e[s],o.attrs["PATHWAY-ID"]=i,o});r.push(...n)})}function wu(r,e,t,i){if(e){const{[t]:o}=i;if(o){const l=o[e];if(l)return l}}const{HOST:s,PARAMS:n}=i,a=new self.URL(r);return s&&(a.hostname=s),n&&Object.keys(n).sort().forEach(o=>{o&&Ti(a,o,n[o])}),a.href}class Ip{constructor(){this.status="initialized",this.requestErrors=[],this.licenseXhr=void 0,this.onmessage=void 0,this.onkeystatuseschange=void 0,this.emitter=new Sr,this.error=void 0,this.ok=void 0}get errored(){return this.error}set errored(e){this.error=e,this.emitter.eventNames().length&&this.emitter.emit("error",e)}get hasListeners(){return this.emitter.eventNames().length>0}get resolved(){return this.ok}resolve(){this.ok=!0,this.emitter.emit("resolved")}get useable(){return this.ok?Promise.resolve():this.error?Promise.reject(this.error):new Promise((e,t)=>{this.emitter.on("error",t),this.emitter.on("resolved",e)})}reset(){this.emitter.removeAllListeners();const e=this.licenseXhr;e&&(e.readyState!==XMLHttpRequest.DONE&&e.abort(),this.licenseXhr=void 0),this.onmessage=this.onkeystatuseschange=void 0}}class qt extends Error{constructor(e,t){super(t),this.data=void 0,e.error||(e.error=new Error(t)),this.data=e,e.err=e.error}}class Ji extends wt{constructor(e){super("eme",e.logger),this.hls=void 0,this.config=void 0,this.media=null,this.mediaResolved=void 0,this.keyFormatPromise=null,this.keySystemAccessPromises={},this.sessionSetupByUri={},this.mediaKeySessions=[],this.activeKeys={},this.mediaKeys=null,this.setMediaKeysQueue=Ji.CDMCleanupPromise?[Ji.CDMCleanupPromise]:[],this.onMediaEncrypted=t=>{const{initDataType:i,initData:s}=t,n=`"${t.type}" event: init data type: "${i}"`;if(this.log(n),s!==null){if(!this.keyFormatPromise){let a=Object.keys(this.keySystemAccessPromises);a.length||(a=vs(this.config));const o=a.map(Ar).filter(l=>!!l);this.keyFormatPromise=this.getKeyFormatPromise(o)}this.keyFormatPromise.then(a=>{let o;const l=un(a),u=this.activeLevelKeys();if(l===Je.FAIRPLAY&&i==="sinf")try{const A=Yt(new Uint8Array(s)),C=Jn(JSON.parse(A).sinf),v=uo(C);if(!v)throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");o=new Uint8Array(v.subarray(8,24))}catch(A){this.warn(`${n} Failed to parse sinf: ${A}`);return}else if(l===Je.PLAYREADY)o=Ir(new Uint8Array(s));else if(l===Je.WIDEVINE){const A=po(s).filter(C=>C.systemId===el.WIDEVINE);if(A.length){var h;const C=A[0];o=(h=C.kids)!=null&&h.length?C.kids[0]:null}}let d;if(o){const A=ut(o);for(let C=0;C<u.length;C++){const v=u[C];if(v.keyId&&(on(o,v.keyId)||v.uri.replace(/-/g,"").indexOf(A)!==-1)){v.pssh||(v.scheme=i,v.pssh=new Uint8Array(s),v.keyId=o,gi.setKeyIdForUri(v.uri,o)),d=this.getSessionForKey(v,"encrypted-event-key-match");break}}}if(!d){if(u.length){var g,m;return(g=u[0]).scheme||(g.scheme=i),(m=u[0]).pssh||(m.pssh=new Uint8Array(s)),this.getSessionForKey(u[0],"encrypted-event-no-match")}if(o)throw new Error(`Key ID ${ut(o)} not encountered in playlist`);this.log(`Ignoring "${t.type}" event - could not determine keyId`)}return d}).catch(a=>this.handleError(a))}},this.onWaitingForKey=t=>{this.log(`"${t.type}" event`)},this.hls=e,this.config=e.config,this.registerListeners()}destroy(){this.onDestroying(),this.onMediaDetached();const e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.config=null,this.onMediaEncrypted=this.onWaitingForKey=null}registerListeners(){const{hls:e}=this;e&&(e.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(E.MEDIA_DETACHED,this.onMediaDetached,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(E.DESTROYING,this.onDestroying,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(E.MEDIA_DETACHED,this.onMediaDetached,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(E.DESTROYING,this.onDestroying,this))}attemptKeySystemAccess(e){if(!this.hls)return Promise.reject(new Error("destroyed"));const t=this.hls.levels,i=(a,o,l)=>!!a&&l.indexOf(a)===o,s=t.map(a=>a.audioCodec).filter(i),n=t.map(a=>a.videoCodec).filter(i);return s.length+n.length===0&&n.push("avc1.42e01e"),new Promise((a,o)=>{const l=u=>{const h=u.shift();this.getMediaKeysPromise(h,s,n).then(d=>a({keySystem:h,mediaKeys:d})).catch(d=>{u.length?l(u):d instanceof qt?o(d):o(new qt({type:me.KEY_SYSTEM_ERROR,details:U.KEY_SYSTEM_NO_ACCESS,error:d,fatal:!0},d.message))})};l(e)})}requestMediaKeySystemAccess(e,t){const{requestMediaKeySystemAccessFunc:i}=this.config;if(typeof i!="function"){let s=`Configured requestMediaKeySystemAccess is not a function ${i}`;return tl===null&&self.location.protocol==="http:"&&(s=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(s))}return i(e,t)}getMediaKeysPromise(e,t,i){var s;const n=Ud(e,t,i,this.config.drmSystemOptions||{});let a=this.keySystemAccessPromises[e],o=(s=a)==null?void 0:s.keySystemAccess;if(!o){this.log(`Requesting encrypted media "${e}" key-system access with config: ${Xe(n)}`),o=this.requestMediaKeySystemAccess(e,n);const l=a=this.keySystemAccessPromises[e]={keySystemAccess:o};return o.catch(u=>{this.log(`Failed to obtain access to key-system "${e}": ${u}`)}),o.then(u=>{this.throwIfDestroyed(),this.log(`Access for key-system "${u.keySystem}" obtained`);const h=this.fetchServerCertificate(e);this.log(`Create media-keys for "${e}"`);const d=l.mediaKeys=u.createMediaKeys().then(g=>(this.log(`Media-keys created for "${e}"`),l.hasMediaKeys=!0,h.then(m=>m?this.setMediaKeysServerCertificate(g,e,m):g)));return d.catch(g=>{this.error(`Failed to create media-keys for "${e}"}: ${g}`)}),d})}return o.then(()=>a.mediaKeys)}getMediaKeySessionContext(e,t,i,s){const{mediaKeySessions:n}=this,a=` key-session "${e}" keyId: ${ut(i.keyId||[])} keyUri: ${i.uri} for "${s}"`;for(let u=0;u<n.length;u++){const h=n[u];if(!h.initialized&&h.createdFor.levelKey.uri===i.uri)return this.log(`Reusing${a}`),h}this.log(`Creating${a}`);const o=t.createSession(),l={keySystem:e,mediaKeys:t,mediaKeysSession:o,keyRequests:{},keyStatuses:{},createdFor:{levelKey:i,reason:s},initialized:!1};return n.push(l),l}resetMediaKeys(){var e;const t=(e=this.mediaKeySessions[0])==null?void 0:e.keySystem,i=this.keySystemAccessPromises[t];i&&(this.log("reset mediaKeys"),this.mediaKeys=null,i.hasMediaKeys=!1,delete i.mediaKeys,delete this.keySystemAccessPromises[t])}updateKeySession(e,t,i){const s=e.mediaKeysSession;return this.log(`Updating key-session "${s.sessionId}" for keyId ${ut(t.keyId||[])}
30
+ } (data length: ${i.byteLength})`),s.update(i)}getSelectedKeySystemFormats(){return Object.keys(this.keySystemAccessPromises).map(e=>({keySystem:e,hasMediaKeys:this.keySystemAccessPromises[e].hasMediaKeys})).filter(({hasMediaKeys:e})=>!!e).map(({keySystem:e})=>Ar(e)).filter(e=>!!e)}getKeySystemAccess(e){return this.getKeySystemSelectionPromise(e).then(({keySystem:t,mediaKeys:i})=>this.attemptSetMediaKeys(t,i))}selectKeySystem(e){return this.getKeySystemSelectionPromise(e).then(({keySystem:t})=>{const i=Ar(t);if(!i)throw new Error(`Unable to find format for key-system "${t}"`);return i})}selectKeySystemFormat(e){const t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${e.sn} ${e.type}: ${e.level}) key formats ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}getKeyFormatPromise(e){const t=vs(this.config),i=e.map(un).filter(s=>!!s&&t.indexOf(s)!==-1);return this.selectKeySystem(i)}loadClear(e,t,i){if(this.config.emeEnabled&&!this.getSelectedKeySystemFormats().length){if(t.length)for(let s=0,n=t.length;s<n;s++){const a=t[s];if(e.cc<=a.cc&&(!st(e)||!st(a)||e.sn<a.sn)||!i&&s==n-1)return this.selectKeySystemFormat(a).then(o=>{if(!this.hls)return;a.setKeyFormat(o);const l=un(o);if(l)return this.getKeySystemAccess([l])})}if(this.config.requireKeySystemAccessOnStart){const s=vs(this.config);if(s.length)return this.getKeySystemAccess(s)}}return null}getKeyStatus(e){const{mediaKeySessions:t}=this;for(let i=0;i<t.length;i++){const s=zr(e,t[i]);if(s)return s}}loadKey(e){const t=e.decryptdata,i=this.getKeyStatus(t);if(i==="internal-error"){const o=Mu(i,t);return o.data.frag=e,this.error(`${o.message} (${ut(t.keyId||[])})`),Promise.reject(o)}const s=e.type,n=this.activeKeys,a=n[s];a&&!t.matches(a.decryptdata)&&(n.previous||(n.previous=[]),n.previous.push(a),delete n[s]),n[s]||(n[s]=e);for(let o=this.mediaKeySessions.length;o--;){const l=this.mediaKeySessions[o];if(t.keyId&&l.keyStatuses[ut(t.keyId)]==="expired")return this.renewKeySession(t,l)}return this.updateUsablePromise(t,"playlist-key",e)}renewKeySession(e,t){return this.resetMediaKeys(),this.removeSession(t).then(()=>(this.throwIfDestroyed(),this.updateUsablePromise(e,"expired")))}updateUsablePromise(e,t,i){const s=this.getSessionForKey(e,t);return s.catch(n=>this.handleError(n,i)),s.then(n=>e)}getSessionForKey(e,t){const i=this.findContextForKey(e);if(i!==void 0)return Promise.resolve(i);const s=e.uri,n=this.sessionSetupByUri[s];let a;n===void 0?a=this.resolveSessionForKey(e,t):a=n.catch(()=>{}).then(()=>(this.throwIfDestroyed(),this.resolveSessionForKey(e,t))),this.sessionSetupByUri[s]=a;const o=()=>{this.sessionSetupByUri[s]===a&&delete this.sessionSetupByUri[s]};return a.then(o,o),a}findContextForKey(e){const{mediaKeySessions:t}=this;for(let i=t.length;i--;){const s=t[i];if(zr(e,s))return s}}resolveSessionForKey(e,t){return this.getKeySystemForKeyPromise(e).then(({keySystem:i,mediaKeys:s})=>{this.throwIfDestroyed();for(let n=this.mediaKeySessions.length;n--;){const a=this.mediaKeySessions[n];if(zr(e,a))return a;const o=this.getUsableKeyPromise(a,e,t);if(o)return o}return this.attemptSetMediaKeys(i,s).then(()=>(this.throwIfDestroyed(),this.getMediaKeySessionContext(i,s,e,t))).then(n=>{this.throwIfDestroyed();const a=e.scheme||"cenc",o=e.pssh?e.pssh.buffer:null;return this.generateRequestWithPreferredKeySession(n,e,a,o,t)})})}getUsableKeyPromise(e,t,i){const s=e.keyRequests[t.uri];if(s)return this.log(`Waiting for usable key (${i} keyId: ${vp(t)} format: "${t.keyFormat}" URI: ${t.uri})`),s.useable.then(()=>e)}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e,t){if(this.hls)if(e instanceof qt){t&&(e.data.frag=t);const i=e.data.decryptdata;this.error(`${e.message}${i?` (${ut(i.keyId||[])})`:""}`),this.hls.trigger(E.ERROR,e.data)}else this.error(e.message),this.hls.trigger(E.ERROR,{type:me.KEY_SYSTEM_ERROR,details:U.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0})}getKeySystemForKeyPromise(e){const t=un(e.keyFormat),i=t?[t]:vs(this.config);return this.attemptKeySystemAccess(i)}getKeySystemSelectionPromise(e){if(e.length||(e=vs(this.config)),e.length===0)throw new qt({type:me.KEY_SYSTEM_ERROR,details:U.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${Xe({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}activeLevelKeys(){const e=this.activeKeys,t=(e.previous||[]).map(i=>i.decryptdata);return e.audio&&t.unshift(e.audio.decryptdata),e.main&&t.unshift(e.main.decryptdata),t}attemptSetMediaKeys(e,t){if(this.mediaResolved=void 0,this.mediaKeys===t)return Promise.resolve();const i=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);const s=Promise.all(i).then(()=>this.media?this.media.setMediaKeys(t):new Promise((n,a)=>{this.mediaResolved=()=>{if(this.mediaResolved=void 0,!this.media)return a(new Error("Attempted to set mediaKeys without media element attached"));this.mediaKeys=t,this.media.setMediaKeys(t).then(n).catch(a)}}));return this.mediaKeys=t,this.setMediaKeysQueue.push(s),s.then(()=>{this.log(`Media-keys set for "${e}"`),i.push(s),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(n=>i.indexOf(n)===-1)})}filterInitData(e,t,i,s,n){var a;const o=(a=this.config.drmSystems)==null||(a=a[e.keySystem])==null?void 0:a.generateRequest;if(o)try{const u=o.call(this.hls,i,s,je({},e,{decryptdata:t,reason:n}),n);if(!u)throw new Error("Invalid response from configured generateRequest filter");t.scheme=u.initDataType?u.initDataType:"cenc";const h=u.initData?u.initData:null;return t.pssh=h?new Uint8Array(h):null,u}catch(u){var l;if(this.warn(u.message),(l=this.hls)!=null&&l.config.debug)throw u}return{initDataType:i,initData:s}}generateRequestWithPreferredKeySession(e,t,i,s,n){const a=this.getUsableKeyPromise(e,t,n);if(a)return a;const o=this.filterInitData(e,t,i,s,n);if(o&&(s=o.initData?o.initData:null,i=o.initDataType),s===null)return n.startsWith("encrypted-event")?Promise.reject(new Error(`missing initialization data for "${n}"`)):(this.log(`Skipping key-session request for "${n}" (no initData)`),Promise.resolve(e));const l=t.uri,u=new Ip;e.keyRequests[l]=u;const h=g=>{const m=e.mediaKeysSession;if(!m){const v=new Error("invalid state");u.errored=v;return}const{messageType:A,message:C}=g;u.status=A,this.log(`"${A}" message event for session "${m.sessionId}" message size: ${C.byteLength}`),A==="license-request"||A==="license-renewal"?this.renewLicense(e,t,C).catch(v=>{u.errored=v,u.hasListeners||this.handleError(v),this.removeSession(e)}):A==="license-release"?e.keySystem===Je.FAIRPLAY&&this.updateKeySession(e,t,mr("acknowledged")).then(()=>this.removeSession(e)).catch(v=>this.handleError(v)):this.warn(`unhandled media key message type "${A}"`)};return u.onmessage=h,Ke(e.mediaKeysSession,"message",h),this.generateRequest(e,t,i,s,n,!1)}generateRequest(e,t,i,s,n,a){if(a){const m=this.filterInitData(e,t,i,s,n);m&&(s=m.initData?m.initData:s,i=m.initDataType)}const o=t.uri,l=e.keyRequests[o],u=ut(t.keyId||[]),h=m=>{let A;m.startsWith("usable")?l.resolve():m==="internal-error"||m==="output-restricted"||m==="output-downscaled"?A=Mu(m,t):m==="expired"?A=new Error(`key expired (keyId: ${u})`):m==="released"?A=new Error("key released"):m==="status-pending"||this.warn(`unhandled key status change "${m}" (keyId: ${u})`),A&&(l.errored=A,l.hasListeners||this.handleError(A))},d=m=>{if(!e.mediaKeysSession){const _=new Error("invalid state");l.errored=_;return}const C=e.keyStatuses=this.getKeyStatuses(e);if(!Object.keys(C).some(_=>C[_]!=="status-pending"))return;const S=this.activeLevelKeys();for(let _=0;_<S.length;_++){const M=ut(S[_].keyId||[]);if(C[M]==="expired"){var R;this.log(`Expired key ${Xe(C)} in key-session "${(R=e.mediaKeysSession)==null?void 0:R.sessionId}"`),this.renewKeySession(t,e).catch(p=>this.handleError(p));break}}let b=C[u];if(b)h(b);else{var D;e.keyStatusTimeouts||(e.keyStatusTimeouts={}),(D=e.keyStatusTimeouts)[u]||(D[u]=self.setTimeout(()=>{var M;if(!e.mediaKeysSession)return;const p=this.getKeyStatus(t);if(p&&p!=="status-pending"){var $;return this.log(`No status for keyId ${u} in key-session "${($=e.mediaKeysSession)==null?void 0:$.sessionId}". Using session key-status ${p} from other session.`),h(p)}this.log(`key status for ${u} in key-session "${(M=e.mediaKeysSession)==null?void 0:M.sessionId}" timed out after 1000ms`),b="internal-error",h(b)},1e3)),this.log(`No status for keyId ${u} (${Xe(C)}).`)}};l.onkeystatuseschange=d,Ke(e.mediaKeysSession,"keystatuseschange",d);const g=l.useable;return this.log(`Generating key-session request for "${n}" keyId: ${u} URI: ${o} (init data type: ${i} length: ${s.byteLength})`),l.status="started",e.initialized=!0,e.mediaKeysSession.generateRequest(i,s).then(()=>{var m;l.status="generated",this.log(`Request generated for key-session "${(m=e.mediaKeysSession)==null?void 0:m.sessionId}" keyId: ${u} URI: ${o}`)}).catch(m=>{throw this.log(`mediaKeysSession.generateRequest failed: ${m}`),new qt({type:me.KEY_SYSTEM_ERROR,details:U.KEY_SYSTEM_NO_SESSION,error:m,decryptdata:t,fatal:!1},`Error generating key-session request: ${m}`)}).then(()=>g).catch(m=>{var A;this.log(`mediaKeysSession.generateRequest failed: ${m}`);const C=(A=m.data)==null?void 0:A.details;return(C===U.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED||C===U.KEY_SYSTEM_STATUS_INTERNAL_ERROR)&&Object.keys(e.keyStatuses).some(v=>e.keyStatuses[v]==="usable")?(this.handleError(m),e):this.removeSession(e).then(()=>{throw m})}).then(()=>e)}getKeyStatuses(e){const t={},i=e.mediaKeysSession.sessionId;return e.mediaKeysSession.keyStatuses.forEach((s,n)=>{if(typeof n=="string"&&typeof s=="object"){const l=n;n=s,s=l}const a="buffer"in n?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):new Uint8Array(n);if(e.keySystem===Je.PLAYREADY&&a.length===16){const l=ut(a);t[l]=s,Qo(a)}const o=ut(a);this.log(`key status change "${s}" for keyStatuses keyId: ${o} key-session "${i}"`),t[o]=s}),t}fetchServerCertificate(e){const t=this.config,i=t.loader,s=new i(t),n=yp(e,t);return n?(this.log(`Fetching server certificate for "${e}"`),new Promise((a,o)=>{const l={type:ke.SERVER_CERTIFICATE,responseType:"arraybuffer",url:n},u=t.certLoadPolicy.default,h={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},d={onSuccess:(g,m,A,C)=>{a(g.data)},onError:(g,m,A,C)=>{o(new qt({type:me.KEY_SYSTEM_ERROR,details:U.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:A,response:Ae({url:l.url,data:void 0},g)},`"${e}" certificate request failed (${n}). Status: ${g.code} (${g.text})`))},onTimeout:(g,m,A)=>{o(new qt({type:me.KEY_SYSTEM_ERROR,details:U.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:A,response:{url:l.url,data:void 0}},`"${e}" certificate request timed out (${n})`))},onAbort:(g,m,A)=>{o(new Error("aborted"))}};s.load(l,h,d)})):(this.log(`No Server Certificate in config.drmSystems["${e}"]`),Promise.resolve())}setMediaKeysServerCertificate(e,t,i){return new Promise((s,n)=>{e.setServerCertificate(i).then(a=>{this.log(`setServerCertificate ${a?"success":"not supported by CDM"} (${i.byteLength}) on "${t}"`),s(e)}).catch(a=>{n(new qt({type:me.KEY_SYSTEM_ERROR,details:U.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:a,fatal:!0},a.message))})})}renewLicense(e,t,i){return this.requestLicense(e,t,new Uint8Array(i)).then(s=>this.updateKeySession(e,t,new Uint8Array(s)).catch(n=>{throw new qt({type:me.KEY_SYSTEM_ERROR,details:U.KEY_SYSTEM_SESSION_UPDATE_FAILED,decryptdata:t,error:n,fatal:!1},n.message)}))}unpackPlayReadyKeyMessage(e,t){const i=Yt(new Uint16Array(t.buffer));if(!i.includes("PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;const s=new DOMParser().parseFromString(i,"application/xml"),n=s.querySelectorAll("HttpHeader");if(n.length>0){let h;for(let d=0,g=n.length;d<g;d++){var a,o;h=n[d];const m=(a=h.querySelector("name"))==null?void 0:a.textContent,A=(o=h.querySelector("value"))==null?void 0:o.textContent;m&&A&&e.setRequestHeader(m,A)}}const l=s.querySelector("Challenge"),u=l?.textContent;if(!u)throw new Error("Cannot find <Challenge> in key message");return mr(atob(u))}setupLicenseXHR(e,t,i,s,n){const a=this.config.licenseXhrSetup;return a?Promise.resolve().then(()=>(this.throwIfDestroyed(),a.call(this.hls,e,t,Ae(Ae({},i),{},{decryptdata:s}),n))).catch(o=>{if(!i.mediaKeysSession)throw o;return e.open("POST",t,!0),a.call(this.hls,e,t,Ae(Ae({},i),{},{decryptdata:s}),n)}).then(o=>(e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:o||n})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:n}))}requestLicense(e,t,i){return new Promise((s,n)=>{const a=Cp(e.keySystem,this.config);if(!a)return n(new Error(`no license server URL configured for key-system "${e.keySystem}"`));const o=e.keyRequests[t.uri];if(!o)return n(new Error("License emitter removed"));this.log(`Sending license request to URL: ${a}`);const l=this.config.keyLoadPolicy.default,u=new XMLHttpRequest;u.responseType="arraybuffer",u.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return n(new Error("invalid state"));if(u.readyState===4)if(u.status===200){o.requestErrors=[];let h=u.response;this.log(`License received ${h instanceof ArrayBuffer?h.byteLength:h}`);const d=this.config.licenseResponseCallback;if(d)try{h=d.call(this.hls,u,a,Ae(Ae({},e),{},{decryptdata:t}))}catch(g){this.error(g)}s(h)}else{const h=l.errorRetry,d=h?h.maxNumRetry:0;if(o.requestErrors.push({status:u.status,message:u.statusText}),o.requestErrors.length>d||u.status>=400&&u.status<500)n(new qt({type:me.KEY_SYSTEM_ERROR,details:U.KEY_SYSTEM_LICENSE_REQUEST_FAILED,decryptdata:t,fatal:!0,networkDetails:u,response:{url:a,data:void 0,code:u.status,text:u.statusText}},`License Request XHR failed (${a}). Status: ${u.status} (${u.statusText})`));else{const g=d-o.requestErrors.length;this.warn(`Retrying license request, ${g} attempts left`),this.requestLicense(e,t,i).then(s,n)}}},o.licenseXhr&&o.licenseXhr.readyState!==XMLHttpRequest.DONE&&o.licenseXhr.abort(),o.licenseXhr=u,this.setupLicenseXHR(u,a,e,t,i).then(({xhr:h,licenseChallenge:d})=>{e.keySystem==Je.PLAYREADY&&(d=this.unpackPlayReadyKeyMessage(h,d)),h.send(d)}).catch(n)})}onDestroying(){this.unregisterListeners(),this._clear()}onMediaAttached(e,t){if(!this.config.emeEnabled)return;const i=t.media;this.media=i,Ke(i,"encrypted",this.onMediaEncrypted),Ke(i,"waitingforkey",this.onWaitingForKey);const s=this.mediaResolved;s?s():this.mediaKeys=i.mediaKeys}onMediaDetached(){const e=this.media;e&&(Ve(e,"encrypted",this.onMediaEncrypted),Ve(e,"waitingforkey",this.onWaitingForKey),this.media=null,this.mediaKeys=null)}_clear(){var e;this.keyFormatPromise=null,this.keySystemAccessPromises={},this.activeKeys={},this.sessionSetupByUri={};const t=this.mediaResolved;if(t&&t(),!this.mediaKeys&&!this.mediaKeySessions.length)return;const i=this.media,s=this.mediaKeySessions.slice();this.mediaKeySessions=[],this.mediaKeys=null,gi.clearKeyUriToKeyIdMap();const n=s.length;Ji.CDMCleanupPromise=Promise.all(s.map(a=>this.removeSession(a)).concat((i==null||(e=i.setMediaKeys(null))==null?void 0:e.catch(a=>{this.log(`Could not clear media keys: ${a}`),this.hls&&this.hls.trigger(E.ERROR,{type:me.OTHER_ERROR,details:U.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR,fatal:!1,error:new Error(`Could not clear media keys: ${a}`)})}))||Promise.resolve())).catch(a=>{this.log(`Could not close sessions and clear media keys: ${a}`),this.hls&&this.hls.trigger(E.ERROR,{type:me.OTHER_ERROR,details:U.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close sessions and clear media keys: ${a}`)})}).then(()=>{n&&this.log("finished closing key sessions and clearing media keys")})}onManifestLoading(){this._clear(),this.keyFormatPromise=null}onManifestLoaded(e,{sessionKeys:t}){if(!(!t||!this.config.emeEnabled)&&!this.keyFormatPromise){const i=t.reduce((s,n)=>(s.indexOf(n.keyFormat)===-1&&s.push(n.keyFormat),s),[]);this.log(`Selecting key-system from session-keys ${i.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(i),this.keyFormatPromise.catch(()=>{})}}removeSession(e){const{mediaKeysSession:t}=e;if(t){this.log(`Remove licenses and keys and close session "${t.sessionId}"`),Object.keys(e.keyRequests).forEach(o=>{const l=e.keyRequests[o];l.onmessage&&t.removeEventListener("message",l.onmessage),l.onkeystatuseschange&&t.removeEventListener("keystatuseschange",l.onkeystatuseschange),l.reset(),e.keyRequests[o]=void 0}),e.mediaKeysSession=void 0;const i=this.mediaKeySessions.indexOf(e);i>-1&&this.mediaKeySessions.splice(i,1);const{keyStatusTimeouts:s}=e;s&&Object.keys(s).forEach(o=>self.clearTimeout(s[o]));const{drmSystemOptions:n}=this.config;return(Gd(n)?new Promise((o,l)=>{self.setTimeout(()=>l(new Error("MediaKeySession.remove() timeout")),8e3),t.remove().then(o).catch(l)}):Promise.resolve()).catch(o=>{this.log(`Could not remove session: ${o}`),this.hls&&this.hls.trigger(E.ERROR,{type:me.OTHER_ERROR,details:U.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR,fatal:!1,error:new Error(`Could not remove session: ${o}`)})}).then(()=>t.close()).then(()=>t.closed).catch(o=>{this.log(`Could not close session: ${o}`),this.hls&&this.hls.trigger(E.ERROR,{type:me.OTHER_ERROR,details:U.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close session: ${o}`)})})}return Promise.resolve()}}Ji.CDMCleanupPromise=void 0;function Cp(r,e){const{drmSystems:t,widevineLicenseUrl:i}=e,s=t?.[r];if(s)return s.licenseUrl;if(r===Je.WIDEVINE&&i)return i}function yp(r,e){const{drmSystems:t}=e,i=t?.[r];if(i)return i.serverCertificateUrl}function vp(r){if(r.keyFormat===pt.FAIRPLAY)return r.uri;if(r.keyId===null)throw new Error("keyId is null");return ut(r.keyId)}function zr(r,e){const t=r.keyId,i=e.mediaKeysSession;if(t&&i){const s=e.mediaKeysSession.keyStatuses;if(s.size)return s.has(t)?s.get(t):e.keyStatuses[ut(t)]}}function Mu(r,e){const t=r==="output-restricted",i=t?U.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:U.KEY_SYSTEM_STATUS_INTERNAL_ERROR;return new qt({type:me.KEY_SYSTEM_ERROR,details:i,fatal:!1,decryptdata:e},t?"HDCP level output restricted":`key status changed to "${r}"`)}class Ep{constructor(e){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=e,this.registerListeners()}setStreamController(e){this.streamController=e}registerListeners(){this.hls.on(E.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(E.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListeners(){this.hls.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(E.MEDIA_DETACHING,this.onMediaDetaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){const i=this.hls.config;if(i.capLevelOnFPSDrop){const s=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=s,s&&typeof s.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),i.fpsDroppedMonitoringPeriod)}}onMediaDetaching(){this.media=null}checkFPS(e,t,i){const s=performance.now();if(t){if(this.lastTime){const n=s-this.lastTime,a=i-this.lastDroppedFrames,o=t-this.lastDecodedFrames,l=1e3*a/n,u=this.hls;if(u.trigger(E.FPS_DROP,{currentDropped:a,currentDecoded:o,totalDroppedFrames:i}),l>0&&a>u.config.fpsDroppedMonitoringThreshold*o){let h=u.currentLevel;u.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+h),h>0&&(u.autoLevelCapping===-1||u.autoLevelCapping>=h)&&(h=h-1,u.trigger(E.FPS_DROP_LEVEL_CAPPING,{level:h,droppedLevel:u.currentLevel}),u.autoLevelCapping=h,this.streamController.nextLevelSwitch())}}this.lastTime=s,this.lastDroppedFrames=i,this.lastDecodedFrames=t}}checkFPSInterval(){const e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){const t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}}var Xr=(function(){if(ln!=null&&ln.VTTCue)return self.VTTCue;const r=["","lr","rl"],e=["start","middle","end","left","right"];function t(o,l){if(typeof l!="string"||!Array.isArray(o))return!1;const u=l.toLowerCase();return~o.indexOf(u)?u:!1}function i(o){return t(r,o)}function s(o){return t(e,o)}function n(o,...l){let u=1;for(;u<arguments.length;u++){const h=arguments[u];for(const d in h)o[d]=h[d]}return o}function a(o,l,u){const h=this,d={enumerable:!0};h.hasBeenReset=!1;let g="",m=!1,A=o,C=l,v=u,S=null,R="",b=!0,D="auto",_="start",M=50,p="middle",$=50,N="middle";Object.defineProperty(h,"id",n({},d,{get:function(){return g},set:function(O){g=""+O}})),Object.defineProperty(h,"pauseOnExit",n({},d,{get:function(){return m},set:function(O){m=!!O}})),Object.defineProperty(h,"startTime",n({},d,{get:function(){return A},set:function(O){if(typeof O!="number")throw new TypeError("Start time must be set to a number.");A=O,this.hasBeenReset=!0}})),Object.defineProperty(h,"endTime",n({},d,{get:function(){return C},set:function(O){if(typeof O!="number")throw new TypeError("End time must be set to a number.");C=O,this.hasBeenReset=!0}})),Object.defineProperty(h,"text",n({},d,{get:function(){return v},set:function(O){v=""+O,this.hasBeenReset=!0}})),Object.defineProperty(h,"region",n({},d,{get:function(){return S},set:function(O){S=O,this.hasBeenReset=!0}})),Object.defineProperty(h,"vertical",n({},d,{get:function(){return R},set:function(O){const W=i(O);if(W===!1)throw new SyntaxError("An invalid or illegal string was specified.");R=W,this.hasBeenReset=!0}})),Object.defineProperty(h,"snapToLines",n({},d,{get:function(){return b},set:function(O){b=!!O,this.hasBeenReset=!0}})),Object.defineProperty(h,"line",n({},d,{get:function(){return D},set:function(O){if(typeof O!="number"&&O!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");D=O,this.hasBeenReset=!0}})),Object.defineProperty(h,"lineAlign",n({},d,{get:function(){return _},set:function(O){const W=s(O);if(!W)throw new SyntaxError("An invalid or illegal string was specified.");_=W,this.hasBeenReset=!0}})),Object.defineProperty(h,"position",n({},d,{get:function(){return M},set:function(O){if(O<0||O>100)throw new Error("Position must be between 0 and 100.");M=O,this.hasBeenReset=!0}})),Object.defineProperty(h,"positionAlign",n({},d,{get:function(){return p},set:function(O){const W=s(O);if(!W)throw new SyntaxError("An invalid or illegal string was specified.");p=W,this.hasBeenReset=!0}})),Object.defineProperty(h,"size",n({},d,{get:function(){return $},set:function(O){if(O<0||O>100)throw new Error("Size must be between 0 and 100.");$=O,this.hasBeenReset=!0}})),Object.defineProperty(h,"align",n({},d,{get:function(){return N},set:function(O){const W=s(O);if(!W)throw new SyntaxError("An invalid or illegal string was specified.");N=W,this.hasBeenReset=!0}})),h.displayState=void 0}return a.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},a})();class Tp{decode(e,t){if(!e)return"";if(typeof e!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}function Ou(r){function e(i,s,n,a){return(i|0)*3600+(s|0)*60+(n|0)+parseFloat(a||0)}const t=r.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return t?parseFloat(t[2])>59?e(t[2],t[3],0,t[4]):e(t[1],t[2],t[3],t[4]):null}class Sp{constructor(){this.values=Object.create(null)}set(e,t){!this.get(e)&&t!==""&&(this.values[e]=t)}get(e,t,i){return i?this.has(e)?this.values[e]:t[i]:this.has(e)?this.values[e]:t}has(e){return e in this.values}alt(e,t,i){for(let s=0;s<i.length;++s)if(t===i[s]){this.set(e,t);break}}integer(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))}percent(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){const i=parseFloat(t);if(i>=0&&i<=100)return this.set(e,i),!0}return!1}}function Fu(r,e,t,i){const s=i?r.split(i):[r];for(const n in s){if(typeof s[n]!="string")continue;const a=s[n].split(t);if(a.length!==2)continue;const o=a[0],l=a[1];e(o,l)}}const Zr=new Xr(0,0,""),Tn=Zr.align==="middle"?"middle":"center";function xp(r,e,t){const i=r;function s(){const o=Ou(r);if(o===null)throw new Error("Malformed timestamp: "+i);return r=r.replace(/^[^\sa-zA-Z-]+/,""),o}function n(o,l){const u=new Sp;Fu(o,function(g,m){let A;switch(g){case"region":for(let C=t.length-1;C>=0;C--)if(t[C].id===m){u.set(g,t[C].region);break}break;case"vertical":u.alt(g,m,["rl","lr"]);break;case"line":A=m.split(","),u.integer(g,A[0]),u.percent(g,A[0])&&u.set("snapToLines",!1),u.alt(g,A[0],["auto"]),A.length===2&&u.alt("lineAlign",A[1],["start",Tn,"end"]);break;case"position":A=m.split(","),u.percent(g,A[0]),A.length===2&&u.alt("positionAlign",A[1],["start",Tn,"end","line-left","line-right","auto"]);break;case"size":u.percent(g,m);break;case"align":u.alt(g,m,["start",Tn,"end","left","right"]);break}},/:/,/\s/),l.region=u.get("region",null),l.vertical=u.get("vertical","");let h=u.get("line","auto");h==="auto"&&Zr.line===-1&&(h=-1),l.line=h,l.lineAlign=u.get("lineAlign","start"),l.snapToLines=u.get("snapToLines",!0),l.size=u.get("size",100),l.align=u.get("align",Tn);let d=u.get("position","auto");d==="auto"&&Zr.position===50&&(d=l.align==="start"||l.align==="left"?0:l.align==="end"||l.align==="right"?100:50),l.position=d}function a(){r=r.replace(/^\s+/,"")}if(a(),e.startTime=s(),a(),r.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+i);r=r.slice(3),a(),e.endTime=s(),a(),n(r,e)}function Nu(r){return r.replace(/<br(?: \/)?>/gi,`
31
+ `)}class bp{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new Tp,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(e){const t=this;e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));function i(){let n=t.buffer,a=0;for(n=Nu(n);a<n.length&&n[a]!=="\r"&&n[a]!==`
32
+ `;)++a;const o=n.slice(0,a);return n[a]==="\r"&&++a,n[a]===`
33
+ `&&++a,t.buffer=n.slice(a),o}function s(n){Fu(n,function(a,o){},/:/)}try{let n="";if(t.state==="INITIAL"){if(!/\r\n|\n/.test(t.buffer))return this;n=i();const o=n.match(/^()?WEBVTT([ \t].*)?$/);if(!(o!=null&&o[0]))throw new Error("Malformed WebVTT signature.");t.state="HEADER"}let a=!1;for(;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(a?a=!1:n=i(),t.state){case"HEADER":/:/.test(n)?s(n):n||(t.state="ID");continue;case"NOTE":n||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(n)){t.state="NOTE";break}if(!n)continue;if(t.cue=new Xr(0,0,""),t.state="CUE",n.indexOf("-->")===-1){t.cue.id=n;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{xp(n,t.cue,t.regionList)}catch{t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":{const o=n.indexOf("-->")!==-1;if(!n||o&&(a=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(t.cue===null)continue;t.cue.text&&(t.cue.text+=`
34
+ `),t.cue.text+=n}continue;case"BADCUE":n||(t.state="ID")}}}catch{t.state==="CUETEXT"&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state=t.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this}flush(){const e=this;try{if((e.cue||e.state==="HEADER")&&(e.buffer+=`
35
35
 
36
- `,e.parse()),e.state==="INITIAL"||e.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this}}const _f=/\r\n|\n\r|\n|\r/g,An=function(e,t,i=0){return e.slice(i,i+t.length)===t},wf=function(e){let t=parseInt(e.slice(-3));const i=parseInt(e.slice(-6,-4)),s=parseInt(e.slice(-9,-7)),r=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!se(t)||!se(i)||!se(s)||!se(r))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*i,t+=60*1e3*s,t+=3600*1e3*r,t};function mn(a,e,t){return as(a.toString())+as(e.toString())+as(t)}const kf=function(e,t,i){let s=e[t],r=e[s.prevCC];if(!r||!r.new&&s.new){e.ccOffset=e.presentationOffset=s.start,s.new=!1;return}for(;(n=r)!=null&&n.new;){var n;e.ccOffset+=s.start-r.start,s.new=!1,s=r,r=e[s.prevCC]}e.presentationOffset=i};function Mf(a,e,t,i,s,r,n){const o=new Pf,c=mt(new Uint8Array(a)).trim().replace(_f,`
36
+ `,e.parse()),e.state==="INITIAL"||e.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this}}function _s(r){let e=5381,t=r.length;for(;t;)e=e*33^r.charCodeAt(--t);return(e>>>0).toString()}const Lp=/\r\n|\n\r|\n|\r/g,Bu="Missing initPTS for VTT ",Rp=function(e){let t=parseInt(e.slice(-3));const i=parseInt(e.slice(-6,-4)),s=parseInt(e.slice(-9,-7)),n=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!se(t)||!se(i)||!se(s)||!se(n))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*i,t+=60*1e3*s,t+=3600*1e3*n,t};function Qr(r,e,t){return _s(r.toString())+_s(e.toString())+_s(t)}function Dp(r,e,t,i,s,n,a){const o=new bp,l=Mt(new Uint8Array(r)).trim().replace(Lp,`
37
37
  `).split(`
38
- `),u=[],h=e?Vh(e.baseTime,e.timescale):0;let f="00:00.000",g=0,I=0,m,E=!0;o.oncue=function(v){const x=t[i];let D=t.ccOffset;const L=(g-h)/9e4;if(x!=null&&x.new&&(I!==void 0?D=t.ccOffset=x.start:kf(t,i,L)),L){if(!e){m=new Error("Missing initPTS for VTT MPEGTS");return}D=L-t.presentationOffset}const w=v.endTime-v.startTime,N=xt((v.startTime+D-I)*9e4,s*9e4)/9e4;v.startTime=Math.max(N,0),v.endTime=Math.max(N+w,0);const K=v.text.trim();v.text=decodeURIComponent(encodeURIComponent(K)),v.id||(v.id=mn(v.startTime,v.endTime,K)),v.endTime>0&&u.push(v)},o.onparsingerror=function(v){m=v},o.onflush=function(){if(m){n(m);return}r(u)},c.forEach(v=>{if(E)if(An(v,"X-TIMESTAMP-MAP=")){E=!1,v.slice(16).split(",").forEach(x=>{An(x,"LOCAL:")?f=x.slice(6):An(x,"MPEGTS:")&&(g=parseInt(x.slice(7)))});try{I=wf(f)/1e3}catch(x){m=x}return}else v===""&&(E=!1);o.parse(v+`
39
- `)}),o.flush()}const In="stpp.ttml.im1t",yl=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,El=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,Of={left:"start",center:"center",right:"end",start:"start",end:"end"};function vl(a,e,t,i){const s=xe(new Uint8Array(a),["mdat"]);if(s.length===0){i(new Error("Could not parse IMSC1 mdat"));return}const r=s.map(o=>mt(o)),n=Hh(e.baseTime,1,e.timescale);try{r.forEach(o=>t(Ff(o,n)))}catch(o){i(o)}}function Ff(a,e){const s=new DOMParser().parseFromString(a,"text/xml").getElementsByTagName("tt")[0];if(!s)throw new Error("Invalid ttml");const r={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},n=Object.keys(r).reduce((f,g)=>(f[g]=s.getAttribute(`ttp:${g}`)||r[g],f),{}),o=s.getAttribute("xml:space")!=="preserve",c=Tl(Cn(s,"styling","style")),u=Tl(Cn(s,"layout","region")),h=Cn(s,"body","[begin]");return[].map.call(h,f=>{const g=Sl(f,o);if(!g||!f.hasAttribute("begin"))return null;const I=En(f.getAttribute("begin"),n),m=En(f.getAttribute("dur"),n);let E=En(f.getAttribute("end"),n);if(I===null)throw xl(f);if(E===null){if(m===null)throw xl(f);E=I+m}const v=new gn(I-e,E-e,g);v.id=mn(v.startTime,v.endTime,v.text);const x=u[f.getAttribute("region")],D=c[f.getAttribute("style")],L=Nf(x,D,c),{textAlign:w}=L;if(w){const N=Of[w];N&&(v.lineAlign=N),v.align=w}return Ne(v,L),v}).filter(f=>f!==null)}function Cn(a,e,t){const i=a.getElementsByTagName(e)[0];return i?[].slice.call(i.querySelectorAll(t)):[]}function Tl(a){return a.reduce((e,t)=>{const i=t.getAttribute("xml:id");return i&&(e[i]=t),e},{})}function Sl(a,e){return[].slice.call(a.childNodes).reduce((t,i,s)=>{var r;return i.nodeName==="br"&&s?t+`
40
- `:(r=i.childNodes)!=null&&r.length?Sl(i,e):e?t+i.textContent.trim().replace(/\s+/g," "):t+i.textContent},"")}function Nf(a,e,t){const i="http://www.w3.org/ns/ttml#styling";let s=null;const r=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],n=a!=null&&a.hasAttribute("style")?a.getAttribute("style"):null;return n&&t.hasOwnProperty(n)&&(s=t[n]),r.reduce((o,c)=>{const u=yn(e,i,c)||yn(a,i,c)||yn(s,i,c);return u&&(o[c]=u),o},{})}function yn(a,e,t){return a&&a.hasAttributeNS(e,t)?a.getAttributeNS(e,t):null}function xl(a){return new Error(`Could not parse ttml timestamp ${a}`)}function En(a,e){if(!a)return null;let t=ml(a);return t===null&&(yl.test(a)?t=Bf(a,e):El.test(a)&&(t=Uf(a,e))),t}function Bf(a,e){const t=yl.exec(a),i=(t[4]|0)+(t[5]|0)/e.subFrameRate;return(t[1]|0)*3600+(t[2]|0)*60+(t[3]|0)+i/e.frameRate}function Uf(a,e){const t=El.exec(a),i=Number(t[1]);switch(t[2]){case"h":return i*3600;case"m":return i*60;case"ms":return i*1e3;case"f":return i/e.frameRate;case"t":return i/e.tickRate}return i}class Xs{constructor(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}dispatchCue(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(e,t,i){(this.startTime===null||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=i,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}class $f{constructor(e){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.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=Rl(),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}},e.on(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(y.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(y.FRAG_LOADING,this.onFragLoading,this),e.on(y.FRAG_LOADED,this.onFragLoaded,this),e.on(y.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(y.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(y.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(y.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(y.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:e}=this;e.off(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(y.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(y.FRAG_LOADING,this.onFragLoading,this),e.off(y.FRAG_LOADED,this.onFragLoaded,this),e.off(y.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(y.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(y.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(y.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(y.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.media=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){const e=new Xs(this,"textTrack1"),t=new Xs(this,"textTrack2"),i=new Xs(this,"textTrack3"),s=new Xs(this,"textTrack4");this.cea608Parser1=new Al(1,e,t),this.cea608Parser2=new Al(3,i,s)}addCues(e,t,i,s,r){let n=!1;for(let o=r.length;o--;){const c=r[o],u=Gf(c[0],c[1],t,i);if(u>=0&&(c[0]=Math.min(c[0],t),c[1]=Math.max(c[1],i),n=!0,u/(i-t)>.5))return}if(n||r.push([t,i]),this.config.renderTextTracksNatively){const o=this.captionsTracks[e];this.Cues.newCue(o,t,i,s)}else{const o=this.Cues.newCue(null,t,i,s);this.hls.trigger(y.CUES_PARSED,{type:"captions",cues:o,track:e})}}onInitPtsFound(e,{frag:t,id:i,initPTS:s,timescale:r,trackId:n}){const{unparsedVttFrags:o}=this;i===he.MAIN&&(this.initPTS[t.cc]={baseTime:s,timescale:r,trackId:n}),o.length&&(this.unparsedVttFrags=[],o.forEach(c=>{this.initPTS[c.frag.cc]?this.onFragLoaded(y.FRAG_LOADED,c):this.hls.trigger(y.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:c.frag,error:new Error("Subtitle discontinuity domain does not match main")})}))}getExistingTrack(e,t){const{media:i}=this;if(i)for(let s=0;s<i.textTracks.length;s++){const r=i.textTracks[s];if(Ll(r,{name:e,lang:t,characteristics:"transcribes-spoken-dialog,describes-music-and-sound"}))return r}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}createNativeTrack(e){if(this.captionsTracks[e])return;const{captionsProperties:t,captionsTracks:i,media:s}=this,{label:r,languageCode:n}=t[e],o=this.getExistingTrack(r,n);if(o)i[e]=o,Bi(i[e]),ol(i[e],s);else{const c=this.createTextTrack("captions",r,n);c&&(c[e]=!0,i[e]=c)}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;const t=this.captionsProperties[e];if(!t)return;const i=t.label,s={_id:e,label:i,kind:"captions",default:t.media?!!t.media.default:!1,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=s,this.hls.trigger(y.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[s]})}createTextTrack(e,t,i){const s=this.media;if(s)return s.addTextTrack(e,t,i)}onMediaAttaching(e,t){this.media=t.media,t.mediaSource||this._cleanTracks()}onMediaDetaching(e,t){const i=!!t.transferMedia;if(this.media=null,i)return;const{captionsTracks:s}=this;Object.keys(s).forEach(r=>{Bi(s[r]),delete s[r]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=Rl(),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 i=0;i<t.length;i++)Bi(t[i])}onSubtitleTracksUpdated(e,t){const i=t.subtitleTracks||[],s=i.some(r=>r.textCodec===In);if(this.config.enableWebVTT||s&&this.config.enableIMSC1){if(Go(this.tracks,i)){this.tracks=i;return}if(this.textTracks=[],this.tracks=i,this.config.renderTextTracksNatively){const n=this.media,o=n?Ys(n.textTracks):null;if(this.tracks.forEach((c,u)=>{let h;if(o){let f=null;for(let g=0;g<o.length;g++)if(o[g]&&Ll(o[g],c)){f=o[g],o[g]=null;break}f&&(h=f)}if(h)Bi(h);else{const f=bl(c);h=this.createTextTrack(f,c.name,c.lang),h&&(h.mode="disabled")}h&&this.textTracks.push(h)}),o!=null&&o.length){const c=o.filter(u=>u!==null).map(u=>u.label);c.length&&this.hls.logger.warn(`Media element contains unused subtitle tracks: ${c.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`)}}else if(this.tracks.length){const n=this.tracks.map(o=>({label:o.name,kind:o.type.toLowerCase(),default:o.default,subtitleTrack:o}));this.hls.trigger(y.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:n})}}}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(i=>{const s=/(?:CC|SERVICE)([1-4])/.exec(i.instreamId);if(!s)return;const r=`textTrack${s[1]}`,n=this.captionsProperties[r];n&&(n.label=i.name,i.lang&&(n.languageCode=i.lang),n.media=i)})}closedCaptionsForLevel(e){const t=this.hls.levels[e.level];return t?.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){if(this.enabled&&t.frag.type===he.MAIN){var i,s;const{cea608Parser1:r,cea608Parser2:n,lastSn:o}=this,{cc:c,sn:u}=t.frag,h=(i=(s=t.part)==null?void 0:s.index)!=null?i:-1;r&&n&&(u!==o+1||u===o&&h!==this.lastPartIndex+1||c!==this.lastCc)&&(r.reset(),n.reset()),this.lastCc=c,this.lastSn=u,this.lastPartIndex=h}}onFragLoaded(e,t){const{frag:i,payload:s}=t;if(i.type===he.SUBTITLE)if(s.byteLength){const r=i.decryptdata,n="stats"in t;if(r==null||!r.encrypted||n){const o=this.tracks[i.level],c=this.vttCCs;c[i.cc]||(c[i.cc]={start:i.start,prevCC:this.prevCC,new:!0},this.prevCC=i.cc),o&&o.textCodec===In?this._parseIMSC1(i,s):this._parseVTTs(t)}}else this.hls.trigger(y.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){const i=this.hls;vl(t,this.initPTS[e.cc],s=>{this._appendCues(s,e.level),i.trigger(y.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},s=>{i.logger.log(`Failed to parse IMSC1: ${s}`),i.trigger(y.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:s})})}_parseVTTs(e){var t;const{frag:i,payload:s}=e,{initPTS:r,unparsedVttFrags:n}=this,o=r.length-1;if(!r[i.cc]&&o===-1){n.push(e);return}const c=this.hls,u=(t=i.initSegment)!=null&&t.data?St(i.initSegment.data,new Uint8Array(s)).buffer:s;Mf(u,this.initPTS[i.cc],this.vttCCs,i.cc,i.start,h=>{this._appendCues(h,i.level),c.trigger(y.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:i})},h=>{const f=h.message==="Missing initPTS for VTT MPEGTS";f?n.push(e):this._fallbackToIMSC1(i,s),c.logger.log(`Failed to parse VTT cue: ${h}`),!(f&&o>i.cc)&&c.trigger(y.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:h})})}_fallbackToIMSC1(e,t){const i=this.tracks[e.level];i.textCodec||vl(t,this.initPTS[e.cc],()=>{i.textCodec=In,this._parseIMSC1(e,t)},()=>{i.textCodec="wvtt"})}_appendCues(e,t){const i=this.hls;if(this.config.renderTextTracksNatively){const s=this.textTracks[t];if(!s||s.mode==="disabled")return;e.forEach(r=>ll(s,r))}else{const s=this.tracks[t];if(!s)return;const r=s.default?"default":"subtitles"+t;i.trigger(y.CUES_PARSED,{type:"subtitles",cues:e,track:r})}}onFragDecrypted(e,t){const{frag:i}=t;i.type===he.SUBTITLE&&this.onFragLoaded(y.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){if(!this.enabled||!this.config.enableCEA708Captions)return;const{frag:i,samples:s}=t;if(!(i.type===he.MAIN&&this.closedCaptionsForLevel(i)==="NONE"))for(let r=0;r<s.length;r++){const n=s[r].bytes;if(n){this.cea608Parser1||this.initCea608Parsers();const o=this.extractCea608Data(n);this.cea608Parser1.addData(s[r].pts,o[0]),this.cea608Parser2.addData(s[r].pts,o[1])}}}onBufferFlushing(e,{startOffset:t,endOffset:i,endOffsetSubtitles:s,type:r}){const{media:n}=this;if(!(!n||n.currentTime<i)){if(!r||r==="video"){const{captionsTracks:o}=this;Object.keys(o).forEach(c=>cn(o[c],t,i))}if(this.config.renderTextTracksNatively&&t===0&&s!==void 0){const{textTracks:o}=this;Object.keys(o).forEach(c=>cn(o[c],t,s))}}}extractCea608Data(e){const t=[[],[]],i=e[0]&31;let s=2;for(let r=0;r<i;r++){const n=e[s++],o=127&e[s++],c=127&e[s++];if(o===0&&c===0)continue;if((4&n)!==0){const h=3&n;(h===0||h===1)&&(t[h].push(o),t[h].push(c))}}return t}}function bl(a){return a.characteristics&&/transcribes-spoken-dialog/gi.test(a.characteristics)&&/describes-music-and-sound/gi.test(a.characteristics)?"captions":"subtitles"}function Ll(a,e){return!!a&&a.kind===bl(e)&&tn(e,a)}function Gf(a,e,t,i){return Math.min(e,i)-Math.max(a,t)}function Rl(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}const Hf=/\s/,Vf={newCue(a,e,t,i){const s=[];let r,n,o,c,u;const h=self.VTTCue||self.TextTrackCue;for(let g=0;g<i.rows.length;g++)if(r=i.rows[g],o=!0,c=0,u="",!r.isEmpty()){var f;for(let E=0;E<r.chars.length;E++)Hf.test(r.chars[E].uchar)&&o?c++:(u+=r.chars[E].uchar,o=!1);r.cueStartTime=e,e===t&&(t+=1e-4),c>=16?c--:c++;const I=Cl(u.trim()),m=mn(e,t,I);a!=null&&(f=a.cues)!=null&&f.getCueById(m)||(n=new h(e,t,I),n.id=m,n.line=g+1,n.align="left",n.position=10+Math.min(80,Math.floor(c*8/32)*10),s.push(n))}return a&&s.length&&(s.sort((g,I)=>g.line==="auto"||I.line==="auto"?0:g.line>8&&I.line>8?I.line-g.line:g.line-I.line),s.forEach(g=>ll(a,g))),s}};function Kf(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}const Yf=/(\d+)-(\d+)\/(\d+)/;class Dl{constructor(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||qf,this.controller=new self.AbortController,this.stats=new Ar}destroy(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null}abortInternal(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(e,t,i){const s=this.stats;if(s.loading.start)throw new Error("Loader can only be used once.");s.loading.start=self.performance.now();const r=Wf(e,this.controller.signal),n=e.responseType==="arraybuffer",o=n?"byteLength":"length",{maxTimeToFirstByteMs:c,maxLoadTimeMs:u}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=i,this.request=this.fetchSetup(e,r),self.clearTimeout(this.requestTimeout),t.timeout=c&&se(c)?c:u,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(s,e,this.response))},t.timeout),(rs(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then(f=>{var g;this.response=this.loader=f;const I=Math.max(self.performance.now(),s.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=u,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(s,e,this.response))},u-(I-s.loading.start)),!f.ok){const{status:E,statusText:v}=f;throw new Xf(v||"fetch, bad network response",E,f)}s.loading.first=I,s.total=zf(f.headers)||s.total;const m=(g=this.callbacks)==null?void 0:g.onProgress;return m&&se(t.highWaterMark)?this.loadProgressively(f,s,e,t.highWaterMark,m):n?f.arrayBuffer():e.responseType==="json"?f.json():f.text()}).then(f=>{var g,I;const m=this.response;if(!m)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),s.loading.end=Math.max(self.performance.now(),s.loading.first);const E=f[o];E&&(s.loaded=s.total=E);const v={url:m.url,data:f,code:m.status},x=(g=this.callbacks)==null?void 0:g.onProgress;x&&!se(t.highWaterMark)&&x(s,e,f,m),(I=this.callbacks)==null||I.onSuccess(v,s,e,m)}).catch(f=>{var g;if(self.clearTimeout(this.requestTimeout),s.aborted)return;const I=f&&f.code||0,m=f?f.message:null;(g=this.callbacks)==null||g.onError({code:I,text:m},e,f?f.details:null,s)})}getCacheAge(){let e=null;if(this.response){const t=this.response.headers.get("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,t,i,s=0,r){const n=new go,o=e.body.getReader(),c=()=>o.read().then(u=>{if(u.done)return n.dataLength&&r(t,i,n.flush().buffer,e),Promise.resolve(new ArrayBuffer(0));const h=u.value,f=h.length;return t.loaded+=f,f<s||n.dataLength?(n.push(h),n.dataLength>=s&&r(t,i,n.flush().buffer,e)):r(t,i,h.buffer,e),c()}).catch(()=>Promise.reject());return c()}}function Wf(a,e){const t={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(Ne({},a.headers))};return a.rangeEnd&&t.headers.set("Range","bytes="+a.rangeStart+"-"+String(a.rangeEnd-1)),t}function jf(a){const e=Yf.exec(a);if(e)return parseInt(e[2])-parseInt(e[1])+1}function zf(a){const e=a.get("Content-Range");if(e){const i=jf(e);if(se(i))return i}const t=a.get("Content-Length");if(t)return parseInt(t)}function qf(a,e){return new self.Request(a.url,e)}class Xf extends Error{constructor(e,t,i){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=i}}const Zf=/^age:\s*[\d.]+\s*$/im;class Pl{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=null,this.loader=null,this.stats=void 0,this.xhrSetup=e&&e.xhrSetup||null,this.stats=new Ar,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null}abortInternal(){const e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,e.readyState!==4&&(this.stats.aborted=!0,e.abort()))}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(e,t,i){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=i,this.loadInternal()}loadInternal(){const{config:e,context:t}=this;if(!e||!t)return;const i=this.loader=new self.XMLHttpRequest,s=this.stats;s.loading.first=0,s.loaded=0,s.aborted=!1;const r=this.xhrSetup;r?Promise.resolve().then(()=>{if(!(this.loader!==i||this.stats.aborted))return r(i,t.url)}).catch(n=>{if(!(this.loader!==i||this.stats.aborted))return i.open("GET",t.url,!0),r(i,t.url)}).then(()=>{this.loader!==i||this.stats.aborted||this.openAndSendXhr(i,t,e)}).catch(n=>{var o;(o=this.callbacks)==null||o.onError({code:i.status,text:n.message},t,i,s)}):this.openAndSendXhr(i,t,e)}openAndSendXhr(e,t,i){e.readyState||e.open("GET",t.url,!0);const s=t.headers,{maxTimeToFirstByteMs:r,maxLoadTimeMs:n}=i.loadPolicy;if(s)for(const o in s)e.setRequestHeader(o,s[o]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),i.timeout=r&&se(r)?r:n,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.timeout),e.send()}readystatechange(){const{context:e,loader:t,stats:i}=this;if(!e||!t)return;const s=t.readyState,r=this.config;if(!i.aborted&&s>=2&&(i.loading.first===0&&(i.loading.first=Math.max(self.performance.now(),i.loading.start),r.timeout!==r.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),r.timeout=r.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.loadPolicy.maxLoadTimeMs-(i.loading.first-i.loading.start)))),s===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;const u=t.status,h=t.responseType==="text"?t.responseText:null;if(u>=200&&u<300){const m=h??t.response;if(m!=null){var n,o;i.loading.end=Math.max(self.performance.now(),i.loading.first);const E=t.responseType==="arraybuffer"?m.byteLength:m.length;i.loaded=i.total=E,i.bwEstimate=i.total*8e3/(i.loading.end-i.loading.first);const v=(n=this.callbacks)==null?void 0:n.onProgress;v&&v(i,e,m,t);const x={url:t.responseURL,data:m,code:u};(o=this.callbacks)==null||o.onSuccess(x,i,e,t);return}}const f=r.loadPolicy.errorRetry,g=i.retry,I={url:e.url,data:void 0,code:u};if(Ls(f,g,!1,I))this.retry(f);else{var c;Oe.error(`${u} while loading ${e.url}`),(c=this.callbacks)==null||c.onError({code:u,text:t.statusText},e,t,i)}}}loadtimeout(){if(!this.config)return;const e=this.config.loadPolicy.timeoutRetry,t=this.stats.retry;if(Ls(e,t,!0))this.retry(e);else{var i;Oe.warn(`timeout while loading ${(i=this.context)==null?void 0:i.url}`);const s=this.callbacks;s&&(this.abortInternal(),s.onTimeout(this.stats,this.context,this.loader))}}retry(e){const{context:t,stats:i}=this;this.retryDelay=br(e,i.retry),i.retry++,Oe.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${t?.url}, retrying ${i.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&&Zf.test(this.loader.getAllResponseHeaders())){const t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}}const Qf={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},Jf=Be(Be({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,maxDevicePixelRatio:Number.POSITIVE_INFINITY,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,startOnSegmentBoundary:!1,maxBufferSize:60*1e3*1e3,maxFragLookUpTolerance:.25,maxBufferHole:.1,detectStallWithCurrentTimeMs:1250,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,nudgeOnVideoHole:!0,liveSyncMode:"edge",liveSyncDurationCount:3,liveSyncOnStallIncrease:1,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,ignorePlaylistParsingErrors:!1,loader:Pl,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:dc,bufferController:rd,capLevelController:rn,errorController:mc,fpsController:tf,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:Va,requireKeySystemAccessOnStart:!1,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableEmsgKLVMetadata:!1,enableID3MetadataCues:!0,enableInterstitialPlayback:!0,interstitialAppendInPlace:!0,interstitialLiveLookAhead:10,useMediaCapabilities:!0,preserveManualLevelOnError:!1,certLoadPolicy:{default:Qf},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},interstitialAssetListLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:3e4,timeoutRetry:{maxNumRetry:0,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:0,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},eg()),{},{subtitleStreamController:gf,subtitleTrackController:nf,timelineController:$f,audioStreamController:ed,audioTrackController:td,emeController:Ni,cmcdController:Qd,contentSteeringController:ef,interstitialsController:ff});function eg(){return{cueHandler:Vf,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 tg(a,e,t){if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(e.liveMaxLatencyDurationCount!==void 0&&(e.liveSyncDurationCount===void 0||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(e.liveMaxLatencyDuration!==void 0&&(e.liveSyncDuration===void 0||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const i=vn(a),s=["manifest","level","frag"],r=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return s.forEach(n=>{const o=`${n==="level"?"playlist":n}LoadPolicy`,c=e[o]===void 0,u=[];r.forEach(h=>{const f=`${n}Loading${h}`,g=e[f];if(g!==void 0&&c){u.push(f);const I=i[o].default;switch(e[o]={default:I},h){case"TimeOut":I.maxLoadTimeMs=g,I.maxTimeToFirstByteMs=g;break;case"MaxRetry":I.errorRetry.maxNumRetry=g,I.timeoutRetry.maxNumRetry=g;break;case"RetryDelay":I.errorRetry.retryDelayMs=g,I.timeoutRetry.retryDelayMs=g;break;case"MaxRetryTimeout":I.errorRetry.maxRetryDelayMs=g,I.timeoutRetry.maxRetryDelayMs=g;break}}}),u.length&&t.warn(`hls.js config: "${u.join('", "')}" setting(s) are deprecated, use "${o}": ${Ge(e[o])}`)}),Be(Be({},i),e)}function vn(a){return a&&typeof a=="object"?Array.isArray(a)?a.map(vn):Object.keys(a).reduce((e,t)=>(e[t]=vn(a[t]),e),{}):a}function ig(a,e){const t=a.loader;t!==Dl&&t!==Pl?(e.log("[config]: Custom loader detected, cannot enable progressive streaming"),a.progressive=!1):Kf()&&(a.loader=Dl,a.progressive=!0,a.enableSoftwareAES=!0,e.log("[config]: Progressive streaming enabled, using FetchLoader"))}const Zs=2,sg=.1,rg=.05,ng=100;class ag extends Ma{constructor(e,t){super("gap-controller",e.logger),this.hls=void 0,this.fragmentTracker=void 0,this.media=null,this.mediaSource=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.buffered={},this.lastCurrentTime=0,this.ended=0,this.waiting=0,this.onMediaPlaying=()=>{this.ended=0,this.waiting=0},this.onMediaWaiting=()=>{var i;(i=this.media)!=null&&i.seeking||(this.waiting=self.performance.now(),this.tick())},this.onMediaEnded=()=>{if(this.hls){var i;this.ended=((i=this.media)==null?void 0:i.currentTime)||1,this.hls.trigger(y.MEDIA_ENDED,{stalled:!1})}},this.hls=e,this.fragmentTracker=t,this.registerListeners()}registerListeners(){const{hls:e}=this;e&&(e.on(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.BUFFER_APPENDED,this.onBufferAppended,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.BUFFER_APPENDED,this.onBufferAppended,this))}destroy(){super.destroy(),this.unregisterListeners(),this.media=this.hls=this.fragmentTracker=null,this.mediaSource=void 0}onMediaAttached(e,t){this.setInterval(ng),this.mediaSource=t.mediaSource;const i=this.media=t.media;ot(i,"playing",this.onMediaPlaying),ot(i,"waiting",this.onMediaWaiting),ot(i,"ended",this.onMediaEnded)}onMediaDetaching(e,t){this.clearInterval();const{media:i}=this;i&&(ht(i,"playing",this.onMediaPlaying),ht(i,"waiting",this.onMediaWaiting),ht(i,"ended",this.onMediaEnded),this.media=null),this.mediaSource=void 0}onBufferAppended(e,t){this.buffered=t.timeRanges}get hasBuffered(){return Object.keys(this.buffered).length>0}tick(){var e;if(!((e=this.media)!=null&&e.readyState)||!this.hasBuffered)return;const t=this.media.currentTime;this.poll(t,this.lastCurrentTime),this.lastCurrentTime=t}poll(e,t){var i,s;const r=(i=this.hls)==null?void 0:i.config;if(!r)return;const n=this.media;if(!n)return;const{seeking:o}=n,c=this.seeking&&!o,u=!this.seeking&&o,h=n.paused&&!o||n.ended||n.playbackRate===0;if(this.seeking=o,e!==t){t&&(this.ended=0),this.moved=!0,o||(this.nudgeRetry=0,r.nudgeOnVideoHole&&!h&&e>t&&this.nudgeOnVideoHole(e,t)),this.waiting===0&&this.stallResolved(e);return}if(u||c){c&&this.stallResolved(e);return}if(h){this.nudgeRetry=0,this.stallResolved(e),!this.ended&&n.ended&&this.hls&&(this.ended=e||1,this.hls.trigger(y.MEDIA_ENDED,{stalled:!1}));return}if(!ye.getBuffered(n).length){this.nudgeRetry=0;return}const f=ye.bufferInfo(n,e,0),g=f.nextStart||0,I=this.fragmentTracker;if(o&&I&&this.hls){const K=_l(this.hls.inFlightFragments,e),p=f.len>Zs,$=!g||K||g-e>Zs&&!I.getPartialFragment(e);if(p||$)return;this.moved=!1}const m=(s=this.hls)==null?void 0:s.latestLevelDetails;if(!this.moved&&this.stalled!==null&&I){if(!(f.len>0)&&!g)return;const p=Math.max(g,f.start||0)-e,F=!!(m!=null&&m.live)?m.targetduration*2:Zs,O=Qs(e,I);if(p>0&&(p<=F||O)){n.paused||this._trySkipBufferHole(O);return}}const E=r.detectStallWithCurrentTimeMs,v=self.performance.now(),x=this.waiting;let D=this.stalled;if(D===null)if(x>0&&v-x<E)D=this.stalled=x;else{this.stalled=v;return}const L=v-D;if(!o&&(L>=E||x)&&this.hls){var w;if(((w=this.mediaSource)==null?void 0:w.readyState)==="ended"&&!(m!=null&&m.live)&&Math.abs(e-(m?.edge||0))<1){if(this.ended)return;this.ended=e||1,this.hls.trigger(y.MEDIA_ENDED,{stalled:!0});return}if(this._reportStall(f),!this.media||!this.hls)return}const N=ye.bufferInfo(n,e,r.maxBufferHole);this._tryFixBufferStall(N,L,e)}stallResolved(e){const t=this.stalled;if(t&&this.hls&&(this.stalled=null,this.stallReported)){const i=self.performance.now()-t;this.log(`playback not stuck anymore @${e}, after ${Math.round(i)}ms`),this.stallReported=!1,this.waiting=0,this.hls.trigger(y.STALL_RESOLVED,{})}}nudgeOnVideoHole(e,t){var i;const s=this.buffered.video;if(this.hls&&this.media&&this.fragmentTracker&&(i=this.buffered.audio)!=null&&i.length&&s&&s.length>1&&e>s.end(0)){const r=ye.bufferedInfo(ye.timeRangesToArray(this.buffered.audio),e,0);if(r.len>1&&t>=r.start){const n=ye.timeRangesToArray(s),o=ye.bufferedInfo(n,t,0).bufferedIndex;if(o>-1&&o<n.length-1){const c=ye.bufferedInfo(n,e,0).bufferedIndex,u=n[o].end,h=n[o+1].start;if((c===-1||c>o)&&h-u<1&&e-u<2){const f=new Error(`nudging playhead to flush pipeline after video hole. currentTime: ${e} hole: ${u} -> ${h} buffered index: ${c}`);this.warn(f.message),this.media.currentTime+=1e-6;let g=Qs(e,this.fragmentTracker);g&&"fragment"in g?g=g.fragment:g||(g=void 0);const I=ye.bufferInfo(this.media,e,0);this.hls.trigger(y.ERROR,{type:de.MEDIA_ERROR,details:U.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:f,reason:f.message,frag:g,buffer:I.len,bufferInfo:I})}}}}}_tryFixBufferStall(e,t,i){var s,r;const{fragmentTracker:n,media:o}=this,c=(s=this.hls)==null?void 0:s.config;if(!o||!n||!c)return;const u=(r=this.hls)==null?void 0:r.latestLevelDetails,h=Qs(i,n);if((h||u!=null&&u.live&&i<u.fragmentStart)&&(this._trySkipBufferHole(h)||!this.media))return;const f=e.buffered,g=this.adjacentTraversal(e,i);(f&&f.length>1&&e.len>c.maxBufferHole||e.nextStart&&(e.nextStart-i<c.maxBufferHole||g))&&(t>c.highBufferWatchdogPeriod*1e3||this.waiting)&&(this.warn("Trying to nudge playhead over buffer-hole"),this._tryNudgeBuffer(e))}adjacentTraversal(e,t){const i=this.fragmentTracker,s=e.nextStart;if(i&&s){const r=i.getFragAtPos(t,he.MAIN),n=i.getFragAtPos(s,he.MAIN);if(r&&n)return n.sn-r.sn<2}return!1}_reportStall(e){const{hls:t,media:i,stallReported:s,stalled:r}=this;if(!s&&r!==null&&i&&t){this.stallReported=!0;const n=new Error(`Playback stalling at @${i.currentTime} due to low buffer (${Ge(e)})`);this.warn(n.message),t.trigger(y.ERROR,{type:de.MEDIA_ERROR,details:U.BUFFER_STALLED_ERROR,fatal:!1,error:n,buffer:e.len,bufferInfo:e,stalled:{start:r}})}}_trySkipBufferHole(e){var t;const{fragmentTracker:i,media:s}=this,r=(t=this.hls)==null?void 0:t.config;if(!s||!i||!r)return 0;const n=s.currentTime,o=ye.bufferInfo(s,n,0),c=n<o.start?o.start:o.nextStart;if(c&&this.hls){const h=o.len<=r.maxBufferHole,f=o.len>0&&o.len<1&&s.readyState<3,g=c-n;if(g>0&&(h||f)){if(g>r.maxBufferHole){let m=!1;if(n===0){const E=i.getAppendedFrag(0,he.MAIN);E&&c<E.end&&(m=!0)}if(!m&&e){var u;if(!((u=this.hls.loadLevelObj)!=null&&u.details)||_l(this.hls.inFlightFragments,c))return 0;let v=!1,x=e.end;for(;x<c;){const D=Qs(x,i);if(D)x+=D.duration;else{v=!0;break}}if(v)return 0}}const I=Math.max(c+rg,n+sg);if(this.warn(`skipping hole, adjusting currentTime from ${n} to ${I}`),this.moved=!0,s.currentTime=I,!(e!=null&&e.gap)){const m=new Error(`fragment loaded with buffer holes, seeking from ${n} to ${I}`),E={type:de.MEDIA_ERROR,details:U.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:m,reason:m.message,buffer:o.len,bufferInfo:o};e&&("fragment"in e?E.part=e:E.frag=e),this.hls.trigger(y.ERROR,E)}return I}}return 0}_tryNudgeBuffer(e){const{hls:t,media:i,nudgeRetry:s}=this,r=t?.config;if(!i||!r)return 0;const n=i.currentTime;if(this.nudgeRetry++,s<r.nudgeMaxRetry){const o=n+(s+1)*r.nudgeOffset,c=new Error(`Nudging 'currentTime' from ${n} to ${o}`);this.warn(c.message),i.currentTime=o,t.trigger(y.ERROR,{type:de.MEDIA_ERROR,details:U.BUFFER_NUDGE_ON_STALL,error:c,fatal:!1,buffer:e.len,bufferInfo:e})}else{const o=new Error(`Playhead still not moving while enough data buffered @${n} after ${r.nudgeMaxRetry} nudges`);this.error(o.message),t.trigger(y.ERROR,{type:de.MEDIA_ERROR,details:U.BUFFER_STALLED_ERROR,error:o,fatal:!0,buffer:e.len,bufferInfo:e})}}}function _l(a,e){const t=wl(a.main);if(t&&t.start<=e)return t;const i=wl(a.audio);return i&&i.start<=e?i:null}function wl(a){if(!a)return null;switch(a.state){case j.IDLE:case j.STOPPED:case j.ENDED:case j.ERROR:return null}return a.frag}function Qs(a,e){return e.getAppendedFrag(a,he.MAIN)||e.getPartialFragment(a)}const og=.25;function Tn(){if(!(typeof self>"u"))return self.VTTCue||self.TextTrackCue}function Sn(a,e,t,i,s){let r=new a(e,t,"");try{r.value=i,s&&(r.type=s)}catch{r=new a(e,t,Ge(s?Be({type:s},i):i))}return r}const Js=(()=>{const a=Tn();try{a&&new a(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();class lg{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=!0,this.assetCue=void 0,this.onEventCueEnter=()=>{this.hls&&this.hls.trigger(y.EVENT_CUE_ENTER,{})},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=this.onEventCueEnter=null}_registerListeners(){const{hls:e}=this;e&&(e.on(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(y.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(y.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(y.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}_unregisterListeners(){const{hls:e}=this;e&&(e.off(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(y.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(y.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(y.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}onMediaAttaching(e,t){var i;this.media=t.media,((i=t.overrides)==null?void 0:i.cueRemoval)===!1&&(this.removeCues=!1)}onMediaAttached(){var e;const t=(e=this.hls)==null?void 0:e.latestLevelDetails;t&&this.updateDateRangeCues(t)}onMediaDetaching(e,t){this.media=null,!t.transferMedia&&(this.id3Track&&(this.removeCues&&Bi(this.id3Track,this.onEventCueEnter),this.id3Track=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 i=e[t];if(i.kind==="metadata"&&i.label==="id3")return ol(i,this.media),i}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media||!this.hls)return;const{enableEmsgMetadataCues:i,enableID3MetadataCues:s}=this.hls.config;if(!i&&!s)return;const{samples:r}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));const n=Tn();if(n)for(let o=0;o<r.length;o++){const c=r[o].type;if(c===yt.emsg&&!i||!s)continue;const u=vo(r[o].data),h=r[o].pts;let f=h+r[o].duration;f>Js&&(f=Js),f-h<=0&&(f=h+og);for(let I=0;I<u.length;I++){const m=u[I];if(!To(m)){this.updateId3CueEnds(h,c);const E=Sn(n,h,f,m,c);E&&this.id3Track.addCue(E)}}}}updateId3CueEnds(e,t){var i;const s=(i=this.id3Track)==null?void 0:i.cues;if(s)for(let r=s.length;r--;){const n=s[r];n.type===t&&n.startTime<e&&n.endTime===Js&&(n.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:i,type:s}){const{id3Track:r,hls:n}=this;if(!n)return;const{config:{enableEmsgMetadataCues:o,enableID3MetadataCues:c}}=n;if(r&&(o||c)){let u;s==="audio"?u=h=>h.type===yt.audioId3&&c:s==="video"?u=h=>h.type===yt.emsg&&o:u=h=>h.type===yt.audioId3&&c||h.type===yt.emsg&&o,cn(r,t,i,u)}}onLevelUpdated(e,{details:t}){this.updateDateRangeCues(t,!0)}onLevelPtsUpdated(e,t){Math.abs(t.drift)>.01&&this.updateDateRangeCues(t.details)}updateDateRangeCues(e,t){if(!this.hls||!this.media)return;const{assetPlayerId:i,timelineOffset:s,enableDateRangeMetadataCues:r,interstitialsController:n}=this.hls.config;if(!r)return;const o=Tn();if(i&&s&&!n){const{fragmentStart:E,fragmentEnd:v}=e;let x=this.assetCue;x?(x.startTime=E,x.endTime=v):o&&(x=this.assetCue=Sn(o,E,v,{assetPlayerId:this.hls.config.assetPlayerId},"hlsjs.interstitial.asset"),x&&(x.id=i,this.id3Track||(this.id3Track=this.createTrack(this.media)),this.id3Track.addCue(x),x.addEventListener("enter",this.onEventCueEnter)))}if(!e.hasProgramDateTime)return;const{id3Track:c}=this,{dateRanges:u}=e,h=Object.keys(u);let f=this.dateRangeCuesAppended;if(c&&t){var g;if((g=c.cues)!=null&&g.length){const E=Object.keys(f).filter(v=>!h.includes(v));for(let v=E.length;v--;){var I;const x=E[v],D=(I=f[x])==null?void 0:I.cues;delete f[x],D&&Object.keys(D).forEach(L=>{const w=D[L];if(w){w.removeEventListener("enter",this.onEventCueEnter);try{c.removeCue(w)}catch{}}})}}else f=this.dateRangeCuesAppended={}}const m=e.fragments[e.fragments.length-1];if(!(h.length===0||!se(m?.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(let E=0;E<h.length;E++){const v=h[E],x=u[v],D=x.startTime,L=f[v],w=L?.cues||{};let N=L?.durationKnown||!1,K=Js;const{duration:p,endDate:$}=x;if($&&p!==null)K=D+p,N=!0;else if(x.endOnNext&&!N){const O=h.reduce((W,ie)=>{if(ie!==x.id){const X=u[ie];if(X.class===x.class&&X.startDate>x.startDate&&(!W||x.startDate<W.startDate))return X}return W},null);O&&(K=O.startTime,N=!0)}const F=Object.keys(x.attr);for(let O=0;O<F.length;O++){const W=F[O];if(!Pc(W))continue;const ie=w[W];if(ie)N&&!(L!=null&&L.durationKnown)?ie.endTime=K:Math.abs(ie.startTime-D)>.01&&(ie.startTime=D,ie.endTime=K);else if(o){let X=x.attr[W];_c(W)&&(X=Qn(X));const ue=Sn(o,D,K,{key:W,data:X},yt.dateRange);ue&&(ue.id=v,this.id3Track.addCue(ue),w[W]=ue,n&&(W==="X-ASSET-LIST"||W==="X-ASSET-URL")&&ue.addEventListener("enter",this.onEventCueEnter))}}f[v]={cues:w,dateRange:x,durationKnown:N}}}}}class ug{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.currentTime=0,this.stallCount=0,this._latency=null,this._targetLatencyUpdated=!1,this.onTimeupdate=()=>{const{media:t}=this,i=this.levelDetails;if(!t||!i)return;this.currentTime=t.currentTime;const s=this.computeLatency();if(s===null)return;this._latency=s;const{lowLatencyMode:r,maxLiveSyncPlaybackRate:n}=this.config;if(!r||n===1||!i.live)return;const o=this.targetLatency;if(o===null)return;const c=s-o,u=Math.min(this.maxLatency,o+i.targetduration);if(c<u&&c>.05&&this.forwardBufferLength>1){const f=Math.min(2,Math.max(1,n)),g=Math.round(2/(1+Math.exp(-.75*c-this.edgeStalled))*20)/20,I=Math.min(f,Math.max(1,g));this.changeMediaPlaybackRate(t,I)}else t.playbackRate!==1&&t.playbackRate!==0&&this.changeMediaPlaybackRate(t,1)},this.hls=e,this.config=e.config,this.registerListeners()}get levelDetails(){var e;return((e=this.hls)==null?void 0:e.latestLevelDetails)||null}get latency(){return this._latency||0}get maxLatency(){const{config:e}=this;if(e.liveMaxLatencyDuration!==void 0)return e.liveMaxLatencyDuration;const t=this.levelDetails;return t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){const e=this.levelDetails;if(e===null||this.hls===null)return null;const{holdBack:t,partHoldBack:i,targetduration:s}=e,{liveSyncDuration:r,liveSyncDurationCount:n,lowLatencyMode:o}=this.config,c=this.hls.userConfig;let u=o&&i||t;(this._targetLatencyUpdated||c.liveSyncDuration||c.liveSyncDurationCount||u===0)&&(u=r!==void 0?r:n*s);const h=s;return u+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,h)}set targetLatency(e){this.stallCount=0,this.config.liveSyncDuration=e,this._targetLatencyUpdated=!0}get liveSyncPosition(){const e=this.estimateLiveEdge(),t=this.targetLatency;if(e===null||t===null)return null;const i=this.levelDetails;if(i===null)return null;const s=i.edge,r=e-t-this.edgeStalled,n=s-i.totalduration,o=s-(this.config.lowLatencyMode&&i.partTarget||i.targetduration);return Math.min(Math.max(n,r),o)}get drift(){const e=this.levelDetails;return e===null?1:e.drift}get edgeStalled(){const e=this.levelDetails;if(e===null)return 0;const t=(this.config.lowLatencyMode&&e.partTarget||e.targetduration)*3;return Math.max(e.age-t,0)}get forwardBufferLength(){const{media:e}=this,t=this.levelDetails;if(!e||!t)return 0;const i=e.buffered.length;return(i?e.buffered.end(i-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.hls=null}registerListeners(){const{hls:e}=this;e&&(e.on(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(y.ERROR,this.onError,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(y.ERROR,this.onError,this))}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.onTimeupdate)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.onTimeupdate),this.media=null)}onManifestLoading(){this._latency=null,this.stallCount=0}onLevelUpdated(e,{details:t}){t.advanced&&this.onTimeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.onTimeupdate)}onError(e,t){var i;t.details===U.BUFFER_STALLED_ERROR&&(this.stallCount++,this.hls&&(i=this.levelDetails)!=null&&i.live&&this.hls.logger.warn("[latency-controller]: Stall detected, adjusting target latency"))}changeMediaPlaybackRate(e,t){var i,s;e.playbackRate!==t&&((i=this.hls)==null||i.logger.debug(`[latency-controller]: latency=${this.latency.toFixed(3)}, targetLatency=${(s=this.targetLatency)==null?void 0:s.toFixed(3)}, forwardBufferLength=${this.forwardBufferLength.toFixed(3)}: adjusting playback rate from ${e.playbackRate} to ${t}`),e.playbackRate=t)}estimateLiveEdge(){const e=this.levelDetails;return e===null?null:e.edge+e.age}computeLatency(){const e=this.estimateLiveEdge();return e===null?null:e-this.currentTime}}class cg extends en{constructor(e,t){super(e,"level-controller"),this._levels=[],this._firstLevel=-1,this._maxAutoLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=t,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(y.LEVEL_LOADED,this.onLevelLoaded,this),e.on(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(y.FRAG_BUFFERED,this.onFragBuffered,this),e.on(y.ERROR,this.onError,this)}_unregisterListeners(){const{hls:e}=this;e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(y.LEVEL_LOADED,this.onLevelLoaded,this),e.off(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(y.FRAG_BUFFERED,this.onFragBuffered,this),e.off(y.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}stopLoad(){this._levels.forEach(t=>{t.loadError=0,t.fragmentError=0}),super.stopLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1}onManifestLoading(e,t){this.resetLevels()}onManifestLoaded(e,t){const i=this.hls.config.preferManagedMediaSource,s=[],r={},n={};let o=!1,c=!1,u=!1;t.levels.forEach(h=>{const f=h.attrs;let{audioCodec:g,videoCodec:I}=h;g&&(h.audioCodec=g=Es(g,i)||void 0),I&&(I=h.videoCodec=ju(I));const{width:m,height:E,unknownCodecs:v}=h;let x=v?v.length:0;if(v)for(let O=x;O--;){const W=v[O];this.isAudioSupported(W)?(h.audioCodec=g=g?`${g},${W}`:W,x--,Pi.audio[g.substring(0,4)]=2):this.isVideoSupported(W)&&(h.videoCodec=I=I?`${I},${W}`:W,x--,Pi.video[I.substring(0,4)]=2)}if(o||(o=!!(m&&E)),c||(c=!!I),u||(u=!!g),x||g&&!this.isAudioSupported(g)||I&&!this.isVideoSupported(I)){this.log(`Some or all CODECS not supported "${f.CODECS}"`);return}const{CODECS:D,"FRAME-RATE":L,"HDCP-LEVEL":w,"PATHWAY-ID":N,RESOLUTION:K,"VIDEO-RANGE":p}=f,F=`${`${N||"."}-`}${h.bitrate}-${K}-${L}-${D}-${p}-${w}`;if(r[F])if(r[F].uri!==h.url&&!h.attrs["PATHWAY-ID"]){const O=n[F]+=1;h.attrs["PATHWAY-ID"]=new Array(O+1).join(".");const W=this.createLevel(h);r[F]=W,s.push(W)}else r[F].addGroupId("audio",f.AUDIO),r[F].addGroupId("text",f.SUBTITLES);else{const O=this.createLevel(h);r[F]=O,n[F]=1,s.push(O)}}),this.filterAndSortMediaOptions(s,t,o,c,u)}createLevel(e){const t=new Zi(e),i=e.supplemental;if(i!=null&&i.videoCodec&&!this.isVideoSupported(i.videoCodec)){const s=new Error(`SUPPLEMENTAL-CODECS not supported "${i.videoCodec}"`);this.log(s.message),t.supportedResult=Aa(s,[])}return t}isAudioSupported(e){return Er(e,"audio",this.hls.config.preferManagedMediaSource)}isVideoSupported(e){return Er(e,"video",this.hls.config.preferManagedMediaSource)}filterAndSortMediaOptions(e,t,i,s,r){let n=[],o=[],c=e;if((i||s)&&r&&(c=c.filter(({videoCodec:v,videoRange:x,width:D,height:L})=>(!!v||!!(D&&L))&&sc(x))),c.length===0){Promise.resolve().then(()=>{if(this.hls){let v="no level with compatible codecs found in manifest",x=v;t.levels.length&&(x=`one or more CODECS in variant not supported: ${Ge(t.levels.map(L=>L.attrs.CODECS).filter((L,w,N)=>N.indexOf(L)===w))}`,this.warn(x),v+=` (${x})`);const D=new Error(v);this.hls.trigger(y.ERROR,{type:de.MEDIA_ERROR,details:U.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:D,reason:x})}});return}t.audioTracks&&(n=t.audioTracks.filter(v=>!v.audioCodec||this.isAudioSupported(v.audioCodec)),kl(n)),t.subtitles&&(o=t.subtitles,kl(o));const u=c.slice(0);c.sort((v,x)=>{if(v.attrs["HDCP-LEVEL"]!==x.attrs["HDCP-LEVEL"])return(v.attrs["HDCP-LEVEL"]||"")>(x.attrs["HDCP-LEVEL"]||"")?1:-1;if(i&&v.height!==x.height)return v.height-x.height;if(v.frameRate!==x.frameRate)return v.frameRate-x.frameRate;if(v.videoRange!==x.videoRange)return Ts.indexOf(v.videoRange)-Ts.indexOf(x.videoRange);if(v.videoCodec!==x.videoCodec){const D=da(v.videoCodec),L=da(x.videoCodec);if(D!==L)return L-D}if(v.uri===x.uri&&v.codecSet!==x.codecSet){const D=ys(v.codecSet),L=ys(x.codecSet);if(D!==L)return L-D}return v.averageBitrate!==x.averageBitrate?v.averageBitrate-x.averageBitrate:0});let h=u[0];if(this.steering&&(c=this.steering.filterParsedLevels(c),c.length!==u.length)){for(let v=0;v<u.length;v++)if(u[v].pathwayId===c[0].pathwayId){h=u[v];break}}this._levels=c;for(let v=0;v<c.length;v++)if(c[v]===h){var f;this._firstLevel=v;const x=h.bitrate,D=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${c.length} level(s) found, first bitrate: ${x}`),((f=this.hls.userConfig)==null?void 0:f.abrEwmaDefaultEstimate)===void 0){const L=Math.min(x,this.hls.config.abrEwmaDefaultEstimateMax);L>D&&D===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=L)}break}const g=r&&!s,I=this.hls.config,m=!!(I.audioStreamController&&I.audioTrackController),E={levels:c,audioTracks:n,subtitleTracks:o,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:r,video:s,altAudio:m&&!g&&n.some(v=>!!v.url)};this.hls.trigger(y.MANIFEST_PARSED,E)}get levels(){return this._levels.length===0?null:this._levels}get loadLevelObj(){return this.currentLevel}get level(){return this.currentLevelIndex}set level(e){const t=this._levels;if(t.length===0)return;if(e<0||e>=t.length){const h=new Error("invalid level idx"),f=e<0;if(this.hls.trigger(y.ERROR,{type:de.OTHER_ERROR,details:U.LEVEL_SWITCH_ERROR,level:e,fatal:f,error:h,reason:h.message}),f)return;e=Math.min(e,t.length-1)}const i=this.currentLevelIndex,s=this.currentLevel,r=s?s.attrs["PATHWAY-ID"]:void 0,n=t[e],o=n.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=n,i===e&&s&&r===o)return;this.log(`Switching to level ${e} (${n.height?n.height+"p ":""}${n.videoRange?n.videoRange+" ":""}${n.codecSet?n.codecSet+" ":""}@${n.bitrate})${o?" with Pathway "+o:""} from level ${i}${r?" with Pathway "+r:""}`);const c={level:e,attrs:n.attrs,details:n.details,bitrate:n.bitrate,averageBitrate:n.averageBitrate,maxBitrate:n.maxBitrate,realBitrate:n.realBitrate,width:n.width,height:n.height,codecSet:n.codecSet,audioCodec:n.audioCodec,videoCodec:n.videoCodec,audioGroups:n.audioGroups,subtitleGroups:n.subtitleGroups,loaded:n.loaded,loadError:n.loadError,fragmentError:n.fragmentError,name:n.name,id:n.id,uri:n.uri,url:n.url,urlId:0,audioGroupIds:n.audioGroupIds,textGroupIds:n.textGroupIds};this.hls.trigger(y.LEVEL_SWITCHING,c);const u=n.details;if(!u||u.live){const h=this.switchParams(n.uri,s?.details,u);this.loadPlaylist(h)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(e){this.manualLevelIndex=e,this._startLevel===void 0&&(this._startLevel=e),e!==-1&&(this.level=e)}get firstLevel(){return this._firstLevel}set firstLevel(e){this._firstLevel=e}get startLevel(){if(this._startLevel===void 0){const e=this.hls.config.startLevel;return e!==void 0?e:this.hls.firstAutoLevel}return this._startLevel}set startLevel(e){this._startLevel=e}get pathways(){return this.steering?this.steering.pathways():[]}get pathwayPriority(){return this.steering?this.steering.pathwayPriority:null}set pathwayPriority(e){if(this.steering){const t=this.steering.pathways(),i=e.filter(s=>t.indexOf(s)!==-1);if(e.length<1){this.warn(`pathwayPriority ${e} should contain at least one pathway from list: ${t}`);return}this.steering.pathwayPriority=i}}onError(e,t){t.fatal||!t.context||t.context.type===be.LEVEL&&t.context.level===this.level&&this.checkRetry(t)}onFragBuffered(e,{frag:t}){if(t!==void 0&&t.type===he.MAIN){const i=t.elementaryStreams;if(!Object.keys(i).some(r=>!!i[r]))return;const s=this._levels[t.level];s!=null&&s.loadError&&(this.log(`Resetting level error count of ${s.loadError} on frag buffered`),s.loadError=0)}}onLevelLoaded(e,t){var i;const{level:s,details:r}=t,n=t.levelInfo;if(!n){var o;this.warn(`Invalid level index ${s}`),(o=t.deliveryDirectives)!=null&&o.skip&&(r.deltaUpdateFailed=!0);return}if(n===this.currentLevel||t.withoutMultiVariant){n.fragmentError===0&&(n.loadError=0);let c=n.details;c===t.details&&c.advanced&&(c=void 0),this.playlistLoaded(s,t,c)}else(i=t.deliveryDirectives)!=null&&i.skip&&(r.deltaUpdateFailed=!0)}loadPlaylist(e){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentLevel)&&this.scheduleLoading(this.currentLevel,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);const i=this.getUrlWithDirectives(e.uri,t),s=this.currentLevelIndex,r=e.attrs["PATHWAY-ID"],n=e.details,o=n?.age;this.log(`Loading level index ${s}${t?.msn!==void 0?" at sn "+t.msn+" part "+t.part:""}${r?" Pathway "+r:""}${o&&n.live?" age "+o.toFixed(1)+(n.type&&" "+n.type||""):""} ${i}`),this.hls.trigger(y.LEVEL_LOADING,{url:i,level:s,levelInfo:e,pathwayId:e.attrs["PATHWAY-ID"],id:0,deliveryDirectives:t||null})}get nextLoadLevel(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){this.level=e,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=e)}removeLevel(e){var t;if(this._levels.length===1)return;const i=this._levels.filter((r,n)=>n!==e?!0:(this.steering&&this.steering.removeLevel(r),r===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,r.details&&r.details.fragments.forEach(o=>o.level=-1)),!1));oo(i),this._levels=i,this.currentLevelIndex>-1&&(t=this.currentLevel)!=null&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.manualLevelIndex>-1&&(this.manualLevelIndex=this.currentLevelIndex);const s=i.length-1;this._firstLevel=Math.min(this._firstLevel,s),this._startLevel&&(this._startLevel=Math.min(this._startLevel,s)),this.hls.trigger(y.LEVELS_UPDATED,{levels:i})}onLevelsUpdated(e,{levels:t}){this._levels=t}checkMaxAutoUpdated(){const{autoLevelCapping:e,maxAutoLevel:t,maxHdcpLevel:i}=this.hls;this._maxAutoLevel!==t&&(this._maxAutoLevel=t,this.hls.trigger(y.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:i}))}}function kl(a){const e={};a.forEach(t=>{const i=t.groupId||"";t.id=e[i]=e[i]||0,e[i]++})}function Ml(){return self.SourceBuffer||self.WebKitSourceBuffer}function Ol(){if(!ri())return!1;const e=Ml();return!e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function"}function hg(){if(!Ol())return!1;const a=ri();return typeof a?.isTypeSupported=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(e=>a.isTypeSupported(Xi(e,"video")))||["mp4a.40.2","fLaC"].some(e=>a.isTypeSupported(Xi(e,"audio"))))}function dg(){var a;const e=Ml();return typeof(e==null||(a=e.prototype)==null?void 0:a.changeType)=="function"}const fg=100;class gg extends Ur{constructor(e,t,i){super(e,t,i,"stream-controller",he.MAIN),this.audioCodecSwap=!1,this.level=-1,this._forceStartLoad=!1,this._hasEnoughToStart=!1,this.altAudio=0,this.audioOnly=!1,this.fragPlaying=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this.onMediaPlaying=()=>{this.tick()},this.onMediaSeeked=()=>{const s=this.media,r=s?s.currentTime:null;if(r===null||!se(r)||(this.log(`Media seeked to ${r.toFixed(3)}`),!this.getBufferedFrag(r)))return;const n=this.getFwdBufferInfoAtPos(s,r,he.MAIN,0);if(n===null||n.len===0){this.warn(`Main forward buffer length at ${r} on "seeked" event ${n?n.len:"empty"})`);return}this.tick()},this.registerListeners()}registerListeners(){super.registerListeners();const{hls:e}=this;e.on(y.MANIFEST_PARSED,this.onManifestParsed,this),e.on(y.LEVEL_LOADING,this.onLevelLoading,this),e.on(y.LEVEL_LOADED,this.onLevelLoaded,this),e.on(y.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(y.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(y.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(y.BUFFER_CREATED,this.onBufferCreated,this),e.on(y.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(y.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){super.unregisterListeners();const{hls:e}=this;e.off(y.MANIFEST_PARSED,this.onManifestParsed,this),e.off(y.LEVEL_LOADED,this.onLevelLoaded,this),e.off(y.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(y.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(y.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(y.BUFFER_CREATED,this.onBufferCreated,this),e.off(y.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(y.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),super.onHandlerDestroying()}startLoad(e,t){if(this.levels){const{lastCurrentTime:i,hls:s}=this;if(this.stopLoad(),this.setInterval(fg),this.level=-1,!this.startFragRequested){let r=s.startLevel;r===-1&&(s.config.testBandwidth&&this.levels.length>1?(r=0,this.bitrateTest=!0):r=s.firstAutoLevel),s.nextLoadLevel=r,this.level=s.loadLevel,this._hasEnoughToStart=!!t}i>0&&e===-1&&!t&&(this.log(`Override startPosition with lastCurrentTime @${i.toFixed(3)}`),e=i),this.state=j.IDLE,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}else this._forceStartLoad=!0,this.state=j.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case j.WAITING_LEVEL:{const{levels:e,level:t}=this,i=e?.[t],s=i?.details;if(s&&(!s.live||this.levelLastLoaded===i&&!this.waitForLive(i))){if(this.waitForCdnTuneIn(s))break;this.state=j.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=j.IDLE;break}break}case j.FRAG_LOADING_WAITING_RETRY:this.checkRetryDate();break}this.state===j.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){var e;super.onTickEnd(),(e=this.media)!=null&&e.readyState&&this.media.seeking===!1&&(this.lastCurrentTime=this.media.currentTime),this.checkFragmentChanged()}doTickIdle(){const{hls:e,levelLastLoaded:t,levels:i,media:s}=this;if(t===null||!s&&!this.primaryPrefetch&&(this.startFragRequested||!e.config.startFragPrefetch)||this.altAudio&&this.audioOnly)return;const r=this.buffering?e.nextLoadLevel:e.loadLevel;if(!(i!=null&&i[r]))return;const n=i[r],o=this.getMainFwdBufferInfo();if(o===null)return;const c=this.getLevelDetails();if(c&&this._streamEnded(o,c)){const E={};this.altAudio===2&&(E.type="video"),this.hls.trigger(y.BUFFER_EOS,E),this.state=j.ENDED;return}if(!this.buffering)return;e.loadLevel!==r&&e.manualLevel===-1&&this.log(`Adapting to level ${r} from level ${this.level}`),this.level=e.nextLoadLevel=r;const u=n.details;if(!u||this.state===j.WAITING_LEVEL||this.waitForLive(n)){this.level=r,this.state=j.WAITING_LEVEL,this.startFragRequested=!1;return}const h=o.len,f=this.getMaxBufferLength(n.maxBitrate);if(h>=f)return;this.backtrackFragment&&this.backtrackFragment.start>o.end&&(this.backtrackFragment=null);const g=this.backtrackFragment?this.backtrackFragment.start:o.end;let I=this.getNextFragment(g,u);if(this.couldBacktrack&&!this.fragPrevious&&I&&qe(I)&&this.fragmentTracker.getState(I)!==Qe.OK){var m;const v=((m=this.backtrackFragment)!=null?m:I).sn-u.startSN,x=u.fragments[v-1];x&&I.cc===x.cc&&(I=x,this.fragmentTracker.removeFragment(x))}else this.backtrackFragment&&o.len&&(this.backtrackFragment=null);if(I&&this.isLoopLoading(I,g)){if(!I.gap){const v=this.audioOnly&&!this.altAudio?Ue.AUDIO:Ue.VIDEO,x=(v===Ue.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;x&&this.afterBufferFlushed(x,v,he.MAIN)}I=this.getNextFragmentLoopLoading(I,u,o,he.MAIN,f)}I&&(I.initSegment&&!I.initSegment.data&&!this.bitrateTest&&(I=I.initSegment),this.loadFragment(I,n,g))}loadFragment(e,t,i){const s=this.fragmentTracker.getState(e);s===Qe.NOT_LOADED||s===Qe.PARTIAL?qe(e)?this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,t)):super.loadFragment(e,t,i):this._loadInitSegment(e,t):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,he.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(t!=null&&t.readyState){let i;const s=this.getAppendedFrag(t.currentTime);s&&s.start>1&&this.flushMainBuffer(0,s.start-1);const r=this.getLevelDetails();if(r!=null&&r.live){const o=this.getMainFwdBufferInfo();if(!o||o.len<r.targetduration*2)return}if(!t.paused&&e){const o=this.hls.nextLoadLevel,c=e[o],u=this.fragLastKbps;u&&this.fragCurrent?i=this.fragCurrent.duration*c.maxBitrate/(1e3*u)+1:i=0}else i=0;const n=this.getBufferedFrag(t.currentTime+i);if(n){const o=this.followingBufferedFrag(n);if(o){this.abortCurrentFrag();const c=o.maxStartPTS?o.maxStartPTS:o.start,u=o.duration,h=Math.max(n.end,c+Math.min(Math.max(u-this.config.maxFragLookUpTolerance,u*(this.couldBacktrack?.5:.125)),u*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(h,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 j.KEY_LOADING:case j.FRAG_LOADING:case j.FRAG_LOADING_WAITING_RETRY:case j.PARSING:case j.PARSED:this.state=j.IDLE;break}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,this.altAudio===2?"video":null)}onMediaAttached(e,t){super.onMediaAttached(e,t);const i=t.media;ot(i,"playing",this.onMediaPlaying),ot(i,"seeked",this.onMediaSeeked)}onMediaDetaching(e,t){const{media:i}=this;i&&(ht(i,"playing",this.onMediaPlaying),ht(i,"seeked",this.onMediaSeeked)),this.videoBuffer=null,this.fragPlaying=null,super.onMediaDetaching(e,t),!t.transferMedia&&(this._hasEnoughToStart=!1)}onManifestLoading(){super.onManifestLoading(),this.log("Trigger BUFFER_RESET"),this.hls.trigger(y.BUFFER_RESET,void 0),this.couldBacktrack=!1,this.fragLastKbps=0,this.fragPlaying=this.backtrackFragment=null,this.altAudio=0,this.audioOnly=!1}onManifestParsed(e,t){let i=!1,s=!1;for(let r=0;r<t.levels.length;r++){const n=t.levels[r].audioCodec;n&&(i=i||n.indexOf("mp4a.40.2")!==-1,s=s||n.indexOf("mp4a.40.5")!==-1)}this.audioCodecSwitch=i&&s&&!dg(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1}onLevelLoading(e,t){const{levels:i}=this;if(!i||this.state!==j.IDLE)return;const s=t.levelInfo;(!s.details||s.details.live&&(this.levelLastLoaded!==s||s.details.expired)||this.waitForCdnTuneIn(s.details))&&(this.state=j.WAITING_LEVEL)}onLevelLoaded(e,t){var i;const{levels:s,startFragRequested:r}=this,n=t.level,o=t.details,c=o.totalduration;if(!s){this.warn(`Levels were reset while loading level ${n}`);return}this.log(`Level ${n} loaded [${o.startSN},${o.endSN}]${o.lastPartSn?`[part-${o.lastPartSn}-${o.lastPartIndex}]`:""}, cc [${o.startCC}, ${o.endCC}] duration:${c}`);const u=t.levelInfo,h=this.fragCurrent;h&&(this.state===j.FRAG_LOADING||this.state===j.FRAG_LOADING_WAITING_RETRY)&&h.level!==t.level&&h.loader&&this.abortCurrentFrag();let f=0;if(o.live||(i=u.details)!=null&&i.live){var g;if(this.checkLiveUpdate(o),o.deltaUpdateFailed)return;f=this.alignPlaylists(o,u.details,(g=this.levelLastLoaded)==null?void 0:g.details)}if(u.details=o,this.levelLastLoaded=u,r||this.setStartPosition(o,f),this.hls.trigger(y.LEVEL_UPDATED,{details:o,level:n}),this.state===j.WAITING_LEVEL){if(this.waitForCdnTuneIn(o))return;this.state=j.IDLE}r&&o.live&&this.synchronizeToLiveEdge(o),this.tick()}synchronizeToLiveEdge(e){const{config:t,media:i}=this;if(!i)return;const s=this.hls.liveSyncPosition,r=this.getLoadPosition(),n=e.fragmentStart,o=e.edge,c=r>=n-t.maxFragLookUpTolerance&&r<=o;if(s!==null&&i.duration>s&&(r<s||!c)){const h=t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;if((!c&&i.readyState<4||r<o-h)&&(this._hasEnoughToStart||(this.nextLoadPosition=s),i.readyState))if(this.warn(`Playback: ${r.toFixed(3)} is located too far from the end of live sliding playlist: ${o}, reset currentTime to : ${s.toFixed(3)}`),this.config.liveSyncMode==="buffered"){var u;const f=ye.bufferInfo(i,s,0);if(!((u=f.buffered)!=null&&u.length)){i.currentTime=s;return}if(f.start<=r){i.currentTime=s;return}const{nextStart:I}=ye.bufferedInfo(f.buffered,r,0);I&&(i.currentTime=I)}else i.currentTime=s}}_handleFragmentLoadProgress(e){var t;const i=e.frag,{part:s,payload:r}=e,{levels:n}=this;if(!n){this.warn(`Levels were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);return}const o=n[i.level];if(!o){this.warn(`Level ${i.level} not found on progress`);return}const c=o.details;if(!c){this.warn(`Dropping fragment ${i.sn} of level ${i.level} after level details were reset`),this.fragmentTracker.removeFragment(i);return}const u=o.videoCodec,h=c.PTSKnown||!c.live,f=(t=i.initSegment)==null?void 0:t.data,g=this._getAudioCodec(o),I=this.transmuxer=this.transmuxer||new Uo(this.hls,he.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),m=s?s.index:-1,E=m!==-1,v=new Dr(i.level,i.sn,i.stats.chunkCount,r.byteLength,m,E),x=this.initPTS[i.cc];I.push(r,f,g,u,i,s,c.totalduration,h,v,x)}onAudioTrackSwitching(e,t){const i=this.hls,s=this.altAudio===2;if(xs(t.url,i))this.altAudio=1;else{if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;const n=this.fragCurrent;n&&(this.log("Switching to main audio track, cancel main fragment load"),n.abortRequests(),this.fragmentTracker.removeFragment(n)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();if(s){this.fragmentTracker.removeAllFragments(),i.once(y.BUFFER_FLUSHED,()=>{this.hls&&this.hls.trigger(y.AUDIO_TRACK_SWITCHED,t)}),i.trigger(y.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});return}i.trigger(y.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){const i=xs(t.url,this.hls);if(i){const s=this.videoBuffer;s&&this.mediaBuffer!==s&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=s)}this.altAudio=i?2:0,this.tick()}onBufferCreated(e,t){const i=t.tracks;let s,r,n=!1;for(const o in i){const c=i[o];if(c.id==="main"){if(r=o,s=c,o==="video"){const u=i[o];u&&(this.videoBuffer=u.buffer)}}else n=!0}n&&s?(this.log(`Alternate track found, use ${r}.buffered to schedule main fragment loading`),this.mediaBuffer=s.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){const{frag:i,part:s}=t,r=i.type===he.MAIN;if(r){if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${s?" p: "+s.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}`),this.state===j.PARSED&&(this.state=j.IDLE);return}const o=s?s.stats:i.stats;this.fragLastKbps=Math.round(8*o.total/(o.buffering.end-o.loading.first)),qe(i)&&(this.fragPrevious=i),this.fragBufferedComplete(i,s)}const n=this.media;n&&(!this._hasEnoughToStart&&ye.getBuffered(n).length&&(this._hasEnoughToStart=!0,this.seekToStartPos()),r&&this.tick())}get hasEnoughToStart(){return this._hasEnoughToStart}onError(e,t){var i;if(t.fatal){this.state=j.ERROR;return}switch(t.details){case U.FRAG_GAP:case U.FRAG_PARSING_ERROR:case U.FRAG_DECRYPT_ERROR:case U.FRAG_LOAD_ERROR:case U.FRAG_LOAD_TIMEOUT:case U.KEY_LOAD_ERROR:case U.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(he.MAIN,t);break;case U.LEVEL_LOAD_ERROR:case U.LEVEL_LOAD_TIMEOUT:case U.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===j.WAITING_LEVEL&&((i=t.context)==null?void 0:i.type)===be.LEVEL&&(this.state=j.IDLE);break;case U.BUFFER_ADD_CODEC_ERROR:case U.BUFFER_APPEND_ERROR:if(t.parent!=="main")return;this.reduceLengthAndFlushBuffer(t)&&this.resetLoadingState();break;case U.BUFFER_FULL_ERROR:if(t.parent!=="main")return;this.reduceLengthAndFlushBuffer(t)&&(!this.config.interstitialsController&&this.config.assetPlayerId?this._hasEnoughToStart=!0:this.flushMainBuffer(0,Number.POSITIVE_INFINITY));break;case U.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onFragLoadEmergencyAborted(){this.state=j.IDLE,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==Ue.AUDIO||!this.altAudio){const i=(t===Ue.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;i&&(this.afterBufferFlushed(i,t,he.MAIN),this.tick())}}onLevelsUpdated(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level,this.level===-1&&this.resetWhenMissingContext(this.fragCurrent)),this.levels=t.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){const{media:e}=this;if(!e)return;const t=e.currentTime;let i=this.startPosition;if(i>=0&&t<i){if(e.seeking){this.log(`could not seek to ${i}, already seeking at ${t}`);return}const s=this.timelineOffset;s&&i&&(i+=s);const r=this.getLevelDetails(),n=ye.getBuffered(e),o=n.length?n.start(0):0,c=o-i,u=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);(this.config.startOnSegmentBoundary||c>0&&(c<u||this.loadingParts&&c<2*(r?.partTarget||0)))&&(this.log(`adjusting start position by ${c} to match buffer start`),i+=c,this.startPosition=i),t<i&&(this.log(`seek to target start position ${i} from current time ${t} buffer start ${o}`),e.currentTime=i)}}_getAudioCodec(e){let t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t.indexOf("mp4a.40.5")!==-1?t="mp4a.40.2":t="mp4a.40.5"),t}_loadBitrateTestFrag(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then(i=>{const{hls:s}=this,r=i?.frag;if(!r||this.fragContextChanged(r))return;t.fragmentError=0,this.state=j.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;const n=r.stats;n.parsing.start=n.parsing.end=n.buffering.start=n.buffering.end=self.performance.now(),s.trigger(y.FRAG_LOADED,i),r.bitrateTest=!1}).catch(i=>{this.state===j.STOPPED||this.state===j.ERROR||(this.warn(i),this.resetFragmentLoading(e))})}_handleTransmuxComplete(e){const t=this.playlistType,{hls:i}=this,{remuxResult:s,chunkMeta:r}=e,n=this.getCurrentContext(r);if(!n){this.resetWhenMissingContext(r);return}const{frag:o,part:c,level:u}=n,{video:h,text:f,id3:g,initSegment:I}=s,{details:m}=u,E=this.altAudio?void 0:s.audio;if(this.fragContextChanged(o)){this.fragmentTracker.removeFragment(o);return}if(this.state=j.PARSING,I){const v=I.tracks;if(v){const w=o.initSegment||o;if(this.unhandledEncryptionError(I,o))return;this._bufferInitSegment(u,v,w,r),i.trigger(y.FRAG_PARSING_INIT_SEGMENT,{frag:w,id:t,tracks:v})}const x=I.initPTS,D=I.timescale,L=this.initPTS[o.cc];if(se(x)&&(!L||L.baseTime!==x||L.timescale!==D)){const w=I.trackId;this.initPTS[o.cc]={baseTime:x,timescale:D,trackId:w},i.trigger(y.INIT_PTS_FOUND,{frag:o,id:t,initPTS:x,timescale:D,trackId:w})}}if(h&&m){E&&h.type==="audiovideo"&&this.logMuxedErr(o);const v=m.fragments[o.sn-1-m.startSN],x=o.sn===m.startSN,D=!v||o.cc>v.cc;if(s.independent!==!1){const{startPTS:L,endPTS:w,startDTS:N,endDTS:K}=h;if(c)c.elementaryStreams[h.type]={startPTS:L,endPTS:w,startDTS:N,endDTS:K};else if(h.firstKeyFrame&&h.independent&&r.id===1&&!D&&(this.couldBacktrack=!0),h.dropped&&h.independent){const p=this.getMainFwdBufferInfo(),$=(p?p.end:this.getLoadPosition())+this.config.maxBufferHole,F=h.firstKeyFramePTS?h.firstKeyFramePTS:L;if(!x&&$<F-this.config.maxBufferHole&&!D){this.backtrack(o);return}else D&&(o.gap=!0);o.setElementaryStreamInfo(h.type,o.start,w,o.start,K,!0)}else x&&L-(m.appliedTimelineOffset||0)>Zs&&(o.gap=!0);o.setElementaryStreamInfo(h.type,L,w,N,K),this.backtrackFragment&&(this.backtrackFragment=o),this.bufferFragmentData(h,o,c,r,x||D)}else if(x||D)o.gap=!0;else{this.backtrack(o);return}}if(E){const{startPTS:v,endPTS:x,startDTS:D,endDTS:L}=E;c&&(c.elementaryStreams[Ue.AUDIO]={startPTS:v,endPTS:x,startDTS:D,endDTS:L}),o.setElementaryStreamInfo(Ue.AUDIO,v,x,D,L),this.bufferFragmentData(E,o,c,r)}if(m&&g!=null&&g.samples.length){const v={id:t,frag:o,details:m,samples:g.samples};i.trigger(y.FRAG_PARSING_METADATA,v)}if(m&&f){const v={id:t,frag:o,details:m,samples:f.samples};i.trigger(y.FRAG_PARSING_USERDATA,v)}}logMuxedErr(e){this.warn(`${qe(e)?"Media":"Init"} segment with muxed audiovideo where only video expected: ${e.url}`)}_bufferInitSegment(e,t,i,s){if(this.state!==j.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&(delete t.audio,t.audiovideo&&this.logMuxedErr(i));const{audio:r,video:n,audiovideo:o}=t;if(r){const u=e.audioCodec;let h=vs(r.codec,u);h==="mp4a"&&(h="mp4a.40.5");const f=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){h&&(h.indexOf("mp4a.40.5")!==-1?h="mp4a.40.2":h="mp4a.40.5");const g=r.metadata;g&&"channelCount"in g&&(g.channelCount||1)!==1&&f.indexOf("firefox")===-1&&(h="mp4a.40.5")}h&&h.indexOf("mp4a.40.5")!==-1&&f.indexOf("android")!==-1&&r.container!=="audio/mpeg"&&(h="mp4a.40.2",this.log(`Android: force audio codec to ${h}`)),u&&u!==h&&this.log(`Swapping manifest audio codec "${u}" for "${h}"`),r.levelCodec=h,r.id=he.MAIN,this.log(`Init audio buffer, container:${r.container}, codecs[selected/level/parsed]=[${h||""}/${u||""}/${r.codec}]`),delete t.audiovideo}if(n){n.levelCodec=e.videoCodec,n.id=he.MAIN;const u=n.codec;if(u?.length===4)switch(u){case"hvc1":case"hev1":n.codec="hvc1.1.6.L120.90";break;case"av01":n.codec="av01.0.04M.08";break;case"avc1":n.codec="avc1.42e01e";break}this.log(`Init video buffer, container:${n.container}, codecs[level/parsed]=[${e.videoCodec||""}/${u}]${n.codec!==u?" parsed-corrected="+n.codec:""}${n.supplemental?" supplemental="+n.supplemental:""}`),delete t.audiovideo}o&&(this.log(`Init audiovideo buffer, container:${o.container}, codecs[level/parsed]=[${e.codecs}/${o.codec}]`),delete t.video,delete t.audio);const c=Object.keys(t);if(c.length){if(this.hls.trigger(y.BUFFER_CODECS,t),!this.hls)return;c.forEach(u=>{const f=t[u].initSegment;f!=null&&f.byteLength&&this.hls.trigger(y.BUFFER_APPENDING,{type:u,data:f,frag:i,part:null,chunkMeta:s,parent:i.type})})}this.tickImmediate()}getMainFwdBufferInfo(){const e=this.mediaBuffer&&this.altAudio===2?this.mediaBuffer:this.media;return this.getFwdBufferInfo(e,he.MAIN)}get maxBufferLength(){const{levels:e,level:t}=this,i=e?.[t];return i?this.getMaxBufferLength(i.maxBitrate):this.config.maxBufferLength}backtrack(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=j.IDLE}checkFragmentChanged(){const e=this.media;let t=null;if(e&&e.readyState>1&&e.seeking===!1){const i=e.currentTime;if(ye.isBuffered(e,i)?t=this.getAppendedFrag(i):ye.isBuffered(e,i+.1)&&(t=this.getAppendedFrag(i+.1)),t){this.backtrackFragment=null;const s=this.fragPlaying,r=t.level;(!s||t.sn!==s.sn||s.level!==r)&&(this.fragPlaying=t,this.hls.trigger(y.FRAG_CHANGED,{frag:t}),(!s||s.level!==r)&&this.hls.trigger(y.LEVEL_SWITCHED,{level:r}))}}}get nextLevel(){const e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){var e;if(this.fragPlaying)return this.fragPlaying;const t=((e=this.media)==null?void 0:e.currentTime)||this.lastCurrentTime;return se(t)?this.getAppendedFrag(t):null}get currentProgramDateTime(){var e;const t=((e=this.media)==null?void 0:e.currentTime)||this.lastCurrentTime;if(se(t)){const i=this.getLevelDetails(),s=this.currentFrag||(i?yi(null,i.fragments,t):null);if(s){const r=s.programDateTime;if(r!==null){const n=r+(t-s.start)*1e3;return new Date(n)}}}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 pg extends Tt{constructor(e,t){super("key-loader",t),this.config=void 0,this.keyIdToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(const i in this.keyIdToKeyInfo){const s=this.keyIdToKeyInfo[i].loader;if(s){var t;if(e&&e!==((t=s.context)==null?void 0:t.frag.type))return;s.abort()}}}detach(){for(const e in this.keyIdToKeyInfo){const t=this.keyIdToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyIdToKeyInfo[e]}}destroy(){this.detach();for(const e in this.keyIdToKeyInfo){const t=this.keyIdToKeyInfo[e].loader;t&&t.destroy()}this.keyIdToKeyInfo={}}createKeyLoadError(e,t=U.KEY_LOAD_ERROR,i,s,r){return new zt({type:de.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:r,error:i,networkDetails:s})}loadClear(e,t,i){if(this.emeController&&this.config.emeEnabled&&!this.emeController.getSelectedKeySystemFormats().length){if(t.length)for(let s=0,r=t.length;s<r;s++){const n=t[s];if(e.cc<=n.cc&&(!qe(e)||!qe(n)||e.sn<n.sn)||!i&&s==r-1)return this.emeController.selectKeySystemFormat(n).then(o=>{if(!this.emeController)return;n.setKeyFormat(o);const c=_s(o);if(c)return this.emeController.getKeySystemAccess([c])})}if(this.config.requireKeySystemAccessOnStart){const s=Qi(this.config);if(s.length)return this.emeController.getKeySystemAccess(s)}}return null}load(e){return!e.decryptdata&&e.encrypted&&this.emeController&&this.config.emeEnabled?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}loadInternal(e,t){var i,s;t&&e.setKeyFormat(t);const r=e.decryptdata;if(!r){const h=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,U.KEY_LOAD_ERROR,h))}const n=r.uri;if(!n)return Promise.reject(this.createKeyLoadError(e,U.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${n}"`)));const o=xn(r);let c=this.keyIdToKeyInfo[o];if((i=c)!=null&&i.decryptdata.key)return r.key=c.decryptdata.key,Promise.resolve({frag:e,keyInfo:c});if((s=c)!=null&&s.keyLoadPromise){var u;switch((u=c.mediaKeySessionContext)==null?void 0:u.keyStatus){case"usable":case"usable-in-future":return c.keyLoadPromise.then(f=>{const{keyInfo:g}=f;return r.key=g.decryptdata.key,{frag:e,keyInfo:g}})}}switch(this.log(`Loading key ${It(r.keyId||[])} from ${e.type} ${e.level}`),c=this.keyIdToKeyInfo[o]={decryptdata:r,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},r.method){case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return r.keyFormat==="identity"?this.loadKeyHTTP(c,e):this.loadKeyEME(c,e);case"AES-128":case"AES-256":case"AES-256-CTR":return this.loadKeyHTTP(c,e);default:return Promise.reject(this.createKeyLoadError(e,U.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${r.method}"`)))}}loadKeyEME(e,t){const i={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){const s=this.emeController.loadKey(i);return(e.keyLoadPromise=s.then(r=>(e.mediaKeySessionContext=r,i))).catch(r=>{throw e.keyLoadPromise=null,r.data&&(r.data.frag=t),r})}return Promise.resolve(i)}loadKeyHTTP(e,t){const i=this.config,s=i.loader,r=new s(i);return t.keyLoader=e.loader=r,e.keyLoadPromise=new Promise((n,o)=>{const c={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},u=i.keyLoadPolicy.default,h={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},f={onSuccess:(g,I,m,E)=>{const{frag:v,keyInfo:x,url:D}=m,L=xn(x.decryptdata)||D;if(!v.decryptdata||x!==this.keyIdToKeyInfo[L])return o(this.createKeyLoadError(v,U.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),E));x.decryptdata.key=v.decryptdata.key=new Uint8Array(g.data),v.keyLoader=null,x.loader=null,n({frag:v,keyInfo:x})},onError:(g,I,m,E)=>{this.resetLoader(I),o(this.createKeyLoadError(t,U.KEY_LOAD_ERROR,new Error(`HTTP Error ${g.code} loading key ${g.text}`),m,Be({url:c.url,data:void 0},g)))},onTimeout:(g,I,m)=>{this.resetLoader(I),o(this.createKeyLoadError(t,U.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),m))},onAbort:(g,I,m)=>{this.resetLoader(I),o(this.createKeyLoadError(t,U.INTERNAL_ABORTED,new Error("key loading aborted"),m))}};r.load(c,h,f)})}resetLoader(e){const{frag:t,keyInfo:i,url:s}=e,r=i.loader;t.keyLoader===r&&(t.keyLoader=null,i.loader=null);const n=xn(i.decryptdata)||s;delete this.keyIdToKeyInfo[n],r&&r.destroy()}}function xn(a){const e=a.keyId;return e?It(e):a.uri}function Fl(a){const{type:e}=a;switch(e){case be.AUDIO_TRACK:return he.AUDIO;case be.SUBTITLE_TRACK:return he.SUBTITLE;default:return he.MAIN}}function bn(a,e){let t=a.url;return(t===void 0||t.indexOf("data:")===0)&&(t=e.url),t}class Ag{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){const{hls:e}=this;e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.LEVEL_LOADING,this.onLevelLoading,this),e.on(y.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(y.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.on(y.LEVELS_UPDATED,this.onLevelsUpdated,this)}unregisterListeners(){const{hls:e}=this;e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.LEVEL_LOADING,this.onLevelLoading,this),e.off(y.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(y.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.off(y.LEVELS_UPDATED,this.onLevelsUpdated,this)}createInternalLoader(e){const t=this.hls.config,i=t.pLoader,s=t.loader,r=i||s,n=new r(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:i}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:be.MANIFEST,url:i,deliveryDirectives:null,levelOrTrack:null})}onLevelLoading(e,t){const{id:i,level:s,pathwayId:r,url:n,deliveryDirectives:o,levelInfo:c}=t;this.load({id:i,level:s,pathwayId:r,responseType:"text",type:be.LEVEL,url:n,deliveryDirectives:o,levelOrTrack:c})}onAudioTrackLoading(e,t){const{id:i,groupId:s,url:r,deliveryDirectives:n,track:o}=t;this.load({id:i,groupId:s,level:null,responseType:"text",type:be.AUDIO_TRACK,url:r,deliveryDirectives:n,levelOrTrack:o})}onSubtitleTrackLoading(e,t){const{id:i,groupId:s,url:r,deliveryDirectives:n,track:o}=t;this.load({id:i,groupId:s,level:null,responseType:"text",type:be.SUBTITLE_TRACK,url:r,deliveryDirectives:n,levelOrTrack:o})}onLevelsUpdated(e,t){const i=this.loaders[be.LEVEL];if(i){const s=i.context;s&&!t.levels.some(r=>r===s.levelOrTrack)&&(i.abort(),delete this.loaders[be.LEVEL])}}load(e){var t;const i=this.hls.config;let s=this.getInternalLoader(e);if(s){const u=this.hls.logger,h=s.context;if(h&&h.levelOrTrack===e.levelOrTrack&&(h.url===e.url||h.deliveryDirectives&&!e.deliveryDirectives)){h.url===e.url?u.log(`[playlist-loader]: ignore ${e.url} ongoing request`):u.log(`[playlist-loader]: ignore ${e.url} in favor of ${h.url}`);return}u.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),s.abort()}let r;if(e.type===be.MANIFEST?r=i.manifestLoadPolicy.default:r=Ne({},i.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(e),se((t=e.deliveryDirectives)==null?void 0:t.part)){let u;if(e.type===be.LEVEL&&e.level!==null?u=this.hls.levels[e.level].details:e.type===be.AUDIO_TRACK&&e.id!==null?u=this.hls.audioTracks[e.id].details:e.type===be.SUBTITLE_TRACK&&e.id!==null&&(u=this.hls.subtitleTracks[e.id].details),u){const h=u.partTarget,f=u.targetduration;if(h&&f){const g=Math.max(h*3,f*.8)*1e3;r=Ne({},r,{maxTimeToFirstByteMs:Math.min(g,r.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(g,r.maxTimeToFirstByteMs)})}}}const n=r.errorRetry||r.timeoutRetry||{},o={loadPolicy:r,timeout:r.maxLoadTimeMs,maxRetry:n.maxNumRetry||0,retryDelay:n.retryDelayMs||0,maxRetryDelay:n.maxRetryDelayMs||0},c={onSuccess:(u,h,f,g)=>{const I=this.getInternalLoader(f);this.resetInternalLoader(f.type);const m=u.data;if(m.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(u,f,new Error("no EXTM3U delimiter"),g||null,h);return}h.parsing.start=performance.now(),Nt.isMediaPlaylist(m)||f.type!==be.MANIFEST?this.handleTrackOrLevelPlaylist(u,h,f,g||null,I):this.handleMasterPlaylist(u,h,f,g)},onError:(u,h,f,g)=>{this.handleNetworkError(h,f,!1,u,g)},onTimeout:(u,h,f)=>{this.handleNetworkError(h,f,!0,void 0,u)}};s.load(e,o,c)}checkAutostartLoad(){if(!this.hls)return;const{config:{autoStartLoad:e,startPosition:t},forceStartLoad:i}=this.hls;(e||i)&&(this.hls.logger.log(`${e?"auto":"force"} startLoad with configured startPosition ${t}`),this.hls.startLoad(t))}handleMasterPlaylist(e,t,i,s){const r=this.hls,n=e.data,o=bn(e,i),c=Nt.parseMasterPlaylist(n,o);if(c.playlistParsingError){this.handleManifestParsingError(e,i,c.playlistParsingError,s,t);return}const{contentSteering:u,levels:h,sessionData:f,sessionKeys:g,startTimeOffset:I,variableList:m}=c;this.variableList=m;const{AUDIO:E=[],SUBTITLES:v,"CLOSED-CAPTIONS":x}=Nt.parseMasterPlaylistMedia(n,o,c);E.length&&!E.some(L=>!L.url)&&h[0].audioCodec&&!h[0].attrs.AUDIO&&(this.hls.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),E.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new He({}),bitrate:0,url:""})),r.trigger(y.MANIFEST_LOADED,{levels:h,audioTracks:E,subtitles:v,captions:x,contentSteering:u,url:o,stats:t,networkDetails:s,sessionData:f,sessionKeys:g,startTimeOffset:I,variableList:m})}handleTrackOrLevelPlaylist(e,t,i,s,r){const n=this.hls,{id:o,level:c,type:u}=i,h=bn(e,i),f=se(c)?c:se(o)?o:0,g=Fl(i),I=Nt.parseLevelPlaylist(e.data,h,f,g,0,this.variableList);if(u===be.MANIFEST){const m={attrs:new He({}),bitrate:0,details:I,name:"",url:h};I.requestScheduled=t.loading.start+so(I,0),n.trigger(y.MANIFEST_LOADED,{levels:[m],audioTracks:[],url:h,stats:t,networkDetails:s,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),i.levelDetails=I,this.handlePlaylistLoaded(I,e,t,i,s,r)}handleManifestParsingError(e,t,i,s,r){this.hls.trigger(y.ERROR,{type:de.NETWORK_ERROR,details:U.MANIFEST_PARSING_ERROR,fatal:t.type===be.MANIFEST,url:e.url,err:i,error:i,reason:i.message,response:e,context:t,networkDetails:s,stats:r})}handleNetworkError(e,t,i=!1,s,r){let n=`A network ${i?"timeout":"error"+(s?" (status "+s.code+")":"")} occurred while loading ${e.type}`;e.type===be.LEVEL?n+=`: ${e.level} id: ${e.id}`:(e.type===be.AUDIO_TRACK||e.type===be.SUBTITLE_TRACK)&&(n+=` id: ${e.id} group-id: "${e.groupId}"`);const o=new Error(n);this.hls.logger.warn(`[playlist-loader]: ${n}`);let c=U.UNKNOWN,u=!1;const h=this.getInternalLoader(e);switch(e.type){case be.MANIFEST:c=i?U.MANIFEST_LOAD_TIMEOUT:U.MANIFEST_LOAD_ERROR,u=!0;break;case be.LEVEL:c=i?U.LEVEL_LOAD_TIMEOUT:U.LEVEL_LOAD_ERROR,u=!1;break;case be.AUDIO_TRACK:c=i?U.AUDIO_TRACK_LOAD_TIMEOUT:U.AUDIO_TRACK_LOAD_ERROR,u=!1;break;case be.SUBTITLE_TRACK:c=i?U.SUBTITLE_TRACK_LOAD_TIMEOUT:U.SUBTITLE_LOAD_ERROR,u=!1;break}h&&this.resetInternalLoader(e.type);const f={type:de.NETWORK_ERROR,details:c,fatal:u,url:e.url,loader:h,context:e,error:o,networkDetails:t,stats:r};if(s){const g=t?.url||e.url;f.response=Be({url:g,data:void 0},s)}this.hls.trigger(y.ERROR,f)}handlePlaylistLoaded(e,t,i,s,r,n){const o=this.hls,{type:c,level:u,id:h,groupId:f,deliveryDirectives:g}=s,I=bn(t,s),m=Fl(s),E=typeof s.level=="number"&&m===he.MAIN?u:void 0;if(!e.fragments.length){const x=e.playlistParsingError=new Error("No Segments found in Playlist");o.trigger(y.ERROR,{type:de.NETWORK_ERROR,details:U.LEVEL_EMPTY_ERROR,fatal:!1,url:I,error:x,reason:x.message,response:t,context:s,level:E,parent:m,networkDetails:r,stats:i});return}e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));const v=e.playlistParsingError;if(v){if(this.hls.logger.warn(`${v} ${e.url}`),!o.config.ignorePlaylistParsingErrors){o.trigger(y.ERROR,{type:de.NETWORK_ERROR,details:U.LEVEL_PARSING_ERROR,fatal:!1,url:I,error:v,reason:v.message,response:t,context:s,level:E,parent:m,networkDetails:r,stats:i});return}e.playlistParsingError=null}switch(e.live&&n&&(n.getCacheAge&&(e.ageHeader=n.getCacheAge()||0),(!n.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),c){case be.MANIFEST:case be.LEVEL:o.trigger(y.LEVEL_LOADED,{details:e,levelInfo:s.levelOrTrack||o.levels[0],level:E||0,id:h||0,stats:i,networkDetails:r,deliveryDirectives:g,withoutMultiVariant:c===be.MANIFEST});break;case be.AUDIO_TRACK:o.trigger(y.AUDIO_TRACK_LOADED,{details:e,track:s.levelOrTrack,id:h||0,groupId:f||"",stats:i,networkDetails:r,deliveryDirectives:g});break;case be.SUBTITLE_TRACK:o.trigger(y.SUBTITLE_TRACK_LOADED,{details:e,track:s.levelOrTrack,id:h||0,groupId:f||"",stats:i,networkDetails:r,deliveryDirectives:g});break}}}class ft{static get version(){return es}static isMSESupported(){return Ol()}static isSupported(){return hg()}static getMediaSource(){return ri()}static get Events(){return y}static get MetadataSchema(){return yt}static get ErrorTypes(){return de}static get ErrorDetails(){return U}static get DefaultConfig(){return ft.defaultConfig?ft.defaultConfig:Jf}static set DefaultConfig(e){ft.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.logger=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new Gr,this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioStreamController=void 0,this.subtititleStreamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.interstitialsController=void 0,this.gapController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this._url=null,this._sessionId=void 0,this.triggeringException=void 0,this.started=!1;const t=this.logger=bu(e.debug||!1,"Hls instance",e.assetPlayerId),i=this.config=tg(ft.DefaultConfig,e,t);this.userConfig=e,i.progressive&&ig(i,t);const{abrController:s,bufferController:r,capLevelController:n,errorController:o,fpsController:c}=i,u=new o(this),h=this.abrController=new s(this),f=new Ic(this),g=i.interstitialsController,I=g?this.interstitialsController=new g(this,ft):null,m=this.bufferController=new r(this,f),E=this.capLevelController=new n(this),v=new c(this),x=new Ag(this),D=i.contentSteeringController,L=D?new D(this):null,w=this.levelController=new cg(this,L),N=new lg(this),K=new pg(this.config,this.logger),p=this.streamController=new gg(this,f,K),$=this.gapController=new ag(this,f);E.setStreamController(p),v.setStreamController(p);const F=[x,w,p];I&&F.splice(1,0,I),L&&F.splice(1,0,L),this.networkControllers=F;const O=[h,m,$,E,v,N,f];this.audioTrackController=this.createController(i.audioTrackController,F);const W=i.audioStreamController;W&&F.push(this.audioStreamController=new W(this,f,K)),this.subtitleTrackController=this.createController(i.subtitleTrackController,F);const ie=i.subtitleStreamController;ie&&F.push(this.subtititleStreamController=new ie(this,f,K)),this.createController(i.timelineController,O),K.emeController=this.emeController=this.createController(i.emeController,O),this.cmcdController=this.createController(i.cmcdController,O),this.latencyController=this.createController(ug,O),this.coreComponents=O,F.push(u);const X=u.onErrorOut;typeof X=="function"&&this.on(y.ERROR,X,u),this.on(y.MANIFEST_LOADED,x.onManifestLoaded,x)}createController(e,t){if(e){const i=new e(this);return t&&t.push(i),i}return null}on(e,t,i=this){this._emitter.on(e,t,i)}once(e,t,i=this){this._emitter.once(e,t,i)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,i=this,s){this._emitter.off(e,t,i,s)}listeners(e){return this._emitter.listeners(e)}emit(e,t,i){return this._emitter.emit(e,t,i)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(i){if(this.logger.error("An internal error happened while handling event "+e+'. Error message: "'+i.message+'". Here is a stacktrace:',i),!this.triggeringException){this.triggeringException=!0;const s=e===y.ERROR;this.trigger(y.ERROR,{type:de.OTHER_ERROR,details:U.INTERNAL_EXCEPTION,fatal:s,event:e,error:i}),this.triggeringException=!1}}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){this.logger.log("destroy"),this.trigger(y.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this._url=null,this.networkControllers.forEach(t=>t.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(t=>t.destroy()),this.coreComponents.length=0;const e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}attachMedia(e){if(!e||"media"in e&&!e.media){const r=new Error(`attachMedia failed: invalid argument (${e})`);this.trigger(y.ERROR,{type:de.OTHER_ERROR,details:U.ATTACH_MEDIA_ERROR,fatal:!0,error:r});return}this.logger.log("attachMedia"),this._media&&(this.logger.warn("media must be detached before attaching"),this.detachMedia());const t="media"in e,i=t?e.media:e,s=t?e:{media:i};this._media=i,this.trigger(y.MEDIA_ATTACHING,s)}detachMedia(){this.logger.log("detachMedia"),this.trigger(y.MEDIA_DETACHING,{}),this._media=null}transferMedia(){this._media=null;const e=this.bufferController.transferMedia();return this.trigger(y.MEDIA_DETACHING,{transferMedia:e}),e}loadSource(e){this.stopLoad();const t=this.media,i=this._url,s=this._url=pr.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log(`loadSource:${s}`),t&&i&&(i!==s||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(y.MANIFEST_LOADING,{url:e})}get url(){return this._url}get hasEnoughToStart(){return this.streamController.hasEnoughToStart}get startPosition(){return this.streamController.startPositionValue}startLoad(e=-1,t){this.logger.log(`startLoad(${e+(t?", <skip seek to start>":"")})`),this.started=!0,this.resumeBuffering();for(let i=0;i<this.networkControllers.length&&(this.networkControllers[i].startLoad(e,t),!(!this.started||!this.networkControllers));i++);}stopLoad(){this.logger.log("stopLoad"),this.started=!1;for(let e=0;e<this.networkControllers.length&&(this.networkControllers[e].stopLoad(),!(this.started||!this.networkControllers));e++);}get loadingEnabled(){return this.started}get bufferingEnabled(){return this.streamController.bufferingEnabled}resumeBuffering(){this.bufferingEnabled||(this.logger.log("resume buffering"),this.networkControllers.forEach(e=>{e.resumeBuffering&&e.resumeBuffering()}))}pauseBuffering(){this.bufferingEnabled&&(this.logger.log("pause buffering"),this.networkControllers.forEach(e=>{e.pauseBuffering&&e.pauseBuffering()}))}get inFlightFragments(){const e={[he.MAIN]:this.streamController.inFlightFrag};return this.audioStreamController&&(e[he.AUDIO]=this.audioStreamController.inFlightFrag),this.subtititleStreamController&&(e[he.SUBTITLE]=this.subtititleStreamController.inFlightFrag),e}swapAudioCodec(){this.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){this.logger.log("recoverMediaError");const e=this._media,t=e?.currentTime;this.detachMedia(),e&&(this.attachMedia(e),t&&this.startLoad(t))}removeLevel(e){this.levelController.removeLevel(e)}get sessionId(){let e=this._sessionId;return e||(e=this._sessionId=af()),e}get levels(){const e=this.levelController.levels;return e||[]}get latestLevelDetails(){return this.streamController.getLevelDetails()||null}get loadLevelObj(){return this.levelController.loadLevelObj}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){this.logger.log(`set currentLevel:${e}`),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){this.logger.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){this.logger.log(`set loadLevel:${e}`),this.levelController.manualLevel=e}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(e){this.levelController.nextLoadLevel=e}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(e){this.logger.log(`set firstLevel:${e}`),this.levelController.firstLevel=e}get startLevel(){const e=this.levelController.startLevel;return e===-1&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e}set startLevel(e){this.logger.log(`set startLevel:${e}`),e!==-1&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){const t=!!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}set bandwidthEstimate(e){this.abrController.resetEstimator(e)}get abrEwmaDefaultEstimate(){const{bwEstimator:e}=this.abrController;return e?e.defaultEstimate:NaN}get ttfbEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(this.logger.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){ic(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}get autoLevelEnabled(){return this.levelController.manualLevel===-1}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){const{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;const i=e.length;for(let s=0;s<i;s++)if(e[s].maxBitrate>=t)return s;return 0}get maxAutoLevel(){const{levels:e,autoLevelCapping:t,maxHdcpLevel:i}=this;let s;if(t===-1&&e!=null&&e.length?s=e.length-1:s=t,i)for(let r=s;r--;){const n=e[r].attrs["HDCP-LEVEL"];if(n&&n<=i)return r}return s}get firstAutoLevel(){return this.abrController.firstAutoLevel}get nextAutoLevel(){return this.abrController.nextAutoLevel}set nextAutoLevel(e){this.abrController.nextAutoLevel=e}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get maxBufferLength(){return this.streamController.maxBufferLength}setAudioOption(e){var t;return((t=this.audioTrackController)==null?void 0:t.setAudioOption(e))||null}setSubtitleOption(e){var t;return((t=this.subtitleTrackController)==null?void 0:t.setSubtitleOption(e))||null}get allAudioTracks(){const e=this.audioTrackController;return e?e.allAudioTracks:[]}get audioTracks(){const e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){const e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){const t=this.audioTrackController;t&&(t.audioTrack=e)}get allSubtitleTracks(){const e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}get subtitleTracks(){const e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){const e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){const t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}get subtitleDisplay(){const e=this.subtitleTrackController;return e?e.subtitleDisplay:!1}set subtitleDisplay(e){const t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(e){this.config.lowLatencyMode=e}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}set targetLatency(e){this.latencyController.targetLatency=e}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}get pathways(){return this.levelController.pathways}get pathwayPriority(){return this.levelController.pathwayPriority}set pathwayPriority(e){this.levelController.pathwayPriority=e}get bufferedToEnd(){var e;return!!((e=this.bufferController)!=null&&e.bufferedToEnd)}get interstitialsManager(){var e;return((e=this.interstitialsController)==null?void 0:e.interstitialsManager)||null}getMediaDecodingInfo(e,t=this.allAudioTracks){const i=va(t);return ma(e,i,navigator.mediaCapabilities)}}ft.defaultConfig=void 0;function mg(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var er={exports:{}};/*!
41
- * jQuery JavaScript Library v3.7.1
42
- * https://jquery.com/
43
- *
44
- * Copyright OpenJS Foundation and other contributors
45
- * Released under the MIT license
46
- * https://jquery.org/license
47
- *
48
- * Date: 2023-08-28T13:37Z
49
- */var Ig=er.exports,Nl;function Cg(){return Nl||(Nl=1,(function(a){(function(e,t){a.exports=e.document?t(e,!0):function(i){if(!i.document)throw new Error("jQuery requires a window with a document");return t(i)}})(typeof window<"u"?window:Ig,function(e,t){var i=[],s=Object.getPrototypeOf,r=i.slice,n=i.flat?function(l){return i.flat.call(l)}:function(l){return i.concat.apply([],l)},o=i.push,c=i.indexOf,u={},h=u.toString,f=u.hasOwnProperty,g=f.toString,I=g.call(Object),m={},E=function(d){return typeof d=="function"&&typeof d.nodeType!="number"&&typeof d.item!="function"},v=function(d){return d!=null&&d===d.window},x=e.document,D={type:!0,src:!0,nonce:!0,noModule:!0};function L(l,d,A){A=A||x;var C,T,S=A.createElement("script");if(S.text=l,d)for(C in D)T=d[C]||d.getAttribute&&d.getAttribute(C),T&&S.setAttribute(C,T);A.head.appendChild(S).parentNode.removeChild(S)}function w(l){return l==null?l+"":typeof l=="object"||typeof l=="function"?u[h.call(l)]||"object":typeof l}var N="3.7.1",K=/HTML$/i,p=function(l,d){return new p.fn.init(l,d)};p.fn=p.prototype={jquery:N,constructor:p,length:0,toArray:function(){return r.call(this)},get:function(l){return l==null?r.call(this):l<0?this[l+this.length]:this[l]},pushStack:function(l){var d=p.merge(this.constructor(),l);return d.prevObject=this,d},each:function(l){return p.each(this,l)},map:function(l){return this.pushStack(p.map(this,function(d,A){return l.call(d,A,d)}))},slice:function(){return this.pushStack(r.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},even:function(){return this.pushStack(p.grep(this,function(l,d){return(d+1)%2}))},odd:function(){return this.pushStack(p.grep(this,function(l,d){return d%2}))},eq:function(l){var d=this.length,A=+l+(l<0?d:0);return this.pushStack(A>=0&&A<d?[this[A]]:[])},end:function(){return this.prevObject||this.constructor()},push:o,sort:i.sort,splice:i.splice},p.extend=p.fn.extend=function(){var l,d,A,C,T,S,b=arguments[0]||{},_=1,P=arguments.length,M=!1;for(typeof b=="boolean"&&(M=b,b=arguments[_]||{},_++),typeof b!="object"&&!E(b)&&(b={}),_===P&&(b=this,_--);_<P;_++)if((l=arguments[_])!=null)for(d in l)C=l[d],!(d==="__proto__"||b===C)&&(M&&C&&(p.isPlainObject(C)||(T=Array.isArray(C)))?(A=b[d],T&&!Array.isArray(A)?S=[]:!T&&!p.isPlainObject(A)?S={}:S=A,T=!1,b[d]=p.extend(M,S,C)):C!==void 0&&(b[d]=C));return b},p.extend({expando:"jQuery"+(N+Math.random()).replace(/\D/g,""),isReady:!0,error:function(l){throw new Error(l)},noop:function(){},isPlainObject:function(l){var d,A;return!l||h.call(l)!=="[object Object]"?!1:(d=s(l),d?(A=f.call(d,"constructor")&&d.constructor,typeof A=="function"&&g.call(A)===I):!0)},isEmptyObject:function(l){var d;for(d in l)return!1;return!0},globalEval:function(l,d,A){L(l,{nonce:d&&d.nonce},A)},each:function(l,d){var A,C=0;if($(l))for(A=l.length;C<A&&d.call(l[C],C,l[C])!==!1;C++);else for(C in l)if(d.call(l[C],C,l[C])===!1)break;return l},text:function(l){var d,A="",C=0,T=l.nodeType;if(!T)for(;d=l[C++];)A+=p.text(d);return T===1||T===11?l.textContent:T===9?l.documentElement.textContent:T===3||T===4?l.nodeValue:A},makeArray:function(l,d){var A=d||[];return l!=null&&($(Object(l))?p.merge(A,typeof l=="string"?[l]:l):o.call(A,l)),A},inArray:function(l,d,A){return d==null?-1:c.call(d,l,A)},isXMLDoc:function(l){var d=l&&l.namespaceURI,A=l&&(l.ownerDocument||l).documentElement;return!K.test(d||A&&A.nodeName||"HTML")},merge:function(l,d){for(var A=+d.length,C=0,T=l.length;C<A;C++)l[T++]=d[C];return l.length=T,l},grep:function(l,d,A){for(var C,T=[],S=0,b=l.length,_=!A;S<b;S++)C=!d(l[S],S),C!==_&&T.push(l[S]);return T},map:function(l,d,A){var C,T,S=0,b=[];if($(l))for(C=l.length;S<C;S++)T=d(l[S],S,A),T!=null&&b.push(T);else for(S in l)T=d(l[S],S,A),T!=null&&b.push(T);return n(b)},guid:1,support:m}),typeof Symbol=="function"&&(p.fn[Symbol.iterator]=i[Symbol.iterator]),p.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(l,d){u["[object "+d+"]"]=d.toLowerCase()});function $(l){var d=!!l&&"length"in l&&l.length,A=w(l);return E(l)||v(l)?!1:A==="array"||d===0||typeof d=="number"&&d>0&&d-1 in l}function F(l,d){return l.nodeName&&l.nodeName.toLowerCase()===d.toLowerCase()}var O=i.pop,W=i.sort,ie=i.splice,X="[\\x20\\t\\r\\n\\f]",ce=new RegExp("^"+X+"+|((?:^|[^\\\\])(?:\\\\.)*)"+X+"+$","g");p.contains=function(l,d){var A=d&&d.parentNode;return l===A||!!(A&&A.nodeType===1&&(l.contains?l.contains(A):l.compareDocumentPosition&&l.compareDocumentPosition(A)&16))};var ue=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\x80-\uFFFF\w-]/g;function Q(l,d){return d?l==="\0"?"�":l.slice(0,-1)+"\\"+l.charCodeAt(l.length-1).toString(16)+" ":"\\"+l}p.escapeSelector=function(l){return(l+"").replace(ue,Q)};var ne=x,re=o;(function(){var l,d,A,C,T,S=re,b,_,P,M,Y,q=p.expando,H=0,Z=0,Ce=lr(),we=lr(),Se=lr(),nt=lr(),et=function(R,k){return R===k&&(T=!0),0},Vt="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",Kt="(?:\\\\[\\da-fA-F]{1,6}"+X+"?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+",_e="\\["+X+"*("+Kt+")(?:"+X+"*([*^$|!~]?=)"+X+`*(?:'((?:\\\\.|[^\\\\'])*)'|"((?:\\\\.|[^\\\\"])*)"|(`+Kt+"))|)"+X+"*\\]",bi=":("+Kt+`)(?:\\((('((?:\\\\.|[^\\\\'])*)'|"((?:\\\\.|[^\\\\"])*)")|((?:\\\\.|[^\\\\()[\\]]|`+_e+")*)|.*)\\)|)",Me=new RegExp(X+"+","g"),We=new RegExp("^"+X+"*,"+X+"*"),gs=new RegExp("^"+X+"*([>+~]|"+X+")"+X+"*"),Hn=new RegExp(X+"|>"),Yt=new RegExp(bi),ps=new RegExp("^"+Kt+"$"),Wt={ID:new RegExp("^#("+Kt+")"),CLASS:new RegExp("^\\.("+Kt+")"),TAG:new RegExp("^("+Kt+"|[*])"),ATTR:new RegExp("^"+_e),PSEUDO:new RegExp("^"+bi),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+X+"*(even|odd|(([+-]|)(\\d*)n|)"+X+"*(?:([+-]|)"+X+"*(\\d+)|))"+X+"*\\)|)","i"),bool:new RegExp("^(?:"+Vt+")$","i"),needsContext:new RegExp("^"+X+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+X+"*((?:-\\d)?\\d*)"+X+"*\\)|)(?=[^-]|$)","i")},pi=/^(?:input|select|textarea|button)$/i,Ai=/^h\d$/i,Lt=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,Vn=/[+~]/,ti=new RegExp("\\\\[\\da-fA-F]{1,6}"+X+"?|\\\\([^\\r\\n\\f])","g"),ii=function(R,k){var G="0x"+R.slice(1)-65536;return k||(G<0?String.fromCharCode(G+65536):String.fromCharCode(G>>10|55296,G&1023|56320))},op=function(){mi()},lp=cr(function(R){return R.disabled===!0&&F(R,"fieldset")},{dir:"parentNode",next:"legend"});function up(){try{return b.activeElement}catch{}}try{S.apply(i=r.call(ne.childNodes),ne.childNodes),i[ne.childNodes.length].nodeType}catch{S={apply:function(k,G){re.apply(k,r.call(G))},call:function(k){re.apply(k,r.call(arguments,1))}}}function Fe(R,k,G,V){var z,te,ae,ge,oe,Re,me,Ee=k&&k.ownerDocument,De=k?k.nodeType:9;if(G=G||[],typeof R!="string"||!R||De!==1&&De!==9&&De!==11)return G;if(!V&&(mi(k),k=k||b,P)){if(De!==11&&(oe=Lt.exec(R)))if(z=oe[1]){if(De===9)if(ae=k.getElementById(z)){if(ae.id===z)return S.call(G,ae),G}else return G;else if(Ee&&(ae=Ee.getElementById(z))&&Fe.contains(k,ae)&&ae.id===z)return S.call(G,ae),G}else{if(oe[2])return S.apply(G,k.getElementsByTagName(R)),G;if((z=oe[3])&&k.getElementsByClassName)return S.apply(G,k.getElementsByClassName(z)),G}if(!nt[R+" "]&&(!M||!M.test(R))){if(me=R,Ee=k,De===1&&(Hn.test(R)||gs.test(R))){for(Ee=Vn.test(R)&&Kn(k.parentNode)||k,(Ee!=k||!m.scope)&&((ge=k.getAttribute("id"))?ge=p.escapeSelector(ge):k.setAttribute("id",ge=q)),Re=As(R),te=Re.length;te--;)Re[te]=(ge?"#"+ge:":scope")+" "+ur(Re[te]);me=Re.join(",")}try{return S.apply(G,Ee.querySelectorAll(me)),G}catch{nt(R,!0)}finally{ge===q&&k.removeAttribute("id")}}}return mu(R.replace(ce,"$1"),k,G,V)}function lr(){var R=[];function k(G,V){return R.push(G+" ")>d.cacheLength&&delete k[R.shift()],k[G+" "]=V}return k}function kt(R){return R[q]=!0,R}function zi(R){var k=b.createElement("fieldset");try{return!!R(k)}catch{return!1}finally{k.parentNode&&k.parentNode.removeChild(k),k=null}}function cp(R){return function(k){return F(k,"input")&&k.type===R}}function hp(R){return function(k){return(F(k,"input")||F(k,"button"))&&k.type===R}}function pu(R){return function(k){return"form"in k?k.parentNode&&k.disabled===!1?"label"in k?"label"in k.parentNode?k.parentNode.disabled===R:k.disabled===R:k.isDisabled===R||k.isDisabled!==!R&&lp(k)===R:k.disabled===R:"label"in k?k.disabled===R:!1}}function Li(R){return kt(function(k){return k=+k,kt(function(G,V){for(var z,te=R([],G.length,k),ae=te.length;ae--;)G[z=te[ae]]&&(G[z]=!(V[z]=G[z]))})})}function Kn(R){return R&&typeof R.getElementsByTagName<"u"&&R}function mi(R){var k,G=R?R.ownerDocument||R:ne;return G==b||G.nodeType!==9||!G.documentElement||(b=G,_=b.documentElement,P=!p.isXMLDoc(b),Y=_.matches||_.webkitMatchesSelector||_.msMatchesSelector,_.msMatchesSelector&&ne!=b&&(k=b.defaultView)&&k.top!==k&&k.addEventListener("unload",op),m.getById=zi(function(V){return _.appendChild(V).id=p.expando,!b.getElementsByName||!b.getElementsByName(p.expando).length}),m.disconnectedMatch=zi(function(V){return Y.call(V,"*")}),m.scope=zi(function(){return b.querySelectorAll(":scope")}),m.cssHas=zi(function(){try{return b.querySelector(":has(*,:jqfake)"),!1}catch{return!0}}),m.getById?(d.filter.ID=function(V){var z=V.replace(ti,ii);return function(te){return te.getAttribute("id")===z}},d.find.ID=function(V,z){if(typeof z.getElementById<"u"&&P){var te=z.getElementById(V);return te?[te]:[]}}):(d.filter.ID=function(V){var z=V.replace(ti,ii);return function(te){var ae=typeof te.getAttributeNode<"u"&&te.getAttributeNode("id");return ae&&ae.value===z}},d.find.ID=function(V,z){if(typeof z.getElementById<"u"&&P){var te,ae,ge,oe=z.getElementById(V);if(oe){if(te=oe.getAttributeNode("id"),te&&te.value===V)return[oe];for(ge=z.getElementsByName(V),ae=0;oe=ge[ae++];)if(te=oe.getAttributeNode("id"),te&&te.value===V)return[oe]}return[]}}),d.find.TAG=function(V,z){return typeof z.getElementsByTagName<"u"?z.getElementsByTagName(V):z.querySelectorAll(V)},d.find.CLASS=function(V,z){if(typeof z.getElementsByClassName<"u"&&P)return z.getElementsByClassName(V)},M=[],zi(function(V){var z;_.appendChild(V).innerHTML="<a id='"+q+"' href='' disabled='disabled'></a><select id='"+q+"-\r\\' disabled='disabled'><option selected=''></option></select>",V.querySelectorAll("[selected]").length||M.push("\\["+X+"*(?:value|"+Vt+")"),V.querySelectorAll("[id~="+q+"-]").length||M.push("~="),V.querySelectorAll("a#"+q+"+*").length||M.push(".#.+[+~]"),V.querySelectorAll(":checked").length||M.push(":checked"),z=b.createElement("input"),z.setAttribute("type","hidden"),V.appendChild(z).setAttribute("name","D"),_.appendChild(V).disabled=!0,V.querySelectorAll(":disabled").length!==2&&M.push(":enabled",":disabled"),z=b.createElement("input"),z.setAttribute("name",""),V.appendChild(z),V.querySelectorAll("[name='']").length||M.push("\\["+X+"*name"+X+"*="+X+`*(?:''|"")`)}),m.cssHas||M.push(":has"),M=M.length&&new RegExp(M.join("|")),et=function(V,z){if(V===z)return T=!0,0;var te=!V.compareDocumentPosition-!z.compareDocumentPosition;return te||(te=(V.ownerDocument||V)==(z.ownerDocument||z)?V.compareDocumentPosition(z):1,te&1||!m.sortDetached&&z.compareDocumentPosition(V)===te?V===b||V.ownerDocument==ne&&Fe.contains(ne,V)?-1:z===b||z.ownerDocument==ne&&Fe.contains(ne,z)?1:C?c.call(C,V)-c.call(C,z):0:te&4?-1:1)}),b}Fe.matches=function(R,k){return Fe(R,null,null,k)},Fe.matchesSelector=function(R,k){if(mi(R),P&&!nt[k+" "]&&(!M||!M.test(k)))try{var G=Y.call(R,k);if(G||m.disconnectedMatch||R.document&&R.document.nodeType!==11)return G}catch{nt(k,!0)}return Fe(k,b,null,[R]).length>0},Fe.contains=function(R,k){return(R.ownerDocument||R)!=b&&mi(R),p.contains(R,k)},Fe.attr=function(R,k){(R.ownerDocument||R)!=b&&mi(R);var G=d.attrHandle[k.toLowerCase()],V=G&&f.call(d.attrHandle,k.toLowerCase())?G(R,k,!P):void 0;return V!==void 0?V:R.getAttribute(k)},Fe.error=function(R){throw new Error("Syntax error, unrecognized expression: "+R)},p.uniqueSort=function(R){var k,G=[],V=0,z=0;if(T=!m.sortStable,C=!m.sortStable&&r.call(R,0),W.call(R,et),T){for(;k=R[z++];)k===R[z]&&(V=G.push(z));for(;V--;)ie.call(R,G[V],1)}return C=null,R},p.fn.uniqueSort=function(){return this.pushStack(p.uniqueSort(r.apply(this)))},d=p.expr={cacheLength:50,createPseudo:kt,match:Wt,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(R){return R[1]=R[1].replace(ti,ii),R[3]=(R[3]||R[4]||R[5]||"").replace(ti,ii),R[2]==="~="&&(R[3]=" "+R[3]+" "),R.slice(0,4)},CHILD:function(R){return R[1]=R[1].toLowerCase(),R[1].slice(0,3)==="nth"?(R[3]||Fe.error(R[0]),R[4]=+(R[4]?R[5]+(R[6]||1):2*(R[3]==="even"||R[3]==="odd")),R[5]=+(R[7]+R[8]||R[3]==="odd")):R[3]&&Fe.error(R[0]),R},PSEUDO:function(R){var k,G=!R[6]&&R[2];return Wt.CHILD.test(R[0])?null:(R[3]?R[2]=R[4]||R[5]||"":G&&Yt.test(G)&&(k=As(G,!0))&&(k=G.indexOf(")",G.length-k)-G.length)&&(R[0]=R[0].slice(0,k),R[2]=G.slice(0,k)),R.slice(0,3))}},filter:{TAG:function(R){var k=R.replace(ti,ii).toLowerCase();return R==="*"?function(){return!0}:function(G){return F(G,k)}},CLASS:function(R){var k=Ce[R+" "];return k||(k=new RegExp("(^|"+X+")"+R+"("+X+"|$)"))&&Ce(R,function(G){return k.test(typeof G.className=="string"&&G.className||typeof G.getAttribute<"u"&&G.getAttribute("class")||"")})},ATTR:function(R,k,G){return function(V){var z=Fe.attr(V,R);return z==null?k==="!=":k?(z+="",k==="="?z===G:k==="!="?z!==G:k==="^="?G&&z.indexOf(G)===0:k==="*="?G&&z.indexOf(G)>-1:k==="$="?G&&z.slice(-G.length)===G:k==="~="?(" "+z.replace(Me," ")+" ").indexOf(G)>-1:k==="|="?z===G||z.slice(0,G.length+1)===G+"-":!1):!0}},CHILD:function(R,k,G,V,z){var te=R.slice(0,3)!=="nth",ae=R.slice(-4)!=="last",ge=k==="of-type";return V===1&&z===0?function(oe){return!!oe.parentNode}:function(oe,Re,me){var Ee,De,Ae,$e,At,at=te!==ae?"nextSibling":"previousSibling",Rt=oe.parentNode,jt=ge&&oe.nodeName.toLowerCase(),qi=!me&&!ge,ut=!1;if(Rt){if(te){for(;at;){for(Ae=oe;Ae=Ae[at];)if(ge?F(Ae,jt):Ae.nodeType===1)return!1;At=at=R==="only"&&!At&&"nextSibling"}return!0}if(At=[ae?Rt.firstChild:Rt.lastChild],ae&&qi){for(De=Rt[q]||(Rt[q]={}),Ee=De[R]||[],$e=Ee[0]===H&&Ee[1],ut=$e&&Ee[2],Ae=$e&&Rt.childNodes[$e];Ae=++$e&&Ae&&Ae[at]||(ut=$e=0)||At.pop();)if(Ae.nodeType===1&&++ut&&Ae===oe){De[R]=[H,$e,ut];break}}else if(qi&&(De=oe[q]||(oe[q]={}),Ee=De[R]||[],$e=Ee[0]===H&&Ee[1],ut=$e),ut===!1)for(;(Ae=++$e&&Ae&&Ae[at]||(ut=$e=0)||At.pop())&&!((ge?F(Ae,jt):Ae.nodeType===1)&&++ut&&(qi&&(De=Ae[q]||(Ae[q]={}),De[R]=[H,ut]),Ae===oe)););return ut-=z,ut===V||ut%V===0&&ut/V>=0}}},PSEUDO:function(R,k){var G,V=d.pseudos[R]||d.setFilters[R.toLowerCase()]||Fe.error("unsupported pseudo: "+R);return V[q]?V(k):V.length>1?(G=[R,R,"",k],d.setFilters.hasOwnProperty(R.toLowerCase())?kt(function(z,te){for(var ae,ge=V(z,k),oe=ge.length;oe--;)ae=c.call(z,ge[oe]),z[ae]=!(te[ae]=ge[oe])}):function(z){return V(z,0,G)}):V}},pseudos:{not:kt(function(R){var k=[],G=[],V=zn(R.replace(ce,"$1"));return V[q]?kt(function(z,te,ae,ge){for(var oe,Re=V(z,null,ge,[]),me=z.length;me--;)(oe=Re[me])&&(z[me]=!(te[me]=oe))}):function(z,te,ae){return k[0]=z,V(k,null,ae,G),k[0]=null,!G.pop()}}),has:kt(function(R){return function(k){return Fe(R,k).length>0}}),contains:kt(function(R){return R=R.replace(ti,ii),function(k){return(k.textContent||p.text(k)).indexOf(R)>-1}}),lang:kt(function(R){return ps.test(R||"")||Fe.error("unsupported lang: "+R),R=R.replace(ti,ii).toLowerCase(),function(k){var G;do if(G=P?k.lang:k.getAttribute("xml:lang")||k.getAttribute("lang"))return G=G.toLowerCase(),G===R||G.indexOf(R+"-")===0;while((k=k.parentNode)&&k.nodeType===1);return!1}}),target:function(R){var k=e.location&&e.location.hash;return k&&k.slice(1)===R.id},root:function(R){return R===_},focus:function(R){return R===up()&&b.hasFocus()&&!!(R.type||R.href||~R.tabIndex)},enabled:pu(!1),disabled:pu(!0),checked:function(R){return F(R,"input")&&!!R.checked||F(R,"option")&&!!R.selected},selected:function(R){return R.parentNode&&R.parentNode.selectedIndex,R.selected===!0},empty:function(R){for(R=R.firstChild;R;R=R.nextSibling)if(R.nodeType<6)return!1;return!0},parent:function(R){return!d.pseudos.empty(R)},header:function(R){return Ai.test(R.nodeName)},input:function(R){return pi.test(R.nodeName)},button:function(R){return F(R,"input")&&R.type==="button"||F(R,"button")},text:function(R){var k;return F(R,"input")&&R.type==="text"&&((k=R.getAttribute("type"))==null||k.toLowerCase()==="text")},first:Li(function(){return[0]}),last:Li(function(R,k){return[k-1]}),eq:Li(function(R,k,G){return[G<0?G+k:G]}),even:Li(function(R,k){for(var G=0;G<k;G+=2)R.push(G);return R}),odd:Li(function(R,k){for(var G=1;G<k;G+=2)R.push(G);return R}),lt:Li(function(R,k,G){var V;for(G<0?V=G+k:G>k?V=k:V=G;--V>=0;)R.push(V);return R}),gt:Li(function(R,k,G){for(var V=G<0?G+k:G;++V<k;)R.push(V);return R})}},d.pseudos.nth=d.pseudos.eq;for(l in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})d.pseudos[l]=cp(l);for(l in{submit:!0,reset:!0})d.pseudos[l]=hp(l);function Au(){}Au.prototype=d.filters=d.pseudos,d.setFilters=new Au;function As(R,k){var G,V,z,te,ae,ge,oe,Re=we[R+" "];if(Re)return k?0:Re.slice(0);for(ae=R,ge=[],oe=d.preFilter;ae;){(!G||(V=We.exec(ae)))&&(V&&(ae=ae.slice(V[0].length)||ae),ge.push(z=[])),G=!1,(V=gs.exec(ae))&&(G=V.shift(),z.push({value:G,type:V[0].replace(ce," ")}),ae=ae.slice(G.length));for(te in d.filter)(V=Wt[te].exec(ae))&&(!oe[te]||(V=oe[te](V)))&&(G=V.shift(),z.push({value:G,type:te,matches:V}),ae=ae.slice(G.length));if(!G)break}return k?ae.length:ae?Fe.error(R):we(R,ge).slice(0)}function ur(R){for(var k=0,G=R.length,V="";k<G;k++)V+=R[k].value;return V}function cr(R,k,G){var V=k.dir,z=k.next,te=z||V,ae=G&&te==="parentNode",ge=Z++;return k.first?function(oe,Re,me){for(;oe=oe[V];)if(oe.nodeType===1||ae)return R(oe,Re,me);return!1}:function(oe,Re,me){var Ee,De,Ae=[H,ge];if(me){for(;oe=oe[V];)if((oe.nodeType===1||ae)&&R(oe,Re,me))return!0}else for(;oe=oe[V];)if(oe.nodeType===1||ae)if(De=oe[q]||(oe[q]={}),z&&F(oe,z))oe=oe[V]||oe;else{if((Ee=De[te])&&Ee[0]===H&&Ee[1]===ge)return Ae[2]=Ee[2];if(De[te]=Ae,Ae[2]=R(oe,Re,me))return!0}return!1}}function Yn(R){return R.length>1?function(k,G,V){for(var z=R.length;z--;)if(!R[z](k,G,V))return!1;return!0}:R[0]}function dp(R,k,G){for(var V=0,z=k.length;V<z;V++)Fe(R,k[V],G);return G}function hr(R,k,G,V,z){for(var te,ae=[],ge=0,oe=R.length,Re=k!=null;ge<oe;ge++)(te=R[ge])&&(!G||G(te,V,z))&&(ae.push(te),Re&&k.push(ge));return ae}function Wn(R,k,G,V,z,te){return V&&!V[q]&&(V=Wn(V)),z&&!z[q]&&(z=Wn(z,te)),kt(function(ae,ge,oe,Re){var me,Ee,De,Ae,$e=[],At=[],at=ge.length,Rt=ae||dp(k||"*",oe.nodeType?[oe]:oe,[]),jt=R&&(ae||!k)?hr(Rt,$e,R,oe,Re):Rt;if(G?(Ae=z||(ae?R:at||V)?[]:ge,G(jt,Ae,oe,Re)):Ae=jt,V)for(me=hr(Ae,At),V(me,[],oe,Re),Ee=me.length;Ee--;)(De=me[Ee])&&(Ae[At[Ee]]=!(jt[At[Ee]]=De));if(ae){if(z||R){if(z){for(me=[],Ee=Ae.length;Ee--;)(De=Ae[Ee])&&me.push(jt[Ee]=De);z(null,Ae=[],me,Re)}for(Ee=Ae.length;Ee--;)(De=Ae[Ee])&&(me=z?c.call(ae,De):$e[Ee])>-1&&(ae[me]=!(ge[me]=De))}}else Ae=hr(Ae===ge?Ae.splice(at,Ae.length):Ae),z?z(null,ge,Ae,Re):S.apply(ge,Ae)})}function jn(R){for(var k,G,V,z=R.length,te=d.relative[R[0].type],ae=te||d.relative[" "],ge=te?1:0,oe=cr(function(Ee){return Ee===k},ae,!0),Re=cr(function(Ee){return c.call(k,Ee)>-1},ae,!0),me=[function(Ee,De,Ae){var $e=!te&&(Ae||De!=A)||((k=De).nodeType?oe(Ee,De,Ae):Re(Ee,De,Ae));return k=null,$e}];ge<z;ge++)if(G=d.relative[R[ge].type])me=[cr(Yn(me),G)];else{if(G=d.filter[R[ge].type].apply(null,R[ge].matches),G[q]){for(V=++ge;V<z&&!d.relative[R[V].type];V++);return Wn(ge>1&&Yn(me),ge>1&&ur(R.slice(0,ge-1).concat({value:R[ge-2].type===" "?"*":""})).replace(ce,"$1"),G,ge<V&&jn(R.slice(ge,V)),V<z&&jn(R=R.slice(V)),V<z&&ur(R))}me.push(G)}return Yn(me)}function fp(R,k){var G=k.length>0,V=R.length>0,z=function(te,ae,ge,oe,Re){var me,Ee,De,Ae=0,$e="0",At=te&&[],at=[],Rt=A,jt=te||V&&d.find.TAG("*",Re),qi=H+=Rt==null?1:Math.random()||.1,ut=jt.length;for(Re&&(A=ae==b||ae||Re);$e!==ut&&(me=jt[$e])!=null;$e++){if(V&&me){for(Ee=0,!ae&&me.ownerDocument!=b&&(mi(me),ge=!P);De=R[Ee++];)if(De(me,ae||b,ge)){S.call(oe,me);break}Re&&(H=qi)}G&&((me=!De&&me)&&Ae--,te&&At.push(me))}if(Ae+=$e,G&&$e!==Ae){for(Ee=0;De=k[Ee++];)De(At,at,ae,ge);if(te){if(Ae>0)for(;$e--;)At[$e]||at[$e]||(at[$e]=O.call(oe));at=hr(at)}S.apply(oe,at),Re&&!te&&at.length>0&&Ae+k.length>1&&p.uniqueSort(oe)}return Re&&(H=qi,A=Rt),At};return G?kt(z):z}function zn(R,k){var G,V=[],z=[],te=Se[R+" "];if(!te){for(k||(k=As(R)),G=k.length;G--;)te=jn(k[G]),te[q]?V.push(te):z.push(te);te=Se(R,fp(z,V)),te.selector=R}return te}function mu(R,k,G,V){var z,te,ae,ge,oe,Re=typeof R=="function"&&R,me=!V&&As(R=Re.selector||R);if(G=G||[],me.length===1){if(te=me[0]=me[0].slice(0),te.length>2&&(ae=te[0]).type==="ID"&&k.nodeType===9&&P&&d.relative[te[1].type]){if(k=(d.find.ID(ae.matches[0].replace(ti,ii),k)||[])[0],k)Re&&(k=k.parentNode);else return G;R=R.slice(te.shift().value.length)}for(z=Wt.needsContext.test(R)?0:te.length;z--&&(ae=te[z],!d.relative[ge=ae.type]);)if((oe=d.find[ge])&&(V=oe(ae.matches[0].replace(ti,ii),Vn.test(te[0].type)&&Kn(k.parentNode)||k))){if(te.splice(z,1),R=V.length&&ur(te),!R)return S.apply(G,V),G;break}}return(Re||zn(R,me))(V,k,!P,G,!k||Vn.test(R)&&Kn(k.parentNode)||k),G}m.sortStable=q.split("").sort(et).join("")===q,mi(),m.sortDetached=zi(function(R){return R.compareDocumentPosition(b.createElement("fieldset"))&1}),p.find=Fe,p.expr[":"]=p.expr.pseudos,p.unique=p.uniqueSort,Fe.compile=zn,Fe.select=mu,Fe.setDocument=mi,Fe.tokenize=As,Fe.escape=p.escapeSelector,Fe.getText=p.text,Fe.isXML=p.isXMLDoc,Fe.selectors=p.expr,Fe.support=p.support,Fe.uniqueSort=p.uniqueSort})();var le=function(l,d,A){for(var C=[],T=A!==void 0;(l=l[d])&&l.nodeType!==9;)if(l.nodeType===1){if(T&&p(l).is(A))break;C.push(l)}return C},pe=function(l,d){for(var A=[];l;l=l.nextSibling)l.nodeType===1&&l!==d&&A.push(l);return A},J=p.expr.match.needsContext,ee=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function ve(l,d,A){return E(d)?p.grep(l,function(C,T){return!!d.call(C,T,C)!==A}):d.nodeType?p.grep(l,function(C){return C===d!==A}):typeof d!="string"?p.grep(l,function(C){return c.call(d,C)>-1!==A}):p.filter(d,l,A)}p.filter=function(l,d,A){var C=d[0];return A&&(l=":not("+l+")"),d.length===1&&C.nodeType===1?p.find.matchesSelector(C,l)?[C]:[]:p.find.matches(l,p.grep(d,function(T){return T.nodeType===1}))},p.fn.extend({find:function(l){var d,A,C=this.length,T=this;if(typeof l!="string")return this.pushStack(p(l).filter(function(){for(d=0;d<C;d++)if(p.contains(T[d],this))return!0}));for(A=this.pushStack([]),d=0;d<C;d++)p.find(l,T[d],A);return C>1?p.uniqueSort(A):A},filter:function(l){return this.pushStack(ve(this,l||[],!1))},not:function(l){return this.pushStack(ve(this,l||[],!0))},is:function(l){return!!ve(this,typeof l=="string"&&J.test(l)?p(l):l||[],!1).length}});var ke,Te=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,Le=p.fn.init=function(l,d,A){var C,T;if(!l)return this;if(A=A||ke,typeof l=="string")if(l[0]==="<"&&l[l.length-1]===">"&&l.length>=3?C=[null,l,null]:C=Te.exec(l),C&&(C[1]||!d))if(C[1]){if(d=d instanceof p?d[0]:d,p.merge(this,p.parseHTML(C[1],d&&d.nodeType?d.ownerDocument||d:x,!0)),ee.test(C[1])&&p.isPlainObject(d))for(C in d)E(this[C])?this[C](d[C]):this.attr(C,d[C]);return this}else return T=x.getElementById(C[2]),T&&(this[0]=T,this.length=1),this;else return!d||d.jquery?(d||A).find(l):this.constructor(d).find(l);else{if(l.nodeType)return this[0]=l,this.length=1,this;if(E(l))return A.ready!==void 0?A.ready(l):l(p)}return p.makeArray(l,this)};Le.prototype=p.fn,ke=p(x);var it=/^(?:parents|prev(?:Until|All))/,Je={children:!0,contents:!0,next:!0,prev:!0};p.fn.extend({has:function(l){var d=p(l,this),A=d.length;return this.filter(function(){for(var C=0;C<A;C++)if(p.contains(this,d[C]))return!0})},closest:function(l,d){var A,C=0,T=this.length,S=[],b=typeof l!="string"&&p(l);if(!J.test(l)){for(;C<T;C++)for(A=this[C];A&&A!==d;A=A.parentNode)if(A.nodeType<11&&(b?b.index(A)>-1:A.nodeType===1&&p.find.matchesSelector(A,l))){S.push(A);break}}return this.pushStack(S.length>1?p.uniqueSort(S):S)},index:function(l){return l?typeof l=="string"?c.call(p(l),this[0]):c.call(this,l.jquery?l[0]:l):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(l,d){return this.pushStack(p.uniqueSort(p.merge(this.get(),p(l,d))))},addBack:function(l){return this.add(l==null?this.prevObject:this.prevObject.filter(l))}});function lt(l,d){for(;(l=l[d])&&l.nodeType!==1;);return l}p.each({parent:function(l){var d=l.parentNode;return d&&d.nodeType!==11?d:null},parents:function(l){return le(l,"parentNode")},parentsUntil:function(l,d,A){return le(l,"parentNode",A)},next:function(l){return lt(l,"nextSibling")},prev:function(l){return lt(l,"previousSibling")},nextAll:function(l){return le(l,"nextSibling")},prevAll:function(l){return le(l,"previousSibling")},nextUntil:function(l,d,A){return le(l,"nextSibling",A)},prevUntil:function(l,d,A){return le(l,"previousSibling",A)},siblings:function(l){return pe((l.parentNode||{}).firstChild,l)},children:function(l){return pe(l.firstChild)},contents:function(l){return l.contentDocument!=null&&s(l.contentDocument)?l.contentDocument:(F(l,"template")&&(l=l.content||l),p.merge([],l.childNodes))}},function(l,d){p.fn[l]=function(A,C){var T=p.map(this,d,A);return l.slice(-5)!=="Until"&&(C=A),C&&typeof C=="string"&&(T=p.filter(C,T)),this.length>1&&(Je[l]||p.uniqueSort(T),it.test(l)&&T.reverse()),this.pushStack(T)}});var je=/[^\x20\t\r\n\f]+/g;function Qt(l){var d={};return p.each(l.match(je)||[],function(A,C){d[C]=!0}),d}p.Callbacks=function(l){l=typeof l=="string"?Qt(l):p.extend({},l);var d,A,C,T,S=[],b=[],_=-1,P=function(){for(T=T||l.once,C=d=!0;b.length;_=-1)for(A=b.shift();++_<S.length;)S[_].apply(A[0],A[1])===!1&&l.stopOnFalse&&(_=S.length,A=!1);l.memory||(A=!1),d=!1,T&&(A?S=[]:S="")},M={add:function(){return S&&(A&&!d&&(_=S.length-1,b.push(A)),(function Y(q){p.each(q,function(H,Z){E(Z)?(!l.unique||!M.has(Z))&&S.push(Z):Z&&Z.length&&w(Z)!=="string"&&Y(Z)})})(arguments),A&&!d&&P()),this},remove:function(){return p.each(arguments,function(Y,q){for(var H;(H=p.inArray(q,S,H))>-1;)S.splice(H,1),H<=_&&_--}),this},has:function(Y){return Y?p.inArray(Y,S)>-1:S.length>0},empty:function(){return S&&(S=[]),this},disable:function(){return T=b=[],S=A="",this},disabled:function(){return!S},lock:function(){return T=b=[],!A&&!d&&(S=A=""),this},locked:function(){return!!T},fireWith:function(Y,q){return T||(q=q||[],q=[Y,q.slice?q.slice():q],b.push(q),d||P()),this},fire:function(){return M.fireWith(this,arguments),this},fired:function(){return!!C}};return M};function ci(l){return l}function hi(l){throw l}function Gi(l,d,A,C){var T;try{l&&E(T=l.promise)?T.call(l).done(d).fail(A):l&&E(T=l.then)?T.call(l,d,A):d.apply(void 0,[l].slice(C))}catch(S){A.apply(void 0,[S])}}p.extend({Deferred:function(l){var d=[["notify","progress",p.Callbacks("memory"),p.Callbacks("memory"),2],["resolve","done",p.Callbacks("once memory"),p.Callbacks("once memory"),0,"resolved"],["reject","fail",p.Callbacks("once memory"),p.Callbacks("once memory"),1,"rejected"]],A="pending",C={state:function(){return A},always:function(){return T.done(arguments).fail(arguments),this},catch:function(S){return C.then(null,S)},pipe:function(){var S=arguments;return p.Deferred(function(b){p.each(d,function(_,P){var M=E(S[P[4]])&&S[P[4]];T[P[1]](function(){var Y=M&&M.apply(this,arguments);Y&&E(Y.promise)?Y.promise().progress(b.notify).done(b.resolve).fail(b.reject):b[P[0]+"With"](this,M?[Y]:arguments)})}),S=null}).promise()},then:function(S,b,_){var P=0;function M(Y,q,H,Z){return function(){var Ce=this,we=arguments,Se=function(){var et,Vt;if(!(Y<P)){if(et=H.apply(Ce,we),et===q.promise())throw new TypeError("Thenable self-resolution");Vt=et&&(typeof et=="object"||typeof et=="function")&&et.then,E(Vt)?Z?Vt.call(et,M(P,q,ci,Z),M(P,q,hi,Z)):(P++,Vt.call(et,M(P,q,ci,Z),M(P,q,hi,Z),M(P,q,ci,q.notifyWith))):(H!==ci&&(Ce=void 0,we=[et]),(Z||q.resolveWith)(Ce,we))}},nt=Z?Se:function(){try{Se()}catch(et){p.Deferred.exceptionHook&&p.Deferred.exceptionHook(et,nt.error),Y+1>=P&&(H!==hi&&(Ce=void 0,we=[et]),q.rejectWith(Ce,we))}};Y?nt():(p.Deferred.getErrorHook?nt.error=p.Deferred.getErrorHook():p.Deferred.getStackHook&&(nt.error=p.Deferred.getStackHook()),e.setTimeout(nt))}}return p.Deferred(function(Y){d[0][3].add(M(0,Y,E(_)?_:ci,Y.notifyWith)),d[1][3].add(M(0,Y,E(S)?S:ci)),d[2][3].add(M(0,Y,E(b)?b:hi))}).promise()},promise:function(S){return S!=null?p.extend(S,C):C}},T={};return p.each(d,function(S,b){var _=b[2],P=b[5];C[b[1]]=_.add,P&&_.add(function(){A=P},d[3-S][2].disable,d[3-S][3].disable,d[0][2].lock,d[0][3].lock),_.add(b[3].fire),T[b[0]]=function(){return T[b[0]+"With"](this===T?void 0:this,arguments),this},T[b[0]+"With"]=_.fireWith}),C.promise(T),l&&l.call(T,T),T},when:function(l){var d=arguments.length,A=d,C=Array(A),T=r.call(arguments),S=p.Deferred(),b=function(_){return function(P){C[_]=this,T[_]=arguments.length>1?r.call(arguments):P,--d||S.resolveWith(C,T)}};if(d<=1&&(Gi(l,S.done(b(A)).resolve,S.reject,!d),S.state()==="pending"||E(T[A]&&T[A].then)))return S.then();for(;A--;)Gi(T[A],b(A),S.reject);return S.promise()}});var Ul=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;p.Deferred.exceptionHook=function(l,d){e.console&&e.console.warn&&l&&Ul.test(l.name)&&e.console.warn("jQuery.Deferred exception: "+l.message,l.stack,d)},p.readyException=function(l){e.setTimeout(function(){throw l})};var Pe=p.Deferred();p.fn.ready=function(l){return Pe.then(l).catch(function(d){p.readyException(d)}),this},p.extend({isReady:!1,readyWait:1,ready:function(l){(l===!0?--p.readyWait:p.isReady)||(p.isReady=!0,!(l!==!0&&--p.readyWait>0)&&Pe.resolveWith(x,[p]))}}),p.ready.then=Pe.then;function ze(){x.removeEventListener("DOMContentLoaded",ze),e.removeEventListener("load",ze),p.ready()}x.readyState==="complete"||x.readyState!=="loading"&&!x.documentElement.doScroll?e.setTimeout(p.ready):(x.addEventListener("DOMContentLoaded",ze),e.addEventListener("load",ze));var Ye=function(l,d,A,C,T,S,b){var _=0,P=l.length,M=A==null;if(w(A)==="object"){T=!0;for(_ in A)Ye(l,d,_,A[_],!0,S,b)}else if(C!==void 0&&(T=!0,E(C)||(b=!0),M&&(b?(d.call(l,C),d=null):(M=d,d=function(Y,q,H){return M.call(p(Y),H)})),d))for(;_<P;_++)d(l[_],A,b?C:C.call(l[_],_,d(l[_],A)));return T?l:M?d.call(l):P?d(l[0],A):S},Jt=/^-ms-/,vt=/-([a-z])/g;function di(l,d){return d.toUpperCase()}function st(l){return l.replace(Jt,"ms-").replace(vt,di)}var fi=function(l){return l.nodeType===1||l.nodeType===9||!+l.nodeType};function Ht(){this.expando=p.expando+Ht.uid++}Ht.uid=1,Ht.prototype={cache:function(l){var d=l[this.expando];return d||(d={},fi(l)&&(l.nodeType?l[this.expando]=d:Object.defineProperty(l,this.expando,{value:d,configurable:!0}))),d},set:function(l,d,A){var C,T=this.cache(l);if(typeof d=="string")T[st(d)]=A;else for(C in d)T[st(C)]=d[C];return T},get:function(l,d){return d===void 0?this.cache(l):l[this.expando]&&l[this.expando][st(d)]},access:function(l,d,A){return d===void 0||d&&typeof d=="string"&&A===void 0?this.get(l,d):(this.set(l,d,A),A!==void 0?A:d)},remove:function(l,d){var A,C=l[this.expando];if(C!==void 0){if(d!==void 0)for(Array.isArray(d)?d=d.map(st):(d=st(d),d=d in C?[d]:d.match(je)||[]),A=d.length;A--;)delete C[d[A]];(d===void 0||p.isEmptyObject(C))&&(l.nodeType?l[this.expando]=void 0:delete l[this.expando])}},hasData:function(l){var d=l[this.expando];return d!==void 0&&!p.isEmptyObject(d)}};var fe=new Ht,Xe=new Ht,tr=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,Ln=/[A-Z]/g;function ir(l){return l==="true"?!0:l==="false"?!1:l==="null"?null:l===+l+""?+l:tr.test(l)?JSON.parse(l):l}function os(l,d,A){var C;if(A===void 0&&l.nodeType===1)if(C="data-"+d.replace(Ln,"-$&").toLowerCase(),A=l.getAttribute(C),typeof A=="string"){try{A=ir(A)}catch{}Xe.set(l,d,A)}else A=void 0;return A}p.extend({hasData:function(l){return Xe.hasData(l)||fe.hasData(l)},data:function(l,d,A){return Xe.access(l,d,A)},removeData:function(l,d){Xe.remove(l,d)},_data:function(l,d,A){return fe.access(l,d,A)},_removeData:function(l,d){fe.remove(l,d)}}),p.fn.extend({data:function(l,d){var A,C,T,S=this[0],b=S&&S.attributes;if(l===void 0){if(this.length&&(T=Xe.get(S),S.nodeType===1&&!fe.get(S,"hasDataAttrs"))){for(A=b.length;A--;)b[A]&&(C=b[A].name,C.indexOf("data-")===0&&(C=st(C.slice(5)),os(S,C,T[C])));fe.set(S,"hasDataAttrs",!0)}return T}return typeof l=="object"?this.each(function(){Xe.set(this,l)}):Ye(this,function(_){var P;if(S&&_===void 0)return P=Xe.get(S,l),P!==void 0||(P=os(S,l),P!==void 0)?P:void 0;this.each(function(){Xe.set(this,l,_)})},null,d,arguments.length>1,null,!0)},removeData:function(l){return this.each(function(){Xe.remove(this,l)})}}),p.extend({queue:function(l,d,A){var C;if(l)return d=(d||"fx")+"queue",C=fe.get(l,d),A&&(!C||Array.isArray(A)?C=fe.access(l,d,p.makeArray(A)):C.push(A)),C||[]},dequeue:function(l,d){d=d||"fx";var A=p.queue(l,d),C=A.length,T=A.shift(),S=p._queueHooks(l,d),b=function(){p.dequeue(l,d)};T==="inprogress"&&(T=A.shift(),C--),T&&(d==="fx"&&A.unshift("inprogress"),delete S.stop,T.call(l,b,S)),!C&&S&&S.empty.fire()},_queueHooks:function(l,d){var A=d+"queueHooks";return fe.get(l,A)||fe.access(l,A,{empty:p.Callbacks("once memory").add(function(){fe.remove(l,[d+"queue",A])})})}}),p.fn.extend({queue:function(l,d){var A=2;return typeof l!="string"&&(d=l,l="fx",A--),arguments.length<A?p.queue(this[0],l):d===void 0?this:this.each(function(){var C=p.queue(this,l,d);p._queueHooks(this,l),l==="fx"&&C[0]!=="inprogress"&&p.dequeue(this,l)})},dequeue:function(l){return this.each(function(){p.dequeue(this,l)})},clearQueue:function(l){return this.queue(l||"fx",[])},promise:function(l,d){var A,C=1,T=p.Deferred(),S=this,b=this.length,_=function(){--C||T.resolveWith(S,[S])};for(typeof l!="string"&&(d=l,l=void 0),l=l||"fx";b--;)A=fe.get(S[b],l+"queueHooks"),A&&A.empty&&(C++,A.empty.add(_));return _(),T.promise(d)}});var gi=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,ls=new RegExp("^(?:([+-])=|)("+gi+")([a-z%]*)$","i"),ei=["Top","Right","Bottom","Left"],Ti=x.documentElement,Hi=function(l){return p.contains(l.ownerDocument,l)},xg={composed:!0};Ti.getRootNode&&(Hi=function(l){return p.contains(l.ownerDocument,l)||l.getRootNode(xg)===l.ownerDocument});var sr=function(l,d){return l=d||l,l.style.display==="none"||l.style.display===""&&Hi(l)&&p.css(l,"display")==="none"};function $l(l,d,A,C){var T,S,b=20,_=C?function(){return C.cur()}:function(){return p.css(l,d,"")},P=_(),M=A&&A[3]||(p.cssNumber[d]?"":"px"),Y=l.nodeType&&(p.cssNumber[d]||M!=="px"&&+P)&&ls.exec(p.css(l,d));if(Y&&Y[3]!==M){for(P=P/2,M=M||Y[3],Y=+P||1;b--;)p.style(l,d,Y+M),(1-S)*(1-(S=_()/P||.5))<=0&&(b=0),Y=Y/S;Y=Y*2,p.style(l,d,Y+M),A=A||[]}return A&&(Y=+Y||+P||0,T=A[1]?Y+(A[1]+1)*A[2]:+A[2],C&&(C.unit=M,C.start=Y,C.end=T)),T}var Gl={};function bg(l){var d,A=l.ownerDocument,C=l.nodeName,T=Gl[C];return T||(d=A.body.appendChild(A.createElement(C)),T=p.css(d,"display"),d.parentNode.removeChild(d),T==="none"&&(T="block"),Gl[C]=T,T)}function Vi(l,d){for(var A,C,T=[],S=0,b=l.length;S<b;S++)C=l[S],C.style&&(A=C.style.display,d?(A==="none"&&(T[S]=fe.get(C,"display")||null,T[S]||(C.style.display="")),C.style.display===""&&sr(C)&&(T[S]=bg(C))):A!=="none"&&(T[S]="none",fe.set(C,"display",A)));for(S=0;S<b;S++)T[S]!=null&&(l[S].style.display=T[S]);return l}p.fn.extend({show:function(){return Vi(this,!0)},hide:function(){return Vi(this)},toggle:function(l){return typeof l=="boolean"?l?this.show():this.hide():this.each(function(){sr(this)?p(this).show():p(this).hide()})}});var us=/^(?:checkbox|radio)$/i,Hl=/<([a-z][^\/\0>\x20\t\r\n\f]*)/i,Vl=/^$|^module$|\/(?:java|ecma)script/i;(function(){var l=x.createDocumentFragment(),d=l.appendChild(x.createElement("div")),A=x.createElement("input");A.setAttribute("type","radio"),A.setAttribute("checked","checked"),A.setAttribute("name","t"),d.appendChild(A),m.checkClone=d.cloneNode(!0).cloneNode(!0).lastChild.checked,d.innerHTML="<textarea>x</textarea>",m.noCloneChecked=!!d.cloneNode(!0).lastChild.defaultValue,d.innerHTML="<option></option>",m.option=!!d.lastChild})();var bt={thead:[1,"<table>","</table>"],col:[2,"<table><colgroup>","</colgroup></table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:[0,"",""]};bt.tbody=bt.tfoot=bt.colgroup=bt.caption=bt.thead,bt.th=bt.td,m.option||(bt.optgroup=bt.option=[1,"<select multiple='multiple'>","</select>"]);function gt(l,d){var A;return typeof l.getElementsByTagName<"u"?A=l.getElementsByTagName(d||"*"):typeof l.querySelectorAll<"u"?A=l.querySelectorAll(d||"*"):A=[],d===void 0||d&&F(l,d)?p.merge([l],A):A}function Rn(l,d){for(var A=0,C=l.length;A<C;A++)fe.set(l[A],"globalEval",!d||fe.get(d[A],"globalEval"))}var Lg=/<|&#?\w+;/;function Kl(l,d,A,C,T){for(var S,b,_,P,M,Y,q=d.createDocumentFragment(),H=[],Z=0,Ce=l.length;Z<Ce;Z++)if(S=l[Z],S||S===0)if(w(S)==="object")p.merge(H,S.nodeType?[S]:S);else if(!Lg.test(S))H.push(d.createTextNode(S));else{for(b=b||q.appendChild(d.createElement("div")),_=(Hl.exec(S)||["",""])[1].toLowerCase(),P=bt[_]||bt._default,b.innerHTML=P[1]+p.htmlPrefilter(S)+P[2],Y=P[0];Y--;)b=b.lastChild;p.merge(H,b.childNodes),b=q.firstChild,b.textContent=""}for(q.textContent="",Z=0;S=H[Z++];){if(C&&p.inArray(S,C)>-1){T&&T.push(S);continue}if(M=Hi(S),b=gt(q.appendChild(S),"script"),M&&Rn(b),A)for(Y=0;S=b[Y++];)Vl.test(S.type||"")&&A.push(S)}return q}var Yl=/^([^.]*)(?:\.(.+)|)/;function Ki(){return!0}function Yi(){return!1}function Dn(l,d,A,C,T,S){var b,_;if(typeof d=="object"){typeof A!="string"&&(C=C||A,A=void 0);for(_ in d)Dn(l,_,A,C,d[_],S);return l}if(C==null&&T==null?(T=A,C=A=void 0):T==null&&(typeof A=="string"?(T=C,C=void 0):(T=C,C=A,A=void 0)),T===!1)T=Yi;else if(!T)return l;return S===1&&(b=T,T=function(P){return p().off(P),b.apply(this,arguments)},T.guid=b.guid||(b.guid=p.guid++)),l.each(function(){p.event.add(this,d,T,C,A)})}p.event={global:{},add:function(l,d,A,C,T){var S,b,_,P,M,Y,q,H,Z,Ce,we,Se=fe.get(l);if(fi(l))for(A.handler&&(S=A,A=S.handler,T=S.selector),T&&p.find.matchesSelector(Ti,T),A.guid||(A.guid=p.guid++),(P=Se.events)||(P=Se.events=Object.create(null)),(b=Se.handle)||(b=Se.handle=function(nt){return typeof p<"u"&&p.event.triggered!==nt.type?p.event.dispatch.apply(l,arguments):void 0}),d=(d||"").match(je)||[""],M=d.length;M--;)_=Yl.exec(d[M])||[],Z=we=_[1],Ce=(_[2]||"").split(".").sort(),Z&&(q=p.event.special[Z]||{},Z=(T?q.delegateType:q.bindType)||Z,q=p.event.special[Z]||{},Y=p.extend({type:Z,origType:we,data:C,handler:A,guid:A.guid,selector:T,needsContext:T&&p.expr.match.needsContext.test(T),namespace:Ce.join(".")},S),(H=P[Z])||(H=P[Z]=[],H.delegateCount=0,(!q.setup||q.setup.call(l,C,Ce,b)===!1)&&l.addEventListener&&l.addEventListener(Z,b)),q.add&&(q.add.call(l,Y),Y.handler.guid||(Y.handler.guid=A.guid)),T?H.splice(H.delegateCount++,0,Y):H.push(Y),p.event.global[Z]=!0)},remove:function(l,d,A,C,T){var S,b,_,P,M,Y,q,H,Z,Ce,we,Se=fe.hasData(l)&&fe.get(l);if(!(!Se||!(P=Se.events))){for(d=(d||"").match(je)||[""],M=d.length;M--;){if(_=Yl.exec(d[M])||[],Z=we=_[1],Ce=(_[2]||"").split(".").sort(),!Z){for(Z in P)p.event.remove(l,Z+d[M],A,C,!0);continue}for(q=p.event.special[Z]||{},Z=(C?q.delegateType:q.bindType)||Z,H=P[Z]||[],_=_[2]&&new RegExp("(^|\\.)"+Ce.join("\\.(?:.*\\.|)")+"(\\.|$)"),b=S=H.length;S--;)Y=H[S],(T||we===Y.origType)&&(!A||A.guid===Y.guid)&&(!_||_.test(Y.namespace))&&(!C||C===Y.selector||C==="**"&&Y.selector)&&(H.splice(S,1),Y.selector&&H.delegateCount--,q.remove&&q.remove.call(l,Y));b&&!H.length&&((!q.teardown||q.teardown.call(l,Ce,Se.handle)===!1)&&p.removeEvent(l,Z,Se.handle),delete P[Z])}p.isEmptyObject(P)&&fe.remove(l,"handle events")}},dispatch:function(l){var d,A,C,T,S,b,_=new Array(arguments.length),P=p.event.fix(l),M=(fe.get(this,"events")||Object.create(null))[P.type]||[],Y=p.event.special[P.type]||{};for(_[0]=P,d=1;d<arguments.length;d++)_[d]=arguments[d];if(P.delegateTarget=this,!(Y.preDispatch&&Y.preDispatch.call(this,P)===!1)){for(b=p.event.handlers.call(this,P,M),d=0;(T=b[d++])&&!P.isPropagationStopped();)for(P.currentTarget=T.elem,A=0;(S=T.handlers[A++])&&!P.isImmediatePropagationStopped();)(!P.rnamespace||S.namespace===!1||P.rnamespace.test(S.namespace))&&(P.handleObj=S,P.data=S.data,C=((p.event.special[S.origType]||{}).handle||S.handler).apply(T.elem,_),C!==void 0&&(P.result=C)===!1&&(P.preventDefault(),P.stopPropagation()));return Y.postDispatch&&Y.postDispatch.call(this,P),P.result}},handlers:function(l,d){var A,C,T,S,b,_=[],P=d.delegateCount,M=l.target;if(P&&M.nodeType&&!(l.type==="click"&&l.button>=1)){for(;M!==this;M=M.parentNode||this)if(M.nodeType===1&&!(l.type==="click"&&M.disabled===!0)){for(S=[],b={},A=0;A<P;A++)C=d[A],T=C.selector+" ",b[T]===void 0&&(b[T]=C.needsContext?p(T,this).index(M)>-1:p.find(T,this,null,[M]).length),b[T]&&S.push(C);S.length&&_.push({elem:M,handlers:S})}}return M=this,P<d.length&&_.push({elem:M,handlers:d.slice(P)}),_},addProp:function(l,d){Object.defineProperty(p.Event.prototype,l,{enumerable:!0,configurable:!0,get:E(d)?function(){if(this.originalEvent)return d(this.originalEvent)}:function(){if(this.originalEvent)return this.originalEvent[l]},set:function(A){Object.defineProperty(this,l,{enumerable:!0,configurable:!0,writable:!0,value:A})}})},fix:function(l){return l[p.expando]?l:new p.Event(l)},special:{load:{noBubble:!0},click:{setup:function(l){var d=this||l;return us.test(d.type)&&d.click&&F(d,"input")&&rr(d,"click",!0),!1},trigger:function(l){var d=this||l;return us.test(d.type)&&d.click&&F(d,"input")&&rr(d,"click"),!0},_default:function(l){var d=l.target;return us.test(d.type)&&d.click&&F(d,"input")&&fe.get(d,"click")||F(d,"a")}},beforeunload:{postDispatch:function(l){l.result!==void 0&&l.originalEvent&&(l.originalEvent.returnValue=l.result)}}}};function rr(l,d,A){if(!A){fe.get(l,d)===void 0&&p.event.add(l,d,Ki);return}fe.set(l,d,!1),p.event.add(l,d,{namespace:!1,handler:function(C){var T,S=fe.get(this,d);if(C.isTrigger&1&&this[d]){if(S)(p.event.special[d]||{}).delegateType&&C.stopPropagation();else if(S=r.call(arguments),fe.set(this,d,S),this[d](),T=fe.get(this,d),fe.set(this,d,!1),S!==T)return C.stopImmediatePropagation(),C.preventDefault(),T}else S&&(fe.set(this,d,p.event.trigger(S[0],S.slice(1),this)),C.stopPropagation(),C.isImmediatePropagationStopped=Ki)}})}p.removeEvent=function(l,d,A){l.removeEventListener&&l.removeEventListener(d,A)},p.Event=function(l,d){if(!(this instanceof p.Event))return new p.Event(l,d);l&&l.type?(this.originalEvent=l,this.type=l.type,this.isDefaultPrevented=l.defaultPrevented||l.defaultPrevented===void 0&&l.returnValue===!1?Ki:Yi,this.target=l.target&&l.target.nodeType===3?l.target.parentNode:l.target,this.currentTarget=l.currentTarget,this.relatedTarget=l.relatedTarget):this.type=l,d&&p.extend(this,d),this.timeStamp=l&&l.timeStamp||Date.now(),this[p.expando]=!0},p.Event.prototype={constructor:p.Event,isDefaultPrevented:Yi,isPropagationStopped:Yi,isImmediatePropagationStopped:Yi,isSimulated:!1,preventDefault:function(){var l=this.originalEvent;this.isDefaultPrevented=Ki,l&&!this.isSimulated&&l.preventDefault()},stopPropagation:function(){var l=this.originalEvent;this.isPropagationStopped=Ki,l&&!this.isSimulated&&l.stopPropagation()},stopImmediatePropagation:function(){var l=this.originalEvent;this.isImmediatePropagationStopped=Ki,l&&!this.isSimulated&&l.stopImmediatePropagation(),this.stopPropagation()}},p.each({altKey:!0,bubbles:!0,cancelable:!0,changedTouches:!0,ctrlKey:!0,detail:!0,eventPhase:!0,metaKey:!0,pageX:!0,pageY:!0,shiftKey:!0,view:!0,char:!0,code:!0,charCode:!0,key:!0,keyCode:!0,button:!0,buttons:!0,clientX:!0,clientY:!0,offsetX:!0,offsetY:!0,pointerId:!0,pointerType:!0,screenX:!0,screenY:!0,targetTouches:!0,toElement:!0,touches:!0,which:!0},p.event.addProp),p.each({focus:"focusin",blur:"focusout"},function(l,d){function A(C){if(x.documentMode){var T=fe.get(this,"handle"),S=p.event.fix(C);S.type=C.type==="focusin"?"focus":"blur",S.isSimulated=!0,T(C),S.target===S.currentTarget&&T(S)}else p.event.simulate(d,C.target,p.event.fix(C))}p.event.special[l]={setup:function(){var C;if(rr(this,l,!0),x.documentMode)C=fe.get(this,d),C||this.addEventListener(d,A),fe.set(this,d,(C||0)+1);else return!1},trigger:function(){return rr(this,l),!0},teardown:function(){var C;if(x.documentMode)C=fe.get(this,d)-1,C?fe.set(this,d,C):(this.removeEventListener(d,A),fe.remove(this,d));else return!1},_default:function(C){return fe.get(C.target,l)},delegateType:d},p.event.special[d]={setup:function(){var C=this.ownerDocument||this.document||this,T=x.documentMode?this:C,S=fe.get(T,d);S||(x.documentMode?this.addEventListener(d,A):C.addEventListener(l,A,!0)),fe.set(T,d,(S||0)+1)},teardown:function(){var C=this.ownerDocument||this.document||this,T=x.documentMode?this:C,S=fe.get(T,d)-1;S?fe.set(T,d,S):(x.documentMode?this.removeEventListener(d,A):C.removeEventListener(l,A,!0),fe.remove(T,d))}}}),p.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},function(l,d){p.event.special[l]={delegateType:d,bindType:d,handle:function(A){var C,T=this,S=A.relatedTarget,b=A.handleObj;return(!S||S!==T&&!p.contains(T,S))&&(A.type=b.origType,C=b.handler.apply(this,arguments),A.type=d),C}}}),p.fn.extend({on:function(l,d,A,C){return Dn(this,l,d,A,C)},one:function(l,d,A,C){return Dn(this,l,d,A,C,1)},off:function(l,d,A){var C,T;if(l&&l.preventDefault&&l.handleObj)return C=l.handleObj,p(l.delegateTarget).off(C.namespace?C.origType+"."+C.namespace:C.origType,C.selector,C.handler),this;if(typeof l=="object"){for(T in l)this.off(T,d,l[T]);return this}return(d===!1||typeof d=="function")&&(A=d,d=void 0),A===!1&&(A=Yi),this.each(function(){p.event.remove(this,l,A,d)})}});var Rg=/<script|<style|<link/i,Dg=/checked\s*(?:[^=]|=\s*.checked.)/i,Pg=/^\s*<!\[CDATA\[|\]\]>\s*$/g;function Wl(l,d){return F(l,"table")&&F(d.nodeType!==11?d:d.firstChild,"tr")&&p(l).children("tbody")[0]||l}function _g(l){return l.type=(l.getAttribute("type")!==null)+"/"+l.type,l}function wg(l){return(l.type||"").slice(0,5)==="true/"?l.type=l.type.slice(5):l.removeAttribute("type"),l}function jl(l,d){var A,C,T,S,b,_,P;if(d.nodeType===1){if(fe.hasData(l)&&(S=fe.get(l),P=S.events,P)){fe.remove(d,"handle events");for(T in P)for(A=0,C=P[T].length;A<C;A++)p.event.add(d,T,P[T][A])}Xe.hasData(l)&&(b=Xe.access(l),_=p.extend({},b),Xe.set(d,_))}}function kg(l,d){var A=d.nodeName.toLowerCase();A==="input"&&us.test(l.type)?d.checked=l.checked:(A==="input"||A==="textarea")&&(d.defaultValue=l.defaultValue)}function Wi(l,d,A,C){d=n(d);var T,S,b,_,P,M,Y=0,q=l.length,H=q-1,Z=d[0],Ce=E(Z);if(Ce||q>1&&typeof Z=="string"&&!m.checkClone&&Dg.test(Z))return l.each(function(we){var Se=l.eq(we);Ce&&(d[0]=Z.call(this,we,Se.html())),Wi(Se,d,A,C)});if(q&&(T=Kl(d,l[0].ownerDocument,!1,l,C),S=T.firstChild,T.childNodes.length===1&&(T=S),S||C)){for(b=p.map(gt(T,"script"),_g),_=b.length;Y<q;Y++)P=T,Y!==H&&(P=p.clone(P,!0,!0),_&&p.merge(b,gt(P,"script"))),A.call(l[Y],P,Y);if(_)for(M=b[b.length-1].ownerDocument,p.map(b,wg),Y=0;Y<_;Y++)P=b[Y],Vl.test(P.type||"")&&!fe.access(P,"globalEval")&&p.contains(M,P)&&(P.src&&(P.type||"").toLowerCase()!=="module"?p._evalUrl&&!P.noModule&&p._evalUrl(P.src,{nonce:P.nonce||P.getAttribute("nonce")},M):L(P.textContent.replace(Pg,""),P,M))}return l}function zl(l,d,A){for(var C,T=d?p.filter(d,l):l,S=0;(C=T[S])!=null;S++)!A&&C.nodeType===1&&p.cleanData(gt(C)),C.parentNode&&(A&&Hi(C)&&Rn(gt(C,"script")),C.parentNode.removeChild(C));return l}p.extend({htmlPrefilter:function(l){return l},clone:function(l,d,A){var C,T,S,b,_=l.cloneNode(!0),P=Hi(l);if(!m.noCloneChecked&&(l.nodeType===1||l.nodeType===11)&&!p.isXMLDoc(l))for(b=gt(_),S=gt(l),C=0,T=S.length;C<T;C++)kg(S[C],b[C]);if(d)if(A)for(S=S||gt(l),b=b||gt(_),C=0,T=S.length;C<T;C++)jl(S[C],b[C]);else jl(l,_);return b=gt(_,"script"),b.length>0&&Rn(b,!P&&gt(l,"script")),_},cleanData:function(l){for(var d,A,C,T=p.event.special,S=0;(A=l[S])!==void 0;S++)if(fi(A)){if(d=A[fe.expando]){if(d.events)for(C in d.events)T[C]?p.event.remove(A,C):p.removeEvent(A,C,d.handle);A[fe.expando]=void 0}A[Xe.expando]&&(A[Xe.expando]=void 0)}}}),p.fn.extend({detach:function(l){return zl(this,l,!0)},remove:function(l){return zl(this,l)},text:function(l){return Ye(this,function(d){return d===void 0?p.text(this):this.empty().each(function(){(this.nodeType===1||this.nodeType===11||this.nodeType===9)&&(this.textContent=d)})},null,l,arguments.length)},append:function(){return Wi(this,arguments,function(l){if(this.nodeType===1||this.nodeType===11||this.nodeType===9){var d=Wl(this,l);d.appendChild(l)}})},prepend:function(){return Wi(this,arguments,function(l){if(this.nodeType===1||this.nodeType===11||this.nodeType===9){var d=Wl(this,l);d.insertBefore(l,d.firstChild)}})},before:function(){return Wi(this,arguments,function(l){this.parentNode&&this.parentNode.insertBefore(l,this)})},after:function(){return Wi(this,arguments,function(l){this.parentNode&&this.parentNode.insertBefore(l,this.nextSibling)})},empty:function(){for(var l,d=0;(l=this[d])!=null;d++)l.nodeType===1&&(p.cleanData(gt(l,!1)),l.textContent="");return this},clone:function(l,d){return l=l??!1,d=d??l,this.map(function(){return p.clone(this,l,d)})},html:function(l){return Ye(this,function(d){var A=this[0]||{},C=0,T=this.length;if(d===void 0&&A.nodeType===1)return A.innerHTML;if(typeof d=="string"&&!Rg.test(d)&&!bt[(Hl.exec(d)||["",""])[1].toLowerCase()]){d=p.htmlPrefilter(d);try{for(;C<T;C++)A=this[C]||{},A.nodeType===1&&(p.cleanData(gt(A,!1)),A.innerHTML=d);A=0}catch{}}A&&this.empty().append(d)},null,l,arguments.length)},replaceWith:function(){var l=[];return Wi(this,arguments,function(d){var A=this.parentNode;p.inArray(this,l)<0&&(p.cleanData(gt(this)),A&&A.replaceChild(d,this))},l)}}),p.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(l,d){p.fn[l]=function(A){for(var C,T=[],S=p(A),b=S.length-1,_=0;_<=b;_++)C=_===b?this:this.clone(!0),p(S[_])[d](C),o.apply(T,C.get());return this.pushStack(T)}});var Pn=new RegExp("^("+gi+")(?!px)[a-z%]+$","i"),_n=/^--/,nr=function(l){var d=l.ownerDocument.defaultView;return(!d||!d.opener)&&(d=e),d.getComputedStyle(l)},ql=function(l,d,A){var C,T,S={};for(T in d)S[T]=l.style[T],l.style[T]=d[T];C=A.call(l);for(T in d)l.style[T]=S[T];return C},Mg=new RegExp(ei.join("|"),"i");(function(){function l(){if(M){P.style.cssText="position:absolute;left:-11111px;width:60px;margin-top:1px;padding:0;border:0",M.style.cssText="position:relative;display:block;box-sizing:border-box;overflow:scroll;margin:auto;border:1px;padding:1px;width:60%;top:1%",Ti.appendChild(P).appendChild(M);var Y=e.getComputedStyle(M);A=Y.top!=="1%",_=d(Y.marginLeft)===12,M.style.right="60%",S=d(Y.right)===36,C=d(Y.width)===36,M.style.position="absolute",T=d(M.offsetWidth/3)===12,Ti.removeChild(P),M=null}}function d(Y){return Math.round(parseFloat(Y))}var A,C,T,S,b,_,P=x.createElement("div"),M=x.createElement("div");M.style&&(M.style.backgroundClip="content-box",M.cloneNode(!0).style.backgroundClip="",m.clearCloneStyle=M.style.backgroundClip==="content-box",p.extend(m,{boxSizingReliable:function(){return l(),C},pixelBoxStyles:function(){return l(),S},pixelPosition:function(){return l(),A},reliableMarginLeft:function(){return l(),_},scrollboxSize:function(){return l(),T},reliableTrDimensions:function(){var Y,q,H,Z;return b==null&&(Y=x.createElement("table"),q=x.createElement("tr"),H=x.createElement("div"),Y.style.cssText="position:absolute;left:-11111px;border-collapse:separate",q.style.cssText="box-sizing:content-box;border:1px solid",q.style.height="1px",H.style.height="9px",H.style.display="block",Ti.appendChild(Y).appendChild(q).appendChild(H),Z=e.getComputedStyle(q),b=parseInt(Z.height,10)+parseInt(Z.borderTopWidth,10)+parseInt(Z.borderBottomWidth,10)===q.offsetHeight,Ti.removeChild(Y)),b}}))})();function cs(l,d,A){var C,T,S,b,_=_n.test(d),P=l.style;return A=A||nr(l),A&&(b=A.getPropertyValue(d)||A[d],_&&b&&(b=b.replace(ce,"$1")||void 0),b===""&&!Hi(l)&&(b=p.style(l,d)),!m.pixelBoxStyles()&&Pn.test(b)&&Mg.test(d)&&(C=P.width,T=P.minWidth,S=P.maxWidth,P.minWidth=P.maxWidth=P.width=b,b=A.width,P.width=C,P.minWidth=T,P.maxWidth=S)),b!==void 0?b+"":b}function Xl(l,d){return{get:function(){if(l()){delete this.get;return}return(this.get=d).apply(this,arguments)}}}var Zl=["Webkit","Moz","ms"],Ql=x.createElement("div").style,Jl={};function Og(l){for(var d=l[0].toUpperCase()+l.slice(1),A=Zl.length;A--;)if(l=Zl[A]+d,l in Ql)return l}function wn(l){var d=p.cssProps[l]||Jl[l];return d||(l in Ql?l:Jl[l]=Og(l)||l)}var Fg=/^(none|table(?!-c[ea]).+)/,Ng={position:"absolute",visibility:"hidden",display:"block"},eu={letterSpacing:"0",fontWeight:"400"};function tu(l,d,A){var C=ls.exec(d);return C?Math.max(0,C[2]-(A||0))+(C[3]||"px"):d}function kn(l,d,A,C,T,S){var b=d==="width"?1:0,_=0,P=0,M=0;if(A===(C?"border":"content"))return 0;for(;b<4;b+=2)A==="margin"&&(M+=p.css(l,A+ei[b],!0,T)),C?(A==="content"&&(P-=p.css(l,"padding"+ei[b],!0,T)),A!=="margin"&&(P-=p.css(l,"border"+ei[b]+"Width",!0,T))):(P+=p.css(l,"padding"+ei[b],!0,T),A!=="padding"?P+=p.css(l,"border"+ei[b]+"Width",!0,T):_+=p.css(l,"border"+ei[b]+"Width",!0,T));return!C&&S>=0&&(P+=Math.max(0,Math.ceil(l["offset"+d[0].toUpperCase()+d.slice(1)]-S-P-_-.5))||0),P+M}function iu(l,d,A){var C=nr(l),T=!m.boxSizingReliable()||A,S=T&&p.css(l,"boxSizing",!1,C)==="border-box",b=S,_=cs(l,d,C),P="offset"+d[0].toUpperCase()+d.slice(1);if(Pn.test(_)){if(!A)return _;_="auto"}return(!m.boxSizingReliable()&&S||!m.reliableTrDimensions()&&F(l,"tr")||_==="auto"||!parseFloat(_)&&p.css(l,"display",!1,C)==="inline")&&l.getClientRects().length&&(S=p.css(l,"boxSizing",!1,C)==="border-box",b=P in l,b&&(_=l[P])),_=parseFloat(_)||0,_+kn(l,d,A||(S?"border":"content"),b,C,_)+"px"}p.extend({cssHooks:{opacity:{get:function(l,d){if(d){var A=cs(l,"opacity");return A===""?"1":A}}}},cssNumber:{animationIterationCount:!0,aspectRatio:!0,borderImageSlice:!0,columnCount:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,gridArea:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnStart:!0,gridRow:!0,gridRowEnd:!0,gridRowStart:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,scale:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeMiterlimit:!0,strokeOpacity:!0},cssProps:{},style:function(l,d,A,C){if(!(!l||l.nodeType===3||l.nodeType===8||!l.style)){var T,S,b,_=st(d),P=_n.test(d),M=l.style;if(P||(d=wn(_)),b=p.cssHooks[d]||p.cssHooks[_],A!==void 0){if(S=typeof A,S==="string"&&(T=ls.exec(A))&&T[1]&&(A=$l(l,d,T),S="number"),A==null||A!==A)return;S==="number"&&!P&&(A+=T&&T[3]||(p.cssNumber[_]?"":"px")),!m.clearCloneStyle&&A===""&&d.indexOf("background")===0&&(M[d]="inherit"),(!b||!("set"in b)||(A=b.set(l,A,C))!==void 0)&&(P?M.setProperty(d,A):M[d]=A)}else return b&&"get"in b&&(T=b.get(l,!1,C))!==void 0?T:M[d]}},css:function(l,d,A,C){var T,S,b,_=st(d),P=_n.test(d);return P||(d=wn(_)),b=p.cssHooks[d]||p.cssHooks[_],b&&"get"in b&&(T=b.get(l,!0,A)),T===void 0&&(T=cs(l,d,C)),T==="normal"&&d in eu&&(T=eu[d]),A===""||A?(S=parseFloat(T),A===!0||isFinite(S)?S||0:T):T}}),p.each(["height","width"],function(l,d){p.cssHooks[d]={get:function(A,C,T){if(C)return Fg.test(p.css(A,"display"))&&(!A.getClientRects().length||!A.getBoundingClientRect().width)?ql(A,Ng,function(){return iu(A,d,T)}):iu(A,d,T)},set:function(A,C,T){var S,b=nr(A),_=!m.scrollboxSize()&&b.position==="absolute",P=_||T,M=P&&p.css(A,"boxSizing",!1,b)==="border-box",Y=T?kn(A,d,T,M,b):0;return M&&_&&(Y-=Math.ceil(A["offset"+d[0].toUpperCase()+d.slice(1)]-parseFloat(b[d])-kn(A,d,"border",!1,b)-.5)),Y&&(S=ls.exec(C))&&(S[3]||"px")!=="px"&&(A.style[d]=C,C=p.css(A,d)),tu(A,C,Y)}}}),p.cssHooks.marginLeft=Xl(m.reliableMarginLeft,function(l,d){if(d)return(parseFloat(cs(l,"marginLeft"))||l.getBoundingClientRect().left-ql(l,{marginLeft:0},function(){return l.getBoundingClientRect().left}))+"px"}),p.each({margin:"",padding:"",border:"Width"},function(l,d){p.cssHooks[l+d]={expand:function(A){for(var C=0,T={},S=typeof A=="string"?A.split(" "):[A];C<4;C++)T[l+ei[C]+d]=S[C]||S[C-2]||S[0];return T}},l!=="margin"&&(p.cssHooks[l+d].set=tu)}),p.fn.extend({css:function(l,d){return Ye(this,function(A,C,T){var S,b,_={},P=0;if(Array.isArray(C)){for(S=nr(A),b=C.length;P<b;P++)_[C[P]]=p.css(A,C[P],!1,S);return _}return T!==void 0?p.style(A,C,T):p.css(A,C)},l,d,arguments.length>1)}});function pt(l,d,A,C,T){return new pt.prototype.init(l,d,A,C,T)}p.Tween=pt,pt.prototype={constructor:pt,init:function(l,d,A,C,T,S){this.elem=l,this.prop=A,this.easing=T||p.easing._default,this.options=d,this.start=this.now=this.cur(),this.end=C,this.unit=S||(p.cssNumber[A]?"":"px")},cur:function(){var l=pt.propHooks[this.prop];return l&&l.get?l.get(this):pt.propHooks._default.get(this)},run:function(l){var d,A=pt.propHooks[this.prop];return this.options.duration?this.pos=d=p.easing[this.easing](l,this.options.duration*l,0,1,this.options.duration):this.pos=d=l,this.now=(this.end-this.start)*d+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),A&&A.set?A.set(this):pt.propHooks._default.set(this),this}},pt.prototype.init.prototype=pt.prototype,pt.propHooks={_default:{get:function(l){var d;return l.elem.nodeType!==1||l.elem[l.prop]!=null&&l.elem.style[l.prop]==null?l.elem[l.prop]:(d=p.css(l.elem,l.prop,""),!d||d==="auto"?0:d)},set:function(l){p.fx.step[l.prop]?p.fx.step[l.prop](l):l.elem.nodeType===1&&(p.cssHooks[l.prop]||l.elem.style[wn(l.prop)]!=null)?p.style(l.elem,l.prop,l.now+l.unit):l.elem[l.prop]=l.now}}},pt.propHooks.scrollTop=pt.propHooks.scrollLeft={set:function(l){l.elem.nodeType&&l.elem.parentNode&&(l.elem[l.prop]=l.now)}},p.easing={linear:function(l){return l},swing:function(l){return .5-Math.cos(l*Math.PI)/2},_default:"swing"},p.fx=pt.prototype.init,p.fx.step={};var ji,ar,Bg=/^(?:toggle|show|hide)$/,Ug=/queueHooks$/;function Mn(){ar&&(x.hidden===!1&&e.requestAnimationFrame?e.requestAnimationFrame(Mn):e.setTimeout(Mn,p.fx.interval),p.fx.tick())}function su(){return e.setTimeout(function(){ji=void 0}),ji=Date.now()}function or(l,d){var A,C=0,T={height:l};for(d=d?1:0;C<4;C+=2-d)A=ei[C],T["margin"+A]=T["padding"+A]=l;return d&&(T.opacity=T.width=l),T}function ru(l,d,A){for(var C,T=(wt.tweeners[d]||[]).concat(wt.tweeners["*"]),S=0,b=T.length;S<b;S++)if(C=T[S].call(A,d,l))return C}function $g(l,d,A){var C,T,S,b,_,P,M,Y,q="width"in d||"height"in d,H=this,Z={},Ce=l.style,we=l.nodeType&&sr(l),Se=fe.get(l,"fxshow");A.queue||(b=p._queueHooks(l,"fx"),b.unqueued==null&&(b.unqueued=0,_=b.empty.fire,b.empty.fire=function(){b.unqueued||_()}),b.unqueued++,H.always(function(){H.always(function(){b.unqueued--,p.queue(l,"fx").length||b.empty.fire()})}));for(C in d)if(T=d[C],Bg.test(T)){if(delete d[C],S=S||T==="toggle",T===(we?"hide":"show"))if(T==="show"&&Se&&Se[C]!==void 0)we=!0;else continue;Z[C]=Se&&Se[C]||p.style(l,C)}if(P=!p.isEmptyObject(d),!(!P&&p.isEmptyObject(Z))){q&&l.nodeType===1&&(A.overflow=[Ce.overflow,Ce.overflowX,Ce.overflowY],M=Se&&Se.display,M==null&&(M=fe.get(l,"display")),Y=p.css(l,"display"),Y==="none"&&(M?Y=M:(Vi([l],!0),M=l.style.display||M,Y=p.css(l,"display"),Vi([l]))),(Y==="inline"||Y==="inline-block"&&M!=null)&&p.css(l,"float")==="none"&&(P||(H.done(function(){Ce.display=M}),M==null&&(Y=Ce.display,M=Y==="none"?"":Y)),Ce.display="inline-block")),A.overflow&&(Ce.overflow="hidden",H.always(function(){Ce.overflow=A.overflow[0],Ce.overflowX=A.overflow[1],Ce.overflowY=A.overflow[2]})),P=!1;for(C in Z)P||(Se?"hidden"in Se&&(we=Se.hidden):Se=fe.access(l,"fxshow",{display:M}),S&&(Se.hidden=!we),we&&Vi([l],!0),H.done(function(){we||Vi([l]),fe.remove(l,"fxshow");for(C in Z)p.style(l,C,Z[C])})),P=ru(we?Se[C]:0,C,H),C in Se||(Se[C]=P.start,we&&(P.end=P.start,P.start=0))}}function Gg(l,d){var A,C,T,S,b;for(A in l)if(C=st(A),T=d[C],S=l[A],Array.isArray(S)&&(T=S[1],S=l[A]=S[0]),A!==C&&(l[C]=S,delete l[A]),b=p.cssHooks[C],b&&"expand"in b){S=b.expand(S),delete l[C];for(A in S)A in l||(l[A]=S[A],d[A]=T)}else d[C]=T}function wt(l,d,A){var C,T,S=0,b=wt.prefilters.length,_=p.Deferred().always(function(){delete P.elem}),P=function(){if(T)return!1;for(var q=ji||su(),H=Math.max(0,M.startTime+M.duration-q),Z=H/M.duration||0,Ce=1-Z,we=0,Se=M.tweens.length;we<Se;we++)M.tweens[we].run(Ce);return _.notifyWith(l,[M,Ce,H]),Ce<1&&Se?H:(Se||_.notifyWith(l,[M,1,0]),_.resolveWith(l,[M]),!1)},M=_.promise({elem:l,props:p.extend({},d),opts:p.extend(!0,{specialEasing:{},easing:p.easing._default},A),originalProperties:d,originalOptions:A,startTime:ji||su(),duration:A.duration,tweens:[],createTween:function(q,H){var Z=p.Tween(l,M.opts,q,H,M.opts.specialEasing[q]||M.opts.easing);return M.tweens.push(Z),Z},stop:function(q){var H=0,Z=q?M.tweens.length:0;if(T)return this;for(T=!0;H<Z;H++)M.tweens[H].run(1);return q?(_.notifyWith(l,[M,1,0]),_.resolveWith(l,[M,q])):_.rejectWith(l,[M,q]),this}}),Y=M.props;for(Gg(Y,M.opts.specialEasing);S<b;S++)if(C=wt.prefilters[S].call(M,l,Y,M.opts),C)return E(C.stop)&&(p._queueHooks(M.elem,M.opts.queue).stop=C.stop.bind(C)),C;return p.map(Y,ru,M),E(M.opts.start)&&M.opts.start.call(l,M),M.progress(M.opts.progress).done(M.opts.done,M.opts.complete).fail(M.opts.fail).always(M.opts.always),p.fx.timer(p.extend(P,{elem:l,anim:M,queue:M.opts.queue})),M}p.Animation=p.extend(wt,{tweeners:{"*":[function(l,d){var A=this.createTween(l,d);return $l(A.elem,l,ls.exec(d),A),A}]},tweener:function(l,d){E(l)?(d=l,l=["*"]):l=l.match(je);for(var A,C=0,T=l.length;C<T;C++)A=l[C],wt.tweeners[A]=wt.tweeners[A]||[],wt.tweeners[A].unshift(d)},prefilters:[$g],prefilter:function(l,d){d?wt.prefilters.unshift(l):wt.prefilters.push(l)}}),p.speed=function(l,d,A){var C=l&&typeof l=="object"?p.extend({},l):{complete:A||!A&&d||E(l)&&l,duration:l,easing:A&&d||d&&!E(d)&&d};return p.fx.off?C.duration=0:typeof C.duration!="number"&&(C.duration in p.fx.speeds?C.duration=p.fx.speeds[C.duration]:C.duration=p.fx.speeds._default),(C.queue==null||C.queue===!0)&&(C.queue="fx"),C.old=C.complete,C.complete=function(){E(C.old)&&C.old.call(this),C.queue&&p.dequeue(this,C.queue)},C},p.fn.extend({fadeTo:function(l,d,A,C){return this.filter(sr).css("opacity",0).show().end().animate({opacity:d},l,A,C)},animate:function(l,d,A,C){var T=p.isEmptyObject(l),S=p.speed(d,A,C),b=function(){var _=wt(this,p.extend({},l),S);(T||fe.get(this,"finish"))&&_.stop(!0)};return b.finish=b,T||S.queue===!1?this.each(b):this.queue(S.queue,b)},stop:function(l,d,A){var C=function(T){var S=T.stop;delete T.stop,S(A)};return typeof l!="string"&&(A=d,d=l,l=void 0),d&&this.queue(l||"fx",[]),this.each(function(){var T=!0,S=l!=null&&l+"queueHooks",b=p.timers,_=fe.get(this);if(S)_[S]&&_[S].stop&&C(_[S]);else for(S in _)_[S]&&_[S].stop&&Ug.test(S)&&C(_[S]);for(S=b.length;S--;)b[S].elem===this&&(l==null||b[S].queue===l)&&(b[S].anim.stop(A),T=!1,b.splice(S,1));(T||!A)&&p.dequeue(this,l)})},finish:function(l){return l!==!1&&(l=l||"fx"),this.each(function(){var d,A=fe.get(this),C=A[l+"queue"],T=A[l+"queueHooks"],S=p.timers,b=C?C.length:0;for(A.finish=!0,p.queue(this,l,[]),T&&T.stop&&T.stop.call(this,!0),d=S.length;d--;)S[d].elem===this&&S[d].queue===l&&(S[d].anim.stop(!0),S.splice(d,1));for(d=0;d<b;d++)C[d]&&C[d].finish&&C[d].finish.call(this);delete A.finish})}}),p.each(["toggle","show","hide"],function(l,d){var A=p.fn[d];p.fn[d]=function(C,T,S){return C==null||typeof C=="boolean"?A.apply(this,arguments):this.animate(or(d,!0),C,T,S)}}),p.each({slideDown:or("show"),slideUp:or("hide"),slideToggle:or("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(l,d){p.fn[l]=function(A,C,T){return this.animate(d,A,C,T)}}),p.timers=[],p.fx.tick=function(){var l,d=0,A=p.timers;for(ji=Date.now();d<A.length;d++)l=A[d],!l()&&A[d]===l&&A.splice(d--,1);A.length||p.fx.stop(),ji=void 0},p.fx.timer=function(l){p.timers.push(l),p.fx.start()},p.fx.interval=13,p.fx.start=function(){ar||(ar=!0,Mn())},p.fx.stop=function(){ar=null},p.fx.speeds={slow:600,fast:200,_default:400},p.fn.delay=function(l,d){return l=p.fx&&p.fx.speeds[l]||l,d=d||"fx",this.queue(d,function(A,C){var T=e.setTimeout(A,l);C.stop=function(){e.clearTimeout(T)}})},(function(){var l=x.createElement("input"),d=x.createElement("select"),A=d.appendChild(x.createElement("option"));l.type="checkbox",m.checkOn=l.value!=="",m.optSelected=A.selected,l=x.createElement("input"),l.value="t",l.type="radio",m.radioValue=l.value==="t"})();var nu,hs=p.expr.attrHandle;p.fn.extend({attr:function(l,d){return Ye(this,p.attr,l,d,arguments.length>1)},removeAttr:function(l){return this.each(function(){p.removeAttr(this,l)})}}),p.extend({attr:function(l,d,A){var C,T,S=l.nodeType;if(!(S===3||S===8||S===2)){if(typeof l.getAttribute>"u")return p.prop(l,d,A);if((S!==1||!p.isXMLDoc(l))&&(T=p.attrHooks[d.toLowerCase()]||(p.expr.match.bool.test(d)?nu:void 0)),A!==void 0){if(A===null){p.removeAttr(l,d);return}return T&&"set"in T&&(C=T.set(l,A,d))!==void 0?C:(l.setAttribute(d,A+""),A)}return T&&"get"in T&&(C=T.get(l,d))!==null?C:(C=p.find.attr(l,d),C??void 0)}},attrHooks:{type:{set:function(l,d){if(!m.radioValue&&d==="radio"&&F(l,"input")){var A=l.value;return l.setAttribute("type",d),A&&(l.value=A),d}}}},removeAttr:function(l,d){var A,C=0,T=d&&d.match(je);if(T&&l.nodeType===1)for(;A=T[C++];)l.removeAttribute(A)}}),nu={set:function(l,d,A){return d===!1?p.removeAttr(l,A):l.setAttribute(A,A),A}},p.each(p.expr.match.bool.source.match(/\w+/g),function(l,d){var A=hs[d]||p.find.attr;hs[d]=function(C,T,S){var b,_,P=T.toLowerCase();return S||(_=hs[P],hs[P]=b,b=A(C,T,S)!=null?P:null,hs[P]=_),b}});var Hg=/^(?:input|select|textarea|button)$/i,Vg=/^(?:a|area)$/i;p.fn.extend({prop:function(l,d){return Ye(this,p.prop,l,d,arguments.length>1)},removeProp:function(l){return this.each(function(){delete this[p.propFix[l]||l]})}}),p.extend({prop:function(l,d,A){var C,T,S=l.nodeType;if(!(S===3||S===8||S===2))return(S!==1||!p.isXMLDoc(l))&&(d=p.propFix[d]||d,T=p.propHooks[d]),A!==void 0?T&&"set"in T&&(C=T.set(l,A,d))!==void 0?C:l[d]=A:T&&"get"in T&&(C=T.get(l,d))!==null?C:l[d]},propHooks:{tabIndex:{get:function(l){var d=p.find.attr(l,"tabindex");return d?parseInt(d,10):Hg.test(l.nodeName)||Vg.test(l.nodeName)&&l.href?0:-1}}},propFix:{for:"htmlFor",class:"className"}}),m.optSelected||(p.propHooks.selected={get:function(l){var d=l.parentNode;return d&&d.parentNode&&d.parentNode.selectedIndex,null},set:function(l){var d=l.parentNode;d&&(d.selectedIndex,d.parentNode&&d.parentNode.selectedIndex)}}),p.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){p.propFix[this.toLowerCase()]=this});function Si(l){var d=l.match(je)||[];return d.join(" ")}function xi(l){return l.getAttribute&&l.getAttribute("class")||""}function On(l){return Array.isArray(l)?l:typeof l=="string"?l.match(je)||[]:[]}p.fn.extend({addClass:function(l){var d,A,C,T,S,b;return E(l)?this.each(function(_){p(this).addClass(l.call(this,_,xi(this)))}):(d=On(l),d.length?this.each(function(){if(C=xi(this),A=this.nodeType===1&&" "+Si(C)+" ",A){for(S=0;S<d.length;S++)T=d[S],A.indexOf(" "+T+" ")<0&&(A+=T+" ");b=Si(A),C!==b&&this.setAttribute("class",b)}}):this)},removeClass:function(l){var d,A,C,T,S,b;return E(l)?this.each(function(_){p(this).removeClass(l.call(this,_,xi(this)))}):arguments.length?(d=On(l),d.length?this.each(function(){if(C=xi(this),A=this.nodeType===1&&" "+Si(C)+" ",A){for(S=0;S<d.length;S++)for(T=d[S];A.indexOf(" "+T+" ")>-1;)A=A.replace(" "+T+" "," ");b=Si(A),C!==b&&this.setAttribute("class",b)}}):this):this.attr("class","")},toggleClass:function(l,d){var A,C,T,S,b=typeof l,_=b==="string"||Array.isArray(l);return E(l)?this.each(function(P){p(this).toggleClass(l.call(this,P,xi(this),d),d)}):typeof d=="boolean"&&_?d?this.addClass(l):this.removeClass(l):(A=On(l),this.each(function(){if(_)for(S=p(this),T=0;T<A.length;T++)C=A[T],S.hasClass(C)?S.removeClass(C):S.addClass(C);else(l===void 0||b==="boolean")&&(C=xi(this),C&&fe.set(this,"__className__",C),this.setAttribute&&this.setAttribute("class",C||l===!1?"":fe.get(this,"__className__")||""))}))},hasClass:function(l){var d,A,C=0;for(d=" "+l+" ";A=this[C++];)if(A.nodeType===1&&(" "+Si(xi(A))+" ").indexOf(d)>-1)return!0;return!1}});var Kg=/\r/g;p.fn.extend({val:function(l){var d,A,C,T=this[0];return arguments.length?(C=E(l),this.each(function(S){var b;this.nodeType===1&&(C?b=l.call(this,S,p(this).val()):b=l,b==null?b="":typeof b=="number"?b+="":Array.isArray(b)&&(b=p.map(b,function(_){return _==null?"":_+""})),d=p.valHooks[this.type]||p.valHooks[this.nodeName.toLowerCase()],(!d||!("set"in d)||d.set(this,b,"value")===void 0)&&(this.value=b))})):T?(d=p.valHooks[T.type]||p.valHooks[T.nodeName.toLowerCase()],d&&"get"in d&&(A=d.get(T,"value"))!==void 0?A:(A=T.value,typeof A=="string"?A.replace(Kg,""):A??"")):void 0}}),p.extend({valHooks:{option:{get:function(l){var d=p.find.attr(l,"value");return d??Si(p.text(l))}},select:{get:function(l){var d,A,C,T=l.options,S=l.selectedIndex,b=l.type==="select-one",_=b?null:[],P=b?S+1:T.length;for(S<0?C=P:C=b?S:0;C<P;C++)if(A=T[C],(A.selected||C===S)&&!A.disabled&&(!A.parentNode.disabled||!F(A.parentNode,"optgroup"))){if(d=p(A).val(),b)return d;_.push(d)}return _},set:function(l,d){for(var A,C,T=l.options,S=p.makeArray(d),b=T.length;b--;)C=T[b],(C.selected=p.inArray(p.valHooks.option.get(C),S)>-1)&&(A=!0);return A||(l.selectedIndex=-1),S}}}}),p.each(["radio","checkbox"],function(){p.valHooks[this]={set:function(l,d){if(Array.isArray(d))return l.checked=p.inArray(p(l).val(),d)>-1}},m.checkOn||(p.valHooks[this].get=function(l){return l.getAttribute("value")===null?"on":l.value})});var ds=e.location,au={guid:Date.now()},Fn=/\?/;p.parseXML=function(l){var d,A;if(!l||typeof l!="string")return null;try{d=new e.DOMParser().parseFromString(l,"text/xml")}catch{}return A=d&&d.getElementsByTagName("parsererror")[0],(!d||A)&&p.error("Invalid XML: "+(A?p.map(A.childNodes,function(C){return C.textContent}).join(`
50
- `):l)),d};var ou=/^(?:focusinfocus|focusoutblur)$/,lu=function(l){l.stopPropagation()};p.extend(p.event,{trigger:function(l,d,A,C){var T,S,b,_,P,M,Y,q,H=[A||x],Z=f.call(l,"type")?l.type:l,Ce=f.call(l,"namespace")?l.namespace.split("."):[];if(S=q=b=A=A||x,!(A.nodeType===3||A.nodeType===8)&&!ou.test(Z+p.event.triggered)&&(Z.indexOf(".")>-1&&(Ce=Z.split("."),Z=Ce.shift(),Ce.sort()),P=Z.indexOf(":")<0&&"on"+Z,l=l[p.expando]?l:new p.Event(Z,typeof l=="object"&&l),l.isTrigger=C?2:3,l.namespace=Ce.join("."),l.rnamespace=l.namespace?new RegExp("(^|\\.)"+Ce.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,l.result=void 0,l.target||(l.target=A),d=d==null?[l]:p.makeArray(d,[l]),Y=p.event.special[Z]||{},!(!C&&Y.trigger&&Y.trigger.apply(A,d)===!1))){if(!C&&!Y.noBubble&&!v(A)){for(_=Y.delegateType||Z,ou.test(_+Z)||(S=S.parentNode);S;S=S.parentNode)H.push(S),b=S;b===(A.ownerDocument||x)&&H.push(b.defaultView||b.parentWindow||e)}for(T=0;(S=H[T++])&&!l.isPropagationStopped();)q=S,l.type=T>1?_:Y.bindType||Z,M=(fe.get(S,"events")||Object.create(null))[l.type]&&fe.get(S,"handle"),M&&M.apply(S,d),M=P&&S[P],M&&M.apply&&fi(S)&&(l.result=M.apply(S,d),l.result===!1&&l.preventDefault());return l.type=Z,!C&&!l.isDefaultPrevented()&&(!Y._default||Y._default.apply(H.pop(),d)===!1)&&fi(A)&&P&&E(A[Z])&&!v(A)&&(b=A[P],b&&(A[P]=null),p.event.triggered=Z,l.isPropagationStopped()&&q.addEventListener(Z,lu),A[Z](),l.isPropagationStopped()&&q.removeEventListener(Z,lu),p.event.triggered=void 0,b&&(A[P]=b)),l.result}},simulate:function(l,d,A){var C=p.extend(new p.Event,A,{type:l,isSimulated:!0});p.event.trigger(C,null,d)}}),p.fn.extend({trigger:function(l,d){return this.each(function(){p.event.trigger(l,d,this)})},triggerHandler:function(l,d){var A=this[0];if(A)return p.event.trigger(l,d,A,!0)}});var Yg=/\[\]$/,uu=/\r?\n/g,Wg=/^(?:submit|button|image|reset|file)$/i,jg=/^(?:input|select|textarea|keygen)/i;function Nn(l,d,A,C){var T;if(Array.isArray(d))p.each(d,function(S,b){A||Yg.test(l)?C(l,b):Nn(l+"["+(typeof b=="object"&&b!=null?S:"")+"]",b,A,C)});else if(!A&&w(d)==="object")for(T in d)Nn(l+"["+T+"]",d[T],A,C);else C(l,d)}p.param=function(l,d){var A,C=[],T=function(S,b){var _=E(b)?b():b;C[C.length]=encodeURIComponent(S)+"="+encodeURIComponent(_??"")};if(l==null)return"";if(Array.isArray(l)||l.jquery&&!p.isPlainObject(l))p.each(l,function(){T(this.name,this.value)});else for(A in l)Nn(A,l[A],d,T);return C.join("&")},p.fn.extend({serialize:function(){return p.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var l=p.prop(this,"elements");return l?p.makeArray(l):this}).filter(function(){var l=this.type;return this.name&&!p(this).is(":disabled")&&jg.test(this.nodeName)&&!Wg.test(l)&&(this.checked||!us.test(l))}).map(function(l,d){var A=p(this).val();return A==null?null:Array.isArray(A)?p.map(A,function(C){return{name:d.name,value:C.replace(uu,`\r
51
- `)}}):{name:d.name,value:A.replace(uu,`\r
52
- `)}}).get()}});var zg=/%20/g,qg=/#.*$/,Xg=/([?&])_=[^&]*/,Zg=/^(.*?):[ \t]*([^\r\n]*)$/mg,Qg=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Jg=/^(?:GET|HEAD)$/,ep=/^\/\//,cu={},Bn={},hu="*/".concat("*"),Un=x.createElement("a");Un.href=ds.href;function du(l){return function(d,A){typeof d!="string"&&(A=d,d="*");var C,T=0,S=d.toLowerCase().match(je)||[];if(E(A))for(;C=S[T++];)C[0]==="+"?(C=C.slice(1)||"*",(l[C]=l[C]||[]).unshift(A)):(l[C]=l[C]||[]).push(A)}}function fu(l,d,A,C){var T={},S=l===Bn;function b(_){var P;return T[_]=!0,p.each(l[_]||[],function(M,Y){var q=Y(d,A,C);if(typeof q=="string"&&!S&&!T[q])return d.dataTypes.unshift(q),b(q),!1;if(S)return!(P=q)}),P}return b(d.dataTypes[0])||!T["*"]&&b("*")}function $n(l,d){var A,C,T=p.ajaxSettings.flatOptions||{};for(A in d)d[A]!==void 0&&((T[A]?l:C||(C={}))[A]=d[A]);return C&&p.extend(!0,l,C),l}function tp(l,d,A){for(var C,T,S,b,_=l.contents,P=l.dataTypes;P[0]==="*";)P.shift(),C===void 0&&(C=l.mimeType||d.getResponseHeader("Content-Type"));if(C){for(T in _)if(_[T]&&_[T].test(C)){P.unshift(T);break}}if(P[0]in A)S=P[0];else{for(T in A){if(!P[0]||l.converters[T+" "+P[0]]){S=T;break}b||(b=T)}S=S||b}if(S)return S!==P[0]&&P.unshift(S),A[S]}function ip(l,d,A,C){var T,S,b,_,P,M={},Y=l.dataTypes.slice();if(Y[1])for(b in l.converters)M[b.toLowerCase()]=l.converters[b];for(S=Y.shift();S;)if(l.responseFields[S]&&(A[l.responseFields[S]]=d),!P&&C&&l.dataFilter&&(d=l.dataFilter(d,l.dataType)),P=S,S=Y.shift(),S){if(S==="*")S=P;else if(P!=="*"&&P!==S){if(b=M[P+" "+S]||M["* "+S],!b){for(T in M)if(_=T.split(" "),_[1]===S&&(b=M[P+" "+_[0]]||M["* "+_[0]],b)){b===!0?b=M[T]:M[T]!==!0&&(S=_[0],Y.unshift(_[1]));break}}if(b!==!0)if(b&&l.throws)d=b(d);else try{d=b(d)}catch(q){return{state:"parsererror",error:b?q:"No conversion from "+P+" to "+S}}}}return{state:"success",data:d}}p.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:ds.href,type:"GET",isLocal:Qg.test(ds.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":hu,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":p.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(l,d){return d?$n($n(l,p.ajaxSettings),d):$n(p.ajaxSettings,l)},ajaxPrefilter:du(cu),ajaxTransport:du(Bn),ajax:function(l,d){typeof l=="object"&&(d=l,l=void 0),d=d||{};var A,C,T,S,b,_,P,M,Y,q,H=p.ajaxSetup({},d),Z=H.context||H,Ce=H.context&&(Z.nodeType||Z.jquery)?p(Z):p.event,we=p.Deferred(),Se=p.Callbacks("once memory"),nt=H.statusCode||{},et={},Vt={},Kt="canceled",_e={readyState:0,getResponseHeader:function(Me){var We;if(P){if(!S)for(S={};We=Zg.exec(T);)S[We[1].toLowerCase()+" "]=(S[We[1].toLowerCase()+" "]||[]).concat(We[2]);We=S[Me.toLowerCase()+" "]}return We==null?null:We.join(", ")},getAllResponseHeaders:function(){return P?T:null},setRequestHeader:function(Me,We){return P==null&&(Me=Vt[Me.toLowerCase()]=Vt[Me.toLowerCase()]||Me,et[Me]=We),this},overrideMimeType:function(Me){return P==null&&(H.mimeType=Me),this},statusCode:function(Me){var We;if(Me)if(P)_e.always(Me[_e.status]);else for(We in Me)nt[We]=[nt[We],Me[We]];return this},abort:function(Me){var We=Me||Kt;return A&&A.abort(We),bi(0,We),this}};if(we.promise(_e),H.url=((l||H.url||ds.href)+"").replace(ep,ds.protocol+"//"),H.type=d.method||d.type||H.method||H.type,H.dataTypes=(H.dataType||"*").toLowerCase().match(je)||[""],H.crossDomain==null){_=x.createElement("a");try{_.href=H.url,_.href=_.href,H.crossDomain=Un.protocol+"//"+Un.host!=_.protocol+"//"+_.host}catch{H.crossDomain=!0}}if(H.data&&H.processData&&typeof H.data!="string"&&(H.data=p.param(H.data,H.traditional)),fu(cu,H,d,_e),P)return _e;M=p.event&&H.global,M&&p.active++===0&&p.event.trigger("ajaxStart"),H.type=H.type.toUpperCase(),H.hasContent=!Jg.test(H.type),C=H.url.replace(qg,""),H.hasContent?H.data&&H.processData&&(H.contentType||"").indexOf("application/x-www-form-urlencoded")===0&&(H.data=H.data.replace(zg,"+")):(q=H.url.slice(C.length),H.data&&(H.processData||typeof H.data=="string")&&(C+=(Fn.test(C)?"&":"?")+H.data,delete H.data),H.cache===!1&&(C=C.replace(Xg,"$1"),q=(Fn.test(C)?"&":"?")+"_="+au.guid+++q),H.url=C+q),H.ifModified&&(p.lastModified[C]&&_e.setRequestHeader("If-Modified-Since",p.lastModified[C]),p.etag[C]&&_e.setRequestHeader("If-None-Match",p.etag[C])),(H.data&&H.hasContent&&H.contentType!==!1||d.contentType)&&_e.setRequestHeader("Content-Type",H.contentType),_e.setRequestHeader("Accept",H.dataTypes[0]&&H.accepts[H.dataTypes[0]]?H.accepts[H.dataTypes[0]]+(H.dataTypes[0]!=="*"?", "+hu+"; q=0.01":""):H.accepts["*"]);for(Y in H.headers)_e.setRequestHeader(Y,H.headers[Y]);if(H.beforeSend&&(H.beforeSend.call(Z,_e,H)===!1||P))return _e.abort();if(Kt="abort",Se.add(H.complete),_e.done(H.success),_e.fail(H.error),A=fu(Bn,H,d,_e),!A)bi(-1,"No Transport");else{if(_e.readyState=1,M&&Ce.trigger("ajaxSend",[_e,H]),P)return _e;H.async&&H.timeout>0&&(b=e.setTimeout(function(){_e.abort("timeout")},H.timeout));try{P=!1,A.send(et,bi)}catch(Me){if(P)throw Me;bi(-1,Me)}}function bi(Me,We,gs,Hn){var Yt,ps,Wt,pi,Ai,Lt=We;P||(P=!0,b&&e.clearTimeout(b),A=void 0,T=Hn||"",_e.readyState=Me>0?4:0,Yt=Me>=200&&Me<300||Me===304,gs&&(pi=tp(H,_e,gs)),!Yt&&p.inArray("script",H.dataTypes)>-1&&p.inArray("json",H.dataTypes)<0&&(H.converters["text script"]=function(){}),pi=ip(H,pi,_e,Yt),Yt?(H.ifModified&&(Ai=_e.getResponseHeader("Last-Modified"),Ai&&(p.lastModified[C]=Ai),Ai=_e.getResponseHeader("etag"),Ai&&(p.etag[C]=Ai)),Me===204||H.type==="HEAD"?Lt="nocontent":Me===304?Lt="notmodified":(Lt=pi.state,ps=pi.data,Wt=pi.error,Yt=!Wt)):(Wt=Lt,(Me||!Lt)&&(Lt="error",Me<0&&(Me=0))),_e.status=Me,_e.statusText=(We||Lt)+"",Yt?we.resolveWith(Z,[ps,Lt,_e]):we.rejectWith(Z,[_e,Lt,Wt]),_e.statusCode(nt),nt=void 0,M&&Ce.trigger(Yt?"ajaxSuccess":"ajaxError",[_e,H,Yt?ps:Wt]),Se.fireWith(Z,[_e,Lt]),M&&(Ce.trigger("ajaxComplete",[_e,H]),--p.active||p.event.trigger("ajaxStop")))}return _e},getJSON:function(l,d,A){return p.get(l,d,A,"json")},getScript:function(l,d){return p.get(l,void 0,d,"script")}}),p.each(["get","post"],function(l,d){p[d]=function(A,C,T,S){return E(C)&&(S=S||T,T=C,C=void 0),p.ajax(p.extend({url:A,type:d,dataType:S,data:C,success:T},p.isPlainObject(A)&&A))}}),p.ajaxPrefilter(function(l){var d;for(d in l.headers)d.toLowerCase()==="content-type"&&(l.contentType=l.headers[d]||"")}),p._evalUrl=function(l,d,A){return p.ajax({url:l,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,converters:{"text script":function(){}},dataFilter:function(C){p.globalEval(C,d,A)}})},p.fn.extend({wrapAll:function(l){var d;return this[0]&&(E(l)&&(l=l.call(this[0])),d=p(l,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&d.insertBefore(this[0]),d.map(function(){for(var A=this;A.firstElementChild;)A=A.firstElementChild;return A}).append(this)),this},wrapInner:function(l){return E(l)?this.each(function(d){p(this).wrapInner(l.call(this,d))}):this.each(function(){var d=p(this),A=d.contents();A.length?A.wrapAll(l):d.append(l)})},wrap:function(l){var d=E(l);return this.each(function(A){p(this).wrapAll(d?l.call(this,A):l)})},unwrap:function(l){return this.parent(l).not("body").each(function(){p(this).replaceWith(this.childNodes)}),this}}),p.expr.pseudos.hidden=function(l){return!p.expr.pseudos.visible(l)},p.expr.pseudos.visible=function(l){return!!(l.offsetWidth||l.offsetHeight||l.getClientRects().length)},p.ajaxSettings.xhr=function(){try{return new e.XMLHttpRequest}catch{}};var sp={0:200,1223:204},fs=p.ajaxSettings.xhr();m.cors=!!fs&&"withCredentials"in fs,m.ajax=fs=!!fs,p.ajaxTransport(function(l){var d,A;if(m.cors||fs&&!l.crossDomain)return{send:function(C,T){var S,b=l.xhr();if(b.open(l.type,l.url,l.async,l.username,l.password),l.xhrFields)for(S in l.xhrFields)b[S]=l.xhrFields[S];l.mimeType&&b.overrideMimeType&&b.overrideMimeType(l.mimeType),!l.crossDomain&&!C["X-Requested-With"]&&(C["X-Requested-With"]="XMLHttpRequest");for(S in C)b.setRequestHeader(S,C[S]);d=function(_){return function(){d&&(d=A=b.onload=b.onerror=b.onabort=b.ontimeout=b.onreadystatechange=null,_==="abort"?b.abort():_==="error"?typeof b.status!="number"?T(0,"error"):T(b.status,b.statusText):T(sp[b.status]||b.status,b.statusText,(b.responseType||"text")!=="text"||typeof b.responseText!="string"?{binary:b.response}:{text:b.responseText},b.getAllResponseHeaders()))}},b.onload=d(),A=b.onerror=b.ontimeout=d("error"),b.onabort!==void 0?b.onabort=A:b.onreadystatechange=function(){b.readyState===4&&e.setTimeout(function(){d&&A()})},d=d("abort");try{b.send(l.hasContent&&l.data||null)}catch(_){if(d)throw _}},abort:function(){d&&d()}}}),p.ajaxPrefilter(function(l){l.crossDomain&&(l.contents.script=!1)}),p.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(l){return p.globalEval(l),l}}}),p.ajaxPrefilter("script",function(l){l.cache===void 0&&(l.cache=!1),l.crossDomain&&(l.type="GET")}),p.ajaxTransport("script",function(l){if(l.crossDomain||l.scriptAttrs){var d,A;return{send:function(C,T){d=p("<script>").attr(l.scriptAttrs||{}).prop({charset:l.scriptCharset,src:l.url}).on("load error",A=function(S){d.remove(),A=null,S&&T(S.type==="error"?404:200,S.type)}),x.head.appendChild(d[0])},abort:function(){A&&A()}}}});var gu=[],Gn=/(=)\?(?=&|$)|\?\?/;p.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var l=gu.pop()||p.expando+"_"+au.guid++;return this[l]=!0,l}}),p.ajaxPrefilter("json jsonp",function(l,d,A){var C,T,S,b=l.jsonp!==!1&&(Gn.test(l.url)?"url":typeof l.data=="string"&&(l.contentType||"").indexOf("application/x-www-form-urlencoded")===0&&Gn.test(l.data)&&"data");if(b||l.dataTypes[0]==="jsonp")return C=l.jsonpCallback=E(l.jsonpCallback)?l.jsonpCallback():l.jsonpCallback,b?l[b]=l[b].replace(Gn,"$1"+C):l.jsonp!==!1&&(l.url+=(Fn.test(l.url)?"&":"?")+l.jsonp+"="+C),l.converters["script json"]=function(){return S||p.error(C+" was not called"),S[0]},l.dataTypes[0]="json",T=e[C],e[C]=function(){S=arguments},A.always(function(){T===void 0?p(e).removeProp(C):e[C]=T,l[C]&&(l.jsonpCallback=d.jsonpCallback,gu.push(C)),S&&E(T)&&T(S[0]),S=T=void 0}),"script"}),m.createHTMLDocument=(function(){var l=x.implementation.createHTMLDocument("").body;return l.innerHTML="<form></form><form></form>",l.childNodes.length===2})(),p.parseHTML=function(l,d,A){if(typeof l!="string")return[];typeof d=="boolean"&&(A=d,d=!1);var C,T,S;return d||(m.createHTMLDocument?(d=x.implementation.createHTMLDocument(""),C=d.createElement("base"),C.href=x.location.href,d.head.appendChild(C)):d=x),T=ee.exec(l),S=!A&&[],T?[d.createElement(T[1])]:(T=Kl([l],d,S),S&&S.length&&p(S).remove(),p.merge([],T.childNodes))},p.fn.load=function(l,d,A){var C,T,S,b=this,_=l.indexOf(" ");return _>-1&&(C=Si(l.slice(_)),l=l.slice(0,_)),E(d)?(A=d,d=void 0):d&&typeof d=="object"&&(T="POST"),b.length>0&&p.ajax({url:l,type:T||"GET",dataType:"html",data:d}).done(function(P){S=arguments,b.html(C?p("<div>").append(p.parseHTML(P)).find(C):P)}).always(A&&function(P,M){b.each(function(){A.apply(this,S||[P.responseText,M,P])})}),this},p.expr.pseudos.animated=function(l){return p.grep(p.timers,function(d){return l===d.elem}).length},p.offset={setOffset:function(l,d,A){var C,T,S,b,_,P,M,Y=p.css(l,"position"),q=p(l),H={};Y==="static"&&(l.style.position="relative"),_=q.offset(),S=p.css(l,"top"),P=p.css(l,"left"),M=(Y==="absolute"||Y==="fixed")&&(S+P).indexOf("auto")>-1,M?(C=q.position(),b=C.top,T=C.left):(b=parseFloat(S)||0,T=parseFloat(P)||0),E(d)&&(d=d.call(l,A,p.extend({},_))),d.top!=null&&(H.top=d.top-_.top+b),d.left!=null&&(H.left=d.left-_.left+T),"using"in d?d.using.call(l,H):q.css(H)}},p.fn.extend({offset:function(l){if(arguments.length)return l===void 0?this:this.each(function(T){p.offset.setOffset(this,l,T)});var d,A,C=this[0];if(C)return C.getClientRects().length?(d=C.getBoundingClientRect(),A=C.ownerDocument.defaultView,{top:d.top+A.pageYOffset,left:d.left+A.pageXOffset}):{top:0,left:0}},position:function(){if(this[0]){var l,d,A,C=this[0],T={top:0,left:0};if(p.css(C,"position")==="fixed")d=C.getBoundingClientRect();else{for(d=this.offset(),A=C.ownerDocument,l=C.offsetParent||A.documentElement;l&&(l===A.body||l===A.documentElement)&&p.css(l,"position")==="static";)l=l.parentNode;l&&l!==C&&l.nodeType===1&&(T=p(l).offset(),T.top+=p.css(l,"borderTopWidth",!0),T.left+=p.css(l,"borderLeftWidth",!0))}return{top:d.top-T.top-p.css(C,"marginTop",!0),left:d.left-T.left-p.css(C,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){for(var l=this.offsetParent;l&&p.css(l,"position")==="static";)l=l.offsetParent;return l||Ti})}}),p.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(l,d){var A=d==="pageYOffset";p.fn[l]=function(C){return Ye(this,function(T,S,b){var _;if(v(T)?_=T:T.nodeType===9&&(_=T.defaultView),b===void 0)return _?_[d]:T[S];_?_.scrollTo(A?_.pageXOffset:b,A?b:_.pageYOffset):T[S]=b},l,C,arguments.length)}}),p.each(["top","left"],function(l,d){p.cssHooks[d]=Xl(m.pixelPosition,function(A,C){if(C)return C=cs(A,d),Pn.test(C)?p(A).position()[d]+"px":C})}),p.each({Height:"height",Width:"width"},function(l,d){p.each({padding:"inner"+l,content:d,"":"outer"+l},function(A,C){p.fn[C]=function(T,S){var b=arguments.length&&(A||typeof T!="boolean"),_=A||(T===!0||S===!0?"margin":"border");return Ye(this,function(P,M,Y){var q;return v(P)?C.indexOf("outer")===0?P["inner"+l]:P.document.documentElement["client"+l]:P.nodeType===9?(q=P.documentElement,Math.max(P.body["scroll"+l],q["scroll"+l],P.body["offset"+l],q["offset"+l],q["client"+l])):Y===void 0?p.css(P,M,_):p.style(P,M,Y,_)},d,b?T:void 0,b)}})}),p.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(l,d){p.fn[d]=function(A){return this.on(d,A)}}),p.fn.extend({bind:function(l,d,A){return this.on(l,null,d,A)},unbind:function(l,d){return this.off(l,null,d)},delegate:function(l,d,A,C){return this.on(d,l,A,C)},undelegate:function(l,d,A){return arguments.length===1?this.off(l,"**"):this.off(d,l||"**",A)},hover:function(l,d){return this.on("mouseenter",l).on("mouseleave",d||l)}}),p.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(l,d){p.fn[d]=function(A,C){return arguments.length>0?this.on(d,null,A,C):this.trigger(d)}});var rp=/^[\s\uFEFF\xA0]+|([^\s\uFEFF\xA0])[\s\uFEFF\xA0]+$/g;p.proxy=function(l,d){var A,C,T;if(typeof d=="string"&&(A=l[d],d=l,l=A),!!E(l))return C=r.call(arguments,2),T=function(){return l.apply(d||this,C.concat(r.call(arguments)))},T.guid=l.guid=l.guid||p.guid++,T},p.holdReady=function(l){l?p.readyWait++:p.ready(!0)},p.isArray=Array.isArray,p.parseJSON=JSON.parse,p.nodeName=F,p.isFunction=E,p.isWindow=v,p.camelCase=st,p.type=w,p.now=Date.now,p.isNumeric=function(l){var d=p.type(l);return(d==="number"||d==="string")&&!isNaN(l-parseFloat(l))},p.trim=function(l){return l==null?"":(l+"").replace(rp,"$1")};var np=e.jQuery,ap=e.$;return p.noConflict=function(l){return e.$===p&&(e.$=ap),l&&e.jQuery===p&&(e.jQuery=np),p},typeof t>"u"&&(e.jQuery=e.$=p),p})})(er)),er.exports}var yg=Cg();const ui=mg(yg),Et={None:"none",DualLayer:"dual-layer",Segments:"segments",MinimalWave:"minimal-wave"},Eg={[Et.None]:`
38
+ `),u=[],h=e?Vf(e.baseTime,e.timescale):0;let d="00:00.000",g=0,m=0,A=!1,C,v=!0;o.oncue=function(S){const R=t[i];let b=t.ccOffset;const D=(g-h)/9e4;if(A){if(R!=null&&R.new&&(b=t.ccOffset=R.start),D){if(!e){C=new Error(Bu+"MPEGTS");return}b=D-t.presentationOffset}}else if(e)b=-e.baseTime/e.timescale;else{C=new Error(Bu+"without X-TIMESTAMP-MAP");return}const _=S.endTime-S.startTime,M=Ot((S.startTime+b-m)*9e4,s*9e4)/9e4;S.startTime=Math.max(M,0),S.endTime=Math.max(M+_,0);const p=S.text.trim();S.text=decodeURIComponent(encodeURIComponent(p)),S.id?i&&(S.id=`hlsjscc${i}_${S.id}`):S.id=Qr(S.startTime,S.endTime,p),S.endTime>0&&u.push(S)},o.onparsingerror=function(S){C=S},o.onflush=function(){if(C){a(C);return}n(u)},l.forEach(S=>{if(v)if(S.startsWith("X-TIMESTAMP-MAP=")){v=!1,A=!0,S.slice(16).split(",").forEach(R=>{R.startsWith("LOCAL:")?d=R.slice(6):R.startsWith("MPEGTS:")&&(g=parseInt(R.slice(7)))});try{m=Rp(d)/1e3}catch(R){C=R}return}else S===""&&(v=!1);o.parse(S+`
39
+ `)}),o.flush()}const Jr="stpp.ttml.im1t",Uu=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,$u=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,Pp={left:"start",center:"center",right:"end",start:"start",end:"end"};function Gu(r,e,t,i){const s=xe(new Uint8Array(r),["mdat"]);if(s.length===0){i(new Error("Could not parse IMSC1 mdat"));return}const n=s.map(o=>Mt(o)),a=Hf(e.baseTime,1,e.timescale);try{n.forEach(o=>t(_p(o,a)))}catch(o){i(o)}}function _p(r,e){const s=new DOMParser().parseFromString(r,"text/xml").getElementsByTagName("tt")[0];if(!s)throw new Error("Invalid ttml");const n={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:1},a=Object.keys(n).reduce((d,g)=>(d[g]=s.getAttribute(`ttp:${g}`)||n[g],d),{});!s.getAttribute("ttp:tickRate")&&s.getAttribute("ttp:frameRate")&&(a.tickRate=Number(a.frameRate)*Number(a.subFrameRate));const o=s.getAttribute("xml:space")!=="preserve",l=Hu(ea(s,"styling","style")),u=Hu(ea(s,"layout","region")),h=ea(s,"body","[begin]");return[].map.call(h,d=>{const g=Vu(d,o);if(!g||!d.hasAttribute("begin"))return null;const m=ia(d.getAttribute("begin"),a),A=ia(d.getAttribute("dur"),a);let C=ia(d.getAttribute("end"),a);if(m===null)throw Ku(d);if(C===null){if(A===null)throw Ku(d);C=m+A}const v=new Xr(m-e,C-e,g);v.id=Qr(v.startTime,v.endTime,v.text);const S=u[d.getAttribute("region")],R=l[d.getAttribute("style")],b=kp(S,R,l),{textAlign:D}=b;if(D){const _=Pp[D];_&&(v.lineAlign=_),v.align=D}return je(v,b),v}).filter(d=>d!==null)}function ea(r,e,t){const i=r.getElementsByTagName(e)[0];return i?[].slice.call(i.querySelectorAll(t)):[]}function Hu(r){return r.reduce((e,t)=>{const i=t.getAttribute("xml:id");return i&&(e[i]=t),e},{})}function Vu(r,e){return[].slice.call(r.childNodes).reduce((t,i,s)=>{var n;return i.nodeName==="br"&&s?t+`
40
+ `:(n=i.childNodes)!=null&&n.length?Vu(i,e):e?t+i.textContent.trim().replace(/\s+/g," "):t+i.textContent},"")}function kp(r,e,t){const i="http://www.w3.org/ns/ttml#styling";let s=null;const n=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],a=r!=null&&r.hasAttribute("style")?r.getAttribute("style"):null;return a&&t.hasOwnProperty(a)&&(s=t[a]),n.reduce((o,l)=>{const u=ta(e,i,l)||ta(r,i,l)||ta(s,i,l);return u&&(o[l]=u),o},{})}function ta(r,e,t){return r&&r.hasAttributeNS(e,t)?r.getAttributeNS(e,t):null}function Ku(r){return new Error(`Could not parse ttml timestamp ${r}`)}function ia(r,e){if(!r)return null;let t=Ou(r);return t===null&&(Uu.test(r)?t=wp(r,e):$u.test(r)&&(t=Mp(r,e))),t}function wp(r,e){const t=Uu.exec(r),i=(t[4]|0)+(t[5]|0)/e.subFrameRate;return(t[1]|0)*3600+(t[2]|0)*60+(t[3]|0)+i/e.frameRate}function Mp(r,e){const t=$u.exec(r),i=Number(t[1]);switch(t[2]){case"h":return i*3600;case"m":return i*60;case"ms":return i/1e3;case"f":return i/e.frameRate;case"t":return i/e.tickRate}return i}function sa(r,e,t,i="",s="disabled"){const n=r.ownerDocument.createElement("track");return n.kind=e,n.label=t,i&&(n.srclang=i),n.src="data:,WEBVTT",n.track.mode=s,r.appendChild(n),n}function Op(r){return r.forced&&Xh()?"forced":r.characteristics&&/transcribes-spoken-dialog/gi.test(r.characteristics)&&/describes-music-and-sound/gi.test(r.characteristics)?"captions":"subtitles"}function na(r,e){const t=r.mode;if(t==="disabled"&&(r.mode="hidden"),r.cues&&!r.cues.getCueById(e.id))try{if(r.addCue(e),!r.cues.getCueById(e.id))throw new Error(`addCue is failed for: ${e}`)}catch(i){Ge.debug(`[texttrack-utils]: ${i}`);try{const s=new self.TextTrackCue(e.startTime,e.endTime,e.text);s.id=e.id,r.addCue(s)}catch(s){Ge.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${s}`)}}t==="disabled"&&(r.mode=t)}function ra(r,e,t,i){const s=r.mode;if(s==="disabled"&&(r.mode="hidden"),r.cues&&r.cues.length>0){const n=Np(r.cues,e,t);for(let a=0;a<n.length;a++)(!i||i(n[a]))&&r.removeCue(n[a])}s==="disabled"&&(r.mode=s)}function Fp(r,e){if(e<=r[0].startTime)return 0;const t=r.length-1;if(e>r[t].endTime)return-1;let i=0,s=t,n;for(;i<=s;)if(n=Math.floor((s+i)/2),e<r[n].startTime)s=n-1;else if(e>r[n].startTime&&i<t)i=n+1;else return n;return r[i].startTime-e<e-r[s].startTime?i:s}function Np(r,e,t){const i=[],s=Fp(r,e);if(s>-1)for(let n=s,a=r.length;n<a;n++){const o=r[n];if(o.startTime>=e&&o.endTime<=t)i.push(o);else if(o.startTime>t)return i}return i}class Bp extends wr{constructor(e){super(e,"subtitle-track-controller"),this.media=null,this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.onTextTracksChanged=()=>{if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let t=-1,i=!1;if(this.currentTrack){var s;const o=(s=this.currentTrack.trackNode)==null?void 0:s.track.mode;o==="showing"?(t=this.trackId,i=!0):o==="hidden"&&(t=this.trackId)}if(!i)for(let o=0;o<this.tracksInGroup.length;o++){var n;const l=(n=this.tracksInGroup[o].trackNode)==null?void 0:n.track.mode;if(l==="showing"){t=o;break}else t<0&&l==="hidden"&&(t=o)}if(t>-1){var a;this._subtitleDisplay=((a=this.tracksInGroup[t].trackNode)==null?void 0:a.track.mode)==="showing"}this.setSubtitleTrack(t,!0)},this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,this.onTextTracksChanged=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes()}registerListeners(){const{hls:e}=this;e.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.LEVEL_LOADING,this.onLevelLoading,this),e.on(E.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(E.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(E.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.LEVEL_LOADING,this.onLevelLoading,this),e.off(E.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(E.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(E.ERROR,this.onError,this)}createTracksInGroup(){var e;if(!this.media||!this.hls.config.renderTextTracksNatively)return;this.tracksInGroup.forEach(i=>{i.trackNode||(i.trackNode=sa(this.media,Op(i),i.name,i.lang))});const t=(e=this.currentTrack)==null||(e=e.trackNode)==null?void 0:e.track;t?.mode==="disabled"&&(t.mode=this._subtitleDisplay?"showing":"hidden")}onMediaAttached(e,t){const i=t.media;this.media=i;let s=this.trackId;this.queuedDefaultTrack>-1&&(s=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.setSubtitleTrack(s),this.createTracksInGroup(),this.useTextTrackPolling=!(i.textTracks&&"onchange"in i.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):i.textTracks.addEventListener("change",this.asyncPollTrackChange)}pollTrackChange(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.onTextTracksChanged,e)}onMediaDetaching(e,t){const i=this.media;if(!i)return;const s=!!t.transferMedia;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||i.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId,this.setSubtitleTrack(-1)),this.media=null,!s&&this.hls.config.renderTextTracksNatively&&this.tracksInGroup.forEach(n=>{const a=n.trackNode;a&&(a.track.mode="hidden",a.remove(),n.trackNode=void 0)})}onManifestLoading(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.subtitleTracks}onSubtitleTrackLoaded(e,t){const{id:i,groupId:s,details:n}=t,a=this.tracksInGroup[i];if(!a||a.groupId!==s){this.warn(`Subtitle track with id:${i} and group:${s} not found in active group ${a?.groupId}`);return}const o=a.details;a.details=t.details,this.log(`Subtitle track ${i} "${a.name}" lang:${a.lang} group:${s} loaded [${n.startSN}-${n.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(!t)return;const i=t.subtitleGroups||null,s=this.groupIds;let n=this.currentTrack;if(!i||s?.length!==i?.length||i!=null&&i.some(a=>s?.indexOf(a)===-1)){this.groupIds=i;const a=[];if(this.tracks.forEach(h=>{(h.textCodec===Jr?this.hls.config.enableIMSC1:this.hls.config.enableWebVTT)&&(!i||i.indexOf(h.groupId)>-1?(h.id=a.length,a.push(h)):h.trackNode&&(h.trackNode.remove(),h.trackNode=void 0))}),a.length===this.tracksInGroup.length){let h=!1;for(let d=0;d<a.length;d++)if(a[d]!==this.tracksInGroup[d]){h=!0;break}if(!h)return}a.length&&this.selectDefaultTrack&&!a.some(h=>h.default)&&(this.selectDefaultTrack=!1),this.tracksInGroup=a,this.trackId=-1,this.currentTrack=null;const o=this.hls.config.subtitlePreference;if(!n&&o){this.selectDefaultTrack=!1;const h=ii(o,a);if(h>-1)n=a[h];else{const d=ii(o,this.tracks);n=this.tracks[d]}}let l=this.findTrackId(n);l===-1&&n&&(l=this.findTrackId(null));const u={subtitleTracks:a};this.log(`Updating subtitle tracks, ${a.length} track(s) found in "${i?.join(",")}" group-id`),this.hls.trigger(E.SUBTITLE_TRACKS_UPDATED,u),this.setSubtitleTrack(l),this.createTracksInGroup()}}findTrackId(e){const t=this.tracksInGroup,i=this.selectDefaultTrack;for(let s=0;s<t.length;s++){const n=t[s];if(!(i&&!n.default||!i&&!e)&&(!e||wi(n,e)))return s}if(e){for(let s=0;s<t.length;s++){const n=t[s];if(Ds(e.attrs,n.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return s}for(let s=0;s<t.length;s++){const n=t[s];if(Ds(e.attrs,n.attrs,["LANGUAGE"]))return s}}return-1}onError(e,t){t.fatal||!t.context||t.context.type===ke.SUBTITLE_TRACK&&t.context.id===this.trackId&&Cs(t.context.groupId,this.groupIds)&&this.checkRetry(t)}get allSubtitleTracks(){return this.tracks}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(e){this.selectDefaultTrack=!1,this.setSubtitleTrack(e,!0)}setSubtitleOption(e){if(this.hls.config.subtitlePreference=e,e){if(e.id===-1)return this.setSubtitleTrack(-1,!0),null;const t=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,t.length){const i=this.currentTrack;if(i&&wi(e,i))return i;const s=ii(e,this.tracksInGroup);if(s>-1){const n=this.tracksInGroup[s];return this.setSubtitleTrack(s,!0),n}else{if(i)return null;{const n=ii(e,t);if(n>-1)return t[n]}}}}return null}loadPlaylist(e){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentTrack)&&this.scheduleLoading(this.currentTrack,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);const i=e.id,s=e.groupId,n=this.getUrlWithDirectives(e.url,t),a=e.details,o=a?.age;this.log(`Loading subtitle ${i} "${e.name}" lang:${e.lang} group:${s}${t?.msn!==void 0?" at sn "+t.msn+" part "+t.part:""}${o&&a.live?" age "+o.toFixed(1)+(a.type&&" "+a.type||""):""} ${n}`),this.hls.trigger(E.SUBTITLE_TRACK_LOADING,{url:n,id:i,groupId:s,deliveryDirectives:t||null,track:e})}toggleTrackModes(){if(!this.media||!this.hls.config.renderTextTracksNatively)return;const e=this.currentTrack;this.tracksInGroup.forEach(t=>{if(t.trackNode){const i=t===e?this._subtitleDisplay?"showing":"hidden":"disabled",s=t.trackNode.track;s.mode!==i&&(s.mode=i)}})}setSubtitleTrack(e,t=!1){const i=this.tracksInGroup;if(this.media||(this.queuedDefaultTrack=e),e<-1||e>=i.length||!se(e)){this.warn(`Invalid subtitle track id: ${e}`);return}const s=this.currentTrack,n=i[e]||null;if(this.trackId=e,this.currentTrack=n,t&&this.toggleTrackModes(),!n){s&&this.hls.trigger(E.SUBTITLE_TRACK_SWITCH,{id:e});return}const a=!!n.details&&!n.details.live;if(n===s&&a)return;this.log(`Switching to subtitle-track ${e}`+(n?` "${n.name}" lang:${n.lang} group:${n.groupId}`:""));const{id:o,groupId:l="",name:u,type:h,url:d}=n;this.hls.trigger(E.SUBTITLE_TRACK_SWITCH,{id:o,groupId:l,name:u,type:h,url:d});const g=this.switchParams(n.url,s?.details,n.details);this.loadPlaylist(g)}}const Sn=2,Up=100;class $p extends Ko{constructor(e,t){super("gap-controller",e.logger),this.hls=void 0,this.fragmentTracker=void 0,this.media=null,this.mediaSource=void 0,this.nudgeRetry=0,this.skipRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.buffered={},this.lastCurrentTime=void 0,this.ended=0,this.waiting=0,this.onMediaPlaying=()=>{this.ended=0,this.waiting=0},this.onMediaWaiting=()=>{var i;(i=this.media)!=null&&i.seeking||(this.waiting=self.performance.now(),this.tick())},this.onMediaEnded=()=>{if(this.hls){var i;this.ended=((i=this.media)==null?void 0:i.currentTime)||1,this.hls.trigger(E.MEDIA_ENDED,{stalled:!1})}},this.hls=e,this.fragmentTracker=t,this.lastCurrentTime=this.getCurrentTime(),this.registerListeners()}registerListeners(){const{hls:e}=this;e&&(e.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.BUFFER_APPENDED,this.onBufferAppended,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.BUFFER_APPENDED,this.onBufferAppended,this))}destroy(){super.destroy(),this.unregisterListeners(),this.media=this.hls=this.fragmentTracker=null,this.mediaSource=void 0}onMediaAttached(e,t){this.setInterval(Up),this.mediaSource=t.mediaSource;const i=this.media=t.media;Ke(i,"playing",this.onMediaPlaying),Ke(i,"waiting",this.onMediaWaiting),Ke(i,"ended",this.onMediaEnded)}onMediaDetaching(e,t){this.clearInterval();const{media:i}=this;i&&(Ve(i,"playing",this.onMediaPlaying),Ve(i,"waiting",this.onMediaWaiting),Ve(i,"ended",this.onMediaEnded),this.media=null),this.mediaSource=void 0}onBufferAppended(e,t){this.buffered=t.timeRanges}get hasBuffered(){return Object.keys(this.buffered).length>0}getCurrentTime(){var e;const t=((e=this.hls)==null?void 0:e.config.timelineOffset)||0;return this.media?Math.max(this.media.currentTime,t):t}tick(){var e;if(!((e=this.media)!=null&&e.readyState)||!this.hasBuffered)return;const t=this.getCurrentTime();this.media.currentTime<t||(this.poll(t,this.lastCurrentTime),this.lastCurrentTime=t)}poll(e,t){var i,s;const n=(i=this.hls)==null?void 0:i.config;if(!n)return;const a=this.media;if(!a)return;const{seeking:o}=a,l=this.seeking&&!o,u=!this.seeking&&o,h=a.paused&&!o||a.ended||a.playbackRate===0;if(this.seeking=o,e!==t){t&&(this.ended=0),this.moved=!0,o||(this.skipRetry=this.nudgeRetry=0,n.nudgeOnVideoHole&&!h&&e>t&&this.nudgeOnVideoHole(e,t)),this.waiting===0&&this.stallResolved(e);return}if(u||l){l&&this.stallResolved(e);return}if(h){this.skipRetry=this.nudgeRetry=0,this.stallResolved(e),!this.ended&&a.ended&&this.hls&&(this.ended=e||1,this.hls.trigger(E.MEDIA_ENDED,{stalled:!1}));return}if(!ve.getBuffered(a).length){this.skipRetry=this.nudgeRetry=0;return}const d=ve.bufferInfo(a,e,0),g=this.fragmentTracker;g&&this.hls&&ju(d,e,g,this.hls);const m=d.nextStart||0;if(o&&g&&this.hls){const M=Yu(this.hls.inFlightFragments,e),p=d.len>Sn,$=!m||M||m-e>Sn&&!g.getPartialFragment(e);if(p||$)return;this.moved=!1}const A=(s=this.hls)==null?void 0:s.latestLevelDetails;if(!this.moved&&this.stalled!==null&&g){if(!(d.len>0)&&!m)return;const p=Math.max(m,d.start||0)-e,N=!!(A!=null&&A.live)?A.targetduration*2:Sn,O=ks(e,g);if(p>0&&(p<=N||O)){a.paused||this._trySkipBufferHole(O);return}}const C=n.detectStallWithCurrentTimeMs,v=self.performance.now(),S=this.waiting;let R=this.stalled;if(R===null)if(S>0&&v-S<C)R=this.stalled=S;else{this.stalled=v;return}const b=v-R;if(!o&&(b>=C||S&&this.moved)&&this.hls){var D;if(((D=this.mediaSource)==null?void 0:D.readyState)==="ended"&&!(A!=null&&A.live)&&Math.abs(e-(A?.edge||0))<1){if(this.ended)return;this.ended=e||1,this.hls.trigger(E.MEDIA_ENDED,{stalled:!0});return}if(this._reportStall(d),!this.media||!this.hls)return;if(a.currentTime!==e){const M=e;e=a.currentTime,this.moved=!0,this.log(`currentTime changed ${M} > ${e}`);return}}const _=ve.bufferInfo(a,e,n.maxBufferHole);this._tryFixBufferStall(_,b,e)}stallResolved(e){const t=this.stalled;if(t&&this.hls&&(this.stalled=null,this.stallReported)){const i=self.performance.now()-t;this.log(`playback not stuck anymore @${e}, after ${Math.round(i)}ms`),this.stallReported=!1,this.waiting=0,this.hls.trigger(E.STALL_RESOLVED,{})}}nudgeOnVideoHole(e,t){var i;const s=this.buffered.video;if(this.hls&&this.media&&this.fragmentTracker&&(i=this.buffered.audio)!=null&&i.length&&s&&s.length>1&&e>s.end(0)){const n=ve.bufferedInfo(ve.timeRangesToArray(this.buffered.audio),e,0);if(n.len>1&&t>=n.start){const a=ve.timeRangesToArray(s),o=ve.bufferedInfo(a,t,0).bufferedIndex;if(o>-1&&o<a.length-1){const l=ve.bufferedInfo(a,e,0).bufferedIndex,u=a[o].end,h=a[o+1].start;if((l===-1||l>o)&&h-u<1&&e-u<2){const d=new Error(`nudging playhead to flush pipeline after video hole. currentTime: ${e} hole: ${u} -> ${h} buffered index: ${l}`);this.warn(d.message),this.media.currentTime+=1e-6;let g=ks(e,this.fragmentTracker);g&&"fragment"in g?g=g.fragment:g||(g=void 0);const m=ve.bufferInfo(this.media,e,0);this.hls.trigger(E.ERROR,{type:me.MEDIA_ERROR,details:U.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:d,reason:d.message,frag:g,buffer:m.len,bufferInfo:m})}}}}}_tryFixBufferStall(e,t,i){var s,n;const{fragmentTracker:a,media:o}=this,l=(s=this.hls)==null?void 0:s.config;if(!o||!a||!l)return;const u=(n=this.hls)==null?void 0:n.latestLevelDetails,h=ks(i,a);if((h||u!=null&&u.live&&i<u.fragmentStart)&&(this._trySkipBufferHole(h)||!this.media))return;const d=e.buffered,g=this.adjacentTraversal(e,i);(d&&d.length>1&&e.len>l.maxBufferHole||e.nextStart&&(e.nextStart-i<l.maxBufferHole||g))&&(t>l.highBufferWatchdogPeriod*1e3||this.waiting)&&(this.warn("Trying to nudge playhead over buffer-hole"),this._tryNudgeBuffer(e))}adjacentTraversal(e,t){const i=this.fragmentTracker,s=e.nextStart;if(i&&s){const n=i.getFragAtPos(t,ge.MAIN),a=i.getFragAtPos(s,ge.MAIN);if(n&&a)return a.sn-n.sn<2}return!1}_reportStall(e){const{hls:t,media:i,stallReported:s,stalled:n}=this;if(!s&&n!==null&&i&&t){this.stallReported=!0;const a=new Error(`Playback stalling at @${i.currentTime} due to low buffer (${Xe(e)})`);this.warn(a.message),t.trigger(E.ERROR,{type:me.MEDIA_ERROR,details:U.BUFFER_STALLED_ERROR,fatal:!1,error:a,buffer:e.len,bufferInfo:e,stalled:{start:n}})}}_trySkipBufferHole(e){const{fragmentTracker:t,media:i,hls:s}=this,n=s?.config;if(!i||!t||!n)return 0;const a=i.currentTime,o=ve.bufferInfo(i,a,0);ju(o,a,t,s);const l=a<o.start?o.start:o.nextStart;if(l){const h=o.len<=n.maxBufferHole,d=o.len>0&&o.len<1&&i.readyState<3,g=l-a;if(g>0&&(h||d)){if(g>n.maxBufferHole){let S=!1;if(a===0){const R=t.getAppendedFrag(0,ge.MAIN);R&&l<R.end&&(S=!0)}if(!S&&e){var u;if(!((u=s.loadLevelObj)!=null&&u.details)||Yu(s.inFlightFragments,l))return 0;let b=!1,D=e.end;for(;D<l;){const _=ks(D,t),M=_?_.duration:0;if(M>0)D+=M;else{b=!0;break}}if(b)return 0}}const{nudgeMaxRetry:m,skipBufferHolePadding:A}=n,C=++this.skipRetry>m,v=Math.max(l,a)+A;if(C||(this.warn(`skipping hole, adjusting currentTime from ${a} to ${v}`),this.moved=!0,i.currentTime=v),!(e!=null&&e.gap)||C){const S=new Error(C?`Playhead still not moving after seeking over buffer hole from ${a} to ${v} after ${n.nudgeMaxRetry} attempts.`:`fragment loaded with buffer holes, seeking from ${a} to ${v}`),R={type:me.MEDIA_ERROR,details:U.BUFFER_SEEK_OVER_HOLE,fatal:C,error:S,reason:S.message,buffer:o.len,bufferInfo:o};e&&("fragment"in e?R.part=e:R.frag=e),s.trigger(E.ERROR,R)}return v}}return 0}_tryNudgeBuffer(e){const{hls:t,media:i,nudgeRetry:s}=this,n=t?.config;if(!i||!n)return 0;const a=i.currentTime;if(this.nudgeRetry++,s<n.nudgeMaxRetry){const o=a+(s+1)*n.nudgeOffset,l=new Error(`Nudging 'currentTime' from ${a} to ${o}`);this.warn(l.message),i.currentTime=o,t.trigger(E.ERROR,{type:me.MEDIA_ERROR,details:U.BUFFER_NUDGE_ON_STALL,error:l,fatal:!1,buffer:e.len,bufferInfo:e})}else{const o=new Error(`Playhead still not moving while enough data buffered @${a} after ${n.nudgeMaxRetry} nudges`);this.error(o.message),t.trigger(E.ERROR,{type:me.MEDIA_ERROR,details:U.BUFFER_STALLED_ERROR,error:o,fatal:!0,buffer:e.len,bufferInfo:e})}}}function Yu(r,e){const t=Wu(r.main);if(t&&t.start<=e)return t;const i=Wu(r.audio);return i&&i.start<=e?i:null}function Wu(r){if(!r)return null;switch(r.state){case Y.IDLE:case Y.STOPPED:case Y.ENDED:case Y.ERROR:return null}return r.frag}function ks(r,e){return e.getAppendedFrag(r,ge.MAIN)||e.getPartialFragment(r)}function ju(r,e,t,i){const s=i.latestLevelDetails,n=ks(e,t);if(dn(i.config)&&!r.nextStart&&s&&n&&i.interstitialsManager){const a="type"in n?n:n.fragment,o=Fo(s,a.sn);o?.level===a.level&&Sl(o,i.interstitialsManager.playerQueue,e)&&(r.nextStart=o.start)}}const Gp=.25;function aa(){if(!(typeof self>"u"))return self.VTTCue||self.TextTrackCue}function oa(r,e,t,i,s){let n=new r(e,t,"");try{n.value=i,s&&(n.type=s)}catch{n=new r(e,t,Xe(s?Ae({type:s},i):i))}return n}const xn=(()=>{const r=aa();try{r&&new r(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();class Hp{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=!0,this.assetCue=void 0,this.onEventCueEnter=()=>{this.hls&&this.hls.trigger(E.EVENT_CUE_ENTER,{})},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=this.onEventCueEnter=null}_registerListeners(){const{hls:e}=this;e&&(e.on(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(E.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(E.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}_unregisterListeners(){const{hls:e}=this;e&&(e.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(E.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(E.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}onMediaAttaching(e,t){this.media=t.media}onMediaAttached(){var e;const t=(e=this.hls)==null?void 0:e.latestLevelDetails;t&&this.updateDateRangeCues(t)}onMediaDetaching(e,t){this.media=null,!t.transferMedia&&(this.id3Track&&(this.id3Track.remove(),this.id3Track=null),this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(e){return sa(e,"metadata","id3","","hidden")}onFragParsingMetadata(e,t){if(!this.media||!this.hls)return;const{enableEmsgMetadataCues:i,enableID3MetadataCues:s}=this.hls.config;if(!i&&!s)return;const{samples:n}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));const a=aa();if(a)for(let o=0;o<n.length;o++){const l=n[o].type;if(l===Et.emsg&&!i||!s)continue;const u=Qa(n[o].data),h=n[o].pts;let d=h+n[o].duration;d>xn&&(d=xn),d-h<=0&&(d=h+Gp);for(let m=0;m<u.length;m++){const A=u[m];if(!Ja(A)){this.updateId3CueEnds(h,l);const C=oa(a,h,d,A,l);C&&this.id3Track.track.addCue(C)}}}}updateId3CueEnds(e,t){var i;const s=(i=this.id3Track)==null?void 0:i.track.cues;if(s)for(let n=s.length;n--;){const a=s[n];a.type===t&&a.startTime<e&&a.endTime===xn&&(a.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:i,type:s}){const{id3Track:n,hls:a}=this;if(!a)return;const{config:{enableEmsgMetadataCues:o,enableID3MetadataCues:l}}=a;if(n&&(o||l)){let u;s==="audio"?u=h=>h.type===Et.audioId3&&l:s==="video"?u=h=>h.type===Et.emsg&&o:u=h=>h.type===Et.audioId3&&l||h.type===Et.emsg&&o,ra(n.track,t,i,u)}}onLevelUpdated(e,{details:t}){this.updateDateRangeCues(t,!0)}onLevelPtsUpdated(e,t){Math.abs(t.drift)>.01&&this.updateDateRangeCues(t.details)}updateDateRangeCues(e,t){if(!this.hls||!this.media)return;const{assetPlayerId:i,timelineOffset:s,enableDateRangeMetadataCues:n,interstitialsController:a}=this.hls.config;if(!n)return;const o=aa();if(i&&s&&!a){const{fragmentStart:C,fragmentEnd:v}=e;let S=this.assetCue;S?(S.startTime=C,S.endTime=v):o&&(S=this.assetCue=oa(o,C,v,{assetPlayerId:this.hls.config.assetPlayerId},"hlsjs.interstitial.asset"),S&&(S.id=i,this.id3Track||(this.id3Track=this.createTrack(this.media)),this.id3Track.track.addCue(S),S.addEventListener("enter",this.onEventCueEnter)))}if(!e.hasProgramDateTime)return;const{id3Track:l}=this,{dateRanges:u}=e,h=Object.keys(u);let d=this.dateRangeCuesAppended;if(l&&t){var g;if((g=l.track.cues)!=null&&g.length){const C=Object.keys(d).filter(v=>h.indexOf(v)===-1);for(let v=C.length;v--;){var m;const S=C[v],R=(m=d[S])==null?void 0:m.cues;delete d[S],R&&Object.keys(R).forEach(b=>{const D=R[b];if(D){D.removeEventListener("enter",this.onEventCueEnter);try{l.track.removeCue(D)}catch{}}})}}else d=this.dateRangeCuesAppended={}}const A=e.fragments[e.fragments.length-1];if(!(h.length===0||!se(A?.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(let C=0;C<h.length;C++){const v=h[C],S=u[v],R=S.startTime,b=d[v],D=b?.cues||{};let _=b?.durationKnown||!1,M=xn;const{duration:p,endDate:$}=S;if($&&p!==null)M=R+p,_=!0;else if(S.endOnNext&&!_){const O=h.reduce((W,q)=>{if(q!==S.id){const z=u[q];if(z.class===S.class&&z.startDate>S.startDate&&(!W||S.startDate<W.startDate))return z}return W},null);O&&(M=O.startTime,_=!0)}const N=Object.keys(S.attr);for(let O=0;O<N.length;O++){const W=N[O];if(!Od(W))continue;const q=D[W];if(q)_&&!(b!=null&&b.durationKnown)?q.endTime=M:Math.abs(q.startTime-R)>.01&&(q.startTime=R,q.endTime=M);else if(o){let z=S.attr[W];Fd(W)&&(z=eo(z));const ne=oa(o,R,M,{key:W,data:z},Et.dateRange);ne&&(ne.id=v,this.id3Track.track.addCue(ne),D[W]=ne,a&&(W==="X-ASSET-LIST"||W==="X-ASSET-URL")&&ne.addEventListener("enter",this.onEventCueEnter))}}d[v]={cues:D,dateRange:S,durationKnown:_}}}}}function qu(){return self.SourceBuffer||self.WebKitSourceBuffer}function zu(){if(!Ei())return!1;const e=qu();return!e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function"}function Vp(){if(!zu())return!1;const r=Ei();return typeof r?.isTypeSupported=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(e=>r.isTypeSupported(As(e,"video")))||["mp4a.40.2","fLaC"].some(e=>r.isTypeSupported(As(e,"audio"))))}function Kp(){var r;const e=qu();return typeof(e==null||(r=e.prototype)==null?void 0:r.changeType)=="function"}var oi={DISABLED:0,SWITCHING:1,SWITCHED:2};const Yp=100;class Xu extends Er{constructor(e,t,i){super(e,t,i,"stream-controller",ge.MAIN),this.audioCodecSwap=!1,this.level=-1,this._forceStartLoad=!1,this._hasEnoughToStart=!1,this.altAudio=oi.DISABLED,this.audioOnly=!1,this._couldBacktrack=!1,this._backtrackFragment=void 0,this.audioCodecSwitch=!1,this.videoBuffer=null,this.onMediaPlaying=()=>{this.tick()},this.onMediaSeeked=()=>{const s=this.media,n=s?s.currentTime:null;if(n===null||!se(n)||(this.log(`Media seeked to ${n}`),!this.getBufferedFrag(n)))return;const a=this.getFwdBufferInfoAtPos(s,n,ge.MAIN,0);if(!a||a.len===0){this.log(`Main buffer empty at ${n} on "seeked" event: ${a&&a.len}`);return}this.tick()},this.registerListeners()}registerListeners(){super.registerListeners();const{hls:e}=this;e.on(E.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.LEVEL_LOADING,this.onLevelLoading,this),e.on(E.LEVEL_LOADED,this.onLevelLoaded,this),e.on(E.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(E.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(E.BUFFER_CREATED,this.onBufferCreated,this),e.on(E.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(E.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){super.unregisterListeners();const{hls:e}=this;e.off(E.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.LEVEL_LOADED,this.onLevelLoaded,this),e.off(E.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(E.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(E.BUFFER_CREATED,this.onBufferCreated,this),e.off(E.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),super.onHandlerDestroying()}startLoad(e,t){if(this.levels){const{lastCurrentTime:i,hls:s}=this;if(this.stopLoad(),this.setInterval(Yp),this.level=-1,!this.startFragRequested){let n=s.startLevel;n===-1&&(s.config.testBandwidth&&this.levels.length>1?(n=0,this.bitrateTest=!0):n=s.firstAutoLevel),s.nextLoadLevel=n,this.level=s.loadLevel,this._hasEnoughToStart=!!t}i>0&&e===-1&&!t&&this.initPTS.length&&(this.log(`Override startPosition with lastCurrentTime @${i}`),e=i),this.state=Y.IDLE,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,!t&&!this.fragmentTracker.hasFragments(this.playlistType)&&(this._hasEnoughToStart=this.startFragRequested=!1),this.tick()}else this._forceStartLoad=!0,this.state=Y.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case Y.WAITING_LEVEL:{const{levels:e,level:t}=this,i=e?.[t],s=i?.details;if(s&&(!s.live||this.levelLastLoaded===i&&!this.waitForLive(i))){if(this.waitForCdnTuneIn(s))break;this.state=Y.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=Y.IDLE;break}break}case Y.FRAG_LOADING_WAITING_RETRY:this.checkRetryDate();break}this.state===Y.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){var e;super.onTickEnd(),(e=this.media)!=null&&e.readyState&&this.media.seeking===!1&&(this.lastCurrentTime=this.media.currentTime),this.checkFragmentChanged()}doTickIdle(){const{hls:e,levelLastLoaded:t,levels:i,media:s}=this;if(t===null||!s&&!this.primaryPrefetch&&(this.startFragRequested||!e.config.startFragPrefetch)||this.altAudio&&this.audioOnly)return;const n=this.buffering?e.nextLoadLevel:e.loadLevel;if(!(i!=null&&i[n]))return;const a=i[n],o=this.getMainFwdBufferInfo();if(o===null)return;const l=this.getLevelDetails();if(l&&this._streamEnded(o,l)){const C={type:this.targetBufferType()};this.hls.trigger(E.BUFFER_EOS,C),this.state=Y.ENDED;return}if(!this.buffering)return;e.loadLevel!==n&&e.manualLevel===-1&&this.log(`Adapting to level ${n} from level ${this.level}`),this.level=e.nextLoadLevel=n;const u=a.details;if(!u||this.state===Y.WAITING_LEVEL||this.waitForLive(a)){this.level=n,this.state=Y.WAITING_LEVEL,this.startFragRequested=!1;return}const h=o.len,d=this.getMaxBufferLength(a.maxBitrate);if(h>=d)return;this.backtrackFragment&&this.backtrackFragment.start>o.end&&(this.backtrackFragment=void 0);const g=this.backtrackFragment?this.backtrackFragment.start:o.end;let m=this.getNextFragment(g,u);if(this.couldBacktrack&&!this.fragPrevious&&m&&st(m)&&this.fragmentTracker.getState(m)!==et.OK){var A;const v=((A=this.backtrackFragment)!=null?A:m).sn-u.startSN,S=u.fragments[v-1];S&&m.cc===S.cc&&(m=S,this.fragmentTracker.removeFragment(S))}else this.backtrackFragment&&o.len&&(this.backtrackFragment=void 0);if(m&&this.isLoopLoading(m,g)){if(!m.gap){const v=this.audioOnly&&!this.altAudio?ze.AUDIO:ze.VIDEO,S=(v===ze.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;S&&this.afterBufferFlushed(S,v)}m=this.getNextFragmentLoopLoading(m,u,o,ge.MAIN,d)}m&&(this.exceedsMaxBuffer(o,d,m)||this.loadFragment(m,a,g))}loadFragment(e,t,i){const s=this.fragmentTracker.getState(e);s===et.NOT_LOADED||s===et.PARTIAL?this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,t)):super.loadFragment(e,t,i):this.clearTrackerIfNeeded(e)}immediateLevelSwitch(){if(this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY),this.altAudio!==oi.DISABLED){var e;(((e=this.getLevelDetails())==null?void 0:e.fragmentStart)||0)>this.lastCurrentTime&&super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio")}}getBufferOutput(){return this.mediaBuffer&&this.altAudio===oi.SWITCHED?this.mediaBuffer:this.media}checkFragmentChanged(){const e=this.fragPlaying;if(!this.checkFragPlaying())return!1;const i=this.fragPlaying;if(i){const s=i.level;this.hls.trigger(E.FRAG_CHANGED,{frag:i,previousFrag:e}),e?.level!==s&&this.hls.trigger(E.LEVEL_SWITCHED,{level:s})}return!0}get backtrackFragment(){return this._backtrackFragment}set backtrackFragment(e){this._backtrackFragment=e}get couldBacktrack(){return this._couldBacktrack}set couldBacktrack(e){this._couldBacktrack=e}abortCurrentFrag(){this.backtrackFragment=void 0,super.abortCurrentFrag()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,this.targetBufferType())}targetBufferType(){return this.altAudio===oi.SWITCHED&&!this.audioOnly?"video":null}onMediaAttached(e,t){super.onMediaAttached(e,t);const i=t.media;Ke(i,"playing",this.onMediaPlaying),Ke(i,"seeked",this.onMediaSeeked)}onMediaDetaching(e,t){const{media:i}=this;i&&(Ve(i,"playing",this.onMediaPlaying),Ve(i,"seeked",this.onMediaSeeked)),this.videoBuffer=null,super.onMediaDetaching(e,t),!t.transferMedia&&(this._hasEnoughToStart=!1)}onManifestLoading(){super.onManifestLoading(),this.log("Trigger BUFFER_RESET"),this.hls.trigger(E.BUFFER_RESET,void 0),this.couldBacktrack=!1,this.backtrackFragment=void 0,this.altAudio=oi.DISABLED,this.audioOnly=!1}onManifestParsed(e,t){let i=!1,s=!1;for(let n=0;n<t.levels.length;n++){const a=t.levels[n].audioCodec;a&&(i=i||a.indexOf("mp4a.40.2")!==-1,s=s||a.indexOf("mp4a.40.5")!==-1)}this.audioCodecSwitch=i&&s&&!Kp(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1}onLevelLoading(e,t){const{levels:i}=this;if(!i||this.state!==Y.IDLE)return;const s=t.levelInfo;(!s.details||s.details.live&&(this.levelLastLoaded!==s||s.details.expired)||this.waitForCdnTuneIn(s.details))&&(this.state=Y.WAITING_LEVEL)}onLevelLoaded(e,t){var i;const{levels:s,startFragRequested:n}=this,a=t.level,o=t.details,l=o.totalduration;if(!s){this.warn(`Levels were reset while loading level ${a}`);return}this.log(`Level ${a} loaded [${o.startSN},${o.endSN}]${o.lastPartSn?`[part-${o.lastPartSn}-${o.lastPartIndex}]`:""}, cc [${o.startCC}, ${o.endCC}] duration:${l}`);const u=t.levelInfo,h=this.fragCurrent;h&&(this.state===Y.FRAG_LOADING||this.state===Y.FRAG_LOADING_WAITING_RETRY)&&h.level!==t.level&&h.loader&&this.abortCurrentFrag();let d=0;if(o.live||(i=u.details)!=null&&i.live){var g;if(this.checkLiveUpdate(o),o.deltaUpdateFailed)return;d=this.alignPlaylists(o,u.details,(g=this.levelLastLoaded)==null?void 0:g.details)}if(u.details=o,this.levelLastLoaded=u,n||this.setStartPosition(o,d),this.hls.trigger(E.LEVEL_UPDATED,{details:o,level:a}),this.state===Y.WAITING_LEVEL){if(this.waitForCdnTuneIn(o))return;this.state=Y.IDLE}n&&o.live&&this.synchronizeToLiveEdge(o),this.initPTS.some((m,A)=>{if(A>=o.startCC)return!0;delete this.initPTS[A]}),this.tick()}synchronizeToLiveEdge(e){const{config:t,media:i}=this;if(!i)return;const s=this.hls.liveSyncPosition,n=this.playhead,a=e.fragmentStart,o=e.edge,l=n>=a-t.maxFragLookUpTolerance&&n<=o;if(s!==null&&i.duration>s&&(n<s||!l)){const h=t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;if((!l&&i.readyState<4||n<o-h)&&(this._hasEnoughToStart||(this.nextLoadPosition=s),i.readyState))if(this.warn(`Playback: ${n} is located too far from the end of live sliding playlist: ${o}, reset currentTime to : ${s}`),this.config.liveSyncMode==="buffered"){var u;const d=ve.bufferInfo(i,s,0);if(!((u=d.buffered)!=null&&u.length)){i.currentTime=s;return}if(d.start<=n){i.currentTime=s;return}const{nextStart:m}=ve.bufferedInfo(d.buffered,n,0);m&&(i.currentTime=m)}else i.currentTime=s}}_handleFragmentLoadProgress(e){var t;const i=e.frag,{part:s,payload:n}=e,{levels:a}=this;if(!a){this.warn(`Levels were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);return}const o=a[i.level];if(!o){this.warn(`Level ${i.level} not found on progress`);return}const l=o.details;if(!l){this.warn(`Dropping fragment ${i.sn} of level ${i.level} after level details were reset`),this.fragmentTracker.removeFragment(i);return}const u=o.videoCodec,h=l.PTSKnown||!l.live,d=(t=i.initSegment)==null?void 0:t.data,g=this._getAudioCodec(o),m=this.transmuxer=this.transmuxer||new Xl(this.hls,ge.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),A=s?s.index:-1,C=A!==-1,{decryptRange:v,byteRange:S}=rn(i,s,this.iframesOnly),R=new dr(i.level,i.sn,i.stats.chunkCount,S?S.end-S.start:n.byteLength,A,C,i.duration,this.iframesOnly,v),b=this.initPTS[i.cc];m.push(n,d,g,u,i,s,l.totalduration,h,R,b)}onAudioTrackSwitching(e,t){const i=this.hls,s=this.altAudio!==oi.DISABLED;if(sn(t.url,i))this.altAudio=oi.SWITCHING;else{if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;const a=this.fragCurrent;a&&(this.log("Switching to main audio track, cancel main fragment load"),a.abortRequests(),this.fragmentTracker.removeFragment(a)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();if(s){this.altAudio=oi.DISABLED,this.fragmentTracker.removeAllFragments(),i.once(E.BUFFER_FLUSHED,()=>{this.hls&&this.hls.trigger(E.AUDIO_TRACK_SWITCHED,t)}),i.trigger(E.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});return}i.trigger(E.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){const i=sn(t.url,this.hls);if(i){const s=this.videoBuffer;s&&this.mediaBuffer!==s&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=s)}this.altAudio=i?oi.SWITCHED:oi.DISABLED,this.tick()}onBufferCreated(e,t){const i=t.tracks;let s,n,a=!1;for(const o in i){const l=i[o];if(l.id==="main"){if(n=o,s=l,o==="video"){const u=i[o];u&&(this.videoBuffer=u.buffer)}}else a=!0}a&&s?(this.log(`Alternate track found, use ${n}.buffered to schedule main fragment loading`),this.mediaBuffer=s.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){const{frag:i,part:s}=t,n=i.type===ge.MAIN;if(n){if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${s?" p: "+s.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}`),this.state===Y.PARSED&&(this.state=Y.IDLE);return}let l=!1;if(st(i)&&(l=!!i.gap&&!i.tagList.some(u=>u[0]==="GAP")),this.fragBufferedComplete(i,s),l){var a;i.stats.retry++;const u=(a=this.levels)==null?void 0:a[i.level];u&&u.fragmentError++}}const o=this.media;o&&(!this._hasEnoughToStart&&ve.getBuffered(o).length&&(this._hasEnoughToStart=!0,this.seekToStartPos()),n&&this.tick())}get hasEnoughToStart(){return this._hasEnoughToStart}onError(e,t){var i;if(t.fatal){this.state=Y.ERROR;return}switch(t.details){case U.FRAG_GAP:case U.FRAG_PARSING_ERROR:case U.FRAG_DECRYPT_ERROR:case U.FRAG_LOAD_ERROR:case U.FRAG_LOAD_TIMEOUT:case U.KEY_LOAD_ERROR:case U.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(ge.MAIN,t);break;case U.LEVEL_LOAD_ERROR:case U.LEVEL_LOAD_TIMEOUT:case U.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===Y.WAITING_LEVEL&&((i=t.context)==null?void 0:i.type)===ke.LEVEL&&(this.state=Y.IDLE);break;case U.BUFFER_APPEND_NO_PROGRESS:if(t.parent!=="main")return;t.frag&&(t.appendsWithoutProgress||0)>=this.config.appendErrorMaxRetry&&(this.warn(`Marking fragment ${t.frag.sn} of level ${t.frag.level} as a gap after ${t.appendsWithoutProgress} appends without buffered range growth, to prevent loop loading`),this.fragmentTracker.addAsGap(t.frag));break;case U.BUFFER_ADD_CODEC_ERROR:case U.BUFFER_APPEND_ERROR:if(t.parent!=="main")return;this.reduceLengthAndFlushBuffer(t)&&this.resetLoadingState();break;case U.BUFFER_FULL_ERROR:if(t.parent!=="main")return;this.reduceLengthAndFlushBuffer(t)&&(!this.config.interstitialsController&&this.config.assetPlayerId?this._hasEnoughToStart=!0:this.flushMainBuffer(0,Number.POSITIVE_INFINITY));break;case U.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onFragLoadEmergencyAborted(){this.state=Y.IDLE,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==ze.AUDIO||!this.altAudio){const i=(t===ze.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;i&&(this.afterBufferFlushed(i,t),this.tick())}}onLevelsUpdated(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level,this.level===-1&&this.resetWhenMissingContext(this.fragCurrent)),this.levels=t.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){const{media:e}=this;if(!e)return;const t=e.currentTime;let i=this.startPosition;if(i>=0&&t<i){if(e.seeking){this.log(`could not seek to ${i}, already seeking at ${t}`);return}const s=this.timelineOffset;s&&i&&(i+=s);const n=this.getLevelDetails(),a=ve.getBuffered(e),o=a.length?a.start(0):0,l=o-i,u=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);(this.config.startOnSegmentBoundary||l>0&&(l<u||this.loadingParts&&l<2*(n?.partTarget||0)))&&(this.log(`adjusting start position by ${l} to match buffer start`),i+=l,this.startPosition=i),t<i&&(this.log(`seek to target start position ${i} from current time ${t} buffer start ${o}`),e.currentTime=i)}}_getAudioCodec(e){let t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t.indexOf("mp4a.40.5")!==-1?t="mp4a.40.2":t="mp4a.40.5"),t}_loadBitrateTestFrag(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then(i=>{const{hls:s}=this,n=i?.frag;if(!n||this.fragContextChanged(n))return;t.fragmentError=0,this.state=Y.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;const a=n.stats;a.parsing.start=a.parsing.end=a.buffering.start=a.buffering.end=self.performance.now(),s.trigger(E.FRAG_LOADED,i),n.bitrateTest=!1}).catch(i=>{this.state===Y.STOPPED||this.state===Y.ERROR||(this.warn(i),this.resetFragmentLoading(e))})}_handleTransmuxComplete(e){const t=this.playlistType,{hls:i}=this,{remuxResult:s,chunkMeta:n}=e,a=this.getCurrentContext(n);if(!a){this.resetWhenMissingContext(n);return}const{frag:o,part:l,level:u}=a,{video:h,text:d,id3:g,initSegment:m}=s,{details:A}=u,C=this.altAudio?void 0:s.audio;if(this.fragContextChanged(o)){this.fragmentTracker.removeFragment(o);return}if(this.state=Y.PARSING,m){const v=m.tracks;if(v){const D=o.initSegment||o;if(this.unhandledEncryptionError(m,o))return;this._bufferInitSegment(u,v,D,n),i.trigger(E.FRAG_PARSING_INIT_SEGMENT,{frag:D,id:t,tracks:v})}const S=m.initPTS,R=m.timescale,b=this.initPTS[o.cc];if(se(S)&&(!b||b.baseTime!==S||b.timescale!==R)){const D=m.trackId;this.initPTS[o.cc]={baseTime:S,timescale:R,trackId:D};const _=this.initPTS.slice(0);i.trigger(E.INIT_PTS_FOUND,{timestampOffsets:_,frag:o,id:t,initPTS:S,timescale:R,trackId:D})}}if(h&&A){C&&h.type==="audiovideo"&&this.logMuxedErr(o);const v=A.fragments[o.sn-1-A.startSN],S=o.sn===A.startSN,R=!v||o.cc>v.cc;if(s.independent!==!1){const{startPTS:b,endPTS:D,startDTS:_,endDTS:M}=h;if(l)l.elementaryStreams[h.type]={startPTS:b,endPTS:D,startDTS:_,endDTS:M};else if(h.firstKeyFrame&&h.independent&&n.id===1&&!R&&(this.couldBacktrack=!0),h.dropped&&h.independent){const p=this.getMainFwdBufferInfo(),$=(p?p.end:this.getLoadPosition())+this.config.maxBufferHole,N=h.firstKeyFramePTS?h.firstKeyFramePTS:b;if(!S&&$<N-this.config.maxBufferHole&&!R){this.backtrack(o);return}else R&&(o.gap=!0);o.setElementaryStreamInfo(h.type,o.start,D,o.start,M,!0)}else S&&b-(A.appliedTimelineOffset||0)>Sn&&(o.gap=!0);o.setElementaryStreamInfo(h.type,b,D,_,M),this.backtrackFragment&&(this.backtrackFragment=o),this.bufferFragmentData(h,o,l,n,S||R)}else if(S||R)o.gap=!0;else{this.backtrack(o);return}}if(C){const{startPTS:v,endPTS:S,startDTS:R,endDTS:b}=C;l&&(l.elementaryStreams[ze.AUDIO]={startPTS:v,endPTS:S,startDTS:R,endDTS:b}),o.setElementaryStreamInfo(ze.AUDIO,v,S,R,b),this.bufferFragmentData(C,o,l,n)}if(A&&g!=null&&g.samples.length){const v={id:t,frag:o,details:A,samples:g.samples};i.trigger(E.FRAG_PARSING_METADATA,v)}if(A&&d){const v={id:t,frag:o,details:A,samples:d.samples};i.trigger(E.FRAG_PARSING_USERDATA,v)}}logMuxedErr(e){this.warn(`${st(e)?"Media":"Init"} segment with muxed audiovideo where only video expected: ${e.url}`)}_bufferInitSegment(e,t,i,s){if(this.state!==Y.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&(delete t.audio,t.audiovideo&&this.logMuxedErr(i));const{audio:n,video:a,audiovideo:o}=t;if(n){const u=e.audioCodec;let h=Js(n.codec,u);if(h==="mp4a"&&(h="mp4a.40.5"),this.audioCodecSwitch){h&&(h.indexOf("mp4a.40.5")!==-1?h="mp4a.40.2":h="mp4a.40.5");const d=n.metadata;d&&"channelCount"in d&&(d.channelCount||1)!==1&&!zh()&&(h="mp4a.40.5")}h&&h.indexOf("mp4a.40.5")!==-1&&Zh()&&n.container!=="audio/mpeg"&&(h="mp4a.40.2",this.log(`Android: force audio codec to ${h}`)),u&&u!==h&&this.log(`Swapping manifest audio codec "${u}" for "${h}"`),n.levelCodec=h,n.id=ge.MAIN,this.log(`Init audio buffer, container:${n.container}, codecs[selected/level/parsed]=[${h||""}/${u||""}/${n.codec}]`),delete t.audiovideo}if(a){a.levelCodec=e.videoCodec,a.id=ge.MAIN;const u=a.codec;if(u?.length===4)switch(u){case"hvc1":case"hev1":a.codec="hvc1.1.6.L120.90";break;case"av01":a.codec="av01.0.04M.08";break;case"avc1":a.codec="avc1.42e01e";break}this.log(`Init video buffer, container:${a.container}, codecs[level/parsed]=[${e.videoCodec||""}/${u}]${a.codec!==u?" parsed-corrected="+a.codec:""}${a.supplemental?" supplemental="+a.supplemental:""}`),delete t.audiovideo}o&&(this.iframesOnly&&this.logMuxedErr(i),this.log(`Init audiovideo buffer, container:${o.container}, codecs[level/parsed]=[${e.codecs}/${o.codec}]`),delete t.video,delete t.audio);const l=Object.keys(t);if(l.length){if(this.hls.trigger(E.BUFFER_CODECS,t),!this.hls)return;l.forEach(u=>{const d=t[u].initSegment;d!=null&&d.byteLength&&this.hls.trigger(E.BUFFER_APPENDING,{type:u,data:d,frag:i,part:null,chunkMeta:s,parent:i.type})})}this.tickImmediate()}getMainFwdBufferInfo(){const e=this.getBufferOutput();return this.getFwdBufferInfo(e,ge.MAIN)}get maxBufferLength(){const{levels:e,level:t}=this,i=e?.[t];return i?this.getMaxBufferLength(i.maxBitrate):this.config.maxBufferLength}backtrack(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=Y.IDLE}get nextLevel(){const e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){var e;if(this.fragPlaying)return this.fragPlaying;const t=((e=this.media)==null?void 0:e.currentTime)||this.lastCurrentTime;return se(t)?this.getAppendedFrag(t):null}get currentProgramDateTime(){var e;const t=((e=this.media)==null?void 0:e.currentTime)||this.lastCurrentTime;if(se(t)){const i=this.getLevelDetails(),s=this.currentFrag||(i?ji(null,i.fragments,t):null);if(s){const n=s.programDateTime;if(n!==null){const a=n+(t-s.start)*1e3;return new Date(a)}}}return null}get currentLevel(){const e=this.currentFrag;return e?e.level:-1}get nextBufferedFrag(){const e=this.currentFrag;return e?this.followingBufferedFrag(e):null}get forceStartLoad(){return this._forceStartLoad}}class Zu extends Xu{constructor(...e){super(...e),this.currentOp=void 0,this.nextOp=void 0,this.cached=[],this.cachedSize=0,this.cacheFragmentData=!0,this.initDetails=void 0,this.onBufferedToEnd=()=>{const t=this.media;t!=null&&t.seeking&&(t.currentTime=t.currentTime)},this.onMediaSeeking=()=>{}}setInitPts(e){this.initPTS=e.slice()}loadMediaAt(e,t){if(!this.hls)return;const{seekOnAppend:i}=t,s=e+this.timelineOffset;switch(this.nextLoadPosition=this.lastCurrentTime=s,this.startPosition=e,this.state){case Y.STOPPED:case Y.ENDED:case Y.ERROR:this.state=Y.IDLE}this.state===Y.IDLE?(this.hls.resumeBuffering(),this.tick(),this.currentOp=[s,t]):this.nextOp=[s,t],this.hls.off(E.BUFFERED_TO_END,this.onBufferedToEnd);const n=this.media;i&&n&&this.seekTo(s)&&(this.currentOp=[s,t],this.nextOp=void 0,this.flushPipeline(s,!0))}seekTo(e){const t=this.media;if(t){var i;const s=(i=this.getLevelDetails())==null?void 0:i.edge,n=s!==void 0?s:t.duration;if(e>=n&&(e=n-.01),ve.bufferInfo(t,e,0).len>0&&this.getBufferedAt(e))return t.currentTime=e,!0}return!1}getBufferedAt(e){return this.fragmentTracker.getBufferedFrag(e,ge.MAIN)}cacheSet(e,t){if(!this.hls)return;e.data=t;const i=this.cached;i.push(e),this.cachedSize+=t.buffer.byteLength;const s=this.hls.config.iframeCacheLimit;for(;this.cachedSize>s&&i.length>1;){const n=i.shift();if(n.data)this.cachedSize-=n.data.byteLength,n.data=void 0;else{this.cached=i.filter(a=>!!a.data),this.cachedSize=i.reduce((a,{data:o})=>o?o.buffer.byteLength:0,0);break}}}onHandlerDestroying(){this.cached.length=0,this.cachedSize=0,super.onHandlerDestroying()}_handleFragmentLoadProgress(e){const t=e.frag,{part:i,payload:s}=e;this.cacheFragmentData&&!i&&s!=null&&s.byteLength&&!t.data&&st(t)&&this.cacheSet(t,new Uint8Array(s.slice(0))),super._handleFragmentLoadProgress(e)}loadFragment(e,t,i){const s=this.fragmentTracker.getState(e);if((s===et.NOT_LOADED||s===et.PARTIAL)&&this.canReplayCached(e)){this.replayCachedFragment(e);return}super.loadFragment(e,t,i)}canReplayCached(e){var t;if(!this.cacheFragmentData||!((t=e.data)!=null&&t.byteLength))return!1;const i=e.decryptdata;return i?.keyFormat!=="identity"||!!i.key}replayCachedFragment(e){const t=e.data.slice().buffer;this.log(`Buffering cached ${e.type} sn: ${e.sn} of level ${e.level} (${t.byteLength} bytes)`),this.fragCurrent=e,this.startFragRequested=!0;const i=e.stats=new Kn;i.loading.start=i.loading.first=i.loading.end=self.performance.now(),i.loaded=i.total=t.byteLength,i.chunkCount=1,this.state=Y.FRAG_LOADING;const s={frag:e,part:null,payload:t,networkDetails:null};this._handleFragmentLoadProgress(s),this.hls.trigger(E.FRAG_LOADED,s),this._handleFragmentLoadComplete(s)}fragBufferedComplete(e,t){super.fragBufferedComplete(e,t);const{currentOp:i,nextOp:s}=this;this.currentOp=this.nextOp=void 0,this.state=Y.STOPPED,i!=null&&i[1].seekOnAppend&&(this.flushPipeline(i[0],!s),this.seekTo(i[0])||this.log(`Could not seek to ${i[0]} after fragment buffered (superseded or flushed) buffer: ${this.media?hn(ve.getBuffered(this.media)):"none"}`)),s&&this.loadMediaAt.apply(this,s)}flushPipeline(e,t){if(t){const i=this.media;if(i){const s=ve.bufferInfo(i,e,0),n=s.len?s.nextStart:0;n&&(this.fragmentTracker.removeFragmentsInRange(n,1/0,ge.MAIN),this.flushMainBuffer(n,1/0))}this.hls.once(E.BUFFERED_TO_END,this.onBufferedToEnd)}this.hls.trigger(E.BUFFER_EOS,{type:"video"})}get playhead(){return this.nextLoadPosition}startLoad(){if(!this.startFragRequested){const e=this.hls;e.nextLoadLevel=e.startLevel===-1?0:e.firstAutoLevel}}seekToStartPos(){}setStartPosition(){}alignPlaylists(e,t,i){const s=this.initDetails;return this.initDetails=null,super.alignPlaylists(e,t,i||s||void 0)}getMainFwdBufferInfo(){const e=this.playhead,t=this.getBufferedAt(e);if(t){const i=t.duration;return{len:i,start:e,end:e+i,bufferedIndex:-1}}return{len:0,start:e,end:e,bufferedIndex:-1}}_streamEnded(){const e=this.playhead,t=this.fragmentTracker.getBufferedFrag(e,ge.MAIN);return!!(t!=null&&t.endList)}}class Wp extends Zu{constructor(...e){super(...e),this._img=void 0,this.queued=void 0,this.cacheFragmentData=!1}get image(){return this._img}set image(e){var t;const i=(t=this._img)==null?void 0:t.src;i&&self.URL.revokeObjectURL(i),this._img=e}loadMediaAt(e){if(!this.hls)return;const t=e+this.timelineOffset;switch(this.nextLoadPosition=this.lastCurrentTime=t,this.startPosition=e,this.state){case Y.STOPPED:case Y.ENDED:case Y.ERROR:this.state=Y.IDLE}if(this.state===Y.IDLE){if(this.hls.resumeBuffering(),this.media||(this.media={}),this.tick(),this.state===Y.IDLE){const i=this.getBufferedAt(e);i&&(this.fragCurrent=i,this.updateImage(i,null))}}else{const i=this.fragCurrent;(!i||e>=i.start&&e<i.end)&&(this.queued=[t])}}updateImage(e,t,i){const s=e.data;s||this.fragmentTracker.removeFragment(e);const n=this._img;if(n&&s){const a=self.performance.now(),o=t?t.stats:e.stats;o.buffering.start=e.stats.buffering.start=a,n.onload=()=>{if(!this.hls)return;const h=this.hls.levels[e.level];h!=null&&h.fragmentError&&(h.fragmentError=0,e.stats.retry=0);const d=self.performance.now(),g=t?t.stats:e.stats;g.buffering.end=e.stats.buffering.end=d,this.hls.trigger(E.FRAG_BUFFERED,{frag:e,part:t,stats:g,id:e.type,chunkMeta:i})},n.onerror=()=>{this.handleError("Image decode error",e,t,i)};const l=n.src;l&&self.URL.revokeObjectURL(l);const u=new Blob([s],{type:"image/jpeg"});n.src=self.URL.createObjectURL(u)}else this.state=Y.STOPPED,this.processQueued()}processQueued(){const e=this.queued;this.queued=void 0,e&&this.loadMediaAt.apply(this,e)}handleError(e,t,i,s){if(!this.hls)return;const n=new Error(e);this.hls.trigger(E.ERROR,{type:me.MEDIA_ERROR,details:U.FRAG_PARSING_ERROR,chunkMeta:s,frag:t,part:i,fatal:!1,error:n,err:n})}_bufferInitSegment(){}bufferFragmentData(e,t,i,s){super.bufferFragmentData(e,t,i,s,!0);const n=xe(new Uint8Array(e.data1),["mdat"]);if(n.length===0){this.handleError("Could not find I-Frame mdat",t,i,s);return}const a=t;this.cacheSet(a,n[0]),this.updateImage(a,i,s)}fragBufferedComplete(e,t){this.fragmentTracker.fragBuffered(e,!0),super.fragBufferedComplete(e,t),this.processQueued()}checkFragPlaying(){var e;const t=(e=this.fragPrevious)==null?void 0:e.start;if(t!==void 0){const i=this.getAppendedFrag(t);if(i&&!us(i,this.fragPlaying))return this.fragPlaying=i,!0}return!1}getMainFwdBufferInfo(){return{len:0,start:this.playhead,end:this.playhead,bufferedIndex:-1}}}const jp=10,qp="Image I-Frame player does not accept HTMLMediaElements",Qu={seekOnAppend:!0};let bn,la;class zp extends wt{constructor(e,t){super("iframes",e.logger),this.hls=void 0,this.stats=void 0,this.variableList=null,this.initPTS=[],this.iframeInstances=void 0,this.instanceCounter=0,bn||(bn=Xp(t)),la||(la=Zp(bn)),this.hls=e,this.iframeInstances=[],this.registerListeners()}registerListeners(){const e=this.hls;e&&(e.on(E.MANIFEST_LOADING,this.clearAsset,this),e.on(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(E.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(E.FRAG_BUFFERED,this.onFragBuffered,this),e.on(E.DESTROYING,this.onDestroying,this))}unregisterListeners(){const e=this.hls;e&&(e.off(E.MANIFEST_LOADING,this.clearAsset,this),e.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(E.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this),e.off(E.DESTROYING,this.onDestroying,this))}clearAsset(){this.stats=void 0,this.variableList=null,this.initPTS=[],this.iframeInstances.forEach(e=>e.destroy()),this.iframeInstances.length=0}onDestroying(){this.unregisterListeners(),this.clearAsset(),this.hls=void 0}onManifestLoaded(e,t){this.stats=t.stats,this.variableList=t.variableList}onLevelsUpdated(e,{levels:t}){var i;const s=(i=this.hls)==null?void 0:i.pathwayPriority;t.length&&s&&this.iframeInstances.forEach(n=>{n.pathwayPriority=s})}onInitPtsFound(e,{id:t,timestampOffsets:i}){t===ge.MAIN&&(this.initPTS=i)}onFragBuffered(e,t){var i;const s=this.hls;s&&s.hasEnoughToStart&&(((i=s.mainForwardBufferInfo)==null?void 0:i.len)||0)>jp&&this.iframeInstances.forEach(n=>{if(!n.loadingEnabled){var a;n.startLoad(((a=this.hls)==null||(a=a.media)==null?void 0:a.currentTime)||0)}})}createIFramePlayer(e){var t;return this.createInstance(bn,(t=this.hls)==null?void 0:t.iframeVariants,e)}createImageIFramePlayer(e){var t;const i=(t=this.hls)==null?void 0:t.iframeVariants.filter(s=>s.imageCodec);return this.createInstance(la,i,e,"image-")}createInstance(e,t,i,s){const{hls:n}=this;if(!n)return null;const{url:a,userConfig:o,latestLevelDetails:l,loadLevelObj:u,loadLevel:h,bandwidthEstimate:d,sessionId:g}=n,{stats:m,variableList:A}=this;if(!(t!=null&&t.length)||!m||!a)return null;const C=`${s||""}iframe-player-${this.instanceCounter++}`,v=n.levels,S=u||v[h],R=ko(S,o.videoPreference),b=S?.pathwayId||".",D=Ae(Ae({},o),{},{loggerId:C,primarySessionId:g,videoPreference:R,abrEwmaDefaultEstimate:d,streamController:void 0,audioStreamController:void 0,audioTrackController:void 0,subtitleStreamController:void 0,subtitleTrackController:void 0,timelineController:void 0,id3TrackController:void 0,fpsController:void 0,gapController:void 0,iframeController:void 0,cmcd:void 0,interstitialsController:void 0,backBufferLength:1/0,maxMaxBufferLength:1,capLevelToPlayerSize:!0,enableWorker:!1,autoStartLoad:!1,startFragPrefetch:!1,testBandwidth:!1,progressive:!1},i),_=new e(D,a,this.initPTS,l);return this.iframeInstances=this.iframeInstances.filter(M=>!M.url),this.iframeInstances.push(_),_.trigger(E.MANIFEST_LOADED,{levels:t,contentSteering:{uri:"",pathwayId:b},sessionKeys:null,audioTracks:[],iframeVariants:[],sessionData:null,startTimeOffset:null,stats:m,networkDetails:null,url:a,variableList:A}),_}}function Xp(r){return class extends r{constructor(t,i,s,n){t.streamController||(t.streamController=Zu),super(t),this._url=i,this.streamController.setInitPts(s),this.streamController.initDetails=n}loadSource(){}loadMediaAt(t,i=Qu){if(t<0)return;const s=Ae(Ae({},Qu),i);this.loadingEnabled||this.startLoad(t),this.streamController.loadMediaAt(t,s)}}}function Zp(r){return class extends r{constructor(t,i,s,n){t.cmcdController=void 0,t.emeController=void 0,t.streamController||(t.streamController=Wp),t.capLevelController=void 0,t.bufferController=void 0,super(t,i,s,n)}attachImage(t){this.streamController.image=t}detachImage(){this.streamController.image=void 0}loadSource(){}attachMedia(){throw new Error(qp)}detachMedia(){}recoverMediaError(){}transferMedia(){return null}loadMediaAt(t){if(t<0)return null;this.loadingEnabled||this.startLoad(t),this.streamController.loadMediaAt(t)}}}const bi=.025;let Ln=(function(r){return r[r.Point=0]="Point",r[r.Range=1]="Range",r})({});function Qp(r,e,t){return`${r.identifier}-${t+1}-${_s(e)}`}class Jp{constructor(e,t){this.base=void 0,this._duration=null,this._timelineStart=null,this.appendInPlaceDisabled=void 0,this.appendInPlaceStarted=void 0,this.dateRange=void 0,this.hasPlayed=!1,this.cumulativeDuration=0,this.resumeOffset=NaN,this.playoutLimit=NaN,this.restrictions={skip:!1,jump:!1},this.snapOptions={out:!1,in:!1},this.assetList=[],this.assetListLoader=void 0,this.assetListResponse=null,this.resumeAnchor=void 0,this.error=void 0,this.resetOnResume=void 0,this.base=t,this.dateRange=e,this.setDateRange(e)}setDateRange(e){this.dateRange=e,this.resumeOffset=e.attr.optionalFloat("X-RESUME-OFFSET",this.resumeOffset),this.playoutLimit=e.attr.optionalFloat("X-PLAYOUT-LIMIT",this.playoutLimit),this.restrictions=e.attr.enumeratedStringList("X-RESTRICT",this.restrictions),this.snapOptions=e.attr.enumeratedStringList("X-SNAP",this.snapOptions)}reset(){var e;this.appendInPlaceStarted=!1,(e=this.assetListLoader)==null||e.destroy(),this.assetListLoader=void 0,this.supplementsPrimary||(this.assetListResponse=null,this.assetList=[],this._duration=null)}isAssetPastPlayoutLimit(e){var t;if(e>0&&e>=this.assetList.length)return!0;const i=this.playoutLimit;return e<=0||isNaN(i)?!1:i===0?!0:(((t=this.assetList[e])==null?void 0:t.startOffset)||0)>i}findAssetIndex(e){return this.assetList.indexOf(e)}get identifier(){return this.dateRange.id}get startDate(){return this.dateRange.startDate}get startTime(){const e=this.dateRange.startTime;if(this.snapOptions.out){const t=this.dateRange.tagAnchor;if(t)return Ju(t,e)?Rn(e,t):e}return e}get startOffset(){return this.cue.pre?0:this.startTime}get startIsAligned(){if(this.startTime===0||this.snapOptions.out)return!0;const e=this.dateRange.tagAnchor;if(e){const t=this.dateRange.startTime,i=Rn(t,e);return t-i<.1}return!1}get resumptionOffset(){const e=this.resumeOffset,t=se(e)?e:this.duration;return this.cumulativeDuration+t}get resumeTime(){const e=this.startOffset+this.resumptionOffset;if(this.snapOptions.in){const t=this.resumeAnchor;if(t)return Ju(t,e)?Rn(e,t):e}return e}get appendInPlace(){return this.appendInPlaceStarted?!0:this.appendInPlaceDisabled?!1:!!(!this.cue.once&&!this.cue.pre&&this.startIsAligned&&(isNaN(this.playoutLimit)&&isNaN(this.resumeOffset)||this.resumeOffset&&this.duration&&Math.abs(this.resumeOffset-this.duration)<bi))}set appendInPlace(e){if(this.appendInPlaceStarted){this.resetOnResume=!e;return}this.appendInPlaceDisabled=!e}get timelineStart(){return this._timelineStart!==null?this._timelineStart:this.startTime}set timelineStart(e){this._timelineStart=e}get duration(){const e=this.playoutLimit;let t;return this._duration!==null?t=this._duration:this.dateRange.duration?t=this.dateRange.duration:t=this.dateRange.plannedDuration||0,!isNaN(e)&&e<t&&(t=e),t}set duration(e){this._duration=e}get cue(){return this.dateRange.cue}get timelineOccupancy(){return this.dateRange.attr["X-TIMELINE-OCCUPIES"]==="RANGE"?Ln.Range:Ln.Point}get supplementsPrimary(){return this.dateRange.attr["X-TIMELINE-STYLE"]==="PRIMARY"}get contentMayVary(){return this.dateRange.attr["X-CONTENT-MAY-VARY"]!=="NO"}get assetUrl(){return this.dateRange.attr["X-ASSET-URI"]}get assetListUrl(){return this.dateRange.attr["X-ASSET-LIST"]}get baseUrl(){return this.base.url}get assetListLoaded(){return this.assetList.length>0||this.assetListResponse!==null}toString(){return em(this)}}function Rn(r,e){return r-e.start<e.duration/2&&!(Math.abs(r-(e.start+e.duration))<bi)?e.start:e.start+e.duration}function Ju(r,e){return e>r.start-bi&&e<r.start+r.duration+bi}function ec(r,e,t){const i=new self.URL(r,t);return i.protocol!=="data:"&&Ti(i,"_HLS_primary_id",e),i}function ua(r,e){for(;(t=r.assetList[++e])!=null&&t.error;)var t;return e}function em(r){return`["${r.identifier}" ${r.cue.pre?"<pre>":r.cue.post?"<post>":""}${r.timelineStart.toFixed(2)}-${r.resumeTime.toFixed(2)}]`}function es(r){const e=r.timelineStart,t=r.duration||0;return`["${r.identifier}" ${e.toFixed(2)}-${(e+t).toFixed(2)}]`}class tm{constructor(e,t,i,s){this.hls=void 0,this.interstitial=void 0,this.assetItem=void 0,this.tracks=null,this.hasDetails=!1,this.mediaAttached=null,this._currentTime=void 0,this._bufferedEosTime=void 0,this.checkPlayout=()=>{this.reachedPlayout(this.currentTime)&&this.hls&&this.hls.trigger(E.PLAYOUT_LIMIT_REACHED,{})};const n=this.hls=new e(t);this.interstitial=i,this.assetItem=s;const a=()=>{this.hasDetails=!0};n.once(E.LEVEL_LOADED,a),n.once(E.AUDIO_TRACK_LOADED,a),n.once(E.SUBTITLE_TRACK_LOADED,a),n.on(E.MEDIA_ATTACHING,(o,{media:l})=>{this.removeMediaListeners(),this.mediaAttached=l,this.interstitial.playoutLimit&&(l.addEventListener("timeupdate",this.checkPlayout),this.appendInPlace&&n.on(E.BUFFER_APPENDED,()=>{const h=this.bufferedEnd;this.reachedPlayout(h)&&(this._bufferedEosTime=h,n.trigger(E.BUFFERED_TO_END,void 0))}))})}get appendInPlace(){return this.interstitial.appendInPlace}loadSource(){const e=this.hls;if(e)if(e.url)e.levels.length&&!e.started&&e.startLoad(-1,!0);else{let t=this.assetItem.uri;try{t=ec(t,e.config.primarySessionId||"").href}catch{}e.loadSource(t)}}bufferedInPlaceToEnd(e,t){var i;if(!this.appendInPlace)return!1;if((i=this.hls)!=null&&i.bufferedToEnd)return!0;if(!e)return!1;const s=Math.min(this._bufferedEosTime||1/0,this.duration),n=this.timelineOffset+(t||0),a=ve.bufferInfo(e,n,.02);return this.getAssetTime(a.end)>=s-.02}reachedPlayout(e){const i=this.interstitial.playoutLimit;return this.startOffset+e>=i}get destroyed(){var e;return!((e=this.hls)!=null&&e.userConfig)}get assetId(){return this.assetItem.identifier}get interstitialId(){return this.assetItem.parentIdentifier}get media(){var e;return((e=this.hls)==null?void 0:e.media)||null}get bufferedEnd(){const e=this.media||this.mediaAttached;if(!e)return this._bufferedEosTime?this._bufferedEosTime:this.currentTime;const t=ve.bufferInfo(e,e.currentTime,.001);return this.getAssetTime(t.end)}get currentTime(){const e=this.media||this.mediaAttached;return e?this.getAssetTime(e.currentTime):this._currentTime||0}get duration(){const e=this.assetItem.duration;if(!e)return 0;const t=this.interstitial.playoutLimit;if(t){const i=t-this.startOffset;if(i>0&&i<e)return i}return e}get remaining(){const e=this.duration;return e?Math.max(0,e-this.currentTime):0}get startOffset(){return this.assetItem.startOffset}get timelineOffset(){var e;return((e=this.hls)==null?void 0:e.config.timelineOffset)||0}set timelineOffset(e){const t=this.timelineOffset;if(e!==t){const i=e-t;if(Math.abs(i)>1/9e4&&this.hls){if(this.hasDetails)throw new Error("Cannot set timelineOffset after playlists are loaded");this.hls.config.timelineOffset=e}}}getAssetTime(e){const t=this.timelineOffset,i=this.duration;return Math.min(Math.max(0,e-t),i)}removeMediaListeners(){const e=this.mediaAttached;e&&(this._currentTime=e.currentTime,this.bufferSnapShot(),e.removeEventListener("timeupdate",this.checkPlayout))}bufferSnapShot(){if(this.mediaAttached){var e;(e=this.hls)!=null&&e.bufferedToEnd&&(this._bufferedEosTime=this.bufferedEnd)}}destroy(){this.removeMediaListeners(),this.hls&&this.hls.destroy(),this.hls=null,this.tracks=this.mediaAttached=this.checkPlayout=null}attachMedia(e){var t;this.loadSource(),(t=this.hls)==null||t.attachMedia(e)}detachMedia(){var e;this.removeMediaListeners(),this.mediaAttached=null,(e=this.hls)==null||e.detachMedia()}resumeBuffering(){var e;(e=this.hls)==null||e.resumeBuffering()}pauseBuffering(){var e;(e=this.hls)==null||e.pauseBuffering()}transferMedia(){var e;return this.bufferSnapShot(),((e=this.hls)==null?void 0:e.transferMedia())||null}resetDetails(){const e=this.hls;if(e&&this.hasDetails){e.stopLoad();const t=i=>delete i.details;e.levels.forEach(t),e.allAudioTracks.forEach(t),e.allSubtitleTracks.forEach(t),this.hasDetails=!1}}on(e,t,i){var s;(s=this.hls)==null||s.on(e,t)}once(e,t,i){var s;(s=this.hls)==null||s.once(e,t)}off(e,t,i){var s;(s=this.hls)==null||s.off(e,t)}toString(){var e;return`HlsAssetPlayer: ${es(this.assetItem)} ${(e=this.hls)==null?void 0:e.sessionId} ${this.appendInPlace?"append-in-place":""}`}}const ca=.033;class im extends wt{constructor(e,t){super("interstitials-sched",t),this.onScheduleUpdate=void 0,this.eventMap={},this.events=null,this.items=null,this.durations={primary:0,playout:0,integrated:0},this.onScheduleUpdate=e}destroy(){this.reset(),this.onScheduleUpdate=null}reset(){this.eventMap={},this.setDurations(0,0,0),this.events&&this.events.forEach(e=>e.reset()),this.events=this.items=null}resetErrorsInRange(e,t){return this.events?this.events.reduce((i,s)=>e<=s.startOffset&&t>s.startOffset?(delete s.error,i+1):i,0):0}get duration(){const e=this.items;return e?e[e.length-1].end:0}get length(){return this.items?this.items.length:0}getEvent(e){return e&&this.eventMap[e]||null}hasEvent(e){return e in this.eventMap}findItemIndex(e,t){if(e.event)return this.findEventIndex(e.event.identifier);let i=-1;e.nextEvent?i=this.findEventIndex(e.nextEvent.identifier)-1:e.previousEvent&&(i=this.findEventIndex(e.previousEvent.identifier)+1);const s=this.items;if(s)for(s[i]||(t===void 0&&(t=e.start),i=this.findItemIndexAtTime(t));i>=0&&(n=s[i])!=null&&n.event;){var n;i--}return i}findItemIndexAtTime(e,t){const i=this.items;if(i)for(let s=0;s<i.length;s++){let n=i[s];t&&t!=="primary"&&(n=n[t]);const a=n.start,o=i[s].event,l=o!=null&&o.cue.pre?o.duration:n.end;if(e===a||e>a&&e<l)return s}return-1}findJumpRestrictedIndex(e,t){const i=this.items;if(i)for(let s=e;s<=t&&i[s];s++){const n=i[s].event;if(n!=null&&n.restrictions.jump&&!n.appendInPlace)return s}return-1}findEventIndex(e){const t=this.items;if(t)for(let s=t.length;s--;){var i;if(((i=t[s].event)==null?void 0:i.identifier)===e)return s}return-1}findAssetIndex(e,t){const i=e.assetList,s=i.length;if(s>1)for(let n=0;n<s;n++){const a=i[n];if(!a.error){const o=a.timelineStart;if(t===o||t>o&&(t<o+(a.duration||0)||n===s-1))return n}}return 0}get assetIdAtEnd(){var e;const t=(e=this.items)==null||(e=e[this.length-1])==null?void 0:e.event;if(t){const i=t.assetList,s=i[i.length-1];if(s)return s.identifier}return null}parseInterstitialDateRanges(e,t,i=0){const s=e.main.details,{dateRanges:n}=s,a=this.events,o=this.parseDateRanges(n,{url:s.url},t),l=Object.keys(n),u=a?a.filter(h=>l.indexOf(h.identifier)===-1):[];o.length&&o.sort((h,d)=>{const g=h.cue.pre,m=h.cue.post,A=d.cue.pre,C=d.cue.post;if(g&&!A)return-1;if(A&&!g||m&&!C)return 1;if(C&&!m)return-1;if(!g&&!A&&!m&&!C){const v=h.startTime,S=d.startTime;if(v!==S)return v-S}return h.dateRange.tagOrder-d.dateRange.tagOrder}),this.events=o,u.forEach(h=>{this.removeEvent(h)}),this.updateSchedule(e,u,i)}updateSchedule(e,t=[],i=0,s=!1){const n=this.events||[];if(n.length||t.length||this.length<2){const a=this.items,o=this.parseSchedule(n,e,i);(s||t.length||a?.length!==o.length||o.some((u,h)=>Math.abs(u.playout.start-a[h].playout.start)>.005||Math.abs(u.playout.end-a[h].playout.end)>.005))&&(this.items=o,this.onScheduleUpdate(t,a))}}parseDateRanges(e,t,i){const s=[],n=Object.keys(e);for(let a=0;a<n.length;a++){const o=n[a],l=e[o];if(l.isInterstitial){let u=this.eventMap[o];u?u.setDateRange(l):(u=new Jp(l,t),this.eventMap[o]=u,i===!1&&(u.appendInPlace=i)),s.push(u)}}return s}parseSchedule(e,t,i=0){const s=[],n=t.main.details,a=n.live?1/0:n.edge;let o=0;if(e=e.filter(u=>!u.error&&!(u.cue.once&&u.hasPlayed)),e.length){this.resolveOffsets(e,t);let u=0,h=0;if(e.forEach((d,g)=>{const m=d.cue.pre,A=d.cue.post,C=e[g-1]||null,v=d.appendInPlace,S=A?a:d.startOffset,R=d.duration,b=d.timelineOccupancy===Ln.Range?R:0,D=m&&n.live?i+(d.resumeOffset||0):0,_=D||d.resumptionOffset,M=C?.startTime===S,p=S+d.cumulativeDuration;let $=v?p+R:S+_;if(m||!A&&S<=0){const O=h;h+=b,d.timelineStart=p;const W=o;o+=R,s.push({event:d,start:p,end:$,playout:{start:W,end:o},integrated:{start:O,end:h}})}else if(S<=a){if(!M){const q=S-u;if(q>ca){const z=u,oe=h;h+=q;const ne=o;o+=q;const J={previousEvent:e[g-1]||null,nextEvent:d,start:z,end:z+q,playout:{start:ne,end:o},integrated:{start:oe,end:h}};s.push(J)}else q>0&&C&&(C.cumulativeDuration+=q,s[s.length-1].end=S)}A&&($=p),d.timelineStart=p;const O=h;h+=b;const W=o;o+=R,s.push({event:d,start:p,end:$,playout:{start:W,end:o},integrated:{start:O,end:h}})}else return;const N=D||d.resumeTime;A||N>a?u=a:!m&&$&&d.appendInPlaceStarted&&N-$>ca?u=$:u=N}),u<a){var l;const d=u,g=h,m=a-u;h+=m;const A=o;o+=m,s.push({previousEvent:((l=s[s.length-1])==null?void 0:l.event)||null,nextEvent:null,start:u,end:d+m,playout:{start:A,end:o},integrated:{start:g,end:h}})}this.setDurations(a,o,h)}else s.push({previousEvent:null,nextEvent:null,start:0,end:a,playout:{start:0,end:a},integrated:{start:0,end:a}}),this.setDurations(a,a,a);return s}setDurations(e,t,i){this.durations={primary:e,playout:t,integrated:i}}resolveOffsets(e,t){const i=t.main.details,s=i.live?1/0:i.edge;let n=0,a=-1;e.forEach((o,l)=>{const u=o.cue.pre,h=o.cue.post,d=u?0:h?s:o.startTime;this.updateAssetDurations(o),a===d?o.cumulativeDuration=n:(n=0,a=d),!h&&o.snapOptions.in&&(o.resumeAnchor=ji(null,i.fragments,o.startOffset+o.resumptionOffset,0,0)||void 0),o.appendInPlace&&!o.appendInPlaceStarted&&(this.primaryCanResumeInPlaceAt(o,t)||(o.appendInPlace=!1)),!o.appendInPlace&&l+1<e.length&&e[l+1].startTime-e[l].resumeTime<ca&&(e[l+1].appendInPlace=!1,e[l+1].appendInPlace&&this.warn(`Could not change append strategy for abutting event ${o}`));const m=se(o.resumeOffset)?o.resumeOffset:o.duration;n+=m})}primaryCanResumeInPlaceAt(e,t){const i=e.resumeTime,s=e.startTime+e.resumptionOffset;return Math.abs(i-s)>bi?(this.log(`"${e.identifier}" resumption ${i} not aligned with estimated timeline end ${s}`),!1):!Object.keys(t).some(a=>{const o=t[a].details,l=o.edge;if(i>=l)return this.log(`"${e.identifier}" resumption ${i} past ${a} playlist end ${l}`),!1;const u=ji(null,o.fragments,i);if(!u)return this.log(`"${e.identifier}" resumption ${i} does not align with any fragments in ${a} playlist (${o.fragStart}-${o.fragmentEnd})`),!0;const h=a==="audio"?.175:0;return Math.abs(u.start-i)<bi+h||Math.abs(u.end-i)<bi+h?!1:(this.log(`"${e.identifier}" resumption ${i} not aligned with ${a} fragment bounds (${u.start}-${u.end} sn: ${u.sn} cc: ${u.cc})`),!0)})}updateAssetDurations(e){if(!e.assetListLoaded)return;const t=e.timelineStart;let i=0,s=!1,n=!1;for(let a=0;a<e.assetList.length;a++){const o=e.assetList[a],l=t+i;o.startOffset=i,o.timelineStart=l,s||(s=o.duration===null),n||(n=!!o.error);const u=o.error?0:o.duration||0;i+=u}s&&!n?e.duration=Math.max(i,e.duration):e.duration=i}removeEvent(e){e.reset(),delete this.eventMap[e.identifier]}}function Ft(r){return`[${r.event?'"'+r.event.identifier+'"':"primary"}: ${r.start.toFixed(2)}-${r.end.toFixed(2)}]`}class sm{constructor(e){this.hls=void 0,this.hls=e}destroy(){this.hls=null}loadAssetList(e,t){const i=e.assetListUrl;let s;try{s=ec(i,this.hls.sessionId,e.baseUrl)}catch(g){const m=this.assignAssetListError(e,U.ASSET_LIST_LOAD_ERROR,g,i);this.hls.trigger(E.ERROR,m);return}t&&s.protocol!=="data:"&&Ti(s,"_HLS_start_offset",""+t);const n=this.hls.config,a=n.loader,o=new a(n),l={type:ke.INTERSTITIAL_ASSET_LIST,responseType:"json",url:s.href},u=n.interstitialAssetListLoadPolicy.default,h={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},d={onSuccess:(g,m,A,C)=>{const v=g.data,S=v?.ASSETS;if(!Array.isArray(S)){const R=this.assignAssetListError(e,U.ASSET_LIST_PARSING_ERROR,new Error("Invalid interstitial asset list"),A.url,m,C);this.hls.trigger(E.ERROR,R);return}e.assetListResponse=v,this.hls.trigger(E.ASSET_LIST_LOADED,{event:e,assetListResponse:v,networkDetails:C})},onError:(g,m,A,C)=>{const v=this.assignAssetListError(e,U.ASSET_LIST_LOAD_ERROR,new Error(`Error loading X-ASSET-LIST: HTTP status ${g.code} ${g.text} (${m.url})`),m.url,C,A);this.hls.trigger(E.ERROR,v)},onTimeout:(g,m,A)=>{const C=this.assignAssetListError(e,U.ASSET_LIST_LOAD_TIMEOUT,new Error(`Timeout loading X-ASSET-LIST (${m.url})`),m.url,g,A);this.hls.trigger(E.ERROR,C)}};return o.load(l,h,d),this.hls.trigger(E.ASSET_LIST_LOADING,{event:e}),o}assignAssetListError(e,t,i,s,n,a){return e.error=i,{type:me.NETWORK_ERROR,details:t,fatal:!1,interstitial:e,url:s,error:i,networkDetails:a,stats:n}}}function tc(r){var e;r==null||(e=r.play())==null||e.catch(()=>{})}function Fi(r,e){return`[${r}] Advancing timeline position to ${e}`}class nm extends wt{constructor(e,t){super("interstitials",e.logger),this.HlsPlayerClass=void 0,this.hls=void 0,this.assetListLoader=void 0,this.mediaSelection=null,this.altSelection=null,this.media=null,this.detachedData=null,this.requiredTracks=null,this.manager=null,this.playerQueue=[],this.bufferedPos=-1,this.timelinePos=-1,this.schedule=void 0,this.playingItem=null,this.bufferingItem=null,this.waitingItem=null,this.endedItem=null,this.playingAsset=null,this.endedAsset=null,this.bufferingAsset=null,this.bufferPastEdge=!1,this.shouldPlay=!1,this.onPlay=()=>{this.shouldPlay=!0},this.onPause=()=>{this.shouldPlay=!1},this.onSeeking=()=>{const i=this.currentTime;if(i===void 0||this.playbackDisabled||!this.schedule)return;const s=i-this.timelinePos;if(Math.abs(s)<1/7056e5)return;const a=s<=-.01;this.timelinePos===-1&&!this.effectivePlayingItem&&this.checkStart(),this.timelinePos=i,this.bufferedPos=i;const o=this.playingItem;if(!o){this.checkBuffer();return}if(a&&this.schedule.resetErrorsInRange(i,i-s)&&this.updateSchedule(!0),this.checkBuffer(),a&&i<o.start||i>=o.end){var l;const m=this.findItemIndex(o);let A=this.schedule.findItemIndexAtTime(i);if(A===-1&&(A=m+(a?-1:1),this.log(`seeked ${a?"back ":""}to position not covered by schedule ${i} (resolving from ${m} to ${A})`)),!this.isInterstitial(o)&&(l=this.media)!=null&&l.paused&&(this.shouldPlay=!1),!a&&A>m){const C=this.schedule.findJumpRestrictedIndex(m+1,A);if(C>m){this.setSchedulePosition(C);return}}this.setSchedulePosition(A);return}const u=this.playingAsset;if(!u){if(this.playingLastItem&&this.isInterstitial(o)){const m=o.event.assetList[0];m&&(this.endedItem=this.playingItem,this.playingItem=null,this.setScheduleToAssetAtTime(i,m))}return}const h=u.timelineStart,d=u.duration||0;if(a&&i<h||i>=h+d){var g;(g=o.event)!=null&&g.appendInPlace&&(this.clearAssetPlayers(o.event,o),this.flushFrontBuffer(i)),this.setScheduleToAssetAtTime(i,u)}},this.onTimeupdate=()=>{const i=this.currentTime;if(i===void 0||this.playbackDisabled)return;if(this.timelinePos===-1&&!this.effectivePlayingItem&&this.checkStart(),i>this.timelinePos)this.timelinePos=i,i>this.bufferedPos&&this.checkBuffer();else return;const s=this.playingItem;if(!s||this.playingLastItem)return;if(i>=s.end){this.timelinePos=s.end;const o=this.findItemIndex(s);this.setSchedulePosition(o+1)}const n=this.playingAsset;if(!n)return;const a=n.timelineStart+(n.duration||0);i>=a&&this.setScheduleToAssetAtTime(i,n)},this.onScheduleUpdate=(i,s)=>{const n=this.schedule;if(!n)return;const a=this.playingItem,o=n.events||[],l=n.items||[],u=n.durations,h=i.map(C=>C.identifier),d=!!(o.length||h.length);(d||s)&&this.log(`INTERSTITIALS_UPDATED (${o.length}): ${o}
41
+ Schedule: ${l.map(C=>Ft(C))} pos: ${this.timelinePos}`),h.length&&this.log(`Removed events ${h}`);let g=null,m=null;a&&(g=this.updateItem(a,this.timelinePos),this.itemsMatch(a,g)?this.playingItem=g:this.waitingItem=null),this.waitingItem=this.updateItem(this.waitingItem);const A=this.bufferingItem;if(A&&(m=this.updateItem(A,this.bufferedPos),this.itemsMatch(A,m)?this.bufferingItem=m:A.event&&(this.bufferingItem=this.playingItem,this.clearInterstitial(A.event,null))),i.forEach(C=>{C.assetList.forEach(v=>{this.clearAssetPlayer(v.identifier,null)})}),this.playerQueue.forEach(C=>{if(C.interstitial.appendInPlace){const v=C.assetItem.timelineStart,S=C.timelineOffset-v;if(S)try{C.timelineOffset=v}catch(R){Math.abs(S)>bi&&this.warn(`${R} ("${C.assetId}" ${C.timelineOffset}->${v})`)}}}),d||s){if(this.hls.trigger(E.INTERSTITIALS_UPDATED,{events:o.slice(0),schedule:l.slice(0),durations:u,removedIds:h}),this.isInterstitial(a)&&h.indexOf(a.event.identifier)>-1){this.warn(`Interstitial "${a.event.identifier}" removed while playing`),this.primaryFallback(a.event);return}a&&this.trimInPlace(g,a),A&&m!==g&&this.trimInPlace(m,A),this.checkBuffer()}},this.hls=e,this.HlsPlayerClass=t,this.assetListLoader=new sm(e),this.schedule=new im(this.onScheduleUpdate,e.logger),this.registerListeners()}registerListeners(){const e=this.hls;e&&(e.on(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(E.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.on(E.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(E.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.on(E.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.on(E.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.on(E.BUFFER_APPENDED,this.onBufferAppended,this),e.on(E.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(E.BUFFERED_TO_END,this.onBufferedToEnd,this),e.on(E.MEDIA_ENDED,this.onMediaEnded,this),e.on(E.ERROR,this.onError,this),e.on(E.DESTROYING,this.onDestroying,this))}unregisterListeners(){const e=this.hls;e&&(e.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(E.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.off(E.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(E.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.off(E.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.off(E.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.off(E.BUFFER_CODECS,this.onBufferCodecs,this),e.off(E.BUFFER_APPENDED,this.onBufferAppended,this),e.off(E.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(E.BUFFERED_TO_END,this.onBufferedToEnd,this),e.off(E.MEDIA_ENDED,this.onMediaEnded,this),e.off(E.ERROR,this.onError,this),e.off(E.DESTROYING,this.onDestroying,this))}startLoad(){this.resumeBuffering()}stopLoad(){this.pauseBuffering()}resumeBuffering(){var e;(e=this.getBufferingPlayer())==null||e.resumeBuffering()}pauseBuffering(){var e;(e=this.getBufferingPlayer())==null||e.pauseBuffering()}destroy(){this.unregisterListeners(),this.stopLoad(),this.assetListLoader&&this.assetListLoader.destroy(),this.emptyPlayerQueue(),this.clearScheduleState(),this.schedule&&this.schedule.destroy(),this.media=this.detachedData=this.mediaSelection=this.requiredTracks=this.altSelection=this.schedule=this.manager=null,this.hls=this.HlsPlayerClass=null,this.assetListLoader=null,this.onPlay=this.onPause=this.onSeeking=this.onTimeupdate=null,this.onScheduleUpdate=null}onDestroying(){const e=this.primaryMedia||this.media;e&&this.removeMediaListeners(e)}removeMediaListeners(e){Ve(e,"play",this.onPlay),Ve(e,"pause",this.onPause),Ve(e,"seeking",this.onSeeking),Ve(e,"timeupdate",this.onTimeupdate)}onMediaAttaching(e,t){const i=this.media=t.media;Ke(i,"seeking",this.onSeeking),Ke(i,"timeupdate",this.onTimeupdate),Ke(i,"play",this.onPlay),Ke(i,"pause",this.onPause)}onMediaAttached(e,t){const i=this.effectivePlayingItem,s=this.detachedData;if(this.detachedData=null,i===null)this.checkStart();else if(!s){this.clearScheduleState();const n=this.findItemIndex(i);this.setSchedulePosition(n)}}clearScheduleState(){this.log("clear schedule state"),this.playingItem=this.bufferingItem=this.waitingItem=this.endedItem=this.playingAsset=this.endedAsset=this.bufferingAsset=null}onMediaDetaching(e,t){const i=!!t.transferMedia,s=this.media;if(this.media=null,!i&&(s&&this.removeMediaListeners(s),this.detachedData)){const n=this.getBufferingPlayer();n&&(this.log(`Removing schedule state for detachedData and ${n}`),this.playingAsset=this.endedAsset=this.bufferingAsset=this.bufferingItem=this.waitingItem=this.detachedData=null,n.detachMedia()),this.shouldPlay=!1}}get interstitialsManager(){if(!this.hls)return null;if(this.manager)return this.manager;const e=this,t=()=>e.bufferingItem||e.waitingItem,i=d=>d&&e.getAssetPlayer(d.identifier),s=(d,g,m,A,C)=>{if(d){let v=d[g].start;const S=d.event;if(S){if(g==="playout"||S.timelineOccupancy!==Ln.Point){const R=i(m);R?.interstitial===S&&(v+=R.assetItem.startOffset+R[C])}}else{const R=A==="bufferedPos"?a():e[A];v+=R-d.start}return v}return 0},n=(d,g)=>{var m;if(d!==0&&g!=="primary"&&(m=e.schedule)!=null&&m.length){var A;const C=e.schedule.findItemIndexAtTime(d),v=(A=e.schedule.items)==null?void 0:A[C];if(v){const S=v[g].start-v.start;return d+S}}return d},a=()=>{const d=e.bufferedPos;return d===Number.MAX_VALUE?o("primary"):Math.max(d,0)},o=d=>{var g,m;return(g=e.primaryDetails)!=null&&g.live?e.primaryDetails.edge:((m=e.schedule)==null?void 0:m.durations[d])||0},l=(d,g)=>{var m,A;const C=e.effectivePlayingItem;if(C!=null&&(m=C.event)!=null&&m.restrictions.skip||!e.schedule)return;e.log(`seek to ${d} "${g}"`);const v=e.effectivePlayingItem,S=e.schedule.findItemIndexAtTime(d,g),R=(A=e.schedule.items)==null?void 0:A[S],b=e.getBufferingPlayer(),D=b?.interstitial,_=D?.appendInPlace,M=v&&e.itemsMatch(v,R);if(v&&(_||M)){const p=i(e.playingAsset),$=p?.media||e.primaryMedia;if($){const N=g==="primary"?$.currentTime:s(v,g,e.playingAsset,"timelinePos","currentTime"),O=d-N,W=(_?N:$.currentTime)+O;if(W>=0&&(!p||_||W<=p.duration)){$.currentTime=W;return}}}if(R){let p=d;if(g!=="primary"){const N=R[g].start,O=d-N;p=R.start+O}const $=!e.isInterstitial(R);if((!e.isInterstitial(v)||v.event.appendInPlace)&&($||R.event.appendInPlace)){const N=e.media||(_?b?.media:null);N&&(N.currentTime=p)}else if(v){const N=e.findItemIndex(v);if(S>N){const W=e.schedule.findJumpRestrictedIndex(N+1,S);if(W>N){e.setSchedulePosition(W);return}}let O=0;if($)e.timelinePos=p,e.checkBuffer();else{const W=R.event.assetList,q=d-(R[g]||R).start;for(let z=W.length;z--;){const oe=W[z];if(oe.duration&&q>=oe.startOffset&&q<oe.startOffset+oe.duration){O=z;break}}}e.setSchedulePosition(S,O)}}},u=()=>{const d=e.effectivePlayingItem;if(e.isInterstitial(d))return d;const g=t();return e.isInterstitial(g)?g:null},h={get bufferedEnd(){const d=t(),g=e.bufferingItem;if(g&&g===d){var m;return s(g,"playout",e.bufferingAsset,"bufferedPos","bufferedEnd")-g.playout.start||((m=e.bufferingAsset)==null?void 0:m.startOffset)||0}return 0},get currentTime(){const d=u(),g=e.effectivePlayingItem;return g&&g===d?s(g,"playout",e.effectivePlayingAsset,"timelinePos","currentTime")-g.playout.start:0},set currentTime(d){const g=u(),m=e.effectivePlayingItem;m&&m===g&&l(d+m.playout.start,"playout")},get duration(){const d=u();return d?d.playout.end-d.playout.start:0},get assetPlayers(){var d;const g=(d=u())==null?void 0:d.event.assetList;return g?g.map(m=>e.getAssetPlayer(m.identifier)):[]},get playingIndex(){var d;const g=(d=u())==null?void 0:d.event;return g&&e.effectivePlayingAsset?g.findAssetIndex(e.effectivePlayingAsset):-1},get scheduleItem(){return u()}};return this.manager={get events(){var d;return((d=e.schedule)==null||(d=d.events)==null?void 0:d.slice(0))||[]},get schedule(){var d;return((d=e.schedule)==null||(d=d.items)==null?void 0:d.slice(0))||[]},get interstitialPlayer(){return u()?h:null},get playerQueue(){return e.playerQueue.slice(0)},get bufferingAsset(){return e.bufferingAsset},get bufferingItem(){return t()},get bufferingIndex(){const d=t();return e.findItemIndex(d)},get playingAsset(){return e.effectivePlayingAsset},get playingItem(){return e.effectivePlayingItem},get playingIndex(){const d=e.effectivePlayingItem;return e.findItemIndex(d)},primary:{get bufferedEnd(){return a()},get currentTime(){const d=e.timelinePos;return d>0?d:0},set currentTime(d){l(d,"primary")},get duration(){return o("primary")},get seekableStart(){return e.seekableStart}},integrated:{get bufferedEnd(){return s(t(),"integrated",e.bufferingAsset,"bufferedPos","bufferedEnd")},get currentTime(){return s(e.effectivePlayingItem,"integrated",e.effectivePlayingAsset,"timelinePos","currentTime")},set currentTime(d){l(d,"integrated")},get duration(){return o("integrated")},get seekableStart(){return n(e.seekableStart,"integrated")}},skip:()=>{const d=e.effectivePlayingItem,g=d?.event;if(g&&!g.restrictions.skip){const m=e.findItemIndex(d);if(g.appendInPlace){const A=d.playout.start+d.event.duration;l(A+.001,"playout")}else e.advanceAfterAssetEnded(g,m,1/0)}}}}get effectivePlayingItem(){return this.waitingItem||this.playingItem||this.endedItem}get effectivePlayingAsset(){return this.playingAsset||this.endedAsset}get playingLastItem(){var e;const t=this.playingItem,i=(e=this.schedule)==null?void 0:e.items;return!this.playbackStarted||!t||!i?!1:this.findItemIndex(t)===i.length-1}get playbackStarted(){return this.effectivePlayingItem!==null}get currentTime(){var e,t;if(this.mediaSelection===null)return;const i=this.waitingItem||this.playingItem;if(this.isInterstitial(i)&&!i.event.appendInPlace)return;let s=this.media;!s&&(e=this.bufferingItem)!=null&&(e=e.event)!=null&&e.appendInPlace&&(s=this.primaryMedia);const n=(t=s)==null?void 0:t.currentTime;if(!(n===void 0||!se(n)))return n}get primaryMedia(){var e;return this.media||((e=this.detachedData)==null?void 0:e.media)||null}isInterstitial(e){return!!(e!=null&&e.event)}retreiveMediaSource(e,t){const i=this.getAssetPlayer(e);i&&this.transferMediaFromPlayer(i,t)}transferMediaFromPlayer(e,t){const i=e.interstitial.appendInPlace,s=e.media;if(i&&s===this.primaryMedia){if(this.bufferingAsset=null,(!t||this.isInterstitial(t)&&!t.event.appendInPlace)&&t&&s){this.detachedData={media:s};return}const n=e.transferMedia();this.log(`transfer MediaSource from ${e} ${Xe(n)}`),this.detachedData=n}else t&&s&&(this.shouldPlay||(this.shouldPlay=!s.paused))}transferMediaTo(e,t){var i,s;if(e.media===t)return;let n=null;const a=this.hls,o=e!==a,l=o&&e.interstitial.appendInPlace,u=(i=this.detachedData)==null?void 0:i.mediaSource;let h;if(a.media)l&&(n=a.transferMedia(),this.detachedData=n),h="Primary";else{const A=this.getBufferingPlayer();A?(n=A.transferMedia(),this.detachedData=n,h=`${A}`):u?h="detached MediaSource":h="detached media"}if(!n){if(u)n=this.detachedData,this.log(`using detachedData: MediaSource ${Xe(n)}`);else if(!this.detachedData||a.media===t){const A=this.playerQueue;A.length>1&&A.forEach(C=>{if(o&&C.interstitial.appendInPlace!==l){const v=C.interstitial;this.clearInterstitial(C.interstitial,null),v.appendInPlace=!1,v.appendInPlace&&this.warn(`Could not change append strategy for queued assets ${v}`)}}),this.hls.detachMedia(),this.detachedData={media:t}}}const d=n&&"mediaSource"in n&&((s=n.mediaSource)==null?void 0:s.readyState)!=="closed";if(this.log(`${d?"transfering MediaSource":"attaching media"} to ${o?e:"Primary"} from ${h} (media.currentTime: ${t.currentTime})`),!d&&!o){e.attachMedia(t);return}const g=d&&n?Ae({},n):{media:t},m=this.schedule;if(m&&o){const A=e.assetId===m.assetIdAtEnd;g.overrides={duration:m.duration,endOfStream:A||e.appendInPlace===!1}}if(!d&&l){const A=e,C=A.assetItem.timelineStart;if(C){const v=A.hls,S=Math.max(this.timelinePos-C,Number.EPSILON);v.startPosition!==S&&(this.log(`Set ${A} startPosition: ${S}`),v.config.startPosition=S,v.loadingEnabled&&v.startLoad(S))}}e.attachMedia(g)}onInterstitialCueEnter(){this.onTimeupdate()}checkStart(){const e=this.schedule,t=e?.events,i=this.hls;if(!t||this.playbackDisabled||!this.media||!i)return;this.bufferedPos===-1&&(this.bufferedPos=0);const s=this.timelinePos,n=this.effectivePlayingItem;if(s===-1){if(!i.loadingEnabled){this.log("waiting for startLoad( <startPosition> )");return}const a=i.startPosition;if(this.timelinePos=a,t.length===0)this.setSchedulePosition(0);else if(t[0].cue.pre){this.log(Fi("checkStart (preroll)",a));const o=e.findEventIndex(t[0].identifier);this.setSchedulePosition(o)}else if(a>=0||!this.primaryLive){this.log(Fi("checkStart",a));const o=this.timelinePos=a>0?a:0,l=e.findItemIndexAtTime(o);this.setSchedulePosition(l)}else i.liveSyncPosition===0?this.setSchedulePosition(0):this.log("[checkStart] waiting for live start")}else if(n&&!this.playingItem){this.log(Fi("checkStart (playing item)",n.start));const a=e.findItemIndex(n);this.setSchedulePosition(a)}}advanceAssetBuffering(e,t){const i=e.event,s=i.findAssetIndex(t),n=ua(i,s);if(!i.isAssetPastPlayoutLimit(n))this.bufferedToEvent(e,n);else if(this.schedule){var a;const o=this.getNextItemIndex(e,!0),l=(a=this.schedule.items)==null?void 0:a[o];l&&this.bufferedToItem(l)}}livePrerollResumption(e,t){if(e.cue.pre&&this.primaryLive&&!se(e.resumeOffset)&&this.hls){const i=this.getLiveStartPos();if(t){const s=this.getBufferingPlayer(),n=s!=null&&s.interstitial.cue.pre?s.remaining:0;return i+n}return i}}getNextItemIndex(e,t){if(this.schedule){const i=this.livePrerollResumption(e.event,t);if(i!==void 0)return this.log(`find next item index @${i}`),this.schedule.findItemIndexAtTime(i)}return this.findItemIndex(e)+1}advanceAfterAssetEnded(e,t,i){const s=ua(e,i);if(e.isAssetPastPlayoutLimit(s)){if(this.schedule){const n=this.schedule.items;if(n){const a=n[t],o=a.event?this.getNextItemIndex(a):t+1,l=n.length;if(o>=l){this.setSchedulePosition(-1);return}const u=e.resumeTime;this.timelinePos<u&&(this.log(Fi("advanceAfterAssetEnded",u)),this.timelinePos=u,e.appendInPlace&&!n[o].event&&this.hls.startLoad(u+.01),this.checkBuffer(this.bufferedPos<u)),this.setSchedulePosition(o)}}}else{if(e.appendInPlace){const n=e.assetList[s];n&&this.advanceInPlace(n.timelineStart)}this.setSchedulePosition(t,s)}}setScheduleToAssetAtTime(e,t){const i=this.schedule;if(!i)return;const s=t.parentIdentifier,n=i.getEvent(s);if(n){const a=i.findEventIndex(s),o=i.findAssetIndex(n,e);this.advanceAfterAssetEnded(n,a,o-1)}}setSchedulePosition(e,t){var i;const s=(i=this.schedule)==null?void 0:i.items;if(!s||this.playbackDisabled)return;const n=e>=0?s[e]:null;this.log(`setSchedulePosition ${e}, ${t} (${n&&Ft(n)}) pos: ${this.timelinePos}`);const a=this.waitingItem||this.playingItem,o=this.playingLastItem;if(this.isInterstitial(a)){const d=a.event,g=this.playingAsset,m=g?.identifier,A=m?this.getAssetPlayer(m):null;if(A&&m&&(!this.eventItemsMatch(a,n)||t!==void 0&&m!==d.assetList[t].identifier)){var l;const C=d.findAssetIndex(g);if(this.log(`INTERSTITIAL_ASSET_ENDED ${C+1}/${d.assetList.length} ${es(g)}`),this.endedAsset=g,this.playingAsset=null,this.hls.trigger(E.INTERSTITIAL_ASSET_ENDED,{asset:g,assetListIndex:C,event:d,schedule:s.slice(0),scheduleIndex:e,player:A}),a!==this.playingItem){this.itemsMatch(a,this.playingItem)&&!this.playingAsset&&this.advanceAfterAssetEnded(d,this.findItemIndex(this.playingItem),C);return}this.retreiveMediaSource(m,n),A.media&&!((l=this.detachedData)!=null&&l.mediaSource)&&A.detachMedia()}if(!this.eventItemsMatch(a,n)&&(this.endedItem=a,this.playingItem=this.waitingItem=null,this.log(`INTERSTITIAL_ENDED ${d} ${Ft(a)}`),d.hasPlayed=!0,this.hls.trigger(E.INTERSTITIAL_ENDED,{event:d,schedule:s.slice(0),scheduleIndex:e}),d.cue.once&&this.hls)){var u;this.updateSchedule();const C=(u=this.schedule)==null?void 0:u.items;if(n&&C){const v=this.findItemIndex(n),S=this.livePrerollResumption(d);if(S!==void 0){let R=S;const b=this.getNextItemIndex(a);if(!this.isInterstitial(s[b])){var h;const D=(h=this.primaryDetails)==null?void 0:h.fragments;if(d.snapOptions.in&&D){const _=ji(null,D,S);_&&(R=Math.min(Math.max(s[b].start,Rn(R,_)),s[b].end))}}if(this.log(Fi("live join (preroll)",R)),this.timelinePos=R,b!==v&&(b||b===0)){this.advanceSchedule(b,C,void 0,a,o);return}}this.advanceSchedule(v,C,t,a,o)}return}}this.advanceSchedule(e,s,t,a,o)}advanceSchedule(e,t,i,s,n){const a=this.schedule;if(!a)return;const o=t[e]||null,l=this.primaryMedia,u=this.playerQueue;if(u.length&&u.forEach(h=>{const d=h.interstitial,g=a.findEventIndex(d.identifier);(g<e||g>e+1)&&this.clearInterstitial(d,o)}),this.isInterstitial(o)){this.timelinePos=Math.min(Math.max(this.timelinePos,o.start),o.end);const h=o.event;if(i===void 0){i=h.cue.pre?0:a.findAssetIndex(h,this.timelinePos);const A=ua(h,i-1);if(h.isAssetPastPlayoutLimit(A)||h.appendInPlace&&this.timelinePos===o.end){this.advanceAfterAssetEnded(h,e,i);return}i=A}const d=this.waitingItem;this.assetsBuffered(o,l)||this.setBufferingItem(o);let g=this.preloadAssets(h,i);if(this.eventItemsMatch(o,d||s)||(this.waitingItem=o,this.log(`INTERSTITIAL_STARTED ${Ft(o)} ${h.appendInPlace?"append in place":""}`),h.hasPlayed=!1,this.hls.trigger(E.INTERSTITIAL_STARTED,{event:h,schedule:t.slice(0),scheduleIndex:e})),!h.assetListLoaded){this.log(`Waiting for ASSET-LIST to complete loading ${h}`);return}if(h.assetListLoader&&(h.assetListLoader.destroy(),h.assetListLoader=void 0),!l){this.log(`Waiting for attachMedia to start Interstitial ${h}`);return}this.waitingItem=this.endedItem=null,this.playingItem=o;const m=h.assetList[i];if(!m){this.advanceAfterAssetEnded(h,e,i||0);return}if(g||(g=this.getAssetPlayer(m.identifier)),g===null||g.destroyed){const A=h.assetList.length;this.warn(`asset ${i+1}/${A} player destroyed ${h}`),g=this.createAssetPlayer(h,m,i),g.loadSource()}if(!this.eventItemsMatch(o,this.bufferingItem)&&h.appendInPlace&&this.isAssetBuffered(m))return;this.startAssetPlayer(g,i,t,e,l),this.shouldPlay&&tc(g.media)}else o?(this.resumePrimary(o,e,s),this.shouldPlay&&tc(this.hls.media)):n&&this.isInterstitial(s)&&(this.endedItem=null,this.playingItem=s,s.event.appendInPlace||this.attachPrimary(a.durations.primary,null))}get playbackDisabled(){return this.hls.config.enableInterstitialPlayback===!1}get primaryDetails(){var e;return(e=this.mediaSelection)==null?void 0:e.main.details}get primaryLive(){var e;return!!((e=this.primaryDetails)!=null&&e.live)}resumePrimary(e,t,i){var s,n;this.playingItem=e,this.playingAsset=this.endedAsset=null,this.waitingItem=null,this.bufferedToItem(e),this.endedItem=null,this.log(`resuming ${Ft(e)}`);let a=this.timelinePos;if((s=this.detachedData)!=null&&s.mediaSource?this.primaryLive&&this.startLoadingPrimaryAt(a):((a<e.start||a>=e.end||a<this.seekableStart)&&(a=this.getPrimaryResumption(e,t),this.log(Fi("resumePrimary",a)),this.timelinePos=a),this.attachPrimary(a,e)),!i)return;const o=(n=this.schedule)==null?void 0:n.items;o&&(this.log(`INTERSTITIALS_PRIMARY_RESUMED ${Ft(e)}`),this.hls.trigger(E.INTERSTITIALS_PRIMARY_RESUMED,{schedule:o.slice(0),scheduleIndex:t}),this.checkBuffer())}get seekableStart(){var e;return this.primaryLive&&((e=this.primaryDetails)==null?void 0:e.fragmentStart)||0}getPrimaryResumption(e,t,i){const s=e.start;if(this.primaryLive){if(t===0)return this.hls.startPosition;const n=this.endedItem||this.playingItem,a=n!=null&&n.event?this.livePrerollResumption(n.event,i):void 0;if(a!==void 0)return a;const o=this.primaryDetails;if(o){const{fragmentStart:l,edge:u}=o;if(s<l||s>u&&!i){const h=this.hls.liveSyncPosition;return this.log(`primary resumption out of bounds (${s} [${l}-${u}]) snapping to liveSync ${h}`),h||l}}}return this.log(`primary resumption itemStart: ${s}`),s}getLiveStartPos(){var e;const t=this.hls.startPosition,i=this.hls.liveSyncPosition||0,s=(((e=this.primaryDetails)==null?void 0:e.targetduration)||10)*3;return t===-1||i&&i-t<s?i||0:t}isAssetBuffered(e){const t=this.getAssetPlayer(e.identifier);return t!=null&&t.hls?t.hls.bufferedToEnd:ve.bufferInfo(this.primaryMedia,this.timelinePos,0).end+1>=e.timelineStart+(e.duration||0)}attachPrimary(e,t,i){t?this.setBufferingItem(t):this.bufferingItem=this.playingItem,this.bufferingAsset=null;const s=this.primaryMedia;if(!s)return;const n=this.hls;n.media?this.checkBuffer():(this.transferMediaTo(n,s),i&&this.startLoadingPrimaryAt(e,i)),i||(this.log(Fi("attachPrimary",e)),this.timelinePos=e,this.startLoadingPrimaryAt(e,i))}startLoadingPrimaryAt(e,t){const i=this.hls,{loadingEnabled:s,bufferingEnabled:n,startPosition:a}=i,o=i.hasEnoughToStart;if(this.log(`Start loading primary @${e} bufferedPos: ${this.bufferedPos} startPosition: ${a} skip seek: ${t} has enough ${o} loadingEnabled: ${s} bufferingEnabled: ${n}`),!t&&o||!s||Math.abs(a-e)>.1){const l=this.primaryDetails;if(l!=null&&l.live&&e+.5>=l.edge){const u=this.bufferingItem;this.log(`Resume primary loading when live passes ${e} buffering item: ${u?Ft(u):null}`),i.pauseBuffering(),this.bufferPastEdge=!0;return}i.startLoad(e,t)}else n||i.resumeBuffering()}onManifestLoading(){var e;this.stopLoad(),(e=this.schedule)==null||e.reset(),this.emptyPlayerQueue(),this.clearScheduleState(),this.shouldPlay=!1,this.bufferedPos=this.timelinePos=-1,this.mediaSelection=this.altSelection=this.manager=this.requiredTracks=null,this.hls.off(E.BUFFER_CODECS,this.onBufferCodecs,this),this.hls.on(E.BUFFER_CODECS,this.onBufferCodecs,this)}onLevelUpdated(e,t){if(t.level===-1||!this.schedule)return;const i=this.hls.levels[t.level];if(!i.details)return;const s=Ae(Ae({},this.mediaSelection||this.altSelection),{},{main:i});this.mediaSelection=s;const n=this.hls.startPosition;if(this.schedule.parseInterstitialDateRanges(s,this.hls.config.interstitialAppendInPlace,n===-1?0:n),!!this.schedule.items){if(!this.effectivePlayingItem)this.checkStart();else if(this.bufferPastEdge){const o=this.primaryDetails,l=this.bufferedPos;if(o!=null&&o.live&&l+.5<o.edge){this.bufferPastEdge=!1;const u=this.bufferingItem;if(this.log(`Live edge ${o.edge} passed buffer: ${l} buffering item: ${u?Ft(u):null}`),u?.end===1/0){const d=this.playingItem,g=this.isInterstitial(d)&&d.event.appendInPlace;this.hls.startLoad(Math.max(l,u.start),g)}else{const d=this.getBufferingPlayer();d&&d.bufferedInPlaceToEnd(this.primaryMedia,d.currentTime)&&d.hls&&d.hls.trigger(E.BUFFERED_TO_END,void 0)}}}}}onAudioTrackUpdated(e,t){const i=this.hls.audioTracks[t.id],s=this.mediaSelection;if(!s){this.altSelection=Ae(Ae({},this.altSelection),{},{audio:i});return}const n=Ae(Ae({},s),{},{audio:i});this.mediaSelection=n}onSubtitleTrackUpdated(e,t){const i=this.hls.subtitleTracks[t.id],s=this.mediaSelection;if(!s){this.altSelection=Ae(Ae({},this.altSelection),{},{subtitles:i});return}const n=Ae(Ae({},s),{},{subtitles:i});this.mediaSelection=n}onAudioTrackSwitching(e,t){const i=Po(t);this.playerQueue.forEach(({hls:s})=>s&&(s.setAudioOption(t)||s.setAudioOption(i)))}onSubtitleTrackSwitch(e,t){const i=Po(t);this.playerQueue.forEach(({hls:s})=>s&&(s.setSubtitleOption(t)||t.id!==-1&&s.setSubtitleOption(i)))}onBufferCodecs(e,t){const i=t.tracks;i&&(this.requiredTracks=i)}onBufferAppended(e,t){this.checkBuffer()}onBufferFlushed(e,t){const i=this.playingItem;if(i&&!this.itemsMatch(i,this.bufferingItem)&&!this.isInterstitial(i)){const s=this.timelinePos;this.bufferedPos=s,this.checkBuffer()}}onBufferedToEnd(e){if(!this.schedule)return;const t=this.schedule.events;if(this.bufferedPos<Number.MAX_VALUE&&t){for(let i=0;i<t.length;i++){const s=t[i];if(s.cue.post){const n=this.getEventItem(s.identifier);n&&this.eventItemsMatch(n,this.bufferingItem)&&this.bufferedToItem(n,0);break}}this.bufferedPos=Number.MAX_VALUE}}onMediaEnded(e){const t=this.playingItem;if(!this.playingLastItem&&t){const i=this.findItemIndex(t);this.setSchedulePosition(i+1)}else this.shouldPlay=!1}updateItem(e,t){var i;const s=(i=this.schedule)==null?void 0:i.items;if(e&&s){const n=this.findItemIndex(e,t);return s[n]||null}return null}trimInPlace(e,t){if(this.isInterstitial(e)&&e.event.appendInPlace&&t.end-e.end>.25){e.event.assetList.forEach((n,a)=>{e.event.isAssetPastPlayoutLimit(a)&&this.clearAssetPlayer(n.identifier,null)});const i=e.end+.25,s=ve.bufferInfo(this.primaryMedia,i,0);(s.end>i||(s.nextStart||0)>i)&&(this.log(`trim buffered interstitial ${Ft(e)} (was ${Ft(t)})`),this.attachPrimary(i,null,!0),this.flushFrontBuffer(i))}}itemsMatch(e,t){return!!t&&(e===t||e.event&&t.event&&this.eventItemsMatch(e,t)||!e.event&&!t.event&&this.findItemIndex(e)===this.findItemIndex(t))}eventItemsMatch(e,t){var i;return!!t&&(e===t||e.event.identifier===((i=t.event)==null?void 0:i.identifier))}findEventIndex(e){return this.schedule?this.schedule.findEventIndex(e):-1}getEventItem(e){if(this.schedule){var t;const i=(t=this.schedule.items)==null?void 0:t[this.findEventIndex(e)];if(this.isInterstitial(i)&&i.event.identifier===e)return i}}findItemIndex(e,t){return e&&this.schedule?this.schedule.findItemIndex(e,t):-1}updateSchedule(e=!1){var t,i;const s=this.mediaSelection;if(!s)return;const n=((t=this.hls)==null?void 0:t.liveSyncPosition)||0;(i=this.schedule)==null||i.updateSchedule(s,[],n,e)}checkBuffer(e){var t;const i=(t=this.schedule)==null?void 0:t.items;if(!i)return;const s=ve.bufferInfo(this.primaryMedia,this.timelinePos,0);e&&(this.bufferedPos=this.timelinePos),e||(e=s.len<1),this.updateBufferedPos(s.end,i,e)}updateBufferedPos(e,t,i){const s=this.schedule,n=this.bufferingItem;if(this.bufferedPos>e||!s)return;if(t.length===1&&this.itemsMatch(t[0],n)){this.bufferedPos=e;return}const a=this.playingItem,o=this.findItemIndex(a);let l=s.findItemIndexAtTime(e);if(this.bufferedPos<e){var u;const h=this.findItemIndex(n),d=Math.min(h+1,t.length-1),g=t[d];if((l===-1&&n&&e>=n.end||(u=g.event)!=null&&u.appendInPlace&&e+.01>=g.start)&&(l=d),this.isInterstitial(n)){const m=n.event;if(d-o>1&&m.appendInPlace===!1||m.assetList.length===0&&m.assetListLoader)return}if(this.bufferedPos=e,l>h&&l>o)this.bufferedToItem(g);else{const m=this.primaryDetails;this.primaryLive&&m&&e>m.edge-m.targetduration&&g.start<m.edge+this.hls.config.interstitialLiveLookAhead&&this.isInterstitial(g)&&this.preloadAssets(g.event,0)}}else i&&a&&!this.itemsMatch(a,n)&&(l===o?this.bufferedToItem(a):l===o+1&&this.bufferedToItem(t[l]))}assetsBuffered(e,t){return e.event.assetList.length===0?!1:!e.event.assetList.some(s=>{const n=this.getAssetPlayer(s.identifier);return!(n!=null&&n.bufferedInPlaceToEnd(t))})}setBufferingItem(e){const t=this.bufferingItem,i=this.schedule;if(!this.itemsMatch(e,t)&&i){const{items:s,events:n}=i;if(!s||!n)return t;const a=this.isInterstitial(e),o=this.getBufferingPlayer();this.bufferingItem=e,this.bufferedPos=Math.max(e.start,Math.min(e.end,this.timelinePos));const l=o?o.remaining:t?t.end-this.timelinePos:0;if(this.log(`INTERSTITIALS_BUFFERED_TO_BOUNDARY ${Ft(e)}`+(t?` (${l.toFixed(2)} remaining)`:"")),!this.playbackDisabled)if(a){const u=i.findAssetIndex(e.event,this.bufferedPos);e.event.assetList.forEach((h,d)=>{const g=this.getAssetPlayer(h.identifier);g&&(d===u&&g.loadSource(),g.resumeBuffering())})}else this.hls.resumeBuffering(),this.playerQueue.forEach(u=>u.pauseBuffering());this.hls.trigger(E.INTERSTITIALS_BUFFERED_TO_BOUNDARY,{events:n.slice(0),schedule:s.slice(0),bufferingIndex:this.findItemIndex(e),playingIndex:this.findItemIndex(this.playingItem)})}else this.bufferingItem!==e&&(this.bufferingItem=e);return t}bufferedToItem(e,t=0){const i=this.setBufferingItem(e);if(!this.playbackDisabled){if(this.isInterstitial(e))this.bufferedToEvent(e,t);else if(i!==null){this.bufferingAsset=null;const s=this.getPrimaryResumption(e,this.findItemIndex(e),!0),n=this.bufferedPos=Math.max(s,Math.min(this.bufferedPos,e.end),this.timelinePos,e.start),a=this.detachedData;if(a)a.mediaSource?this.attachPrimary(n,e,!0):this.startLoadingPrimaryAt(n);else{const o=this.playingItem,l=this.isInterstitial(o)&&o.event.appendInPlace;this.startLoadingPrimaryAt(n,l)}}}}bufferedToEvent(e,t){const i=e.event,s=i.assetList.length===0&&!i.assetListLoader,n=i.cue.once;if(s||!n){const a=this.preloadAssets(i,t);if(a!=null&&a.interstitial.appendInPlace){const o=this.primaryMedia;o&&this.bufferAssetPlayer(a,o)}}}preloadAssets(e,t){const i=e.assetUrl,s=e.assetList.length,n=s===0&&!e.assetListLoader,a=e.cue.once;if(n){const l=e.timelineStart,u=this.playingItem,h=this.getBufferingPlayer();if(e.appendInPlace){var o;!this.isInterstitial(u)&&(u==null||(o=u.nextEvent)==null?void 0:o.identifier)===e.identifier&&this.flushFrontBuffer(l+.25)}let d,g=0;if((!h||h.interstitial.cue.pre)&&this.primaryLive&&(g=this.getLiveStartPos(),h&&(g+=h.remaining)),g&&!(e.cue.pre||e.cue.post)){const A=g-l;A>0&&(d=Math.round(A*1e3)/1e3)}if(this.log(`Load interstitial asset ${t+1}/${i?1:s} ${e}${g?` live-start: ${g} start-offset: ${d} (timeline-start: ${l})`:""}`),i)return this.createAsset(e,0,0,l,e.duration,i);const m=this.assetListLoader.loadAssetList(e,d);m&&(e.assetListLoader=m)}else if(!a&&s){for(let u=t;u<s;u++){const h=e.assetList[u],d=this.getAssetPlayerQueueIndex(h.identifier);(d===-1||this.playerQueue[d].destroyed)&&!h.error&&this.createAssetPlayer(e,h,u)}const l=e.assetList[t];if(l){const u=this.getAssetPlayer(l.identifier);return u&&u.loadSource(),u}}return null}flushFrontBuffer(e){const t=this.requiredTracks;if(!t)return;const i=this.primaryDetails;if(i&&e>=i.edge)return;this.log(`Removing front buffer starting at ${e}`),Object.keys(t).forEach(n=>{this.hls.trigger(E.BUFFER_FLUSHING,{startOffset:e,endOffset:1/0,type:n})})}getAssetPlayerQueueIndex(e){const t=this.playerQueue;for(let i=0;i<t.length;i++)if(e===t[i].assetId)return i;return-1}getAssetPlayer(e){const t=this.getAssetPlayerQueueIndex(e);return this.playerQueue[t]||null}getBufferingPlayer(){const{playerQueue:e,primaryMedia:t}=this;if(t){for(let i=0;i<e.length;i++)if(e[i].media===t)return e[i]}return null}createAsset(e,t,i,s,n,a){const o={parentIdentifier:e.identifier,identifier:Qp(e,a,t),duration:n,startOffset:i,timelineStart:s,uri:a};return this.createAssetPlayer(e,o,t)}createAssetPlayer(e,t,i){const s=this.hls,n=s.userConfig,a=s.loadLevelObj||s.levels[s.currentLevel],o=ko(a,n.videoPreference),l=s.audioTracks[s.audioTrack],u=s.subtitleTracks[s.subtitleTrack];let h=0;if(this.primaryLive||e.appendInPlace){const D=this.timelinePos-t.timelineStart;if(D>=0){const _=t.duration;_&&D<_&&(h=D)}}const d=t.identifier,g=Ae(Ae({},n),{},{maxMaxBufferLength:Math.min(15,s.config.maxMaxBufferLength),autoStartLoad:!0,startFragPrefetch:!0,primarySessionId:s.sessionId,assetPlayerId:d,abrEwmaDefaultEstimate:s.bandwidthEstimate,interstitialsController:void 0,startPosition:h,liveDurationInfinity:!1,testBandwidth:!1,videoPreference:o,audioPreference:l||n.audioPreference,subtitlePreference:u||n.subtitlePreference});e.appendInPlace&&(e.appendInPlaceStarted=!0,t.timelineStart&&(g.timelineOffset=t.timelineStart));const m=g.cmcd;m!=null&&m.sessionId&&m.contentId&&(g.cmcd=je({},m,{contentId:_s(t.uri)})),this.getAssetPlayer(d)&&this.warn(`Duplicate date range identifier ${e} and asset ${d}`);const A=new tm(this.HlsPlayerClass,g,e,t);this.playerQueue.push(A),e.assetList[i]=t;let C=!0;const v=D=>{if(D.live){const p=new Error(`Interstitials MUST be VOD assets ${e}`),$={fatal:!0,type:me.OTHER_ERROR,details:U.INTERSTITIAL_ASSET_ITEM_ERROR,error:p},N=this.findEventIndex(e.identifier);this.handleAssetItemError($,e,N,i,p.message);return}const _=D.edge-D.fragmentStart,M=t.duration;(C||M===null||_>M)&&(C=!1,this.log(`Interstitial asset "${d}" duration change ${M} > ${_}`),t.duration=_,this.updateSchedule())};A.on(E.LEVEL_UPDATED,(D,{details:_})=>v(_)),A.on(E.LEVEL_PTS_UPDATED,(D,{details:_})=>v(_)),A.on(E.EVENT_CUE_ENTER,()=>this.onInterstitialCueEnter());const S=(D,_)=>{const M=this.getAssetPlayer(d);if(M&&_.tracks){M.off(E.BUFFER_CODECS,S),M.tracks=_.tracks;const p=this.primaryMedia;this.bufferingAsset===M.assetItem&&p&&!M.media&&this.bufferAssetPlayer(M,p)}};A.on(E.BUFFER_CODECS,S);const R=()=>{const D=this.getAssetPlayer(d);if(this.log(`buffered to end of asset ${D}`),!D||!this.schedule)return;const _=this.getEventItem(e.identifier);_&&this.advanceAssetBuffering(_,D.assetItem)};A.on(E.BUFFERED_TO_END,R);const b=D=>()=>{if(!this.getAssetPlayer(d)||!this.schedule)return;this.shouldPlay=!0;const M=this.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,M,D)};return A.once(E.MEDIA_ENDED,b(i)),A.once(E.PLAYOUT_LIMIT_REACHED,b(1/0)),A.on(E.ERROR,(D,_)=>{if(!this.schedule)return;const M=this.getAssetPlayer(d);if(_.details===U.BUFFER_STALLED_ERROR){if(M!=null&&M.appendInPlace){this.handleInPlaceStall(e);return}this.onTimeupdate(),this.checkBuffer(!0);return}else if(_.details===U.BUFFER_SEEK_OVER_HOLE)return;this.handleAssetItemError(_,e,this.findEventIndex(e.identifier),i,`Asset player error ${_.error} ${e}`)}),A.on(E.DESTROYING,()=>{if(!this.getAssetPlayer(d)||!this.schedule)return;const _=new Error(`Asset player destroyed unexpectedly ${d}`),M={fatal:!0,type:me.OTHER_ERROR,details:U.INTERSTITIAL_ASSET_ITEM_ERROR,error:_};this.handleAssetItemError(M,e,this.findEventIndex(e.identifier),i,_.message)}),this.log(`INTERSTITIAL_ASSET_PLAYER_CREATED ${es(t)}`),this.hls.trigger(E.INTERSTITIAL_ASSET_PLAYER_CREATED,{asset:t,assetListIndex:i,event:e,player:A}),A}clearInterstitial(e,t){this.clearAssetPlayers(e,t),e.reset()}clearAssetPlayers(e,t){e.assetList.forEach(i=>{this.clearAssetPlayer(i.identifier,t)})}resetAssetPlayer(e){const t=this.getAssetPlayerQueueIndex(e);if(t!==-1){this.log(`reset asset player "${e}" after error`);const i=this.playerQueue[t];this.transferMediaFromPlayer(i,null),i.resetDetails()}}clearAssetPlayer(e,t){const i=this.getAssetPlayerQueueIndex(e);if(i!==-1){const s=this.playerQueue[i];this.log(`clear ${s} toSegment: ${t&&Ft(t)}`),this.transferMediaFromPlayer(s,t),this.playerQueue.splice(i,1),s.destroy()}}emptyPlayerQueue(){let e;for(;e=this.playerQueue.pop();)e.destroy();this.playerQueue=[]}startAssetPlayer(e,t,i,s,n){const{interstitial:a,assetItem:o,assetId:l}=e,u=a.assetList.length,h=this.playingAsset;this.endedAsset=null,this.playingAsset=o,h?.identifier!==l&&(h&&(this.clearAssetPlayer(h.identifier,i[s]),delete h.error),this.log(`INTERSTITIAL_ASSET_STARTED ${t+1}/${u} ${es(o)}`),this.hls.trigger(E.INTERSTITIAL_ASSET_STARTED,{asset:o,assetListIndex:t,event:a,schedule:i.slice(0),scheduleIndex:s,player:e})),this.bufferAssetPlayer(e,n)}bufferAssetPlayer(e,t){var i;if(!this.schedule)return;const{interstitial:s,assetItem:n}=e,a=this.getEventItem(s.identifier);if(!a)return;if(e.loadSource(),this.setBufferingItem(a),this.bufferingAsset=n,e.bufferedInPlaceToEnd(this.primaryMedia,e.currentTime)){this.advanceAssetBuffering(a,n);return}const o=this.getBufferingPlayer();if(o===e)return;const l=s.appendInPlace;if(l&&o?.interstitial.appendInPlace===!1)return;const u=o?.tracks||((i=this.detachedData)==null?void 0:i.tracks)||this.requiredTracks;if(l&&n!==this.playingAsset){if(!e.tracks){this.log(`Waiting for track info before buffering ${e}`);return}if(u&&!ja(u,e.tracks)){const h=new Error(`Asset ${es(n)} SourceBuffer tracks ('${Object.keys(e.tracks)}') are not compatible with primary content tracks ('${Object.keys(u)}')`),d={fatal:!0,type:me.OTHER_ERROR,details:U.INTERSTITIAL_ASSET_ITEM_ERROR,error:h},g=s.findAssetIndex(n);this.handleAssetItemError(d,s,this.findEventIndex(s.identifier),g,h.message);return}}this.transferMediaTo(e,t)}handleInPlaceStall(e){const t=this.schedule,i=this.primaryMedia;if(!t||!i)return;const s=i.currentTime,n=t.findAssetIndex(e,s),a=e.assetList[n];if(a){const o=this.getAssetPlayer(a.identifier);if(o){const l=o.currentTime||s-a.timelineStart,u=o.duration-l;if(this.warn(`Stalled at ${l} of ${l+u} in ${o} ${e} (media.currentTime: ${s})`),l&&(u/i.playbackRate<.5||o.bufferedInPlaceToEnd(i,o.currentTime))&&o.hls){const h=t.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,h,n)}}}}advanceInPlace(e){const t=this.primaryMedia;if(t&&t.currentTime<e){const i=`advance currentTime to ${e}, duration: ${t.duration}`;t.duration>e?(this.log(i),t.currentTime=e):this.log(`Cannot ${i}`)}}handleAssetItemError(e,t,i,s,n){if(e.details===U.BUFFER_STALLED_ERROR)return;const a=t.assetList[s]||null;if(this.warn(`INTERSTITIAL_ASSET_ERROR ${a&&es(a)} ${e.error}`),!this.schedule)return;const o=a?.identifier||"",l=this.getAssetPlayerQueueIndex(o),u=this.playerQueue[l]||null,h=this.schedule.items,d=je({},e,{fatal:!1,errorAction:ys(!0),asset:a,assetListIndex:s,event:t,schedule:h,scheduleIndex:i,player:u});if(this.hls.trigger(E.INTERSTITIAL_ASSET_ERROR,d),!e.fatal)return;const g=this.playingAsset,m=this.bufferingAsset,A=new Error(n);if(a&&(this.clearAssetPlayer(o,null),a.error=A),!t.assetList.some(C=>!C.error))t.error=A;else for(let C=s;C<t.assetList.length;C++)this.resetAssetPlayer(t.assetList[C].identifier);this.updateSchedule(!0),t.error?this.primaryFallback(t):g?.identifier===o?this.advanceAfterAssetEnded(t,i,s):m?.identifier===o&&this.isInterstitial(this.bufferingItem)&&this.advanceAssetBuffering(this.bufferingItem,m)}primaryFallback(e){const t=e.timelineStart,i=this.effectivePlayingItem,s=this.playingItem,n=this.seekableStart,a=this.hls.startPosition;let o=this.timelinePos;if(this.isInterstitial(i)){this.log(`Fallback to primary from event "${e.identifier}" start: ${t} pos: ${o} playing: ${Ft(i)} startPosition: ${a} seekableStart: ${n} error: ${e.error}`),o===-1&&(o=a),o=Math.max(o,n);const u=this.updateItem(i,o);this.itemsMatch(i,u)&&this.clearInterstitial(e,null),e.appendInPlace&&(this.attachPrimary(t,null),this.flushFrontBuffer(t))}else if(o===-1){this.checkStart();return}if(!this.schedule||!this.isInterstitial(s))return;const l=this.schedule.findItemIndexAtTime(o);this.setSchedulePosition(l)}onAssetListLoaded(e,t){var i,s;const n=t.event,a=n.identifier,o=t.assetListResponse.ASSETS;if(!((i=this.schedule)!=null&&i.hasEvent(a)))return;const l=n.timelineStart,u=n.duration;let h=0;o.forEach((A,C)=>{const v=parseFloat(A.DURATION);this.createAsset(n,C,h,l+h,v,A.URI),h+=v}),n.duration=h,this.log(`Loaded asset-list with duration: ${h} (was: ${u}) ${n}`);const d=this.waitingItem,g=d?.event.identifier===a;this.updateSchedule();const m=(s=this.bufferingItem)==null?void 0:s.event;if(g){const A=this.findEventIndex(a),C=this.getEventItem(a);if(C){if(!this.playingItem&&this.timelinePos>C.end&&this.schedule.findItemIndexAtTime(this.timelinePos)!==A){n.error=new Error(`Interstitial ${o.length?"no longer within playback range":"asset-list is empty"} ${this.timelinePos} ${n}`),this.log(n.error.message),this.updateSchedule(!0),this.primaryFallback(n);return}this.setBufferingItem(C)}this.setSchedulePosition(A)}else if(m?.identifier===a){const A=n.assetList[0];if(A){const C=this.getAssetPlayer(A.identifier);if(m.appendInPlace){const v=this.primaryMedia;C&&v&&this.bufferAssetPlayer(C,v)}else C&&C.loadSource()}}}onError(e,t){if(this.schedule)switch(t.details){case U.ASSET_LIST_PARSING_ERROR:case U.ASSET_LIST_LOAD_ERROR:case U.ASSET_LIST_LOAD_TIMEOUT:{const i=t.interstitial;i&&(this.updateSchedule(!0),this.primaryFallback(i));break}case U.BUFFER_STALLED_ERROR:{const i=this.endedItem||this.waitingItem||this.playingItem;if(this.isInterstitial(i)&&i.event.appendInPlace){this.handleInPlaceStall(i.event);return}const s=this.primaryMedia;this.log(`Primary player stall @${this.timelinePos} currentTime: ${s?.currentTime} bufferedPos: ${this.bufferedPos}`),this.onTimeupdate(),this.checkBuffer(!0);break}}}}class rm{constructor(e){this.hls=void 0,this.media=null,this.currentTime=0,this.stallCount=0,this._latency=null,this._targetLatencyUpdated=!1,this.onTimeupdate=()=>{var t;const{media:i}=this,s=this.levelDetails;if(!i||!s||!this.hls)return;this.currentTime=i.currentTime;const n=this.hls.config,a=this.computeLatency();if(a===null)return;this._latency=a;const{lowLatencyMode:o,maxLiveSyncPlaybackRate:l}=n;if(!o||l===1||!s.live)return;const u=this.targetLatency;if(u===null)return;const h=a-u,d=Math.min(this.maxLatency,u+s.targetduration),g=h<d,m=dn(n)&&!!((t=this.hls.interstitialsManager)!=null&&(t=t.playingItem)!=null&&t.event);if(g&&h>.05&&this.forwardBufferLength>1&&!m){const A=Math.min(2,Math.max(1,l)),C=Math.round(2/(1+Math.exp(-.75*h-this.edgeStalled))*20)/20,v=Math.min(A,Math.max(1,C));this.changeMediaPlaybackRate(i,v)}else i.playbackRate!==1&&i.playbackRate!==0&&this.changeMediaPlaybackRate(i,1)},this.hls=e,this.registerListeners()}get levelDetails(){var e;return((e=this.hls)==null?void 0:e.latestLevelDetails)||null}get latency(){return this._latency||0}get maxLatency(){var e;const t=(e=this.hls)==null?void 0:e.config;if(!t)return 0;if(t.liveMaxLatencyDuration!==void 0)return t.liveMaxLatencyDuration;const i=this.levelDetails;return i?t.liveMaxLatencyDurationCount*i.targetduration:0}get targetLatency(){const e=this.levelDetails;if(e===null||!this.hls)return null;const t=this.hls.config,{holdBack:i,partHoldBack:s,targetduration:n}=e,{liveSyncDuration:a,liveSyncDurationCount:o,lowLatencyMode:l}=t,u=this.hls.userConfig;let h=l&&s||i;(this._targetLatencyUpdated||u.liveSyncDuration||u.liveSyncDurationCount||h===0)&&(h=a!==void 0?a:o*n);const d=n;return h+Math.min(this.stallCount*t.liveSyncOnStallIncrease,d)}set targetLatency(e){this.hls&&(this.stallCount=0,this.hls.config.liveSyncDuration=e,this._targetLatencyUpdated=!0)}get liveSyncPosition(){const e=this.estimateLiveEdge(),t=this.targetLatency;if(e===null||t===null||!this.hls)return null;const i=this.levelDetails;if(i===null)return null;const s=i.edge,n=e-t-this.edgeStalled,a=s-i.totalduration,o=s-(this.hls.config.lowLatencyMode&&i.partTarget||i.targetduration);return Math.min(Math.max(a,n),o)}get drift(){const e=this.levelDetails;return e===null?1:e.drift}get edgeStalled(){const e=this.levelDetails;if(e===null||!this.hls)return 0;const t=(this.hls.config.lowLatencyMode&&e.partTarget||e.targetduration)*3;return Math.max(e.age-t,0)}get forwardBufferLength(){const{media:e}=this,t=this.levelDetails;if(!e||!t)return 0;const i=e.buffered.length;return(i?e.buffered.end(i-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.hls=null}registerListeners(){const{hls:e}=this;e&&(e.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(E.ERROR,this.onError,this),e.on(E.INTERSTITIAL_ASSET_STARTED,this.onAssetStarted,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(E.ERROR,this.onError,this),e.off(E.INTERSTITIAL_ASSET_STARTED,this.onAssetStarted,this))}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.onTimeupdate)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.onTimeupdate),this.media=null)}onManifestLoading(){this._latency=null,this.stallCount=0}onLevelUpdated(e,{details:t}){t.advanced&&this.onTimeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.onTimeupdate)}onAssetStarted(e,t){var i;const s=this.hls,n=this.media||t.event.appendInPlace&&(s==null||(i=s.interstitialsManager)==null?void 0:i.playerQueue.reduce((a,o)=>a||o.media,null));s&&n&&n.playbackRate>1&&n.playbackRate<=s.config.maxLiveSyncPlaybackRate&&this.changeMediaPlaybackRate(n,1)}onError(e,t){var i;t.details===U.BUFFER_STALLED_ERROR&&(this.stallCount++,this.hls&&(i=this.levelDetails)!=null&&i.live&&this.hls.logger.warn("[latency-controller]: Stall detected, adjusting target latency"))}changeMediaPlaybackRate(e,t){var i,s;e.playbackRate!==t&&((i=this.hls)==null||i.logger.debug(`[latency-controller]: latency=${this.latency.toFixed(3)}, targetLatency=${(s=this.targetLatency)==null?void 0:s.toFixed(3)}, forwardBufferLength=${this.forwardBufferLength.toFixed(3)}: adjusting playback rate from ${e.playbackRate} to ${t}`),e.playbackRate=t)}estimateLiveEdge(){const e=this.levelDetails;return e===null?null:e.edge+e.age}computeLatency(){const e=this.estimateLiveEdge();return e===null?null:e-this.currentTime}}const ic=500;class am extends Er{constructor(e,t,i){super(e,t,i,"subtitle-stream-controller",ge.SUBTITLE),this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this.registerListeners()}onHandlerDestroying(){this.unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null}registerListeners(){super.registerListeners();const{hls:e}=this;e.on(E.LEVEL_LOADED,this.onLevelLoaded,this),e.on(E.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(E.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(E.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(E.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(E.BUFFER_FLUSHING,this.onBufferFlushing,this)}unregisterListeners(){super.unregisterListeners();const{hls:e}=this;e.off(E.LEVEL_LOADED,this.onLevelLoaded,this),e.off(E.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(E.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(E.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(E.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this)}startLoad(e,t){this.stopLoad(),this.state=Y.IDLE,this.setInterval(ic),this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}onManifestLoading(){super.onManifestLoading(),this.mainDetails=null}onMediaDetaching(e,t){this.tracksBuffered=[],super.onMediaDetaching(e,t)}onLevelLoaded(e,t){this.mainDetails=t.details}onSubtitleFragProcessed(e,t){const{frag:i,part:s,success:n}=t;if(!n)return;const a=this.tracksBuffered[this.currentTrackId];if(!a)return;let o;const l=(s||i).start;for(let h=0;h<a.length;h++)if(l>=a[h].start&&l<=a[h].end){o=a[h];break}const u=l+(s||i).duration;if(o?o.end=u:(o={start:l,end:u},a.push(o)),!s||u>=i.end){const h=this.fragmentTracker.fragBuffered(i);s&&h&&(h.range.subs={time:[{startPTS:i.start,endPTS:u}],partial:!0}),st(i)&&!this.fragContextChanged(i)&&(this.fragPrevious=i),this.fragBufferedComplete(i,s),this.media&&this.tickImmediate()}}onBufferFlushing(e,t){const{startOffset:i,endOffset:s}=t;if(i===0&&s!==Number.POSITIVE_INFINITY){const n=s-1;if(n<=0)return;t.endOffsetSubtitles=Math.max(0,n),this.tracksBuffered.forEach(a=>{if(a)for(let o=0;o<a.length;){if(a[o].end<=n){a.shift();continue}else if(a[o].start<n)a[o].start=n;else break;o++}}),this.fragmentTracker.removeFragmentsInRange(i,n,ge.SUBTITLE)}}onError(e,t){const i=t.frag;i?.type===ge.SUBTITLE&&(t.details===U.FRAG_GAP&&this.fragmentTracker.addAsGap(i),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==Y.STOPPED&&(this.state=Y.IDLE))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){if(this.levels&&Ql(this.levels,t)){this.levels=t.map(i=>new Is(i));return}this.tracksBuffered=[],this.levels=t.map(i=>{const s=new Is(i);return this.tracksBuffered[s.id]=[],s}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,ge.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null}onSubtitleTrackSwitch(e,t){var i;if(this.currentTrackId=t.id,this.abortCurrentFrag(),!((i=this.levels)!=null&&i.length)||this.currentTrackId===-1){this.clearInterval();return}const s=this.levels[this.currentTrackId];if(!(s!=null&&s.details)){this.mediaBuffer=null;return}this.mediaBuffer=this.mediaBufferTimeRanges,this.state!==Y.STOPPED&&this.setInterval(ic)}onSubtitleTrackLoaded(e,t){var i;const{currentTrackId:s,levels:n}=this,{details:a,id:o}=t;if(!n){this.warn(`Subtitle tracks were reset while loading level ${o}`);return}const l=n[o];if(o>=n.length||!l)return;this.log(`Subtitle track ${o} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""},duration:${a.totalduration}`),this.mediaBuffer=this.mediaBufferTimeRanges;const u=this.mainDetails;let h=0;if(a.live||(i=l.details)!=null&&i.live){if(a.deltaUpdateFailed)return;if(!u){this.startFragRequested=!1;return}if(l.details){var d;h=this.alignPlaylists(a,l.details,(d=this.levelLastLoaded)==null?void 0:d.details)}a.alignedSliding||(cn(u,a,this),h=a.fragmentStart)}l.details=a,this.levelLastLoaded=l,u&&!this.startFragRequested&&this.setStartPosition(u,h),o===s&&(this.hls.trigger(E.SUBTITLE_TRACK_UPDATED,{details:a,id:o,groupId:t.groupId}),this.tickImmediate())}_handleFragmentLoadProgress(e){const{frag:t,part:i,payload:s}=e;!i||!(s!=null&&s.byteLength)||!this.shouldDecrypt(t)||this.decryptPayload(s,t,i)}_handleFragmentLoadComplete(e){const{frag:t,payload:i}=e;this.fragContextChanged(t)||!(i!=null&&i.byteLength)||!this.shouldDecrypt(t)||this.decryptPayload(i,t,null)}shouldDecrypt(e){const t=e.decryptdata;return!!(t!=null&&t.key&&t.iv&&zi(t.method))}decryptPayload(e,t,i){const s=t.decryptdata,n=performance.now();this.decrypter.decrypt(new Uint8Array(e),s.key.buffer,s.iv.buffer,pr(s.method)).then(a=>{this.fragContextChanged(t)||this.hls.trigger(E.FRAG_DECRYPTED,{frag:t,part:i,payload:a,stats:{tstart:n,tdecrypt:performance.now()}})}).catch(a=>{this.hls.trigger(E.ERROR,{type:me.MEDIA_ERROR,details:U.FRAG_DECRYPT_ERROR,fatal:!1,error:a,reason:a.message,frag:t,part:i}),i||(this.warn(`${a.name}: ${a.message}`),this.state=Y.IDLE)})}doTick(){if(this.state===Y.IDLE&&this.levels){var e;if(!this.media&&!this.primaryPrefetch&&(this.startFragRequested||!this.config.startFragPrefetch))return;const{currentTrackId:i,levels:s}=this,n=s[i],a=n?.details;if(!a||this.waitForLive(n)||this.waitForCdnTuneIn(a)){this.startFragRequested=!1;return}const{config:o}=this,l=this.playhead,u=ve.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],l,o.maxBufferHole),{end:h,len:d}=u,g=Math.max(this.hls.maxBufferLength+a.levelTargetDuration,((e=this.hls.mainForwardBufferInfo)==null?void 0:e.len)||0);if(d>g||d&&!this.buffering)return;let m=this.getNextFragment(h,a);if(!m)return;if(st(m)){var t;const A=m.sn-a.startSN,C=a.fragments[A-1];m.cc===C?.cc&&!((t=a.partList)!=null&&t.length)&&this.fragmentTracker.getState(C)===et.NOT_LOADED&&(m=C)}this.loadFragment(m,n,h)}}loadFragment(e,t,i){const s=this.fragmentTracker.getState(e);(s===et.NOT_LOADED||s===et.PARTIAL)&&super.loadFragment(e,t,i)}get mediaBufferTimeRanges(){return new om(this.tracksBuffered[this.currentTrackId]||[])}}class om{constructor(e){this.buffered=void 0;const t=(i,s,n)=>{if(s=s>>>0,s>n-1)throw new DOMException(`Failed to execute '${i}' on 'TimeRanges': The index provided (${s}) is greater than the maximum bound (${n})`);return e[s][i]};this.buffered={get length(){return e.length},end(i){return t("end",i,e.length)},start(i){return t("start",i,e.length)}}}}const lm={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},sc=r=>String.fromCharCode(lm[r]||r),zt=15,Xt=42,um={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},cm={17:2,18:4,21:6,22:8,23:10,19:13,20:15},hm={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},dm={25:2,26:4,29:6,30:8,31:10,27:13,28:15},fm=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class gm{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){const i=typeof t=="function"?t():t;Ge.log(`${this.time} [${e}] ${i}`)}}}const Ni=function(e){const t=[];for(let i=0;i<e.length;i++)t.push(e[i].toString(16));return t},ha=Object.freeze({foreground:"white",underline:!1,italics:!1,background:"black",flash:!1});class nc{constructor(){this.styles=ha}get foreground(){return this.styles.foreground}set foreground(e){const t=this.styles;this.styles={foreground:e,underline:t.underline,italics:t.italics,background:t.background,flash:t.flash}}get underline(){return this.styles.underline}set underline(e){const t=this.styles;this.styles={foreground:t.foreground,underline:e,italics:t.italics,background:t.background,flash:t.flash}}get italics(){return this.styles.italics}set italics(e){const t=this.styles;this.styles={foreground:t.foreground,underline:t.underline,italics:e,background:t.background,flash:t.flash}}get background(){return this.styles.background}set background(e){const t=this.styles;this.styles={foreground:t.foreground,underline:t.underline,italics:t.italics,background:e,flash:t.flash}}get flash(){return this.styles.flash}set flash(e){const t=this.styles;this.styles={foreground:t.foreground,underline:t.underline,italics:t.italics,background:t.background,flash:e}}reset(){this.styles=ha}setStyles(e){const t=this.styles,i=Object.prototype.hasOwnProperty;this.styles={foreground:i.call(e,"foreground")?e.foreground:t.foreground,underline:i.call(e,"underline")?e.underline:t.underline,italics:i.call(e,"italics")?e.italics:t.italics,background:i.call(e,"background")?e.background:t.background,flash:i.call(e,"flash")?e.flash:t.flash}}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}}class pm{constructor(){this.uchar=" ",this.penState=new nc}reset(){this.uchar=" ",this.penState.reset()}setChar(e,t){this.uchar=e,this.penState.styles=t.styles}setPenState(e){this.penState.styles=e.styles}copy(e){this.uchar=e.uchar,this.penState.styles=e.penState.styles}}class mm{constructor(e){this.chars=[],this.pos=0,this.currPenState=new nc,this.cueStartTime=null,this.logger=void 0;for(let t=0;t<Xt;t++)this.chars.push(new pm);this.logger=e}equals(e){const t=this.chars,i=e.chars;for(let s=0;s<Xt;s++){const n=t[s],a=i[s];if(n.uchar!==a.uchar)return!1;const o=n.penState.styles,l=a.penState.styles;if(o!==l&&(o.foreground!==l.foreground||o.underline!==l.underline||o.italics!==l.italics||o.background!==l.background||o.flash!==l.flash))return!1}return!0}copy(e){for(let t=0;t<Xt;t++)this.chars[t].copy(e.chars[t])}isEmpty(){const e=this.chars;for(let t=0;t<Xt;t++){const i=e[t];if(i.uchar!==" ")return!1;const s=i.penState.styles;if(s!==ha&&(s.foreground!=="white"||s.underline||s.italics||s.background!=="black"||s.flash))return!1}return!0}setCursor(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>=Xt&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=Xt-1)}moveCursor(e){const t=Math.min(this.pos+e,Xt);if(e>1)for(let i=this.pos+1;i<t;i++)this.chars[i].setPenState(this.currPenState);this.setCursor(t)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(e){e>=144&&this.backSpace();const t=sc(e);if(this.pos>=Xt){this.logger.log(0,()=>"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1)}clearFromPos(e){let t;for(t=e;t<Xt;t++)this.chars[t].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){const e=[];let t=!0;for(let i=0;i<Xt;i++){const s=this.chars[i].uchar;s!==" "&&(t=!1),e.push(s)}return t?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)}}class da{constructor(e){this.rows=[],this.currRow=zt-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let t=0;t<zt;t++)this.rows.push(new mm(e));this.logger=e}reset(){for(let e=0;e<zt;e++)this.rows[e].clear();this.currRow=zt-1}equals(e){let t=!0;for(let i=0;i<zt;i++)if(!this.rows[i].equals(e.rows[i])){t=!1;break}return t}copy(e){for(let t=0;t<zt;t++){const i=this.rows[t].chars,s=e.rows[t].chars;for(let n=0;n<Xt;n++){const a=i[n],o=s[n];a.uchar=o.uchar,a.penState.styles=o.penState.styles}}}isEmpty(){let e=!0;for(let t=0;t<zt;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e}backSpace(){this.rows[this.currRow].backSpace()}clearToEndOfRow(){this.rows[this.currRow].clearToEndOfRow()}insertChar(e){this.rows[this.currRow].insertChar(e)}setPen(e){this.rows[this.currRow].setPenStyles(e)}moveCursor(e){this.rows[this.currRow].moveCursor(e)}setCursor(e){this.logger.log(2,"setCursor: "+e),this.rows[this.currRow].setCursor(e)}setPAC(e){this.logger.log(2,()=>"pacData = "+Xe(e));let t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(let o=0;o<zt;o++)this.rows[o].clear();const n=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){const o=a.rows[n].cueStartTime,l=this.logger.time;if(o!==null&&l!==null&&o<l)for(let u=0;u<this.nrRollUpRows;u++)this.rows[t-this.nrRollUpRows+u+1].copy(a.rows[n+u])}}this.currRow=t;const i=this.rows[this.currRow];if(e.indent!==null){const n=e.indent,a=Math.max(n-1,0);i.setCursor(e.indent),e.color=i.chars[a].penState.foreground}const s={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(s)}setBkgData(e){this.logger.log(2,()=>"bkgData = "+Xe(e)),this.backSpace(),this.setPen(e),this.insertChar(32)}setRollUpRows(e){this.nrRollUpRows=e}rollUp(){if(this.nrRollUpRows===null){this.logger.log(3,"roll_up but nrRollUpRows not set yet");return}this.logger.log(1,()=>this.getDisplayText());const e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(2,"Rolling up")}getDisplayText(e){e=e||!1;const t=[];let i="",s=-1;for(let n=0;n<zt;n++){const a=this.rows[n].getTextString();a&&(s=n+1,e?t.push("Row "+s+": '"+a+"'"):t.push(a.trim()))}return t.length>0&&(e?i="["+t.join(" | ")+"]":i=t.join(`
42
+ `)),i}getTextAndFormat(){return this.rows}}class Am{constructor(e,t,i){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new da(i),this.nonDisplayedMemory=new da(i),this.lastOutputScreen=new da(i),this.currRollUpRow=this.displayedMemory.rows[zt-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=i}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[zt-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(e){this.outputFilter=e}setPAC(e){this.writeScreen.setPAC(e)}setBkgData(e){this.writeScreen.setBkgData(e)}setMode(e){e!==this.mode&&(this.mode=e,this.logger.log(2,()=>"MODE="+e),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)}insertChars(e){for(let i=0;i<e.length;i++)this.writeScreen.insertChar(e[i]);const t=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>t+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(1,()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())}ccRCL(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}ccBS(){this.logger.log(2,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}ccAOF(){}ccAON(){}ccDER(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}ccRU(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}ccEOC(){if(this.logger.log(2,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){const e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}ccTO(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}ccMIDROW(e){const t={flash:!1};if(t.underline=e%2===1,t.italics=e>=46,t.italics)t.foreground="white";else{const i=Math.floor(e/2)-16,s=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=s[i]}this.logger.log(2,"MIDROW: "+Xe(t)),this.writeScreen.setPen(t)}outputDataUpdate(e=!1){const t=this.logger.time;t!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=t:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t),this.lastOutputScreen.copy(this.displayedMemory))}cueSplitAtTime(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))}}class rc{constructor(e,t,i){this.channels=[null,null,null],this.currentChannel=0,this.cmdHistory=Cm(),this.logger=void 0,this.field=void 0,this.outputFilters=void 0,this.logger=new gm,this.field=e,this.outputFilters=[null,t,i]}getHandler(e){return this.outputFilters[e]}setHandler(e,t){var i;this.outputFilters[e]=t,(i=this.channels[e])==null||i.setHandler(t)}getChannel(e){let t=this.channels[e];return t||(t=this.channels[e]=new Am(this.field+e-1,this.outputFilters[e],this.logger)),t}addData(e,t){this.logger.time=e;for(let i=0;i<t.length;i+=2){const s=t[i]&127,n=t[i+1]&127;let a=!1,o=null;if(s===0&&n===0)continue;this.logger.log(3,()=>"["+Ni([t[i],t[i+1]])+"] -> ("+Ni([s,n])+")");const l=this.cmdHistory;if(s>=16&&s<=31){if(Im(s,n,l)){Dn(null,null,l),this.logger.log(3,()=>"Repeated command ("+Ni([s,n])+") is dropped");continue}Dn(s,n,this.cmdHistory),a=this.parseCmd(s,n),a||(a=this.parseMidrow(s,n)),a||(a=this.parsePAC(s,n)),a||(a=this.parseBackgroundAttributes(s,n))}else Dn(null,null,l);if(!a&&(o=this.parseChars(s,n),o)){const h=this.currentChannel;h&&h>0?this.getChannel(h).insertChars(o):this.logger.log(2,"No channel found yet. TEXT-MODE?")}!a&&!o&&this.logger.log(2,()=>"Couldn't parse cleaned data "+Ni([s,n])+" orig: "+Ni([t[i],t[i+1]]))}}parseCmd(e,t){const i=(e===20||e===28||e===21||e===29)&&t>=32&&t<=47,s=(e===23||e===31)&&t>=33&&t<=35;if(!(i||s))return!1;const n=e===20||e===21||e===23?1:2,a=this.getChannel(n);return e===20||e===21||e===28||e===29?t===32?a.ccRCL():t===33?a.ccBS():t===34?a.ccAOF():t===35?a.ccAON():t===36?a.ccDER():t===37?a.ccRU(2):t===38?a.ccRU(3):t===39?a.ccRU(4):t===40?a.ccFON():t===41?a.ccRDC():t===42?a.ccTR():t===43?a.ccRTD():t===44?a.ccEDM():t===45?a.ccCR():t===46?a.ccENM():t===47&&a.ccEOC():a.ccTO(t-32),this.currentChannel=n,!0}parseMidrow(e,t){let i=0;if((e===17||e===25)&&t>=32&&t<=47){if(e===17?i=1:i=2,i!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;const s=this.channels[i];return s?(s.ccMIDROW(t),this.logger.log(3,()=>"MIDROW ("+Ni([e,t])+")"),!0):!1}return!1}parsePAC(e,t){let i;const s=(e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127,n=(e===16||e===24)&&t>=64&&t<=95;if(!(s||n))return!1;const a=e<=23?1:2;return t>=64&&t<=95?i=a===1?um[e]:hm[e]:i=a===1?cm[e]:dm[e],this.getChannel(a).setPAC(this.interpretPAC(i,t)),this.currentChannel=a,!0}interpretPAC(e,t){let i;const s={color:null,italics:!1,indent:null,underline:!1,row:e};return t>95?i=t-96:i=t-64,s.underline=(i&1)===1,i<=13?s.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(i/2)]:i<=15?(s.italics=!0,s.color="white"):s.indent=Math.floor((i-16)/2)*4,s}parseChars(e,t){let i,s=null,n=null;if(e>=25?(i=2,n=e-8):(i=1,n=e),n>=17&&n<=19){let a;n===17?a=t+80:n===18?a=t+112:a=t+144,this.logger.log(2,()=>"Special char '"+sc(a)+"' in channel "+i),s=[a]}else e>=32&&e<=127&&(s=t===0?[e]:[e,t]);return s&&this.logger.log(3,()=>"Char codes = "+Ni(s).join(",")),s}parseBackgroundAttributes(e,t){const i=(e===16||e===24)&&t>=32&&t<=47,s=(e===23||e===31)&&t>=45&&t<=47;if(!(i||s))return!1;let n;const a={};e===16||e===24?(n=Math.floor((t-32)/2),a.background=fm[n],t%2===1&&(a.background=a.background+"_semi")):t===45?a.background="transparent":(a.foreground="black",t===47&&(a.underline=!0));const o=e<=23?1:2;return this.getChannel(o).setBkgData(a),!0}reset(){for(let e=0;e<Object.keys(this.channels).length;e++){const t=this.channels[e];t&&t.reset()}Dn(null,null,this.cmdHistory)}cueSplitAtTime(e){for(let t=0;t<this.channels.length;t++){const i=this.channels[t];i&&i.cueSplitAtTime(e)}}}function Dn(r,e,t){t.a=r,t.b=e}function Im(r,e,t){return t.a===r&&t.b===e}function Cm(){return{a:null,b:null}}class Pn{constructor(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}dispatchCue(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(e,t,i){(this.startTime===null||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=i,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}class ym{constructor(e){this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.cueCache={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=ac(),this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.config.cueHandler,this.cueCache={},this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},e.on(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(E.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(E.FRAG_LOADING,this.onFragLoading,this),e.on(E.FRAG_LOADED,this.onFragLoaded,this),e.on(E.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(E.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(E.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(E.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(E.BUFFER_APPENDED,this.onBufferAppended,this),e.on(E.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:e}=this;e.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(E.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(E.FRAG_LOADING,this.onFragLoading,this),e.off(E.FRAG_LOADED,this.onFragLoaded,this),e.off(E.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(E.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(E.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(E.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(E.BUFFER_APPENDED,this.onBufferAppended,this),e.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.media=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){const e=new Pn(this,"textTrack1"),t=new Pn(this,"textTrack2"),i=new Pn(this,"textTrack3"),s=new Pn(this,"textTrack4");this.cea608Parser1=new rc(1,e,t),this.cea608Parser2=new rc(3,i,s)}addCues(e,t,i,s,n){let a=!1;for(let l=n.length;l--;){const u=n[l],h=vm(u[0],u[1],t,i);if(h>=0&&(u[0]=Math.min(u[0],t),u[1]=Math.max(u[1],i),a=!0,h/(i-t)>.5))return}if(a||n.push([t,i]),this.config.renderTextTracksNatively){const l=this.cueCache[e];if(l){const u=this.Cues.newCue(null,t,i,s);u.length&&l.push.apply(l,u)}else{const u=this.captionsTracks[e].track;this.Cues.newCue(u,t,i,s)}}else{var o;const l=this.Cues.newCue(null,t,i,s),u=(o=this.captionsProperties[e])==null?void 0:o.media;this.hls.trigger(E.CUES_PARSED,{type:"captions",cues:l,track:e,closedCaptions:u})}}onInitPtsFound(e,{id:t,timestampOffsets:i}){const{unparsedVttFrags:s}=this;t===ge.MAIN&&(this.initPTS=i),s.length&&(this.unparsedVttFrags=[],s.forEach(n=>{this.initPTS[n.frag.cc]?this.onFragLoaded(E.FRAG_LOADED,n):this.hls.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:n.frag,part:null,error:new Error("Subtitle discontinuity domain does not match main")})}))}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}createNativeTrack(e){if(this.captionsTracks[e])return;const{captionsProperties:t,captionsTracks:i,cueCache:s,media:n}=this,{label:a,languageCode:o}=t[e];n&&(s[e]=[],i[e]=sa(n,"captions",a,o,"hidden"))}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;const t=this.captionsProperties[e];if(!t)return;const i=t.label,s={_id:e,label:i,kind:"captions",default:t.media?!!t.media.default:!1,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=s,this.hls.trigger(E.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[s]})}onMediaAttaching(e,t){this.media=t.media}onMediaDetaching(e,t){const i=!!t.transferMedia;if(this.media=null,!i){if(this.config.renderTextTracksNatively){const{captionsTracks:s,cueCache:n}=this;for(const a in s)s[a].remove(),delete n[a]}this.cueCache={},this.captionsTracks={},this.nonNativeCaptionsTracks={}}}onManifestLoading(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=ac(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}onSubtitleTracksUpdated(e,t){const i=t.subtitleTracks||[];if(i.length&&!this.config.renderTextTracksNatively&&!Ql(this.tracks,i)){const s=i.map(n=>({label:n.name,kind:n.type.toLowerCase(),default:n.default,subtitleTrack:n}));this.hls.trigger(E.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:s})}this.tracks=i}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(i=>{const s=/(?:CC|SERVICE)([1-4])/.exec(i.instreamId);if(!s)return;const n=`textTrack${s[1]}`,a=this.captionsProperties[n];a&&(a.label=i.name,i.lang&&(a.languageCode=i.lang),a.media=i)})}closedCaptionsForLevel(e){const t=this.hls.levels[e.level];return t?.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){if(this.enabled&&t.frag.type===ge.MAIN){var i,s;const{cea608Parser1:n,cea608Parser2:a,lastSn:o}=this,{cc:l,sn:u}=t.frag,h=(i=(s=t.part)==null?void 0:s.index)!=null?i:-1;n&&a&&(u!==o+1||u===o&&h!==this.lastPartIndex+1||l!==this.lastCc)&&(n.reset(),a.reset()),this.lastCc=l,this.lastSn=u,this.lastPartIndex=h}}onFragLoaded(e,t){const{frag:i,payload:s}=t;if(i.level<this.tracks.length&&i.type===ge.SUBTITLE){var n;if(s.byteLength||(n=i.initSegment)!=null&&(n=n.data)!=null&&n.byteLength){const a=i.decryptdata,o="stats"in t;if(a==null||!a.encrypted||o){const l=this.tracks[i.level],u=this.vttCCs;u[i.cc]||(u[i.cc]={start:i.start,prevCC:this.prevCC,new:!0},this.prevCC=i.cc),l?.textCodec===Jr?this._parseIMSC1(t):this._parseVTTs(t)}}else{const a="part"in t?t.part:null;this.hls.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,part:a,error:new Error("Empty subtitle payload")})}}}_parseIMSC1(e){const{frag:t,payload:i}=e,s="part"in e?e.part:null,n=this.hls;Gu(i,this.initPTS[t.cc],a=>{this._appendCues(a,t.level),n.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t,part:s})},a=>{n.logger.log(`Cannot parse IMSC1 (sn: ${t.sn} @${t.start}): ${a}`),n.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,part:s,error:a})})}_parseVTTs(e){var t;const{frag:i,payload:s}=e,n="part"in e?e.part:null,{initPTS:a,unparsedVttFrags:o}=this,l=a.length-1;if(!a[i.cc]&&l===-1){o.push(e);return}const u=this.hls,h=(t=i.initSegment)==null?void 0:t.data,d=h?Ut(h,new Uint8Array(s)).buffer:s;Dp(d,this.initPTS[i.cc],this.vttCCs,i.cc,(n&&!h?n:i).start,g=>{this._appendCues(g,i.level),u.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:i,part:n})},g=>{const m=g.message.startsWith("Missing initPTS");if(u.logger.log(`${m?"Deferred parsing of":"Cannot parse"} VTT cue (sn: ${i.sn} @${i.start}): ${g}`),m){o.push(e);return}else this.config.enableIMSC1&&this._fallbackToIMSC1(e);u.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,part:n,error:g})})}_fallbackToIMSC1(e){const{frag:t,payload:i}=e,s=this.tracks[t.level];s.textCodec||Gu(i,this.initPTS[t.cc],()=>{s.textCodec=Jr,this._parseIMSC1(e)},()=>{s.textCodec="wvtt"})}_appendCues(e,t){const i=this.hls;if(this.config.renderTextTracksNatively){var s;const n=(s=this.tracks[t].trackNode)==null?void 0:s.track;if(!n||n.mode==="disabled")return;e.forEach(a=>na(n,a))}else{const n=this.tracks[t];if(!n)return;const a=n.default?"default":"subtitles"+t;i.trigger(E.CUES_PARSED,{type:"subtitles",cues:e,track:a,subtitleTrack:n})}}onFragDecrypted(e,t){const{frag:i}=t;i.type===ge.SUBTITLE&&this.onFragLoaded(E.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){if(!this.enabled||!this.config.enableCEA708Captions)return;const{frag:i,samples:s}=t;if(!(i.type===ge.MAIN&&this.closedCaptionsForLevel(i)==="NONE"))for(let n=0;n<s.length;n++){const a=s[n].bytes;if(a){this.cea608Parser1||this.initCea608Parsers();const o=this.extractCea608Data(a);this.cea608Parser1.addData(s[n].pts,o[0]),this.cea608Parser2.addData(s[n].pts,o[1])}}}onBufferAppended(e,t){if(this.config.renderTextTracksNatively){var i;const{type:s,timeRanges:n}=t;if(s==="video"&&(i=n[s])!=null&&i.length){const{captionsTracks:a,cueCache:o}=this;Object.keys(o).forEach(l=>{var u;const h=(u=a[l])==null?void 0:u.track;if(h){const d=o[l];for(let g=0;g<d.length;g++)na(h,d[g])}delete o[l]})}}}onBufferFlushing(e,t){const{startOffset:i,endOffset:s,endOffsetSubtitles:n,type:a}=t,{media:o}=this;if(!(!o||o.currentTime<s)){if(!a||a==="video"){const{captionsTracks:l,cueCache:u}=this;Object.keys(l).forEach(h=>ra(l[h].track,i,s)),Object.keys(u).forEach(h=>{const d=u[h];for(let g=d.length;g--;){const m=d[g];m.startTime>=i&&m.endTime<=s&&d.splice(g,1)}})}this.config.renderTextTracksNatively&&i===0&&n!==void 0&&this.tracks.forEach(l=>{var u;const h=(u=l.trackNode)==null?void 0:u.track;h&&ra(h,i,n)})}}extractCea608Data(e){const t=[[],[]],i=e[0]&31;let s=2;for(let n=0;n<i;n++){const a=e[s++],o=127&e[s++],l=127&e[s++];if(o===0&&l===0)continue;if((4&a)!==0){const h=3&a;(h===0||h===1)&&(t[h].push(o),t[h].push(l))}}return t}}function vm(r,e,t,i){return Math.min(e,i)-Math.max(r,t)}function ac(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}const Em=/\s/,Tm={newCue(r,e,t,i){const s=[];let n,a,o,l,u;const h=self.VTTCue||self.TextTrackCue;for(let g=0;g<i.rows.length;g++)if(n=i.rows[g],o=!0,l=0,u="",!n.isEmpty()){var d;for(let C=0;C<n.chars.length;C++)Em.test(n.chars[C].uchar)&&o?l++:(u+=n.chars[C].uchar,o=!1);n.cueStartTime=e,e===t&&(t+=1e-4),l>=16?l--:l++;const m=Nu(u.trim()),A=Qr(e,t,m);r!=null&&(d=r.cues)!=null&&d.getCueById(A)||(a=new h(e,t,m),a.id=A,a.line=g+1,a.align="left",a.position=10+Math.min(80,Math.floor(l*8/32)*10),s.push(a))}return r&&s.length&&(s.sort((g,m)=>g.line==="auto"||m.line==="auto"?0:g.line>8&&m.line>8?m.line-g.line:g.line-m.line),s.forEach(g=>na(r,g))),s}};class oc{constructor(){this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=0,this.config=null,this.callbacks=null,this.context=null,this.stats=new Kn}destroy(){this.callbacks=this.context=this.config=null,this.abortInternal(),this.stats=null}load(e,t,i){const s=this.stats;if(s.loading.start)throw new Error("Loader can only be used once.");s.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=i,this.loadInternal()}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.getNetworkDetails())}loadtimeout(){if(!this.config)return;const e=this.config.loadPolicy.timeoutRetry,t=this.stats.retry;if(cs(e,t,!0))this.retry(e);else{var i;Ge.warn(`timeout while loading ${(i=this.context)==null?void 0:i.url}`);const s=this.callbacks;s&&(this.abortInternal(),s.onTimeout(this.stats,this.context,this.getNetworkDetails()))}}retry(e){const{context:t,stats:i}=this;this.retryDelay=Wn(e,i.retry),i.retry++,Ge.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${t?.url}, retrying ${i.retry}/${e.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.resetInternalLoader(),self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(()=>this.loadInternal(),this.retryDelay)}}function Sm(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}const xm=/(\d+)-(\d+)\/(\d+)/;class lc extends oc{constructor(e){super(),this.fetchSetup=void 0,this.request=null,this.response=null,this.controller=null,this.fetchSetup=e.fetchSetup||Dm}destroy(){this.request=null,super.destroy(),this.response=null,this.controller=null,this.fetchSetup=null}abortInternal(){self.clearTimeout(this.retryTimeout),this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())}getNetworkDetails(){return this.response}resetInternalLoader(){this.response=null}loadInternal(){const{config:e,context:t,stats:i}=this;if(!e||!t)return;i.loading.first=0,i.loaded=0,i.aborted=!1,this.controller=new self.AbortController;const s=bm(t,this.controller.signal),n=t.responseType==="arraybuffer",a=n?"byteLength":"length",{maxTimeToFirstByteMs:o,maxLoadTimeMs:l}=e.loadPolicy;this.request=this.fetchSetup(t,s),self.clearTimeout(this.requestTimeout),e.timeout=o&&se(o)?o:l,this.requestTimeout=self.setTimeout(()=>{this.loadtimeout()},e.timeout),(Rs(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then(h=>{var d;this.response=h;const g=Math.max(self.performance.now(),i.loading.start);if(self.clearTimeout(this.requestTimeout),e.timeout=l,this.requestTimeout=self.setTimeout(()=>{this.loadtimeout()},l-(g-i.loading.start)),!h.ok){const{status:A,statusText:C}=h;throw new Pm(C||"fetch, bad network response",A,h)}i.loading.first=g,i.total=Rm(h.headers)||i.total;const m=(d=this.callbacks)==null?void 0:d.onProgress;return m&&se(e.highWaterMark)?this.loadProgressively(h,i,t,e.highWaterMark,m):n?h.arrayBuffer():t.responseType==="json"?h.json():h.text()}).then(h=>{var d,g;const m=this.response;if(!m)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),i.loading.end=Math.max(self.performance.now(),i.loading.first);const A=h[a];A&&(i.loaded=i.total=A);const C={url:m.url,data:h,code:m.status},v=(d=this.callbacks)==null?void 0:d.onProgress;v&&!se(e.highWaterMark)&&v(i,t,h,m),(g=this.callbacks)==null||g.onSuccess(C,i,t,m)}).catch(h=>{if(self.clearTimeout(this.requestTimeout),i.aborted)return;const d=h&&h.code||0,g=h?h.message:null,m=e.loadPolicy.errorRetry,A=i.retry,C={url:t.url,data:void 0,code:d};if(cs(m,A,!1,C))this.retry(m);else{var v;Ge.error(`${d} while loading ${t.url}`),(v=this.callbacks)==null||v.onError({code:d,text:g},t,h?h.details:null,i)}})}getCacheAge(){let e=null;if(this.response){const t=this.response.headers.get("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,t,i,s=0,n){const a=new xl,o=e.body.getReader(),l=()=>o.read().then(u=>{if(u.done)return a.dataLength&&n(t,i,a.flush().buffer,e),Promise.resolve(new ArrayBuffer(0));const h=u.value,d=h.length;return t.loaded+=d,d<s||a.dataLength?(a.push(h),a.dataLength>=s&&n(t,i,a.flush().buffer,e)):n(t,i,h.buffer,e),l()}).catch(()=>Promise.reject());return l()}}function bm(r,e){const t={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(je({},r.headers))};return r.rangeEnd&&t.headers.set("Range","bytes="+r.rangeStart+"-"+String(r.rangeEnd-1)),t}function Lm(r){const e=xm.exec(r);if(e)return parseInt(e[2])-parseInt(e[1])+1}function Rm(r){const e=r.get("Content-Range");if(e){const i=Lm(e);if(se(i))return i}const t=r.get("Content-Length");if(t)return parseInt(t)}function Dm(r,e){return new self.Request(r.url,e)}class Pm extends Error{constructor(e,t,i){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=i}}const _m=(r,e,t)=>Math.max(e,Math.min(r,t)),km=/^age:\s*[\d.]+\s*$/im;class uc extends oc{constructor(e){super(),this.xhrSetup=void 0,this.loader=null,this.xhrSetup=e.xhrSetup||null}destroy(){super.destroy(),this.loader=null,this.xhrSetup=null}abortInternal(){const e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,e.readyState!==4&&(this.stats.aborted=!0,e.abort()))}getNetworkDetails(){return this.loader}resetInternalLoader(){this.loader=null}loadInternal(){const{config:e,context:t}=this;if(!e||!t)return;const i=this.loader=new self.XMLHttpRequest,s=this.stats;s.loading.first=0,s.loaded=0,s.aborted=!1;const n=this.xhrSetup;n?Promise.resolve().then(()=>{if(!(this.loader!==i||this.stats.aborted))return n.call(this,i,t.url,t)}).catch(a=>{if(!(this.loader!==i||this.stats.aborted))return i.open("GET",t.url,!0),n.call(this,i,t.url,t)}).then(()=>{this.loader!==i||this.stats.aborted||this.openAndSendXhr(i,t,e)}).catch(a=>{var o;(o=this.callbacks)==null||o.onError({code:i.status,text:a.message},t,i,s)}):this.openAndSendXhr(i,t,e)}openAndSendXhr(e,t,i){e.readyState||e.open("GET",t.url,!0);const s=t.headers,{maxTimeToFirstByteMs:n,maxLoadTimeMs:a}=i.loadPolicy;if(s)for(const o in s)e.setRequestHeader(o,s[o]);t.rangeEnd&&e.setRequestHeader("Range",`bytes=${t.rangeStart}-${t.rangeEnd-1}`),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),i.timeout=n&&se(n)?n:a,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.timeout),e.send()}readystatechange(){const{context:e,loader:t,stats:i}=this;if(!e||!t)return;const s=t.readyState,n=this.config;if(!i.aborted&&s>=2&&(i.loading.first===0&&(i.loading.first=Math.max(self.performance.now(),i.loading.start),n.timeout!==n.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),n.timeout=n.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),n.loadPolicy.maxLoadTimeMs-(i.loading.first-i.loading.start)))),s===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;const u=t.status,h=t.responseType==="text"?t.responseText:null;if(u>=200&&u<300){const A=h??t.response;if(A!=null){var a,o;i.loading.end=Math.max(self.performance.now(),i.loading.first);const C=t.responseType==="arraybuffer"?A.byteLength:A.length;i.loaded=i.total=C,i.bwEstimate=i.total*8e3/(i.loading.end-i.loading.first);const v=(a=this.callbacks)==null?void 0:a.onProgress;v&&v(i,e,A,t);const S={url:t.responseURL,data:A,code:u};e.rangeEnd&&C!==e.rangeEnd-e.rangeStart&&Ge.warn(`Payload length ${C} does not match requested Range: bytes=${e.rangeStart}-${e.rangeEnd-1}`),(o=this.callbacks)==null||o.onSuccess(S,i,e,t);return}}const d=n.loadPolicy.errorRetry,g=i.retry,m={url:e.url,data:void 0,code:u};if(cs(d,g,!1,m))this.retry(d);else{var l;Ge.error(`${u} while loading ${e.url}`),(l=this.callbacks)==null||l.onError({code:u,text:t.statusText},e,t,i)}}}loadprogress(e){const t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}getCacheAge(){let e=null;if(this.loader&&km.test(this.loader.getAllResponseHeaders())){const t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}}const wm={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},Mm=Ae(Ae({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,maxDevicePixelRatio:Number.POSITIVE_INFINITY,preferManagedMediaSource:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,loopBackBufferFlush:void 0,startOnSegmentBoundary:!1,nextAudioTrackBufferFlushForwardOffset:.25,maxBufferSize:60*1e3*1e3,maxFragLookUpTolerance:.25,maxBufferHole:.1,detectStallWithCurrentTimeMs:1250,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,nudgeOnVideoHole:!0,skipBufferHolePadding:.1,liveSyncMode:"edge",liveSyncDurationCount:3,liveSyncOnStallIncrease:1,liveMaxLatencyDurationCount:1/0,liveMaxUnchangedPlaylistRefresh:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,appendTimeout:1/0,ignorePlaylistParsingErrors:!1,loader:uc,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,handleMpegTsVideoIntegrityErrors:"process",abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,abrSwitchInterval:0,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:tl,requireKeySystemAccessOnStart:!1,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableEmsgKLVMetadata:!1,enableID3MetadataCues:!0,emsgKLVSchemaUri:void 0,enableInterstitialPlayback:!0,interstitialAppendInPlace:!0,interstitialLiveLookAhead:10,iframeCacheLimit:2*1024*1024,useMediaCapabilities:!0,preserveManualLevelOnError:!1,errorPenaltyExpireMs:0,certLoadPolicy:{default:wm},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},interstitialAssetListLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:3e4,timeoutRetry:{maxNumRetry:0,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:0,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,streamController:Xu,abrController:Cd,bufferController:lg,capLevelController:Fr,errorController:Td,fpsController:Ep,id3TrackController:Hp,gapController:$p,latencyController:rm},Om()),{},{subtitleStreamController:am,subtitleTrackController:Bp,timelineController:ym,audioStreamController:ig,audioTrackController:sg,emeController:Ji,cmcdController:pp,contentSteeringController:Ap,iframeController:zp,interstitialsController:nm});function Om(){return{cueHandler:Tm,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 Fm(r,e,t){if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(e.liveMaxLatencyDurationCount!==void 0&&(e.liveSyncDurationCount===void 0||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(e.liveMaxLatencyDuration!==void 0&&(e.liveSyncDuration===void 0||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');if(e.liveMaxUnchangedPlaylistRefresh!==void 0){const a=e.liveMaxUnchangedPlaylistRefresh,o=_m(a,2,1/0);o!==a&&t.warn(`hls.js config: "liveMaxUnchangedPlaylistRefresh" clamped from ${a} to ${o}.`),e.liveMaxUnchangedPlaylistRefresh=o}const i=fa(r),s=["manifest","level","frag"],n=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return s.forEach(a=>{const o=`${a==="level"?"playlist":a}LoadPolicy`,l=e[o]===void 0,u=[];n.forEach(h=>{const d=`${a}Loading${h}`,g=e[d];if(g!==void 0&&l){u.push(d);const m=i[o].default;switch(e[o]={default:m},h){case"TimeOut":m.maxLoadTimeMs=g,m.maxTimeToFirstByteMs=g;break;case"MaxRetry":m.errorRetry.maxNumRetry=g,m.timeoutRetry.maxNumRetry=g;break;case"RetryDelay":m.errorRetry.retryDelayMs=g,m.timeoutRetry.retryDelayMs=g;break;case"MaxRetryTimeout":m.errorRetry.maxRetryDelayMs=g,m.timeoutRetry.maxRetryDelayMs=g;break}}}),u.length&&t.warn(`hls.js config: "${u.join('", "')}" setting(s) are deprecated, use "${o}": ${Xe(e[o])}`)}),Ae(Ae({},i),e)}function fa(r){return r&&typeof r=="object"?Array.isArray(r)?r.map(fa):Object.keys(r).reduce((e,t)=>(e[t]=fa(r[t]),e),{}):r}function Nm(r,e){const t=r.loader;t!==lc&&t!==uc?(e.log("[config]: Custom loader detected, cannot enable progressive streaming"),r.progressive=!1):Sm()&&(r.loader=lc,r.progressive=!0,r.enableSoftwareAES=!0,e.log("[config]: Progressive streaming enabled, using FetchLoader"))}class Bm extends wr{constructor(e,t){super(e,"level-controller"),this._levels=[],this._firstLevel=-1,this._maxAutoLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.lastABRSwitchTime=-1,this._iframeVariants=[],this.onParsedComplete=void 0,this.steering=t,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(E.LEVEL_LOADED,this.onLevelLoaded,this),e.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(E.FRAG_BUFFERED,this.onFragBuffered,this),e.on(E.ERROR,this.onError,this)}_unregisterListeners(){const{hls:e}=this;e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(E.LEVEL_LOADED,this.onLevelLoaded,this),e.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this),e.off(E.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}stopLoad(){this._levels.forEach(t=>{t.loadError=0,t.fragmentError=0}),super.stopLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1,this._iframeVariants=[]}onManifestLoading(e,t){this.resetLevels()}onManifestLoaded(e,t){const i=this.hls.config.preferManagedMediaSource,s=[],n={},a={};let o=!1,l=!1,u=!1,h=!1;t.levels.forEach(d=>{const g=d.attrs,m=dc(d,i),{audioCodec:A,videoCodec:C,imageCodec:v,width:S,height:R}=d;if(!m){this.log(`Some or all CODECS not supported "${g.CODECS}"`);return}o||(o=!!(S&&R)),l||(l=!!C),u||(u=!!A),h||(h=!!v);const{CODECS:b,"FRAME-RATE":D,"HDCP-LEVEL":_,"PATHWAY-ID":M,RESOLUTION:p,"VIDEO-RANGE":$}=g,O=`${`${M||"."}-`}${d.bitrate}-${p}-${D}-${b}-${$}-${_}`;if(n[O])if(n[O].uri!==d.url&&!d.attrs["PATHWAY-ID"]){const W=a[O]+=1;d.attrs["PATHWAY-ID"]=new Array(W+1).join(".");const q=this.createLevel(d);n[O]=q,s.push(q)}else d.iframes||(n[O].addGroupId("audio",g.AUDIO),n[O].addGroupId("text",g.SUBTITLES));else{const W=this.createLevel(d);n[O]=W,a[O]=1,s.push(W)}}),this.filterAndSortMediaOptions(s,t,o,l,u,h)}createLevel(e){const t=new Is(e),i=e.supplemental;if(i!=null&&i.videoCodec&&!hc(i.videoCodec,this.hls.config.preferManagedMediaSource)){const s=new Error(`SUPPLEMENTAL-CODECS not supported "${i.videoCodec}"`);this.log(s.message),t.supportedResult=Eo(s,[])}return t}filterAndSortMediaOptions(e,t,i,s,n,a){var o;let l=[],u=[],h=e;const d=((o=t.stats)==null?void 0:o.parsing)||{},g=this.hls.config.preferManagedMediaSource;if((i||s)&&n&&(h=h.filter(({videoCodec:_,videoRange:M,width:p,height:$})=>(!!_||!!(p&&$))&&cd(M))),s&&a&&(h=h.filter(_=>!_.imageCodec)),h.length===0){Promise.resolve().then(()=>{if(this.hls){let _="no level with compatible codecs found in manifest",M=_;t.levels.length&&(M=`one or more CODECS in variant not supported: ${Xe(t.levels.map($=>$.attrs.CODECS).filter(($,N,O)=>O.indexOf($)===N))}`,this.warn(M),_+=` (${M})`);const p=new Error(_);this.hls.trigger(E.ERROR,{type:me.MEDIA_ERROR,details:U.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:p,reason:M})}}),d.end=performance.now();return}t.audioTracks&&(l=t.audioTracks.filter(_=>!_.audioCodec||cc(_.audioCodec,g)),fc(l)),t.subtitles&&(u=t.subtitles,fc(u));const m=h.slice(0);h.sort((_,M)=>{if(_.attrs["HDCP-LEVEL"]!==M.attrs["HDCP-LEVEL"])return(_.attrs["HDCP-LEVEL"]||"")>(M.attrs["HDCP-LEVEL"]||"")?1:-1;if(i&&_.height!==M.height)return _.height-M.height;if(_.frameRate!==M.frameRate)return _.frameRate-M.frameRate;if(_.videoRange!==M.videoRange)return en.indexOf(_.videoRange)-en.indexOf(M.videoRange);if(_.videoCodec!==M.videoCodec){const p=Io(_.videoCodec),$=Io(M.videoCodec);if(p!==$)return $-p}if(_.uri===M.uri&&_.codecSet!==M.codecSet){const p=Zs(_.codecSet),$=Zs(M.codecSet);if(p!==$)return $-p}return _.averageBitrate!==M.averageBitrate?_.averageBitrate-M.averageBitrate:0});let A=m[0];if(this.steering&&(h=this.steering.filterParsedLevels(h),h.length!==m.length)){for(let _=0;_<m.length;_++)if(m[_].pathwayId===h[0].pathwayId){A=m[_];break}}this._levels=h;for(let _=0;_<h.length;_++)if(h[_]===A){var C;this._firstLevel=_;const M=A.bitrate,p=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${h.length} level(s) found, first bitrate: ${M}`),((C=this.hls.userConfig)==null?void 0:C.abrEwmaDefaultEstimate)===void 0){const $=Math.min(M,this.hls.config.abrEwmaDefaultEstimateMax);$>p&&p===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=$)}break}const v=t.iframeVariants.filter(_=>dc(_,g));this._iframeVariants=v;const S=n&&!s,R=this.hls.config,b=!!(R.audioStreamController&&R.audioTrackController),D={levels:h,audioTracks:l,subtitleTracks:u,iframeVariants:v,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:n,video:s,altAudio:b&&!S&&l.some(_=>!!_.url)};d.end=performance.now(),this.hls.trigger(E.MANIFEST_PARSED,D)}get iframeVariants(){return this._iframeVariants.length===0?null:this._iframeVariants}get levels(){return this._levels.length===0?null:this._levels}get loadLevelObj(){return this.currentLevel}get level(){return this.currentLevelIndex}set level(e){const t=this._levels;if(t.length===0)return;if(e<0||e>=t.length){const h=new Error("invalid level idx"),d=e<0;if(this.hls.trigger(E.ERROR,{type:me.OTHER_ERROR,details:U.LEVEL_SWITCH_ERROR,level:e,fatal:d,error:h,reason:h.message}),d)return;e=Math.min(e,t.length-1)}const i=this.currentLevelIndex,s=this.currentLevel,n=s?s.attrs["PATHWAY-ID"]:void 0,a=t[e],o=a.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=a,i===e&&s&&n===o)return;this.log(`Switching to level ${e} (${a.height?a.height+"p ":""}${a.videoRange?a.videoRange+" ":""}${a.codecSet?a.codecSet+" ":""}@${a.bitrate})${o?" with Pathway "+o:""} from level ${i}${n?" with Pathway "+n:""}`);const l={level:e,attrs:a.attrs,details:a.details,bitrate:a.bitrate,averageBitrate:a.averageBitrate,maxBitrate:a.maxBitrate,realBitrate:a.realBitrate,width:a.width,height:a.height,codecSet:a.codecSet,audioCodec:a.audioCodec,videoCodec:a.videoCodec,audioGroups:a.audioGroups,subtitleGroups:a.subtitleGroups,loaded:a.loaded,loadError:a.loadError,fragmentError:a.fragmentError,name:a.name,id:a.id,uri:a.uri,url:a.url,urlId:0,audioGroupIds:a.audioGroupIds,textGroupIds:a.textGroupIds};this.hls.trigger(E.LEVEL_SWITCHING,l);const u=a.details;if(!u||u.live){const h=this.switchParams(a.uri,s?.details,u);this.loadPlaylist(h)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(e){this.manualLevelIndex=e,this._startLevel===void 0&&(this._startLevel=e),e!==-1&&(this.level=e)}get firstLevel(){return this._firstLevel}set firstLevel(e){this._firstLevel=e}get startLevel(){if(this._startLevel===void 0){const e=this.hls.config.startLevel;return e!==void 0?e:this.hls.firstAutoLevel}return this._startLevel}set startLevel(e){this._startLevel=e}get pathways(){return this.steering?this.steering.pathways():[]}get pathwayPriority(){return this.steering?this.steering.pathwayPriority:null}set pathwayPriority(e){if(this.steering){const t=this.steering.pathways(),i=e.filter(s=>t.indexOf(s)!==-1);if(e.length<1){this.warn(`pathwayPriority ${e} should contain at least one pathway from list: ${t}`);return}this.steering.pathwayPriority=i}}onError(e,t){t.fatal||!t.context||t.context.type===ke.LEVEL&&t.context.level===this.level&&this.checkRetry(t)}onFragBuffered(e,{frag:t}){if(t.type===ge.MAIN){const i=t.elementaryStreams;if(!Object.keys(i).some(n=>!!i[n]))return;const s=this._levels[t.level];s!=null&&s.loadError&&(this.log(`Resetting level error count of ${s.loadError} on frag buffered`),s.loadError=0)}}onLevelLoaded(e,t){var i;const{level:s,details:n}=t,a=t.levelInfo;if(!a){var o;this.warn(`Invalid level index ${s}`),(o=t.deliveryDirectives)!=null&&o.skip&&(n.deltaUpdateFailed=!0);return}if(a===this.currentLevel||t.withoutMultiVariant){a.fragmentError===0&&(a.loadError=0);let l=a.details;l===t.details&&l.advanced&&(l=void 0),this.playlistLoaded(s,t,l)}else(i=t.deliveryDirectives)!=null&&i.skip&&(n.deltaUpdateFailed=!0)}loadPlaylist(e){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentLevel)&&this.scheduleLoading(this.currentLevel,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);const i=this.getUrlWithDirectives(e.uri,t),s=this.currentLevelIndex,n=e.attrs["PATHWAY-ID"],a=e.details,o=a?.age;this.log(`Loading level index ${s}${t?.msn!==void 0?" at sn "+t.msn+" part "+t.part:""}${n?" Pathway "+n:""}${o&&a.live?" age "+o.toFixed(1)+(a.type&&" "+a.type||""):""} ${i}`),this.hls.trigger(E.LEVEL_LOADING,{url:i,level:s,levelInfo:e,pathwayId:e.attrs["PATHWAY-ID"],id:0,deliveryDirectives:t||null})}get nextLoadLevel(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){const t=this.currentLevelIndex;if(this.manualLevelIndex===-1&&e!==t&&e!==-1){const s=this.hls.config.abrSwitchInterval;if(s>0){const n=performance.now(),a=n-this.lastABRSwitchTime,o=s*1e3;if(this.lastABRSwitchTime>-1&&a<o){this.warn(`Preventing ABR level switch: ${t} -> ${e} (${Math.round(a)}ms < ${o}ms / ${s}s)`);return}this.lastABRSwitchTime=n,this.log(`Allowing ABR level switch: ${t} -> ${e} (${Math.round(a)}ms >= ${o}ms / ${s}s)`)}}this.level=e,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=e)}removeLevel(e){var t;if(this._levels.length===1)return;const i=this._levels.filter((n,a)=>a!==e?!0:(this.steering&&this.steering.removeLevel(n),n===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,n.details&&n.details.fragments.forEach(o=>o.level=-1)),!1));yl(i),this._levels=i,this.currentLevelIndex>-1&&(t=this.currentLevel)!=null&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.manualLevelIndex>-1&&(this.manualLevelIndex=this.currentLevelIndex);const s=i.length-1;this._firstLevel=Math.min(this._firstLevel,s),this._startLevel&&(this._startLevel=Math.min(this._startLevel,s)),this.hls.trigger(E.LEVELS_UPDATED,{levels:i})}onLevelsUpdated(e,{levels:t}){this._levels=t}checkMaxAutoUpdated(){const{autoLevelCapping:e,maxAutoLevel:t,maxHdcpLevel:i}=this.hls;this._maxAutoLevel!==t&&(this._maxAutoLevel=t,this.hls.trigger(E.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:i}))}}function cc(r,e){return ms(r,"audio",e)}function hc(r,e){return ms(r,"video",e)}function dc(r,e){let{audioCodec:t,videoCodec:i}=r;t&&(r.audioCodec=t=Qs(t,e)||void 0),i&&(i=r.videoCodec=td(i));const{unknownCodecs:s}=r;return!(s?.length||0||t&&!cc(t,e)||i&&!hc(i,e))}function fc(r){const e={};r.forEach(t=>{const i=t.groupId||"";t.id=e[i]=e[i]||0,e[i]++})}class Um extends wt{constructor(e,t){super("key-loader",t),this.config=void 0,this.keyLoaderInfo={},this.emeController=null,this.config=e}abort(e){for(const i in this.keyLoaderInfo){const s=this.keyLoaderInfo[i].loader;if(s){var t;if(e&&e!==((t=s.context)==null?void 0:t.frag.type))return;s.abort()}}}destroy(){for(const e in this.keyLoaderInfo){const t=this.keyLoaderInfo[e].loader;t&&t.destroy()}this.emeController=null,this.keyLoaderInfo={}}loadClear(e,t,i){return this.emeController?this.emeController.loadClear(e,t,i):null}load(e,t){return!e.decryptdata&&e.encrypted&&this.emeController&&this.config.emeEnabled?this.emeController.selectKeySystemFormat(e).then(i=>this.loadInternal(e,t,i)):this.loadInternal(e,t)}loadInternal(e,t,i){i&&e.setKeyFormat(i);const s=e.decryptdata;if(!s){const a=new Error(i?`Expected frag.decryptdata to be defined after setting format ${i}`:`Missing decryption data on fragment in onKeyLoading (emeEnabled with controller: ${this.emeController&&this.config.emeEnabled})`);return Promise.reject(Li(e,U.KEY_LOAD_ERROR,a))}const n=e;switch(s.method){case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return s.keyFormat==="identity"?this.loadKeyHTTP(n):t?t.then(()=>this.loadKeyEME(n)):this.loadKeyEME(n);case"AES-128":case"AES-256":case"AES-256-CTR":return this.loadKeyHTTP(n);default:return Promise.reject(Li(e,U.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${s.method}"`)))}}loadKeyEME(e){if(this.emeController&&this.config.emeEnabled){var t;if(!e.decryptdata.keyId&&(t=e.initSegment)!=null&&t.data){const i=Oh(e.initSegment.data);if(i.length){let s=i[0];const n=e.decryptdata.uri;if(s.some(a=>a!==0))this.log(`Using keyId found in init segment ${ut(s)} keyUri: ${n}`),gi.setKeyIdForUri(n,s);else{const a=gi.addKeyIdForUri(n);this.log(`Patching empty keyId with ${ut(a)} keyUri: ${n}`),s=a}e.decryptdata.keyId=s}}return this.emeController.loadKey(e).then(()=>({frag:e,keyInfo:{decryptdata:e.decryptdata}}))}return Promise.reject(Li(e,U.KEY_LOAD_ERROR,new Error(`emeEnabled with controller: ${this.emeController&&this.config.emeEnabled})`)))}loadKeyHTTP(e){const t=e.decryptdata,i=t.uri;if(!i)return Promise.reject(Li(e,U.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${i}"`)));const s=this.keyLoaderInfo[i];if(s){if(s.decryptdata.key)return t.key=s.decryptdata.key,s.keyLoadPromise=null,Promise.resolve({frag:e,keyInfo:s});if(s.keyLoadPromise)return s.keyLoadPromise.then(u=>(t.key=s.decryptdata.key,Ae(Ae({},u),{},{frag:e})))}this.log(`Loading${t.keyId?" keyId: "+ut(t.keyId):""} URI: ${t.uri} from ${e.type} ${e.level}`);const n=this.config,a=n.loader,o=new a(n);e.keyLoader=o;const l=this.keyLoaderInfo[i]={decryptdata:t,keyLoadPromise:null,loader:o};return l.keyLoadPromise=new Promise((u,h)=>{const d={type:ke.KEY,keyInfo:l,frag:e,responseType:"arraybuffer",url:i},g=n.keyLoadPolicy.default,m={loadPolicy:g,timeout:g.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},A={onSuccess:(C,v,S,R)=>{const{frag:b,keyInfo:D,url:_}=S;if(!b.decryptdata||D!==this.keyLoaderInfo[_])return h(Li(b,U.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),R));D.decryptdata.key=b.decryptdata.key=new Uint8Array(C.data),b.keyLoader=D.loader=D.keyLoadPromise=null,u({frag:b,keyInfo:D})},onError:(C,v,S,R)=>{this.resetLoader(v),h(Li(e,U.KEY_LOAD_ERROR,new Error(`HTTP Error ${C.code} loading key ${C.text}`),S,Ae({url:i,data:void 0},C)))},onTimeout:(C,v,S)=>{this.resetLoader(v),h(Li(e,U.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),S))},onAbort:(C,v,S)=>{this.resetLoader(v),h(Li(e,U.INTERNAL_ABORTED,new Error("key loading aborted"),S))}};o.load(d,m,A)})}resetLoader(e){const{frag:t,keyInfo:i,url:s}=e,n=i.loader;t.keyLoader===n&&(t.keyLoader=i.loader=i.keyLoadPromise=null),delete this.keyLoaderInfo[s],n&&n.destroy()}}function Li(r,e=U.KEY_LOAD_ERROR,t,i,s){return new si({type:me.NETWORK_ERROR,details:e,fatal:!1,frag:r,response:s,error:t,networkDetails:i||null})}function gc(r){const{type:e}=r;switch(e){case ke.AUDIO_TRACK:return ge.AUDIO;case ke.SUBTITLE_TRACK:return ge.SUBTITLE;default:return ge.MAIN}}function ga(r,e){let t=r.url;return(t===void 0||t.indexOf("data:")===0)&&(t=e.url),t}class $m{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){const{hls:e}=this;e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.LEVEL_LOADING,this.onLevelLoading,this),e.on(E.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(E.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this)}unregisterListeners(){const{hls:e}=this;e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.LEVEL_LOADING,this.onLevelLoading,this),e.off(E.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(E.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this)}createInternalLoader(e){const t=this.hls.config,i=t.pLoader,s=t.loader,n=i||s,a=new n(t);return this.loaders[e.type]=a,a}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e]}destroyInternalLoaders(){for(const e in this.loaders){const t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(e,t){const{url:i}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:ke.MANIFEST,url:i,deliveryDirectives:null,levelOrTrack:null})}onLevelLoading(e,t){const{id:i,level:s,pathwayId:n,url:a,deliveryDirectives:o,levelInfo:l}=t;this.load({id:i,level:s,pathwayId:n,responseType:"text",type:ke.LEVEL,url:a,deliveryDirectives:o,levelOrTrack:l})}onAudioTrackLoading(e,t){const{id:i,groupId:s,url:n,deliveryDirectives:a,track:o}=t;this.load({id:i,groupId:s,level:null,responseType:"text",type:ke.AUDIO_TRACK,url:n,deliveryDirectives:a,levelOrTrack:o})}onSubtitleTrackLoading(e,t){const{id:i,groupId:s,url:n,deliveryDirectives:a,track:o}=t;this.load({id:i,groupId:s,level:null,responseType:"text",type:ke.SUBTITLE_TRACK,url:n,deliveryDirectives:a,levelOrTrack:o})}onLevelsUpdated(e,t){const i=this.loaders[ke.LEVEL];if(i){const s=i.context;s&&!t.levels.some(n=>n===s.levelOrTrack)&&(i.abort(),delete this.loaders[ke.LEVEL])}}load(e){var t;const i=this.hls.config;let s=this.getInternalLoader(e);if(s){const u=this.hls.logger,h=s.context;if(h?.levelOrTrack===e.levelOrTrack&&(h.url===e.url||h.deliveryDirectives&&!e.deliveryDirectives)){h.url===e.url?u.log(`[playlist-loader]: ignore ${e.url} ongoing request`):u.log(`[playlist-loader]: ignore ${e.url} in favor of ${h.url}`);return}u.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),s.abort()}let n;if(e.type===ke.MANIFEST?n=i.manifestLoadPolicy.default:n=je({},i.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(e),se((t=e.deliveryDirectives)==null?void 0:t.part)){let u;if(e.type===ke.LEVEL&&e.level!==null?u=this.hls.levels[e.level].details:e.type===ke.AUDIO_TRACK&&e.id!==null?u=this.hls.audioTracks[e.id].details:e.type===ke.SUBTITLE_TRACK&&e.id!==null&&(u=this.hls.subtitleTracks[e.id].details),u){const h=u.partTarget,d=u.targetduration;if(h&&d){const g=Math.max(h*3,d*.8)*1e3;n=je({},n,{maxTimeToFirstByteMs:Math.min(g,n.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(g,n.maxTimeToFirstByteMs)})}}}const a=n.errorRetry||n.timeoutRetry||{},o={loadPolicy:n,timeout:n.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},l={onSuccess:(u,h,d,g)=>{const m=this.getInternalLoader(d);this.resetInternalLoader(d.type);const A=u.data;h.parsing.start=performance.now(),ni.isMediaPlaylist(A)||d.type!==ke.MANIFEST?this.handleTrackOrLevelPlaylist(u,h,d,g||null,m):this.handleMasterPlaylist(u,h,d,g)},onError:(u,h,d,g)=>{this.handleNetworkError(h,d,!1,u,g)},onTimeout:(u,h,d)=>{this.handleNetworkError(h,d,!0,void 0,u)}};s.load(e,o,l)}checkAutostartLoad(){if(!this.hls)return;const{config:{autoStartLoad:e,startPosition:t},forceStartLoad:i}=this.hls;(e||i)&&(this.hls.logger.log(`${e?"auto":"force"} startLoad with configured startPosition ${t}`),this.hls.startLoad(t))}handleMasterPlaylist(e,t,i,s){const n=this.hls,a=e.data,o=ga(e,i),l=ni.parseMasterPlaylist(a,o);if(l.playlistParsingError){t.parsing.end=performance.now(),this.handleManifestParsingError(e,i,l.playlistParsingError,s,t);return}const{contentSteering:u,levels:h,iframeVariants:d,sessionData:g,sessionKeys:m,startTimeOffset:A,variableList:C}=l;this.variableList=C,h.forEach(b=>{const{unknownCodecs:D}=b;if(D){const{preferManagedMediaSource:_}=this.hls.config;let{audioCodec:M,videoCodec:p}=b;for(let $=D.length;$--;){const N=D[$];ms(N,"audio",_)?(b.audioCodec=M=M?`${M},${N}`:N,Wi.audio[M.substring(0,4)]=2,D.splice($,1)):ms(N,"video",_)&&(b.videoCodec=p=p?`${p},${N}`:N,Wi.video[p.substring(0,4)]=2,D.splice($,1))}}});const{AUDIO:v=[],SUBTITLES:S,"CLOSED-CAPTIONS":R}=ni.parseMasterPlaylistMedia(a,o,l);v.length&&!v.some(D=>!D.url)&&h[0].audioCodec&&!h[0].attrs.AUDIO&&(this.hls.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),v.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new tt({}),bitrate:0,url:""})),n.trigger(E.MANIFEST_LOADED,{levels:h,audioTracks:v,subtitles:S,iframeVariants:d,captions:R,contentSteering:u,url:o,stats:t,networkDetails:s,sessionData:g,sessionKeys:m,startTimeOffset:A,variableList:C})}handleTrackOrLevelPlaylist(e,t,i,s,n){const a=this.hls,{id:o,level:l,type:u}=i,h=ga(e,i),d=se(l)?l:se(o)?o:0,g=gc(i),m=ni.parseLevelPlaylist(e.data,h,d,g,0,this.variableList);if(u===ke.MANIFEST){const A={attrs:new tt({}),bitrate:0,details:m,name:"",url:h};m.requestScheduled=t.loading.start+ml(m,0),a.trigger(E.MANIFEST_LOADED,{levels:[A],audioTracks:[],iframeVariants:[],url:h,stats:t,networkDetails:s,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),i.levelDetails=m,this.handlePlaylistLoaded(m,e,t,i,s,n)}handleManifestParsingError(e,t,i,s,n){this.hls.trigger(E.ERROR,{type:me.NETWORK_ERROR,details:U.MANIFEST_PARSING_ERROR,fatal:t.type===ke.MANIFEST,url:e.url,err:i,error:i,reason:i.message,response:e,context:t,networkDetails:s,stats:n})}handleNetworkError(e,t,i=!1,s,n){let a=`A network ${i?"timeout":"error"+(s?" (status "+s.code+")":"")} occurred while loading ${e.type}`;e.type===ke.LEVEL?a+=`: ${e.level} id: ${e.id}`:(e.type===ke.AUDIO_TRACK||e.type===ke.SUBTITLE_TRACK)&&(a+=` id: ${e.id} group-id: "${e.groupId}"`);const o=new Error(a);this.hls.logger.warn(`[playlist-loader]: ${a}`);let l=U.UNKNOWN,u=!1;const h=this.getInternalLoader(e);switch(e.type){case ke.MANIFEST:l=i?U.MANIFEST_LOAD_TIMEOUT:U.MANIFEST_LOAD_ERROR,u=!0;break;case ke.LEVEL:l=i?U.LEVEL_LOAD_TIMEOUT:U.LEVEL_LOAD_ERROR,u=!1;break;case ke.AUDIO_TRACK:l=i?U.AUDIO_TRACK_LOAD_TIMEOUT:U.AUDIO_TRACK_LOAD_ERROR,u=!1;break;case ke.SUBTITLE_TRACK:l=i?U.SUBTITLE_TRACK_LOAD_TIMEOUT:U.SUBTITLE_LOAD_ERROR,u=!1;break}h&&this.resetInternalLoader(e.type);const d={type:me.NETWORK_ERROR,details:l,fatal:u,url:e.url,loader:h,context:e,error:o,networkDetails:t,stats:n};if(s){let g=e.url;t&&"url"in t&&(g=t.url),d.response=Ae({url:g,data:void 0},s)}this.hls.trigger(E.ERROR,d)}handlePlaylistLoaded(e,t,i,s,n,a){const o=this.hls,{type:l,level:u,levelOrTrack:h,id:d,groupId:g,deliveryDirectives:m}=s,A=ga(t,s),C=gc(s);let v=typeof s.level=="number"&&C===ge.MAIN?u:void 0;h&&"iframes"in h&&h.iframes&&!e.iframesOnly&&(e.playlistParsingError=new Error("EXT-X-I-FRAME-STREAM-INF media playlist MUST contain an EXT-X-I-FRAMES-ONLY tag"),e.iframesOnly=!0);const S=e.playlistParsingError;if(S){if(this.hls.logger.warn(`${S} ${e.url}`),!o.config.ignorePlaylistParsingErrors){o.trigger(E.ERROR,{type:me.NETWORK_ERROR,details:U.LEVEL_PARSING_ERROR,fatal:!1,url:A,error:S,reason:S.message,response:t,context:s,level:v,parent:C,networkDetails:n,stats:i});return}e.playlistParsingError=null}if(!e.fragments.length){const R=e.playlistParsingError=new Error("No Segments found in Playlist");o.trigger(E.ERROR,{type:me.NETWORK_ERROR,details:U.LEVEL_EMPTY_ERROR,fatal:!1,url:A,error:R,reason:R.message,response:t,context:s,level:v,parent:C,networkDetails:n,stats:i});return}switch(e.live&&a&&(a.getCacheAge&&(e.ageHeader=a.getCacheAge()||0),(!a.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),l){case ke.MANIFEST:case ke.LEVEL:if(v){if(!h)v=0;else if(h!==o.levels[v]){const R=o.levels.indexOf(h);R>-1&&(v=R)}}o.trigger(E.LEVEL_LOADED,{details:e,levelInfo:h||o.levels[0],level:v||0,id:d||0,stats:i,networkDetails:n,deliveryDirectives:m,withoutMultiVariant:l===ke.MANIFEST,context:s});break;case ke.AUDIO_TRACK:o.trigger(E.AUDIO_TRACK_LOADED,{details:e,track:h,id:d||0,groupId:g||"",stats:i,networkDetails:n,deliveryDirectives:m,context:s});break;case ke.SUBTITLE_TRACK:o.trigger(E.SUBTITLE_TRACK_LOADED,{details:e,track:h,id:d||0,groupId:g||"",stats:i,networkDetails:n,deliveryDirectives:m,context:s});break}}}class Tt{static get version(){return Ts}static isMSESupported(){return zu()}static isSupported(){return Vp()}static getMediaSource(){return Ei()}static get Events(){return E}static get MetadataSchema(){return Et}static get ErrorTypes(){return me}static get ErrorDetails(){return U}static get DefaultConfig(){return Tt.defaultConfig?Tt.defaultConfig:Mm}static set DefaultConfig(e){Tt.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.logger=void 0,this._url=null,this.streamController=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new Sr,this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.audioStreamController=void 0,this.subtititleStreamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.interstitialsController=void 0,this.iframeController=void 0,this.gapController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this._sessionId=void 0,this.triggeringException=void 0,this.started=!1;const t=this.logger=lh(e.debug||!1,"Hls instance",e.loggerId||e.assetPlayerId),i=this.config=Fm(Tt.DefaultConfig,e,t);this.userConfig=e,i.progressive&&Nm(i,t);const{streamController:s,abrController:n,bufferController:a,capLevelController:o,errorController:l,fpsController:u,id3TrackController:h,iframeController:d,gapController:g}=i,m=new l(this),A=this.abrController=new n(this),C=new Sd(this),v=i.interstitialsController,S=v?this.interstitialsController=new v(this,Tt):null,R=a?this.bufferController=new a(this,C):null,b=o?this.capLevelController=new o(this):null,D=u?new u(this):null,_=i.cmcdController,M=_?this.cmcdController=new _(this):null,p=new $m(this),$=i.contentSteeringController,N=$?new $(this):null,O=this.levelController=new Bm(this,N),W=h?new h(this):void 0,q=new Um(this.config,this.logger),z=this.streamController=new s(this,C,q),oe=this.gapController=g?new g(this,C):void 0;b&&b.setStreamController(z);const ne=[p,O,z];S&&ne.splice(1,0,S),N&&ne.splice(1,0,N),this.networkControllers=ne;const J=[A];R&&J.push(R),oe&&J.push(oe),b&&J.push(b),D&&(D.setStreamController(z),J.push(D)),W&&J.push(W),J.push(C),this.audioTrackController=this.createController(i.audioTrackController,ne);const Z=i.audioStreamController;Z&&ne.push(this.audioStreamController=new Z(this,C,q)),this.subtitleTrackController=this.createController(i.subtitleTrackController,ne);const Q=i.subtitleStreamController;Q&&ne.push(this.subtititleStreamController=new Q(this,C,q)),this.createController(i.timelineController,J),q.emeController=this.emeController=this.createController(i.emeController,J),M&&J.push(M),this.latencyController=this.createController(i.latencyController,J),this.coreComponents=J,this.iframeController=d?new d(this,Tt):void 0,ne.push(m);const ee=m.onErrorOut;typeof ee=="function"&&this.on(E.ERROR,ee,m),this.on(E.MANIFEST_LOADED,p.onManifestLoaded,p)}createController(e,t){if(e){const i=new e(this);return t&&t.push(i),i}return null}on(e,t,i=this){this._emitter.on(e,t,i)}once(e,t,i=this){this._emitter.once(e,t,i)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,i=this,s){this._emitter.off(e,t,i,s)}listeners(e){return this._emitter.listeners(e)}emit(e,t,i){return this._emitter.emit(e,t,i)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(i){if(this.logger.error("An internal error happened while handling event "+e+'. Error message: "'+i.message+'". Here is a stacktrace:',i),!this.triggeringException){this.triggeringException=!0;const s=e===E.ERROR;this.trigger(E.ERROR,{type:me.OTHER_ERROR,details:U.INTERNAL_EXCEPTION,fatal:s,event:e,error:i}),this.triggeringException=!1}}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){this.logger.log("destroy"),this.trigger(E.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this._url=null,this.networkControllers.forEach(t=>t.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(t=>t.destroy()),this.coreComponents.length=0,this.iframeController=void 0;const e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}attachMedia(e){if(!e||"media"in e&&!e.media){const n=new Error(`attachMedia failed: invalid argument (${e})`);this.trigger(E.ERROR,{type:me.OTHER_ERROR,details:U.ATTACH_MEDIA_ERROR,fatal:!0,error:n});return}this.logger.log("attachMedia"),this._media&&(this.logger.warn("media must be detached before attaching"),this.detachMedia());const t="media"in e,i=t?e.media:e,s=t?e:{media:i};this._media=i,this.trigger(E.MEDIA_ATTACHING,s)}detachMedia(){this.logger.log("detachMedia");const e={};this.trigger(E.MEDIA_DETACHING,e),this._media=null,this.trigger(E.MEDIA_DETACHED,e)}transferMedia(){var e;this._media=null;const t=((e=this.bufferController)==null?void 0:e.transferMedia())||null,i={transferMedia:t};return this.trigger(E.MEDIA_DETACHING,i),this.trigger(E.MEDIA_DETACHED,i),t}loadSource(e){var t;this.stopLoad();const i=this.media,s=this._url,n=this._url=Vn.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log(`loadSource:${n}`),i&&s&&(s!==n||(t=this.bufferController)!=null&&t.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(i)),this.trigger(E.MANIFEST_LOADING,{url:e})}get url(){return this._url}get hasEnoughToStart(){return this.streamController.hasEnoughToStart}get startPosition(){return this.streamController.startPositionValue}startLoad(e=-1,t){this.logger.log(`startLoad(${e+(t?", <skip seek to start>":"")})`),this.started=!0,this.resumeBuffering();for(let i=0;i<this.networkControllers.length&&(this.networkControllers[i].startLoad(e,t),!(!this.started||!this.networkControllers));i++);}stopLoad(){this.logger.log("stopLoad"),this.started=!1;for(let e=0;e<this.networkControllers.length&&(this.networkControllers[e].stopLoad(),!(this.started||!this.networkControllers));e++);}get loadingEnabled(){return this.started&&this.streamController.state!==Y.STOPPED}get bufferingEnabled(){return this.streamController.bufferingEnabled}resumeBuffering(){this.bufferingEnabled||(this.logger.log("resume buffering"),this.networkControllers.forEach(e=>{e.resumeBuffering&&e.resumeBuffering()}))}pauseBuffering(){this.bufferingEnabled&&(this.logger.log("pause buffering"),this.networkControllers.forEach(e=>{e.pauseBuffering&&e.pauseBuffering()}))}get inFlightFragments(){const e={[ge.MAIN]:this.streamController.inFlightFrag};return this.audioStreamController&&(e[ge.AUDIO]=this.audioStreamController.inFlightFrag),this.subtititleStreamController&&(e[ge.SUBTITLE]=this.subtititleStreamController.inFlightFrag),e}swapAudioCodec(){this.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){this.logger.log("recoverMediaError");const e=this._media,t=this.started,i=e?.currentTime;this.detachMedia(),e&&(this.attachMedia(e),t&&(i?this.startLoad(i):this.config.autoStartLoad||this.startLoad()))}removeLevel(e){this.levelController.removeLevel(e)}get sessionId(){let e=this._sessionId;return e||(e=this._sessionId=Xa()),e}get levels(){const e=this.levelController.levels;return e||[]}get latestLevelDetails(){return this.streamController.getLevelDetails()||null}get loadLevelObj(){return this.levelController.loadLevelObj}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){this.logger.log(`set currentLevel:${e}`),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){this.logger.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){this.logger.log(`set loadLevel:${e}`),this.levelController.manualLevel=e}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(e){this.levelController.nextLoadLevel=e}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(e){this.logger.log(`set firstLevel:${e}`),this.levelController.firstLevel=e}get startLevel(){const e=this.levelController.startLevel;return e===-1&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e}set startLevel(e){this.logger.log(`set startLevel:${e}`),e!==-1&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){const t=this.capLevelController,i=!!e;t&&i!==this.config.capLevelToPlayerSize&&(i?t.startCapping():(t.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=i)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimate():NaN}set bandwidthEstimate(e){this.abrController.resetEstimator(e)}get abrEwmaDefaultEstimate(){const{bwEstimator:e}=this.abrController;return e?e.defaultEstimate:NaN}get ttfbEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(this.logger.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){ud(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}get autoLevelEnabled(){return this.levelController.manualLevel===-1}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){const{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;const i=e.length;for(let s=0;s<i;s++)if(e[s].maxBitrate>=t)return s;return 0}get maxAutoLevel(){const{levels:e,autoLevelCapping:t,maxHdcpLevel:i}=this;let s;if(t===-1&&e!=null&&e.length?s=e.length-1:s=t,i)for(let n=s;n--;){const a=e[n].attrs["HDCP-LEVEL"];if(a&&a<=i)return n}return s}get firstAutoLevel(){return this.abrController.firstAutoLevel}get nextAutoLevel(){return this.abrController.nextAutoLevel}set nextAutoLevel(e){this.abrController.nextAutoLevel=e}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get audioForwardBufferInfo(){var e;return((e=this.audioStreamController)==null?void 0:e.getFwdBufferInfo())||null}get maxBufferLength(){return this.streamController.maxBufferLength}setAudioOption(e){var t;return((t=this.audioTrackController)==null?void 0:t.setAudioOption(e))||null}setSubtitleOption(e){var t;return((t=this.subtitleTrackController)==null?void 0:t.setSubtitleOption(e))||null}get allAudioTracks(){const e=this.audioTrackController;return e?e.allAudioTracks:[]}get audioTracks(){const e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){const e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){const t=this.audioTrackController;t&&(t.audioTrack=e)}get nextAudioTrack(){var e,t;return(e=(t=this.audioStreamController)==null?void 0:t.nextAudioTrack)!=null?e:-1}set nextAudioTrack(e){const{audioTrackController:t}=this;t&&(t.nextAudioTrack=e)}get allSubtitleTracks(){const e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}get subtitleTracks(){const e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){const e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){const t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}get subtitleDisplay(){const e=this.subtitleTrackController;return e?e.subtitleDisplay:!1}set subtitleDisplay(e){const t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(e){this.config.lowLatencyMode=e}get liveSyncPosition(){var e,t;return(e=(t=this.latencyController)==null?void 0:t.liveSyncPosition)!=null?e:null}get latency(){var e;return((e=this.latencyController)==null?void 0:e.latency)||0}get maxLatency(){var e;return((e=this.latencyController)==null?void 0:e.maxLatency)||0}get targetLatency(){var e;return((e=this.latencyController)==null?void 0:e.targetLatency)||null}set targetLatency(e){this.latencyController&&(this.latencyController.targetLatency=e)}get drift(){var e;return((e=this.latencyController)==null?void 0:e.drift)||null}get forceStartLoad(){return this.streamController.forceStartLoad}get pathways(){return this.levelController.pathways}get pathwayPriority(){return this.levelController.pathwayPriority}set pathwayPriority(e){this.levelController.pathwayPriority=e}get bufferedToEnd(){var e;return!!((e=this.bufferController)!=null&&e.bufferedToEnd)}get interstitialsManager(){return this.interstitialsController?this.interstitialsController.interstitialsManager:null}get iframeVariants(){const e=this.levelController.iframeVariants;return e||[]}createIFramePlayer(e){return this._url&&this.iframeController?this.iframeController.createIFramePlayer(e):null}createImageIFramePlayer(e){return this._url&&this.iframeController?this.iframeController.createImageIFramePlayer(e):null}getMediaDecodingInfo(e,t=this.allAudioTracks){const i=Do(t);return To(e,i,navigator.mediaCapabilities)}}Tt.defaultConfig=void 0;function Gm(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var _n={exports:{}};var Hm=_n.exports,pc;function Vm(){return pc||(pc=1,(function(r){(function(e,t){r.exports=e.document?t(e,!0):function(i){if(!i.document)throw new Error("jQuery requires a window with a document");return t(i)}})(typeof window<"u"?window:Hm,function(e,t){var i=[],s=Object.getPrototypeOf,n=i.slice,a=i.flat?function(c){return i.flat.call(c)}:function(c){return i.concat.apply([],c)},o=i.push,l=i.indexOf,u={},h=u.toString,d=u.hasOwnProperty,g=d.toString,m=g.call(Object),A={},C=function(f){return typeof f=="function"&&typeof f.nodeType!="number"&&typeof f.item!="function"},v=function(f){return f!=null&&f===f.window},S=e.document,R={type:!0,src:!0,nonce:!0,noModule:!0};function b(c,f,I){I=I||S;var y,T,x=I.createElement("script");if(x.text=c,f)for(y in R)T=f[y]||f.getAttribute&&f.getAttribute(y),T&&x.setAttribute(y,T);I.head.appendChild(x).parentNode.removeChild(x)}function D(c){return c==null?c+"":typeof c=="object"||typeof c=="function"?u[h.call(c)]||"object":typeof c}var _="3.7.1",M=/HTML$/i,p=function(c,f){return new p.fn.init(c,f)};p.fn=p.prototype={jquery:_,constructor:p,length:0,toArray:function(){return n.call(this)},get:function(c){return c==null?n.call(this):c<0?this[c+this.length]:this[c]},pushStack:function(c){var f=p.merge(this.constructor(),c);return f.prevObject=this,f},each:function(c){return p.each(this,c)},map:function(c){return this.pushStack(p.map(this,function(f,I){return c.call(f,I,f)}))},slice:function(){return this.pushStack(n.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},even:function(){return this.pushStack(p.grep(this,function(c,f){return(f+1)%2}))},odd:function(){return this.pushStack(p.grep(this,function(c,f){return f%2}))},eq:function(c){var f=this.length,I=+c+(c<0?f:0);return this.pushStack(I>=0&&I<f?[this[I]]:[])},end:function(){return this.prevObject||this.constructor()},push:o,sort:i.sort,splice:i.splice},p.extend=p.fn.extend=function(){var c,f,I,y,T,x,L=arguments[0]||{},w=1,k=arguments.length,B=!1;for(typeof L=="boolean"&&(B=L,L=arguments[w]||{},w++),typeof L!="object"&&!C(L)&&(L={}),w===k&&(L=this,w--);w<k;w++)if((c=arguments[w])!=null)for(f in c)y=c[f],!(f==="__proto__"||L===y)&&(B&&y&&(p.isPlainObject(y)||(T=Array.isArray(y)))?(I=L[f],T&&!Array.isArray(I)?x=[]:!T&&!p.isPlainObject(I)?x={}:x=I,T=!1,L[f]=p.extend(B,x,y)):y!==void 0&&(L[f]=y));return L},p.extend({expando:"jQuery"+(_+Math.random()).replace(/\D/g,""),isReady:!0,error:function(c){throw new Error(c)},noop:function(){},isPlainObject:function(c){var f,I;return!c||h.call(c)!=="[object Object]"?!1:(f=s(c),f?(I=d.call(f,"constructor")&&f.constructor,typeof I=="function"&&g.call(I)===m):!0)},isEmptyObject:function(c){var f;for(f in c)return!1;return!0},globalEval:function(c,f,I){b(c,{nonce:f&&f.nonce},I)},each:function(c,f){var I,y=0;if($(c))for(I=c.length;y<I&&f.call(c[y],y,c[y])!==!1;y++);else for(y in c)if(f.call(c[y],y,c[y])===!1)break;return c},text:function(c){var f,I="",y=0,T=c.nodeType;if(!T)for(;f=c[y++];)I+=p.text(f);return T===1||T===11?c.textContent:T===9?c.documentElement.textContent:T===3||T===4?c.nodeValue:I},makeArray:function(c,f){var I=f||[];return c!=null&&($(Object(c))?p.merge(I,typeof c=="string"?[c]:c):o.call(I,c)),I},inArray:function(c,f,I){return f==null?-1:l.call(f,c,I)},isXMLDoc:function(c){var f=c&&c.namespaceURI,I=c&&(c.ownerDocument||c).documentElement;return!M.test(f||I&&I.nodeName||"HTML")},merge:function(c,f){for(var I=+f.length,y=0,T=c.length;y<I;y++)c[T++]=f[y];return c.length=T,c},grep:function(c,f,I){for(var y,T=[],x=0,L=c.length,w=!I;x<L;x++)y=!f(c[x],x),y!==w&&T.push(c[x]);return T},map:function(c,f,I){var y,T,x=0,L=[];if($(c))for(y=c.length;x<y;x++)T=f(c[x],x,I),T!=null&&L.push(T);else for(x in c)T=f(c[x],x,I),T!=null&&L.push(T);return a(L)},guid:1,support:A}),typeof Symbol=="function"&&(p.fn[Symbol.iterator]=i[Symbol.iterator]),p.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(c,f){u["[object "+f+"]"]=f.toLowerCase()});function $(c){var f=!!c&&"length"in c&&c.length,I=D(c);return C(c)||v(c)?!1:I==="array"||f===0||typeof f=="number"&&f>0&&f-1 in c}function N(c,f){return c.nodeName&&c.nodeName.toLowerCase()===f.toLowerCase()}var O=i.pop,W=i.sort,q=i.splice,z="[\\x20\\t\\r\\n\\f]",oe=new RegExp("^"+z+"+|((?:^|[^\\\\])(?:\\\\.)*)"+z+"+$","g");p.contains=function(c,f){var I=f&&f.parentNode;return c===I||!!(I&&I.nodeType===1&&(c.contains?c.contains(I):c.compareDocumentPosition&&c.compareDocumentPosition(I)&16))};var ne=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\x80-\uFFFF\w-]/g;function J(c,f){return f?c==="\0"?"�":c.slice(0,-1)+"\\"+c.charCodeAt(c.length-1).toString(16)+" ":"\\"+c}p.escapeSelector=function(c){return(c+"").replace(ne,J)};var Z=S,Q=o;(function(){var c,f,I,y,T,x=Q,L,w,k,B,K,X=p.expando,H=0,ie=0,De=Bn(),$e=Bn(),Me=Bn(),It=Bn(),ht=function(P,F){return P===F&&(T=!0),0},ui="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",ci="(?:\\\\[\\da-fA-F]{1,6}"+z+"?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+",Ue="\\["+z+"*("+ci+")(?:"+z+"*([*^$|!~]?=)"+z+`*(?:'((?:\\\\.|[^\\\\'])*)'|"((?:\\\\.|[^\\\\"])*)"|(`+ci+"))|)"+z+"*\\]",Gi=":("+ci+`)(?:\\((('((?:\\\\.|[^\\\\'])*)'|"((?:\\\\.|[^\\\\"])*)")|((?:\\\\.|[^\\\\()[\\]]|`+Ue+")*)|.*)\\)|)",He=new RegExp(z+"+","g"),ot=new RegExp("^"+z+"*,"+z+"*"),Bs=new RegExp("^"+z+"*([>+~]|"+z+")"+z+"*"),Da=new RegExp(z+"|>"),hi=new RegExp(Gi),Us=new RegExp("^"+ci+"$"),di={ID:new RegExp("^#("+ci+")"),CLASS:new RegExp("^\\.("+ci+")"),TAG:new RegExp("^("+ci+"|[*])"),ATTR:new RegExp("^"+Ue),PSEUDO:new RegExp("^"+Gi),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+z+"*(even|odd|(([+-]|)(\\d*)n|)"+z+"*(?:([+-]|)"+z+"*(\\d+)|))"+z+"*\\)|)","i"),bool:new RegExp("^(?:"+ui+")$","i"),needsContext:new RegExp("^"+z+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+z+"*((?:-\\d)?\\d*)"+z+"*\\)|)(?=[^-]|$)","i")},Pi=/^(?:input|select|textarea|button)$/i,_i=/^h\d$/i,Vt=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,Pa=/[+~]/,Ci=new RegExp("\\\\[\\da-fA-F]{1,6}"+z+"?|\\\\([^\\r\\n\\f])","g"),yi=function(P,F){var G="0x"+P.slice(1)-65536;return F||(G<0?String.fromCharCode(G+65536):String.fromCharCode(G>>10|55296,G&1023|56320))},_0=function(){ki()},k0=$n(function(P){return P.disabled===!0&&N(P,"fieldset")},{dir:"parentNode",next:"legend"});function w0(){try{return L.activeElement}catch{}}try{x.apply(i=n.call(Z.childNodes),Z.childNodes),i[Z.childNodes.length].nodeType}catch{x={apply:function(F,G){Q.apply(F,n.call(G))},call:function(F){Q.apply(F,n.call(arguments,1))}}}function qe(P,F,G,V){var j,ae,de,Ce,fe,Ne,be,Pe=F&&F.ownerDocument,Be=F?F.nodeType:9;if(G=G||[],typeof P!="string"||!P||Be!==1&&Be!==9&&Be!==11)return G;if(!V&&(ki(F),F=F||L,k)){if(Be!==11&&(fe=Vt.exec(P)))if(j=fe[1]){if(Be===9)if(de=F.getElementById(j)){if(de.id===j)return x.call(G,de),G}else return G;else if(Pe&&(de=Pe.getElementById(j))&&qe.contains(F,de)&&de.id===j)return x.call(G,de),G}else{if(fe[2])return x.apply(G,F.getElementsByTagName(P)),G;if((j=fe[3])&&F.getElementsByClassName)return x.apply(G,F.getElementsByClassName(j)),G}if(!It[P+" "]&&(!B||!B.test(P))){if(be=P,Pe=F,Be===1&&(Da.test(P)||Bs.test(P))){for(Pe=Pa.test(P)&&_a(F.parentNode)||F,(Pe!=F||!A.scope)&&((Ce=F.getAttribute("id"))?Ce=p.escapeSelector(Ce):F.setAttribute("id",Ce=X)),Ne=$s(P),ae=Ne.length;ae--;)Ne[ae]=(Ce?"#"+Ce:":scope")+" "+Un(Ne[ae]);be=Ne.join(",")}try{return x.apply(G,Pe.querySelectorAll(be)),G}catch{It(P,!0)}finally{Ce===X&&F.removeAttribute("id")}}}return jc(P.replace(oe,"$1"),F,G,V)}function Bn(){var P=[];function F(G,V){return P.push(G+" ")>f.cacheLength&&delete F[P.shift()],F[G+" "]=V}return F}function Qt(P){return P[X]=!0,P}function os(P){var F=L.createElement("fieldset");try{return!!P(F)}catch{return!1}finally{F.parentNode&&F.parentNode.removeChild(F),F=null}}function M0(P){return function(F){return N(F,"input")&&F.type===P}}function O0(P){return function(F){return(N(F,"input")||N(F,"button"))&&F.type===P}}function Yc(P){return function(F){return"form"in F?F.parentNode&&F.disabled===!1?"label"in F?"label"in F.parentNode?F.parentNode.disabled===P:F.disabled===P:F.isDisabled===P||F.isDisabled!==!P&&k0(F)===P:F.disabled===P:"label"in F?F.disabled===P:!1}}function Hi(P){return Qt(function(F){return F=+F,Qt(function(G,V){for(var j,ae=P([],G.length,F),de=ae.length;de--;)G[j=ae[de]]&&(G[j]=!(V[j]=G[j]))})})}function _a(P){return P&&typeof P.getElementsByTagName<"u"&&P}function ki(P){var F,G=P?P.ownerDocument||P:Z;return G==L||G.nodeType!==9||!G.documentElement||(L=G,w=L.documentElement,k=!p.isXMLDoc(L),K=w.matches||w.webkitMatchesSelector||w.msMatchesSelector,w.msMatchesSelector&&Z!=L&&(F=L.defaultView)&&F.top!==F&&F.addEventListener("unload",_0),A.getById=os(function(V){return w.appendChild(V).id=p.expando,!L.getElementsByName||!L.getElementsByName(p.expando).length}),A.disconnectedMatch=os(function(V){return K.call(V,"*")}),A.scope=os(function(){return L.querySelectorAll(":scope")}),A.cssHas=os(function(){try{return L.querySelector(":has(*,:jqfake)"),!1}catch{return!0}}),A.getById?(f.filter.ID=function(V){var j=V.replace(Ci,yi);return function(ae){return ae.getAttribute("id")===j}},f.find.ID=function(V,j){if(typeof j.getElementById<"u"&&k){var ae=j.getElementById(V);return ae?[ae]:[]}}):(f.filter.ID=function(V){var j=V.replace(Ci,yi);return function(ae){var de=typeof ae.getAttributeNode<"u"&&ae.getAttributeNode("id");return de&&de.value===j}},f.find.ID=function(V,j){if(typeof j.getElementById<"u"&&k){var ae,de,Ce,fe=j.getElementById(V);if(fe){if(ae=fe.getAttributeNode("id"),ae&&ae.value===V)return[fe];for(Ce=j.getElementsByName(V),de=0;fe=Ce[de++];)if(ae=fe.getAttributeNode("id"),ae&&ae.value===V)return[fe]}return[]}}),f.find.TAG=function(V,j){return typeof j.getElementsByTagName<"u"?j.getElementsByTagName(V):j.querySelectorAll(V)},f.find.CLASS=function(V,j){if(typeof j.getElementsByClassName<"u"&&k)return j.getElementsByClassName(V)},B=[],os(function(V){var j;w.appendChild(V).innerHTML="<a id='"+X+"' href='' disabled='disabled'></a><select id='"+X+"-\r\\' disabled='disabled'><option selected=''></option></select>",V.querySelectorAll("[selected]").length||B.push("\\["+z+"*(?:value|"+ui+")"),V.querySelectorAll("[id~="+X+"-]").length||B.push("~="),V.querySelectorAll("a#"+X+"+*").length||B.push(".#.+[+~]"),V.querySelectorAll(":checked").length||B.push(":checked"),j=L.createElement("input"),j.setAttribute("type","hidden"),V.appendChild(j).setAttribute("name","D"),w.appendChild(V).disabled=!0,V.querySelectorAll(":disabled").length!==2&&B.push(":enabled",":disabled"),j=L.createElement("input"),j.setAttribute("name",""),V.appendChild(j),V.querySelectorAll("[name='']").length||B.push("\\["+z+"*name"+z+"*="+z+`*(?:''|"")`)}),A.cssHas||B.push(":has"),B=B.length&&new RegExp(B.join("|")),ht=function(V,j){if(V===j)return T=!0,0;var ae=!V.compareDocumentPosition-!j.compareDocumentPosition;return ae||(ae=(V.ownerDocument||V)==(j.ownerDocument||j)?V.compareDocumentPosition(j):1,ae&1||!A.sortDetached&&j.compareDocumentPosition(V)===ae?V===L||V.ownerDocument==Z&&qe.contains(Z,V)?-1:j===L||j.ownerDocument==Z&&qe.contains(Z,j)?1:y?l.call(y,V)-l.call(y,j):0:ae&4?-1:1)}),L}qe.matches=function(P,F){return qe(P,null,null,F)},qe.matchesSelector=function(P,F){if(ki(P),k&&!It[F+" "]&&(!B||!B.test(F)))try{var G=K.call(P,F);if(G||A.disconnectedMatch||P.document&&P.document.nodeType!==11)return G}catch{It(F,!0)}return qe(F,L,null,[P]).length>0},qe.contains=function(P,F){return(P.ownerDocument||P)!=L&&ki(P),p.contains(P,F)},qe.attr=function(P,F){(P.ownerDocument||P)!=L&&ki(P);var G=f.attrHandle[F.toLowerCase()],V=G&&d.call(f.attrHandle,F.toLowerCase())?G(P,F,!k):void 0;return V!==void 0?V:P.getAttribute(F)},qe.error=function(P){throw new Error("Syntax error, unrecognized expression: "+P)},p.uniqueSort=function(P){var F,G=[],V=0,j=0;if(T=!A.sortStable,y=!A.sortStable&&n.call(P,0),W.call(P,ht),T){for(;F=P[j++];)F===P[j]&&(V=G.push(j));for(;V--;)q.call(P,G[V],1)}return y=null,P},p.fn.uniqueSort=function(){return this.pushStack(p.uniqueSort(n.apply(this)))},f=p.expr={cacheLength:50,createPseudo:Qt,match:di,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(P){return P[1]=P[1].replace(Ci,yi),P[3]=(P[3]||P[4]||P[5]||"").replace(Ci,yi),P[2]==="~="&&(P[3]=" "+P[3]+" "),P.slice(0,4)},CHILD:function(P){return P[1]=P[1].toLowerCase(),P[1].slice(0,3)==="nth"?(P[3]||qe.error(P[0]),P[4]=+(P[4]?P[5]+(P[6]||1):2*(P[3]==="even"||P[3]==="odd")),P[5]=+(P[7]+P[8]||P[3]==="odd")):P[3]&&qe.error(P[0]),P},PSEUDO:function(P){var F,G=!P[6]&&P[2];return di.CHILD.test(P[0])?null:(P[3]?P[2]=P[4]||P[5]||"":G&&hi.test(G)&&(F=$s(G,!0))&&(F=G.indexOf(")",G.length-F)-G.length)&&(P[0]=P[0].slice(0,F),P[2]=G.slice(0,F)),P.slice(0,3))}},filter:{TAG:function(P){var F=P.replace(Ci,yi).toLowerCase();return P==="*"?function(){return!0}:function(G){return N(G,F)}},CLASS:function(P){var F=De[P+" "];return F||(F=new RegExp("(^|"+z+")"+P+"("+z+"|$)"))&&De(P,function(G){return F.test(typeof G.className=="string"&&G.className||typeof G.getAttribute<"u"&&G.getAttribute("class")||"")})},ATTR:function(P,F,G){return function(V){var j=qe.attr(V,P);return j==null?F==="!=":F?(j+="",F==="="?j===G:F==="!="?j!==G:F==="^="?G&&j.indexOf(G)===0:F==="*="?G&&j.indexOf(G)>-1:F==="$="?G&&j.slice(-G.length)===G:F==="~="?(" "+j.replace(He," ")+" ").indexOf(G)>-1:F==="|="?j===G||j.slice(0,G.length+1)===G+"-":!1):!0}},CHILD:function(P,F,G,V,j){var ae=P.slice(0,3)!=="nth",de=P.slice(-4)!=="last",Ce=F==="of-type";return V===1&&j===0?function(fe){return!!fe.parentNode}:function(fe,Ne,be){var Pe,Be,Se,Qe,kt,vt=ae!==de?"nextSibling":"previousSibling",Kt=fe.parentNode,fi=Ce&&fe.nodeName.toLowerCase(),ls=!be&&!Ce,bt=!1;if(Kt){if(ae){for(;vt;){for(Se=fe;Se=Se[vt];)if(Ce?N(Se,fi):Se.nodeType===1)return!1;kt=vt=P==="only"&&!kt&&"nextSibling"}return!0}if(kt=[de?Kt.firstChild:Kt.lastChild],de&&ls){for(Be=Kt[X]||(Kt[X]={}),Pe=Be[P]||[],Qe=Pe[0]===H&&Pe[1],bt=Qe&&Pe[2],Se=Qe&&Kt.childNodes[Qe];Se=++Qe&&Se&&Se[vt]||(bt=Qe=0)||kt.pop();)if(Se.nodeType===1&&++bt&&Se===fe){Be[P]=[H,Qe,bt];break}}else if(ls&&(Be=fe[X]||(fe[X]={}),Pe=Be[P]||[],Qe=Pe[0]===H&&Pe[1],bt=Qe),bt===!1)for(;(Se=++Qe&&Se&&Se[vt]||(bt=Qe=0)||kt.pop())&&!((Ce?N(Se,fi):Se.nodeType===1)&&++bt&&(ls&&(Be=Se[X]||(Se[X]={}),Be[P]=[H,bt]),Se===fe)););return bt-=j,bt===V||bt%V===0&&bt/V>=0}}},PSEUDO:function(P,F){var G,V=f.pseudos[P]||f.setFilters[P.toLowerCase()]||qe.error("unsupported pseudo: "+P);return V[X]?V(F):V.length>1?(G=[P,P,"",F],f.setFilters.hasOwnProperty(P.toLowerCase())?Qt(function(j,ae){for(var de,Ce=V(j,F),fe=Ce.length;fe--;)de=l.call(j,Ce[fe]),j[de]=!(ae[de]=Ce[fe])}):function(j){return V(j,0,G)}):V}},pseudos:{not:Qt(function(P){var F=[],G=[],V=Oa(P.replace(oe,"$1"));return V[X]?Qt(function(j,ae,de,Ce){for(var fe,Ne=V(j,null,Ce,[]),be=j.length;be--;)(fe=Ne[be])&&(j[be]=!(ae[be]=fe))}):function(j,ae,de){return F[0]=j,V(F,null,de,G),F[0]=null,!G.pop()}}),has:Qt(function(P){return function(F){return qe(P,F).length>0}}),contains:Qt(function(P){return P=P.replace(Ci,yi),function(F){return(F.textContent||p.text(F)).indexOf(P)>-1}}),lang:Qt(function(P){return Us.test(P||"")||qe.error("unsupported lang: "+P),P=P.replace(Ci,yi).toLowerCase(),function(F){var G;do if(G=k?F.lang:F.getAttribute("xml:lang")||F.getAttribute("lang"))return G=G.toLowerCase(),G===P||G.indexOf(P+"-")===0;while((F=F.parentNode)&&F.nodeType===1);return!1}}),target:function(P){var F=e.location&&e.location.hash;return F&&F.slice(1)===P.id},root:function(P){return P===w},focus:function(P){return P===w0()&&L.hasFocus()&&!!(P.type||P.href||~P.tabIndex)},enabled:Yc(!1),disabled:Yc(!0),checked:function(P){return N(P,"input")&&!!P.checked||N(P,"option")&&!!P.selected},selected:function(P){return P.parentNode&&P.parentNode.selectedIndex,P.selected===!0},empty:function(P){for(P=P.firstChild;P;P=P.nextSibling)if(P.nodeType<6)return!1;return!0},parent:function(P){return!f.pseudos.empty(P)},header:function(P){return _i.test(P.nodeName)},input:function(P){return Pi.test(P.nodeName)},button:function(P){return N(P,"input")&&P.type==="button"||N(P,"button")},text:function(P){var F;return N(P,"input")&&P.type==="text"&&((F=P.getAttribute("type"))==null||F.toLowerCase()==="text")},first:Hi(function(){return[0]}),last:Hi(function(P,F){return[F-1]}),eq:Hi(function(P,F,G){return[G<0?G+F:G]}),even:Hi(function(P,F){for(var G=0;G<F;G+=2)P.push(G);return P}),odd:Hi(function(P,F){for(var G=1;G<F;G+=2)P.push(G);return P}),lt:Hi(function(P,F,G){var V;for(G<0?V=G+F:G>F?V=F:V=G;--V>=0;)P.push(V);return P}),gt:Hi(function(P,F,G){for(var V=G<0?G+F:G;++V<F;)P.push(V);return P})}},f.pseudos.nth=f.pseudos.eq;for(c in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})f.pseudos[c]=M0(c);for(c in{submit:!0,reset:!0})f.pseudos[c]=O0(c);function Wc(){}Wc.prototype=f.filters=f.pseudos,f.setFilters=new Wc;function $s(P,F){var G,V,j,ae,de,Ce,fe,Ne=$e[P+" "];if(Ne)return F?0:Ne.slice(0);for(de=P,Ce=[],fe=f.preFilter;de;){(!G||(V=ot.exec(de)))&&(V&&(de=de.slice(V[0].length)||de),Ce.push(j=[])),G=!1,(V=Bs.exec(de))&&(G=V.shift(),j.push({value:G,type:V[0].replace(oe," ")}),de=de.slice(G.length));for(ae in f.filter)(V=di[ae].exec(de))&&(!fe[ae]||(V=fe[ae](V)))&&(G=V.shift(),j.push({value:G,type:ae,matches:V}),de=de.slice(G.length));if(!G)break}return F?de.length:de?qe.error(P):$e(P,Ce).slice(0)}function Un(P){for(var F=0,G=P.length,V="";F<G;F++)V+=P[F].value;return V}function $n(P,F,G){var V=F.dir,j=F.next,ae=j||V,de=G&&ae==="parentNode",Ce=ie++;return F.first?function(fe,Ne,be){for(;fe=fe[V];)if(fe.nodeType===1||de)return P(fe,Ne,be);return!1}:function(fe,Ne,be){var Pe,Be,Se=[H,Ce];if(be){for(;fe=fe[V];)if((fe.nodeType===1||de)&&P(fe,Ne,be))return!0}else for(;fe=fe[V];)if(fe.nodeType===1||de)if(Be=fe[X]||(fe[X]={}),j&&N(fe,j))fe=fe[V]||fe;else{if((Pe=Be[ae])&&Pe[0]===H&&Pe[1]===Ce)return Se[2]=Pe[2];if(Be[ae]=Se,Se[2]=P(fe,Ne,be))return!0}return!1}}function ka(P){return P.length>1?function(F,G,V){for(var j=P.length;j--;)if(!P[j](F,G,V))return!1;return!0}:P[0]}function F0(P,F,G){for(var V=0,j=F.length;V<j;V++)qe(P,F[V],G);return G}function Gn(P,F,G,V,j){for(var ae,de=[],Ce=0,fe=P.length,Ne=F!=null;Ce<fe;Ce++)(ae=P[Ce])&&(!G||G(ae,V,j))&&(de.push(ae),Ne&&F.push(Ce));return de}function wa(P,F,G,V,j,ae){return V&&!V[X]&&(V=wa(V)),j&&!j[X]&&(j=wa(j,ae)),Qt(function(de,Ce,fe,Ne){var be,Pe,Be,Se,Qe=[],kt=[],vt=Ce.length,Kt=de||F0(F||"*",fe.nodeType?[fe]:fe,[]),fi=P&&(de||!F)?Gn(Kt,Qe,P,fe,Ne):Kt;if(G?(Se=j||(de?P:vt||V)?[]:Ce,G(fi,Se,fe,Ne)):Se=fi,V)for(be=Gn(Se,kt),V(be,[],fe,Ne),Pe=be.length;Pe--;)(Be=be[Pe])&&(Se[kt[Pe]]=!(fi[kt[Pe]]=Be));if(de){if(j||P){if(j){for(be=[],Pe=Se.length;Pe--;)(Be=Se[Pe])&&be.push(fi[Pe]=Be);j(null,Se=[],be,Ne)}for(Pe=Se.length;Pe--;)(Be=Se[Pe])&&(be=j?l.call(de,Be):Qe[Pe])>-1&&(de[be]=!(Ce[be]=Be))}}else Se=Gn(Se===Ce?Se.splice(vt,Se.length):Se),j?j(null,Ce,Se,Ne):x.apply(Ce,Se)})}function Ma(P){for(var F,G,V,j=P.length,ae=f.relative[P[0].type],de=ae||f.relative[" "],Ce=ae?1:0,fe=$n(function(Pe){return Pe===F},de,!0),Ne=$n(function(Pe){return l.call(F,Pe)>-1},de,!0),be=[function(Pe,Be,Se){var Qe=!ae&&(Se||Be!=I)||((F=Be).nodeType?fe(Pe,Be,Se):Ne(Pe,Be,Se));return F=null,Qe}];Ce<j;Ce++)if(G=f.relative[P[Ce].type])be=[$n(ka(be),G)];else{if(G=f.filter[P[Ce].type].apply(null,P[Ce].matches),G[X]){for(V=++Ce;V<j&&!f.relative[P[V].type];V++);return wa(Ce>1&&ka(be),Ce>1&&Un(P.slice(0,Ce-1).concat({value:P[Ce-2].type===" "?"*":""})).replace(oe,"$1"),G,Ce<V&&Ma(P.slice(Ce,V)),V<j&&Ma(P=P.slice(V)),V<j&&Un(P))}be.push(G)}return ka(be)}function N0(P,F){var G=F.length>0,V=P.length>0,j=function(ae,de,Ce,fe,Ne){var be,Pe,Be,Se=0,Qe="0",kt=ae&&[],vt=[],Kt=I,fi=ae||V&&f.find.TAG("*",Ne),ls=H+=Kt==null?1:Math.random()||.1,bt=fi.length;for(Ne&&(I=de==L||de||Ne);Qe!==bt&&(be=fi[Qe])!=null;Qe++){if(V&&be){for(Pe=0,!de&&be.ownerDocument!=L&&(ki(be),Ce=!k);Be=P[Pe++];)if(Be(be,de||L,Ce)){x.call(fe,be);break}Ne&&(H=ls)}G&&((be=!Be&&be)&&Se--,ae&&kt.push(be))}if(Se+=Qe,G&&Qe!==Se){for(Pe=0;Be=F[Pe++];)Be(kt,vt,de,Ce);if(ae){if(Se>0)for(;Qe--;)kt[Qe]||vt[Qe]||(vt[Qe]=O.call(fe));vt=Gn(vt)}x.apply(fe,vt),Ne&&!ae&&vt.length>0&&Se+F.length>1&&p.uniqueSort(fe)}return Ne&&(H=ls,I=Kt),kt};return G?Qt(j):j}function Oa(P,F){var G,V=[],j=[],ae=Me[P+" "];if(!ae){for(F||(F=$s(P)),G=F.length;G--;)ae=Ma(F[G]),ae[X]?V.push(ae):j.push(ae);ae=Me(P,N0(j,V)),ae.selector=P}return ae}function jc(P,F,G,V){var j,ae,de,Ce,fe,Ne=typeof P=="function"&&P,be=!V&&$s(P=Ne.selector||P);if(G=G||[],be.length===1){if(ae=be[0]=be[0].slice(0),ae.length>2&&(de=ae[0]).type==="ID"&&F.nodeType===9&&k&&f.relative[ae[1].type]){if(F=(f.find.ID(de.matches[0].replace(Ci,yi),F)||[])[0],F)Ne&&(F=F.parentNode);else return G;P=P.slice(ae.shift().value.length)}for(j=di.needsContext.test(P)?0:ae.length;j--&&(de=ae[j],!f.relative[Ce=de.type]);)if((fe=f.find[Ce])&&(V=fe(de.matches[0].replace(Ci,yi),Pa.test(ae[0].type)&&_a(F.parentNode)||F))){if(ae.splice(j,1),P=V.length&&Un(ae),!P)return x.apply(G,V),G;break}}return(Ne||Oa(P,be))(V,F,!k,G,!F||Pa.test(P)&&_a(F.parentNode)||F),G}A.sortStable=X.split("").sort(ht).join("")===X,ki(),A.sortDetached=os(function(P){return P.compareDocumentPosition(L.createElement("fieldset"))&1}),p.find=qe,p.expr[":"]=p.expr.pseudos,p.unique=p.uniqueSort,qe.compile=Oa,qe.select=jc,qe.setDocument=ki,qe.tokenize=$s,qe.escape=p.escapeSelector,qe.getText=p.text,qe.isXML=p.isXMLDoc,qe.selectors=p.expr,qe.support=p.support,qe.uniqueSort=p.uniqueSort})();var ee=function(c,f,I){for(var y=[],T=I!==void 0;(c=c[f])&&c.nodeType!==9;)if(c.nodeType===1){if(T&&p(c).is(I))break;y.push(c)}return y},he=function(c,f){for(var I=[];c;c=c.nextSibling)c.nodeType===1&&c!==f&&I.push(c);return I},te=p.expr.match.needsContext,re=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function Ee(c,f,I){return C(f)?p.grep(c,function(y,T){return!!f.call(y,T,y)!==I}):f.nodeType?p.grep(c,function(y){return y===f!==I}):typeof f!="string"?p.grep(c,function(y){return l.call(f,y)>-1!==I}):p.filter(f,c,I)}p.filter=function(c,f,I){var y=f[0];return I&&(c=":not("+c+")"),f.length===1&&y.nodeType===1?p.find.matchesSelector(y,c)?[y]:[]:p.find.matches(c,p.grep(f,function(T){return T.nodeType===1}))},p.fn.extend({find:function(c){var f,I,y=this.length,T=this;if(typeof c!="string")return this.pushStack(p(c).filter(function(){for(f=0;f<y;f++)if(p.contains(T[f],this))return!0}));for(I=this.pushStack([]),f=0;f<y;f++)p.find(c,T[f],I);return y>1?p.uniqueSort(I):I},filter:function(c){return this.pushStack(Ee(this,c||[],!1))},not:function(c){return this.pushStack(Ee(this,c||[],!0))},is:function(c){return!!Ee(this,typeof c=="string"&&te.test(c)?p(c):c||[],!1).length}});var Ie,_e=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,ye=p.fn.init=function(c,f,I){var y,T;if(!c)return this;if(I=I||Ie,typeof c=="string")if(c[0]==="<"&&c[c.length-1]===">"&&c.length>=3?y=[null,c,null]:y=_e.exec(c),y&&(y[1]||!f))if(y[1]){if(f=f instanceof p?f[0]:f,p.merge(this,p.parseHTML(y[1],f&&f.nodeType?f.ownerDocument||f:S,!0)),re.test(y[1])&&p.isPlainObject(f))for(y in f)C(this[y])?this[y](f[y]):this.attr(y,f[y]);return this}else return T=S.getElementById(y[2]),T&&(this[0]=T,this.length=1),this;else return!f||f.jquery?(f||I).find(c):this.constructor(f).find(c);else{if(c.nodeType)return this[0]=c,this.length=1,this;if(C(c))return I.ready!==void 0?I.ready(c):c(p)}return p.makeArray(c,this)};ye.prototype=p.fn,Ie=p(S);var Oe=/^(?:parents|prev(?:Until|All))/,Le={children:!0,contents:!0,next:!0,prev:!0};p.fn.extend({has:function(c){var f=p(c,this),I=f.length;return this.filter(function(){for(var y=0;y<I;y++)if(p.contains(this,f[y]))return!0})},closest:function(c,f){var I,y=0,T=this.length,x=[],L=typeof c!="string"&&p(c);if(!te.test(c)){for(;y<T;y++)for(I=this[y];I&&I!==f;I=I.parentNode)if(I.nodeType<11&&(L?L.index(I)>-1:I.nodeType===1&&p.find.matchesSelector(I,c))){x.push(I);break}}return this.pushStack(x.length>1?p.uniqueSort(x):x)},index:function(c){return c?typeof c=="string"?l.call(p(c),this[0]):l.call(this,c.jquery?c[0]:c):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(c,f){return this.pushStack(p.uniqueSort(p.merge(this.get(),p(c,f))))},addBack:function(c){return this.add(c==null?this.prevObject:this.prevObject.filter(c))}});function Fe(c,f){for(;(c=c[f])&&c.nodeType!==1;);return c}p.each({parent:function(c){var f=c.parentNode;return f&&f.nodeType!==11?f:null},parents:function(c){return ee(c,"parentNode")},parentsUntil:function(c,f,I){return ee(c,"parentNode",I)},next:function(c){return Fe(c,"nextSibling")},prev:function(c){return Fe(c,"previousSibling")},nextAll:function(c){return ee(c,"nextSibling")},prevAll:function(c){return ee(c,"previousSibling")},nextUntil:function(c,f,I){return ee(c,"nextSibling",I)},prevUntil:function(c,f,I){return ee(c,"previousSibling",I)},siblings:function(c){return he((c.parentNode||{}).firstChild,c)},children:function(c){return he(c.firstChild)},contents:function(c){return c.contentDocument!=null&&s(c.contentDocument)?c.contentDocument:(N(c,"template")&&(c=c.content||c),p.merge([],c.childNodes))}},function(c,f){p.fn[c]=function(I,y){var T=p.map(this,f,I);return c.slice(-5)!=="Until"&&(y=I),y&&typeof y=="string"&&(T=p.filter(y,T)),this.length>1&&(Le[c]||p.uniqueSort(T),Oe.test(c)&&T.reverse()),this.pushStack(T)}});var Ye=/[^\x20\t\r\n\f]+/g;function Ct(c){var f={};return p.each(c.match(Ye)||[],function(I,y){f[y]=!0}),f}p.Callbacks=function(c){c=typeof c=="string"?Ct(c):p.extend({},c);var f,I,y,T,x=[],L=[],w=-1,k=function(){for(T=T||c.once,y=f=!0;L.length;w=-1)for(I=L.shift();++w<x.length;)x[w].apply(I[0],I[1])===!1&&c.stopOnFalse&&(w=x.length,I=!1);c.memory||(I=!1),f=!1,T&&(I?x=[]:x="")},B={add:function(){return x&&(I&&!f&&(w=x.length-1,L.push(I)),(function K(X){p.each(X,function(H,ie){C(ie)?(!c.unique||!B.has(ie))&&x.push(ie):ie&&ie.length&&D(ie)!=="string"&&K(ie)})})(arguments),I&&!f&&k()),this},remove:function(){return p.each(arguments,function(K,X){for(var H;(H=p.inArray(X,x,H))>-1;)x.splice(H,1),H<=w&&w--}),this},has:function(K){return K?p.inArray(K,x)>-1:x.length>0},empty:function(){return x&&(x=[]),this},disable:function(){return T=L=[],x=I="",this},disabled:function(){return!x},lock:function(){return T=L=[],!I&&!f&&(x=I=""),this},locked:function(){return!!T},fireWith:function(K,X){return T||(X=X||[],X=[K,X.slice?X.slice():X],L.push(X),f||k()),this},fire:function(){return B.fireWith(this,arguments),this},fired:function(){return!!y}};return B};function yt(c){return c}function We(c){throw c}function St(c,f,I,y){var T;try{c&&C(T=c.promise)?T.call(c).done(f).fail(I):c&&C(T=c.then)?T.call(c,f,I):f.apply(void 0,[c].slice(y))}catch(x){I.apply(void 0,[x])}}p.extend({Deferred:function(c){var f=[["notify","progress",p.Callbacks("memory"),p.Callbacks("memory"),2],["resolve","done",p.Callbacks("once memory"),p.Callbacks("once memory"),0,"resolved"],["reject","fail",p.Callbacks("once memory"),p.Callbacks("once memory"),1,"rejected"]],I="pending",y={state:function(){return I},always:function(){return T.done(arguments).fail(arguments),this},catch:function(x){return y.then(null,x)},pipe:function(){var x=arguments;return p.Deferred(function(L){p.each(f,function(w,k){var B=C(x[k[4]])&&x[k[4]];T[k[1]](function(){var K=B&&B.apply(this,arguments);K&&C(K.promise)?K.promise().progress(L.notify).done(L.resolve).fail(L.reject):L[k[0]+"With"](this,B?[K]:arguments)})}),x=null}).promise()},then:function(x,L,w){var k=0;function B(K,X,H,ie){return function(){var De=this,$e=arguments,Me=function(){var ht,ui;if(!(K<k)){if(ht=H.apply(De,$e),ht===X.promise())throw new TypeError("Thenable self-resolution");ui=ht&&(typeof ht=="object"||typeof ht=="function")&&ht.then,C(ui)?ie?ui.call(ht,B(k,X,yt,ie),B(k,X,We,ie)):(k++,ui.call(ht,B(k,X,yt,ie),B(k,X,We,ie),B(k,X,yt,X.notifyWith))):(H!==yt&&(De=void 0,$e=[ht]),(ie||X.resolveWith)(De,$e))}},It=ie?Me:function(){try{Me()}catch(ht){p.Deferred.exceptionHook&&p.Deferred.exceptionHook(ht,It.error),K+1>=k&&(H!==We&&(De=void 0,$e=[ht]),X.rejectWith(De,$e))}};K?It():(p.Deferred.getErrorHook?It.error=p.Deferred.getErrorHook():p.Deferred.getStackHook&&(It.error=p.Deferred.getStackHook()),e.setTimeout(It))}}return p.Deferred(function(K){f[0][3].add(B(0,K,C(w)?w:yt,K.notifyWith)),f[1][3].add(B(0,K,C(x)?x:yt)),f[2][3].add(B(0,K,C(L)?L:We))}).promise()},promise:function(x){return x!=null?p.extend(x,y):y}},T={};return p.each(f,function(x,L){var w=L[2],k=L[5];y[L[1]]=w.add,k&&w.add(function(){I=k},f[3-x][2].disable,f[3-x][3].disable,f[0][2].lock,f[0][3].lock),w.add(L[3].fire),T[L[0]]=function(){return T[L[0]+"With"](this===T?void 0:this,arguments),this},T[L[0]+"With"]=w.fireWith}),y.promise(T),c&&c.call(T,T),T},when:function(c){var f=arguments.length,I=f,y=Array(I),T=n.call(arguments),x=p.Deferred(),L=function(w){return function(k){y[w]=this,T[w]=arguments.length>1?n.call(arguments):k,--f||x.resolveWith(y,T)}};if(f<=1&&(St(c,x.done(L(I)).resolve,x.reject,!f),x.state()==="pending"||C(T[I]&&T[I].then)))return x.then();for(;I--;)St(T[I],L(I),x.reject);return x.promise()}});var $t=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;p.Deferred.exceptionHook=function(c,f){e.console&&e.console.warn&&c&&$t.test(c.name)&&e.console.warn("jQuery.Deferred exception: "+c.message,c.stack,f)},p.readyException=function(c){e.setTimeout(function(){throw c})};var pe=p.Deferred();p.fn.ready=function(c){return pe.then(c).catch(function(f){p.readyException(f)}),this},p.extend({isReady:!1,readyWait:1,ready:function(c){(c===!0?--p.readyWait:p.isReady)||(p.isReady=!0,!(c!==!0&&--p.readyWait>0)&&pe.resolveWith(S,[p]))}}),p.ready.then=pe.then;function we(){S.removeEventListener("DOMContentLoaded",we),e.removeEventListener("load",we),p.ready()}S.readyState==="complete"||S.readyState!=="loading"&&!S.documentElement.doScroll?e.setTimeout(p.ready):(S.addEventListener("DOMContentLoaded",we),e.addEventListener("load",we));var Re=function(c,f,I,y,T,x,L){var w=0,k=c.length,B=I==null;if(D(I)==="object"){T=!0;for(w in I)Re(c,f,w,I[w],!0,x,L)}else if(y!==void 0&&(T=!0,C(y)||(L=!0),B&&(L?(f.call(c,y),f=null):(B=f,f=function(K,X,H){return B.call(p(K),H)})),f))for(;w<k;w++)f(c[w],I,L?y:y.call(c[w],w,f(c[w],I)));return T?c:B?f.call(c):k?f(c[0],I):x},rt=/^-ms-/,it=/-([a-z])/g;function At(c,f){return f.toUpperCase()}function at(c){return c.replace(rt,"ms-").replace(it,At)}var Bt=function(c){return c.nodeType===1||c.nodeType===9||!+c.nodeType};function nt(){this.expando=p.expando+nt.uid++}nt.uid=1,nt.prototype={cache:function(c){var f=c[this.expando];return f||(f={},Bt(c)&&(c.nodeType?c[this.expando]=f:Object.defineProperty(c,this.expando,{value:f,configurable:!0}))),f},set:function(c,f,I){var y,T=this.cache(c);if(typeof f=="string")T[at(f)]=I;else for(y in f)T[at(y)]=f[y];return T},get:function(c,f){return f===void 0?this.cache(c):c[this.expando]&&c[this.expando][at(f)]},access:function(c,f,I){return f===void 0||f&&typeof f=="string"&&I===void 0?this.get(c,f):(this.set(c,f,I),I!==void 0?I:f)},remove:function(c,f){var I,y=c[this.expando];if(y!==void 0){if(f!==void 0)for(Array.isArray(f)?f=f.map(at):(f=at(f),f=f in y?[f]:f.match(Ye)||[]),I=f.length;I--;)delete y[f[I]];(f===void 0||p.isEmptyObject(y))&&(c.nodeType?c[this.expando]=void 0:delete c[this.expando])}},hasData:function(c){var f=c[this.expando];return f!==void 0&&!p.isEmptyObject(f)}};var ue=new nt,Ze=new nt,xt=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,ft=/[A-Z]/g;function li(c){return c==="true"?!0:c==="false"?!1:c==="null"?null:c===+c+""?+c:xt.test(c)?JSON.parse(c):c}function Gt(c,f,I){var y;if(I===void 0&&c.nodeType===1)if(y="data-"+f.replace(ft,"-$&").toLowerCase(),I=c.getAttribute(y),typeof I=="string"){try{I=li(I)}catch{}Ze.set(c,f,I)}else I=void 0;return I}p.extend({hasData:function(c){return Ze.hasData(c)||ue.hasData(c)},data:function(c,f,I){return Ze.access(c,f,I)},removeData:function(c,f){Ze.remove(c,f)},_data:function(c,f,I){return ue.access(c,f,I)},_removeData:function(c,f){ue.remove(c,f)}}),p.fn.extend({data:function(c,f){var I,y,T,x=this[0],L=x&&x.attributes;if(c===void 0){if(this.length&&(T=Ze.get(x),x.nodeType===1&&!ue.get(x,"hasDataAttrs"))){for(I=L.length;I--;)L[I]&&(y=L[I].name,y.indexOf("data-")===0&&(y=at(y.slice(5)),Gt(x,y,T[y])));ue.set(x,"hasDataAttrs",!0)}return T}return typeof c=="object"?this.each(function(){Ze.set(this,c)}):Re(this,function(w){var k;if(x&&w===void 0)return k=Ze.get(x,c),k!==void 0||(k=Gt(x,c),k!==void 0)?k:void 0;this.each(function(){Ze.set(this,c,w)})},null,f,arguments.length>1,null,!0)},removeData:function(c){return this.each(function(){Ze.remove(this,c)})}}),p.extend({queue:function(c,f,I){var y;if(c)return f=(f||"fx")+"queue",y=ue.get(c,f),I&&(!y||Array.isArray(I)?y=ue.access(c,f,p.makeArray(I)):y.push(I)),y||[]},dequeue:function(c,f){f=f||"fx";var I=p.queue(c,f),y=I.length,T=I.shift(),x=p._queueHooks(c,f),L=function(){p.dequeue(c,f)};T==="inprogress"&&(T=I.shift(),y--),T&&(f==="fx"&&I.unshift("inprogress"),delete x.stop,T.call(c,L,x)),!y&&x&&x.empty.fire()},_queueHooks:function(c,f){var I=f+"queueHooks";return ue.get(c,I)||ue.access(c,I,{empty:p.Callbacks("once memory").add(function(){ue.remove(c,[f+"queue",I])})})}}),p.fn.extend({queue:function(c,f){var I=2;return typeof c!="string"&&(f=c,c="fx",I--),arguments.length<I?p.queue(this[0],c):f===void 0?this:this.each(function(){var y=p.queue(this,c,f);p._queueHooks(this,c),c==="fx"&&y[0]!=="inprogress"&&p.dequeue(this,c)})},dequeue:function(c){return this.each(function(){p.dequeue(this,c)})},clearQueue:function(c){return this.queue(c||"fx",[])},promise:function(c,f){var I,y=1,T=p.Deferred(),x=this,L=this.length,w=function(){--y||T.resolveWith(x,[x])};for(typeof c!="string"&&(f=c,c=void 0),c=c||"fx";L--;)I=ue.get(x[L],c+"queueHooks"),I&&I.empty&&(y++,I.empty.add(w));return w(),T.promise(f)}});var Dt=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,Di=new RegExp("^(?:([+-])=|)("+Dt+")([a-z%]*)$","i"),Ii=["Top","Right","Bottom","Left"],Bi=S.documentElement,ts=function(c){return p.contains(c.ownerDocument,c)},zm={composed:!0};Bi.getRootNode&&(ts=function(c){return p.contains(c.ownerDocument,c)||c.getRootNode(zm)===c.ownerDocument});var wn=function(c,f){return c=f||c,c.style.display==="none"||c.style.display===""&&ts(c)&&p.css(c,"display")==="none"};function mc(c,f,I,y){var T,x,L=20,w=y?function(){return y.cur()}:function(){return p.css(c,f,"")},k=w(),B=I&&I[3]||(p.cssNumber[f]?"":"px"),K=c.nodeType&&(p.cssNumber[f]||B!=="px"&&+k)&&Di.exec(p.css(c,f));if(K&&K[3]!==B){for(k=k/2,B=B||K[3],K=+k||1;L--;)p.style(c,f,K+B),(1-x)*(1-(x=w()/k||.5))<=0&&(L=0),K=K/x;K=K*2,p.style(c,f,K+B),I=I||[]}return I&&(K=+K||+k||0,T=I[1]?K+(I[1]+1)*I[2]:+I[2],y&&(y.unit=B,y.start=K,y.end=T)),T}var Ac={};function Xm(c){var f,I=c.ownerDocument,y=c.nodeName,T=Ac[y];return T||(f=I.body.appendChild(I.createElement(y)),T=p.css(f,"display"),f.parentNode.removeChild(f),T==="none"&&(T="block"),Ac[y]=T,T)}function is(c,f){for(var I,y,T=[],x=0,L=c.length;x<L;x++)y=c[x],y.style&&(I=y.style.display,f?(I==="none"&&(T[x]=ue.get(y,"display")||null,T[x]||(y.style.display="")),y.style.display===""&&wn(y)&&(T[x]=Xm(y))):I!=="none"&&(T[x]="none",ue.set(y,"display",I)));for(x=0;x<L;x++)T[x]!=null&&(c[x].style.display=T[x]);return c}p.fn.extend({show:function(){return is(this,!0)},hide:function(){return is(this)},toggle:function(c){return typeof c=="boolean"?c?this.show():this.hide():this.each(function(){wn(this)?p(this).show():p(this).hide()})}});var ws=/^(?:checkbox|radio)$/i,Ic=/<([a-z][^\/\0>\x20\t\r\n\f]*)/i,Cc=/^$|^module$|\/(?:java|ecma)script/i;(function(){var c=S.createDocumentFragment(),f=c.appendChild(S.createElement("div")),I=S.createElement("input");I.setAttribute("type","radio"),I.setAttribute("checked","checked"),I.setAttribute("name","t"),f.appendChild(I),A.checkClone=f.cloneNode(!0).cloneNode(!0).lastChild.checked,f.innerHTML="<textarea>x</textarea>",A.noCloneChecked=!!f.cloneNode(!0).lastChild.defaultValue,f.innerHTML="<option></option>",A.option=!!f.lastChild})();var Ht={thead:[1,"<table>","</table>"],col:[2,"<table><colgroup>","</colgroup></table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:[0,"",""]};Ht.tbody=Ht.tfoot=Ht.colgroup=Ht.caption=Ht.thead,Ht.th=Ht.td,A.option||(Ht.optgroup=Ht.option=[1,"<select multiple='multiple'>","</select>"]);function Pt(c,f){var I;return typeof c.getElementsByTagName<"u"?I=c.getElementsByTagName(f||"*"):typeof c.querySelectorAll<"u"?I=c.querySelectorAll(f||"*"):I=[],f===void 0||f&&N(c,f)?p.merge([c],I):I}function pa(c,f){for(var I=0,y=c.length;I<y;I++)ue.set(c[I],"globalEval",!f||ue.get(f[I],"globalEval"))}var Zm=/<|&#?\w+;/;function yc(c,f,I,y,T){for(var x,L,w,k,B,K,X=f.createDocumentFragment(),H=[],ie=0,De=c.length;ie<De;ie++)if(x=c[ie],x||x===0)if(D(x)==="object")p.merge(H,x.nodeType?[x]:x);else if(!Zm.test(x))H.push(f.createTextNode(x));else{for(L=L||X.appendChild(f.createElement("div")),w=(Ic.exec(x)||["",""])[1].toLowerCase(),k=Ht[w]||Ht._default,L.innerHTML=k[1]+p.htmlPrefilter(x)+k[2],K=k[0];K--;)L=L.lastChild;p.merge(H,L.childNodes),L=X.firstChild,L.textContent=""}for(X.textContent="",ie=0;x=H[ie++];){if(y&&p.inArray(x,y)>-1){T&&T.push(x);continue}if(B=ts(x),L=Pt(X.appendChild(x),"script"),B&&pa(L),I)for(K=0;x=L[K++];)Cc.test(x.type||"")&&I.push(x)}return X}var vc=/^([^.]*)(?:\.(.+)|)/;function ss(){return!0}function ns(){return!1}function ma(c,f,I,y,T,x){var L,w;if(typeof f=="object"){typeof I!="string"&&(y=y||I,I=void 0);for(w in f)ma(c,w,I,y,f[w],x);return c}if(y==null&&T==null?(T=I,y=I=void 0):T==null&&(typeof I=="string"?(T=y,y=void 0):(T=y,y=I,I=void 0)),T===!1)T=ns;else if(!T)return c;return x===1&&(L=T,T=function(k){return p().off(k),L.apply(this,arguments)},T.guid=L.guid||(L.guid=p.guid++)),c.each(function(){p.event.add(this,f,T,y,I)})}p.event={global:{},add:function(c,f,I,y,T){var x,L,w,k,B,K,X,H,ie,De,$e,Me=ue.get(c);if(Bt(c))for(I.handler&&(x=I,I=x.handler,T=x.selector),T&&p.find.matchesSelector(Bi,T),I.guid||(I.guid=p.guid++),(k=Me.events)||(k=Me.events=Object.create(null)),(L=Me.handle)||(L=Me.handle=function(It){return typeof p<"u"&&p.event.triggered!==It.type?p.event.dispatch.apply(c,arguments):void 0}),f=(f||"").match(Ye)||[""],B=f.length;B--;)w=vc.exec(f[B])||[],ie=$e=w[1],De=(w[2]||"").split(".").sort(),ie&&(X=p.event.special[ie]||{},ie=(T?X.delegateType:X.bindType)||ie,X=p.event.special[ie]||{},K=p.extend({type:ie,origType:$e,data:y,handler:I,guid:I.guid,selector:T,needsContext:T&&p.expr.match.needsContext.test(T),namespace:De.join(".")},x),(H=k[ie])||(H=k[ie]=[],H.delegateCount=0,(!X.setup||X.setup.call(c,y,De,L)===!1)&&c.addEventListener&&c.addEventListener(ie,L)),X.add&&(X.add.call(c,K),K.handler.guid||(K.handler.guid=I.guid)),T?H.splice(H.delegateCount++,0,K):H.push(K),p.event.global[ie]=!0)},remove:function(c,f,I,y,T){var x,L,w,k,B,K,X,H,ie,De,$e,Me=ue.hasData(c)&&ue.get(c);if(!(!Me||!(k=Me.events))){for(f=(f||"").match(Ye)||[""],B=f.length;B--;){if(w=vc.exec(f[B])||[],ie=$e=w[1],De=(w[2]||"").split(".").sort(),!ie){for(ie in k)p.event.remove(c,ie+f[B],I,y,!0);continue}for(X=p.event.special[ie]||{},ie=(y?X.delegateType:X.bindType)||ie,H=k[ie]||[],w=w[2]&&new RegExp("(^|\\.)"+De.join("\\.(?:.*\\.|)")+"(\\.|$)"),L=x=H.length;x--;)K=H[x],(T||$e===K.origType)&&(!I||I.guid===K.guid)&&(!w||w.test(K.namespace))&&(!y||y===K.selector||y==="**"&&K.selector)&&(H.splice(x,1),K.selector&&H.delegateCount--,X.remove&&X.remove.call(c,K));L&&!H.length&&((!X.teardown||X.teardown.call(c,De,Me.handle)===!1)&&p.removeEvent(c,ie,Me.handle),delete k[ie])}p.isEmptyObject(k)&&ue.remove(c,"handle events")}},dispatch:function(c){var f,I,y,T,x,L,w=new Array(arguments.length),k=p.event.fix(c),B=(ue.get(this,"events")||Object.create(null))[k.type]||[],K=p.event.special[k.type]||{};for(w[0]=k,f=1;f<arguments.length;f++)w[f]=arguments[f];if(k.delegateTarget=this,!(K.preDispatch&&K.preDispatch.call(this,k)===!1)){for(L=p.event.handlers.call(this,k,B),f=0;(T=L[f++])&&!k.isPropagationStopped();)for(k.currentTarget=T.elem,I=0;(x=T.handlers[I++])&&!k.isImmediatePropagationStopped();)(!k.rnamespace||x.namespace===!1||k.rnamespace.test(x.namespace))&&(k.handleObj=x,k.data=x.data,y=((p.event.special[x.origType]||{}).handle||x.handler).apply(T.elem,w),y!==void 0&&(k.result=y)===!1&&(k.preventDefault(),k.stopPropagation()));return K.postDispatch&&K.postDispatch.call(this,k),k.result}},handlers:function(c,f){var I,y,T,x,L,w=[],k=f.delegateCount,B=c.target;if(k&&B.nodeType&&!(c.type==="click"&&c.button>=1)){for(;B!==this;B=B.parentNode||this)if(B.nodeType===1&&!(c.type==="click"&&B.disabled===!0)){for(x=[],L={},I=0;I<k;I++)y=f[I],T=y.selector+" ",L[T]===void 0&&(L[T]=y.needsContext?p(T,this).index(B)>-1:p.find(T,this,null,[B]).length),L[T]&&x.push(y);x.length&&w.push({elem:B,handlers:x})}}return B=this,k<f.length&&w.push({elem:B,handlers:f.slice(k)}),w},addProp:function(c,f){Object.defineProperty(p.Event.prototype,c,{enumerable:!0,configurable:!0,get:C(f)?function(){if(this.originalEvent)return f(this.originalEvent)}:function(){if(this.originalEvent)return this.originalEvent[c]},set:function(I){Object.defineProperty(this,c,{enumerable:!0,configurable:!0,writable:!0,value:I})}})},fix:function(c){return c[p.expando]?c:new p.Event(c)},special:{load:{noBubble:!0},click:{setup:function(c){var f=this||c;return ws.test(f.type)&&f.click&&N(f,"input")&&Mn(f,"click",!0),!1},trigger:function(c){var f=this||c;return ws.test(f.type)&&f.click&&N(f,"input")&&Mn(f,"click"),!0},_default:function(c){var f=c.target;return ws.test(f.type)&&f.click&&N(f,"input")&&ue.get(f,"click")||N(f,"a")}},beforeunload:{postDispatch:function(c){c.result!==void 0&&c.originalEvent&&(c.originalEvent.returnValue=c.result)}}}};function Mn(c,f,I){if(!I){ue.get(c,f)===void 0&&p.event.add(c,f,ss);return}ue.set(c,f,!1),p.event.add(c,f,{namespace:!1,handler:function(y){var T,x=ue.get(this,f);if(y.isTrigger&1&&this[f]){if(x)(p.event.special[f]||{}).delegateType&&y.stopPropagation();else if(x=n.call(arguments),ue.set(this,f,x),this[f](),T=ue.get(this,f),ue.set(this,f,!1),x!==T)return y.stopImmediatePropagation(),y.preventDefault(),T}else x&&(ue.set(this,f,p.event.trigger(x[0],x.slice(1),this)),y.stopPropagation(),y.isImmediatePropagationStopped=ss)}})}p.removeEvent=function(c,f,I){c.removeEventListener&&c.removeEventListener(f,I)},p.Event=function(c,f){if(!(this instanceof p.Event))return new p.Event(c,f);c&&c.type?(this.originalEvent=c,this.type=c.type,this.isDefaultPrevented=c.defaultPrevented||c.defaultPrevented===void 0&&c.returnValue===!1?ss:ns,this.target=c.target&&c.target.nodeType===3?c.target.parentNode:c.target,this.currentTarget=c.currentTarget,this.relatedTarget=c.relatedTarget):this.type=c,f&&p.extend(this,f),this.timeStamp=c&&c.timeStamp||Date.now(),this[p.expando]=!0},p.Event.prototype={constructor:p.Event,isDefaultPrevented:ns,isPropagationStopped:ns,isImmediatePropagationStopped:ns,isSimulated:!1,preventDefault:function(){var c=this.originalEvent;this.isDefaultPrevented=ss,c&&!this.isSimulated&&c.preventDefault()},stopPropagation:function(){var c=this.originalEvent;this.isPropagationStopped=ss,c&&!this.isSimulated&&c.stopPropagation()},stopImmediatePropagation:function(){var c=this.originalEvent;this.isImmediatePropagationStopped=ss,c&&!this.isSimulated&&c.stopImmediatePropagation(),this.stopPropagation()}},p.each({altKey:!0,bubbles:!0,cancelable:!0,changedTouches:!0,ctrlKey:!0,detail:!0,eventPhase:!0,metaKey:!0,pageX:!0,pageY:!0,shiftKey:!0,view:!0,char:!0,code:!0,charCode:!0,key:!0,keyCode:!0,button:!0,buttons:!0,clientX:!0,clientY:!0,offsetX:!0,offsetY:!0,pointerId:!0,pointerType:!0,screenX:!0,screenY:!0,targetTouches:!0,toElement:!0,touches:!0,which:!0},p.event.addProp),p.each({focus:"focusin",blur:"focusout"},function(c,f){function I(y){if(S.documentMode){var T=ue.get(this,"handle"),x=p.event.fix(y);x.type=y.type==="focusin"?"focus":"blur",x.isSimulated=!0,T(y),x.target===x.currentTarget&&T(x)}else p.event.simulate(f,y.target,p.event.fix(y))}p.event.special[c]={setup:function(){var y;if(Mn(this,c,!0),S.documentMode)y=ue.get(this,f),y||this.addEventListener(f,I),ue.set(this,f,(y||0)+1);else return!1},trigger:function(){return Mn(this,c),!0},teardown:function(){var y;if(S.documentMode)y=ue.get(this,f)-1,y?ue.set(this,f,y):(this.removeEventListener(f,I),ue.remove(this,f));else return!1},_default:function(y){return ue.get(y.target,c)},delegateType:f},p.event.special[f]={setup:function(){var y=this.ownerDocument||this.document||this,T=S.documentMode?this:y,x=ue.get(T,f);x||(S.documentMode?this.addEventListener(f,I):y.addEventListener(c,I,!0)),ue.set(T,f,(x||0)+1)},teardown:function(){var y=this.ownerDocument||this.document||this,T=S.documentMode?this:y,x=ue.get(T,f)-1;x?ue.set(T,f,x):(S.documentMode?this.removeEventListener(f,I):y.removeEventListener(c,I,!0),ue.remove(T,f))}}}),p.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},function(c,f){p.event.special[c]={delegateType:f,bindType:f,handle:function(I){var y,T=this,x=I.relatedTarget,L=I.handleObj;return(!x||x!==T&&!p.contains(T,x))&&(I.type=L.origType,y=L.handler.apply(this,arguments),I.type=f),y}}}),p.fn.extend({on:function(c,f,I,y){return ma(this,c,f,I,y)},one:function(c,f,I,y){return ma(this,c,f,I,y,1)},off:function(c,f,I){var y,T;if(c&&c.preventDefault&&c.handleObj)return y=c.handleObj,p(c.delegateTarget).off(y.namespace?y.origType+"."+y.namespace:y.origType,y.selector,y.handler),this;if(typeof c=="object"){for(T in c)this.off(T,f,c[T]);return this}return(f===!1||typeof f=="function")&&(I=f,f=void 0),I===!1&&(I=ns),this.each(function(){p.event.remove(this,c,I,f)})}});var Qm=/<script|<style|<link/i,Jm=/checked\s*(?:[^=]|=\s*.checked.)/i,e0=/^\s*<!\[CDATA\[|\]\]>\s*$/g;function Ec(c,f){return N(c,"table")&&N(f.nodeType!==11?f:f.firstChild,"tr")&&p(c).children("tbody")[0]||c}function t0(c){return c.type=(c.getAttribute("type")!==null)+"/"+c.type,c}function i0(c){return(c.type||"").slice(0,5)==="true/"?c.type=c.type.slice(5):c.removeAttribute("type"),c}function Tc(c,f){var I,y,T,x,L,w,k;if(f.nodeType===1){if(ue.hasData(c)&&(x=ue.get(c),k=x.events,k)){ue.remove(f,"handle events");for(T in k)for(I=0,y=k[T].length;I<y;I++)p.event.add(f,T,k[T][I])}Ze.hasData(c)&&(L=Ze.access(c),w=p.extend({},L),Ze.set(f,w))}}function s0(c,f){var I=f.nodeName.toLowerCase();I==="input"&&ws.test(c.type)?f.checked=c.checked:(I==="input"||I==="textarea")&&(f.defaultValue=c.defaultValue)}function rs(c,f,I,y){f=a(f);var T,x,L,w,k,B,K=0,X=c.length,H=X-1,ie=f[0],De=C(ie);if(De||X>1&&typeof ie=="string"&&!A.checkClone&&Jm.test(ie))return c.each(function($e){var Me=c.eq($e);De&&(f[0]=ie.call(this,$e,Me.html())),rs(Me,f,I,y)});if(X&&(T=yc(f,c[0].ownerDocument,!1,c,y),x=T.firstChild,T.childNodes.length===1&&(T=x),x||y)){for(L=p.map(Pt(T,"script"),t0),w=L.length;K<X;K++)k=T,K!==H&&(k=p.clone(k,!0,!0),w&&p.merge(L,Pt(k,"script"))),I.call(c[K],k,K);if(w)for(B=L[L.length-1].ownerDocument,p.map(L,i0),K=0;K<w;K++)k=L[K],Cc.test(k.type||"")&&!ue.access(k,"globalEval")&&p.contains(B,k)&&(k.src&&(k.type||"").toLowerCase()!=="module"?p._evalUrl&&!k.noModule&&p._evalUrl(k.src,{nonce:k.nonce||k.getAttribute("nonce")},B):b(k.textContent.replace(e0,""),k,B))}return c}function Sc(c,f,I){for(var y,T=f?p.filter(f,c):c,x=0;(y=T[x])!=null;x++)!I&&y.nodeType===1&&p.cleanData(Pt(y)),y.parentNode&&(I&&ts(y)&&pa(Pt(y,"script")),y.parentNode.removeChild(y));return c}p.extend({htmlPrefilter:function(c){return c},clone:function(c,f,I){var y,T,x,L,w=c.cloneNode(!0),k=ts(c);if(!A.noCloneChecked&&(c.nodeType===1||c.nodeType===11)&&!p.isXMLDoc(c))for(L=Pt(w),x=Pt(c),y=0,T=x.length;y<T;y++)s0(x[y],L[y]);if(f)if(I)for(x=x||Pt(c),L=L||Pt(w),y=0,T=x.length;y<T;y++)Tc(x[y],L[y]);else Tc(c,w);return L=Pt(w,"script"),L.length>0&&pa(L,!k&&Pt(c,"script")),w},cleanData:function(c){for(var f,I,y,T=p.event.special,x=0;(I=c[x])!==void 0;x++)if(Bt(I)){if(f=I[ue.expando]){if(f.events)for(y in f.events)T[y]?p.event.remove(I,y):p.removeEvent(I,y,f.handle);I[ue.expando]=void 0}I[Ze.expando]&&(I[Ze.expando]=void 0)}}}),p.fn.extend({detach:function(c){return Sc(this,c,!0)},remove:function(c){return Sc(this,c)},text:function(c){return Re(this,function(f){return f===void 0?p.text(this):this.empty().each(function(){(this.nodeType===1||this.nodeType===11||this.nodeType===9)&&(this.textContent=f)})},null,c,arguments.length)},append:function(){return rs(this,arguments,function(c){if(this.nodeType===1||this.nodeType===11||this.nodeType===9){var f=Ec(this,c);f.appendChild(c)}})},prepend:function(){return rs(this,arguments,function(c){if(this.nodeType===1||this.nodeType===11||this.nodeType===9){var f=Ec(this,c);f.insertBefore(c,f.firstChild)}})},before:function(){return rs(this,arguments,function(c){this.parentNode&&this.parentNode.insertBefore(c,this)})},after:function(){return rs(this,arguments,function(c){this.parentNode&&this.parentNode.insertBefore(c,this.nextSibling)})},empty:function(){for(var c,f=0;(c=this[f])!=null;f++)c.nodeType===1&&(p.cleanData(Pt(c,!1)),c.textContent="");return this},clone:function(c,f){return c=c??!1,f=f??c,this.map(function(){return p.clone(this,c,f)})},html:function(c){return Re(this,function(f){var I=this[0]||{},y=0,T=this.length;if(f===void 0&&I.nodeType===1)return I.innerHTML;if(typeof f=="string"&&!Qm.test(f)&&!Ht[(Ic.exec(f)||["",""])[1].toLowerCase()]){f=p.htmlPrefilter(f);try{for(;y<T;y++)I=this[y]||{},I.nodeType===1&&(p.cleanData(Pt(I,!1)),I.innerHTML=f);I=0}catch{}}I&&this.empty().append(f)},null,c,arguments.length)},replaceWith:function(){var c=[];return rs(this,arguments,function(f){var I=this.parentNode;p.inArray(this,c)<0&&(p.cleanData(Pt(this)),I&&I.replaceChild(f,this))},c)}}),p.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(c,f){p.fn[c]=function(I){for(var y,T=[],x=p(I),L=x.length-1,w=0;w<=L;w++)y=w===L?this:this.clone(!0),p(x[w])[f](y),o.apply(T,y.get());return this.pushStack(T)}});var Aa=new RegExp("^("+Dt+")(?!px)[a-z%]+$","i"),Ia=/^--/,On=function(c){var f=c.ownerDocument.defaultView;return(!f||!f.opener)&&(f=e),f.getComputedStyle(c)},xc=function(c,f,I){var y,T,x={};for(T in f)x[T]=c.style[T],c.style[T]=f[T];y=I.call(c);for(T in f)c.style[T]=x[T];return y},n0=new RegExp(Ii.join("|"),"i");(function(){function c(){if(B){k.style.cssText="position:absolute;left:-11111px;width:60px;margin-top:1px;padding:0;border:0",B.style.cssText="position:relative;display:block;box-sizing:border-box;overflow:scroll;margin:auto;border:1px;padding:1px;width:60%;top:1%",Bi.appendChild(k).appendChild(B);var K=e.getComputedStyle(B);I=K.top!=="1%",w=f(K.marginLeft)===12,B.style.right="60%",x=f(K.right)===36,y=f(K.width)===36,B.style.position="absolute",T=f(B.offsetWidth/3)===12,Bi.removeChild(k),B=null}}function f(K){return Math.round(parseFloat(K))}var I,y,T,x,L,w,k=S.createElement("div"),B=S.createElement("div");B.style&&(B.style.backgroundClip="content-box",B.cloneNode(!0).style.backgroundClip="",A.clearCloneStyle=B.style.backgroundClip==="content-box",p.extend(A,{boxSizingReliable:function(){return c(),y},pixelBoxStyles:function(){return c(),x},pixelPosition:function(){return c(),I},reliableMarginLeft:function(){return c(),w},scrollboxSize:function(){return c(),T},reliableTrDimensions:function(){var K,X,H,ie;return L==null&&(K=S.createElement("table"),X=S.createElement("tr"),H=S.createElement("div"),K.style.cssText="position:absolute;left:-11111px;border-collapse:separate",X.style.cssText="box-sizing:content-box;border:1px solid",X.style.height="1px",H.style.height="9px",H.style.display="block",Bi.appendChild(K).appendChild(X).appendChild(H),ie=e.getComputedStyle(X),L=parseInt(ie.height,10)+parseInt(ie.borderTopWidth,10)+parseInt(ie.borderBottomWidth,10)===X.offsetHeight,Bi.removeChild(K)),L}}))})();function Ms(c,f,I){var y,T,x,L,w=Ia.test(f),k=c.style;return I=I||On(c),I&&(L=I.getPropertyValue(f)||I[f],w&&L&&(L=L.replace(oe,"$1")||void 0),L===""&&!ts(c)&&(L=p.style(c,f)),!A.pixelBoxStyles()&&Aa.test(L)&&n0.test(f)&&(y=k.width,T=k.minWidth,x=k.maxWidth,k.minWidth=k.maxWidth=k.width=L,L=I.width,k.width=y,k.minWidth=T,k.maxWidth=x)),L!==void 0?L+"":L}function bc(c,f){return{get:function(){if(c()){delete this.get;return}return(this.get=f).apply(this,arguments)}}}var Lc=["Webkit","Moz","ms"],Rc=S.createElement("div").style,Dc={};function r0(c){for(var f=c[0].toUpperCase()+c.slice(1),I=Lc.length;I--;)if(c=Lc[I]+f,c in Rc)return c}function Ca(c){var f=p.cssProps[c]||Dc[c];return f||(c in Rc?c:Dc[c]=r0(c)||c)}var a0=/^(none|table(?!-c[ea]).+)/,o0={position:"absolute",visibility:"hidden",display:"block"},Pc={letterSpacing:"0",fontWeight:"400"};function _c(c,f,I){var y=Di.exec(f);return y?Math.max(0,y[2]-(I||0))+(y[3]||"px"):f}function ya(c,f,I,y,T,x){var L=f==="width"?1:0,w=0,k=0,B=0;if(I===(y?"border":"content"))return 0;for(;L<4;L+=2)I==="margin"&&(B+=p.css(c,I+Ii[L],!0,T)),y?(I==="content"&&(k-=p.css(c,"padding"+Ii[L],!0,T)),I!=="margin"&&(k-=p.css(c,"border"+Ii[L]+"Width",!0,T))):(k+=p.css(c,"padding"+Ii[L],!0,T),I!=="padding"?k+=p.css(c,"border"+Ii[L]+"Width",!0,T):w+=p.css(c,"border"+Ii[L]+"Width",!0,T));return!y&&x>=0&&(k+=Math.max(0,Math.ceil(c["offset"+f[0].toUpperCase()+f.slice(1)]-x-k-w-.5))||0),k+B}function kc(c,f,I){var y=On(c),T=!A.boxSizingReliable()||I,x=T&&p.css(c,"boxSizing",!1,y)==="border-box",L=x,w=Ms(c,f,y),k="offset"+f[0].toUpperCase()+f.slice(1);if(Aa.test(w)){if(!I)return w;w="auto"}return(!A.boxSizingReliable()&&x||!A.reliableTrDimensions()&&N(c,"tr")||w==="auto"||!parseFloat(w)&&p.css(c,"display",!1,y)==="inline")&&c.getClientRects().length&&(x=p.css(c,"boxSizing",!1,y)==="border-box",L=k in c,L&&(w=c[k])),w=parseFloat(w)||0,w+ya(c,f,I||(x?"border":"content"),L,y,w)+"px"}p.extend({cssHooks:{opacity:{get:function(c,f){if(f){var I=Ms(c,"opacity");return I===""?"1":I}}}},cssNumber:{animationIterationCount:!0,aspectRatio:!0,borderImageSlice:!0,columnCount:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,gridArea:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnStart:!0,gridRow:!0,gridRowEnd:!0,gridRowStart:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,scale:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeMiterlimit:!0,strokeOpacity:!0},cssProps:{},style:function(c,f,I,y){if(!(!c||c.nodeType===3||c.nodeType===8||!c.style)){var T,x,L,w=at(f),k=Ia.test(f),B=c.style;if(k||(f=Ca(w)),L=p.cssHooks[f]||p.cssHooks[w],I!==void 0){if(x=typeof I,x==="string"&&(T=Di.exec(I))&&T[1]&&(I=mc(c,f,T),x="number"),I==null||I!==I)return;x==="number"&&!k&&(I+=T&&T[3]||(p.cssNumber[w]?"":"px")),!A.clearCloneStyle&&I===""&&f.indexOf("background")===0&&(B[f]="inherit"),(!L||!("set"in L)||(I=L.set(c,I,y))!==void 0)&&(k?B.setProperty(f,I):B[f]=I)}else return L&&"get"in L&&(T=L.get(c,!1,y))!==void 0?T:B[f]}},css:function(c,f,I,y){var T,x,L,w=at(f),k=Ia.test(f);return k||(f=Ca(w)),L=p.cssHooks[f]||p.cssHooks[w],L&&"get"in L&&(T=L.get(c,!0,I)),T===void 0&&(T=Ms(c,f,y)),T==="normal"&&f in Pc&&(T=Pc[f]),I===""||I?(x=parseFloat(T),I===!0||isFinite(x)?x||0:T):T}}),p.each(["height","width"],function(c,f){p.cssHooks[f]={get:function(I,y,T){if(y)return a0.test(p.css(I,"display"))&&(!I.getClientRects().length||!I.getBoundingClientRect().width)?xc(I,o0,function(){return kc(I,f,T)}):kc(I,f,T)},set:function(I,y,T){var x,L=On(I),w=!A.scrollboxSize()&&L.position==="absolute",k=w||T,B=k&&p.css(I,"boxSizing",!1,L)==="border-box",K=T?ya(I,f,T,B,L):0;return B&&w&&(K-=Math.ceil(I["offset"+f[0].toUpperCase()+f.slice(1)]-parseFloat(L[f])-ya(I,f,"border",!1,L)-.5)),K&&(x=Di.exec(y))&&(x[3]||"px")!=="px"&&(I.style[f]=y,y=p.css(I,f)),_c(I,y,K)}}}),p.cssHooks.marginLeft=bc(A.reliableMarginLeft,function(c,f){if(f)return(parseFloat(Ms(c,"marginLeft"))||c.getBoundingClientRect().left-xc(c,{marginLeft:0},function(){return c.getBoundingClientRect().left}))+"px"}),p.each({margin:"",padding:"",border:"Width"},function(c,f){p.cssHooks[c+f]={expand:function(I){for(var y=0,T={},x=typeof I=="string"?I.split(" "):[I];y<4;y++)T[c+Ii[y]+f]=x[y]||x[y-2]||x[0];return T}},c!=="margin"&&(p.cssHooks[c+f].set=_c)}),p.fn.extend({css:function(c,f){return Re(this,function(I,y,T){var x,L,w={},k=0;if(Array.isArray(y)){for(x=On(I),L=y.length;k<L;k++)w[y[k]]=p.css(I,y[k],!1,x);return w}return T!==void 0?p.style(I,y,T):p.css(I,y)},c,f,arguments.length>1)}});function _t(c,f,I,y,T){return new _t.prototype.init(c,f,I,y,T)}p.Tween=_t,_t.prototype={constructor:_t,init:function(c,f,I,y,T,x){this.elem=c,this.prop=I,this.easing=T||p.easing._default,this.options=f,this.start=this.now=this.cur(),this.end=y,this.unit=x||(p.cssNumber[I]?"":"px")},cur:function(){var c=_t.propHooks[this.prop];return c&&c.get?c.get(this):_t.propHooks._default.get(this)},run:function(c){var f,I=_t.propHooks[this.prop];return this.options.duration?this.pos=f=p.easing[this.easing](c,this.options.duration*c,0,1,this.options.duration):this.pos=f=c,this.now=(this.end-this.start)*f+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),I&&I.set?I.set(this):_t.propHooks._default.set(this),this}},_t.prototype.init.prototype=_t.prototype,_t.propHooks={_default:{get:function(c){var f;return c.elem.nodeType!==1||c.elem[c.prop]!=null&&c.elem.style[c.prop]==null?c.elem[c.prop]:(f=p.css(c.elem,c.prop,""),!f||f==="auto"?0:f)},set:function(c){p.fx.step[c.prop]?p.fx.step[c.prop](c):c.elem.nodeType===1&&(p.cssHooks[c.prop]||c.elem.style[Ca(c.prop)]!=null)?p.style(c.elem,c.prop,c.now+c.unit):c.elem[c.prop]=c.now}}},_t.propHooks.scrollTop=_t.propHooks.scrollLeft={set:function(c){c.elem.nodeType&&c.elem.parentNode&&(c.elem[c.prop]=c.now)}},p.easing={linear:function(c){return c},swing:function(c){return .5-Math.cos(c*Math.PI)/2},_default:"swing"},p.fx=_t.prototype.init,p.fx.step={};var as,Fn,l0=/^(?:toggle|show|hide)$/,u0=/queueHooks$/;function va(){Fn&&(S.hidden===!1&&e.requestAnimationFrame?e.requestAnimationFrame(va):e.setTimeout(va,p.fx.interval),p.fx.tick())}function wc(){return e.setTimeout(function(){as=void 0}),as=Date.now()}function Nn(c,f){var I,y=0,T={height:c};for(f=f?1:0;y<4;y+=2-f)I=Ii[y],T["margin"+I]=T["padding"+I]=c;return f&&(T.opacity=T.width=c),T}function Mc(c,f,I){for(var y,T=(Zt.tweeners[f]||[]).concat(Zt.tweeners["*"]),x=0,L=T.length;x<L;x++)if(y=T[x].call(I,f,c))return y}function c0(c,f,I){var y,T,x,L,w,k,B,K,X="width"in f||"height"in f,H=this,ie={},De=c.style,$e=c.nodeType&&wn(c),Me=ue.get(c,"fxshow");I.queue||(L=p._queueHooks(c,"fx"),L.unqueued==null&&(L.unqueued=0,w=L.empty.fire,L.empty.fire=function(){L.unqueued||w()}),L.unqueued++,H.always(function(){H.always(function(){L.unqueued--,p.queue(c,"fx").length||L.empty.fire()})}));for(y in f)if(T=f[y],l0.test(T)){if(delete f[y],x=x||T==="toggle",T===($e?"hide":"show"))if(T==="show"&&Me&&Me[y]!==void 0)$e=!0;else continue;ie[y]=Me&&Me[y]||p.style(c,y)}if(k=!p.isEmptyObject(f),!(!k&&p.isEmptyObject(ie))){X&&c.nodeType===1&&(I.overflow=[De.overflow,De.overflowX,De.overflowY],B=Me&&Me.display,B==null&&(B=ue.get(c,"display")),K=p.css(c,"display"),K==="none"&&(B?K=B:(is([c],!0),B=c.style.display||B,K=p.css(c,"display"),is([c]))),(K==="inline"||K==="inline-block"&&B!=null)&&p.css(c,"float")==="none"&&(k||(H.done(function(){De.display=B}),B==null&&(K=De.display,B=K==="none"?"":K)),De.display="inline-block")),I.overflow&&(De.overflow="hidden",H.always(function(){De.overflow=I.overflow[0],De.overflowX=I.overflow[1],De.overflowY=I.overflow[2]})),k=!1;for(y in ie)k||(Me?"hidden"in Me&&($e=Me.hidden):Me=ue.access(c,"fxshow",{display:B}),x&&(Me.hidden=!$e),$e&&is([c],!0),H.done(function(){$e||is([c]),ue.remove(c,"fxshow");for(y in ie)p.style(c,y,ie[y])})),k=Mc($e?Me[y]:0,y,H),y in Me||(Me[y]=k.start,$e&&(k.end=k.start,k.start=0))}}function h0(c,f){var I,y,T,x,L;for(I in c)if(y=at(I),T=f[y],x=c[I],Array.isArray(x)&&(T=x[1],x=c[I]=x[0]),I!==y&&(c[y]=x,delete c[I]),L=p.cssHooks[y],L&&"expand"in L){x=L.expand(x),delete c[y];for(I in x)I in c||(c[I]=x[I],f[I]=T)}else f[y]=T}function Zt(c,f,I){var y,T,x=0,L=Zt.prefilters.length,w=p.Deferred().always(function(){delete k.elem}),k=function(){if(T)return!1;for(var X=as||wc(),H=Math.max(0,B.startTime+B.duration-X),ie=H/B.duration||0,De=1-ie,$e=0,Me=B.tweens.length;$e<Me;$e++)B.tweens[$e].run(De);return w.notifyWith(c,[B,De,H]),De<1&&Me?H:(Me||w.notifyWith(c,[B,1,0]),w.resolveWith(c,[B]),!1)},B=w.promise({elem:c,props:p.extend({},f),opts:p.extend(!0,{specialEasing:{},easing:p.easing._default},I),originalProperties:f,originalOptions:I,startTime:as||wc(),duration:I.duration,tweens:[],createTween:function(X,H){var ie=p.Tween(c,B.opts,X,H,B.opts.specialEasing[X]||B.opts.easing);return B.tweens.push(ie),ie},stop:function(X){var H=0,ie=X?B.tweens.length:0;if(T)return this;for(T=!0;H<ie;H++)B.tweens[H].run(1);return X?(w.notifyWith(c,[B,1,0]),w.resolveWith(c,[B,X])):w.rejectWith(c,[B,X]),this}}),K=B.props;for(h0(K,B.opts.specialEasing);x<L;x++)if(y=Zt.prefilters[x].call(B,c,K,B.opts),y)return C(y.stop)&&(p._queueHooks(B.elem,B.opts.queue).stop=y.stop.bind(y)),y;return p.map(K,Mc,B),C(B.opts.start)&&B.opts.start.call(c,B),B.progress(B.opts.progress).done(B.opts.done,B.opts.complete).fail(B.opts.fail).always(B.opts.always),p.fx.timer(p.extend(k,{elem:c,anim:B,queue:B.opts.queue})),B}p.Animation=p.extend(Zt,{tweeners:{"*":[function(c,f){var I=this.createTween(c,f);return mc(I.elem,c,Di.exec(f),I),I}]},tweener:function(c,f){C(c)?(f=c,c=["*"]):c=c.match(Ye);for(var I,y=0,T=c.length;y<T;y++)I=c[y],Zt.tweeners[I]=Zt.tweeners[I]||[],Zt.tweeners[I].unshift(f)},prefilters:[c0],prefilter:function(c,f){f?Zt.prefilters.unshift(c):Zt.prefilters.push(c)}}),p.speed=function(c,f,I){var y=c&&typeof c=="object"?p.extend({},c):{complete:I||!I&&f||C(c)&&c,duration:c,easing:I&&f||f&&!C(f)&&f};return p.fx.off?y.duration=0:typeof y.duration!="number"&&(y.duration in p.fx.speeds?y.duration=p.fx.speeds[y.duration]:y.duration=p.fx.speeds._default),(y.queue==null||y.queue===!0)&&(y.queue="fx"),y.old=y.complete,y.complete=function(){C(y.old)&&y.old.call(this),y.queue&&p.dequeue(this,y.queue)},y},p.fn.extend({fadeTo:function(c,f,I,y){return this.filter(wn).css("opacity",0).show().end().animate({opacity:f},c,I,y)},animate:function(c,f,I,y){var T=p.isEmptyObject(c),x=p.speed(f,I,y),L=function(){var w=Zt(this,p.extend({},c),x);(T||ue.get(this,"finish"))&&w.stop(!0)};return L.finish=L,T||x.queue===!1?this.each(L):this.queue(x.queue,L)},stop:function(c,f,I){var y=function(T){var x=T.stop;delete T.stop,x(I)};return typeof c!="string"&&(I=f,f=c,c=void 0),f&&this.queue(c||"fx",[]),this.each(function(){var T=!0,x=c!=null&&c+"queueHooks",L=p.timers,w=ue.get(this);if(x)w[x]&&w[x].stop&&y(w[x]);else for(x in w)w[x]&&w[x].stop&&u0.test(x)&&y(w[x]);for(x=L.length;x--;)L[x].elem===this&&(c==null||L[x].queue===c)&&(L[x].anim.stop(I),T=!1,L.splice(x,1));(T||!I)&&p.dequeue(this,c)})},finish:function(c){return c!==!1&&(c=c||"fx"),this.each(function(){var f,I=ue.get(this),y=I[c+"queue"],T=I[c+"queueHooks"],x=p.timers,L=y?y.length:0;for(I.finish=!0,p.queue(this,c,[]),T&&T.stop&&T.stop.call(this,!0),f=x.length;f--;)x[f].elem===this&&x[f].queue===c&&(x[f].anim.stop(!0),x.splice(f,1));for(f=0;f<L;f++)y[f]&&y[f].finish&&y[f].finish.call(this);delete I.finish})}}),p.each(["toggle","show","hide"],function(c,f){var I=p.fn[f];p.fn[f]=function(y,T,x){return y==null||typeof y=="boolean"?I.apply(this,arguments):this.animate(Nn(f,!0),y,T,x)}}),p.each({slideDown:Nn("show"),slideUp:Nn("hide"),slideToggle:Nn("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(c,f){p.fn[c]=function(I,y,T){return this.animate(f,I,y,T)}}),p.timers=[],p.fx.tick=function(){var c,f=0,I=p.timers;for(as=Date.now();f<I.length;f++)c=I[f],!c()&&I[f]===c&&I.splice(f--,1);I.length||p.fx.stop(),as=void 0},p.fx.timer=function(c){p.timers.push(c),p.fx.start()},p.fx.interval=13,p.fx.start=function(){Fn||(Fn=!0,va())},p.fx.stop=function(){Fn=null},p.fx.speeds={slow:600,fast:200,_default:400},p.fn.delay=function(c,f){return c=p.fx&&p.fx.speeds[c]||c,f=f||"fx",this.queue(f,function(I,y){var T=e.setTimeout(I,c);y.stop=function(){e.clearTimeout(T)}})},(function(){var c=S.createElement("input"),f=S.createElement("select"),I=f.appendChild(S.createElement("option"));c.type="checkbox",A.checkOn=c.value!=="",A.optSelected=I.selected,c=S.createElement("input"),c.value="t",c.type="radio",A.radioValue=c.value==="t"})();var Oc,Os=p.expr.attrHandle;p.fn.extend({attr:function(c,f){return Re(this,p.attr,c,f,arguments.length>1)},removeAttr:function(c){return this.each(function(){p.removeAttr(this,c)})}}),p.extend({attr:function(c,f,I){var y,T,x=c.nodeType;if(!(x===3||x===8||x===2)){if(typeof c.getAttribute>"u")return p.prop(c,f,I);if((x!==1||!p.isXMLDoc(c))&&(T=p.attrHooks[f.toLowerCase()]||(p.expr.match.bool.test(f)?Oc:void 0)),I!==void 0){if(I===null){p.removeAttr(c,f);return}return T&&"set"in T&&(y=T.set(c,I,f))!==void 0?y:(c.setAttribute(f,I+""),I)}return T&&"get"in T&&(y=T.get(c,f))!==null?y:(y=p.find.attr(c,f),y??void 0)}},attrHooks:{type:{set:function(c,f){if(!A.radioValue&&f==="radio"&&N(c,"input")){var I=c.value;return c.setAttribute("type",f),I&&(c.value=I),f}}}},removeAttr:function(c,f){var I,y=0,T=f&&f.match(Ye);if(T&&c.nodeType===1)for(;I=T[y++];)c.removeAttribute(I)}}),Oc={set:function(c,f,I){return f===!1?p.removeAttr(c,I):c.setAttribute(I,I),I}},p.each(p.expr.match.bool.source.match(/\w+/g),function(c,f){var I=Os[f]||p.find.attr;Os[f]=function(y,T,x){var L,w,k=T.toLowerCase();return x||(w=Os[k],Os[k]=L,L=I(y,T,x)!=null?k:null,Os[k]=w),L}});var d0=/^(?:input|select|textarea|button)$/i,f0=/^(?:a|area)$/i;p.fn.extend({prop:function(c,f){return Re(this,p.prop,c,f,arguments.length>1)},removeProp:function(c){return this.each(function(){delete this[p.propFix[c]||c]})}}),p.extend({prop:function(c,f,I){var y,T,x=c.nodeType;if(!(x===3||x===8||x===2))return(x!==1||!p.isXMLDoc(c))&&(f=p.propFix[f]||f,T=p.propHooks[f]),I!==void 0?T&&"set"in T&&(y=T.set(c,I,f))!==void 0?y:c[f]=I:T&&"get"in T&&(y=T.get(c,f))!==null?y:c[f]},propHooks:{tabIndex:{get:function(c){var f=p.find.attr(c,"tabindex");return f?parseInt(f,10):d0.test(c.nodeName)||f0.test(c.nodeName)&&c.href?0:-1}}},propFix:{for:"htmlFor",class:"className"}}),A.optSelected||(p.propHooks.selected={get:function(c){var f=c.parentNode;return f&&f.parentNode&&f.parentNode.selectedIndex,null},set:function(c){var f=c.parentNode;f&&(f.selectedIndex,f.parentNode&&f.parentNode.selectedIndex)}}),p.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){p.propFix[this.toLowerCase()]=this});function Ui(c){var f=c.match(Ye)||[];return f.join(" ")}function $i(c){return c.getAttribute&&c.getAttribute("class")||""}function Ea(c){return Array.isArray(c)?c:typeof c=="string"?c.match(Ye)||[]:[]}p.fn.extend({addClass:function(c){var f,I,y,T,x,L;return C(c)?this.each(function(w){p(this).addClass(c.call(this,w,$i(this)))}):(f=Ea(c),f.length?this.each(function(){if(y=$i(this),I=this.nodeType===1&&" "+Ui(y)+" ",I){for(x=0;x<f.length;x++)T=f[x],I.indexOf(" "+T+" ")<0&&(I+=T+" ");L=Ui(I),y!==L&&this.setAttribute("class",L)}}):this)},removeClass:function(c){var f,I,y,T,x,L;return C(c)?this.each(function(w){p(this).removeClass(c.call(this,w,$i(this)))}):arguments.length?(f=Ea(c),f.length?this.each(function(){if(y=$i(this),I=this.nodeType===1&&" "+Ui(y)+" ",I){for(x=0;x<f.length;x++)for(T=f[x];I.indexOf(" "+T+" ")>-1;)I=I.replace(" "+T+" "," ");L=Ui(I),y!==L&&this.setAttribute("class",L)}}):this):this.attr("class","")},toggleClass:function(c,f){var I,y,T,x,L=typeof c,w=L==="string"||Array.isArray(c);return C(c)?this.each(function(k){p(this).toggleClass(c.call(this,k,$i(this),f),f)}):typeof f=="boolean"&&w?f?this.addClass(c):this.removeClass(c):(I=Ea(c),this.each(function(){if(w)for(x=p(this),T=0;T<I.length;T++)y=I[T],x.hasClass(y)?x.removeClass(y):x.addClass(y);else(c===void 0||L==="boolean")&&(y=$i(this),y&&ue.set(this,"__className__",y),this.setAttribute&&this.setAttribute("class",y||c===!1?"":ue.get(this,"__className__")||""))}))},hasClass:function(c){var f,I,y=0;for(f=" "+c+" ";I=this[y++];)if(I.nodeType===1&&(" "+Ui($i(I))+" ").indexOf(f)>-1)return!0;return!1}});var g0=/\r/g;p.fn.extend({val:function(c){var f,I,y,T=this[0];return arguments.length?(y=C(c),this.each(function(x){var L;this.nodeType===1&&(y?L=c.call(this,x,p(this).val()):L=c,L==null?L="":typeof L=="number"?L+="":Array.isArray(L)&&(L=p.map(L,function(w){return w==null?"":w+""})),f=p.valHooks[this.type]||p.valHooks[this.nodeName.toLowerCase()],(!f||!("set"in f)||f.set(this,L,"value")===void 0)&&(this.value=L))})):T?(f=p.valHooks[T.type]||p.valHooks[T.nodeName.toLowerCase()],f&&"get"in f&&(I=f.get(T,"value"))!==void 0?I:(I=T.value,typeof I=="string"?I.replace(g0,""):I??"")):void 0}}),p.extend({valHooks:{option:{get:function(c){var f=p.find.attr(c,"value");return f??Ui(p.text(c))}},select:{get:function(c){var f,I,y,T=c.options,x=c.selectedIndex,L=c.type==="select-one",w=L?null:[],k=L?x+1:T.length;for(x<0?y=k:y=L?x:0;y<k;y++)if(I=T[y],(I.selected||y===x)&&!I.disabled&&(!I.parentNode.disabled||!N(I.parentNode,"optgroup"))){if(f=p(I).val(),L)return f;w.push(f)}return w},set:function(c,f){for(var I,y,T=c.options,x=p.makeArray(f),L=T.length;L--;)y=T[L],(y.selected=p.inArray(p.valHooks.option.get(y),x)>-1)&&(I=!0);return I||(c.selectedIndex=-1),x}}}}),p.each(["radio","checkbox"],function(){p.valHooks[this]={set:function(c,f){if(Array.isArray(f))return c.checked=p.inArray(p(c).val(),f)>-1}},A.checkOn||(p.valHooks[this].get=function(c){return c.getAttribute("value")===null?"on":c.value})});var Fs=e.location,Fc={guid:Date.now()},Ta=/\?/;p.parseXML=function(c){var f,I;if(!c||typeof c!="string")return null;try{f=new e.DOMParser().parseFromString(c,"text/xml")}catch{}return I=f&&f.getElementsByTagName("parsererror")[0],(!f||I)&&p.error("Invalid XML: "+(I?p.map(I.childNodes,function(y){return y.textContent}).join(`
43
+ `):c)),f};var Nc=/^(?:focusinfocus|focusoutblur)$/,Bc=function(c){c.stopPropagation()};p.extend(p.event,{trigger:function(c,f,I,y){var T,x,L,w,k,B,K,X,H=[I||S],ie=d.call(c,"type")?c.type:c,De=d.call(c,"namespace")?c.namespace.split("."):[];if(x=X=L=I=I||S,!(I.nodeType===3||I.nodeType===8)&&!Nc.test(ie+p.event.triggered)&&(ie.indexOf(".")>-1&&(De=ie.split("."),ie=De.shift(),De.sort()),k=ie.indexOf(":")<0&&"on"+ie,c=c[p.expando]?c:new p.Event(ie,typeof c=="object"&&c),c.isTrigger=y?2:3,c.namespace=De.join("."),c.rnamespace=c.namespace?new RegExp("(^|\\.)"+De.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,c.result=void 0,c.target||(c.target=I),f=f==null?[c]:p.makeArray(f,[c]),K=p.event.special[ie]||{},!(!y&&K.trigger&&K.trigger.apply(I,f)===!1))){if(!y&&!K.noBubble&&!v(I)){for(w=K.delegateType||ie,Nc.test(w+ie)||(x=x.parentNode);x;x=x.parentNode)H.push(x),L=x;L===(I.ownerDocument||S)&&H.push(L.defaultView||L.parentWindow||e)}for(T=0;(x=H[T++])&&!c.isPropagationStopped();)X=x,c.type=T>1?w:K.bindType||ie,B=(ue.get(x,"events")||Object.create(null))[c.type]&&ue.get(x,"handle"),B&&B.apply(x,f),B=k&&x[k],B&&B.apply&&Bt(x)&&(c.result=B.apply(x,f),c.result===!1&&c.preventDefault());return c.type=ie,!y&&!c.isDefaultPrevented()&&(!K._default||K._default.apply(H.pop(),f)===!1)&&Bt(I)&&k&&C(I[ie])&&!v(I)&&(L=I[k],L&&(I[k]=null),p.event.triggered=ie,c.isPropagationStopped()&&X.addEventListener(ie,Bc),I[ie](),c.isPropagationStopped()&&X.removeEventListener(ie,Bc),p.event.triggered=void 0,L&&(I[k]=L)),c.result}},simulate:function(c,f,I){var y=p.extend(new p.Event,I,{type:c,isSimulated:!0});p.event.trigger(y,null,f)}}),p.fn.extend({trigger:function(c,f){return this.each(function(){p.event.trigger(c,f,this)})},triggerHandler:function(c,f){var I=this[0];if(I)return p.event.trigger(c,f,I,!0)}});var p0=/\[\]$/,Uc=/\r?\n/g,m0=/^(?:submit|button|image|reset|file)$/i,A0=/^(?:input|select|textarea|keygen)/i;function Sa(c,f,I,y){var T;if(Array.isArray(f))p.each(f,function(x,L){I||p0.test(c)?y(c,L):Sa(c+"["+(typeof L=="object"&&L!=null?x:"")+"]",L,I,y)});else if(!I&&D(f)==="object")for(T in f)Sa(c+"["+T+"]",f[T],I,y);else y(c,f)}p.param=function(c,f){var I,y=[],T=function(x,L){var w=C(L)?L():L;y[y.length]=encodeURIComponent(x)+"="+encodeURIComponent(w??"")};if(c==null)return"";if(Array.isArray(c)||c.jquery&&!p.isPlainObject(c))p.each(c,function(){T(this.name,this.value)});else for(I in c)Sa(I,c[I],f,T);return y.join("&")},p.fn.extend({serialize:function(){return p.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var c=p.prop(this,"elements");return c?p.makeArray(c):this}).filter(function(){var c=this.type;return this.name&&!p(this).is(":disabled")&&A0.test(this.nodeName)&&!m0.test(c)&&(this.checked||!ws.test(c))}).map(function(c,f){var I=p(this).val();return I==null?null:Array.isArray(I)?p.map(I,function(y){return{name:f.name,value:y.replace(Uc,`\r
44
+ `)}}):{name:f.name,value:I.replace(Uc,`\r
45
+ `)}}).get()}});var I0=/%20/g,C0=/#.*$/,y0=/([?&])_=[^&]*/,v0=/^(.*?):[ \t]*([^\r\n]*)$/mg,E0=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,T0=/^(?:GET|HEAD)$/,S0=/^\/\//,$c={},xa={},Gc="*/".concat("*"),ba=S.createElement("a");ba.href=Fs.href;function Hc(c){return function(f,I){typeof f!="string"&&(I=f,f="*");var y,T=0,x=f.toLowerCase().match(Ye)||[];if(C(I))for(;y=x[T++];)y[0]==="+"?(y=y.slice(1)||"*",(c[y]=c[y]||[]).unshift(I)):(c[y]=c[y]||[]).push(I)}}function Vc(c,f,I,y){var T={},x=c===xa;function L(w){var k;return T[w]=!0,p.each(c[w]||[],function(B,K){var X=K(f,I,y);if(typeof X=="string"&&!x&&!T[X])return f.dataTypes.unshift(X),L(X),!1;if(x)return!(k=X)}),k}return L(f.dataTypes[0])||!T["*"]&&L("*")}function La(c,f){var I,y,T=p.ajaxSettings.flatOptions||{};for(I in f)f[I]!==void 0&&((T[I]?c:y||(y={}))[I]=f[I]);return y&&p.extend(!0,c,y),c}function x0(c,f,I){for(var y,T,x,L,w=c.contents,k=c.dataTypes;k[0]==="*";)k.shift(),y===void 0&&(y=c.mimeType||f.getResponseHeader("Content-Type"));if(y){for(T in w)if(w[T]&&w[T].test(y)){k.unshift(T);break}}if(k[0]in I)x=k[0];else{for(T in I){if(!k[0]||c.converters[T+" "+k[0]]){x=T;break}L||(L=T)}x=x||L}if(x)return x!==k[0]&&k.unshift(x),I[x]}function b0(c,f,I,y){var T,x,L,w,k,B={},K=c.dataTypes.slice();if(K[1])for(L in c.converters)B[L.toLowerCase()]=c.converters[L];for(x=K.shift();x;)if(c.responseFields[x]&&(I[c.responseFields[x]]=f),!k&&y&&c.dataFilter&&(f=c.dataFilter(f,c.dataType)),k=x,x=K.shift(),x){if(x==="*")x=k;else if(k!=="*"&&k!==x){if(L=B[k+" "+x]||B["* "+x],!L){for(T in B)if(w=T.split(" "),w[1]===x&&(L=B[k+" "+w[0]]||B["* "+w[0]],L)){L===!0?L=B[T]:B[T]!==!0&&(x=w[0],K.unshift(w[1]));break}}if(L!==!0)if(L&&c.throws)f=L(f);else try{f=L(f)}catch(X){return{state:"parsererror",error:L?X:"No conversion from "+k+" to "+x}}}}return{state:"success",data:f}}p.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:Fs.href,type:"GET",isLocal:E0.test(Fs.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Gc,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":p.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(c,f){return f?La(La(c,p.ajaxSettings),f):La(p.ajaxSettings,c)},ajaxPrefilter:Hc($c),ajaxTransport:Hc(xa),ajax:function(c,f){typeof c=="object"&&(f=c,c=void 0),f=f||{};var I,y,T,x,L,w,k,B,K,X,H=p.ajaxSetup({},f),ie=H.context||H,De=H.context&&(ie.nodeType||ie.jquery)?p(ie):p.event,$e=p.Deferred(),Me=p.Callbacks("once memory"),It=H.statusCode||{},ht={},ui={},ci="canceled",Ue={readyState:0,getResponseHeader:function(He){var ot;if(k){if(!x)for(x={};ot=v0.exec(T);)x[ot[1].toLowerCase()+" "]=(x[ot[1].toLowerCase()+" "]||[]).concat(ot[2]);ot=x[He.toLowerCase()+" "]}return ot==null?null:ot.join(", ")},getAllResponseHeaders:function(){return k?T:null},setRequestHeader:function(He,ot){return k==null&&(He=ui[He.toLowerCase()]=ui[He.toLowerCase()]||He,ht[He]=ot),this},overrideMimeType:function(He){return k==null&&(H.mimeType=He),this},statusCode:function(He){var ot;if(He)if(k)Ue.always(He[Ue.status]);else for(ot in He)It[ot]=[It[ot],He[ot]];return this},abort:function(He){var ot=He||ci;return I&&I.abort(ot),Gi(0,ot),this}};if($e.promise(Ue),H.url=((c||H.url||Fs.href)+"").replace(S0,Fs.protocol+"//"),H.type=f.method||f.type||H.method||H.type,H.dataTypes=(H.dataType||"*").toLowerCase().match(Ye)||[""],H.crossDomain==null){w=S.createElement("a");try{w.href=H.url,w.href=w.href,H.crossDomain=ba.protocol+"//"+ba.host!=w.protocol+"//"+w.host}catch{H.crossDomain=!0}}if(H.data&&H.processData&&typeof H.data!="string"&&(H.data=p.param(H.data,H.traditional)),Vc($c,H,f,Ue),k)return Ue;B=p.event&&H.global,B&&p.active++===0&&p.event.trigger("ajaxStart"),H.type=H.type.toUpperCase(),H.hasContent=!T0.test(H.type),y=H.url.replace(C0,""),H.hasContent?H.data&&H.processData&&(H.contentType||"").indexOf("application/x-www-form-urlencoded")===0&&(H.data=H.data.replace(I0,"+")):(X=H.url.slice(y.length),H.data&&(H.processData||typeof H.data=="string")&&(y+=(Ta.test(y)?"&":"?")+H.data,delete H.data),H.cache===!1&&(y=y.replace(y0,"$1"),X=(Ta.test(y)?"&":"?")+"_="+Fc.guid+++X),H.url=y+X),H.ifModified&&(p.lastModified[y]&&Ue.setRequestHeader("If-Modified-Since",p.lastModified[y]),p.etag[y]&&Ue.setRequestHeader("If-None-Match",p.etag[y])),(H.data&&H.hasContent&&H.contentType!==!1||f.contentType)&&Ue.setRequestHeader("Content-Type",H.contentType),Ue.setRequestHeader("Accept",H.dataTypes[0]&&H.accepts[H.dataTypes[0]]?H.accepts[H.dataTypes[0]]+(H.dataTypes[0]!=="*"?", "+Gc+"; q=0.01":""):H.accepts["*"]);for(K in H.headers)Ue.setRequestHeader(K,H.headers[K]);if(H.beforeSend&&(H.beforeSend.call(ie,Ue,H)===!1||k))return Ue.abort();if(ci="abort",Me.add(H.complete),Ue.done(H.success),Ue.fail(H.error),I=Vc(xa,H,f,Ue),!I)Gi(-1,"No Transport");else{if(Ue.readyState=1,B&&De.trigger("ajaxSend",[Ue,H]),k)return Ue;H.async&&H.timeout>0&&(L=e.setTimeout(function(){Ue.abort("timeout")},H.timeout));try{k=!1,I.send(ht,Gi)}catch(He){if(k)throw He;Gi(-1,He)}}function Gi(He,ot,Bs,Da){var hi,Us,di,Pi,_i,Vt=ot;k||(k=!0,L&&e.clearTimeout(L),I=void 0,T=Da||"",Ue.readyState=He>0?4:0,hi=He>=200&&He<300||He===304,Bs&&(Pi=x0(H,Ue,Bs)),!hi&&p.inArray("script",H.dataTypes)>-1&&p.inArray("json",H.dataTypes)<0&&(H.converters["text script"]=function(){}),Pi=b0(H,Pi,Ue,hi),hi?(H.ifModified&&(_i=Ue.getResponseHeader("Last-Modified"),_i&&(p.lastModified[y]=_i),_i=Ue.getResponseHeader("etag"),_i&&(p.etag[y]=_i)),He===204||H.type==="HEAD"?Vt="nocontent":He===304?Vt="notmodified":(Vt=Pi.state,Us=Pi.data,di=Pi.error,hi=!di)):(di=Vt,(He||!Vt)&&(Vt="error",He<0&&(He=0))),Ue.status=He,Ue.statusText=(ot||Vt)+"",hi?$e.resolveWith(ie,[Us,Vt,Ue]):$e.rejectWith(ie,[Ue,Vt,di]),Ue.statusCode(It),It=void 0,B&&De.trigger(hi?"ajaxSuccess":"ajaxError",[Ue,H,hi?Us:di]),Me.fireWith(ie,[Ue,Vt]),B&&(De.trigger("ajaxComplete",[Ue,H]),--p.active||p.event.trigger("ajaxStop")))}return Ue},getJSON:function(c,f,I){return p.get(c,f,I,"json")},getScript:function(c,f){return p.get(c,void 0,f,"script")}}),p.each(["get","post"],function(c,f){p[f]=function(I,y,T,x){return C(y)&&(x=x||T,T=y,y=void 0),p.ajax(p.extend({url:I,type:f,dataType:x,data:y,success:T},p.isPlainObject(I)&&I))}}),p.ajaxPrefilter(function(c){var f;for(f in c.headers)f.toLowerCase()==="content-type"&&(c.contentType=c.headers[f]||"")}),p._evalUrl=function(c,f,I){return p.ajax({url:c,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,converters:{"text script":function(){}},dataFilter:function(y){p.globalEval(y,f,I)}})},p.fn.extend({wrapAll:function(c){var f;return this[0]&&(C(c)&&(c=c.call(this[0])),f=p(c,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&f.insertBefore(this[0]),f.map(function(){for(var I=this;I.firstElementChild;)I=I.firstElementChild;return I}).append(this)),this},wrapInner:function(c){return C(c)?this.each(function(f){p(this).wrapInner(c.call(this,f))}):this.each(function(){var f=p(this),I=f.contents();I.length?I.wrapAll(c):f.append(c)})},wrap:function(c){var f=C(c);return this.each(function(I){p(this).wrapAll(f?c.call(this,I):c)})},unwrap:function(c){return this.parent(c).not("body").each(function(){p(this).replaceWith(this.childNodes)}),this}}),p.expr.pseudos.hidden=function(c){return!p.expr.pseudos.visible(c)},p.expr.pseudos.visible=function(c){return!!(c.offsetWidth||c.offsetHeight||c.getClientRects().length)},p.ajaxSettings.xhr=function(){try{return new e.XMLHttpRequest}catch{}};var L0={0:200,1223:204},Ns=p.ajaxSettings.xhr();A.cors=!!Ns&&"withCredentials"in Ns,A.ajax=Ns=!!Ns,p.ajaxTransport(function(c){var f,I;if(A.cors||Ns&&!c.crossDomain)return{send:function(y,T){var x,L=c.xhr();if(L.open(c.type,c.url,c.async,c.username,c.password),c.xhrFields)for(x in c.xhrFields)L[x]=c.xhrFields[x];c.mimeType&&L.overrideMimeType&&L.overrideMimeType(c.mimeType),!c.crossDomain&&!y["X-Requested-With"]&&(y["X-Requested-With"]="XMLHttpRequest");for(x in y)L.setRequestHeader(x,y[x]);f=function(w){return function(){f&&(f=I=L.onload=L.onerror=L.onabort=L.ontimeout=L.onreadystatechange=null,w==="abort"?L.abort():w==="error"?typeof L.status!="number"?T(0,"error"):T(L.status,L.statusText):T(L0[L.status]||L.status,L.statusText,(L.responseType||"text")!=="text"||typeof L.responseText!="string"?{binary:L.response}:{text:L.responseText},L.getAllResponseHeaders()))}},L.onload=f(),I=L.onerror=L.ontimeout=f("error"),L.onabort!==void 0?L.onabort=I:L.onreadystatechange=function(){L.readyState===4&&e.setTimeout(function(){f&&I()})},f=f("abort");try{L.send(c.hasContent&&c.data||null)}catch(w){if(f)throw w}},abort:function(){f&&f()}}}),p.ajaxPrefilter(function(c){c.crossDomain&&(c.contents.script=!1)}),p.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(c){return p.globalEval(c),c}}}),p.ajaxPrefilter("script",function(c){c.cache===void 0&&(c.cache=!1),c.crossDomain&&(c.type="GET")}),p.ajaxTransport("script",function(c){if(c.crossDomain||c.scriptAttrs){var f,I;return{send:function(y,T){f=p("<script>").attr(c.scriptAttrs||{}).prop({charset:c.scriptCharset,src:c.url}).on("load error",I=function(x){f.remove(),I=null,x&&T(x.type==="error"?404:200,x.type)}),S.head.appendChild(f[0])},abort:function(){I&&I()}}}});var Kc=[],Ra=/(=)\?(?=&|$)|\?\?/;p.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var c=Kc.pop()||p.expando+"_"+Fc.guid++;return this[c]=!0,c}}),p.ajaxPrefilter("json jsonp",function(c,f,I){var y,T,x,L=c.jsonp!==!1&&(Ra.test(c.url)?"url":typeof c.data=="string"&&(c.contentType||"").indexOf("application/x-www-form-urlencoded")===0&&Ra.test(c.data)&&"data");if(L||c.dataTypes[0]==="jsonp")return y=c.jsonpCallback=C(c.jsonpCallback)?c.jsonpCallback():c.jsonpCallback,L?c[L]=c[L].replace(Ra,"$1"+y):c.jsonp!==!1&&(c.url+=(Ta.test(c.url)?"&":"?")+c.jsonp+"="+y),c.converters["script json"]=function(){return x||p.error(y+" was not called"),x[0]},c.dataTypes[0]="json",T=e[y],e[y]=function(){x=arguments},I.always(function(){T===void 0?p(e).removeProp(y):e[y]=T,c[y]&&(c.jsonpCallback=f.jsonpCallback,Kc.push(y)),x&&C(T)&&T(x[0]),x=T=void 0}),"script"}),A.createHTMLDocument=(function(){var c=S.implementation.createHTMLDocument("").body;return c.innerHTML="<form></form><form></form>",c.childNodes.length===2})(),p.parseHTML=function(c,f,I){if(typeof c!="string")return[];typeof f=="boolean"&&(I=f,f=!1);var y,T,x;return f||(A.createHTMLDocument?(f=S.implementation.createHTMLDocument(""),y=f.createElement("base"),y.href=S.location.href,f.head.appendChild(y)):f=S),T=re.exec(c),x=!I&&[],T?[f.createElement(T[1])]:(T=yc([c],f,x),x&&x.length&&p(x).remove(),p.merge([],T.childNodes))},p.fn.load=function(c,f,I){var y,T,x,L=this,w=c.indexOf(" ");return w>-1&&(y=Ui(c.slice(w)),c=c.slice(0,w)),C(f)?(I=f,f=void 0):f&&typeof f=="object"&&(T="POST"),L.length>0&&p.ajax({url:c,type:T||"GET",dataType:"html",data:f}).done(function(k){x=arguments,L.html(y?p("<div>").append(p.parseHTML(k)).find(y):k)}).always(I&&function(k,B){L.each(function(){I.apply(this,x||[k.responseText,B,k])})}),this},p.expr.pseudos.animated=function(c){return p.grep(p.timers,function(f){return c===f.elem}).length},p.offset={setOffset:function(c,f,I){var y,T,x,L,w,k,B,K=p.css(c,"position"),X=p(c),H={};K==="static"&&(c.style.position="relative"),w=X.offset(),x=p.css(c,"top"),k=p.css(c,"left"),B=(K==="absolute"||K==="fixed")&&(x+k).indexOf("auto")>-1,B?(y=X.position(),L=y.top,T=y.left):(L=parseFloat(x)||0,T=parseFloat(k)||0),C(f)&&(f=f.call(c,I,p.extend({},w))),f.top!=null&&(H.top=f.top-w.top+L),f.left!=null&&(H.left=f.left-w.left+T),"using"in f?f.using.call(c,H):X.css(H)}},p.fn.extend({offset:function(c){if(arguments.length)return c===void 0?this:this.each(function(T){p.offset.setOffset(this,c,T)});var f,I,y=this[0];if(y)return y.getClientRects().length?(f=y.getBoundingClientRect(),I=y.ownerDocument.defaultView,{top:f.top+I.pageYOffset,left:f.left+I.pageXOffset}):{top:0,left:0}},position:function(){if(this[0]){var c,f,I,y=this[0],T={top:0,left:0};if(p.css(y,"position")==="fixed")f=y.getBoundingClientRect();else{for(f=this.offset(),I=y.ownerDocument,c=y.offsetParent||I.documentElement;c&&(c===I.body||c===I.documentElement)&&p.css(c,"position")==="static";)c=c.parentNode;c&&c!==y&&c.nodeType===1&&(T=p(c).offset(),T.top+=p.css(c,"borderTopWidth",!0),T.left+=p.css(c,"borderLeftWidth",!0))}return{top:f.top-T.top-p.css(y,"marginTop",!0),left:f.left-T.left-p.css(y,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){for(var c=this.offsetParent;c&&p.css(c,"position")==="static";)c=c.offsetParent;return c||Bi})}}),p.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(c,f){var I=f==="pageYOffset";p.fn[c]=function(y){return Re(this,function(T,x,L){var w;if(v(T)?w=T:T.nodeType===9&&(w=T.defaultView),L===void 0)return w?w[f]:T[x];w?w.scrollTo(I?w.pageXOffset:L,I?L:w.pageYOffset):T[x]=L},c,y,arguments.length)}}),p.each(["top","left"],function(c,f){p.cssHooks[f]=bc(A.pixelPosition,function(I,y){if(y)return y=Ms(I,f),Aa.test(y)?p(I).position()[f]+"px":y})}),p.each({Height:"height",Width:"width"},function(c,f){p.each({padding:"inner"+c,content:f,"":"outer"+c},function(I,y){p.fn[y]=function(T,x){var L=arguments.length&&(I||typeof T!="boolean"),w=I||(T===!0||x===!0?"margin":"border");return Re(this,function(k,B,K){var X;return v(k)?y.indexOf("outer")===0?k["inner"+c]:k.document.documentElement["client"+c]:k.nodeType===9?(X=k.documentElement,Math.max(k.body["scroll"+c],X["scroll"+c],k.body["offset"+c],X["offset"+c],X["client"+c])):K===void 0?p.css(k,B,w):p.style(k,B,K,w)},f,L?T:void 0,L)}})}),p.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(c,f){p.fn[f]=function(I){return this.on(f,I)}}),p.fn.extend({bind:function(c,f,I){return this.on(c,null,f,I)},unbind:function(c,f){return this.off(c,null,f)},delegate:function(c,f,I,y){return this.on(f,c,I,y)},undelegate:function(c,f,I){return arguments.length===1?this.off(c,"**"):this.off(f,c||"**",I)},hover:function(c,f){return this.on("mouseenter",c).on("mouseleave",f||c)}}),p.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(c,f){p.fn[f]=function(I,y){return arguments.length>0?this.on(f,null,I,y):this.trigger(f)}});var R0=/^[\s\uFEFF\xA0]+|([^\s\uFEFF\xA0])[\s\uFEFF\xA0]+$/g;p.proxy=function(c,f){var I,y,T;if(typeof f=="string"&&(I=c[f],f=c,c=I),!!C(c))return y=n.call(arguments,2),T=function(){return c.apply(f||this,y.concat(n.call(arguments)))},T.guid=c.guid=c.guid||p.guid++,T},p.holdReady=function(c){c?p.readyWait++:p.ready(!0)},p.isArray=Array.isArray,p.parseJSON=JSON.parse,p.nodeName=N,p.isFunction=C,p.isWindow=v,p.camelCase=at,p.type=D,p.now=Date.now,p.isNumeric=function(c){var f=p.type(c);return(f==="number"||f==="string")&&!isNaN(c-parseFloat(c))},p.trim=function(c){return c==null?"":(c+"").replace(R0,"$1")};var D0=e.jQuery,P0=e.$;return p.noConflict=function(c){return e.$===p&&(e.$=P0),c&&e.jQuery===p&&(e.jQuery=D0),p},typeof t>"u"&&(e.jQuery=e.$=p),p})})(_n)),_n.exports}var Km=Vm();const Ri=Gm(Km),Nt={None:"none",DualLayer:"dual-layer",Segments:"segments",MinimalWave:"minimal-wave"},Ym={[Nt.None]:`
53
46
  .progress-bar {
54
47
  flex: 1;
55
48
  height: 4px;
@@ -66,7 +59,7 @@ Schedule: ${c.map(E=>Pt(E))} pos: ${this.timelinePos}`),h.length&&this.log(`Remo
66
59
  background: #0A84FF;
67
60
  border-radius: 2px;
68
61
  }
69
- `,[Et.DualLayer]:`
62
+ `,[Nt.DualLayer]:`
70
63
  .progress-bar {
71
64
  flex: 1;
72
65
  height: 8px;
@@ -108,7 +101,7 @@ Schedule: ${c.map(E=>Pt(E))} pos: ${this.timelinePos}`),h.length&&this.log(`Remo
108
101
  .progress-bar:hover .progress-handle {
109
102
  transform: translateY(-50%) scale(1.2);
110
103
  }
111
- `,[Et.Segments]:`
104
+ `,[Nt.Segments]:`
112
105
  .progress-bar {
113
106
  flex: 1;
114
107
  height: 4px;
@@ -145,7 +138,7 @@ Schedule: ${c.map(E=>Pt(E))} pos: ${this.timelinePos}`),h.length&&this.log(`Remo
145
138
  .progress-segment.filled:hover {
146
139
  background: #40A2FF;
147
140
  }
148
- `,[Et.MinimalWave]:`
141
+ `,[Nt.MinimalWave]:`
149
142
  .progress-bar {
150
143
  flex: 1;
151
144
  height: 2px;
@@ -182,7 +175,7 @@ Schedule: ${c.map(E=>Pt(E))} pos: ${this.timelinePos}`),h.length&&this.log(`Remo
182
175
  50% { transform: translateY(-50%) scaleY(0.6); }
183
176
  100% { transform: translateY(-50%) scaleY(1); }
184
177
  }
185
- `},vg={play:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="black">
178
+ `},Wm={play:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="black">
186
179
  <path d="M8 5v14l11-7z"/>
187
180
  </svg>`,pause:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="black">
188
181
  <path d="M6 19h4V5H6v14zm8-14v14h4V5h-4z"/>
@@ -192,24 +185,24 @@ Schedule: ${c.map(E=>Pt(E))} pos: ${this.timelinePos}`),h.length&&this.log(`Remo
192
185
  <path d="M11 18V6l-8.5 6 8.5 6zm.5-6l8.5 6V6l-8.5 6z"/>
193
186
  </svg>`,fullscreen:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="black">
194
187
  <path d="M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"/>
195
- </svg>`,"speed-0.50":'<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAYAAACOEfKtAAAC9HpUWHRSYXcgcHJvZmlsZSB0eXBlIGV4aWYAAHja7ZddktsqEIXfWUWWoP6jm+UgEFXZQZafA5Kdscd58L1PqTKUADXo0PQHeCYdv36O9AOJSuSk5pFLzhuSFi1c0YjtTHWVtOkqV7KrC+8P9nTvYJgEtZyvka/xNzvdBc6qomVfhKJdHftjR9FLP56ErolkesRo9EuoXELCZwddAvVc1pZL+Ncl7MdZ99tK4nzSLEbjsta/n33P7+qIXjfMI8yHkGwoRS4HZD6WpKJBKEkQDpSKti7LJn55goC8itM9Ydo0pqv6ctADlXuLXtvTMy3la4g8BTnf65f2RPaaygr9l5k1rhY/2l1OqbQ9RX8Ff/QYa81YRdWMUOdrUbelrBbGAYfOqSNBL2+OxyDhKxfkwK5u2Ap9a9uO3KgQA9cgpU6VBh2rbtTgovKR2NFgbizLGOJcuMnJD5kGuxTpEoDcFnYVvvtCa9qytbRmC8zcCUOZIEb45O2c3v1gjHkUiLa4xwp+Mc9gw41JbpYYBiI0rqDaCvAtP6fJVUDQZpTnESkI7H5K7EZ/bgJZoAUDDfV5Bsn7JYAQYWqDMzgTSqBGYpRpc2YnQiADgCpcZ1HeQYDMuMNJVpEMNsFzanzitIayMcwJdlxmIGGSxcGmSAUsVcP+cQ3soWpiambZ3MKK1SxZs+WcPc9Lsbq4JjfP7h5evIaEhkUOj4gStXARXJpWcvESpZRaMWeFcsXXFQNq3XmXXXdLe959j73stWH7NG3WcvMWrbTauUvH/dFz9x699HrQga106GFHPvyIoxx1YKsNSUOHjTx8xCij3qldWL/lN6jRRY0XqTnQ79Rgdb9J0LxObDIDME5KIO4TATY0T2ZbkCpPcpPZVhinwhhO2mTWaRIDQT2IbdCNXeKT6CT3v7gl1wdu/F/JpYnuTXLfub2i1ufPUFvEzlM4g7oJTh/6j6gcdf7YfavT3zrerT9CH6GP0EfoI/QR+gj9Q0IDfzzM/wJ/AwtlqMgGWC/6AAAAYXpUWHRSYXcgcHJvZmlsZSB0eXBlIGlwdGMAAHjaPYk7DoAwDEP3nIIj5GPUch2Sha0D9xemUuunWLGePONNOWbgEh2OC6UgO1aW6tH49vBQ3sm2n2mS5uYCMZomXmuqygcwfhTVhYB0sAAAAYVpQ0NQSUNDIHByb2ZpbGUAAHicfZE9SMNQFIVPW7VWKw52EHHIUJ0siIo4ahWKUCHUCq06mLz0D5o0JCkujoJrwcGfxaqDi7OuDq6CIPgD4i44KbpIifclhRYxXni8j/PuObx3H+Cvl5lqdowDqmYZqURcyGRXheArfOhFCF0ISczU50QxCc/6uqduqrsYz/Lu+7P6lJzJAJ9APMt0wyLeIJ7etHTO+8QRVpQU4nPiMYMuSPzIddnlN84Fh/08M2KkU/PEEWKh0MZyG7OioRJPEUcVVaN8f8ZlhfMWZ7VcZc178heGc9rKMtdpDSOBRSxBhAAZVZRQhoUY7RopJlJ0HvfwDzl+kVwyuUpg5FhABSokxw/+B79na+YnJ9ykcBzofLHtjxEguAs0arb9fWzbjRMg8AxcaS1/pQ7MfJJea2nRI6B/G7i4bmnyHnC5Aww+6ZIhOVKAlj+fB97P6JuywMAt0LPmzq15jtMHIE2zSt4AB4fAaIGy1z3e3d0+t397mvP7AdDBcmazf/6+AAAPw2lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4KPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNC40LjAtRXhpdjIiPgogPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iCiAgICB4bWxuczpzdEV2dD0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL3NUeXBlL1Jlc291cmNlRXZlbnQjIgogICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICAgeG1sbnM6R0lNUD0iaHR0cDovL3d3dy5naW1wLm9yZy94bXAvIgogICAgeG1sbnM6dGlmZj0iaHR0cDovL25zLmFkb2JlLmNvbS90aWZmLzEuMC8iCiAgICB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iCiAgIHhtcE1NOkRvY3VtZW50SUQ9ImdpbXA6ZG9jaWQ6Z2ltcDpmNzU5ZmE3Zi1mYWYzLTRiYjUtOTU2OC01ZWZmOTQ5MzhmOWEiCiAgIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6MmE1YTUxZWQtMjFkNi00MzY2LWJmY2ItZDcyNzJjNzdhN2U3IgogICB4bXBNTTpPcmlnaW5hbERvY3VtZW50SUQ9InhtcC5kaWQ6MGI4NjEwY2EtMDU3Ni00MTJlLTg2NzEtYjRjZWU1YzJkZGFiIgogICBkYzpGb3JtYXQ9ImltYWdlL3BuZyIKICAgR0lNUDpBUEk9IjIuMCIKICAgR0lNUDpQbGF0Zm9ybT0iTGludXgiCiAgIEdJTVA6VGltZVN0YW1wPSIxNzM2NTg2NjY3OTU1MTQ1IgogICBHSU1QOlZlcnNpb249IjIuMTAuMzAiCiAgIHRpZmY6T3JpZW50YXRpb249IjEiCiAgIHhtcDpDcmVhdG9yVG9vbD0iR0lNUCAyLjEwIj4KICAgPHhtcE1NOkhpc3Rvcnk+CiAgICA8cmRmOlNlcT4KICAgICA8cmRmOmxpCiAgICAgIHN0RXZ0OmFjdGlvbj0ic2F2ZWQiCiAgICAgIHN0RXZ0OmNoYW5nZWQ9Ii8iCiAgICAgIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6ZTZkNDA1MzYtMmM4Mi00YmMyLTgwYzctYWM2ZjU0ZGM3YjIxIgogICAgICBzdEV2dDpzb2Z0d2FyZUFnZW50PSJHaW1wIDIuMTAgKExpbnV4KSIKICAgICAgc3RFdnQ6d2hlbj0iMjAyMy0xMC0zMVQxNToxMTozNiswNTozMCIvPgogICAgIDxyZGY6bGkKICAgICAgc3RFdnQ6YWN0aW9uPSJzYXZlZCIKICAgICAgc3RFdnQ6Y2hhbmdlZD0iLyIKICAgICAgc3RFdnQ6aW5zdGFuY2VJRD0ieG1wLmlpZDphN2IwZGUxZi1iYmFhLTQ1ZWQtOGU3Mi1mNzIxZDViMGUzZmIiCiAgICAgIHN0RXZ0OnNvZnR3YXJlQWdlbnQ9IkdpbXAgMi4xMCAoTGludXgpIgogICAgICBzdEV2dDp3aGVuPSIyMDIzLTEwLTMxVDE1OjMyOjIwKzA1OjMwIi8+CiAgICAgPHJkZjpsaQogICAgICBzdEV2dDphY3Rpb249InNhdmVkIgogICAgICBzdEV2dDpjaGFuZ2VkPSIvIgogICAgICBzdEV2dDppbnN0YW5jZUlEPSJ4bXAuaWlkOjZiNTdlZmMzLTdmNjMtNGE0MS1hZWYzLTc4MGQ0NzU1YmRjZiIKICAgICAgc3RFdnQ6c29mdHdhcmVBZ2VudD0iR2ltcCAyLjEwIChMaW51eCkiCiAgICAgIHN0RXZ0OndoZW49IjIwMjMtMTEtMDNUMTI6MjE6NTUrMDU6MzAiLz4KICAgICA8cmRmOmxpCiAgICAgIHN0RXZ0OmFjdGlvbj0ic2F2ZWQiCiAgICAgIHN0RXZ0OmNoYW5nZWQ9Ii8iCiAgICAgIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6MzJhOTk4N2MtMWE5ZS00MjNiLWJiZGUtMWQxMmE2Njg4MDQ1IgogICAgICBzdEV2dDpzb2Z0d2FyZUFnZW50PSJHaW1wIDIuMTAgKExpbnV4KSIKICAgICAgc3RFdnQ6d2hlbj0iMjAyNS0wMS0xMVQxNDo0MTowNyswNTozMCIvPgogICAgPC9yZGY6U2VxPgogICA8L3htcE1NOkhpc3Rvcnk+CiAgPC9yZGY6RGVzY3JpcHRpb24+CiA8L3JkZjpSREY+CjwveDp4bXBtZXRhPgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgCjw/eHBhY2tldCBlbmQ9InciPz64X1WPAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAB3RJTUUH6QELCQsHZb85vAAABP5JREFUeNrtm2toXEUUgL+ka0xM0lQ2YlCs1aYlaCHxnVqxUir4qLZaS7UI9odVqq2g+IT8kZaqoIjxjfgCkdbaH6Xon7RUrdhCqZWUCkbUGmwVnzE20aZu1h/3LDm5vfu4m4m79+75YODu7MyZe8+eO+fMmVkwDMMwDMMwDMMwDMMwjMhQFeF7rwYagKlS5gGnA33AEeBzYNh+4vE0ArcDHwAjQDpHOQ7sB14GVgJtETeYojkZWAJsEotKT6D8ANwFJCrlFV4CvAU0+er/ArYCXwODQBLoku+6gO+AS4BO4AL5ETRfSbstotjY8r6ynmFgM3ALUOdr16naLQ+w4E7gYZkbtUXuBRbGWYGzgGeAOwKsUHOhUspNOdqdAjwK/O5T5Bb5rmKpFiV8JJ45H6cCTwBDSom7gWbz0+E4A/hUKfFPYH5UnUhSPG19lu+/kRDGNXXAZ0CHfB4GzgO+j5o1LCwgDJmao/9c4DZgSshxVwGjvnH2ADVRU2AS2C5zUVB5J0+AfVQe/oYQY14DpJSX71FK7K6kuWymevA1IfqtU8q7WqaPA0rWskpR4Cz10PeE6NcMPA5cpuraJDhPAz9WSngzWylwtQN5q5W8+ytBgW3qge92IK9GvHBeK6wu8YNPA1oKKI0hwjEXa9sRYINctziyaudMB/4uMIsyELD+1Zyv2t7p6P5qgEMi80A5WmAzUFtg26Y8VujaAjNWuFGu58gPfgKJEirwCwlipxXQ9gjwc561cIZRh/f4IfCIXF8HvBJXJ9KuXuFVDuUmgD9E7ra4Km+FeMqMAkeBp0JMD/nYLHJ/i6Pyns7hePZxYia6GDYomXVxUt4ilQQYAl4EXgMOqwde52CcNUrezFzea7KpAm6VpEEYBoB3A5xDj2RwUnj7HplQoxZv8ygpa9yGIjzzWcD1Mge2q9DoSmBXOaxXw5YOn6yTVAy5MWCsbtX3zCLutS/LfXSVMg4cBI4V0e+4WKG/bkSuWwP6ZKw8JYoOy5dZ6g+X8hUG7+RAY8g+Q+Jl/ewCrpDrxRJmpGVu3CrGsQcv0VoMM+QVXgQ8K3WX4u3kxYK5jCVDM5vm+tX7l5D7G1lYq2TOiFsY85C8zv656hhwr6Mx1iu5DcSQi/BS/pmH3BngdCbCTpHbT4y5SilwsUO5DWLNaeD1cksm1ANvk/vEgU4mrMwRz2WC5yrHS675jO3O9ZSb1XSGjAXzxXNLHScSAF6SsVNkObVQyo31JrxzfoVa4LW4TVXl4zS8U171eBvv8zBC8aSy/htNHeFIMra1uZ8KPdk6EV5Q1nezqSM77eJd71N1yxifU4yU9dVK7BVUJuOwj57n1ktiYkA+/0pA/q+caSX3Nmc/7rNHs4Ff1Bg/MXbCf0GUVxNBJTVJa9F2Cb71WGsL7ZwoIwXuBh4j+wHLQ3hH2Fwzwvg85T7g+Up0CHUUtsesWeGzvt4CA/vYUS/z11GynCDw0QbsYHz660FKf1bIOUuBg8AbwOUFrquX52g3B3hOZVjSeEnYi+NqWe/5JvdemeBbfdaSTYFVwNl4W5N7AxzTm8Q0SapDm20EZ50H8fZFuoFXVf0mvD3ijxk7lqHLP9JmARVEi8xRvRS/NXoQeADHf6aJ4iK5Q+bGc8VhTMfLFU5RYUm/hD3f4qWkPsFLSTknLlmGBHCOKLGP/zdvaBiGYRiGYRiGYRiGYRhR4T+g4LtceW1yGQAAAABJRU5ErkJggg==" width="24" height="24" alt="0.5x speed">',"speed-1.00":'<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAYAAACOEfKtAAAC9HpUWHRSYXcgcHJvZmlsZSB0eXBlIGV4aWYAAHja7ZddktsqEIXfWUWWoP6jm+UgEFXZQZafA5Kdscd58L1PqTKUADXo0PQHeCYdv36O9AOJSuSk5pFLzhuSFi1c0YjtTHWVtOkqV7KrC+8P9nTvYJgEtZyvka/xNzvdBc6qomVfhKJdHftjR9FLP56ErolkesRo9EuoXELCZwddAvVc1pZL+Ncl7MdZ99tK4nzSLEbjsta/n33P7+qIXjfMI8yHkGwoRS4HZD6WpKJBKEkQDpSKtqJr2vnyBAF5Fad7wrRpTFf15aAHKvcWvbanZ1rK1xB5CnK+1y/tiew1lRX6LzNrXC1+tLucUml7iv4K/ugx1pqxiqoZoc7Xom5LWS2MAw6dU0eCXt4cj0HCVy7IgV3dsBX61rYduVEhBq5BSp0qDTpW3ajBReUjsaPB3FiWMcS5cJOTHzINdinSJUCyLexgeveF1rRla2nNFpi5E4YyQYzwyds5vfvBGPMoEG1xjxX8Yp7BhhuT3CwxDERoXEG1FeBbfk6Tq4CgzSjPI1IQ2P2U2I3+3ASyQAsGGurzDJL3SwAhwtQGZ3AmlECNxCjT5sxOhEAGAFW4zqK8gwCZcYeTrCIZbILn1PjEaQ1lY5gT7LjMQMIki4NNkQpYqob94xrYQ9XE1MyyuYUVq1myZss5e56XYnVxTW6e3T28eA0JDYscHhElauEiuDSt5OIlSim1Ys4K5YqvKwbUuvMuu+6W9rz7HnvZa8P2adqs5eYtWmm1c5eO+6Pn7j166fWgA1vp0MOOfPgRRznqwFYbkoYOG3n4iFFGvVO7sH7Lb1CjixovUnOg36nB6n6ToHmd2GQGYJyUQNwnAmxonsy2IFWe5CazrTBOhTGctMms0yQGgnoQ26Abu8Qn0Unuf3FLrg/c+L+SSxPdm+S+c3tFrc+fobaInadwBnUTnD70H1E56vyx+1anv3W8W3+EPkIfoY/QR+gj9BH6h4QG/niY/wX+BtKUqMT2Ahu4AAAAYHpUWHRSYXcgcHJvZmlsZSB0eXBlIGlwdGMAAHja48osKEnmUgADEyMuYwsTIxNLkxQDEyCEA8MUw2QDI2NzINPC2MjYAIhNgaQhCIJlkoEySUCeCRCC5bmMUmBcAwMuADBKFNK6HFPnAAABhWlDQ1BJQ0MgcHJvZmlsZQAAeJx9kT1Iw1AUhU9btVYrDnYQcchQnSyIijhqFYpQIdQKrTqYvPQPmjQkKS6OgmvBwZ/FqoOLs64OroIg+APiLjgpukiJ9yWFFjFeeLyP8+45vHcf4K+XmWp2jAOqZhmpRFzIZFeF4Ct86EUIXQhJzNTnRDEJz/q6p26quxjP8u77s/qUnMkAn0A8y3TDIt4gnt60dM77xBFWlBTic+Ixgy5I/Mh12eU3zgWH/TwzYqRT88QRYqHQxnIbs6KhEk8RRxVVo3x/xmWF8xZntVxlzXvyF4Zz2soy12kNI4FFLEGEABlVlFCGhRjtGikmUnQe9/APOX6RXDK5SmDkWEAFKiTHD/4Hv2dr5icn3KRwHOh8se2PESC4CzRqtv19bNuNEyDwDFxpLX+lDsx8kl5radEjoH8buLhuafIecLkDDD7pkiE5UoCWP58H3s/om7LAwC3Qs+bOrXmO0wcgTbNK3gAHh8BogbLXPd7d3T63f3ua8/sB0MFyZrN//r4AAA/DaVRYdFhNTDpjb20uYWRvYmUueG1wAAAAAAA8P3hwYWNrZXQgYmVnaW49Iu+7vyIgaWQ9Ilc1TTBNcENlaGlIenJlU3pOVGN6a2M5ZCI/Pgo8eDp4bXBtZXRhIHhtbG5zOng9ImFkb2JlOm5zOm1ldGEvIiB4OnhtcHRrPSJYTVAgQ29yZSA0LjQuMC1FeGl2MiI+CiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogIDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiCiAgICB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIKICAgIHhtbG5zOnN0RXZ0PSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VFdmVudCMiCiAgICB4bWxuczpkYz0iaHR0cDovL3B1cmwub3JnL2RjL2VsZW1lbnRzLzEuMS8iCiAgICB4bWxuczpHSU1QPSJodHRwOi8vd3d3LmdpbXAub3JnL3htcC8iCiAgICB4bWxuczp0aWZmPSJodHRwOi8vbnMuYWRvYmUuY29tL3RpZmYvMS4wLyIKICAgIHhtbG5zOnhtcD0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLyIKICAgeG1wTU06RG9jdW1lbnRJRD0iZ2ltcDpkb2NpZDpnaW1wOmIwMWJkMTBiLTY4ZTUtNDI3Yy05MjZjLWYxMmI1NGE5MDIxZSIKICAgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDoyYWRhMTI4OS0yMDdiLTQwYTMtYjdjNS02OTc4NGQ1Yjc3NTIiCiAgIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDo3NDQ3MTYxMC0zYWY0LTQ0MDAtYTZiMC02NGJjZDgyNDIzMzEiCiAgIGRjOkZvcm1hdD0iaW1hZ2UvcG5nIgogICBHSU1QOkFQST0iMi4wIgogICBHSU1QOlBsYXRmb3JtPSJMaW51eCIKICAgR0lNUDpUaW1lU3RhbXA9IjE3MzY1ODY3MjI2MDkwNzgiCiAgIEdJTVA6VmVyc2lvbj0iMi4xMC4zMCIKICAgdGlmZjpPcmllbnRhdGlvbj0iMSIKICAgeG1wOkNyZWF0b3JUb29sPSJHSU1QIDIuMTAiPgogICA8eG1wTU06SGlzdG9yeT4KICAgIDxyZGY6U2VxPgogICAgIDxyZGY6bGkKICAgICAgc3RFdnQ6YWN0aW9uPSJzYXZlZCIKICAgICAgc3RFdnQ6Y2hhbmdlZD0iLyIKICAgICAgc3RFdnQ6aW5zdGFuY2VJRD0ieG1wLmlpZDoxMTg0Y2IxMi1lMTE2LTRlNTEtYTdlYi05ZTBhY2ZhMWNmZDIiCiAgICAgIHN0RXZ0OnNvZnR3YXJlQWdlbnQ9IkdpbXAgMi4xMCAoTGludXgpIgogICAgICBzdEV2dDp3aGVuPSIyMDIzLTEwLTMxVDE1OjExOjM4KzA1OjMwIi8+CiAgICAgPHJkZjpsaQogICAgICBzdEV2dDphY3Rpb249InNhdmVkIgogICAgICBzdEV2dDpjaGFuZ2VkPSIvIgogICAgICBzdEV2dDppbnN0YW5jZUlEPSJ4bXAuaWlkOmQ5OTdhZmU2LTAwYzQtNDhiYS05MzYxLTRmZmU3MWFlNjIwYSIKICAgICAgc3RFdnQ6c29mdHdhcmVBZ2VudD0iR2ltcCAyLjEwIChMaW51eCkiCiAgICAgIHN0RXZ0OndoZW49IjIwMjMtMTAtMzFUMTU6MzI6MTArMDU6MzAiLz4KICAgICA8cmRmOmxpCiAgICAgIHN0RXZ0OmFjdGlvbj0ic2F2ZWQiCiAgICAgIHN0RXZ0OmNoYW5nZWQ9Ii8iCiAgICAgIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6MzRlYTZjOTAtNjY0OS00ZGUwLTk3NjUtZTNiOGIyMDMxNDgxIgogICAgICBzdEV2dDpzb2Z0d2FyZUFnZW50PSJHaW1wIDIuMTAgKExpbnV4KSIKICAgICAgc3RFdnQ6d2hlbj0iMjAyMy0xMS0wM1QxMjoyMToxOCswNTozMCIvPgogICAgIDxyZGY6bGkKICAgICAgc3RFdnQ6YWN0aW9uPSJzYXZlZCIKICAgICAgc3RFdnQ6Y2hhbmdlZD0iLyIKICAgICAgc3RFdnQ6aW5zdGFuY2VJRD0ieG1wLmlpZDo4MDAxYTYxNy01ZTQxLTQ2YjQtOTk3MS1mMzNhYjIyNDNmMWUiCiAgICAgIHN0RXZ0OnNvZnR3YXJlQWdlbnQ9IkdpbXAgMi4xMCAoTGludXgpIgogICAgICBzdEV2dDp3aGVuPSIyMDI1LTAxLTExVDE0OjQyOjAyKzA1OjMwIi8+CiAgICA8L3JkZjpTZXE+CiAgIDwveG1wTU06SGlzdG9yeT4KICA8L3JkZjpEZXNjcmlwdGlvbj4KIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAKPD94cGFja2V0IGVuZD0idyI/Pk8m2PUAAAAGYktHRAD/AP8A/6C9p5MAAAAJcEhZcwAALiMAAC4jAXilP3YAAAAHdElNRQfpAQsJDAJalFv0AAAFB0lEQVR42u2bfYgVVRTAf7u+LdvNNXar1azdLFoQtlIqWJCicjH72IrokyJFLaIIo5aWNiusxUAMURApsCCyyCUL2TBLihIiU4wk0z7dDDOzWrNNe7nP1x/3DHvfNO9j3sxr9s07P7jMvJn7NeedO+fcc++AoiiKoiiKoiiKoiiKopQNVWXe9zqgXtI0YAqwE/gN2Ar8oX9xJicCNwKvAUNAOkc6DuwCXgLuA6YCiUoU2higA1gNDOYRWr40CPQAtZUyhC8C+oEJrutJYAPwOXBItG253HsB2AhcArTLsc5Vfj/wtPwpx+KsfYst7RkWwcwBxrvyNVr5nnDdS8jwvR/Y7dLIb4Dbgeq4CvA0YIk8fFOOfPVASoTyaI58CWA+8KNLkB8Dp1e6gVkGbAPOKSDvSUAX8KslxO+AVrXT/hgP9FlC/FteEWVhRK4GHhcrWwhfAfNkqIZJNbAOuEF+p4DpwJbR/u/3F+GGtJWgH1cBR13tDIhhykuUjuVK4BSfGrgr5D5MAd4ExoortF4c9RbgZaBTritZuFs0LgXMleG8wdLEHhVRfmv8GHCNde1UYK9lVM5SMWXSKcM0Fx2WFq5SkY3Q68MgfSj5kkBz1G5MU4C2UsDBEPqwEHhGzg8C5wJ/5sh/BfC+nD8vEZ1IeDFgBCUNPBWwD11WXb/L3LgQHC08DJwQlQC3hCDAvgDtP2jVc0iiM4UyzyrbEZUfeBdwfYAhPAysLbLsvYyEuYbE2m71Ud5xaaqk7KY4G4ix4oI4zLYiNEPAZUXWu13q2B1Xwd0MfIYJjKYlwvKOJbwjwIwA9dsxyca4CW95nndnUoIWQZhj1XdBnIR3rcxTHSu5BngW+N564O0htDPTqm9WKY1IG3B5yELaL5N9rwn9HZZhug74SM57JJrSDFyIiVYf9tluIya8VQtMtK6XbFpXBewLwV3xStmG4Bdyf4fHvXus8lcW8TxvZ+nLG+6MYS2mODG0sEkCP2W5d0SODR5Obot1PlhEu19mub6vlFO5GlfHw2AQs8vAixXiJAMsBbplqLcAn2IWif4BxsnRL5MkWtMmrxGAO4FX42JEbnENr1/EaBy3ri0OoZ1ZVn0z4yK8yWSuqHmlt2RUBGW2Vee0KKZypaDTcmqXynGqXNspc+f1IbU1XY7HgG/jooFNwOvWO7CU7BHt2xxVMOFWzG6AIPHAJYzE5gAOALf9D31vBc6W83ej0pYdIfiC/RH1/SGrD+1RaeBK4IGA4azVEQivBlgg5z/jLwymkBlMfUTF4Y+EWFzHv6xTkfhjgaV93SqO7JwhBqqXkS0mF2MW1NMSDRo3mh+gFji5wDSmBO3PtTRtjTjijt+XtJzoUUm3a96aLw2IIMOkAbNpyWnDDsnNH+3DZ10R/mApdpBOwuyVtttZ4cfaREWXONl+trd9XYJ+DGP2B2L5fA9XokGowWxK98MMMtdQ9lLB+6S3YQKnlxaQd6IYDfurpmWYL6FiRTvmY5o+TGCzOocxcISxMEd9k4FFmEUmJ/8Bgi99jlp6XS/3PcCTwPmu93euD20mYIKiH3hY/Y389yuoWNEAvAL85WGRj2I2Lq0ic/fAJuA54D2ZhrnLDWNW3W6ivL9W9UW9+GWbffqOaZeBWETIC1/l+A+chwnStmIWz5vFl3MMQArzKdeApB+AT0QjUyieVANnYnYiJFQciqIoiqIoiqIoiqIoiuLJv3j56EqFGeTaAAAAAElFTkSuQmCC" width="24" height="24" alt="1x speed">',"speed-1.50":'<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAYAAACOEfKtAAAC9HpUWHRSYXcgcHJvZmlsZSB0eXBlIGV4aWYAAHja7ZddktsqEIXfWUWWoP6jm+UgEFXZQZafA5Kdscd58L1PqTKUAEHr0PQHeCYdv36O9AOJSuSk5pFLzhuSFi1c0YjtTHWVtOkqV7JrCO8P/ek+wOgS1HK+Rr7sb/10FziripZ9EYp2DeyPA0Uv/XgSuiaS6RGj0S+hcgkJnwN0CdRzWVsu4V+XsB9n3W8rifNJsxiNy1r/fo49v6sjet0wjzAfQrKhFLkckPlYkooGoSRBOFAq2oqhCtNyeYKAvIrTPcEujemqvjR6oHJv0ev+9ExL+TKRpyDne/2yP5G9prJC/2VmjavFj/0up1TanqK/gj96jLVmrKJqRqjztajbUlYLdsChc+pI0Mub4zFI+MoFObCrG7ZC39q2IzcqxMA1SKlTpUHHqhs1uKh8JHY0mBvL6gxxLtzk5IdMg12KdAmQbAs7mN59oTVt2VpaswVm7gRTJogRPnk7p3c/GGMeBaIt7rGCX8wz2HBjkpslzECExhVUWwG+5ec0uQoI2ozyPCIFgd1Pid3oz00gC7TA0FCfZ5C8XwIIEaY2OIMzoQRqJEaZNmd2IgQyAKjCdRblHQTIjDucZBXJYBM8p8YnTsuUjdGd0I/LDCRMsjjYFKmApWrYP66BPVRNTM0sm1tYsZola7acs+d5KVYX1+Tm2d3Di9eQ0LDI4RFRohYugkvTSi5eopRSK+asUK74usKg1p132XW3tOfd99jLXhu2T9NmLTdv0Uqrnbt03B89d+/RS68HHdhKhx525MOPOMpRB7bakDR02MjDR4wy6p3ahfVbfoMaXdR4kZqGfqeGXvebBM3rxCYzAOOkBOI+EWBD82S2BanyJDeZbYVxKozhpE1mnSYxENSD2Abd2CU+iU5y/4tbcn3gxv+VXJro3iT3ndsran3+DLVF7DyFM6ib4PRh/IjKUeeP3bc6/W3g3foj9BH6CH2EPkIfoY/QPyQ08MfD/C/wN2CdqM5T/ye5AAAAYXpUWHRSYXcgcHJvZmlsZSB0eXBlIGlwdGMAAHjaPYnBDYAwDAP/mYIRktiIdh3SD78+2F+YSuCTLVu2a95l2xLT0JjsHE7xK0aUJw7VhoTLuzJe1lN6Ti2KBNAtxzfd7QEw5hTcAducfAAAAYVpQ0NQSUNDIHByb2ZpbGUAAHicfZE9SMNQFIVPW7VWKw52EHHIUJ0siIo4ahWKUCHUCq06mLz0D5o0JCkujoJrwcGfxaqDi7OuDq6CIPgD4i44KbpIifclhRYxXni8j/PuObx3H+Cvl5lqdowDqmYZqURcyGRXheArfOhFCF0ISczU50QxCc/6uqduqrsYz/Lu+7P6lJzJAJ9APMt0wyLeIJ7etHTO+8QRVpQU4nPiMYMuSPzIddnlN84Fh/08M2KkU/PEEWKh0MZyG7OioRJPEUcVVaN8f8ZlhfMWZ7VcZc178heGc9rKMtdpDSOBRSxBhAAZVZRQhoUY7RopJlJ0HvfwDzl+kVwyuUpg5FhABSokxw/+B79na+YnJ9ykcBzofLHtjxEguAs0arb9fWzbjRMg8AxcaS1/pQ7MfJJea2nRI6B/G7i4bmnyHnC5Aww+6ZIhOVKAlj+fB97P6JuywMAt0LPmzq15jtMHIE2zSt4AB4fAaIGy1z3e3d0+t397mvP7AdDBcmazf/6+AAAPw2lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4KPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNC40LjAtRXhpdjIiPgogPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iCiAgICB4bWxuczpzdEV2dD0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL3NUeXBlL1Jlc291cmNlRXZlbnQjIgogICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICAgeG1sbnM6R0lNUD0iaHR0cDovL3d3dy5naW1wLm9yZy94bXAvIgogICAgeG1sbnM6dGlmZj0iaHR0cDovL25zLmFkb2JlLmNvbS90aWZmLzEuMC8iCiAgICB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iCiAgIHhtcE1NOkRvY3VtZW50SUQ9ImdpbXA6ZG9jaWQ6Z2ltcDplNDBjOGRjOC1kY2QwLTRkMTctYmJiYy03YWNlOWM1NTQ0OGIiCiAgIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6YmJhNjM3NmYtZGU4Yy00NmM3LTljZjMtZjQ3Nzc4MWJlZjJkIgogICB4bXBNTTpPcmlnaW5hbERvY3VtZW50SUQ9InhtcC5kaWQ6ODI2OWFlMzQtYThmMy00OTg2LTgyOGMtYzgwZDJkYzg5MGM2IgogICBkYzpGb3JtYXQ9ImltYWdlL3BuZyIKICAgR0lNUDpBUEk9IjIuMCIKICAgR0lNUDpQbGF0Zm9ybT0iTGludXgiCiAgIEdJTVA6VGltZVN0YW1wPSIxNzM2NTg2NzU5MzM3NjcwIgogICBHSU1QOlZlcnNpb249IjIuMTAuMzAiCiAgIHRpZmY6T3JpZW50YXRpb249IjEiCiAgIHhtcDpDcmVhdG9yVG9vbD0iR0lNUCAyLjEwIj4KICAgPHhtcE1NOkhpc3Rvcnk+CiAgICA8cmRmOlNlcT4KICAgICA8cmRmOmxpCiAgICAgIHN0RXZ0OmFjdGlvbj0ic2F2ZWQiCiAgICAgIHN0RXZ0OmNoYW5nZWQ9Ii8iCiAgICAgIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6NzBiNTI5NjQtNTc0NC00NmNiLWE5NDYtYjYwMmNjMWVkOWRmIgogICAgICBzdEV2dDpzb2Z0d2FyZUFnZW50PSJHaW1wIDIuMTAgKExpbnV4KSIKICAgICAgc3RFdnQ6d2hlbj0iMjAyMy0xMC0zMVQxNToxMTo0MSswNTozMCIvPgogICAgIDxyZGY6bGkKICAgICAgc3RFdnQ6YWN0aW9uPSJzYXZlZCIKICAgICAgc3RFdnQ6Y2hhbmdlZD0iLyIKICAgICAgc3RFdnQ6aW5zdGFuY2VJRD0ieG1wLmlpZDo0YmZmMjFlNy03ODE5LTQyYzgtODAwYi1lYjFlNmY2MDRiZDQiCiAgICAgIHN0RXZ0OnNvZnR3YXJlQWdlbnQ9IkdpbXAgMi4xMCAoTGludXgpIgogICAgICBzdEV2dDp3aGVuPSIyMDIzLTEwLTMxVDE1OjMxOjU5KzA1OjMwIi8+CiAgICAgPHJkZjpsaQogICAgICBzdEV2dDphY3Rpb249InNhdmVkIgogICAgICBzdEV2dDpjaGFuZ2VkPSIvIgogICAgICBzdEV2dDppbnN0YW5jZUlEPSJ4bXAuaWlkOmQ3YWQ3ZmQ3LWY0YTItNDM2MC05ZDE1LTgwM2E0NzliZDFhMCIKICAgICAgc3RFdnQ6c29mdHdhcmVBZ2VudD0iR2ltcCAyLjEwIChMaW51eCkiCiAgICAgIHN0RXZ0OndoZW49IjIwMjMtMTEtMDNUMTI6MjA6NDQrMDU6MzAiLz4KICAgICA8cmRmOmxpCiAgICAgIHN0RXZ0OmFjdGlvbj0ic2F2ZWQiCiAgICAgIHN0RXZ0OmNoYW5nZWQ9Ii8iCiAgICAgIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6YjUwZjgyM2QtYjEzNy00ODUxLTk3NGEtOGQxMDE4YmIwOThkIgogICAgICBzdEV2dDpzb2Z0d2FyZUFnZW50PSJHaW1wIDIuMTAgKExpbnV4KSIKICAgICAgc3RFdnQ6d2hlbj0iMjAyNS0wMS0xMVQxNDo0MjozOSswNTozMCIvPgogICAgPC9yZGY6U2VxPgogICA8L3htcE1NOkhpc3Rvcnk+CiAgPC9yZGY6RGVzY3JpcHRpb24+CiA8L3JkZjpSREY+CjwveDp4bXBtZXRhPgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgCjw/eHBhY2tldCBlbmQ9InciPz53lMvMAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAB3RJTUUH6QELCQwnEZCPswAABNZJREFUeNrtm2uIVVUUgD9nUhvL0Ap7EDOOlmMxPc0cGBKNkH74qLCcHxFR2EPwTxYkQQQWJo5GRIX1J9FIf/ig1IEaqIgY1LG0iIjKsdBQnCy1cnzMmX7sdbj7ns45d87cfe69c+76YMO9++579j7rrL3X2muvA4qiKIqiKIqiKIqiKIoybBgxjMdeA1xmlTlSfxg4BBwAzuojzudK4GngM6AfGIgpfUAX8DrQBkyqVqGNBR4BdgLnCgitUPkBWOhy5lX6FF4CtAN1gfpeYDvwK/AXcBPwjPz2BOABM4AWoBm4KPD/bmA50Jl17eu2tOcUsB64L0QgbVa7lsBvlwCzgBUibFsjO4HpWRbgXcAamXZ1Me0esIRye0y78cBK4B+rvQe8FfJQqopLgc+BLWKdC3Et8E5gTf0IGKN2OhlNYlh8IR4DplayERkn0yWpS+EB7wHvpzCmK4D9wHXy/ZgI9mQlPvGFRbggv6U0phUhfW0drHJVuwYuBt6VzyeAg8Cd8n0ZsFZXuXg2iMb1ArcCVwO/S905oFVFFE+jTGHbcMwEzosQ9w/zeEHZWGWthw+qOIZmmU+JAA/E+Za1KQYALhcHt9jSJ0aklJyRe7gbuAr4TvzFkvCw3PSAo3JQ9rPl0MLTMoYdUY1qUuj4ZmC0w+s1yM2Umj8wITSA2VF78TQ20K8BPTKFXbA3RSe6ELuARbJHngV0ZHXRvxgT95vi+LoTyEW+38yq4FZZfpu/5XvUYR975bpfZ014o4F9McbH1TbsAytSkylesYR1BHgVWE0uWOoBcx30s1qu1w+MdGVEJgD3A6NStoLbxCXyGQMskKDE81a7yVa7DcA34mG0AxPlc02IB+LXdWMCsj5TgXvk90lW+2tcGbROh35eXFke6PftkDabQsbXlbAfz9oP1/H/sxO/zHPlB/5Ygil6AfglUHc8pF1dhBOchCPWGndWnPcwjgYriok01Kc8hU9GCKxRDMhm4BbRnvmW0zsX+Niamg9Z//UitoVH5YHZitUo8nkKeM5auo5nxYjMlJv2p9cXwPfW9wuYs+FiWWMZkVoyxhKZcsG16jzwrKM+NpILumaSO8TyHsZkKnQA0xxev0cE+CVKYm6wtPqlUgUTmjBh8vGOrrcHeLFMApxjff60VJ2uTcEfbCqTAHdK/39GGZA0NHAj5mjQpQb+VAbhNWMSmZB1tV9XtGRssnYpt6k4knEjuTjgdhVHMkbITsbXvmkqkmhmS2CkzapbZhmvbZU46FqSH22mlbf3oaVpizGpHH7O4M+U5zArlskS+UjqxnjAuhTG0wr8a/Vxglw6cXMlat+8InzBtFyZe8k/x/YwweJBUeq84A7gcYaW3rYlpTGdkWnrn2VvrVbLO474RPSwtXipNYUHMGH9kdUovHrgb0xgdDBpIC2YY0r7FYrHsiiYpZjEnjcwKSNRLLKEMaOA4NaT/5rYHuD6rGrW7oAh+UrW0InkH0dEvWhTgwlJvUB+Nr4fYV6Z9Sk7HfNioRdilXsxIaZ2zPmIX79OSpdM6+D/TmPyratqh9EIvIw5pRuqG7QbeBKT9+d03zfc9qmtmFO4BjEe9ZgDb/9e+jDvCx/CHE/2AJ8A3+rONZpRYmQa0KRwRVEURVEURVEURVEURYniPzhn3IN1irUKAAAAAElFTkSuQmCC" width="24" height="24" alt="1.5x speed">',"speed-2.00":'<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAYAAACOEfKtAAAC83pUWHRSYXcgcHJvZmlsZSB0eXBlIGV4aWYAAHja7ZdNkuQoDIX3nGKOYP0hcRwMJqJvMMefB3Z6qrKyFzmz6oiEMGCBn0AfkFXp+PvXSH8hUYmc1DxyyXlD0qKFKxqxnamukjZd5Up2deH9mz3dHQyToJbzNfI1/mGnW+CsKlr2RSja1bF/7yh66ceT0OVI5owYjX4JlUtI+OygS6Cey9pyCf+6hP046/5YSZxPmsVoXNb697Pv+V0d0esGP8J8CMmGUuSagMzHklQ0CCUJwoFS0VbY6jWUzoC8itOd4DaNOVV9OegblbtFr+3pmZbyNUSegpzv+qU9kb2mskL/xbPG1eLvdpdTKm1P0V/BHz3GWjNWUTUj1Pla1B21BWV04NDpOhL08uZ4DBK+ckEO7OqGrdC3tu3IjQoxcA1S6lRp0LHqRg1TVD4SOxrMjWUZQ5wLNzn5IdNglyJdApDbwq7C91xouS1bS8tbwHMnDGWCGOGTt3N694Mx5lEg2uKOFebFPIONaUxys8QwEKFxBdVWgB/5OU2uAoI2ozyPSEFg91NiN/r3JpAFWjDQUJ9nkLxfAggRXBsmgzOhBGokRpk2Z3YiBDIAqGLqLMo7CJAZd0ySVSSDTfB0jU+c1lA2hjnBjssMJEyyONgUqYClatg/roE9VE1MzSybW1ixmiVrtpyz53kpVhfX5ObZ3cOL15DQsMjhEVGiFi6CS9NKLl6ilFIrfFYoV3xdMaDWnXfZdbe059332MteG7ZP02YtN2/RSqudu3TcHz1379FLrwcd2EqHHnbkw484ylEHttqQNHTYyMNHjDLqTe3C+iO/QY0uarxIzYF+U4PV/SFB8zqxyQzAOCmBuE8E2NA8mW1BqjzJTWZbYZwKY0zSJrNOkxgI6kFsgx7sEp9EJ7n/xS25fuPG/5VcmujeJPeT2ytqff4MtUXsPIUzqJvg9KH/iMpR54/djzr9ruPd+iP0EfoIfYQ+Qh+hj9AfJDTwx8P8L/AfxFyow7c2uoEAAABgelRYdFJhdyBwcm9maWxlIHR5cGUgaXB0YwAAeNo9icENgFAMQu+dwhFoqfG7ju3Fmwf3j/gT5QUCwc7rLlumMowjI/dspPjl7YXgpjoYhLwq/WU+pefQSgGSsOhvAvYAMDEUz5cVn3MAAAGFaUNDUElDQyBwcm9maWxlAAB4nH2RPUjDUBSFT1u1VisOdhBxyFCdLIiKOGoVilAh1AqtOpi89A+aNCQpLo6Ca8HBn8Wqg4uzrg6ugiD4A+IuOCm6SIn3JYUWMV54vI/z7jm8dx/gr5eZanaMA6pmGalEXMhkV4XgK3zoRQhdCEnM1OdEMQnP+rqnbqq7GM/y7vuz+pScyQCfQDzLdMMi3iCe3rR0zvvEEVaUFOJz4jGDLkj8yHXZ5TfOBYf9PDNipFPzxBFiodDGchuzoqESTxFHFVWjfH/GZYXzFme1XGXNe/IXhnPayjLXaQ0jgUUsQYQAGVWUUIaFGO0aKSZSdB738A85fpFcMrlKYORYQAUqJMcP/ge/Z2vmJyfcpHAc6Hyx7Y8RILgLNGq2/X1s240TIPAMXGktf6UOzHySXmtp0SOgfxu4uG5p8h5wuQMMPumSITlSgJY/nwfez+ibssDALdCz5s6teY7TByBNs0reAAeHwGiBstc93t3dPrd/e5rz+wHQwXJms3/+vgAAD8NpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+Cjx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDQuNC4wLUV4aXYyIj4KIDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+CiAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIKICAgIHhtbG5zOnhtcE1NPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvbW0vIgogICAgeG1sbnM6c3RFdnQ9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZUV2ZW50IyIKICAgIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIKICAgIHhtbG5zOkdJTVA9Imh0dHA6Ly93d3cuZ2ltcC5vcmcveG1wLyIKICAgIHhtbG5zOnRpZmY9Imh0dHA6Ly9ucy5hZG9iZS5jb20vdGlmZi8xLjAvIgogICAgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIgogICB4bXBNTTpEb2N1bWVudElEPSJnaW1wOmRvY2lkOmdpbXA6NDliOGQ3ODctNzUwMy00OTc3LWIwYTItMGEyZWUwZmRjNjdhIgogICB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOmU3MGU2OThlLTZjOWMtNDIzMS04OTExLTE2OTQ1MmUxNWQyMiIKICAgeG1wTU06T3JpZ2luYWxEb2N1bWVudElEPSJ4bXAuZGlkOmIzMWI2YzU3LTY0YTItNGE0Yi04M2U2LTIwYjY0ZmQ1Y2NkYSIKICAgZGM6Rm9ybWF0PSJpbWFnZS9wbmciCiAgIEdJTVA6QVBJPSIyLjAiCiAgIEdJTVA6UGxhdGZvcm09IkxpbnV4IgogICBHSU1QOlRpbWVTdGFtcD0iMTczNjU4NjYzMDc4NzQwNiIKICAgR0lNUDpWZXJzaW9uPSIyLjEwLjMwIgogICB0aWZmOk9yaWVudGF0aW9uPSIxIgogICB4bXA6Q3JlYXRvclRvb2w9IkdJTVAgMi4xMCI+CiAgIDx4bXBNTTpIaXN0b3J5PgogICAgPHJkZjpTZXE+CiAgICAgPHJkZjpsaQogICAgICBzdEV2dDphY3Rpb249InNhdmVkIgogICAgICBzdEV2dDpjaGFuZ2VkPSIvIgogICAgICBzdEV2dDppbnN0YW5jZUlEPSJ4bXAuaWlkOjRjNmY5MTE5LTE2Y2YtNDgyNC1iMWY5LWYxZmNjMDgwNTgzZSIKICAgICAgc3RFdnQ6c29mdHdhcmVBZ2VudD0iR2ltcCAyLjEwIChMaW51eCkiCiAgICAgIHN0RXZ0OndoZW49IjIwMjMtMTAtMzFUMTU6MTE6NDQrMDU6MzAiLz4KICAgICA8cmRmOmxpCiAgICAgIHN0RXZ0OmFjdGlvbj0ic2F2ZWQiCiAgICAgIHN0RXZ0OmNoYW5nZWQ9Ii8iCiAgICAgIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6M2E5MmI5NTQtMGE1Zi00NDI1LWFkMGEtOTRkOGFhMjBjMTU1IgogICAgICBzdEV2dDpzb2Z0d2FyZUFnZW50PSJHaW1wIDIuMTAgKExpbnV4KSIKICAgICAgc3RFdnQ6d2hlbj0iMjAyMy0xMC0zMVQxNTozMTo0MiswNTozMCIvPgogICAgIDxyZGY6bGkKICAgICAgc3RFdnQ6YWN0aW9uPSJzYXZlZCIKICAgICAgc3RFdnQ6Y2hhbmdlZD0iLyIKICAgICAgc3RFdnQ6aW5zdGFuY2VJRD0ieG1wLmlpZDo4OTI1MjY2OS01M2JkLTRlNTktOGE2My1lN2M5ZTgxYzZmNjQiCiAgICAgIHN0RXZ0OnNvZnR3YXJlQWdlbnQ9IkdpbXAgMi4xMCAoTGludXgpIgogICAgICBzdEV2dDp3aGVuPSIyMDIzLTExLTAzVDEyOjIwOjQ4KzA1OjMwIi8+CiAgICAgPHJkZjpsaQogICAgICBzdEV2dDphY3Rpb249InNhdmVkIgogICAgICBzdEV2dDpjaGFuZ2VkPSIvIgogICAgICBzdEV2dDppbnN0YW5jZUlEPSJ4bXAuaWlkOjA1YjNjZDZjLWUwZGYtNGYzNy04ZTg5LTVmMDFiOTNiZTM2NCIKICAgICAgc3RFdnQ6c29mdHdhcmVBZ2VudD0iR2ltcCAyLjEwIChMaW51eCkiCiAgICAgIHN0RXZ0OndoZW49IjIwMjUtMDEtMTFUMTQ6NDA6MzArMDU6MzAiLz4KICAgIDwvcmRmOlNlcT4KICAgPC94bXBNTTpIaXN0b3J5PgogIDwvcmRmOkRlc2NyaXB0aW9uPgogPC9yZGY6UkRGPgo8L3g6eG1wbWV0YT4KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgIAo8P3hwYWNrZXQgZW5kPSJ3Ij8+T3zvpgAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAuIwAALiMBeKU/dgAAAAd0SU1FB+kBCwkKHhjPoD0AAATqSURBVHja7ZtbbBVFGMd/p0VLSxGIIIIXEChiDAaMl2ii4C3Cg/ogEJqIxngJeGlCUB7UmII+mHglpmrigzFRDAEUJAIx4ZJoA0IUSqq2WFACjUBBQFKL2J7jw3wnDuvZs+cye5bu+X7JJGfPzs7O/vebmW++mQVFURRFURRFURRFURRF6TckYvAMFwBDgKHAKGAm0A6cBvYA+4CUCngu1wH1wFxgbEDeLuA7STuAncCJcmwt44GXgFaxqEJTH7ASmFQuwlUBX/mIsQt4DVgMzAe+l/87gWnAcyLWwQzX/gN8CFwRdwGv9jz4L8ASHwv6UvJ0ZDh3OTBLBE1a5fUArwMXx1nEp4BG4IaAfKtElJ8C8l0PbPC8mJPAfeXuVdwjfeRjOea/A9jmadZPqnOWvyfyCHDGEnJDrh5KKdyYacAiYISDsn4GXgYOhVDP+4EvgAo5bgKeOR/e8DdFuh3e1BhCHYeJf+i912y1wNzYKvUEaAamAIOAP4Ebgb3a0/kzEOgWi9sox/WWFbYA1X4XV6p+9MrIvRtYKINJK3CJWN9ImVc3q1T5z4A6xAq7gFq1wPzoE8t7AKiR39+6HkQqxNTDfpCuiEQcALRJIOM4cJUI6YTJMhqmSpBagMERifioVY96lwXPKZF4KenoJ0Yk4CAJOKSAT1w24QpgOjA1ZH+yV/y03RH2hxuBe4FjwKXSrfR7qoH10rGnrbNWXA/XoakGqzXcEpdR8hrroQ6LhfbKcVI6/7sc3Wuida9FcXI13iU4fD/P0WicfjlvxUnASuCoJdhOYAGwTsRLyfmhDu7VKeWt8CqbicuAGdnmgCWgRzrvzix5rrWCFCswq3QA70u/tUzOzwQ+K2CQnAGMswYzgDFBF9Z43mqU6ajUxw970n+359xo69wrBbzA2T51+surspf0ZPp8oFXq40e39dsbLhvhky9XDvhc1x3UhJPAndKMo27CnQF5WsQqEsATwGbgiLgzb3ry5csOseL0VHU9UIdZSo0Vy63mdQZYi9l5kP7vrKNZzO9S3vK4CTgaswcmW196EJhQpBtzVspaFsfQUzXwKmb95Q/MDoUm4CNHIt5qlbOAMiIBvOdAxEarjAmuggkXAS9iVvnDpA/YhNl+UaiITZblHMIsqHfkUUazWOF+TGzQCY+X2CecGpElDsfsWEgBH2TqHAtlDXBbCS2wpYgyUsDTIuR8zEajLZhw3L6AaxdaOq2jzEnINC9tiasC8g8DTknePcRjR68TEd8G/pY+PBtLLLHnqHTnUhVwfgxmy1sK+NFn2qsIS2UGUyfHFwLbyWOPTNgMkPlpsSmMPmigNGd7dH7HEq8pavEarI642HRA/DHXvGHd47j1ewvmM4pI+dqxP7g4pIHFuzzwq/iAgU0rbB6WEczF9rY2YHVI9TzlOZ6LWcYsO0blmX8kZjnADok9X66jaYPflCsDlZL/pCXeD5jPKmIXqlqLWUBvkNmBH9m+E0lTAzwkYqWFS4pzXRVHq6rj/4s6H2M+aRiSo4DVwO2YL5O8HsFhzOpbrHlWQkneETmJ+XJppUy72ixXZKn8385/i+J26gBeyGWkjdMcdjomyny6QBeoB/gUs2iWcFWp/kgt8CBwE3CllewdCMeA36zUDnyOCfkrPgwGbsZnP7OiKIqiKIqiKIqiKIqilDn/AkkxNGAuRZ+BAAAAAElFTkSuQmCC" width="24" height="24" alt="2x speed">'},Tg="X-Jewel-Studio",Sg="69d2c1660df6540944e25eb708fb252724ab27fb";class Bl extends HTMLElement{progressBarStyle=Et.None;_hls;_videoPlayer;background="dark";_autoPlay=!1;_streamLoaded=!1;_startLevel=-1;isValidProgressBarStyle(e){return Object.values(Et).includes(e)}svgIcons=vg;constructor(){super(),this.attachShadow({mode:"open"})}static get observedAttributes(){return["video-src","poster-src","auto-play","width","playback-speeds","default-speed","default-quality","show-time-display","show-speed-control","progress-bar-style","background","aspect-ratio"]}attributeChangedCallback(e,t,i){e==="progress-bar-style"?(this.progressBarStyle=this.isValidProgressBarStyle(i)?i:Et.None,this.render()):e==="background"&&(this.background=i==="light"?"light":"dark",this.updateControlsColor())}async connectedCallback(){this.background=this.getAttribute("background")==="light"?"light":"dark",this._autoPlay=this.hasAttribute("auto-play"),this._streamLoaded=this._autoPlay,this._startLevel=parseInt(this.getAttribute("default-quality")||"-1"),await this.render(),await this.initializePlayer(),this.setupProgressBarInteractions(),this.updateControlsColor()}setupProgressBarInteractions(){if(!this.shadowRoot||!this._videoPlayer)return;const e=this.shadowRoot.querySelector(".progress-bar"),t=this.shadowRoot.querySelector(".progress-bar-fill");if(!e||!t)return;const i=()=>{if(!this._videoPlayer)return;const r=this._videoPlayer.currentTime/this._videoPlayer.duration*100;if(t.style.width=`${r}%`,this.progressBarStyle===Et.Segments){const n=this.shadowRoot?.querySelectorAll(".progress-segment");n&&n.forEach((o,c)=>{const u=(c+1)*(100/n.length);r>=u?o.classList.add("filled"):o.classList.remove("filled")})}};this._videoPlayer.addEventListener("timeupdate",i);const s=r=>{if(!this._videoPlayer||!(r instanceof MouseEvent))return;const n=e.getBoundingClientRect(),o=Math.max(0,Math.min(1,(r.clientX-n.left)/n.width));this._videoPlayer.currentTime=o*this._videoPlayer.duration};e.addEventListener("click",s)}renderProgressBar(){switch(this.progressBarStyle){case Et.DualLayer:return`
188
+ </svg>`,"speed-0.50":'<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAYAAACOEfKtAAAC9HpUWHRSYXcgcHJvZmlsZSB0eXBlIGV4aWYAAHja7ZddktsqEIXfWUWWoP6jm+UgEFXZQZafA5Kdscd58L1PqTKUADXo0PQHeCYdv36O9AOJSuSk5pFLzhuSFi1c0YjtTHWVtOkqV7KrC+8P9nTvYJgEtZyvka/xNzvdBc6qomVfhKJdHftjR9FLP56ErolkesRo9EuoXELCZwddAvVc1pZL+Ncl7MdZ99tK4nzSLEbjsta/n33P7+qIXjfMI8yHkGwoRS4HZD6WpKJBKEkQDpSKti7LJn55goC8itM9Ydo0pqv6ctADlXuLXtvTMy3la4g8BTnf65f2RPaaygr9l5k1rhY/2l1OqbQ9RX8Ff/QYa81YRdWMUOdrUbelrBbGAYfOqSNBL2+OxyDhKxfkwK5u2Ap9a9uO3KgQA9cgpU6VBh2rbtTgovKR2NFgbizLGOJcuMnJD5kGuxTpEoDcFnYVvvtCa9qytbRmC8zcCUOZIEb45O2c3v1gjHkUiLa4xwp+Mc9gw41JbpYYBiI0rqDaCvAtP6fJVUDQZpTnESkI7H5K7EZ/bgJZoAUDDfV5Bsn7JYAQYWqDMzgTSqBGYpRpc2YnQiADgCpcZ1HeQYDMuMNJVpEMNsFzanzitIayMcwJdlxmIGGSxcGmSAUsVcP+cQ3soWpiambZ3MKK1SxZs+WcPc9Lsbq4JjfP7h5evIaEhkUOj4gStXARXJpWcvESpZRaMWeFcsXXFQNq3XmXXXdLe959j73stWH7NG3WcvMWrbTauUvH/dFz9x699HrQga106GFHPvyIoxx1YKsNSUOHjTx8xCij3qldWL/lN6jRRY0XqTnQ79Rgdb9J0LxObDIDME5KIO4TATY0T2ZbkCpPcpPZVhinwhhO2mTWaRIDQT2IbdCNXeKT6CT3v7gl1wdu/F/JpYnuTXLfub2i1ufPUFvEzlM4g7oJTh/6j6gcdf7YfavT3zrerT9CH6GP0EfoI/QR+gj9Q0IDfzzM/wJ/AwtlqMgGWC/6AAAAYXpUWHRSYXcgcHJvZmlsZSB0eXBlIGlwdGMAAHjaPYk7DoAwDEP3nIIj5GPUch2Sha0D9xemUuunWLGePONNOWbgEh2OC6UgO1aW6tH49vBQ3sm2n2mS5uYCMZomXmuqygcwfhTVhYB0sAAAAYVpQ0NQSUNDIHByb2ZpbGUAAHicfZE9SMNQFIVPW7VWKw52EHHIUJ0siIo4ahWKUCHUCq06mLz0D5o0JCkujoJrwcGfxaqDi7OuDq6CIPgD4i44KbpIifclhRYxXni8j/PuObx3H+Cvl5lqdowDqmYZqURcyGRXheArfOhFCF0ISczU50QxCc/6uqduqrsYz/Lu+7P6lJzJAJ9APMt0wyLeIJ7etHTO+8QRVpQU4nPiMYMuSPzIddnlN84Fh/08M2KkU/PEEWKh0MZyG7OioRJPEUcVVaN8f8ZlhfMWZ7VcZc178heGc9rKMtdpDSOBRSxBhAAZVZRQhoUY7RopJlJ0HvfwDzl+kVwyuUpg5FhABSokxw/+B79na+YnJ9ykcBzofLHtjxEguAs0arb9fWzbjRMg8AxcaS1/pQ7MfJJea2nRI6B/G7i4bmnyHnC5Aww+6ZIhOVKAlj+fB97P6JuywMAt0LPmzq15jtMHIE2zSt4AB4fAaIGy1z3e3d0+t397mvP7AdDBcmazf/6+AAAPw2lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4KPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNC40LjAtRXhpdjIiPgogPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iCiAgICB4bWxuczpzdEV2dD0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL3NUeXBlL1Jlc291cmNlRXZlbnQjIgogICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICAgeG1sbnM6R0lNUD0iaHR0cDovL3d3dy5naW1wLm9yZy94bXAvIgogICAgeG1sbnM6dGlmZj0iaHR0cDovL25zLmFkb2JlLmNvbS90aWZmLzEuMC8iCiAgICB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iCiAgIHhtcE1NOkRvY3VtZW50SUQ9ImdpbXA6ZG9jaWQ6Z2ltcDpmNzU5ZmE3Zi1mYWYzLTRiYjUtOTU2OC01ZWZmOTQ5MzhmOWEiCiAgIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6MmE1YTUxZWQtMjFkNi00MzY2LWJmY2ItZDcyNzJjNzdhN2U3IgogICB4bXBNTTpPcmlnaW5hbERvY3VtZW50SUQ9InhtcC5kaWQ6MGI4NjEwY2EtMDU3Ni00MTJlLTg2NzEtYjRjZWU1YzJkZGFiIgogICBkYzpGb3JtYXQ9ImltYWdlL3BuZyIKICAgR0lNUDpBUEk9IjIuMCIKICAgR0lNUDpQbGF0Zm9ybT0iTGludXgiCiAgIEdJTVA6VGltZVN0YW1wPSIxNzM2NTg2NjY3OTU1MTQ1IgogICBHSU1QOlZlcnNpb249IjIuMTAuMzAiCiAgIHRpZmY6T3JpZW50YXRpb249IjEiCiAgIHhtcDpDcmVhdG9yVG9vbD0iR0lNUCAyLjEwIj4KICAgPHhtcE1NOkhpc3Rvcnk+CiAgICA8cmRmOlNlcT4KICAgICA8cmRmOmxpCiAgICAgIHN0RXZ0OmFjdGlvbj0ic2F2ZWQiCiAgICAgIHN0RXZ0OmNoYW5nZWQ9Ii8iCiAgICAgIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6ZTZkNDA1MzYtMmM4Mi00YmMyLTgwYzctYWM2ZjU0ZGM3YjIxIgogICAgICBzdEV2dDpzb2Z0d2FyZUFnZW50PSJHaW1wIDIuMTAgKExpbnV4KSIKICAgICAgc3RFdnQ6d2hlbj0iMjAyMy0xMC0zMVQxNToxMTozNiswNTozMCIvPgogICAgIDxyZGY6bGkKICAgICAgc3RFdnQ6YWN0aW9uPSJzYXZlZCIKICAgICAgc3RFdnQ6Y2hhbmdlZD0iLyIKICAgICAgc3RFdnQ6aW5zdGFuY2VJRD0ieG1wLmlpZDphN2IwZGUxZi1iYmFhLTQ1ZWQtOGU3Mi1mNzIxZDViMGUzZmIiCiAgICAgIHN0RXZ0OnNvZnR3YXJlQWdlbnQ9IkdpbXAgMi4xMCAoTGludXgpIgogICAgICBzdEV2dDp3aGVuPSIyMDIzLTEwLTMxVDE1OjMyOjIwKzA1OjMwIi8+CiAgICAgPHJkZjpsaQogICAgICBzdEV2dDphY3Rpb249InNhdmVkIgogICAgICBzdEV2dDpjaGFuZ2VkPSIvIgogICAgICBzdEV2dDppbnN0YW5jZUlEPSJ4bXAuaWlkOjZiNTdlZmMzLTdmNjMtNGE0MS1hZWYzLTc4MGQ0NzU1YmRjZiIKICAgICAgc3RFdnQ6c29mdHdhcmVBZ2VudD0iR2ltcCAyLjEwIChMaW51eCkiCiAgICAgIHN0RXZ0OndoZW49IjIwMjMtMTEtMDNUMTI6MjE6NTUrMDU6MzAiLz4KICAgICA8cmRmOmxpCiAgICAgIHN0RXZ0OmFjdGlvbj0ic2F2ZWQiCiAgICAgIHN0RXZ0OmNoYW5nZWQ9Ii8iCiAgICAgIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6MzJhOTk4N2MtMWE5ZS00MjNiLWJiZGUtMWQxMmE2Njg4MDQ1IgogICAgICBzdEV2dDpzb2Z0d2FyZUFnZW50PSJHaW1wIDIuMTAgKExpbnV4KSIKICAgICAgc3RFdnQ6d2hlbj0iMjAyNS0wMS0xMVQxNDo0MTowNyswNTozMCIvPgogICAgPC9yZGY6U2VxPgogICA8L3htcE1NOkhpc3Rvcnk+CiAgPC9yZGY6RGVzY3JpcHRpb24+CiA8L3JkZjpSREY+CjwveDp4bXBtZXRhPgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgCjw/eHBhY2tldCBlbmQ9InciPz64X1WPAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAB3RJTUUH6QELCQsHZb85vAAABP5JREFUeNrtm2toXEUUgL+ka0xM0lQ2YlCs1aYlaCHxnVqxUir4qLZaS7UI9odVqq2g+IT8kZaqoIjxjfgCkdbaH6Xon7RUrdhCqZWUCkbUGmwVnzE20aZu1h/3LDm5vfu4m4m79+75YODu7MyZe8+eO+fMmVkwDMMwDMMwDMMwDMMwjMhQFeF7rwYagKlS5gGnA33AEeBzYNh+4vE0ArcDHwAjQDpHOQ7sB14GVgJtETeYojkZWAJsEotKT6D8ANwFJCrlFV4CvAU0+er/ArYCXwODQBLoku+6gO+AS4BO4AL5ETRfSbstotjY8r6ynmFgM3ALUOdr16naLQ+w4E7gYZkbtUXuBRbGWYGzgGeAOwKsUHOhUspNOdqdAjwK/O5T5Bb5rmKpFiV8JJ45H6cCTwBDSom7gWbz0+E4A/hUKfFPYH5UnUhSPG19lu+/kRDGNXXAZ0CHfB4GzgO+j5o1LCwgDJmao/9c4DZgSshxVwGjvnH2ADVRU2AS2C5zUVB5J0+AfVQe/oYQY14DpJSX71FK7K6kuWymevA1IfqtU8q7WqaPA0rWskpR4Cz10PeE6NcMPA5cpuraJDhPAz9WSngzWylwtQN5q5W8+ytBgW3qge92IK9GvHBeK6wu8YNPA1oKKI0hwjEXa9sRYINctziyaudMB/4uMIsyELD+1Zyv2t7p6P5qgEMi80A5WmAzUFtg26Y8VujaAjNWuFGu58gPfgKJEirwCwlipxXQ9gjwc561cIZRh/f4IfCIXF8HvBJXJ9KuXuFVDuUmgD9E7ra4Km+FeMqMAkeBp0JMD/nYLHJ/i6Pyns7hePZxYia6GDYomXVxUt4ilQQYAl4EXgMOqwde52CcNUrezFzea7KpAm6VpEEYBoB3A5xDj2RwUnj7HplQoxZv8ygpa9yGIjzzWcD1Mge2q9DoSmBXOaxXw5YOn6yTVAy5MWCsbtX3zCLutS/LfXSVMg4cBI4V0e+4WKG/bkSuWwP6ZKw8JYoOy5dZ6g+X8hUG7+RAY8g+Q+Jl/ewCrpDrxRJmpGVu3CrGsQcv0VoMM+QVXgQ8K3WX4u3kxYK5jCVDM5vm+tX7l5D7G1lYq2TOiFsY85C8zv656hhwr6Mx1iu5DcSQi/BS/pmH3BngdCbCTpHbT4y5SilwsUO5DWLNaeD1cksm1ANvk/vEgU4mrMwRz2WC5yrHS675jO3O9ZSb1XSGjAXzxXNLHScSAF6SsVNkObVQyo31JrxzfoVa4LW4TVXl4zS8U171eBvv8zBC8aSy/htNHeFIMra1uZ8KPdk6EV5Q1nezqSM77eJd71N1yxifU4yU9dVK7BVUJuOwj57n1ktiYkA+/0pA/q+caSX3Nmc/7rNHs4Ff1Bg/MXbCf0GUVxNBJTVJa9F2Cb71WGsL7ZwoIwXuBh4j+wHLQ3hH2Fwzwvg85T7g+Up0CHUUtsesWeGzvt4CA/vYUS/z11GynCDw0QbsYHz660FKf1bIOUuBg8AbwOUFrquX52g3B3hOZVjSeEnYi+NqWe/5JvdemeBbfdaSTYFVwNl4W5N7AxzTm8Q0SapDm20EZ50H8fZFuoFXVf0mvD3ijxk7lqHLP9JmARVEi8xRvRS/NXoQeADHf6aJ4iK5Q+bGc8VhTMfLFU5RYUm/hD3f4qWkPsFLSTknLlmGBHCOKLGP/zdvaBiGYRiGYRiGYRiGYRhR4T+g4LtceW1yGQAAAABJRU5ErkJggg==" width="24" height="24" alt="0.5x speed">',"speed-1.00":'<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAYAAACOEfKtAAAC9HpUWHRSYXcgcHJvZmlsZSB0eXBlIGV4aWYAAHja7ZddktsqEIXfWUWWoP6jm+UgEFXZQZafA5Kdscd58L1PqTKUADXo0PQHeCYdv36O9AOJSuSk5pFLzhuSFi1c0YjtTHWVtOkqV7KrC+8P9nTvYJgEtZyvka/xNzvdBc6qomVfhKJdHftjR9FLP56ErolkesRo9EuoXELCZwddAvVc1pZL+Ncl7MdZ99tK4nzSLEbjsta/n33P7+qIXjfMI8yHkGwoRS4HZD6WpKJBKEkQDpSKtqJr2vnyBAF5Fad7wrRpTFf15aAHKvcWvbanZ1rK1xB5CnK+1y/tiew1lRX6LzNrXC1+tLucUml7iv4K/ugx1pqxiqoZoc7Xom5LWS2MAw6dU0eCXt4cj0HCVy7IgV3dsBX61rYduVEhBq5BSp0qDTpW3ajBReUjsaPB3FiWMcS5cJOTHzINdinSJUCyLexgeveF1rRla2nNFpi5E4YyQYzwyds5vfvBGPMoEG1xjxX8Yp7BhhuT3CwxDERoXEG1FeBbfk6Tq4CgzSjPI1IQ2P2U2I3+3ASyQAsGGurzDJL3SwAhwtQGZ3AmlECNxCjT5sxOhEAGAFW4zqK8gwCZcYeTrCIZbILn1PjEaQ1lY5gT7LjMQMIki4NNkQpYqob94xrYQ9XE1MyyuYUVq1myZss5e56XYnVxTW6e3T28eA0JDYscHhElauEiuDSt5OIlSim1Ys4K5YqvKwbUuvMuu+6W9rz7HnvZa8P2adqs5eYtWmm1c5eO+6Pn7j166fWgA1vp0MOOfPgRRznqwFYbkoYOG3n4iFFGvVO7sH7Lb1CjixovUnOg36nB6n6ToHmd2GQGYJyUQNwnAmxonsy2IFWe5CazrTBOhTGctMms0yQGgnoQ26Abu8Qn0Unuf3FLrg/c+L+SSxPdm+S+c3tFrc+fobaInadwBnUTnD70H1E56vyx+1anv3W8W3+EPkIfoY/QR+gj9BH6h4QG/niY/wX+BtKUqMT2Ahu4AAAAYHpUWHRSYXcgcHJvZmlsZSB0eXBlIGlwdGMAAHja48osKEnmUgADEyMuYwsTIxNLkxQDEyCEA8MUw2QDI2NzINPC2MjYAIhNgaQhCIJlkoEySUCeCRCC5bmMUmBcAwMuADBKFNK6HFPnAAABhWlDQ1BJQ0MgcHJvZmlsZQAAeJx9kT1Iw1AUhU9btVYrDnYQcchQnSyIijhqFYpQIdQKrTqYvPQPmjQkKS6OgmvBwZ/FqoOLs64OroIg+APiLjgpukiJ9yWFFjFeeLyP8+45vHcf4K+XmWp2jAOqZhmpRFzIZFeF4Ct86EUIXQhJzNTnRDEJz/q6p26quxjP8u77s/qUnMkAn0A8y3TDIt4gnt60dM77xBFWlBTic+Ixgy5I/Mh12eU3zgWH/TwzYqRT88QRYqHQxnIbs6KhEk8RRxVVo3x/xmWF8xZntVxlzXvyF4Zz2soy12kNI4FFLEGEABlVlFCGhRjtGikmUnQe9/APOX6RXDK5SmDkWEAFKiTHD/4Hv2dr5icn3KRwHOh8se2PESC4CzRqtv19bNuNEyDwDFxpLX+lDsx8kl5radEjoH8buLhuafIecLkDDD7pkiE5UoCWP58H3s/om7LAwC3Qs+bOrXmO0wcgTbNK3gAHh8BogbLXPd7d3T63f3ua8/sB0MFyZrN//r4AAA/DaVRYdFhNTDpjb20uYWRvYmUueG1wAAAAAAA8P3hwYWNrZXQgYmVnaW49Iu+7vyIgaWQ9Ilc1TTBNcENlaGlIenJlU3pOVGN6a2M5ZCI/Pgo8eDp4bXBtZXRhIHhtbG5zOng9ImFkb2JlOm5zOm1ldGEvIiB4OnhtcHRrPSJYTVAgQ29yZSA0LjQuMC1FeGl2MiI+CiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogIDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiCiAgICB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIKICAgIHhtbG5zOnN0RXZ0PSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VFdmVudCMiCiAgICB4bWxuczpkYz0iaHR0cDovL3B1cmwub3JnL2RjL2VsZW1lbnRzLzEuMS8iCiAgICB4bWxuczpHSU1QPSJodHRwOi8vd3d3LmdpbXAub3JnL3htcC8iCiAgICB4bWxuczp0aWZmPSJodHRwOi8vbnMuYWRvYmUuY29tL3RpZmYvMS4wLyIKICAgIHhtbG5zOnhtcD0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLyIKICAgeG1wTU06RG9jdW1lbnRJRD0iZ2ltcDpkb2NpZDpnaW1wOmIwMWJkMTBiLTY4ZTUtNDI3Yy05MjZjLWYxMmI1NGE5MDIxZSIKICAgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDoyYWRhMTI4OS0yMDdiLTQwYTMtYjdjNS02OTc4NGQ1Yjc3NTIiCiAgIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDo3NDQ3MTYxMC0zYWY0LTQ0MDAtYTZiMC02NGJjZDgyNDIzMzEiCiAgIGRjOkZvcm1hdD0iaW1hZ2UvcG5nIgogICBHSU1QOkFQST0iMi4wIgogICBHSU1QOlBsYXRmb3JtPSJMaW51eCIKICAgR0lNUDpUaW1lU3RhbXA9IjE3MzY1ODY3MjI2MDkwNzgiCiAgIEdJTVA6VmVyc2lvbj0iMi4xMC4zMCIKICAgdGlmZjpPcmllbnRhdGlvbj0iMSIKICAgeG1wOkNyZWF0b3JUb29sPSJHSU1QIDIuMTAiPgogICA8eG1wTU06SGlzdG9yeT4KICAgIDxyZGY6U2VxPgogICAgIDxyZGY6bGkKICAgICAgc3RFdnQ6YWN0aW9uPSJzYXZlZCIKICAgICAgc3RFdnQ6Y2hhbmdlZD0iLyIKICAgICAgc3RFdnQ6aW5zdGFuY2VJRD0ieG1wLmlpZDoxMTg0Y2IxMi1lMTE2LTRlNTEtYTdlYi05ZTBhY2ZhMWNmZDIiCiAgICAgIHN0RXZ0OnNvZnR3YXJlQWdlbnQ9IkdpbXAgMi4xMCAoTGludXgpIgogICAgICBzdEV2dDp3aGVuPSIyMDIzLTEwLTMxVDE1OjExOjM4KzA1OjMwIi8+CiAgICAgPHJkZjpsaQogICAgICBzdEV2dDphY3Rpb249InNhdmVkIgogICAgICBzdEV2dDpjaGFuZ2VkPSIvIgogICAgICBzdEV2dDppbnN0YW5jZUlEPSJ4bXAuaWlkOmQ5OTdhZmU2LTAwYzQtNDhiYS05MzYxLTRmZmU3MWFlNjIwYSIKICAgICAgc3RFdnQ6c29mdHdhcmVBZ2VudD0iR2ltcCAyLjEwIChMaW51eCkiCiAgICAgIHN0RXZ0OndoZW49IjIwMjMtMTAtMzFUMTU6MzI6MTArMDU6MzAiLz4KICAgICA8cmRmOmxpCiAgICAgIHN0RXZ0OmFjdGlvbj0ic2F2ZWQiCiAgICAgIHN0RXZ0OmNoYW5nZWQ9Ii8iCiAgICAgIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6MzRlYTZjOTAtNjY0OS00ZGUwLTk3NjUtZTNiOGIyMDMxNDgxIgogICAgICBzdEV2dDpzb2Z0d2FyZUFnZW50PSJHaW1wIDIuMTAgKExpbnV4KSIKICAgICAgc3RFdnQ6d2hlbj0iMjAyMy0xMS0wM1QxMjoyMToxOCswNTozMCIvPgogICAgIDxyZGY6bGkKICAgICAgc3RFdnQ6YWN0aW9uPSJzYXZlZCIKICAgICAgc3RFdnQ6Y2hhbmdlZD0iLyIKICAgICAgc3RFdnQ6aW5zdGFuY2VJRD0ieG1wLmlpZDo4MDAxYTYxNy01ZTQxLTQ2YjQtOTk3MS1mMzNhYjIyNDNmMWUiCiAgICAgIHN0RXZ0OnNvZnR3YXJlQWdlbnQ9IkdpbXAgMi4xMCAoTGludXgpIgogICAgICBzdEV2dDp3aGVuPSIyMDI1LTAxLTExVDE0OjQyOjAyKzA1OjMwIi8+CiAgICA8L3JkZjpTZXE+CiAgIDwveG1wTU06SGlzdG9yeT4KICA8L3JkZjpEZXNjcmlwdGlvbj4KIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAKPD94cGFja2V0IGVuZD0idyI/Pk8m2PUAAAAGYktHRAD/AP8A/6C9p5MAAAAJcEhZcwAALiMAAC4jAXilP3YAAAAHdElNRQfpAQsJDAJalFv0AAAFB0lEQVR42u2bfYgVVRTAf7u+LdvNNXar1azdLFoQtlIqWJCicjH72IrokyJFLaIIo5aWNiusxUAMURApsCCyyCUL2TBLihIiU4wk0z7dDDOzWrNNe7nP1x/3DHvfNO9j3sxr9s07P7jMvJn7NeedO+fcc++AoiiKoiiKoiiKoiiKopQNVWXe9zqgXtI0YAqwE/gN2Ar8oX9xJicCNwKvAUNAOkc6DuwCXgLuA6YCiUoU2higA1gNDOYRWr40CPQAtZUyhC8C+oEJrutJYAPwOXBItG253HsB2AhcArTLsc5Vfj/wtPwpx+KsfYst7RkWwcwBxrvyNVr5nnDdS8jwvR/Y7dLIb4Dbgeq4CvA0YIk8fFOOfPVASoTyaI58CWA+8KNLkB8Dp1e6gVkGbAPOKSDvSUAX8KslxO+AVrXT/hgP9FlC/FteEWVhRK4GHhcrWwhfAfNkqIZJNbAOuEF+p4DpwJbR/u/3F+GGtJWgH1cBR13tDIhhykuUjuVK4BSfGrgr5D5MAd4ExoortF4c9RbgZaBTritZuFs0LgXMleG8wdLEHhVRfmv8GHCNde1UYK9lVM5SMWXSKcM0Fx2WFq5SkY3Q68MgfSj5kkBz1G5MU4C2UsDBEPqwEHhGzg8C5wJ/5sh/BfC+nD8vEZ1IeDFgBCUNPBWwD11WXb/L3LgQHC08DJwQlQC3hCDAvgDtP2jVc0iiM4UyzyrbEZUfeBdwfYAhPAysLbLsvYyEuYbE2m71Ud5xaaqk7KY4G4ix4oI4zLYiNEPAZUXWu13q2B1Xwd0MfIYJjKYlwvKOJbwjwIwA9dsxyca4CW95nndnUoIWQZhj1XdBnIR3rcxTHSu5BngW+N564O0htDPTqm9WKY1IG3B5yELaL5N9rwn9HZZhug74SM57JJrSDFyIiVYf9tluIya8VQtMtK6XbFpXBewLwV3xStmG4Bdyf4fHvXus8lcW8TxvZ+nLG+6MYS2mODG0sEkCP2W5d0SODR5Obot1PlhEu19mub6vlFO5GlfHw2AQs8vAixXiJAMsBbplqLcAn2IWif4BxsnRL5MkWtMmrxGAO4FX42JEbnENr1/EaBy3ri0OoZ1ZVn0z4yK8yWSuqHmlt2RUBGW2Vee0KKZypaDTcmqXynGqXNspc+f1IbU1XY7HgG/jooFNwOvWO7CU7BHt2xxVMOFWzG6AIPHAJYzE5gAOALf9D31vBc6W83ej0pYdIfiC/RH1/SGrD+1RaeBK4IGA4azVEQivBlgg5z/jLwymkBlMfUTF4Y+EWFzHv6xTkfhjgaV93SqO7JwhBqqXkS0mF2MW1NMSDRo3mh+gFji5wDSmBO3PtTRtjTjijt+XtJzoUUm3a96aLw2IIMOkAbNpyWnDDsnNH+3DZ10R/mApdpBOwuyVtttZ4cfaREWXONl+trd9XYJ+DGP2B2L5fA9XokGowWxK98MMMtdQ9lLB+6S3YQKnlxaQd6IYDfurpmWYL6FiRTvmY5o+TGCzOocxcISxMEd9k4FFmEUmJ/8Bgi99jlp6XS/3PcCTwPmu93euD20mYIKiH3hY/Y389yuoWNEAvAL85WGRj2I2Lq0ic/fAJuA54D2ZhrnLDWNW3W6ivL9W9UW9+GWbffqOaZeBWETIC1/l+A+chwnStmIWz5vFl3MMQArzKdeApB+AT0QjUyieVANnYnYiJFQciqIoiqIoiqIoiqIoiuLJv3j56EqFGeTaAAAAAElFTkSuQmCC" width="24" height="24" alt="1x speed">',"speed-1.50":'<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAYAAACOEfKtAAAC9HpUWHRSYXcgcHJvZmlsZSB0eXBlIGV4aWYAAHja7ZddktsqEIXfWUWWoP6jm+UgEFXZQZafA5Kdscd58L1PqTKUAEHr0PQHeCYdv36O9AOJSuSk5pFLzhuSFi1c0YjtTHWVtOkqV7JrCO8P/ek+wOgS1HK+Rr7sb/10FziripZ9EYp2DeyPA0Uv/XgSuiaS6RGj0S+hcgkJnwN0CdRzWVsu4V+XsB9n3W8rifNJsxiNy1r/fo49v6sjet0wjzAfQrKhFLkckPlYkooGoSRBOFAq2oqhCtNyeYKAvIrTPcEujemqvjR6oHJv0ev+9ExL+TKRpyDne/2yP5G9prJC/2VmjavFj/0up1TanqK/gj96jLVmrKJqRqjztajbUlYLdsChc+pI0Mub4zFI+MoFObCrG7ZC39q2IzcqxMA1SKlTpUHHqhs1uKh8JHY0mBvL6gxxLtzk5IdMg12KdAmQbAs7mN59oTVt2VpaswVm7gRTJogRPnk7p3c/GGMeBaIt7rGCX8wz2HBjkpslzECExhVUWwG+5ec0uQoI2ozyPCIFgd1Pid3oz00gC7TA0FCfZ5C8XwIIEaY2OIMzoQRqJEaZNmd2IgQyAKjCdRblHQTIjDucZBXJYBM8p8YnTsuUjdGd0I/LDCRMsjjYFKmApWrYP66BPVRNTM0sm1tYsZola7acs+d5KVYX1+Tm2d3Di9eQ0LDI4RFRohYugkvTSi5eopRSK+asUK74usKg1p132XW3tOfd99jLXhu2T9NmLTdv0Uqrnbt03B89d+/RS68HHdhKhx525MOPOMpRB7bakDR02MjDR4wy6p3ahfVbfoMaXdR4kZqGfqeGXvebBM3rxCYzAOOkBOI+EWBD82S2BanyJDeZbYVxKozhpE1mnSYxENSD2Abd2CU+iU5y/4tbcn3gxv+VXJro3iT3ndsran3+DLVF7DyFM6ib4PRh/IjKUeeP3bc6/W3g3foj9BH6CH2EPkIfoY/QPyQ08MfD/C/wN2CdqM5T/ye5AAAAYXpUWHRSYXcgcHJvZmlsZSB0eXBlIGlwdGMAAHjaPYnBDYAwDAP/mYIRktiIdh3SD78+2F+YSuCTLVu2a95l2xLT0JjsHE7xK0aUJw7VhoTLuzJe1lN6Ti2KBNAtxzfd7QEw5hTcAducfAAAAYVpQ0NQSUNDIHByb2ZpbGUAAHicfZE9SMNQFIVPW7VWKw52EHHIUJ0siIo4ahWKUCHUCq06mLz0D5o0JCkujoJrwcGfxaqDi7OuDq6CIPgD4i44KbpIifclhRYxXni8j/PuObx3H+Cvl5lqdowDqmYZqURcyGRXheArfOhFCF0ISczU50QxCc/6uqduqrsYz/Lu+7P6lJzJAJ9APMt0wyLeIJ7etHTO+8QRVpQU4nPiMYMuSPzIddnlN84Fh/08M2KkU/PEEWKh0MZyG7OioRJPEUcVVaN8f8ZlhfMWZ7VcZc178heGc9rKMtdpDSOBRSxBhAAZVZRQhoUY7RopJlJ0HvfwDzl+kVwyuUpg5FhABSokxw/+B79na+YnJ9ykcBzofLHtjxEguAs0arb9fWzbjRMg8AxcaS1/pQ7MfJJea2nRI6B/G7i4bmnyHnC5Aww+6ZIhOVKAlj+fB97P6JuywMAt0LPmzq15jtMHIE2zSt4AB4fAaIGy1z3e3d0+t397mvP7AdDBcmazf/6+AAAPw2lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4KPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNC40LjAtRXhpdjIiPgogPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iCiAgICB4bWxuczpzdEV2dD0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL3NUeXBlL1Jlc291cmNlRXZlbnQjIgogICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICAgeG1sbnM6R0lNUD0iaHR0cDovL3d3dy5naW1wLm9yZy94bXAvIgogICAgeG1sbnM6dGlmZj0iaHR0cDovL25zLmFkb2JlLmNvbS90aWZmLzEuMC8iCiAgICB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iCiAgIHhtcE1NOkRvY3VtZW50SUQ9ImdpbXA6ZG9jaWQ6Z2ltcDplNDBjOGRjOC1kY2QwLTRkMTctYmJiYy03YWNlOWM1NTQ0OGIiCiAgIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6YmJhNjM3NmYtZGU4Yy00NmM3LTljZjMtZjQ3Nzc4MWJlZjJkIgogICB4bXBNTTpPcmlnaW5hbERvY3VtZW50SUQ9InhtcC5kaWQ6ODI2OWFlMzQtYThmMy00OTg2LTgyOGMtYzgwZDJkYzg5MGM2IgogICBkYzpGb3JtYXQ9ImltYWdlL3BuZyIKICAgR0lNUDpBUEk9IjIuMCIKICAgR0lNUDpQbGF0Zm9ybT0iTGludXgiCiAgIEdJTVA6VGltZVN0YW1wPSIxNzM2NTg2NzU5MzM3NjcwIgogICBHSU1QOlZlcnNpb249IjIuMTAuMzAiCiAgIHRpZmY6T3JpZW50YXRpb249IjEiCiAgIHhtcDpDcmVhdG9yVG9vbD0iR0lNUCAyLjEwIj4KICAgPHhtcE1NOkhpc3Rvcnk+CiAgICA8cmRmOlNlcT4KICAgICA8cmRmOmxpCiAgICAgIHN0RXZ0OmFjdGlvbj0ic2F2ZWQiCiAgICAgIHN0RXZ0OmNoYW5nZWQ9Ii8iCiAgICAgIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6NzBiNTI5NjQtNTc0NC00NmNiLWE5NDYtYjYwMmNjMWVkOWRmIgogICAgICBzdEV2dDpzb2Z0d2FyZUFnZW50PSJHaW1wIDIuMTAgKExpbnV4KSIKICAgICAgc3RFdnQ6d2hlbj0iMjAyMy0xMC0zMVQxNToxMTo0MSswNTozMCIvPgogICAgIDxyZGY6bGkKICAgICAgc3RFdnQ6YWN0aW9uPSJzYXZlZCIKICAgICAgc3RFdnQ6Y2hhbmdlZD0iLyIKICAgICAgc3RFdnQ6aW5zdGFuY2VJRD0ieG1wLmlpZDo0YmZmMjFlNy03ODE5LTQyYzgtODAwYi1lYjFlNmY2MDRiZDQiCiAgICAgIHN0RXZ0OnNvZnR3YXJlQWdlbnQ9IkdpbXAgMi4xMCAoTGludXgpIgogICAgICBzdEV2dDp3aGVuPSIyMDIzLTEwLTMxVDE1OjMxOjU5KzA1OjMwIi8+CiAgICAgPHJkZjpsaQogICAgICBzdEV2dDphY3Rpb249InNhdmVkIgogICAgICBzdEV2dDpjaGFuZ2VkPSIvIgogICAgICBzdEV2dDppbnN0YW5jZUlEPSJ4bXAuaWlkOmQ3YWQ3ZmQ3LWY0YTItNDM2MC05ZDE1LTgwM2E0NzliZDFhMCIKICAgICAgc3RFdnQ6c29mdHdhcmVBZ2VudD0iR2ltcCAyLjEwIChMaW51eCkiCiAgICAgIHN0RXZ0OndoZW49IjIwMjMtMTEtMDNUMTI6MjA6NDQrMDU6MzAiLz4KICAgICA8cmRmOmxpCiAgICAgIHN0RXZ0OmFjdGlvbj0ic2F2ZWQiCiAgICAgIHN0RXZ0OmNoYW5nZWQ9Ii8iCiAgICAgIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6YjUwZjgyM2QtYjEzNy00ODUxLTk3NGEtOGQxMDE4YmIwOThkIgogICAgICBzdEV2dDpzb2Z0d2FyZUFnZW50PSJHaW1wIDIuMTAgKExpbnV4KSIKICAgICAgc3RFdnQ6d2hlbj0iMjAyNS0wMS0xMVQxNDo0MjozOSswNTozMCIvPgogICAgPC9yZGY6U2VxPgogICA8L3htcE1NOkhpc3Rvcnk+CiAgPC9yZGY6RGVzY3JpcHRpb24+CiA8L3JkZjpSREY+CjwveDp4bXBtZXRhPgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgCjw/eHBhY2tldCBlbmQ9InciPz53lMvMAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAB3RJTUUH6QELCQwnEZCPswAABNZJREFUeNrtm2uIVVUUgD9nUhvL0Ap7EDOOlmMxPc0cGBKNkH74qLCcHxFR2EPwTxYkQQQWJo5GRIX1J9FIf/ig1IEaqIgY1LG0iIjKsdBQnCy1cnzMmX7sdbj7ns45d87cfe69c+76YMO9++579j7rrL3X2muvA4qiKIqiKIqiKIqiKIoybBgxjMdeA1xmlTlSfxg4BBwAzuojzudK4GngM6AfGIgpfUAX8DrQBkyqVqGNBR4BdgLnCgitUPkBWOhy5lX6FF4CtAN1gfpeYDvwK/AXcBPwjPz2BOABM4AWoBm4KPD/bmA50Jl17eu2tOcUsB64L0QgbVa7lsBvlwCzgBUibFsjO4HpWRbgXcAamXZ1Me0esIRye0y78cBK4B+rvQe8FfJQqopLgc+BLWKdC3Et8E5gTf0IGKN2OhlNYlh8IR4DplayERkn0yWpS+EB7wHvpzCmK4D9wHXy/ZgI9mQlPvGFRbggv6U0phUhfW0drHJVuwYuBt6VzyeAg8Cd8n0ZsFZXuXg2iMb1ArcCVwO/S905oFVFFE+jTGHbcMwEzosQ9w/zeEHZWGWthw+qOIZmmU+JAA/E+Za1KQYALhcHt9jSJ0aklJyRe7gbuAr4TvzFkvCw3PSAo3JQ9rPl0MLTMoYdUY1qUuj4ZmC0w+s1yM2Umj8wITSA2VF78TQ20K8BPTKFXbA3RSe6ELuARbJHngV0ZHXRvxgT95vi+LoTyEW+38yq4FZZfpu/5XvUYR975bpfZ014o4F9McbH1TbsAytSkylesYR1BHgVWE0uWOoBcx30s1qu1w+MdGVEJgD3A6NStoLbxCXyGQMskKDE81a7yVa7DcA34mG0AxPlc02IB+LXdWMCsj5TgXvk90lW+2tcGbROh35eXFke6PftkDabQsbXlbAfz9oP1/H/sxO/zHPlB/5Ygil6AfglUHc8pF1dhBOchCPWGndWnPcwjgYriok01Kc8hU9GCKxRDMhm4BbRnvmW0zsX+Niamg9Z//UitoVH5YHZitUo8nkKeM5auo5nxYjMlJv2p9cXwPfW9wuYs+FiWWMZkVoyxhKZcsG16jzwrKM+NpILumaSO8TyHsZkKnQA0xxev0cE+CVKYm6wtPqlUgUTmjBh8vGOrrcHeLFMApxjff60VJ2uTcEfbCqTAHdK/39GGZA0NHAj5mjQpQb+VAbhNWMSmZB1tV9XtGRssnYpt6k4knEjuTjgdhVHMkbITsbXvmkqkmhmS2CkzapbZhmvbZU46FqSH22mlbf3oaVpizGpHH7O4M+U5zArlskS+UjqxnjAuhTG0wr8a/Vxglw6cXMlat+8InzBtFyZe8k/x/YwweJBUeq84A7gcYaW3rYlpTGdkWnrn2VvrVbLO474RPSwtXipNYUHMGH9kdUovHrgb0xgdDBpIC2YY0r7FYrHsiiYpZjEnjcwKSNRLLKEMaOA4NaT/5rYHuD6rGrW7oAh+UrW0InkH0dEvWhTgwlJvUB+Nr4fYV6Z9Sk7HfNioRdilXsxIaZ2zPmIX79OSpdM6+D/TmPyratqh9EIvIw5pRuqG7QbeBKT9+d03zfc9qmtmFO4BjEe9ZgDb/9e+jDvCx/CHE/2AJ8A3+rONZpRYmQa0KRwRVEURVEURVEURVEURYniPzhn3IN1irUKAAAAAElFTkSuQmCC" width="24" height="24" alt="1.5x speed">',"speed-2.00":'<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAYAAACOEfKtAAAC83pUWHRSYXcgcHJvZmlsZSB0eXBlIGV4aWYAAHja7ZdNkuQoDIX3nGKOYP0hcRwMJqJvMMefB3Z6qrKyFzmz6oiEMGCBn0AfkFXp+PvXSH8hUYmc1DxyyXlD0qKFKxqxnamukjZd5Up2deH9mz3dHQyToJbzNfI1/mGnW+CsKlr2RSja1bF/7yh66ceT0OVI5owYjX4JlUtI+OygS6Cey9pyCf+6hP046/5YSZxPmsVoXNb697Pv+V0d0esGP8J8CMmGUuSagMzHklQ0CCUJwoFS0VbY6jWUzoC8itOd4DaNOVV9OegblbtFr+3pmZbyNUSegpzv+qU9kb2mskL/xbPG1eLvdpdTKm1P0V/BHz3GWjNWUTUj1Pla1B21BWV04NDpOhL08uZ4DBK+ckEO7OqGrdC3tu3IjQoxcA1S6lRp0LHqRg1TVD4SOxrMjWUZQ5wLNzn5IdNglyJdApDbwq7C91xouS1bS8tbwHMnDGWCGOGTt3N694Mx5lEg2uKOFebFPIONaUxys8QwEKFxBdVWgB/5OU2uAoI2ozyPSEFg91NiN/r3JpAFWjDQUJ9nkLxfAggRXBsmgzOhBGokRpk2Z3YiBDIAqGLqLMo7CJAZd0ySVSSDTfB0jU+c1lA2hjnBjssMJEyyONgUqYClatg/roE9VE1MzSybW1ixmiVrtpyz53kpVhfX5ObZ3cOL15DQsMjhEVGiFi6CS9NKLl6ilFIrfFYoV3xdMaDWnXfZdbe059332MteG7ZP02YtN2/RSqudu3TcHz1379FLrwcd2EqHHnbkw484ylEHttqQNHTYyMNHjDLqTe3C+iO/QY0uarxIzYF+U4PV/SFB8zqxyQzAOCmBuE8E2NA8mW1BqjzJTWZbYZwKY0zSJrNOkxgI6kFsgx7sEp9EJ7n/xS25fuPG/5VcmujeJPeT2ytqff4MtUXsPIUzqJvg9KH/iMpR54/djzr9ruPd+iP0EfoIfYQ+Qh+hj9AfJDTwx8P8L/AfxFyow7c2uoEAAABgelRYdFJhdyBwcm9maWxlIHR5cGUgaXB0YwAAeNo9icENgFAMQu+dwhFoqfG7ju3Fmwf3j/gT5QUCwc7rLlumMowjI/dspPjl7YXgpjoYhLwq/WU+pefQSgGSsOhvAvYAMDEUz5cVn3MAAAGFaUNDUElDQyBwcm9maWxlAAB4nH2RPUjDUBSFT1u1VisOdhBxyFCdLIiKOGoVilAh1AqtOpi89A+aNCQpLo6Ca8HBn8Wqg4uzrg6ugiD4A+IuOCm6SIn3JYUWMV54vI/z7jm8dx/gr5eZanaMA6pmGalEXMhkV4XgK3zoRQhdCEnM1OdEMQnP+rqnbqq7GM/y7vuz+pScyQCfQDzLdMMi3iCe3rR0zvvEEVaUFOJz4jGDLkj8yHXZ5TfOBYf9PDNipFPzxBFiodDGchuzoqESTxFHFVWjfH/GZYXzFme1XGXNe/IXhnPayjLXaQ0jgUUsQYQAGVWUUIaFGO0aKSZSdB738A85fpFcMrlKYORYQAUqJMcP/ge/Z2vmJyfcpHAc6Hyx7Y8RILgLNGq2/X1s240TIPAMXGktf6UOzHySXmtp0SOgfxu4uG5p8h5wuQMMPumSITlSgJY/nwfez+ibssDALdCz5s6teY7TByBNs0reAAeHwGiBstc93t3dPrd/e5rz+wHQwXJms3/+vgAAD8NpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+Cjx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDQuNC4wLUV4aXYyIj4KIDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+CiAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIKICAgIHhtbG5zOnhtcE1NPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvbW0vIgogICAgeG1sbnM6c3RFdnQ9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZUV2ZW50IyIKICAgIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIKICAgIHhtbG5zOkdJTVA9Imh0dHA6Ly93d3cuZ2ltcC5vcmcveG1wLyIKICAgIHhtbG5zOnRpZmY9Imh0dHA6Ly9ucy5hZG9iZS5jb20vdGlmZi8xLjAvIgogICAgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIgogICB4bXBNTTpEb2N1bWVudElEPSJnaW1wOmRvY2lkOmdpbXA6NDliOGQ3ODctNzUwMy00OTc3LWIwYTItMGEyZWUwZmRjNjdhIgogICB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOmU3MGU2OThlLTZjOWMtNDIzMS04OTExLTE2OTQ1MmUxNWQyMiIKICAgeG1wTU06T3JpZ2luYWxEb2N1bWVudElEPSJ4bXAuZGlkOmIzMWI2YzU3LTY0YTItNGE0Yi04M2U2LTIwYjY0ZmQ1Y2NkYSIKICAgZGM6Rm9ybWF0PSJpbWFnZS9wbmciCiAgIEdJTVA6QVBJPSIyLjAiCiAgIEdJTVA6UGxhdGZvcm09IkxpbnV4IgogICBHSU1QOlRpbWVTdGFtcD0iMTczNjU4NjYzMDc4NzQwNiIKICAgR0lNUDpWZXJzaW9uPSIyLjEwLjMwIgogICB0aWZmOk9yaWVudGF0aW9uPSIxIgogICB4bXA6Q3JlYXRvclRvb2w9IkdJTVAgMi4xMCI+CiAgIDx4bXBNTTpIaXN0b3J5PgogICAgPHJkZjpTZXE+CiAgICAgPHJkZjpsaQogICAgICBzdEV2dDphY3Rpb249InNhdmVkIgogICAgICBzdEV2dDpjaGFuZ2VkPSIvIgogICAgICBzdEV2dDppbnN0YW5jZUlEPSJ4bXAuaWlkOjRjNmY5MTE5LTE2Y2YtNDgyNC1iMWY5LWYxZmNjMDgwNTgzZSIKICAgICAgc3RFdnQ6c29mdHdhcmVBZ2VudD0iR2ltcCAyLjEwIChMaW51eCkiCiAgICAgIHN0RXZ0OndoZW49IjIwMjMtMTAtMzFUMTU6MTE6NDQrMDU6MzAiLz4KICAgICA8cmRmOmxpCiAgICAgIHN0RXZ0OmFjdGlvbj0ic2F2ZWQiCiAgICAgIHN0RXZ0OmNoYW5nZWQ9Ii8iCiAgICAgIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6M2E5MmI5NTQtMGE1Zi00NDI1LWFkMGEtOTRkOGFhMjBjMTU1IgogICAgICBzdEV2dDpzb2Z0d2FyZUFnZW50PSJHaW1wIDIuMTAgKExpbnV4KSIKICAgICAgc3RFdnQ6d2hlbj0iMjAyMy0xMC0zMVQxNTozMTo0MiswNTozMCIvPgogICAgIDxyZGY6bGkKICAgICAgc3RFdnQ6YWN0aW9uPSJzYXZlZCIKICAgICAgc3RFdnQ6Y2hhbmdlZD0iLyIKICAgICAgc3RFdnQ6aW5zdGFuY2VJRD0ieG1wLmlpZDo4OTI1MjY2OS01M2JkLTRlNTktOGE2My1lN2M5ZTgxYzZmNjQiCiAgICAgIHN0RXZ0OnNvZnR3YXJlQWdlbnQ9IkdpbXAgMi4xMCAoTGludXgpIgogICAgICBzdEV2dDp3aGVuPSIyMDIzLTExLTAzVDEyOjIwOjQ4KzA1OjMwIi8+CiAgICAgPHJkZjpsaQogICAgICBzdEV2dDphY3Rpb249InNhdmVkIgogICAgICBzdEV2dDpjaGFuZ2VkPSIvIgogICAgICBzdEV2dDppbnN0YW5jZUlEPSJ4bXAuaWlkOjA1YjNjZDZjLWUwZGYtNGYzNy04ZTg5LTVmMDFiOTNiZTM2NCIKICAgICAgc3RFdnQ6c29mdHdhcmVBZ2VudD0iR2ltcCAyLjEwIChMaW51eCkiCiAgICAgIHN0RXZ0OndoZW49IjIwMjUtMDEtMTFUMTQ6NDA6MzArMDU6MzAiLz4KICAgIDwvcmRmOlNlcT4KICAgPC94bXBNTTpIaXN0b3J5PgogIDwvcmRmOkRlc2NyaXB0aW9uPgogPC9yZGY6UkRGPgo8L3g6eG1wbWV0YT4KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgIAo8P3hwYWNrZXQgZW5kPSJ3Ij8+T3zvpgAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAuIwAALiMBeKU/dgAAAAd0SU1FB+kBCwkKHhjPoD0AAATqSURBVHja7ZtbbBVFGMd/p0VLSxGIIIIXEChiDAaMl2ii4C3Cg/ogEJqIxngJeGlCUB7UmII+mHglpmrigzFRDAEUJAIx4ZJoA0IUSqq2WFACjUBBQFKL2J7jw3wnDuvZs+cye5bu+X7JJGfPzs7O/vebmW++mQVFURRFURRFURRFURRF6TckYvAMFwBDgKHAKGAm0A6cBvYA+4CUCngu1wH1wFxgbEDeLuA7STuAncCJcmwt44GXgFaxqEJTH7ASmFQuwlUBX/mIsQt4DVgMzAe+l/87gWnAcyLWwQzX/gN8CFwRdwGv9jz4L8ASHwv6UvJ0ZDh3OTBLBE1a5fUArwMXx1nEp4BG4IaAfKtElJ8C8l0PbPC8mJPAfeXuVdwjfeRjOea/A9jmadZPqnOWvyfyCHDGEnJDrh5KKdyYacAiYISDsn4GXgYOhVDP+4EvgAo5bgKeOR/e8DdFuh3e1BhCHYeJf+i912y1wNzYKvUEaAamAIOAP4Ebgb3a0/kzEOgWi9sox/WWFbYA1X4XV6p+9MrIvRtYKINJK3CJWN9ImVc3q1T5z4A6xAq7gFq1wPzoE8t7AKiR39+6HkQqxNTDfpCuiEQcALRJIOM4cJUI6YTJMhqmSpBagMERifioVY96lwXPKZF4KenoJ0Yk4CAJOKSAT1w24QpgOjA1ZH+yV/y03RH2hxuBe4FjwKXSrfR7qoH10rGnrbNWXA/XoakGqzXcEpdR8hrroQ6LhfbKcVI6/7sc3Wuida9FcXI13iU4fD/P0WicfjlvxUnASuCoJdhOYAGwTsRLyfmhDu7VKeWt8CqbicuAGdnmgCWgRzrvzix5rrWCFCswq3QA70u/tUzOzwQ+K2CQnAGMswYzgDFBF9Z43mqU6ajUxw970n+359xo69wrBbzA2T51+surspf0ZPp8oFXq40e39dsbLhvhky9XDvhc1x3UhJPAndKMo27CnQF5WsQqEsATwGbgiLgzb3ry5csOseL0VHU9UIdZSo0Vy63mdQZYi9l5kP7vrKNZzO9S3vK4CTgaswcmW196EJhQpBtzVspaFsfQUzXwKmb95Q/MDoUm4CNHIt5qlbOAMiIBvOdAxEarjAmuggkXAS9iVvnDpA/YhNl+UaiITZblHMIsqHfkUUazWOF+TGzQCY+X2CecGpElDsfsWEgBH2TqHAtlDXBbCS2wpYgyUsDTIuR8zEajLZhw3L6AaxdaOq2jzEnINC9tiasC8g8DTknePcRjR68TEd8G/pY+PBtLLLHnqHTnUhVwfgxmy1sK+NFn2qsIS2UGUyfHFwLbyWOPTNgMkPlpsSmMPmigNGd7dH7HEq8pavEarI642HRA/DHXvGHd47j1ewvmM4pI+dqxP7g4pIHFuzzwq/iAgU0rbB6WEczF9rY2YHVI9TzlOZ6LWcYsO0blmX8kZjnADok9X66jaYPflCsDlZL/pCXeD5jPKmIXqlqLWUBvkNmBH9m+E0lTAzwkYqWFS4pzXRVHq6rj/4s6H2M+aRiSo4DVwO2YL5O8HsFhzOpbrHlWQkneETmJ+XJppUy72ixXZKn8385/i+J26gBeyGWkjdMcdjomyny6QBeoB/gUs2iWcFWp/kgt8CBwE3CllewdCMeA36zUDnyOCfkrPgwGbsZnP7OiKIqiKIqiKIqiKIqilDn/AkkxNGAuRZ+BAAAAAElFTkSuQmCC" width="24" height="24" alt="2x speed">'},jm="X-Jewel-Studio",qm="69d2c1660df6540944e25eb708fb252724ab27fb";class kn extends HTMLElement{progressBarStyle=Nt.None;_hls;_videoPlayer;background="dark";_autoPlay=!1;_streamLoaded=!1;_startLevel=-1;_hideControlsTimer;_pointerOverControls=!1;controlsHideDelay=3e3;isValidProgressBarStyle(e){return Object.values(Nt).includes(e)}svgIcons=Wm;constructor(){super(),this.attachShadow({mode:"open"}),this.setupAutoHide()}static booleanProperties=["autoPlay","showTimeDisplay","showSpeedControl","autoHideControls"];get autoPlay(){return this.hasAttribute("auto-play")}set autoPlay(e){this.toggleAttribute("auto-play",!!e)}get showTimeDisplay(){return this.hasAttribute("show-time-display")}set showTimeDisplay(e){this.toggleAttribute("show-time-display",!!e)}get showSpeedControl(){return this.hasAttribute("show-speed-control")}set showSpeedControl(e){this.toggleAttribute("show-speed-control",!!e)}get autoHideControls(){return this.hasAttribute("auto-hide-controls")}set autoHideControls(e){this.toggleAttribute("auto-hide-controls",!!e)}upgradeProperties(){const e=this;for(const t of kn.booleanProperties)if(Object.prototype.hasOwnProperty.call(this,t)){const i=e[t];delete e[t],this[t]=!!i}}setupAutoHide(){const e=this.shadowRoot;e&&(e.addEventListener("pointermove",t=>{!(t instanceof PointerEvent)||t.pointerType==="touch"||(this._pointerOverControls=!!t.target?.closest?.("#control-bar"),this.showControls())}),e.addEventListener("pointerout",t=>{if(!(t instanceof PointerEvent)||t.pointerType==="touch")return;const i=e.querySelector(".video-container");i&&!i.contains(t.relatedTarget)&&(this._pointerOverControls=!1,this.hideControls())}),e.addEventListener("pointerdown",t=>{!(t instanceof PointerEvent)||t.pointerType!=="touch"||(this._pointerOverControls=!1,this.showControls())}))}showControls(){this.autoHideControls&&(this.shadowRoot?.querySelector(".video-container")?.classList.add("controls-visible"),this.scheduleControlsHide())}scheduleControlsHide(){window.clearTimeout(this._hideControlsTimer),!(this._videoPlayer?.paused||this._pointerOverControls)&&(this._hideControlsTimer=window.setTimeout(()=>this.hideControls(),this.controlsHideDelay))}hideControls(){window.clearTimeout(this._hideControlsTimer),this.shadowRoot?.querySelector(".video-container")?.classList.remove("controls-visible")}static get observedAttributes(){return["video-src","poster-src","auto-play","width","playback-speeds","default-speed","default-quality","show-time-display","show-speed-control","progress-bar-style","background","aspect-ratio"]}attributeChangedCallback(e,t,i){e==="progress-bar-style"?(this.progressBarStyle=this.isValidProgressBarStyle(i)?i:Nt.None,this.render()):e==="background"&&(this.background=i==="light"?"light":"dark",this.updateControlsColor())}async connectedCallback(){this.upgradeProperties(),this.background=this.getAttribute("background")==="light"?"light":"dark",this._autoPlay=this.autoPlay,this._streamLoaded=this._autoPlay,this._startLevel=parseInt(this.getAttribute("default-quality")||"-1"),await this.render(),await this.initializePlayer(),this.setupProgressBarInteractions(),this.updateControlsColor()}setupProgressBarInteractions(){if(!this.shadowRoot||!this._videoPlayer)return;const e=this.shadowRoot.querySelector(".progress-bar"),t=this.shadowRoot.querySelector(".progress-bar-fill");if(!e||!t)return;const i=()=>{if(!this._videoPlayer)return;const n=this._videoPlayer.currentTime/this._videoPlayer.duration*100;if(t.style.width=`${n}%`,this.progressBarStyle===Nt.Segments){const a=this.shadowRoot?.querySelectorAll(".progress-segment");a&&a.forEach((o,l)=>{const u=(l+1)*(100/a.length);n>=u?o.classList.add("filled"):o.classList.remove("filled")})}};this._videoPlayer.addEventListener("timeupdate",i);const s=n=>{if(!this._videoPlayer||!(n instanceof MouseEvent))return;const a=e.getBoundingClientRect(),o=Math.max(0,Math.min(1,(n.clientX-a.left)/a.width));this._videoPlayer.currentTime=o*this._videoPlayer.duration};e.addEventListener("click",s)}renderProgressBar(){switch(this.progressBarStyle){case Nt.DualLayer:return`
196
189
  <div class="progress-bar">
197
190
  <div class="progress-bar-buffer"></div>
198
191
  <div class="progress-bar-fill" style="width: 0%"></div>
199
192
  <div class="progress-handle"></div>
200
193
  </div>
201
- `;case Et.Segments:return`
194
+ `;case Nt.Segments:return`
202
195
  <div class="progress-bar">
203
196
  ${Array.from({length:20},(e,t)=>`
204
197
  <div class="progress-segment" data-index="${t}"></div>
205
198
  `).join("")}
206
199
  </div>
207
- `;case Et.MinimalWave:return`
200
+ `;case Nt.MinimalWave:return`
208
201
  <div class="progress-bar">
209
202
  <div class="progress-bar-fill" style="width: 0%"></div>
210
203
  <div class="progress-wave"></div>
211
204
  </div>
212
- `;case Et.None:default:return""}}async render(){const e=`
205
+ `;case Nt.None:default:return""}}async render(){const e=`
213
206
  :host {
214
207
  display: block;
215
208
  }
@@ -250,7 +243,7 @@ Schedule: ${c.map(E=>Pt(E))} pos: ${this.timelinePos}`),h.length&&this.log(`Remo
250
243
  }
251
244
  #control-bar {
252
245
  position: absolute;
253
- bottom: 10px;
246
+ bottom: 0;
254
247
  left: 0;
255
248
  right: 0;
256
249
  display: flex;
@@ -259,6 +252,33 @@ Schedule: ${c.map(E=>Pt(E))} pos: ${this.timelinePos}`),h.length&&this.log(`Remo
259
252
  background: linear-gradient(transparent, var(--control-bg));
260
253
  gap: 10px;
261
254
  z-index: 1;
255
+ transition: opacity 0.3s ease, transform 0.3s ease;
256
+ }
257
+ /* opacity + pointer-events (not visibility: hidden) so the buttons stay
258
+ keyboard-focusable and :focus-visible can reveal the bar. */
259
+ :host([auto-hide-controls]) #control-bar {
260
+ opacity: 0;
261
+ pointer-events: none;
262
+ transform: translateY(8px);
263
+ }
264
+ /* .controls-visible is toggled by setupAutoHide() for mouse movement and taps. */
265
+ :host([auto-hide-controls]) .video-container.controls-visible #control-bar {
266
+ opacity: 1;
267
+ pointer-events: auto;
268
+ transform: none;
269
+ }
270
+ /* Kept in its own rule: browsers without :has() drop the whole selector list,
271
+ which would also disable the rule above.
272
+ :focus-visible (not :focus-within) so a mouse click on a button doesn't pin the bar open. */
273
+ :host([auto-hide-controls]) .video-container:has(:focus-visible) #control-bar {
274
+ opacity: 1;
275
+ pointer-events: auto;
276
+ transform: none;
277
+ }
278
+ @media (prefers-reduced-motion: reduce) {
279
+ #control-bar {
280
+ transform: none !important;
281
+ }
262
282
  }
263
283
  #progress-row {
264
284
  display: flex;
@@ -299,7 +319,7 @@ Schedule: ${c.map(E=>Pt(E))} pos: ${this.timelinePos}`),h.length&&this.log(`Remo
299
319
  .light-theme .time-display {
300
320
  color: #000;
301
321
  }
302
- ${Eg[this.progressBarStyle]}
322
+ ${Ym[this.progressBarStyle]}
303
323
  .video-controls {
304
324
  display: flex;
305
325
  align-items: center;
@@ -336,9 +356,9 @@ Schedule: ${c.map(E=>Pt(E))} pos: ${this.timelinePos}`),h.length&&this.log(`Remo
336
356
 
337
357
  <div id="control-bar">
338
358
  <div id="progress-row">
339
- ${this.hasAttribute("show-time-display")?'<span class="time-display current-time">0:00</span>':""}
359
+ ${this.showTimeDisplay?'<span class="time-display current-time">0:00</span>':""}
340
360
  ${this.renderProgressBar()}
341
- ${this.hasAttribute("show-time-display")?'<span class="time-display duration">0:00</span>':""}
361
+ ${this.showTimeDisplay?'<span class="time-display duration">0:00</span>':""}
342
362
  </div>
343
363
  <div id="controls-row">
344
364
  <div class="video-controls">
@@ -366,4 +386,4 @@ Schedule: ${c.map(E=>Pt(E))} pos: ${this.timelinePos}`),h.length&&this.log(`Remo
366
386
  </div>
367
387
  </div>
368
388
  </div>
369
- `;if(this.shadowRoot){const i=new CSSStyleSheet;await i.replace(e),this.shadowRoot.adoptedStyleSheets=[i],this.shadowRoot.innerHTML=t}}async initializePlayer(){if(!this.shadowRoot){console.error("Shadow root not found");return}console.debug("Initialize player called");const e=this.shadowRoot.querySelector("video");if(!e){console.error("Video element not found");return}this._videoPlayer=e;const t=this.getAttribute("video-src");if(!t){console.error("Video source is required");return}this._hls&&(this._hls.destroy(),this._hls=void 0),e.removeAttribute("src"),e.load(),e.addEventListener("error",()=>{console.error("Video element error:",e.error)});try{if(ft.isSupported())console.debug("HLS.js is supported, initializing..."),await this.initializeHls(e,t);else if(e.canPlayType("application/vnd.apple.mpegurl"))console.debug("Using native HLS support"),e.src=t,this.startListeners();else throw new Error("Neither HLS.js nor native HLS is supported")}catch(i){console.error("Failed to initialize player:",i)}}async initializeHls(e,t){return new Promise((i,s)=>{try{const r={enableWorker:!0,lowLatencyMode:!0,backBufferLength:90,startLevel:this._startLevel,autoStartLoad:this._autoPlay,manifestLoadingTimeOut:2e4,manifestLoadingMaxRetry:3,manifestLoadingRetryDelay:500,levelLoadingTimeOut:2e4,levelLoadingMaxRetry:3,levelLoadingRetryDelay:500,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:3,fragLoadingRetryDelay:500,xhrSetup:n=>{n.withCredentials=!1,n.setRequestHeader(Tg,Sg)}};this._hls=new ft(r),this._hls.on(ft.Events.ERROR,(n,o)=>{if(console.error("HLS Error:",o),o.fatal)switch(o.type){case ft.ErrorTypes.NETWORK_ERROR:console.debug("Fatal network error encountered, trying to recover..."),this._hls?.startLoad();break;case ft.ErrorTypes.MEDIA_ERROR:console.debug("Fatal media error encountered, trying to recover..."),this._hls?.recoverMediaError();break;default:console.error("Fatal error, cannot recover:",o.details),this._hls?.destroy(),s(new Error(`Fatal HLS error: ${o.details}`));break}}),this._hls.on(ft.Events.MEDIA_ATTACHED,()=>{console.debug("Media attached, loading source:",t),this._hls?.loadSource(t)}),this._hls.on(ft.Events.MANIFEST_PARSED,(n,o)=>{console.debug("Manifest parsed, levels:",o.levels),this.startListeners(),i(),this._autoPlay&&(console.debug("Attempting autoplay..."),e.play().then(()=>console.debug("Playback started successfully")).catch(async c=>{console.error("Autoplay failed:",c),e.muted=!0;try{await e.play(),console.debug("Muted autoplay successful")}catch(u){console.error("Muted autoplay also failed:",u)}}))}),console.debug("Attaching media element..."),this._hls.attachMedia(e)}catch(r){console.error("Error in HLS initialization:",r),s(r)}})}startListeners(){if(!this.shadowRoot)return;const e=ui(this.shadowRoot).find(".play"),t=ui(this.shadowRoot).find(".pause"),i=ui(this.shadowRoot).find(".forward"),s=ui(this.shadowRoot).find(".backward"),r=ui(this.shadowRoot).find(".fullscreen");if(e.on("click",()=>this.play()),t.on("click",()=>this.pause()),i.on("click",()=>this.forward()),s.on("click",()=>this.backward()),r.on("click",()=>this.toggleFullscreen()),this._videoPlayer){const n=ui(this.shadowRoot).find(".duration"),o=ui(this.shadowRoot).find(".progress-bar"),c=ui(this.shadowRoot).find(".speed-container");this._videoPlayer.addEventListener("play",()=>{e.hide(),t.show()}),this._videoPlayer.addEventListener("pause",()=>{t.hide(),e.show()}),this._videoPlayer.addEventListener("timeupdate",()=>{if(!this._videoPlayer||!this.shadowRoot)return;const I=this._videoPlayer.currentTime,m=this._videoPlayer.duration,E=I/m*100;if(this.hasAttribute("show-time-display")){const x=this.shadowRoot.querySelector(".current-time");x&&(x.textContent=this.formatTime(I))}const v=this.shadowRoot.querySelector(".progress-bar-fill");if(v instanceof HTMLElement&&(v.style.width=`${E}%`),this.progressBarStyle===Et.Segments){const x=this.shadowRoot.querySelectorAll(".progress-segment");x.forEach((D,L)=>{const w=(L+1)*(100/x.length);E>=w?D.classList.add("filled"):D.classList.remove("filled")})}}),this._videoPlayer.addEventListener("loadedmetadata",()=>{this.hasAttribute("show-time-display")&&n.text(this.formatTime(this._videoPlayer.duration))}),o.on("click",I=>{const m=I.currentTarget.getBoundingClientRect(),E=(I.clientX-m.left)/m.width;this._videoPlayer.currentTime=E*this._videoPlayer.duration});const u=[.25,.5,.75,1,1.25,1.5,2],h=this.getAttribute("playback-speeds")?.split(",").map(Number)||u,f=parseFloat(this.getAttribute("default-speed")||"1");let g=h.indexOf(f);g===-1&&(g=h.indexOf(1)||0),f&&!isNaN(f)&&(this._videoPlayer.playbackRate=f,c.text(`${f}x`)),this.hasAttribute("show-speed-control")?(c.show(),c.html(this.getSpeedIcon(f)),c.on("click",()=>{g=(g+1)%h.length;const I=h[g];this._videoPlayer.playbackRate=I,c.html(this.getSpeedIcon(I))})):c.hide()}}play(){this._videoPlayer&&(!this._streamLoaded&&!this._autoPlay&&this._hls&&(this._hls.startLoad(this._startLevel),this._streamLoaded=!0),this._videoPlayer.play())}pause(){this._videoPlayer&&this._videoPlayer.pause()}forward(){this._videoPlayer&&(this._videoPlayer.paused||this._videoPlayer.pause(),this._videoPlayer.currentTime=this._videoPlayer.currentTime+.2*this._videoPlayer.playbackRate)}backward(){this._videoPlayer&&(this._videoPlayer.paused||this._videoPlayer.pause(),this._videoPlayer.currentTime=this._videoPlayer.currentTime-.2*this._videoPlayer.playbackRate)}toggleFullscreen(){this._videoPlayer&&(document.fullscreenElement?document.exitFullscreen():this._videoPlayer.requestFullscreen())}getSpeedIcon(e){const i=`speed-${e.toFixed(2)}`;return this.svgIcons[i]||this.svgIcons["speed-1.00"]}formatTime(e){if(!isFinite(e))return"0:00";const t=Math.floor(e/60),i=Math.floor(e%60);return`${t}:${i.toString().padStart(2,"0")}`}updateControlsColor(){requestAnimationFrame(()=>{if(!this.shadowRoot)return;const e=this.shadowRoot.querySelector(".video-container");e&&(e.classList.remove("light-theme"),this.background==="light"&&e.classList.add("light-theme"))})}disconnectedCallback(){this._hls&&this._hls.destroy()}}customElements.define("v360-player",Bl),Ri.V360Player=Bl,Object.defineProperty(Ri,Symbol.toStringTag,{value:"Module"})}));
389
+ `;if(this.shadowRoot){const i=new CSSStyleSheet;await i.replace(e),this.shadowRoot.adoptedStyleSheets=[i],this.shadowRoot.innerHTML=t}}async initializePlayer(){if(!this.shadowRoot){console.error("Shadow root not found");return}console.debug("Initialize player called");const e=this.shadowRoot.querySelector("video");if(!e){console.error("Video element not found");return}this._videoPlayer=e;const t=this.getAttribute("video-src");if(!t){console.error("Video source is required");return}this._hls&&(this._hls.destroy(),this._hls=void 0),e.removeAttribute("src"),e.load(),e.addEventListener("error",()=>{console.error("Video element error:",e.error)});try{if(Tt.isSupported())console.debug("HLS.js is supported, initializing..."),await this.initializeHls(e,t);else if(e.canPlayType("application/vnd.apple.mpegurl"))console.debug("Using native HLS support"),e.src=t,this.startListeners();else throw new Error("Neither HLS.js nor native HLS is supported")}catch(i){console.error("Failed to initialize player:",i)}}async initializeHls(e,t){return new Promise((i,s)=>{try{const n={enableWorker:!0,lowLatencyMode:!0,backBufferLength:90,startLevel:this._startLevel,autoStartLoad:this._autoPlay,manifestLoadingTimeOut:2e4,manifestLoadingMaxRetry:3,manifestLoadingRetryDelay:500,levelLoadingTimeOut:2e4,levelLoadingMaxRetry:3,levelLoadingRetryDelay:500,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:3,fragLoadingRetryDelay:500,xhrSetup:a=>{a.withCredentials=!1,a.setRequestHeader(jm,qm)}};this._hls=new Tt(n),this._hls.on(Tt.Events.ERROR,(a,o)=>{if(console.error("HLS Error:",o),o.fatal)switch(o.type){case Tt.ErrorTypes.NETWORK_ERROR:console.debug("Fatal network error encountered, trying to recover..."),this._hls?.startLoad();break;case Tt.ErrorTypes.MEDIA_ERROR:console.debug("Fatal media error encountered, trying to recover..."),this._hls?.recoverMediaError();break;default:console.error("Fatal error, cannot recover:",o.details),this._hls?.destroy(),s(new Error(`Fatal HLS error: ${o.details}`));break}}),this._hls.on(Tt.Events.MEDIA_ATTACHED,()=>{console.debug("Media attached, loading source:",t),this._hls?.loadSource(t)}),this._hls.on(Tt.Events.MANIFEST_PARSED,(a,o)=>{console.debug("Manifest parsed, levels:",o.levels),this.startListeners(),i(),this._autoPlay&&(console.debug("Attempting autoplay..."),e.play().then(()=>console.debug("Playback started successfully")).catch(async l=>{console.error("Autoplay failed:",l),e.muted=!0;try{await e.play(),console.debug("Muted autoplay successful")}catch(u){console.error("Muted autoplay also failed:",u)}}))}),console.debug("Attaching media element..."),this._hls.attachMedia(e)}catch(n){console.error("Error in HLS initialization:",n),s(n)}})}startListeners(){if(!this.shadowRoot)return;const e=Ri(this.shadowRoot).find(".play"),t=Ri(this.shadowRoot).find(".pause"),i=Ri(this.shadowRoot).find(".forward"),s=Ri(this.shadowRoot).find(".backward"),n=Ri(this.shadowRoot).find(".fullscreen");if(e.on("click",()=>this.play()),t.on("click",()=>this.pause()),i.on("click",()=>this.forward()),s.on("click",()=>this.backward()),n.on("click",()=>this.toggleFullscreen()),this._videoPlayer){const a=Ri(this.shadowRoot).find(".duration"),o=Ri(this.shadowRoot).find(".progress-bar"),l=Ri(this.shadowRoot).find(".speed-container");this._videoPlayer.addEventListener("play",()=>{e.hide(),t.show(),this.scheduleControlsHide()}),this._videoPlayer.addEventListener("pause",()=>{t.hide(),e.show(),window.clearTimeout(this._hideControlsTimer)}),this._videoPlayer.addEventListener("timeupdate",()=>{if(!this._videoPlayer||!this.shadowRoot)return;const m=this._videoPlayer.currentTime,A=this._videoPlayer.duration,C=m/A*100;if(this.showTimeDisplay){const S=this.shadowRoot.querySelector(".current-time");S&&(S.textContent=this.formatTime(m))}const v=this.shadowRoot.querySelector(".progress-bar-fill");if(v instanceof HTMLElement&&(v.style.width=`${C}%`),this.progressBarStyle===Nt.Segments){const S=this.shadowRoot.querySelectorAll(".progress-segment");S.forEach((R,b)=>{const D=(b+1)*(100/S.length);C>=D?R.classList.add("filled"):R.classList.remove("filled")})}}),this._videoPlayer.addEventListener("loadedmetadata",()=>{this.showTimeDisplay&&a.text(this.formatTime(this._videoPlayer.duration))}),o.on("click",m=>{const A=m.currentTarget.getBoundingClientRect(),C=(m.clientX-A.left)/A.width;this._videoPlayer.currentTime=C*this._videoPlayer.duration});const u=[.25,.5,.75,1,1.25,1.5,2],h=this.getAttribute("playback-speeds")?.split(",").map(Number)||u,d=parseFloat(this.getAttribute("default-speed")||"1");let g=h.indexOf(d);g===-1&&(g=h.indexOf(1)||0),d&&!isNaN(d)&&(this._videoPlayer.playbackRate=d,l.text(`${d}x`)),this.showSpeedControl?(l.show(),l.html(this.getSpeedIcon(d)),l.on("click",()=>{g=(g+1)%h.length;const m=h[g];this._videoPlayer.playbackRate=m,l.html(this.getSpeedIcon(m))})):l.hide()}}play(){this._videoPlayer&&(!this._streamLoaded&&!this._autoPlay&&this._hls&&(this._hls.startLoad(this._startLevel),this._streamLoaded=!0),this._videoPlayer.play())}pause(){this._videoPlayer&&this._videoPlayer.pause()}forward(){this._videoPlayer&&(this._videoPlayer.paused||this._videoPlayer.pause(),this._videoPlayer.currentTime=this._videoPlayer.currentTime+.2*this._videoPlayer.playbackRate)}backward(){this._videoPlayer&&(this._videoPlayer.paused||this._videoPlayer.pause(),this._videoPlayer.currentTime=this._videoPlayer.currentTime-.2*this._videoPlayer.playbackRate)}toggleFullscreen(){this._videoPlayer&&(document.fullscreenElement?document.exitFullscreen():this._videoPlayer.requestFullscreen())}getSpeedIcon(e){const i=`speed-${e.toFixed(2)}`;return this.svgIcons[i]||this.svgIcons["speed-1.00"]}formatTime(e){if(!isFinite(e))return"0:00";const t=Math.floor(e/60),i=Math.floor(e%60);return`${t}:${i.toString().padStart(2,"0")}`}updateControlsColor(){requestAnimationFrame(()=>{if(!this.shadowRoot)return;const e=this.shadowRoot.querySelector(".video-container");e&&(e.classList.remove("light-theme"),this.background==="light"&&e.classList.add("light-theme"))})}disconnectedCallback(){window.clearTimeout(this._hideControlsTimer),this._hls&&this._hls.destroy()}}customElements.define("v360-player",kn),Vi.V360Player=kn,Object.defineProperty(Vi,Symbol.toStringTag,{value:"Module"})}));