@tempots/beatui 0.60.1 → 0.60.2

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.
Files changed (79) hide show
  1. package/dist/_commonjsHelpers-C6fGbg64.js +6 -0
  2. package/dist/_commonjsHelpers-DwGv2jUC.cjs +1 -0
  3. package/dist/{ar-B7Vs1jtG.cjs → ar-CZ-UB9pc.cjs} +1 -1
  4. package/dist/{ar-BOqk-mzn.js → ar-TEVFGyor.js} +1 -1
  5. package/dist/auth/index.cjs.js +1 -1
  6. package/dist/auth/index.es.js +4 -4
  7. package/dist/{de-CviZ-p_4.js → de-DAzM31i4.js} +1 -1
  8. package/dist/{de-DNjhUbYu.cjs → de-IZSle3Nd.cjs} +1 -1
  9. package/dist/{es-DxuZQTVE.js → es-C7Gx9dqG.js} +1 -1
  10. package/dist/{es-D82T2KKm.cjs → es-DYe8rpsj.cjs} +1 -1
  11. package/dist/{fa-C7eY3MZF.cjs → fa-CEbnfFly.cjs} +1 -1
  12. package/dist/{fa-BBySqLUh.js → fa-DKX_zJDi.js} +1 -1
  13. package/dist/{fr-DBCblSme.js → fr-BRfNV0Yj.js} +1 -1
  14. package/dist/{fr-DlXc2xhl.cjs → fr-CrG0l5HN.cjs} +1 -1
  15. package/dist/{he-1Czj0G0s.cjs → he-D6hsIiTH.cjs} +1 -1
  16. package/dist/{he-DUrHwGF6.js → he-DRAV97MO.js} +1 -1
  17. package/dist/{hi-BdJqIhvL.js → hi-BaZyjzct.js} +1 -1
  18. package/dist/{hi-DyWQTexo.cjs → hi-DyS6BNlk.cjs} +1 -1
  19. package/dist/hls.light.min-BHW1Af0w.js +8303 -0
  20. package/dist/hls.light.min-D3hUMpII.cjs +27 -0
  21. package/dist/{index-BLTlhUPG.cjs → index-BJxozmss.cjs} +21 -21
  22. package/dist/{index-D6_EcuJG.js → index-Bu4A7nbp.js} +1 -1
  23. package/dist/{index-CMIeO1pS.cjs → index-Ch-e3nx4.cjs} +1 -1
  24. package/dist/{index-yhjOw19A.js → index-nqoZcPdT.js} +2973 -3015
  25. package/dist/index.cjs.js +3 -3
  26. package/dist/index.es.js +82 -82
  27. package/dist/{it-BhqBuhZq.cjs → it-5c_IK4cL.cjs} +1 -1
  28. package/dist/{it-B7HY_G0n.js → it-TCCyUGRc.js} +1 -1
  29. package/dist/{ja-DavHeIBC.js → ja-Bpc6MfYs.js} +1 -1
  30. package/dist/{ja-Be1SXGQn.cjs → ja-VrfuPGN3.cjs} +1 -1
  31. package/dist/json-schema/index.cjs.js +8 -1
  32. package/dist/json-schema/index.es.js +8797 -35
  33. package/dist/{ko-Be3o52et.js → ko-BBN3tai6.js} +1 -1
  34. package/dist/{ko-BuyoVlmH.cjs → ko-BKSVpY_x.cjs} +1 -1
  35. package/dist/{modal-DT3cH1Kz.cjs → modal-DA0OKusk.cjs} +1 -1
  36. package/dist/{modal-BT2LwYlK.js → modal-DJDeFIxV.js} +2 -2
  37. package/dist/{nl-FD8OAOWL.cjs → nl-Bry6kgvp.cjs} +1 -1
  38. package/dist/{nl-DJIY4R0b.js → nl-CwXW1x3G.js} +1 -1
  39. package/dist/{notice-CUTUN2Kh.cjs → notice-BIcHmVnn.cjs} +1 -1
  40. package/dist/{notice-Cs95CTP3.js → notice-Cpso9PgQ.js} +1 -1
  41. package/dist/{pl-weZLWcSD.cjs → pl-CI2JMYK3.cjs} +1 -1
  42. package/dist/{pl-Bqoq63Fm.js → pl-utONv5st.js} +1 -1
  43. package/dist/prosemirror/index.cjs.js +1 -1
  44. package/dist/prosemirror/index.es.js +1 -1
  45. package/dist/{pt-7g4YVboz.js → pt-BKZlur2O.js} +1 -1
  46. package/dist/{pt-BuBrXOmS.cjs → pt-pg3nMUQB.cjs} +1 -1
  47. package/dist/{ru-hvj4lu1_.js → ru-B6HTgTqQ.js} +1 -1
  48. package/dist/{ru-Br9Wedcu.cjs → ru-DcagJ4uT.cjs} +1 -1
  49. package/dist/{toolbar-Bk_vLHOS.cjs → toolbar-CC22Z53U.cjs} +1 -1
  50. package/dist/{toolbar-ReCF2tBa.js → toolbar-_yJ-dm-Z.js} +1 -1
  51. package/dist/{tr-BSuvz1N5.cjs → tr-BabBuwqd.cjs} +1 -1
  52. package/dist/{tr-qxangEut.js → tr-DhELxnEm.js} +1 -1
  53. package/dist/translations-BRRDPpLp.cjs +1 -0
  54. package/dist/translations-ConAsIH1.js +67 -0
  55. package/dist/translations-DM5R5VZ0.cjs +1 -0
  56. package/dist/{translations-D5WRSMhS.js → translations-g3qGTkzw.js} +322 -308
  57. package/dist/types/components/json-schema/ajv-utils.d.ts +1 -3
  58. package/dist/{ur-DBg2MZvK.cjs → ur-BVE5ZRyR.cjs} +1 -1
  59. package/dist/{ur-CCcFf5OU.js → ur-CT09S1x5.js} +1 -1
  60. package/dist/{utils-3Mm1sj4Q.cjs → utils-B25pniId.cjs} +1 -1
  61. package/dist/{utils-CutcxfzK.js → utils-BRzdi3Gx.js} +2 -2
  62. package/dist/{vi-BAHqe-lr.js → vi-BsZzI9Fa.js} +1 -1
  63. package/dist/{vi-DeH8SXUt.cjs → vi-DvU7fKay.cjs} +1 -1
  64. package/dist/{zh-B-ZsrhFY.js → zh-BeCkrv4q.js} +1 -1
  65. package/dist/{zh-Ceo_KGzC.cjs → zh-CijYgDFA.cjs} +1 -1
  66. package/package.json +1 -1
  67. package/dist/2019-CSG1mHKh.cjs +0 -1
  68. package/dist/2019-xRoq64Hq.js +0 -163
  69. package/dist/2020-BxLJruSu.js +0 -191
  70. package/dist/2020-CySfMcC9.cjs +0 -1
  71. package/dist/hls-B5PliUq8.cjs +0 -40
  72. package/dist/hls-DLd3ClAs.js +0 -21741
  73. package/dist/index-B6myFAz5.js +0 -226
  74. package/dist/index-Cok4rljj.cjs +0 -8
  75. package/dist/index-DGQhsTxm.js +0 -8317
  76. package/dist/index-Duw9TkLf.cjs +0 -1
  77. package/dist/translations-BtsgtW4T.js +0 -47
  78. package/dist/translations-CGTcEchB.cjs +0 -1
  79. package/dist/translations-DmVvxPlr.cjs +0 -1
@@ -0,0 +1,27 @@
1
+ "use strict";const io=require("./_commonjsHelpers-DwGv2jUC.cjs");function ao(Ae,hr){for(var be=0;be<hr.length;be++){const te=hr[be];if(typeof te!="string"&&!Array.isArray(te)){for(const ee in te)if(ee!=="default"&&!(ee in Ae)){const ve=Object.getOwnPropertyDescriptor(te,ee);ve&&Object.defineProperty(Ae,ee,ve.get?ve:{enumerable:!0,get:()=>te[ee]})}}}return Object.freeze(Object.defineProperty(Ae,Symbol.toStringTag,{value:"Module"}))}var ti={exports:{}},yn;function no(){return yn||(yn=1,function(Ae,hr){(function be(te){var ee;ee=function(){function ve(n,s){for(var e=0;e<s.length;e++){var t=s[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(n,ii(t.key),t)}}function yt(n,s,e){return s&&ve(n.prototype,s),e&&ve(n,e),Object.defineProperty(n,"prototype",{writable:!1}),n}function Tn(n,s,e){return(s=ii(s))in n?Object.defineProperty(n,s,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[s]=e,n}function Et(){return Et=Object.assign?Object.assign.bind():function(n){for(var s=1;s<arguments.length;s++){var e=arguments[s];for(var t in e)({}).hasOwnProperty.call(e,t)&&(n[t]=e[t])}return n},Et.apply(null,arguments)}function fr(n){return fr=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(s){return s.__proto__||Object.getPrototypeOf(s)},fr(n)}function ct(n,s){n.prototype=Object.create(s.prototype),n.prototype.constructor=n,ke(n,s)}function ei(){try{var n=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(ei=function(){return!!n})()}function ri(n,s){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(n);s&&(t=t.filter(function(r){return Object.getOwnPropertyDescriptor(n,r).enumerable})),e.push.apply(e,t)}return e}function wt(n){for(var s=1;s<arguments.length;s++){var e=arguments[s]!=null?arguments[s]:{};s%2?ri(Object(e),!0).forEach(function(t){Tn(n,t,e[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):ri(Object(e)).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(e,t))})}return n}function ke(n,s){return ke=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},ke(n,s)}function ii(n){var s=function(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,t);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}(n,"string");return typeof s=="symbol"?s:s+""}function De(n){var s=typeof Map=="function"?new Map:void 0;return De=function(e){if(e===null||!function(r){try{return Function.toString.call(r).indexOf("[native code]")!==-1}catch{return typeof r=="function"}}(e))return e;if(typeof e!="function")throw new TypeError("Super expression must either be null or a function");if(s!==void 0){if(s.has(e))return s.get(e);s.set(e,t)}function t(){return function(r,i,a){if(ei())return Reflect.construct.apply(null,arguments);var o=[null];o.push.apply(o,i);var l=new(r.bind.apply(r,o));return a&&ke(l,a.prototype),l}(e,arguments,fr(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),ke(t,e)},De(n)}function ai(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var ni,si,oi={exports:{}},Sn=(ni||(ni=1,function(n){var s=Object.prototype.hasOwnProperty,e="~";function t(){}function r(l,u,d){this.fn=l,this.context=u,this.once=d||!1}function i(l,u,d,h,c){if(typeof d!="function")throw new TypeError("The listener must be a function");var f=new r(d,h||l,c),v=e?e+u:u;return l._events[v]?l._events[v].fn?l._events[v]=[l._events[v],f]:l._events[v].push(f):(l._events[v]=f,l._eventsCount++),l}function a(l,u){--l._eventsCount==0?l._events=new t:delete l._events[u]}function o(){this._events=new t,this._eventsCount=0}Object.create&&(t.prototype=Object.create(null),new t().__proto__||(e=!1)),o.prototype.eventNames=function(){var l,u,d=[];if(this._eventsCount===0)return d;for(u in l=this._events)s.call(l,u)&&d.push(e?u.slice(1):u);return Object.getOwnPropertySymbols?d.concat(Object.getOwnPropertySymbols(l)):d},o.prototype.listeners=function(l){var u=e?e+l:l,d=this._events[u];if(!d)return[];if(d.fn)return[d.fn];for(var h=0,c=d.length,f=new Array(c);h<c;h++)f[h]=d[h].fn;return f},o.prototype.listenerCount=function(l){var u=e?e+l:l,d=this._events[u];return d?d.fn?1:d.length:0},o.prototype.emit=function(l,u,d,h,c,f){var v=e?e+l:l;if(!this._events[v])return!1;var g,m,p=this._events[v],y=arguments.length;if(p.fn){switch(p.once&&this.removeListener(l,p.fn,void 0,!0),y){case 1:return p.fn.call(p.context),!0;case 2:return p.fn.call(p.context,u),!0;case 3:return p.fn.call(p.context,u,d),!0;case 4:return p.fn.call(p.context,u,d,h),!0;case 5:return p.fn.call(p.context,u,d,h,c),!0;case 6:return p.fn.call(p.context,u,d,h,c,f),!0}for(m=1,g=new Array(y-1);m<y;m++)g[m-1]=arguments[m];p.fn.apply(p.context,g)}else{var T,S=p.length;for(m=0;m<S;m++)switch(p[m].once&&this.removeListener(l,p[m].fn,void 0,!0),y){case 1:p[m].fn.call(p[m].context);break;case 2:p[m].fn.call(p[m].context,u);break;case 3:p[m].fn.call(p[m].context,u,d);break;case 4:p[m].fn.call(p[m].context,u,d,h);break;default:if(!g)for(T=1,g=new Array(y-1);T<y;T++)g[T-1]=arguments[T];p[m].fn.apply(p[m].context,g)}}return!0},o.prototype.on=function(l,u,d){return i(this,l,u,d,!1)},o.prototype.once=function(l,u,d){return i(this,l,u,d,!0)},o.prototype.removeListener=function(l,u,d,h){var c=e?e+l:l;if(!this._events[c])return this;if(!u)return a(this,c),this;var f=this._events[c];if(f.fn)f.fn!==u||h&&!f.once||d&&f.context!==d||a(this,c);else{for(var v=0,g=[],m=f.length;v<m;v++)(f[v].fn!==u||h&&!f[v].once||d&&f[v].context!==d)&&g.push(f[v]);g.length?this._events[c]=g.length===1?g[0]:g:a(this,c)}return this},o.prototype.removeAllListeners=function(l){var u;return l?(u=e?e+l:l,this._events[u]&&a(this,u)):(this._events=new t,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=e,o.EventEmitter=o,n.exports=o}(oi)),oi.exports),cr=ai(Sn),li={exports:{}},vr=(si||(si=1,function(n,s){var e,t,r,i,a;e=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,t=/^(?=([^\/?#]*))\1([^]*)$/,r=/(?:\/|^)\.(?=\/)/g,i=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,a={buildAbsoluteURL:function(o,l,u){if(u=u||{},o=o.trim(),!(l=l.trim())){if(!u.alwaysNormalize)return o;var d=a.parseURL(o);if(!d)throw new Error("Error trying to parse base URL.");return d.path=a.normalizePath(d.path),a.buildURLFromParts(d)}var h=a.parseURL(l);if(!h)throw new Error("Error trying to parse relative URL.");if(h.scheme)return u.alwaysNormalize?(h.path=a.normalizePath(h.path),a.buildURLFromParts(h)):l;var c=a.parseURL(o);if(!c)throw new Error("Error trying to parse base URL.");if(!c.netLoc&&c.path&&c.path[0]!=="/"){var f=t.exec(c.path);c.netLoc=f[1],c.path=f[2]}c.netLoc&&!c.path&&(c.path="/");var v={scheme:c.scheme,netLoc:h.netLoc,path:null,params:h.params,query:h.query,fragment:h.fragment};if(!h.netLoc&&(v.netLoc=c.netLoc,h.path[0]!=="/"))if(h.path){var g=c.path,m=g.substring(0,g.lastIndexOf("/")+1)+h.path;v.path=a.normalizePath(m)}else v.path=c.path,h.params||(v.params=c.params,h.query||(v.query=c.query));return v.path===null&&(v.path=u.alwaysNormalize?a.normalizePath(h.path):h.path),a.buildURLFromParts(v)},parseURL:function(o){var l=e.exec(o);return l?{scheme:l[1]||"",netLoc:l[2]||"",path:l[3]||"",params:l[4]||"",query:l[5]||"",fragment:l[6]||""}:null},normalizePath:function(o){for(o=o.split("").reverse().join("").replace(r,"");o.length!==(o=o.replace(i,"")).length;);return o.split("").reverse().join("")},buildURLFromParts:function(o){return o.scheme+o.netLoc+o.path+o.params+o.query+o.fragment}},n.exports=a}(li)),li.exports),U=Number.isFinite||function(n){return typeof n=="number"&&isFinite(n)},Ln=Number.isSafeInteger||function(n){return typeof n=="number"&&Math.abs(n)<=Rn},Rn=Number.MAX_SAFE_INTEGER||9007199254740991,W=function(n){return n.NETWORK_ERROR="networkError",n.MEDIA_ERROR="mediaError",n.KEY_SYSTEM_ERROR="keySystemError",n.MUX_ERROR="muxError",n.OTHER_ERROR="otherError",n}({}),I=function(n){return n.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",n.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",n.KEY_SYSTEM_NO_SESSION="keySystemNoSession",n.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",n.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",n.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",n.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",n.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",n.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",n.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",n.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR="keySystemDestroyMediaKeysError",n.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR="keySystemDestroyCloseSessionError",n.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR="keySystemDestroyRemoveSessionError",n.MANIFEST_LOAD_ERROR="manifestLoadError",n.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",n.MANIFEST_PARSING_ERROR="manifestParsingError",n.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",n.LEVEL_EMPTY_ERROR="levelEmptyError",n.LEVEL_LOAD_ERROR="levelLoadError",n.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",n.LEVEL_PARSING_ERROR="levelParsingError",n.LEVEL_SWITCH_ERROR="levelSwitchError",n.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",n.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",n.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",n.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",n.FRAG_LOAD_ERROR="fragLoadError",n.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",n.FRAG_DECRYPT_ERROR="fragDecryptError",n.FRAG_PARSING_ERROR="fragParsingError",n.FRAG_GAP="fragGap",n.REMUX_ALLOC_ERROR="remuxAllocError",n.KEY_LOAD_ERROR="keyLoadError",n.KEY_LOAD_TIMEOUT="keyLoadTimeOut",n.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",n.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",n.BUFFER_APPEND_ERROR="bufferAppendError",n.BUFFER_APPENDING_ERROR="bufferAppendingError",n.BUFFER_STALLED_ERROR="bufferStalledError",n.BUFFER_FULL_ERROR="bufferFullError",n.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",n.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",n.ASSET_LIST_LOAD_ERROR="assetListLoadError",n.ASSET_LIST_LOAD_TIMEOUT="assetListLoadTimeout",n.ASSET_LIST_PARSING_ERROR="assetListParsingError",n.INTERSTITIAL_ASSET_ITEM_ERROR="interstitialAssetItemError",n.INTERNAL_EXCEPTION="internalException",n.INTERNAL_ABORTED="aborted",n.ATTACH_MEDIA_ERROR="attachMediaError",n.UNKNOWN="unknown",n}({}),E=function(n){return n.MEDIA_ATTACHING="hlsMediaAttaching",n.MEDIA_ATTACHED="hlsMediaAttached",n.MEDIA_DETACHING="hlsMediaDetaching",n.MEDIA_DETACHED="hlsMediaDetached",n.MEDIA_ENDED="hlsMediaEnded",n.STALL_RESOLVED="hlsStallResolved",n.BUFFER_RESET="hlsBufferReset",n.BUFFER_CODECS="hlsBufferCodecs",n.BUFFER_CREATED="hlsBufferCreated",n.BUFFER_APPENDING="hlsBufferAppending",n.BUFFER_APPENDED="hlsBufferAppended",n.BUFFER_EOS="hlsBufferEos",n.BUFFERED_TO_END="hlsBufferedToEnd",n.BUFFER_FLUSHING="hlsBufferFlushing",n.BUFFER_FLUSHED="hlsBufferFlushed",n.MANIFEST_LOADING="hlsManifestLoading",n.MANIFEST_LOADED="hlsManifestLoaded",n.MANIFEST_PARSED="hlsManifestParsed",n.LEVEL_SWITCHING="hlsLevelSwitching",n.LEVEL_SWITCHED="hlsLevelSwitched",n.LEVEL_LOADING="hlsLevelLoading",n.LEVEL_LOADED="hlsLevelLoaded",n.LEVEL_UPDATED="hlsLevelUpdated",n.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",n.LEVELS_UPDATED="hlsLevelsUpdated",n.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",n.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",n.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",n.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",n.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",n.AUDIO_TRACK_UPDATED="hlsAudioTrackUpdated",n.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",n.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",n.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",n.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",n.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",n.SUBTITLE_TRACK_UPDATED="hlsSubtitleTrackUpdated",n.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",n.CUES_PARSED="hlsCuesParsed",n.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",n.INIT_PTS_FOUND="hlsInitPtsFound",n.FRAG_LOADING="hlsFragLoading",n.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",n.FRAG_LOADED="hlsFragLoaded",n.FRAG_DECRYPTED="hlsFragDecrypted",n.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",n.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",n.FRAG_PARSING_METADATA="hlsFragParsingMetadata",n.FRAG_PARSED="hlsFragParsed",n.FRAG_BUFFERED="hlsFragBuffered",n.FRAG_CHANGED="hlsFragChanged",n.FPS_DROP="hlsFpsDrop",n.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",n.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",n.ERROR="hlsError",n.DESTROYING="hlsDestroying",n.KEY_LOADING="hlsKeyLoading",n.KEY_LOADED="hlsKeyLoaded",n.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",n.BACK_BUFFER_REACHED="hlsBackBufferReached",n.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",n.ASSET_LIST_LOADING="hlsAssetListLoading",n.ASSET_LIST_LOADED="hlsAssetListLoaded",n.INTERSTITIALS_UPDATED="hlsInterstitialsUpdated",n.INTERSTITIALS_BUFFERED_TO_BOUNDARY="hlsInterstitialsBufferedToBoundary",n.INTERSTITIAL_ASSET_PLAYER_CREATED="hlsInterstitialAssetPlayerCreated",n.INTERSTITIAL_STARTED="hlsInterstitialStarted",n.INTERSTITIAL_ASSET_STARTED="hlsInterstitialAssetStarted",n.INTERSTITIAL_ASSET_ENDED="hlsInterstitialAssetEnded",n.INTERSTITIAL_ASSET_ERROR="hlsInterstitialAssetError",n.INTERSTITIAL_ENDED="hlsInterstitialEnded",n.INTERSTITIALS_PRIMARY_RESUMED="hlsInterstitialsPrimaryResumed",n.PLAYOUT_LIMIT_REACHED="hlsPlayoutLimitReached",n.EVENT_CUE_ENTER="hlsEventCueEnter",n}({}),re="manifest",jt="level",qt="audioTrack",zt="subtitleTrack",J="main",ge="audio",_e="subtitle",me=function(){function n(e,t,r){t===void 0&&(t=0),r===void 0&&(r=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=r}var s=n.prototype;return s.sample=function(e,t){var r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e},s.getTotalWeight=function(){return this.totalWeight_},s.getEstimate=function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_},n}(),An=function(){function n(e,t,r,i){i===void 0&&(i=100),this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=r,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new me(e),this.fast_=new me(t),this.defaultTTFB_=i,this.ttfb_=new me(e)}var s=n.prototype;return s.update=function(e,t){var r=this.slow_,i=this.fast_,a=this.ttfb_;r.halfLife!==e&&(this.slow_=new me(e,r.getEstimate(),r.getTotalWeight())),i.halfLife!==t&&(this.fast_=new me(t,i.getEstimate(),i.getTotalWeight())),a.halfLife!==e&&(this.ttfb_=new me(e,a.getEstimate(),a.getTotalWeight()))},s.sample=function(e,t){var r=(e=Math.max(e,this.minDelayMs_))/1e3,i=8*t/r;this.fast_.sample(r,i),this.slow_.sample(r,i)},s.sampleTTFB=function(e){var t=e/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(r,Math.max(e,5))},s.canEstimate=function(){return this.fast_.getTotalWeight()>=this.minWeight_},s.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},s.getEstimateTTFB=function(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_},s.destroy=function(){},yt(n,[{key:"defaultEstimate",get:function(){return this.defaultEstimate_}}])}(),Xt=function(n,s){this.trace=void 0,this.debug=void 0,this.log=void 0,this.warn=void 0,this.info=void 0,this.error=void 0;var e="["+n+"]:";this.trace=ie,this.debug=s.debug.bind(null,e),this.log=s.log.bind(null,e),this.warn=s.warn.bind(null,e),this.info=s.info.bind(null,e),this.error=s.error.bind(null,e)},ie=function(){},bn={trace:ie,debug:ie,log:ie,warn:ie,info:ie,error:ie};function gr(){return Et({},bn)}function ui(n,s,e){return s[n]?s[n].bind(s):function(t,r){var i=self.console[t];return i?i.bind(self.console,(r?"["+r+"] ":"")+"["+t+"] >"):ie}(n,e)}var mr=gr();function di(n,s,e){var t=gr();if(typeof console=="object"&&n===!0||typeof n=="object"){var r=["debug","log","info","warn","error"];r.forEach(function(i){t[i]=ui(i,n,e)});try{t.log('Debug logs enabled for "'+s+'" in hls.js version 1.6.14')}catch{return gr()}r.forEach(function(i){mr[i]=ui(i,n)})}else Et(mr,t);return t}var hi,fi,nt=mr,ci=fi?hi:(fi=1,hi=void 0),kn=ai(ci);function ae(n){if(n===void 0&&(n=!0),typeof self<"u")return(n||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function Ft(n,s){if(s===void 0&&(s=!1),typeof TextDecoder<"u"){var e=new TextDecoder("utf-8").decode(n);if(s){var t=e.indexOf("\0");return t!==-1?e.substring(0,t):e}return e.replace(/\0/g,"")}for(var r,i,a,o=n.length,l="",u=0;u<o;){if((r=n[u++])===0&&s)return l;if(r!==0&&r!==3)switch(r>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:l+=String.fromCharCode(r);break;case 12:case 13:i=n[u++],l+=String.fromCharCode((31&r)<<6|63&i);break;case 14:i=n[u++],a=n[u++],l+=String.fromCharCode((15&r)<<12|(63&i)<<6|(63&a)<<0)}}return l}function Ie(n){for(var s="",e=0;e<n.length;e++){var t=n[e].toString(16);t.length<2&&(t="0"+t),s+=t}return s}function vi(n){return Uint8Array.from(n.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var pr=function(){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}},Ut="audio",Qt="video",yr="audiovideo",gi=function(){function n(e){var t,r,i;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,(i=mi(t=this,r="stats"))&&(i.enumerable=!0,Object.defineProperty(t,r,i))}var s=n.prototype;return s.setByteRange=function(e,t){var r,i=e.split("@",2);r=i.length===1?t?.byteRangeEndOffset||0:parseInt(i[1]),this._byteRange=[r,parseInt(i[0])+r]},s.clearElementaryStreamInfo=function(){var e=this.elementaryStreams;e[Ut]=null,e[Qt]=null,e[yr]=null},yt(n,[{key:"baseurl",get:function(){return this.base.url}},{key:"byteRange",get:function(){return this._byteRange===null?[]:this._byteRange}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"elementaryStreams",get:function(){var e;return this._streams===null&&(this._streams=((e={})[Ut]=null,e[Qt]=null,e[yr]=null,e)),this._streams},set:function(e){this._streams=e}},{key:"hasStats",get:function(){return this._stats!==null}},{key:"hasStreams",get:function(){return this._streams!==null}},{key:"stats",get:function(){return this._stats===null&&(this._stats=new pr),this._stats},set:function(e){this._stats=e}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=vr.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(e){this._url=e}}])}();function Mt(n){return n.sn!=="initSegment"}var Er=function(n){function s(t,r){var i;return(i=n.call(this,r)||this)._decryptdata=null,i._programDateTime=null,i._ref=null,i._bitrate=void 0,i.rawProgramDateTime=null,i.tagList=[],i.duration=0,i.sn=0,i.levelkeys=void 0,i.type=void 0,i.loader=null,i.keyLoader=null,i.level=-1,i.cc=0,i.startPTS=void 0,i.endPTS=void 0,i.startDTS=void 0,i.endDTS=void 0,i.start=0,i.playlistOffset=0,i.deltaPTS=void 0,i.maxStartPTS=void 0,i.minEndPTS=void 0,i.data=void 0,i.bitrateTest=!1,i.title=null,i.initSegment=null,i.endList=void 0,i.gap=void 0,i.urlId=0,i.type=t,i}ct(s,n);var e=s.prototype;return e.addStart=function(t){this.setStart(this.start+t)},e.setStart=function(t){this.start=t,this._ref&&(this._ref.start=t)},e.setDuration=function(t){this.duration=t,this._ref&&(this._ref.duration=t)},e.setKeyFormat=function(t){var r=this.levelkeys;if(r){var i,a=r[t];!a||(i=this._decryptdata)!=null&&i.keyId||(this._decryptdata=a.getDecryptData(this.sn,r))}},e.abortRequests=function(){var t,r;(t=this.loader)==null||t.abort(),(r=this.keyLoader)==null||r.abort()},e.setElementaryStreamInfo=function(t,r,i,a,o,l){l===void 0&&(l=!1);var u=this.elementaryStreams,d=u[t];d?(d.startPTS=Math.min(d.startPTS,r),d.endPTS=Math.max(d.endPTS,i),d.startDTS=Math.min(d.startDTS,a),d.endDTS=Math.max(d.endDTS,o)):u[t]={startPTS:r,endPTS:i,startDTS:a,endDTS:o,partial:l}},yt(s,[{key:"byteLength",get:function(){if(this.hasStats){var t=this.stats.total;if(t)return t}if(this.byteRange.length){var r=this.byteRange[0],i=this.byteRange[1];if(U(r)&&U(i))return i-r}return null}},{key:"bitrate",get:function(){return this.byteLength?8*this.byteLength/this.duration:this._bitrate?this._bitrate:null},set:function(t){this._bitrate=t}},{key:"decryptdata",get:function(){var t,r=this.levelkeys;if(!r||r.NONE)return null;if(r.identity)this._decryptdata||(this._decryptdata=r.identity.getDecryptData(this.sn));else if((t=this._decryptdata)==null||!t.keyId){var i=Object.keys(r);if(i.length===1){var a=this._decryptdata=r[i[0]]||null;a&&(this._decryptdata=a.getDecryptData(this.sn,r))}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null)return null;var t=U(this.duration)?this.duration:0;return this.programDateTime+1e3*t}},{key:"encrypted",get:function(){var t;if((t=this._decryptdata)!=null&&t.encrypted)return!0;if(this.levelkeys){var r,i=Object.keys(this.levelkeys),a=i.length;if(a>1||a===1&&(r=this.levelkeys[i[0]])!=null&&r.encrypted)return!0}return!1}},{key:"programDateTime",get:function(){return this._programDateTime===null&&this.rawProgramDateTime&&(this.programDateTime=Date.parse(this.rawProgramDateTime)),this._programDateTime},set:function(t){U(t)?this._programDateTime=t:this._programDateTime=this.rawProgramDateTime=null}},{key:"ref",get:function(){return Mt(this)?(this._ref||(this._ref={base:this.base,start:this.start,duration:this.duration,sn:this.sn,programDateTime:this.programDateTime}),this._ref):null}}])}(gi),Dn=function(n){function s(e,t,r,i,a){var o;(o=n.call(this,r)||this).fragOffset=0,o.duration=0,o.gap=!1,o.independent=!1,o.relurl=void 0,o.fragment=void 0,o.index=void 0,o.duration=e.decimalFloatingPoint("DURATION"),o.gap=e.bool("GAP"),o.independent=e.bool("INDEPENDENT"),o.relurl=e.enumeratedString("URI"),o.fragment=t,o.index=i;var l=e.enumeratedString("BYTERANGE");return l&&o.setByteRange(l,a),a&&(o.fragOffset=a.fragOffset+a.duration),o}return ct(s,n),yt(s,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var e=this.elementaryStreams;return!!(e.audio||e.video||e.audiovideo)}}])}(gi);function mi(n,s){var e=Object.getPrototypeOf(n);if(e){var t=Object.getOwnPropertyDescriptor(e,s);return t||mi(e,s)}}var pi=Math.pow(2,32)-1,_n=[].push,yi={video:1,audio:2,id3:3,text:4};function Tt(n){return String.fromCharCode.apply(null,n)}function Ei(n,s){var e=n[s]<<8|n[s+1];return e<0?65536+e:e}function H(n,s){var e=Si(n,s);return e<0?4294967296+e:e}function Ti(n,s){var e=H(n,s);return e*=Math.pow(2,32),e+=H(n,s+4)}function Si(n,s){return n[s]<<24|n[s+1]<<16|n[s+2]<<8|n[s+3]}function X(n,s){var e=[];if(!s.length)return e;for(var t=n.byteLength,r=0;r<t;){var i=H(n,r),a=i>1?r+i:t;if(Tt(n.subarray(r+4,r+8))===s[0])if(s.length===1)e.push(n.subarray(r+8,a));else{var o=X(n.subarray(r+8,a),s.slice(1));o.length&&_n.apply(e,o)}r=a}return e}function In(n){var s=[],e=n[0],t=8,r=H(n,t);t+=4;var i=0,a=0;e===0?(i=H(n,t),a=H(n,t+4),t+=8):(i=Ti(n,t),a=Ti(n,t+8),t+=16),t+=2;var o=n.length+a,l=Ei(n,t);t+=2;for(var u=0;u<l;u++){var d=t,h=H(n,d);d+=4;var c=2147483647&h;if((2147483648&h)>>>31==1)return nt.warn("SIDX has hierarchical references (not supported)"),null;var f=H(n,d);d+=4,s.push({referenceSize:c,subsegmentDuration:f,info:{duration:f/r,start:o,end:o+c-1}}),o+=c,t=d+=4}return{earliestPresentationTime:i,timescale:r,version:e,referencesCount:l,references:s}}function Li(n){for(var s=[],e=X(n,["moov","trak"]),t=0;t<e.length;t++){var r=e[t],i=X(r,["tkhd"])[0];if(i){var a=i[0],o=H(i,a===0?12:20),l=X(r,["mdia","mdhd"])[0];if(l){var u=H(l,(a=l[0])===0?12:20),d=X(r,["mdia","hdlr"])[0];if(d){var h=Tt(d.subarray(8,12)),c={soun:Ut,vide:Qt}[h],f=Cn(X(r,["mdia","minf","stbl","stsd"])[0]);c?(s[o]={timescale:u,type:c,stsd:f},s[c]=wt({timescale:u,id:o},f)):s[o]={timescale:u,type:h,stsd:f}}}}}return X(n,["moov","mvex","trex"]).forEach(function(v){var g=H(v,4),m=s[g];m&&(m.default={duration:H(v,12),flags:H(v,20)})}),s}function Cn(n){var s,e=n.subarray(8),t=e.subarray(86),r=Tt(e.subarray(4,8)),i=r,a=r==="enca"||r==="encv";if(a){var o=X(e,[r])[0];X(o.subarray(r==="enca"?28:78),["sinf"]).forEach(function(K){var Z=X(K,["schm"])[0];if(Z){var Q=Tt(Z.subarray(4,8));if(Q==="cbcs"||Q==="cenc"){var j=X(K,["frma"])[0];j&&(i=Tt(j))}}})}var l=i;switch(i){case"avc1":case"avc2":case"avc3":case"avc4":var u=X(t,["avcC"])[0];u&&u.length>3&&(i+="."+Ye(u[1])+Ye(u[2])+Ye(u[3]),s=Ke(l==="avc1"?"dva1":"dvav",t));break;case"mp4a":var d=X(e,[r])[0],h=X(d.subarray(28),["esds"])[0];if(h&&h.length>7){var c=4;if(h[c++]!==3)break;c=Tr(h,c),c+=2;var f=h[c++];if(128&f&&(c+=2),64&f&&(c+=h[c++]),h[c++]!==4)break;c=Tr(h,c);var v=h[c++];if(v!==64||(i+="."+Ye(v),c+=12,h[c++]!==5))break;c=Tr(h,c);var g=h[c++],m=(248&g)>>3;m===31&&(m+=1+((7&g)<<3)+((224&h[c])>>5)),i+="."+m}break;case"hvc1":case"hev1":var p=X(t,["hvcC"])[0];if(p&&p.length>12){var y=p[1],T=["","A","B","C"][y>>6],S=31&y,b=H(p,2),L=(32&y)>>5?"H":"L",R=p[12],k=p.subarray(6,12);i+="."+T+S,i+="."+function(K){for(var Z=0,Q=0;Q<32;Q++)Z|=(K>>Q&1)<<31-Q;return Z>>>0}(b).toString(16).toUpperCase(),i+="."+L+R;for(var C="",A=k.length;A--;){var D=k[A];(D||C)&&(C="."+D.toString(16).toUpperCase()+C)}i+=C}s=Ke(l=="hev1"?"dvhe":"dvh1",t);break;case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":i=Ke(i,t)||i;break;case"vp09":var _=X(t,["vpcC"])[0];if(_&&_.length>6){var M=_[4],O=_[5],P=_[6]>>4&15;i+="."+Gt(M)+"."+Gt(O)+"."+Gt(P)}break;case"av01":var w=X(t,["av1C"])[0];if(w&&w.length>2){var x=w[1]>>>5,N=31&w[1],G=w[2]>>>7?"H":"M",B=(64&w[2])>>6,V=(32&w[2])>>5,st=x===2&&B?V?12:10:B?10:8,tt=(16&w[2])>>4,$=(8&w[2])>>3,ot=(4&w[2])>>2,rt=3&w[2];i+="."+x+"."+Gt(N)+G+"."+Gt(st)+"."+tt+"."+$+ot+rt+"."+Gt(1)+"."+Gt(1)+"."+Gt(1)+".0",s=Ke("dav1",t)}}return{codec:i,encrypted:a,supplemental:s}}function Ke(n,s){var e=X(s,["dvvC"]),t=e.length?e[0]:X(s,["dvcC"])[0];if(t){var r=t[2]>>1&127,i=t[2]<<5&32|t[3]>>3&31;return n+"."+Gt(r)+"."+Gt(i)}}function Tr(n,s){for(var e=s+5;128&n[s++]&&s<e;);return s}function Ye(n){return("0"+n.toString(16).toUpperCase()).slice(-2)}function Gt(n){return(n<10?"0":"")+n}function Ri(n,s){X(n,["moov","trak"]).forEach(function(e){var t=X(e,["mdia","minf","stbl","stsd"])[0];if(t){var r=t.subarray(8),i=X(r,["enca"]),a=i.length>0;a||(i=X(r,["encv"])),i.forEach(function(o){X(a?o.subarray(28):o.subarray(78),["sinf"]).forEach(function(l){var u=function(d){var h=X(d,["schm"])[0];if(h){var c=Tt(h.subarray(4,8));if(c==="cbcs"||c==="cenc"){var f=X(d,["schi","tenc"])[0];if(f)return f}}}(l);u&&s(u,a)})})}})}function Nt(n,s){var e=new Uint8Array(n.length+s.length);return e.set(n),e.set(s,n.length),e}function Ai(n,s){var e=[],t=s.samples,r=s.timescale,i=s.id,a=!1;return X(t,["moof"]).map(function(o){var l=o.byteOffset-8;X(o,["traf"]).map(function(u){var d=X(u,["tfdt"]).map(function(h){var c=h[0],f=H(h,4);return c===1&&(f*=Math.pow(2,32),f+=H(h,8)),f/r})[0];return d!==void 0&&(n=d),X(u,["tfhd"]).map(function(h){var c=H(h,4),f=16777215&H(h,0),v=0,g=(16&f)!=0,m=0,p=(32&f)!=0,y=8;c===i&&((1&f)!=0&&(y+=8),(2&f)!=0&&(y+=4),(8&f)!=0&&(v=H(h,y),y+=4),g&&(m=H(h,y),y+=4),p&&(y+=4),s.type==="video"&&(a=Sr(s.codec)),X(u,["trun"]).map(function(T){var S=T[0],b=16777215&H(T,0),L=(1&b)!=0,R=0,k=(4&b)!=0,C=(256&b)!=0,A=0,D=(512&b)!=0,_=0,M=(1024&b)!=0,O=(2048&b)!=0,P=0,w=H(T,4),x=8;L&&(R=H(T,x),x+=4),k&&(x+=4);for(var N=R+l,G=0;G<w;G++){if(C?(A=H(T,x),x+=4):A=v,D?(_=H(T,x),x+=4):_=m,M&&(x+=4),O&&(P=S===0?H(T,x):Si(T,x),x+=4),s.type===Qt)for(var B=0;B<_;){var V=H(t,N);Pn(a,t[N+=4])&&bi(t.subarray(N,N+V),a?2:1,n+P/r,e),N+=V,B+=V+4}n+=A/r}}))})})}),e}function Sr(n){if(!n)return!1;var s=n.substring(0,4);return s==="hvc1"||s==="hev1"||s==="dvh1"||s==="dvhe"}function Pn(n,s){if(n){var e=s>>1&63;return e===39||e===40}return(31&s)==6}function bi(n,s,e,t){var r=ki(n),i=0;i+=s;for(var a=0,o=0,l=0;i<r.length;){a=0;do{if(i>=r.length)break;a+=l=r[i++]}while(l===255);o=0;do{if(i>=r.length)break;o+=l=r[i++]}while(l===255);var u=r.length-i,d=i;if(o<u)i+=o;else if(o>u){nt.error("Malformed SEI payload. "+o+" is too small, only "+u+" bytes left to parse.");break}if(a===4){if(r[d++]===181){var h=Ei(r,d);if(d+=2,h===49){var c=H(r,d);if(d+=4,c===1195456820){var f=r[d++];if(f===3){var v=r[d++],g=64&v,m=g?2+3*(31&v):0,p=new Uint8Array(m);if(g){p[0]=v;for(var y=1;y<m;y++)p[y]=r[d++]}t.push({type:f,payloadType:a,pts:e,bytes:p})}}}}}else if(a===5&&o>16){for(var T=[],S=0;S<16;S++){var b=r[d++].toString(16);T.push(b.length==1?"0"+b:b),S!==3&&S!==5&&S!==7&&S!==9||T.push("-")}for(var L=o-16,R=new Uint8Array(L),k=0;k<L;k++)R[k]=r[d++];t.push({payloadType:a,pts:e,uuid:T.join(""),userData:Ft(R),userDataBytes:R})}}}function ki(n){for(var s=n.byteLength,e=[],t=1;t<s-2;)n[t]===0&&n[t+1]===0&&n[t+2]===3?(e.push(t+2),t+=2):t++;if(e.length===0)return n;var r=s-e.length,i=new Uint8Array(r),a=0;for(t=0;t<r;a++,t++)a===e[0]&&(a++,e.shift()),i[t]=n[a];return i}var Di=function(){return/\(Windows.+Firefox\//i.test(navigator.userAgent)},pe={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 Lr(n,s){var e=pe[s];return!!e&&!!e[n.slice(0,4)]}function Ce(n,s,e){return e===void 0&&(e=!0),!n.split(",").some(function(t){return!Rr(t,s,e)})}function Rr(n,s,e){var t;e===void 0&&(e=!0);var r=ae(e);return(t=r?.isTypeSupported(Pe(n,s)))!=null&&t}function Pe(n,s){return s+"/mp4;codecs="+n}function _i(n){if(n){var s=n.substring(0,4);return pe.video[s]}return 2}function We(n){var s=Di();return n.split(",").reduce(function(e,t){var r=s&&Sr(t)?9:pe.video[t];return r?(2*r+e)/(e?3:2):(pe.audio[t]+e)/(e?2:1)},0)}var Ar={},wn=/flac|opus|mp4a\.40\.34/i;function je(n,s){return s===void 0&&(s=!0),n.replace(wn,function(e){return function(t,r){if(r===void 0&&(r=!0),Ar[t])return Ar[t];for(var i={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[t],a=0;a<i.length;a++){var o;if(Rr(i[a],"audio",r))return Ar[t]=i[a],i[a];if(i[a]==="mp3"&&(o=ae(r))!=null&&o.isTypeSupported("audio/mpeg"))return""}return t}(e.toLowerCase(),s)})}function qe(n,s){if(n&&(n.length>4||["ac-3","ec-3","alac","fLaC","Opus"].indexOf(n)!==-1)&&(Ii(n,"audio")||Ii(n,"video")))return n;if(s){var e=s.split(",");if(e.length>1){if(n){for(var t=e.length;t--;)if(e[t].substring(0,4)===n.substring(0,4))return e[t]}return e[0]}}return s||n}function Ii(n,s){return Lr(n,s)&&Rr(n,s)}function xn(n){if(n.startsWith("av01.")){for(var s=n.split("."),e=["0","111","01","01","01","0"],t=s.length;t>4&&t<10;t++)s[t]=e[t-4];return s.join(".")}return n}function Ci(n){var s=ae(n)||{isTypeSupported:function(){return!1}};return{mpeg:s.isTypeSupported("audio/mpeg"),mp3:s.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:!1}}function br(n){return n.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}var kr=["NONE","TYPE-0","TYPE-1",null],ze=["SDR","PQ","HLG"],Pi="",On="YES",Fn="v2";function wi(n){var s=n.canSkipUntil,e=n.canSkipDateRanges,t=n.age;return s&&t<s/2?e?Fn:On:Pi}var xi=function(){function n(s,e,t){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=s,this.part=e,this.skip=t}return n.prototype.addDirectives=function(s){var e=new self.URL(s);return this.msn!==void 0&&e.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&e.searchParams.set("_HLS_part",this.part.toString()),this.skip&&e.searchParams.set("_HLS_skip",this.skip),e.href},n}(),Oi=function(){function n(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(function(i){return!!i}).map(function(i){return i.substring(0,4)}).join(","),"supplemental"in e){var t;this.supplemental=e.supplemental;var r=(t=e.supplemental)==null?void 0:t.videoCodec;r&&r!==e.videoCodec&&(this.codecSet+=","+r.substring(0,4))}this.addGroupId("audio",e.attrs.AUDIO),this.addGroupId("text",e.attrs.SUBTITLES)}var s=n.prototype;return s.hasAudioGroup=function(e){return Fi(this._audioGroups,e)},s.hasSubtitleGroup=function(e){return Fi(this._subtitleGroups,e)},s.addGroupId=function(e,t){if(t){if(e==="audio"){var r=this._audioGroups;r||(r=this._audioGroups=[]),r.indexOf(t)===-1&&r.push(t)}else if(e==="text"){var i=this._subtitleGroups;i||(i=this._subtitleGroups=[]),i.indexOf(t)===-1&&i.push(t)}}},s.addFallback=function(){},yt(n,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"averageBitrate",get:function(){return this._avgBitrate||this.realBitrate||this.bitrate}},{key:"attrs",get:function(){return this._attrs[0]}},{key:"codecs",get:function(){return this.attrs.CODECS||""}},{key:"pathwayId",get:function(){return this.attrs["PATHWAY-ID"]||"."}},{key:"videoRange",get:function(){return this.attrs["VIDEO-RANGE"]||"SDR"}},{key:"score",get:function(){return this.attrs.optionalFloat("SCORE",0)}},{key:"uri",get:function(){return this.url[0]||""}},{key:"audioGroups",get:function(){return this._audioGroups}},{key:"subtitleGroups",get:function(){return this._subtitleGroups}},{key:"urlId",get:function(){return 0},set:function(e){}},{key:"audioGroupIds",get:function(){return this.audioGroups?[this.audioGroupId]:void 0}},{key:"textGroupIds",get:function(){return this.subtitleGroups?[this.textGroupId]:void 0}},{key:"audioGroupId",get:function(){var e;return(e=this.audioGroups)==null?void 0:e[0]}},{key:"textGroupId",get:function(){var e;return(e=this.subtitleGroups)==null?void 0:e[0]}}])}();function Fi(n,s){return!(!s||!n)&&n.indexOf(s)!==-1}function Mn(n,s){var e=!1,t=[];if(n&&(e=n!=="SDR",t=[n]),s){var r=(t=s.allowedVideoRanges||ze.slice(0)).join("")!=="SDR"&&!s.videoCodec;(e=s.preferHDR!==void 0?s.preferHDR:r&&function(){if(typeof matchMedia=="function"){var i=matchMedia("(dynamic-range: high)"),a=matchMedia("bad query");if(i.media!==a.media)return i.matches===!0}return!1}())||(t=["SDR"])}return{preferHDR:e,allowedVideoRanges:t}}var It=function(n,s){return JSON.stringify(n,function(e){var t=new WeakSet;return function(r,i){if(e&&(i=e(r,i)),typeof i=="object"&&i!==null){if(t.has(i))return;t.add(i)}return i}}(s))};function Vt(n,s){nt.log('[abr] start candidates with "'+n+'" ignored because '+s)}function Mi(n){return n.reduce(function(s,e){var t=s.groups[e.groupId];t||(t=s.groups[e.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),t.tracks.push(e);var r=e.channels||"2";return t.channels[r]=(t.channels[r]||0)+1,t.hasDefault=t.hasDefault||e.default,t.hasAutoSelect=t.hasAutoSelect||e.autoselect,t.hasDefault&&(s.hasDefaultAudio=!0),t.hasAutoSelect&&(s.hasAutoSelectAudio=!0),s},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function Ni(n,s){var e;return!!n&&n!==((e=s.loadLevelObj)==null?void 0:e.uri)}var Nn=function(n){function s(t){var r;return(r=n.call(this,"abr",t.logger)||this).hls=void 0,r.lastLevelLoadSec=0,r.lastLoadedFragLevel=-1,r.firstSelection=-1,r._nextAutoLevel=-1,r.nextAutoLevelKey="",r.audioTracksByGroup=null,r.codecTiers=null,r.timer=-1,r.fragCurrent=null,r.partCurrent=null,r.bitrateTestDelay=0,r.rebufferNotice=-1,r.supportedCache={},r.bwEstimator=void 0,r._abandonRulesCheck=function(i){var a,o=r,l=o.fragCurrent,u=o.partCurrent,d=o.hls,h=d.autoLevelEnabled,c=d.media;if(l&&c){var f=performance.now(),v=u?u.stats:l.stats,g=u?u.duration:l.duration,m=f-v.loading.start,p=d.minAutoLevel,y=l.level,T=r._nextAutoLevel;if(v.aborted||v.loaded&&v.loaded===v.total||y<=p)return r.clearTimer(),void(r._nextAutoLevel=-1);if(h){var S=T>-1&&T!==y,b=!!i||S;if(b||!c.paused&&c.playbackRate&&c.readyState){var L=d.mainForwardBufferInfo;if(b||L!==null){var R=r.bwEstimator.getEstimateTTFB(),k=Math.abs(c.playbackRate);if(!(m<=Math.max(R,g/(2*k)*1e3))){var C=L?L.len/k:0,A=v.loading.first?v.loading.first-v.loading.start:-1,D=v.loaded&&A>-1,_=r.getBwEstimate(),M=d.levels,O=M[y],P=Math.max(v.loaded,Math.round(g*(l.bitrate||O.averageBitrate)/8)),w=D?m-A:m;w<1&&D&&(w=Math.min(m,8*v.loaded/_));var x=D?1e3*v.loaded/w:0,N=R/1e3,G=x?(P-v.loaded)/x:8*P/_+N;if(!(G<=C)){var B,V=x?8*x:_,st=((a=i?.details||r.hls.latestLevelDetails)==null?void 0:a.live)===!0,tt=r.hls.config.abrBandWidthUpFactor,$=Number.POSITIVE_INFINITY;for(B=y-1;B>p;B--){var ot=M[B].maxBitrate,rt=!M[B].details||st;if(($=r.getTimeToLoadFrag(N,V,g*ot,rt))<Math.min(C,g+N))break}if(!($>=G||$>10*g)){D?r.bwEstimator.sample(m-Math.min(R,A),v.loaded):r.bwEstimator.sampleTTFB(m);var K=M[B].maxBitrate;r.getBwEstimate()*tt>K&&r.resetEstimator(K);var Z=r.findBestLevel(K,p,B,0,C,1,1);Z>-1&&(B=Z),r.warn("Fragment "+l.sn+(u?" part "+u.index:"")+" of level "+y+` is loading too slowly;
2
+ Fragment duration: `+l.duration.toFixed(3)+`
3
+ Time to underbuffer: `+C.toFixed(3)+` s
4
+ Estimated load time for current fragment: `+G.toFixed(3)+` s
5
+ Estimated load time for down switch fragment: `+$.toFixed(3)+` s
6
+ TTFB estimate: `+(0|A)+` ms
7
+ Current BW estimate: `+(U(_)?0|_:"Unknown")+` bps
8
+ New BW estimate: `+(0|r.getBwEstimate())+` bps
9
+ Switching to level `+B+" @ "+(0|K)+" bps"),d.nextLoadLevel=d.nextAutoLevel=B,r.clearTimer();var Q=function(){if(r.clearTimer(),r.fragCurrent===l&&r.hls.loadLevel===B&&B>0){var j=r.getStarvationDelay();if(r.warn("Aborting inflight request "+(B>0?"and switching down":"")+`
10
+ Fragment duration: `+l.duration.toFixed(3)+` s
11
+ Time to underbuffer: `+j.toFixed(3)+" s"),l.abortRequests(),r.fragCurrent=r.partCurrent=null,B>p){var at=r.findBestLevel(r.hls.levels[p].bitrate,p,B,0,j,1,1);at===-1&&(at=p),r.hls.nextLoadLevel=r.hls.nextAutoLevel=at,r.resetEstimator(r.hls.levels[at].bitrate)}}};S||G>2*$?Q():r.timer=self.setInterval(Q,1e3*$),d.trigger(E.FRAG_LOAD_EMERGENCY_ABORTED,{frag:l,part:u,stats:v})}}}}}}}},r.hls=t,r.bwEstimator=r.initEstimator(),r.registerListeners(),r}ct(s,n);var e=s.prototype;return e.resetEstimator=function(t){t&&(this.log("setting initial bwe to "+t),this.hls.config.abrEwmaDefaultEstimate=t),this.firstSelection=-1,this.bwEstimator=this.initEstimator()},e.initEstimator=function(){var t=this.hls.config;return new An(t.abrEwmaSlowVoD,t.abrEwmaFastVoD,t.abrEwmaDefaultEstimate)},e.registerListeners=function(){var t=this.hls;t.on(E.MANIFEST_LOADING,this.onManifestLoading,this),t.on(E.FRAG_LOADING,this.onFragLoading,this),t.on(E.FRAG_LOADED,this.onFragLoaded,this),t.on(E.FRAG_BUFFERED,this.onFragBuffered,this),t.on(E.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(E.LEVEL_LOADED,this.onLevelLoaded,this),t.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(E.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),t.on(E.ERROR,this.onError,this)},e.unregisterListeners=function(){var t=this.hls;t&&(t.off(E.MANIFEST_LOADING,this.onManifestLoading,this),t.off(E.FRAG_LOADING,this.onFragLoading,this),t.off(E.FRAG_LOADED,this.onFragLoaded,this),t.off(E.FRAG_BUFFERED,this.onFragBuffered,this),t.off(E.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(E.LEVEL_LOADED,this.onLevelLoaded,this),t.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(E.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),t.off(E.ERROR,this.onError,this))},e.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=this.supportedCache=null,this.fragCurrent=this.partCurrent=null},e.onManifestLoading=function(t,r){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.supportedCache={},this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()},e.onLevelsUpdated=function(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null},e.onMaxAutoLevelUpdated=function(){this.firstSelection=-1,this.nextAutoLevelKey=""},e.onFragLoading=function(t,r){var i,a=r.frag;this.ignoreFragment(a)||(a.bitrateTest||(this.fragCurrent=a,this.partCurrent=(i=r.part)!=null?i:null),this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100))},e.onLevelSwitching=function(t,r){this.clearTimer()},e.onError=function(t,r){if(!r.fatal)switch(r.details){case I.BUFFER_ADD_CODEC_ERROR:case I.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case I.FRAG_LOAD_TIMEOUT:var i=r.frag,a=this.fragCurrent,o=this.partCurrent;if(i&&a&&i.sn===a.sn&&i.level===a.level){var l=performance.now(),u=o?o.stats:i.stats,d=l-u.loading.start,h=u.loading.first?u.loading.first-u.loading.start:-1;if(u.loaded&&h>-1){var c=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(d-Math.min(c,h),u.loaded)}else this.bwEstimator.sampleTTFB(d)}}},e.getTimeToLoadFrag=function(t,r,i,a){return t+i/r+(a?t+this.lastLevelLoadSec:0)},e.onLevelLoaded=function(t,r){var i=this.hls.config,a=r.stats.loading,o=a.end-a.first;U(o)&&(this.lastLevelLoadSec=o/1e3),r.details.live?this.bwEstimator.update(i.abrEwmaSlowLive,i.abrEwmaFastLive):this.bwEstimator.update(i.abrEwmaSlowVoD,i.abrEwmaFastVoD),this.timer>-1&&this._abandonRulesCheck(r.levelInfo)},e.onFragLoaded=function(t,r){var i=r.frag,a=r.part,o=a?a.stats:i.stats;if(i.type===J&&this.bwEstimator.sampleTTFB(o.loading.first-o.loading.start),!this.ignoreFragment(i)){if(this.clearTimer(),i.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){var l=a?a.duration:i.duration,u=this.hls.levels[i.level],d=(u.loaded?u.loaded.bytes:0)+o.loaded,h=(u.loaded?u.loaded.duration:0)+l;u.loaded={bytes:d,duration:h},u.realBitrate=Math.round(8*d/h)}if(i.bitrateTest){var c={stats:o,frag:i,part:a,id:i.type};this.onFragBuffered(E.FRAG_BUFFERED,c),i.bitrateTest=!1}else this.lastLoadedFragLevel=i.level}},e.onFragBuffered=function(t,r){var i=r.frag,a=r.part,o=a!=null&&a.stats.loaded?a.stats:i.stats;if(!o.aborted&&!this.ignoreFragment(i)){var l=o.parsing.end-o.loading.start-Math.min(o.loading.first-o.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(l,o.loaded),o.bwEstimate=this.getBwEstimate(),i.bitrateTest?this.bitrateTestDelay=l/1e3:this.bitrateTestDelay=0}},e.ignoreFragment=function(t){return t.type!==J||t.sn==="initSegment"},e.clearTimer=function(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)},e.getAutoLevelKey=function(){return this.getBwEstimate()+"_"+this.getStarvationDelay().toFixed(2)},e.getNextABRAutoLevel=function(){var t=this.fragCurrent,r=this.partCurrent,i=this.hls;if(i.levels.length<=1)return i.loadLevel;var a=i.maxAutoLevel,o=i.config,l=i.minAutoLevel,u=r?r.duration:t?t.duration:0,d=this.getBwEstimate(),h=this.getStarvationDelay(),c=o.abrBandWidthFactor,f=o.abrBandWidthUpFactor;if(h){var v=this.findBestLevel(d,l,a,h,0,c,f);if(v>=0)return this.rebufferNotice=-1,v}var g=u?Math.min(u,o.maxStarvationDelay):o.maxStarvationDelay;if(!h){var m=this.bitrateTestDelay;m&&(g=(u?Math.min(u,o.maxLoadingDelay):o.maxLoadingDelay)-m,this.info("bitrate test took "+Math.round(1e3*m)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*g)+" ms"),c=f=1)}var p=this.findBestLevel(d,l,a,h,g,c,f);if(this.rebufferNotice!==p&&(this.rebufferNotice=p,this.info((h?"rebuffering expected":"buffer is empty")+", optimal quality level "+p)),p>-1)return p;var y=i.levels[l],T=i.loadLevelObj;return T&&y?.bitrate<T.bitrate?l:i.loadLevel},e.getStarvationDelay=function(){var t=this.hls,r=t.media;if(!r)return 1/0;var i=r&&r.playbackRate!==0?Math.abs(r.playbackRate):1,a=t.mainForwardBufferInfo;return(a?a.len:0)/i},e.getBwEstimate=function(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate},e.findBestLevel=function(t,r,i,a,o,l,u){var d,h=this,c=a+o,f=this.lastLoadedFragLevel,v=f===-1?this.hls.firstLevel:f,g=this.fragCurrent,m=this.partCurrent,p=this.hls,y=p.levels,T=p.allAudioTracks,S=p.loadLevel,b=p.config;if(y.length===1)return 0;var L,R=y[v],k=!((d=this.hls.latestLevelDetails)==null||!d.live),C=S===-1||f===-1,A="SDR",D=R?.frameRate||0,_=b.audioPreference,M=b.videoPreference,O=(this.audioTracksByGroup||(this.audioTracksByGroup=Mi(T)),-1);if(C){if(this.firstSelection!==-1)return this.firstSelection;var P=this.codecTiers||(this.codecTiers=function(Q,j,at,dt){return Q.slice(at,dt+1).reduce(function(it,q,ht){if(!q.codecSet)return it;var mt=q.audioGroups,Y=it[q.codecSet];Y||(it[q.codecSet]=Y={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:ht,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!mt,fragmentError:0}),Y.minBitrate=Math.min(Y.minBitrate,q.bitrate);var lt=Math.min(q.height,q.width);return Y.minHeight=Math.min(Y.minHeight,lt),Y.minFramerate=Math.min(Y.minFramerate,q.frameRate),Y.minIndex=Math.min(Y.minIndex,ht),Y.maxScore=Math.max(Y.maxScore,q.score),Y.fragmentError+=q.fragmentError,Y.videoRanges[q.videoRange]=(Y.videoRanges[q.videoRange]||0)+1,it},{})}(y,0,r,i)),w=function(Q,j,at,dt,it){for(var q=Object.keys(Q),ht=dt?.channels,mt=dt?.audioCodec,Y=it?.videoCodec,lt=ht&&parseInt(ht)===2,Pt=!1,Rt=!1,At=1/0,bt=1/0,pt=1/0,kt=1/0,Dt=0,vt=[],Yt=Mn(j,it),oe=Yt.preferHDR,Re=Yt.allowedVideoRanges,fe=function(){var z=Q[q[ce]];Pt||(Pt=z.channels[2]>0),At=Math.min(At,z.minHeight),bt=Math.min(bt,z.minFramerate),pt=Math.min(pt,z.minBitrate),Re.filter(function(ut){return z.videoRanges[ut]>0}).length>0&&(Rt=!0)},ce=q.length;ce--;)fe();At=U(At)?At:0,bt=U(bt)?bt:0;var le=Math.max(1080,At),ue=Math.max(30,bt);pt=U(pt)?pt:at,at=Math.max(pt,at),Rt||(j=void 0);var _t=q.length>1;return{codecSet:q.reduce(function(z,ut){var ft=Q[ut];if(ut===z)return z;if(vt=Rt?Re.filter(function(Bt){return ft.videoRanges[Bt]>0}):[],_t){if(ft.minBitrate>at)return Vt(ut,"min bitrate of "+ft.minBitrate+" > current estimate of "+at),z;if(!ft.hasDefaultAudio)return Vt(ut,"no renditions with default or auto-select sound found"),z;if(mt&&ut.indexOf(mt.substring(0,4))%5!=0)return Vt(ut,'audio codec preference "'+mt+'" not found'),z;if(ht&&!lt){if(!ft.channels[ht])return Vt(ut,"no renditions with "+ht+" channel sound found (channels options: "+Object.keys(ft.channels)+")"),z}else if((!mt||lt)&&Pt&&ft.channels[2]===0)return Vt(ut,"no renditions with stereo sound found"),z;if(ft.minHeight>le)return Vt(ut,"min resolution of "+ft.minHeight+" > maximum of "+le),z;if(ft.minFramerate>ue)return Vt(ut,"min framerate of "+ft.minFramerate+" > maximum of "+ue),z;if(!vt.some(function(Bt){return ft.videoRanges[Bt]>0}))return Vt(ut,"no variants with VIDEO-RANGE of "+It(vt)+" found"),z;if(Y&&ut.indexOf(Y.substring(0,4))%5!=0)return Vt(ut,'video codec preference "'+Y+'" not found'),z;if(ft.maxScore<Dt)return Vt(ut,"max score of "+ft.maxScore+" < selected max of "+Dt),z}return z&&(We(ut)>=We(z)||ft.fragmentError>Q[z].fragmentError)?z:(kt=ft.minIndex,Dt=ft.maxScore,ut)},void 0),videoRanges:vt,preferHDR:oe,minFramerate:bt,minBitrate:pt,minIndex:kt}}(P,A,t,_,M),x=w.codecSet,N=w.videoRanges,G=w.minFramerate,B=w.minBitrate,V=w.minIndex,st=w.preferHDR;O=V,L=x,A=st?N[N.length-1]:N[0],D=G,t=Math.max(t,B),this.log("picked start tier "+It(w))}else L=R?.codecSet,A=R?.videoRange;for(var tt,$=m?m.duration:g?g.duration:0,ot=this.bwEstimator.getEstimateTTFB()/1e3,rt=[],K=function(){var Q,j=y[Z],at=Z>v;if(!j)return 0;if((L&&j.codecSet!==L||A&&j.videoRange!==A||at&&D>j.frameRate||!at&&D>0&&D<j.frameRate||(Q=j.supportedResult)!=null&&(Q=Q.decodingInfoResults)!=null&&Q.some(function(lt){return lt.smooth===!1}))&&(!C||Z!==O))return rt.push(Z),0;var dt,it=j.details,q=(m?it?.partTarget:it?.averagetargetduration)||$;dt=at?u*t:l*t;var ht=$&&a>=2*$&&o===0?j.averageBitrate:j.maxBitrate,mt=h.getTimeToLoadFrag(ot,dt,ht*q,it===void 0);if(dt>=ht&&(Z===f||j.loadError===0&&j.fragmentError===0)&&(mt<=ot||!U(mt)||k&&!h.bitrateTestDelay||mt<c)){var Y=h.forcedAutoLevel;return Z===S||Y!==-1&&Y===S||(rt.length&&h.trace("Skipped level(s) "+rt.join(",")+" of "+i+' max with CODECS and VIDEO-RANGE:"'+y[rt[0]].codecs+'" '+y[rt[0]].videoRange+'; not compatible with "'+L+'" '+A),h.info("switch candidate:"+v+"->"+Z+" adjustedbw("+Math.round(dt)+")-bitrate="+Math.round(dt-ht)+" ttfb:"+ot.toFixed(1)+" avgDuration:"+q.toFixed(1)+" maxFetchDuration:"+c.toFixed(1)+" fetchDuration:"+mt.toFixed(1)+" firstSelection:"+C+" codecSet:"+j.codecSet+" videoRange:"+j.videoRange+" hls.loadLevel:"+S)),C&&(h.firstSelection=Z),{v:Z}}},Z=i;Z>=r;Z--)if((tt=K())!==0&&tt)return tt.v;return-1},e.deriveNextAutoLevel=function(t){var r=this.hls,i=r.maxAutoLevel,a=r.minAutoLevel;return Math.min(Math.max(t,a),i)},yt(s,[{key:"firstAutoLevel",get:function(){var t=this.hls,r=t.maxAutoLevel,i=t.minAutoLevel,a=this.getBwEstimate(),o=this.hls.config.maxStarvationDelay,l=this.findBestLevel(a,i,r,0,o,1,1);if(l>-1)return l;var u=this.hls.firstLevel,d=Math.min(Math.max(u,i),r);return this.warn("Could not find best starting auto level. Defaulting to first in playlist "+u+" clamped to "+d),d}},{key:"forcedAutoLevel",get:function(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}},{key:"nextAutoLevel",get:function(){var t=this.forcedAutoLevel,r=this.bwEstimator.canEstimate(),i=this.lastLoadedFragLevel>-1;if(!(t===-1||r&&i&&this.nextAutoLevelKey!==this.getAutoLevelKey()))return t;var a=r&&i?this.getNextABRAutoLevel():this.firstAutoLevel;if(t!==-1){var o=this.hls.levels;if(o.length>Math.max(t,a)&&o[t].loadError<=o[a].loadError)return t}return this._nextAutoLevel=a,this.nextAutoLevelKey=this.getAutoLevelKey(),a},set:function(t){var r=this.deriveNextAutoLevel(t);this._nextAutoLevel!==r&&(this.nextAutoLevelKey="",this._nextAutoLevel=r)}}])}(Xt),Bn=function(){function n(e){this.tracks=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.tracks=e}var s=n.prototype;return s.destroy=function(){this.tracks=this.queues=null},s.append=function(e,t,r){if(this.queues!==null&&this.tracks!==null){var i=this.queues[t];i.push(e),i.length!==1||r||this.executeNext(t)}},s.appendBlocker=function(e){var t=this;return new Promise(function(r){var i={label:"async-blocker",execute:r,onStart:function(){},onComplete:function(){},onError:function(){}};t.append(i,e)})},s.prependBlocker=function(e){var t=this;return new Promise(function(r){if(t.queues){var i={label:"async-blocker-prepend",execute:r,onStart:function(){},onComplete:function(){},onError:function(){}};t.queues[e].unshift(i)}})},s.removeBlockers=function(){this.queues!==null&&[this.queues.video,this.queues.audio,this.queues.audiovideo].forEach(function(e){var t,r=(t=e[0])==null?void 0:t.label;r!=="async-blocker"&&r!=="async-blocker-prepend"||(e[0].execute(),e.splice(0,1))})},s.unblockAudio=function(e){this.queues!==null&&this.queues.audio[0]===e&&this.shiftAndExecuteNext("audio")},s.executeNext=function(e){if(this.queues!==null&&this.tracks!==null){var t=this.queues[e];if(t.length){var r=t[0];try{r.execute()}catch(o){var i;if(r.onError(o),this.queues===null||this.tracks===null)return;var a=(i=this.tracks[e])==null?void 0:i.buffer;a!=null&&a.updating||this.shiftAndExecuteNext(e)}}}},s.shiftAndExecuteNext=function(e){this.queues!==null&&(this.queues[e].shift(),this.executeNext(e))},s.current=function(e){var t;return((t=this.queues)==null?void 0:t[e][0])||null},s.toString=function(){var e=this.queues,t=this.tracks;return e===null||t===null?"<destroyed>":`
12
+ `+this.list("video")+`
13
+ `+this.list("audio")+`
14
+ `+this.list("audiovideo")+"}"},s.list=function(e){var t,r;return(t=this.queues)!=null&&t[e]||(r=this.tracks)!=null&&r[e]?e+": ("+this.listSbInfo(e)+") "+this.listOps(e):""},s.listSbInfo=function(e){var t,r=(t=this.tracks)==null?void 0:t[e],i=r?.buffer;return i?"SourceBuffer"+(i.updating?" updating":"")+(r.ended?" ended":"")+(r.ending?" ending":""):"none"},s.listOps=function(e){var t;return((t=this.queues)==null?void 0:t[e].map(function(r){return r.label}).join(", "))||""},n}(),Bi=function(n,s){for(var e=0,t=n.length-1,r=null,i=null;e<=t;){var a=s(i=n[r=(e+t)/2|0]);if(a>0)e=r+1;else{if(!(a<0))return i;t=r-1}}return null};function Dr(n,s,e,t,r){e===void 0&&(e=0),t===void 0&&(t=0),r===void 0&&(r=.005);var i=null;if(n){i=s[1+n.sn-s[0].sn]||null;var a=n.endDTS-e;a>0&&a<15e-7&&(e+=15e-7),i&&n.level!==i.level&&i.end<=n.end&&(i=s[2+n.sn-s[0].sn]||null)}else e===0&&s[0].start===0&&(i=s[0]);if(i&&((!n||n.level===i.level)&&Ui(e,t,i)===0||function(l,u,d){if(u&&u.start===0&&u.level<l.level&&(u.endPTS||0)>0){var h=u.tagList.reduce(function(c,f){return f[0]==="INF"&&(c+=parseFloat(f[1])),c},d);return l.start<=h}return!1}(i,n,Math.min(r,t))))return i;var o=Bi(s,Ui.bind(null,e,t));return!o||o===n&&i?i:o}function Ui(n,s,e){if(n===void 0&&(n=0),s===void 0&&(s=0),e.start<=n&&e.start+e.duration>n)return 0;var t=Math.min(s,e.duration+(e.deltaPTS?e.deltaPTS:0));return e.start+e.duration-t<=n?1:e.start-t>n&&e.start?-1:0}function Un(n,s,e){var t=1e3*Math.min(s,e.duration+(e.deltaPTS?e.deltaPTS:0));return(e.endProgramDateTime||0)-t>n}function Xe(n){switch(n.details){case I.FRAG_LOAD_TIMEOUT:case I.KEY_LOAD_TIMEOUT:case I.LEVEL_LOAD_TIMEOUT:case I.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function Gi(n){return n.details.startsWith("key")}function Vi(n){return Gi(n)&&!!n.frag&&!n.frag.decryptdata}function Hi(n,s){var e=Xe(s);return n.default[(e?"timeout":"error")+"Retry"]}function _r(n,s){var e=n.backoff==="linear"?1:Math.pow(2,s);return Math.min(e*n.retryDelayMs,n.maxRetryDelayMs)}function Ki(n){return wt(wt({},n),{errorRetry:null,timeoutRetry:null})}function Qe(n,s,e,t){if(!n)return!1;var r=t?.code,i=s<n.maxNumRetry&&(function(a){return Ir(a)||!!a&&(a<400||a>499)}(r)||!!e);return n.shouldRetry?n.shouldRetry(n,s,e,t,i):i}function Ir(n){return n===0&&navigator.onLine===!1}var Yi=0,Ht=2,Gn=3,$e=5,we=0,Ze=1,Wi=2,ji=4,Vn=function(n){function s(t){var r;return(r=n.call(this,"error-controller",t.logger)||this).hls=void 0,r.playlistError=0,r.hls=t,r.registerListeners(),r}ct(s,n);var e=s.prototype;return e.registerListeners=function(){var t=this.hls;t.on(E.ERROR,this.onError,this),t.on(E.MANIFEST_LOADING,this.onManifestLoading,this),t.on(E.LEVEL_UPDATED,this.onLevelUpdated,this)},e.unregisterListeners=function(){var t=this.hls;t&&(t.off(E.ERROR,this.onError,this),t.off(E.ERROR,this.onErrorOut,this),t.off(E.MANIFEST_LOADING,this.onManifestLoading,this),t.off(E.LEVEL_UPDATED,this.onLevelUpdated,this))},e.destroy=function(){this.unregisterListeners(),this.hls=null},e.startLoad=function(t){},e.stopLoad=function(){this.playlistError=0},e.getVariantLevelIndex=function(t){return t?.type===J?t.level:this.getVariantIndex()},e.getVariantIndex=function(){var t,r=this.hls,i=r.currentLevel;return(t=r.loadLevelObj)!=null&&t.details||i===-1?r.loadLevel:i},e.variantHasKey=function(t,r){if(t){var i;if((i=t.details)!=null&&i.hasKey(r))return!0;var a=t.audioGroups;if(a)return this.hls.allAudioTracks.filter(function(o){return a.indexOf(o.groupId)>=0}).some(function(o){var l;return(l=o.details)==null?void 0:l.hasKey(r)})}return!1},e.onManifestLoading=function(){this.playlistError=0},e.onLevelUpdated=function(){this.playlistError=0},e.onError=function(t,r){var i;if(!r.fatal){var a=this.hls,o=r.context;switch(r.details){case I.FRAG_LOAD_ERROR:case I.FRAG_LOAD_TIMEOUT:case I.KEY_LOAD_ERROR:case I.KEY_LOAD_TIMEOUT:return void(r.errorAction=this.getFragRetryOrSwitchAction(r));case I.FRAG_PARSING_ERROR:if((i=r.frag)!=null&&i.gap)return void(r.errorAction=xe());case I.FRAG_GAP:case I.FRAG_DECRYPT_ERROR:return r.errorAction=this.getFragRetryOrSwitchAction(r),void(r.errorAction.action=Ht);case I.LEVEL_EMPTY_ERROR:case I.LEVEL_PARSING_ERROR:var l,u=r.parent===J?r.level:a.loadLevel;return void(r.details===I.LEVEL_EMPTY_ERROR&&(l=r.context)!=null&&(l=l.levelDetails)!=null&&l.live?r.errorAction=this.getPlaylistRetryOrSwitchAction(r,u):(r.levelRetry=!1,r.errorAction=this.getLevelSwitchAction(r,u)));case I.LEVEL_LOAD_ERROR:case I.LEVEL_LOAD_TIMEOUT:return void(typeof o?.level=="number"&&(r.errorAction=this.getPlaylistRetryOrSwitchAction(r,o.level)));case I.AUDIO_TRACK_LOAD_ERROR:case I.AUDIO_TRACK_LOAD_TIMEOUT:case I.SUBTITLE_LOAD_ERROR:case I.SUBTITLE_TRACK_LOAD_TIMEOUT:if(o){var d=a.loadLevelObj;if(d&&(o.type===qt&&d.hasAudioGroup(o.groupId)||o.type===zt&&d.hasSubtitleGroup(o.groupId)))return r.errorAction=this.getPlaylistRetryOrSwitchAction(r,a.loadLevel),r.errorAction.action=Ht,void(r.errorAction.flags=Ze)}return;case I.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:return void(r.errorAction={action:Ht,flags:Wi});case I.KEY_SYSTEM_SESSION_UPDATE_FAILED:case I.KEY_SYSTEM_STATUS_INTERNAL_ERROR:case I.KEY_SYSTEM_NO_SESSION:return void(r.errorAction={action:Ht,flags:ji});case I.BUFFER_ADD_CODEC_ERROR:case I.REMUX_ALLOC_ERROR:case I.BUFFER_APPEND_ERROR:var h;return void(r.errorAction||(r.errorAction=this.getLevelSwitchAction(r,(h=r.level)!=null?h:a.loadLevel)));case I.INTERNAL_EXCEPTION:case I.BUFFER_APPENDING_ERROR:case I.BUFFER_FULL_ERROR:case I.LEVEL_SWITCH_ERROR:case I.BUFFER_STALLED_ERROR:case I.BUFFER_SEEK_OVER_HOLE:case I.BUFFER_NUDGE_ON_STALL:return void(r.errorAction=xe())}r.type===W.KEY_SYSTEM_ERROR&&(r.levelRetry=!1,r.errorAction=xe())}},e.getPlaylistRetryOrSwitchAction=function(t,r){var i=Hi(this.hls.config.playlistLoadPolicy,t),a=this.playlistError++;if(Qe(i,a,Xe(t),t.response))return{action:$e,flags:we,retryConfig:i,retryCount:a};var o=this.getLevelSwitchAction(t,r);return i&&(o.retryConfig=i,o.retryCount=a),o},e.getFragRetryOrSwitchAction=function(t){var r=this.hls,i=this.getVariantLevelIndex(t.frag),a=r.levels[i],o=r.config,l=o.fragLoadPolicy,u=o.keyLoadPolicy,d=Hi(Gi(t)?u:l,t),h=r.levels.reduce(function(f,v){return f+v.fragmentError},0);if(a&&(t.details!==I.FRAG_GAP&&a.fragmentError++,!Vi(t)&&Qe(d,h,Xe(t),t.response)))return{action:$e,flags:we,retryConfig:d,retryCount:h};var c=this.getLevelSwitchAction(t,i);return d&&(c.retryConfig=d,c.retryCount=h),c},e.getLevelSwitchAction=function(t,r){var i=this.hls;r==null&&(r=i.loadLevel);var a=this.hls.levels[r];if(a){var o,l,u=t.details;a.loadError++,u===I.BUFFER_APPEND_ERROR&&a.fragmentError++;var d=-1,h=i.levels,c=i.loadLevel,f=i.minAutoLevel,v=i.maxAutoLevel;i.autoLevelEnabled||i.config.preserveManualLevelOnError||(i.loadLevel=-1);for(var g,m=(o=t.frag)==null?void 0:o.type,p=(m===ge&&u===I.FRAG_PARSING_ERROR||t.sourceBufferName==="audio"&&(u===I.BUFFER_ADD_CODEC_ERROR||u===I.BUFFER_APPEND_ERROR))&&h.some(function(k){var C=k.audioCodec;return a.audioCodec!==C}),y=t.sourceBufferName==="video"&&(u===I.BUFFER_ADD_CODEC_ERROR||u===I.BUFFER_APPEND_ERROR)&&h.some(function(k){var C=k.codecSet,A=k.audioCodec;return a.codecSet!==C&&a.audioCodec===A}),T=(l=t.context)!=null?l:{},S=T.type,b=T.groupId,L=function(){var k=(R+c)%h.length;if(k!==c&&k>=f&&k<=v&&h[k].loadError===0){var C,A,D=h[k];if(u===I.FRAG_GAP&&m===J&&t.frag){var _=h[k].details;if(_){var M=Dr(t.frag,_.fragments,t.frag.start);if(M!=null&&M.gap)return 0}}else if(S===qt&&D.hasAudioGroup(b)||S===zt&&D.hasSubtitleGroup(b)||m===ge&&(C=a.audioGroups)!=null&&C.some(function(O){return D.hasAudioGroup(O)})||m===_e&&(A=a.subtitleGroups)!=null&&A.some(function(O){return D.hasSubtitleGroup(O)})||p&&a.audioCodec===D.audioCodec||y&&a.codecSet===D.codecSet||!p&&a.codecSet!==D.codecSet)return 0;return d=k,1}},R=h.length;R--&&((g=L())===0||g!==1););if(d>-1&&i.loadLevel!==d)return t.levelRetry=!0,this.playlistError=0,{action:Ht,flags:we,nextAutoLevel:d}}return{action:Ht,flags:Ze}},e.onErrorOut=function(t,r){var i;switch((i=r.errorAction)==null?void 0:i.action){case Yi:break;case Ht:this.sendAlternateToPenaltyBox(r),r.errorAction.resolved||r.details===I.FRAG_GAP?/MediaSource readyState: ended/.test(r.error.message)&&(this.warn('MediaSource ended after "'+r.sourceBufferName+'" sourceBuffer append error. Attempting to recover from media error.'),this.hls.recoverMediaError()):r.fatal=!0}r.fatal&&this.hls.stopLoad()},e.sendAlternateToPenaltyBox=function(t){var r=this.hls,i=t.errorAction;if(i){var a=i.flags,o=i.nextAutoLevel;switch(a){case we:this.switchLevel(t,o);break;case Wi:var l=this.getVariantLevelIndex(t.frag),u=r.levels[l],d=u?.attrs["HDCP-LEVEL"];if(i.hdcpLevel=d,d==="NONE")this.warn("HDCP policy resticted output with HDCP-LEVEL=NONE");else if(d){r.maxHdcpLevel=kr[kr.indexOf(d)-1],i.resolved=!0,this.warn('Restricting playback to HDCP-LEVEL of "'+r.maxHdcpLevel+'" or lower');break}case ji:var h=t.decryptdata;if(h){for(var c=this.hls.levels,f=c.length,v=f;v--;){var g,m;this.variantHasKey(c[v],h)&&(this.log("Banned key found in level "+v+" ("+c[v].bitrate+'bps) or audio group "'+((g=c[v].audioGroups)==null?void 0:g.join(","))+'" ('+((m=t.frag)==null?void 0:m.type)+" fragment) "+Ie(h.keyId||[])),c[v].fragmentError++,c[v].loadError++,this.log("Removing level "+v+" with key error ("+t.error+")"),this.hls.removeLevel(v))}var p=t.frag;if(this.hls.levels.length<f)i.resolved=!0;else if(p&&p.type!==J){var y=p.decryptdata;y&&!h.matches(y)&&(i.resolved=!0)}}}i.resolved||this.switchLevel(t,o)}},e.switchLevel=function(t,r){if(r!==void 0&&t.errorAction&&(this.warn("switching to level "+r+" after "+t.details),this.hls.nextAutoLevel=r,t.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel,t.details===I.BUFFER_ADD_CODEC_ERROR&&t.mimeType&&t.sourceBufferName!=="audiovideo"))for(var i=br(t.mimeType),a=this.hls.levels,o=a.length;o--;)a[o][t.sourceBufferName+"Codec"]===i&&(this.log("Removing level "+o+" for "+t.details+' ("'+i+'" not supported)'),this.hls.removeLevel(o))},s}(Xt);function xe(n){var s={action:Yi,flags:we};return n&&(s.resolved=!0),s}var qi={length:0,start:function(){return 0},end:function(){return 0}},et=function(){function n(){}return n.isBuffered=function(s,e){if(s){for(var t=n.getBuffered(s),r=t.length;r--;)if(e>=t.start(r)&&e<=t.end(r))return!0}return!1},n.bufferedRanges=function(s){if(s){var e=n.getBuffered(s);return n.timeRangesToArray(e)}return[]},n.timeRangesToArray=function(s){for(var e=[],t=0;t<s.length;t++)e.push({start:s.start(t),end:s.end(t)});return e},n.bufferInfo=function(s,e,t){if(s){var r=n.bufferedRanges(s);if(r.length)return n.bufferedInfo(r,e,t)}return{len:0,start:e,end:e,bufferedIndex:-1}},n.bufferedInfo=function(s,e,t){e=Math.max(0,e),s.length>1&&s.sort(function(m,p){return m.start-p.start||p.end-m.end});var r=-1,i=[];if(t)for(var a=0;a<s.length;a++){e>=s[a].start&&e<=s[a].end&&(r=a);var o=i.length;if(o){var l=i[o-1].end;s[a].start-l<t?s[a].end>l&&(i[o-1].end=s[a].end):i.push(s[a])}else i.push(s[a])}else i=s;for(var u,d=0,h=e,c=e,f=0;f<i.length;f++){var v=i[f].start,g=i[f].end;if(r===-1&&e>=v&&e<=g&&(r=f),e+t>=v&&e<g)h=v,d=(c=g)-e;else if(e+t<v){u=v;break}}return{len:d,start:h||0,end:c||0,nextStart:u,buffered:s,bufferedIndex:r}},n.getBuffered=function(s){try{return s.buffered||qi}catch(e){return nt.log("failed to get media.buffered",e),qi}},n}(),zi=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,Xi="HlsJsTrackRemovedError",Hn=function(n){function s(e){var t;return(t=n.call(this,e)||this).name=Xi,t}return ct(s,n),s}(De(Error)),Kn=function(n){function s(t,r){var i,a;return(i=n.call(this,"buffer-controller",t.logger)||this).hls=void 0,i.fragmentTracker=void 0,i.details=null,i._objectUrl=null,i.operationQueue=null,i.bufferCodecEventsTotal=0,i.media=null,i.mediaSource=null,i.lastMpegAudioChunk=null,i.blockedAudioAppend=null,i.lastVideoAppendEnd=0,i.appendSource=void 0,i.transferData=void 0,i.overrides=void 0,i.appendErrors={audio:0,video:0,audiovideo:0},i.tracks={},i.sourceBuffers=[[null,null],[null,null]],i._onEndStreaming=function(o){var l;i.hls&&((l=i.mediaSource)==null?void 0:l.readyState)==="open"&&i.hls.pauseBuffering()},i._onStartStreaming=function(o){i.hls&&i.hls.resumeBuffering()},i._onMediaSourceOpen=function(o){var l=i,u=l.media,d=l.mediaSource;o&&i.log("Media source opened"),u&&d&&(d.removeEventListener("sourceopen",i._onMediaSourceOpen),u.removeEventListener("emptied",i._onMediaEmptied),i.updateDuration(),i.hls.trigger(E.MEDIA_ATTACHED,{media:u,mediaSource:d}),i.mediaSource!==null&&i.checkPendingTracks())},i._onMediaSourceClose=function(){i.log("Media source closed")},i._onMediaSourceEnded=function(){i.log("Media source ended")},i._onMediaEmptied=function(){var o=i,l=o.mediaSrc,u=o._objectUrl;l!==u&&i.error("Media element src was set while attaching MediaSource ("+u+" > "+l+")")},i.hls=t,i.fragmentTracker=r,i.appendSource=(a=ae(t.config.preferManagedMediaSource),typeof self<"u"&&a===self.ManagedMediaSource),i.initTracks(),i.registerListeners(),i}ct(s,n);var e=s.prototype;return e.hasSourceTypes=function(){return Object.keys(this.tracks).length>0},e.destroy=function(){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},e.registerListeners=function(){var t=this.hls;t.on(E.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(E.MANIFEST_LOADING,this.onManifestLoading,this),t.on(E.MANIFEST_PARSED,this.onManifestParsed,this),t.on(E.BUFFER_RESET,this.onBufferReset,this),t.on(E.BUFFER_APPENDING,this.onBufferAppending,this),t.on(E.BUFFER_CODECS,this.onBufferCodecs,this),t.on(E.BUFFER_EOS,this.onBufferEos,this),t.on(E.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(E.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(E.FRAG_PARSED,this.onFragParsed,this),t.on(E.FRAG_CHANGED,this.onFragChanged,this),t.on(E.ERROR,this.onError,this)},e.unregisterListeners=function(){var t=this.hls;t.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(E.MANIFEST_LOADING,this.onManifestLoading,this),t.off(E.MANIFEST_PARSED,this.onManifestParsed,this),t.off(E.BUFFER_RESET,this.onBufferReset,this),t.off(E.BUFFER_APPENDING,this.onBufferAppending,this),t.off(E.BUFFER_CODECS,this.onBufferCodecs,this),t.off(E.BUFFER_EOS,this.onBufferEos,this),t.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(E.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(E.FRAG_PARSED,this.onFragParsed,this),t.off(E.FRAG_CHANGED,this.onFragChanged,this),t.off(E.ERROR,this.onError,this)},e.transferMedia=function(){var t=this,r=this.media,i=this.mediaSource;if(!r)return null;var a={};if(this.operationQueue){var o=this.isUpdating();o||this.operationQueue.removeBlockers();var l=this.isQueued();(o||l)&&this.warn("Transfering MediaSource with"+(l?" operations in queue":"")+(o?" updating SourceBuffer(s)":"")+" "+this.operationQueue),this.operationQueue.destroy()}var u=this.transferData;return!this.sourceBufferCount&&u&&u.mediaSource===i?Et(a,u.tracks):this.sourceBuffers.forEach(function(d){var h=d[0];h&&(a[h]=Et({},t.tracks[h]),t.removeBuffer(h)),d[0]=d[1]=null}),{media:r,mediaSource:i,tracks:a}},e.initTracks=function(){this.sourceBuffers=[[null,null],[null,null]],this.tracks={},this.resetQueue(),this.resetAppendErrors(),this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.lastVideoAppendEnd=0},e.onManifestLoading=function(){this.bufferCodecEventsTotal=0,this.details=null},e.onManifestParsed=function(t,r){var i,a=2;(r.audio&&!r.video||!r.altAudio)&&(a=1),this.bufferCodecEventsTotal=a,this.log(a+" bufferCodec event(s) expected."),(i=this.transferData)!=null&&i.mediaSource&&this.sourceBufferCount&&a&&this.bufferCreated()},e.onMediaAttaching=function(t,r){var i=this.media=r.media;this.transferData=this.overrides=void 0;var a=ae(this.appendSource);if(a){var o=!!r.mediaSource;(o||r.overrides)&&(this.transferData=r,this.overrides=r.overrides);var l=this.mediaSource=r.mediaSource||new a;if(this.assignMediaSource(l),o)this._objectUrl=i.src,this.attachTransferred();else{var u=this._objectUrl=self.URL.createObjectURL(l);if(this.appendSource)try{i.removeAttribute("src");var d=self.ManagedMediaSource;i.disableRemotePlayback=i.disableRemotePlayback||d&&l instanceof d,Qi(i),function(h,c){var f=self.document.createElement("source");f.type="video/mp4",f.src=c,h.appendChild(f)}(i,u),i.load()}catch{i.src=u}else i.src=u}i.addEventListener("emptied",this._onMediaEmptied)}},e.assignMediaSource=function(t){var r,i;this.log((((r=this.transferData)==null?void 0:r.mediaSource)===t?"transferred":"created")+" media source: "+((i=t.constructor)==null?void 0:i.name)),t.addEventListener("sourceopen",this._onMediaSourceOpen),t.addEventListener("sourceended",this._onMediaSourceEnded),t.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(t.addEventListener("startstreaming",this._onStartStreaming),t.addEventListener("endstreaming",this._onEndStreaming))},e.attachTransferred=function(){var t=this,r=this.media,i=this.transferData;if(i&&r){var a=this.tracks,o=i.tracks,l=o?Object.keys(o):null,u=l?l.length:0,d=function(){Promise.resolve().then(function(){t.media&&t.mediaSourceOpenOrEnded&&t._onMediaSourceOpen()})};if(o&&l&&u){if(!this.tracksReady)return this.hls.config.startFragPrefetch=!0,void this.log("attachTransferred: waiting for SourceBuffer track info");if(this.log("attachTransferred: (bufferCodecEventsTotal "+this.bufferCodecEventsTotal+`)
15
+ required tracks: `+It(a,function(v,g){return v==="initSegment"?void 0:g})+`;
16
+ transfer tracks: `+It(o,function(v,g){return v==="initSegment"?void 0:g})+"}"),!function(v,g){var m=Object.keys(v),p=Object.keys(g),y=m.length,T=p.length;return!y||!T||y===T&&!m.some(function(S){return p.indexOf(S)===-1})}(o,a)){i.mediaSource=null,i.tracks=void 0;var h=r.currentTime,c=this.details,f=Math.max(h,c?.fragments[0].start||0);return f-h>1?void this.log("attachTransferred: waiting for playback to reach new tracks start time "+h+" -> "+f):(this.warn('attachTransferred: resetting MediaSource for incompatible tracks ("'+Object.keys(o)+'"->"'+Object.keys(a)+'") start time: '+f+" currentTime: "+h),this.onMediaDetaching(E.MEDIA_DETACHING,{}),this.onMediaAttaching(E.MEDIA_ATTACHING,i),void(r.currentTime=f))}this.transferData=void 0,l.forEach(function(v){var g=v,m=o[g];if(m){var p=m.buffer;if(p){var y=t.fragmentTracker,T=m.id;if(y.hasFragments(T)||y.hasParts(T)){var S=et.getBuffered(p);y.detectEvictedFragments(g,S,T,null,!0)}var b=Cr(g),L=[g,p];t.sourceBuffers[b]=L,p.updating&&t.operationQueue&&t.operationQueue.prependBlocker(g),t.trackSourceBuffer(g,m)}}}),d(),this.bufferCreated()}else this.log("attachTransferred: MediaSource w/o SourceBuffers"),d()}},e.onMediaDetaching=function(t,r){var i=this,a=!!r.transferMedia;this.transferData=this.overrides=void 0;var o=this.media,l=this.mediaSource,u=this._objectUrl;if(l){if(this.log("media source "+(a?"transferring":"detaching")),a)this.sourceBuffers.forEach(function(f){var v=f[0];v&&i.removeBuffer(v)}),this.resetQueue();else{if(this.mediaSourceOpenOrEnded){var d=l.readyState==="open";try{for(var h=l.sourceBuffers,c=h.length;c--;)d&&h[c].abort(),l.removeSourceBuffer(h[c]);d&&l.endOfStream()}catch(f){this.warn("onMediaDetaching: "+f.message+" while calling endOfStream")}}this.sourceBufferCount&&this.onBufferReset()}l.removeEventListener("sourceopen",this._onMediaSourceOpen),l.removeEventListener("sourceended",this._onMediaSourceEnded),l.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(l.removeEventListener("startstreaming",this._onStartStreaming),l.removeEventListener("endstreaming",this._onEndStreaming)),this.mediaSource=null,this._objectUrl=null}o&&(o.removeEventListener("emptied",this._onMediaEmptied),a||(u&&self.URL.revokeObjectURL(u),this.mediaSrc===u?(o.removeAttribute("src"),this.appendSource&&Qi(o),o.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null),this.hls.trigger(E.MEDIA_DETACHED,r)},e.onBufferReset=function(){var t=this;this.sourceBuffers.forEach(function(r){var i=r[0];i&&t.resetBuffer(i)}),this.initTracks()},e.resetBuffer=function(t){var r,i=(r=this.tracks[t])==null?void 0:r.buffer;if(this.removeBuffer(t),i)try{var a;(a=this.mediaSource)!=null&&a.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(i)}catch(o){this.warn("onBufferReset "+t,o)}delete this.tracks[t]},e.removeBuffer=function(t){this.removeBufferListeners(t),this.sourceBuffers[Cr(t)]=[null,null];var r=this.tracks[t];r&&(r.buffer=void 0)},e.resetQueue=function(){this.operationQueue&&this.operationQueue.destroy(),this.operationQueue=new Bn(this.tracks)},e.onBufferCodecs=function(t,r){var i,a=this,o=this.tracks,l=Object.keys(r);this.log('BUFFER_CODECS: "'+l+'" (current SB count '+this.sourceBufferCount+")");var u="audiovideo"in r&&(o.audio||o.video)||o.audiovideo&&("audio"in r||"video"in r),d=!u&&this.sourceBufferCount&&this.media&&l.some(function(h){return!o[h]});u||d?this.warn('Unsupported transition between "'+Object.keys(o)+'" and "'+l+'" SourceBuffers'):(l.forEach(function(h){var c,f,v=r[h],g=v.id,m=v.codec,p=v.levelCodec,y=v.container,T=v.metadata,S=v.supplemental,b=o[h],L=(c=a.transferData)==null||(c=c.tracks)==null?void 0:c[h],R=L!=null&&L.buffer?L:b,k=R?.pendingCodec||R?.codec,C=R?.levelCodec;b||(b=o[h]={buffer:void 0,listeners:[],codec:m,supplemental:S,container:y,levelCodec:p,metadata:T,id:g});var A=qe(k,C),D=A?.replace(zi,"$1"),_=qe(m,p),M=(f=_)==null?void 0:f.replace(zi,"$1");_&&A&&D!==M&&(h.slice(0,5)==="audio"&&(_=je(_,a.appendSource)),a.log("switching codec "+k+" to "+_),_!==(b.pendingCodec||b.codec)&&(b.pendingCodec=_),b.container=y,a.appendChangeType(h,y,_))}),(this.tracksReady||this.sourceBufferCount)&&(r.tracks=this.sourceBufferTracks),this.sourceBufferCount||(this.bufferCodecEventsTotal>1&&!this.tracks.video&&!r.video&&((i=r.audio)==null?void 0:i.id)==="main"&&(this.log("Main audio-only"),this.bufferCodecEventsTotal=1),this.mediaSourceOpenOrEnded&&this.checkPendingTracks()))},e.appendChangeType=function(t,r,i){var a=this,o=r+";codecs="+i,l={label:"change-type="+o,execute:function(){var u=a.tracks[t];if(u){var d=u.buffer;d!=null&&d.changeType&&(a.log("changing "+t+" sourceBuffer type to "+o),d.changeType(o),u.codec=i,u.container=r)}a.shiftAndExecuteNext(t)},onStart:function(){},onComplete:function(){},onError:function(u){a.warn("Failed to change "+t+" SourceBuffer type",u)}};this.append(l,t,this.isPending(this.tracks[t]))},e.blockAudio=function(t){var r,i=this,a=t.start,o=a+.05*t.duration;if(((r=this.fragmentTracker.getAppendedFrag(a,J))==null?void 0:r.gap)!==!0){var l={label:"block-audio",execute:function(){var u,d=i.tracks.video;(i.lastVideoAppendEnd>o||d!=null&&d.buffer&&et.isBuffered(d.buffer,o)||((u=i.fragmentTracker.getAppendedFrag(o,J))==null?void 0:u.gap)===!0)&&(i.blockedAudioAppend=null,i.shiftAndExecuteNext("audio"))},onStart:function(){},onComplete:function(){},onError:function(u){i.warn("Error executing block-audio operation",u)}};this.blockedAudioAppend={op:l,frag:t},this.append(l,"audio",!0)}},e.unblockAudio=function(){var t=this.blockedAudioAppend,r=this.operationQueue;t&&r&&(this.blockedAudioAppend=null,r.unblockAudio(t.op))},e.onBufferAppending=function(t,r){var i=this,a=this.tracks,o=r.data,l=r.type,u=r.parent,d=r.frag,h=r.part,c=r.chunkMeta,f=r.offset,v=c.buffering[l],g=d.sn,m=d.cc,p=self.performance.now();v.start=p;var y=d.stats.buffering,T=h?h.stats.buffering:null;y.start===0&&(y.start=p),T&&T.start===0&&(T.start=p);var S=a.audio,b=!1;l==="audio"&&S?.container==="audio/mpeg"&&(b=!this.lastMpegAudioChunk||c.id===1||this.lastMpegAudioChunk.sn!==c.sn,this.lastMpegAudioChunk=c);var L=a.video,R=L?.buffer;if(R&&g!=="initSegment"){var k=h||d,C=this.blockedAudioAppend;if(l!=="audio"||u==="main"||this.blockedAudioAppend||L.ending||L.ended){if(l==="video"){var A=k.end;if(C){var D=C.frag.start;(A>D||A<this.lastVideoAppendEnd||et.isBuffered(R,D))&&this.unblockAudio()}this.lastVideoAppendEnd=A}}else{var _=k.start+.05*k.duration,M=R.buffered,O=this.currentOp("video");M.length||O?!O&&!et.isBuffered(R,_)&&this.lastVideoAppendEnd<_&&this.blockAudio(k):this.blockAudio(k)}}var P=(h||d).start,w={label:"append-"+l,execute:function(){var x;v.executeStart=self.performance.now();var N=(x=i.tracks[l])==null?void 0:x.buffer;N&&(b?i.updateTimestampOffset(N,P,.1,l,g,m):f!==void 0&&U(f)&&i.updateTimestampOffset(N,f,1e-6,l,g,m)),i.appendExecutor(o,l)},onStart:function(){},onComplete:function(){var x=self.performance.now();v.executeEnd=v.end=x,y.first===0&&(y.first=x),T&&T.first===0&&(T.first=x);var N={};i.sourceBuffers.forEach(function(G){var B=G[0],V=G[1];B&&(N[B]=et.getBuffered(V))}),i.appendErrors[l]=0,l==="audio"||l==="video"?i.appendErrors.audiovideo=0:(i.appendErrors.audio=0,i.appendErrors.video=0),i.hls.trigger(E.BUFFER_APPENDED,{type:l,frag:d,part:h,chunkMeta:c,parent:d.type,timeRanges:N})},onError:function(x){var N,G={type:W.MEDIA_ERROR,parent:d.type,details:I.BUFFER_APPEND_ERROR,sourceBufferName:l,frag:d,part:h,chunkMeta:c,error:x,err:x,fatal:!1},B=(N=i.media)==null?void 0:N.error;if(x.code===DOMException.QUOTA_EXCEEDED_ERR||x.name=="QuotaExceededError"||"quota"in x)G.details=I.BUFFER_FULL_ERROR;else if(x.code===DOMException.INVALID_STATE_ERR&&i.mediaSourceOpenOrEnded&&!B)G.errorAction=xe(!0);else if(x.name===Xi&&i.sourceBufferCount===0)G.errorAction=xe(!0);else{var V=++i.appendErrors[l];i.warn("Failed "+V+"/"+i.hls.config.appendErrorMaxRetry+' times to append segment in "'+l+'" sourceBuffer ('+(B||"no media error")+")"),(V>=i.hls.config.appendErrorMaxRetry||B)&&(G.fatal=!0)}i.hls.trigger(E.ERROR,G)}};this.log('queuing "'+l+'" append sn: '+g+(h?" p: "+h.index:"")+" of "+(d.type===J?"level":"track")+" "+d.level+" cc: "+m),this.append(w,l,this.isPending(this.tracks[l]))},e.getFlushOp=function(t,r,i){var a=this;return this.log('queuing "'+t+'" remove '+r+"-"+i),{label:"remove",execute:function(){a.removeExecutor(t,r,i)},onStart:function(){},onComplete:function(){a.hls.trigger(E.BUFFER_FLUSHED,{type:t})},onError:function(o){a.warn("Failed to remove "+r+"-"+i+' from "'+t+'" SourceBuffer',o)}}},e.onBufferFlushing=function(t,r){var i=this,a=r.type,o=r.startOffset,l=r.endOffset;a?this.append(this.getFlushOp(a,o,l),a):this.sourceBuffers.forEach(function(u){var d=u[0];d&&i.append(i.getFlushOp(d,o,l),d)})},e.onFragParsed=function(t,r){var i=this,a=r.frag,o=r.part,l=[],u=o?o.elementaryStreams:a.elementaryStreams;u[yr]?l.push("audiovideo"):(u[Ut]&&l.push("audio"),u[Qt]&&l.push("video")),l.length===0&&this.warn("Fragments must have at least one ElementaryStreamType set. type: "+a.type+" level: "+a.level+" sn: "+a.sn),this.blockBuffers(function(){var d=self.performance.now();a.stats.buffering.end=d,o&&(o.stats.buffering.end=d);var h=o?o.stats:a.stats;i.hls.trigger(E.FRAG_BUFFERED,{frag:a,part:o,stats:h,id:a.type})},l).catch(function(d){i.warn("Fragment buffered callback "+d),i.stepOperationQueue(i.sourceBufferTypes)})},e.onFragChanged=function(t,r){this.trimBuffers()},e.onBufferEos=function(t,r){var i,a=this;this.sourceBuffers.forEach(function(l){var u=l[0];if(u){var d=a.tracks[u];r.type&&r.type!==u||(d.ending=!0,d.ended||(d.ended=!0,a.log(u+" buffer reached EOS")))}});var o=((i=this.overrides)==null?void 0:i.endOfStream)!==!1;this.sourceBufferCount>0&&!this.sourceBuffers.some(function(l){var u,d=l[0];return d&&!((u=a.tracks[d])!=null&&u.ended)})?o?(this.log("Queueing EOS"),this.blockUntilOpen(function(){a.tracksEnded();var l=a.mediaSource;l&&l.readyState==="open"?(a.log("Calling mediaSource.endOfStream()"),l.endOfStream(),a.hls.trigger(E.BUFFERED_TO_END,void 0)):l&&a.log("Could not call mediaSource.endOfStream(). mediaSource.readyState: "+l.readyState)})):(this.tracksEnded(),this.hls.trigger(E.BUFFERED_TO_END,void 0)):r.type==="video"&&this.unblockAudio()},e.tracksEnded=function(){var t=this;this.sourceBuffers.forEach(function(r){var i=r[0];if(i!==null){var a=t.tracks[i];a&&(a.ending=!1)}})},e.onLevelUpdated=function(t,r){var i=r.details;i.fragments.length&&(this.details=i,this.updateDuration())},e.updateDuration=function(){var t=this;this.blockUntilOpen(function(){var r=t.getDurationAndRange();r&&t.updateMediaSource(r)})},e.onError=function(t,r){if(r.details===I.BUFFER_APPEND_ERROR&&r.frag){var i,a=(i=r.errorAction)==null?void 0:i.nextAutoLevel;U(a)&&a!==r.frag.level&&this.resetAppendErrors()}},e.resetAppendErrors=function(){this.appendErrors={audio:0,video:0,audiovideo:0}},e.trimBuffers=function(){var t=this.hls,r=this.details,i=this.media;if(i&&r!==null&&this.sourceBufferCount){var a=t.config,o=i.currentTime,l=r.levelTargetDuration,u=r.live&&a.liveBackBufferLength!==null?a.liveBackBufferLength:a.backBufferLength;if(U(u)&&u>=0){var d=Math.max(u,l),h=Math.floor(o/l)*l-d;this.flushBackBuffer(o,l,h)}var c=a.frontBufferFlushThreshold;if(U(c)&&c>0){var f=Math.max(a.maxBufferLength,c),v=Math.max(f,l),g=Math.floor(o/l)*l+v;this.flushFrontBuffer(o,l,g)}}},e.flushBackBuffer=function(t,r,i){var a=this;this.sourceBuffers.forEach(function(o){var l=o[0],u=o[1];if(u){var d=et.getBuffered(u);if(d.length>0&&i>d.start(0)){var h;a.hls.trigger(E.BACK_BUFFER_REACHED,{bufferEnd:i});var c=a.tracks[l];if((h=a.details)!=null&&h.live)a.hls.trigger(E.LIVE_BACK_BUFFER_REACHED,{bufferEnd:i});else if(c!=null&&c.ended)return void a.log("Cannot flush "+l+" back buffer while SourceBuffer is in ended state");a.hls.trigger(E.BUFFER_FLUSHING,{startOffset:0,endOffset:i,type:l})}}})},e.flushFrontBuffer=function(t,r,i){var a=this;this.sourceBuffers.forEach(function(o){var l=o[0],u=o[1];if(u){var d=et.getBuffered(u),h=d.length;if(h<2)return;var c=d.start(h-1),f=d.end(h-1);if(i>c||t>=c&&t<=f)return;a.hls.trigger(E.BUFFER_FLUSHING,{startOffset:c,endOffset:1/0,type:l})}})},e.getDurationAndRange=function(){var t,r=this.details,i=this.mediaSource;if(!r||!this.media||i?.readyState!=="open")return null;var a=r.edge;if(r.live&&this.hls.config.liveDurationInfinity){if(r.fragments.length&&i.setLiveSeekableRange){var o=Math.max(0,r.fragmentStart);return{duration:1/0,start:o,end:Math.max(o,a)}}return{duration:1/0}}var l=(t=this.overrides)==null?void 0:t.duration;if(l)return U(l)?{duration:l}:null;var u=this.media.duration;return a>(U(i.duration)?i.duration:0)&&a>u||!U(u)?{duration:a}:null},e.updateMediaSource=function(t){var r=t.duration,i=t.start,a=t.end,o=this.mediaSource;this.media&&o&&o.readyState==="open"&&(o.duration!==r&&(U(r)&&this.log("Updating MediaSource duration to "+r.toFixed(3)),o.duration=r),i!==void 0&&a!==void 0&&(this.log("MediaSource duration is set to "+o.duration+". Setting seekable range to "+i+"-"+a+"."),o.setLiveSeekableRange(i,a)))},e.checkPendingTracks=function(){var t=this.bufferCodecEventsTotal,r=this.pendingTrackCount,i=this.tracks;if(this.log("checkPendingTracks (pending: "+r+" codec events expected: "+t+") "+It(i)),this.tracksReady){var a,o=(a=this.transferData)==null?void 0:a.tracks;o&&Object.keys(o).length?this.attachTransferred():this.createSourceBuffers()}},e.bufferCreated=function(){var t=this;if(this.sourceBufferCount){var r={};this.sourceBuffers.forEach(function(a){var o=a[0],l=a[1];if(o){var u=t.tracks[o];r[o]={buffer:l,container:u.container,codec:u.codec,supplemental:u.supplemental,levelCodec:u.levelCodec,id:u.id,metadata:u.metadata}}}),this.hls.trigger(E.BUFFER_CREATED,{tracks:r}),this.log("SourceBuffers created. Running queue: "+this.operationQueue),this.sourceBuffers.forEach(function(a){var o=a[0];t.executeNext(o)})}else{var i=new Error("could not create source buffer for media codec(s)");this.hls.trigger(E.ERROR,{type:W.MEDIA_ERROR,details:I.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:i,reason:i.message})}},e.createSourceBuffers=function(){var t=this.tracks,r=this.sourceBuffers,i=this.mediaSource;if(!i)throw new Error("createSourceBuffers called when mediaSource was null");for(var a in t){var o=a,l=t[o];if(this.isPending(l)){var u=this.getTrackCodec(l,o),d=l.container+";codecs="+u;l.codec=u,this.log("creating sourceBuffer("+d+")"+(this.currentOp(o)?" Queued":"")+" "+It(l));try{var h=i.addSourceBuffer(d),c=Cr(o),f=[o,h];r[c]=f,l.buffer=h}catch(g){var v;return this.error("error while trying to add sourceBuffer: "+g.message),this.shiftAndExecuteNext(o),(v=this.operationQueue)==null||v.removeBlockers(),delete this.tracks[o],void this.hls.trigger(E.ERROR,{type:W.MEDIA_ERROR,details:I.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:g,sourceBufferName:o,mimeType:d,parent:l.id})}this.trackSourceBuffer(o,l)}}this.bufferCreated()},e.getTrackCodec=function(t,r){var i=t.supplemental,a=t.codec;i&&(r==="video"||r==="audiovideo")&&Ce(i,"video")&&(a=function(l,u){var d=[];if(l)for(var h=l.split(","),c=0;c<h.length;c++)Lr(h[c],"video")||d.push(h[c]);return u&&d.push(u),d.join(",")}(a,i));var o=qe(a,t.levelCodec);return o?r.slice(0,5)==="audio"?je(o,this.appendSource):o:""},e.trackSourceBuffer=function(t,r){var i=this,a=r.buffer;if(a){var o=this.getTrackCodec(r,t);this.tracks[t]={buffer:a,codec:o,container:r.container,levelCodec:r.levelCodec,supplemental:r.supplemental,metadata:r.metadata,id:r.id,listeners:[]},this.removeBufferListeners(t),this.addBufferListener(t,"updatestart",this.onSBUpdateStart),this.addBufferListener(t,"updateend",this.onSBUpdateEnd),this.addBufferListener(t,"error",this.onSBUpdateError),this.appendSource&&this.addBufferListener(t,"bufferedchange",function(l,u){var d=u.removedRanges;d!=null&&d.length&&i.hls.trigger(E.BUFFER_FLUSHED,{type:l})})}},e.onSBUpdateStart=function(t){var r=this.currentOp(t);r&&r.onStart()},e.onSBUpdateEnd=function(t){var r;if(((r=this.mediaSource)==null?void 0:r.readyState)!=="closed"){var i=this.currentOp(t);i&&(i.onComplete(),this.shiftAndExecuteNext(t))}else this.resetBuffer(t)},e.onSBUpdateError=function(t,r){var i,a=new Error(t+" SourceBuffer error. MediaSource readyState: "+((i=this.mediaSource)==null?void 0:i.readyState));this.error(""+a,r),this.hls.trigger(E.ERROR,{type:W.MEDIA_ERROR,details:I.BUFFER_APPENDING_ERROR,sourceBufferName:t,error:a,fatal:!1});var o=this.currentOp(t);o&&o.onError(a)},e.updateTimestampOffset=function(t,r,i,a,o,l){var u=r-t.timestampOffset;Math.abs(u)>=i&&(this.log("Updating "+a+" SourceBuffer timestampOffset to "+r+" (sn: "+o+" cc: "+l+")"),t.timestampOffset=r)},e.removeExecutor=function(t,r,i){var a=this.media,o=this.mediaSource,l=this.tracks[t],u=l?.buffer;if(!a||!o||!u)return this.warn("Attempting to remove from the "+t+" SourceBuffer, but it does not exist"),void this.shiftAndExecuteNext(t);var d=U(a.duration)?a.duration:1/0,h=U(o.duration)?o.duration:1/0,c=Math.max(0,r),f=Math.min(i,d,h);f>c&&(!l.ending||l.ended)?(l.ended=!1,this.log("Removing ["+c+","+f+"] from the "+t+" SourceBuffer"),u.remove(c,f)):this.shiftAndExecuteNext(t)},e.appendExecutor=function(t,r){var i=this.tracks[r],a=i?.buffer;if(!a)throw new Hn("Attempting to append to the "+r+" SourceBuffer, but it does not exist");i.ending=!1,i.ended=!1,a.appendBuffer(t)},e.blockUntilOpen=function(t){var r=this;if(this.isUpdating()||this.isQueued())this.blockBuffers(t).catch(function(i){r.warn("SourceBuffer blocked callback "+i),r.stepOperationQueue(r.sourceBufferTypes)});else try{t()}catch(i){this.warn("Callback run without blocking "+this.operationQueue+" "+i)}},e.isUpdating=function(){return this.sourceBuffers.some(function(t){var r=t[0],i=t[1];return r&&i.updating})},e.isQueued=function(){var t=this;return this.sourceBuffers.some(function(r){var i=r[0];return i&&!!t.currentOp(i)})},e.isPending=function(t){return!!t&&!t.buffer},e.blockBuffers=function(t,r){var i=this;if(r===void 0&&(r=this.sourceBufferTypes),!r.length)return this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(t);var a=this.operationQueue,o=r.map(function(l){return i.appendBlocker(l)});return r.length>1&&this.blockedAudioAppend&&this.unblockAudio(),Promise.all(o).then(function(l){a===i.operationQueue&&(t(),i.stepOperationQueue(i.sourceBufferTypes))})},e.stepOperationQueue=function(t){var r=this;t.forEach(function(i){var a,o=(a=r.tracks[i])==null?void 0:a.buffer;o&&!o.updating&&r.shiftAndExecuteNext(i)})},e.append=function(t,r,i){this.operationQueue&&this.operationQueue.append(t,r,i)},e.appendBlocker=function(t){if(this.operationQueue)return this.operationQueue.appendBlocker(t)},e.currentOp=function(t){return this.operationQueue?this.operationQueue.current(t):null},e.executeNext=function(t){t&&this.operationQueue&&this.operationQueue.executeNext(t)},e.shiftAndExecuteNext=function(t){this.operationQueue&&this.operationQueue.shiftAndExecuteNext(t)},e.addBufferListener=function(t,r,i){var a=this.tracks[t];if(a){var o=a.buffer;if(o){var l=i.bind(this,t);a.listeners.push({event:r,listener:l}),o.addEventListener(r,l)}}},e.removeBufferListeners=function(t){var r=this.tracks[t];if(r){var i=r.buffer;i&&(r.listeners.forEach(function(a){i.removeEventListener(a.event,a.listener)}),r.listeners.length=0)}},yt(s,[{key:"mediaSourceOpenOrEnded",get:function(){var t,r=(t=this.mediaSource)==null?void 0:t.readyState;return r==="open"||r==="ended"}},{key:"sourceBufferTracks",get:function(){var t=this;return Object.keys(this.tracks).reduce(function(r,i){var a=t.tracks[i];return r[i]={id:a.id,container:a.container,codec:a.codec,levelCodec:a.levelCodec},r},{})}},{key:"bufferedToEnd",get:function(){var t=this;return this.sourceBufferCount>0&&!this.sourceBuffers.some(function(r){var i=r[0];if(i){var a=t.tracks[i];if(a)return!a.ended||a.ending}return!1})}},{key:"tracksReady",get:function(){var t=this.pendingTrackCount;return t>0&&(t>=this.bufferCodecEventsTotal||this.isPending(this.tracks.audiovideo))}},{key:"mediaSrc",get:function(){var t,r,i=((t=this.media)==null||(r=t.querySelector)==null?void 0:r.call(t,"source"))||this.media;return i?.src}},{key:"pendingTrackCount",get:function(){var t=this;return Object.keys(this.tracks).reduce(function(r,i){return r+(t.isPending(t.tracks[i])?1:0)},0)}},{key:"sourceBufferCount",get:function(){return this.sourceBuffers.reduce(function(t,r){return t+(r[0]?1:0)},0)}},{key:"sourceBufferTypes",get:function(){return this.sourceBuffers.map(function(t){return t[0]}).filter(function(t){return!!t})}}])}(Xt);function Qi(n){var s=n.querySelectorAll("source");[].slice.call(s).forEach(function(e){n.removeChild(e)})}function Cr(n){return n==="audio"?1:0}var Yn=function(){function n(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()}var s=n.prototype;return s.setStreamController=function(e){this.streamController=e},s.destroy=function(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},s.registerListeners=function(){var e=this.hls;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)},s.unregisterListener=function(){var e=this.hls;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)},s.onFpsDropLevelCapping=function(e,t){var r=this.hls.levels[t.droppedLevel];this.isLevelAllowed(r)&&this.restrictedLevels.push({bitrate:r.bitrate,height:r.height,width:r.width})},s.onMediaAttaching=function(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()},s.onManifestParsed=function(e,t){var r=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,r.config.capLevelToPlayerSize&&t.video&&this.startCapping()},s.onLevelsUpdated=function(e,t){this.timer&&U(this.autoLevelCapping)&&this.detectPlayerSize()},s.onBufferCodecs=function(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()},s.onMediaDetaching=function(){this.stopCapping(),this.media=null},s.detectPlayerSize=function(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0)return void(this.clientRect=null);var e=this.hls.levels;if(e.length){var t=this.hls,r=this.getMaxLevel(e.length-1);r!==this.autoLevelCapping&&t.logger.log("Setting autoLevelCapping to "+r+": "+e[r].height+"p@"+e[r].bitrate+" for media "+this.mediaWidth+"x"+this.mediaHeight),t.autoLevelCapping=r,t.autoLevelEnabled&&t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}},s.getMaxLevel=function(e){var t=this,r=this.hls.levels;if(!r.length)return-1;var i=r.filter(function(a,o){return t.isLevelAllowed(a)&&o<=e});return this.clientRect=null,n.getMaxLevelByMediaSize(i,this.mediaWidth,this.mediaHeight)},s.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},s.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},s.getDimensions=function(){if(this.clientRect)return this.clientRect;var e=this.media,t={width:0,height:0};if(e){var r=e.getBoundingClientRect();t.width=r.width,t.height=r.height,t.width||t.height||(t.width=r.right-r.left||e.width||0,t.height=r.bottom-r.top||e.height||0)}return this.clientRect=t,t},s.isLevelAllowed=function(e){return!this.restrictedLevels.some(function(t){return e.bitrate===t.bitrate&&e.width===t.width&&e.height===t.height})},n.getMaxLevelByMediaSize=function(e,t,r){if(e==null||!e.length)return-1;for(var i,a,o=e.length-1,l=Math.max(t,r),u=0;u<e.length;u+=1){var d=e[u];if((d.width>=l||d.height>=l)&&(i=d,!(a=e[u+1])||i.width!==a.width||i.height!==a.height)){o=u;break}}return o},yt(n,[{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch{}return Math.min(e,this.hls.config.maxDevicePixelRatio)}}])}(),Wn=/^(\d+)x(\d+)$/,$i=/(.+?)=(".*?"|.*?)(?:,|$)/g,gt=function(){function n(e,t){typeof e=="string"&&(e=n.parseAttrList(e,t)),Et(this,e)}var s=n.prototype;return s.decimalInteger=function(e){var t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t},s.hexadecimalInteger=function(e){if(this[e]){var t=(this[e]||"0x").slice(2);t=(1&t.length?"0":"")+t;for(var r=new Uint8Array(t.length/2),i=0;i<t.length/2;i++)r[i]=parseInt(t.slice(2*i,2*i+2),16);return r}return null},s.hexadecimalIntegerAsNumber=function(e){var t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t},s.decimalFloatingPoint=function(e){return parseFloat(this[e])},s.optionalFloat=function(e,t){var r=this[e];return r?parseFloat(r):t},s.enumeratedString=function(e){return this[e]},s.enumeratedStringList=function(e,t){var r=this[e];return(r?r.split(/[ ,]+/):[]).reduce(function(i,a){return i[a.toLowerCase()]=!0,i},t)},s.bool=function(e){return this[e]==="YES"},s.decimalResolution=function(e){var t=Wn.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}},n.parseAttrList=function(e,t){var r,i={};for($i.lastIndex=0;(r=$i.exec(e))!==null;){var a=r[1].trim(),o=r[2],l=o.indexOf('"')===0&&o.lastIndexOf('"')===o.length-1,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))){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":nt.warn(e+": attribute "+a+" is missing quotes")}}i[a]=o}return i},yt(n,[{key:"clientAttrs",get:function(){return Object.keys(this).filter(function(e){return e.substring(0,2)==="X-"})}}])}();function jn(n){return n==="SCTE35-OUT"||n==="SCTE35-IN"||n==="SCTE35-CMD"}var Zi=function(){return yt(function(n,s,e){var t;if(e===void 0&&(e=0),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=s?.tagAnchor||null,this.tagOrder=(t=s?.tagOrder)!=null?t:e,s){var r=s.attr;for(var i in r)if(Object.prototype.hasOwnProperty.call(n,i)&&n[i]!==r[i]){nt.warn('DATERANGE tag attribute: "'+i+'" does not match for tags with ID: "'+n.ID+'"'),this._badValueForSameId=i;break}n=Et(new gt({}),r,n)}if(this.attr=n,s?(this._startDate=s._startDate,this._cue=s._cue,this._endDate=s._endDate,this._dateAtEnd=s._dateAtEnd):this._startDate=new Date(n["START-DATE"]),"END-DATE"in this.attr){var a=s?.endDate||new Date(this.attr["END-DATE"]);U(a.getTime())&&(this._endDate=a)}},[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"cue",get:function(){var n=this._cue;return n===void 0?this._cue=this.attr.enumeratedStringList(this.attr.CUE?"CUE":"X-CUE",{pre:!1,post:!1,once:!1}):n}},{key:"startTime",get:function(){var n=this.tagAnchor;return n===null||n.programDateTime===null?(nt.warn('Expected tagAnchor Fragment with PDT set for DateRange "'+this.id+'": '+n),NaN):n.start+(this.startDate.getTime()-n.programDateTime)/1e3}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){var n=this._endDate||this._dateAtEnd;if(n)return n;var s=this.duration;return s!==null?this._dateAtEnd=new Date(this._startDate.getTime()+1e3*s):null}},{key:"duration",get:function(){if("DURATION"in this.attr){var n=this.attr.decimalFloatingPoint("DURATION");if(U(n))return n}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}},{key:"endOnNext",get:function(){return this.attr.bool("END-ON-NEXT")}},{key:"isInterstitial",get:function(){return this.class==="com.apple.hls.interstitial"}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&U(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)}}])}(),qn=function(){function n(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}var s=n.prototype;return s.reloaded=function(e){if(!e)return this.advanced=!0,void(this.updated=!0);var t=this.lastPartSn-e.lastPartSn,r=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!r||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||t===0&&r>0,this.updated||this.advanced?this.misses=Math.floor(.6*e.misses):this.misses=e.misses+1},s.hasKey=function(e){return this.encryptedFragments.some(function(t){var r=t.decryptdata;return r||(t.setKeyFormat(e.keyFormat),r=t.decryptdata),!!r&&e.matches(r)})},yt(n,[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&U(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var e=this.driftEndTime-this.driftStartTime;return e>0?1e3*(this.driftEnd-this.driftStart)/e:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){return this.fragments.length?this.fragments[this.fragments.length-1].end:0}},{key:"fragmentStart",get:function(){return this.fragments.length?this.fragments[0].start:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].index:-1}},{key:"maxPartIndex",get:function(){var e=this.partList;if(e){var t=this.lastPartIndex;if(t!==-1){for(var r=e.length;r--;)if(e[r].index>t)return e[r].index;return t}}return 0}},{key:"lastPartSn",get:function(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}},{key:"expired",get:function(){if(this.live&&this.age&&this.misses<3){var e=this.partEnd-this.fragmentStart;return this.age>Math.max(e,this.totalduration)+this.levelTargetDuration}return!1}}])}();function Ji(n,s){return n.length===s.length&&!n.some(function(e,t){return e!==s[t]})}function ta(n,s){return!n&&!s||!(!n||!s)&&Ji(n,s)}var Oe=0,Pr=1;function Fe(n){return n==="AES-128"||n==="AES-256"||n==="AES-256-CTR"}function ea(n){switch(n){case"AES-128":case"AES-256":return Oe;case"AES-256-CTR":return Pr;default:throw new Error("invalid full segment method "+n)}}var ra={},ia=function(){function n(e,t,r,i,a,o){i===void 0&&(i=[1]),a===void 0&&(a=null),this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=e,this.uri=t,this.keyFormat=r,this.keyFormatVersions=i,this.iv=a,this.encrypted=!!e&&e!=="NONE",this.isCommonEncryption=this.encrypted&&!Fe(e),o!=null&&o.startsWith("0x")&&(this.keyId=new Uint8Array(vi(o)))}n.clearKeyUriToKeyIdMap=function(){ra={}},n.setKeyIdForUri=function(e,t){ra[e]=t};var s=n.prototype;return s.matches=function(e){return e.uri===this.uri&&e.method===this.method&&e.encrypted===this.encrypted&&e.keyFormat===this.keyFormat&&Ji(e.keyFormatVersions,this.keyFormatVersions)&&ta(e.iv,this.iv)&&ta(e.keyId,this.keyId)},s.isSupported=function(){if(this.method){if(Fe(this.method)||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES"}return!1},s.getDecryptData=function(e,t){if(!this.encrypted||!this.uri)return null;if(Fe(this.method)){var r=this.iv;return r||(typeof e!="number"&&(nt.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),e=0),r=function(i){for(var a=new Uint8Array(16),o=12;o<16;o++)a[o]=i>>8*(15-o)&255;return a}(e)),new n(this.method,this.uri,"identity",this.keyFormatVersions,r)}return this},n}(),aa=/#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,na=/#EXT-X-MEDIA:(.*)/g,zn=/^#EXT(?:INF|-X-TARGETDURATION):/m,wr=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),Xn=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("|")),Me=function(){function n(){}return n.findGroup=function(s,e){for(var t=0;t<s.length;t++){var r=s[t];if(r.id===e)return r}},n.resolve=function(s,e){return vr.buildAbsoluteURL(e,s,{alwaysNormalize:!0})},n.isMediaPlaylist=function(s){return zn.test(s)},n.parseMasterPlaylist=function(s,e){var t,r={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:!1},i=[];if(aa.lastIndex=0,!s.startsWith("#EXTM3U"))return r.playlistParsingError=new Error("no EXTM3U delimiter"),r;for(;(t=aa.exec(s))!=null;)if(t[1]){var a,o=new gt(t[1],r),l=t[2],u={attrs:o,bitrate:o.decimalInteger("BANDWIDTH")||o.decimalInteger("AVERAGE-BANDWIDTH"),name:o.NAME,url:n.resolve(l,e)},d=o.decimalResolution("RESOLUTION");d&&(u.width=d.width,u.height=d.height),ua(o.CODECS,u);var h=o["SUPPLEMENTAL-CODECS"];h&&(u.supplemental={},ua(h,u.supplemental)),(a=u.unknownCodecs)!=null&&a.length||i.push(u),r.levels.push(u)}else if(t[3]){var c=t[3],f=t[4];switch(c){case"SESSION-DATA":var v=new gt(f,r),g=v["DATA-ID"];g&&(r.sessionData===null&&(r.sessionData={}),r.sessionData[g]=v);break;case"SESSION-KEY":var m=oa(f,e,r);m.encrypted&&m.isSupported()?(r.sessionKeys===null&&(r.sessionKeys=[]),r.sessionKeys.push(m)):nt.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+f+'"');break;case"DEFINE":break;case"CONTENT-STEERING":var p=new gt(f,r);r.contentSteering={uri:n.resolve(p["SERVER-URI"],e),pathwayId:p["PATHWAY-ID"]||"."};break;case"START":r.startTimeOffset=la(f)}}var y=i.length>0&&i.length<r.levels.length;return r.levels=y?i:r.levels,r.levels.length===0&&(r.playlistParsingError=new Error("no levels found in manifest")),r},n.parseMasterPlaylistMedia=function(s,e,t){var r,i={},a=t.levels,o={AUDIO:a.map(function(S){return{id:S.attrs.AUDIO,audioCodec:S.audioCodec}}),SUBTITLES:a.map(function(S){return{id:S.attrs.SUBTITLES,textCodec:S.textCodec}}),"CLOSED-CAPTIONS":[]},l=0;for(na.lastIndex=0;(r=na.exec(s))!==null;){var u=new gt(r[1],t),d=u.TYPE;if(d){var h=o[d],c=i[d]||[];i[d]=c;var f=u.LANGUAGE,v=u["ASSOC-LANGUAGE"],g=u.CHANNELS,m=u.CHARACTERISTICS,p=u["INSTREAM-ID"],y={attrs:u,bitrate:0,id:l++,groupId:u["GROUP-ID"]||"",name:u.NAME||f||"",type:d,default:u.bool("DEFAULT"),autoselect:u.bool("AUTOSELECT"),forced:u.bool("FORCED"),lang:f,url:u.URI?n.resolve(u.URI,e):""};if(v&&(y.assocLang=v),g&&(y.channels=g),m&&(y.characteristics=m),p&&(y.instreamId=p),h!=null&&h.length){var T=n.findGroup(h,y.groupId)||h[0];da(y,T,"audioCodec"),da(y,T,"textCodec")}c.push(y)}}return i},n.parseLevelPlaylist=function(s,e,t,r,i,a){var o,l,u,d,h,c={url:e},f=new qn(e),v=f.fragments,g=[],m=null,p=0,y=0,T=0,S=0,b=0,L=null,R=new Er(r,c),k=-1,C=!1,A=null;if(wr.lastIndex=0,f.m3u8=s,f.hasVariableRefs=!1,((o=wr.exec(s))==null?void 0:o[0])!=="#EXTM3U")return f.playlistParsingError=new Error("Missing format identifier #EXTM3U"),f;for(;(l=wr.exec(s))!==null;){C&&(C=!1,(R=new Er(r,c)).playlistOffset=T,R.setStart(T),R.sn=p,R.cc=S,b&&(R.bitrate=b),R.level=t,m&&(R.initSegment=m,m.rawProgramDateTime&&(R.rawProgramDateTime=m.rawProgramDateTime,m.rawProgramDateTime=null),A&&(R.setByteRange(A),A=null)));var D=l[1];if(D){R.duration=parseFloat(D);var _=(" "+l[2]).slice(1);R.title=_||null,R.tagList.push(_?["INF",D,_]:["INF",D])}else if(l[3]){if(U(R.duration)){R.playlistOffset=T,R.setStart(T),d&&fa(R,d,f),R.sn=p,R.level=t,R.cc=S,v.push(R);var M=(" "+l[3]).slice(1);R.relurl=M,xr(R,L,g),L=R,T+=R.duration,p++,y=0,C=!0}}else{if(!(l=l[0].match(Xn))){nt.warn("No matches on slow regex match for level playlist!");continue}for(u=1;u<l.length&&l[u]===void 0;u++);var O=(" "+l[u]).slice(1),P=(" "+l[u+1]).slice(1),w=l[u+2]?(" "+l[u+2]).slice(1):null;switch(O){case"BYTERANGE":L?R.setByteRange(P,L):R.setByteRange(P);break;case"PROGRAM-DATE-TIME":R.rawProgramDateTime=P,R.tagList.push(["PROGRAM-DATE-TIME",P]),k===-1&&(k=v.length);break;case"PLAYLIST-TYPE":f.type&&$t(f,O,l),f.type=P.toUpperCase();break;case"MEDIA-SEQUENCE":f.startSN!==0?$t(f,O,l):v.length>0&&ca(f,O,l),p=f.startSN=parseInt(P);break;case"SKIP":f.skippedSegments&&$t(f,O,l);var x=new gt(P,f),N=x.decimalInteger("SKIPPED-SEGMENTS");if(U(N)){f.skippedSegments+=N;for(var G=N;G--;)v.push(null);p+=N}var B=x.enumeratedString("RECENTLY-REMOVED-DATERANGES");B&&(f.recentlyRemovedDateranges=(f.recentlyRemovedDateranges||[]).concat(B.split(" ")));break;case"TARGETDURATION":f.targetduration!==0&&$t(f,O,l),f.targetduration=Math.max(parseInt(P),1);break;case"VERSION":f.version!==null&&$t(f,O,l),f.version=parseInt(P);break;case"INDEPENDENT-SEGMENTS":case"DEFINE":break;case"ENDLIST":f.live||$t(f,O,l),f.live=!1;break;case"#":(P||w)&&R.tagList.push(w?[P,w]:[P]);break;case"DISCONTINUITY":S++,R.tagList.push(["DIS"]);break;case"GAP":R.gap=!0,R.tagList.push([O]);break;case"BITRATE":R.tagList.push([O,P]),b=1e3*parseInt(P),U(b)?R.bitrate=b:b=0;break;case"DATERANGE":var V=new gt(P,f),st=new Zi(V,f.dateRanges[V.ID],f.dateRangeTagCount);f.dateRangeTagCount++,st.isValid||f.skippedSegments?f.dateRanges[st.id]=st:nt.warn('Ignoring invalid DATERANGE tag: "'+P+'"'),R.tagList.push(["EXT-X-DATERANGE",P]);break;case"DISCONTINUITY-SEQUENCE":f.startCC!==0?$t(f,O,l):v.length>0&&ca(f,O,l),f.startCC=S=parseInt(P);break;case"KEY":var tt=oa(P,e,f);if(tt.isSupported()){if(tt.method==="NONE"){d=void 0;break}d||(d={});var $=d[tt.keyFormat];$!=null&&$.matches(tt)||($&&(d=Et({},d)),d[tt.keyFormat]=tt)}else nt.warn('[Keys] Ignoring unsupported EXT-X-KEY tag: "'+P+'" (light build)');break;case"START":f.startTimeOffset=la(P);break;case"MAP":var ot=new gt(P,f);if(R.duration){var rt=new Er(r,c);ha(rt,ot,t,d),m=rt,R.initSegment=m,m.rawProgramDateTime&&!R.rawProgramDateTime&&(R.rawProgramDateTime=m.rawProgramDateTime)}else{var K=R.byteRangeEndOffset;if(K){var Z=R.byteRangeStartOffset;A=K-Z+"@"+Z}else A=null;ha(R,ot,t,d),m=R,C=!0}m.cc=S;break;case"SERVER-CONTROL":h&&$t(f,O,l),h=new gt(P),f.canBlockReload=h.bool("CAN-BLOCK-RELOAD"),f.canSkipUntil=h.optionalFloat("CAN-SKIP-UNTIL",0),f.canSkipDateRanges=f.canSkipUntil>0&&h.bool("CAN-SKIP-DATERANGES"),f.partHoldBack=h.optionalFloat("PART-HOLD-BACK",0),f.holdBack=h.optionalFloat("HOLD-BACK",0);break;case"PART-INF":f.partTarget&&$t(f,O,l);var Q=new gt(P);f.partTarget=Q.decimalFloatingPoint("PART-TARGET");break;case"PART":var j=f.partList;j||(j=f.partList=[]);var at=y>0?j[j.length-1]:void 0,dt=y++,it=new gt(P,f),q=new Dn(it,R,c,dt,at);j.push(q),R.duration+=q.duration;break;case"PRELOAD-HINT":var ht=new gt(P,f);f.preloadHint=ht;break;case"RENDITION-REPORT":var mt=new gt(P,f);f.renditionReports=f.renditionReports||[],f.renditionReports.push(mt);break;default:nt.warn("line parsed but not handled: "+l)}}}L&&!L.relurl?(v.pop(),T-=L.duration,f.partList&&(f.fragmentHint=L)):f.partList&&(xr(R,L,g),R.cc=S,f.fragmentHint=R,d&&fa(R,d,f)),f.targetduration||(f.playlistParsingError=new Error("Missing Target Duration"));var Y=v.length,lt=v[0],Pt=v[Y-1];if((T+=f.skippedSegments*f.targetduration)>0&&Y&&Pt){f.averagetargetduration=T/Y;var Rt=Pt.sn;f.endSN=Rt!=="initSegment"?Rt:0,f.live||(Pt.endList=!0),k>0&&(function(At,bt){for(var pt=At[bt],kt=bt;kt--;){var Dt=At[kt];if(!Dt)return;Dt.programDateTime=pt.programDateTime-1e3*Dt.duration,pt=Dt}}(v,k),lt&&g.unshift(lt))}return f.fragmentHint&&(T+=f.fragmentHint.duration),f.totalduration=T,g.length&&f.dateRangeTagCount&&lt&&sa(g,f),f.endCC=S,f},n}();function sa(n,s){var e=n.length;if(!e){if(!s.hasProgramDateTime)return;var t=s.fragments[s.fragments.length-1];n.push(t),e++}for(var r=n[e-1],i=s.live?1/0:s.totalduration,a=Object.keys(s.dateRanges),o=a.length;o--;){var l=s.dateRanges[a[o]],u=l.startDate.getTime();l.tagAnchor=r.ref;for(var d=e;d--;){var h;if(((h=n[d])==null?void 0:h.sn)<s.startSN)break;var c=Qn(s,u,n,d,i);if(c!==-1){l.tagAnchor=s.fragments[c].ref;break}}}}function Qn(n,s,e,t,r){var i=e[t];if(i){var a,o=i.programDateTime;if((s>=o||t===0)&&s<=o+1e3*((((a=e[t+1])==null?void 0:a.start)||r)-i.start)){var l=e[t].sn-n.startSN;if(l<0)return-1;var u=n.fragments;if(u.length>e.length)for(var d=(e[t+1]||u[u.length-1]).sn-n.startSN;d>l;d--){var h=u[d].programDateTime;if(s>=h&&s<h+1e3*u[d].duration)return d}return l}}return-1}function oa(n,s,e){var t,r,i=new gt(n,e),a=(t=i.METHOD)!=null?t:"",o=i.URI,l=i.hexadecimalInteger("IV"),u=i.KEYFORMATVERSIONS,d=(r=i.KEYFORMAT)!=null?r:"identity";o&&i.IV&&!l&&nt.error("Invalid IV: "+i.IV);var h=o?Me.resolve(o,s):"",c=(u||"1").split("/").map(Number).filter(Number.isFinite);return new ia(a,h,d,c,l,i.KEYID)}function la(n){var s=new gt(n).decimalFloatingPoint("TIME-OFFSET");return U(s)?s:null}function ua(n,s){var e=(n||"").split(/[ ,]+/).filter(function(t){return t});["video","audio","text"].forEach(function(t){var r=e.filter(function(i){return Lr(i,t)});r.length&&(s[t+"Codec"]=r.map(function(i){return i.split("/")[0]}).join(","),e=e.filter(function(i){return r.indexOf(i)===-1}))}),s.unknownCodecs=e}function da(n,s,e){var t=s[e];t&&(n[e]=t)}function xr(n,s,e){n.rawProgramDateTime?e.push(n):s!=null&&s.programDateTime&&(n.programDateTime=s.endProgramDateTime)}function ha(n,s,e,t){n.relurl=s.URI,s.BYTERANGE&&n.setByteRange(s.BYTERANGE),n.level=e,n.sn="initSegment",t&&(n.levelkeys=t),n.initSegment=null}function fa(n,s,e){n.levelkeys=s;var t=e.encryptedFragments;t.length&&t[t.length-1].levelkeys===s||!Object.keys(s).some(function(r){return s[r].isCommonEncryption})||t.push(n)}function $t(n,s,e){n.playlistParsingError=new Error("#EXT-X-"+s+" must not appear more than once ("+e[0]+")")}function ca(n,s,e){n.playlistParsingError=new Error("#EXT-X-"+s+" must appear before the first Media Segment ("+e[0]+")")}function Or(n,s){var e=s.startPTS;if(U(e)){var t,r=0;s.sn>n.sn?(r=e-n.start,t=n):(r=n.start-e,t=s),t.duration!==r&&t.setDuration(r)}else s.sn>n.sn?n.cc===s.cc&&n.minEndPTS?s.setStart(n.start+(n.minEndPTS-n.start)):s.setStart(n.start+n.duration):s.setStart(Math.max(n.start-s.duration,0))}function va(n,s,e,t,r,i,a){t-e<=0&&(a.warn("Fragment should have a positive duration",s),t=e+s.duration,i=r+s.duration);var o=e,l=t,u=s.startPTS,d=s.endPTS;if(U(u)){var h=Math.abs(u-e);n&&h>n.totalduration?a.warn("media timestamps and playlist times differ by "+h+"s for level "+s.level+" "+n.url):U(s.deltaPTS)?s.deltaPTS=Math.max(h,s.deltaPTS):s.deltaPTS=h,o=Math.max(e,u),e=Math.min(e,u),r=s.startDTS!==void 0?Math.min(r,s.startDTS):r,l=Math.min(t,d),t=Math.max(t,d),i=s.endDTS!==void 0?Math.max(i,s.endDTS):i}var c=e-s.start;s.start!==0&&s.setStart(e),s.setDuration(t-s.start),s.startPTS=e,s.maxStartPTS=o,s.startDTS=r,s.endPTS=t,s.minEndPTS=l,s.endDTS=i;var f,v=s.sn;if(!n||v<n.startSN||v>n.endSN)return 0;var g=v-n.startSN,m=n.fragments;for(m[g]=s,f=g;f>0;f--)Or(m[f],m[f-1]);for(f=g;f<m.length-1;f++)Or(m[f],m[f+1]);return n.fragmentHint&&Or(m[m.length-1],n.fragmentHint),n.PTSKnown=n.alignedSliding=!0,c}function $n(n,s,e){if(n!==s){for(var t,r=null,i=n.fragments,a=i.length-1;a>=0;a--){var o=i[a].initSegment;if(o){r=o;break}}n.fragmentHint&&delete n.fragmentHint.endPTS,function(p,y,T){for(var S=y.skippedSegments,b=Math.max(p.startSN,y.startSN)-y.startSN,L=(p.fragmentHint?1:0)+(S?y.endSN:Math.min(p.endSN,y.endSN))-y.startSN,R=y.startSN-p.startSN,k=y.fragmentHint?y.fragments.concat(y.fragmentHint):y.fragments,C=p.fragmentHint?p.fragments.concat(p.fragmentHint):p.fragments,A=b;A<=L;A++){var D=C[R+A],_=k[A];if(S&&!_&&D&&(_=y.fragments[A]=D),D&&_){T(D,_,A,k);var M=D.relurl,O=_.relurl;if(M&&Zn(M,O))return void(y.playlistParsingError=ga("media sequence mismatch "+_.sn+":",p,y,0,_));if(D.cc!==_.cc)return void(y.playlistParsingError=ga("discontinuity sequence mismatch ("+D.cc+"!="+_.cc+")",p,y,0,_))}}}(n,s,function(p,y,T,S){if((!s.startCC||s.skippedSegments)&&y.cc!==p.cc){for(var b=p.cc-y.cc,L=T;L<S.length;L++)S[L].cc+=b;s.endCC=S[S.length-1].cc}U(p.startPTS)&&U(p.endPTS)&&(y.setStart(y.startPTS=p.startPTS),y.startDTS=p.startDTS,y.maxStartPTS=p.maxStartPTS,y.endPTS=p.endPTS,y.endDTS=p.endDTS,y.minEndPTS=p.minEndPTS,y.setDuration(p.endPTS-p.startPTS),y.duration&&(t=y),s.PTSKnown=s.alignedSliding=!0),p.hasStreams&&(y.elementaryStreams=p.elementaryStreams),y.loader=p.loader,p.hasStats&&(y.stats=p.stats),p.initSegment&&(y.initSegment=p.initSegment,r=p.initSegment)});var l=s.fragments,u=s.fragmentHint?l.concat(s.fragmentHint):l;if(r&&u.forEach(function(p){var y;!p||p.initSegment&&p.initSegment.relurl!==((y=r)==null?void 0:y.relurl)||(p.initSegment=r)}),s.skippedSegments){if(s.deltaUpdateFailed=l.some(function(p){return!p}),s.deltaUpdateFailed){e.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var d=s.skippedSegments;d--;)l.shift();s.startSN=l[0].sn}else{s.canSkipDateRanges&&(s.dateRanges=function(p,y,T){var S=y.dateRanges,b=y.recentlyRemovedDateranges,L=Et({},p);b&&b.forEach(function(k){delete L[k]});var R=Object.keys(L).length;return R?(Object.keys(S).forEach(function(k){var C=L[k],A=new Zi(S[k].attr,C);A.isValid?(L[k]=A,C||(A.tagOrder+=R)):T.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+It(S[k].attr)+'"')}),L):S}(n.dateRanges,s,e));var h=n.fragments.filter(function(p){return p.rawProgramDateTime});if(n.hasProgramDateTime&&!s.hasProgramDateTime)for(var c=1;c<u.length;c++)u[c].programDateTime===null&&xr(u[c],u[c-1],h);sa(h,s)}s.endCC=l[l.length-1].cc}if(!s.startCC){var f,v=ya(n,s.startSN-1);s.startCC=(f=v?.cc)!=null?f:l[0].cc}(function(p,y,T){if(p&&y)for(var S=0,b=0,L=p.length;b<=L;b++){var R=p[b],k=y[b+S];R&&k&&R.index===k.index&&R.fragment.sn===k.fragment.sn?T(R,k):S--}})(n.partList,s.partList,function(p,y){y.elementaryStreams=p.elementaryStreams,y.stats=p.stats}),t?va(s,t,t.startPTS,t.endPTS,t.startDTS,t.endDTS,e):ma(n,s),l.length&&(s.totalduration=s.edge-l[0].start),s.driftStartTime=n.driftStartTime,s.driftStart=n.driftStart;var g=s.advancedDateTime;if(s.advanced&&g){var m=s.edge;s.driftStart||(s.driftStartTime=g,s.driftStart=m),s.driftEndTime=g,s.driftEnd=m}else s.driftEndTime=n.driftEndTime,s.driftEnd=n.driftEnd,s.advancedDateTime=n.advancedDateTime;s.requestScheduled===-1&&(s.requestScheduled=n.requestScheduled)}}function ga(n,s,e,t,r){return new Error(n+" "+r.url+`
17
+ Playlist starting @`+s.startSN+`
18
+ `+s.m3u8+`
19
+
20
+ Playlist starting @`+e.startSN+`
21
+ `+e.m3u8)}function ma(n,s,e){e===void 0&&(e=!0);var t=s.startSN+s.skippedSegments-n.startSN,r=n.fragments,i=t>=0,a=0;if(i&&t<r.length)a=r[t].start;else if(i&&s.startSN===n.endSN+1)a=n.fragmentEnd;else if(i&&e)a=n.fragmentStart+t*s.levelTargetDuration;else{if(s.skippedSegments||s.fragmentStart!==0)return;a=n.fragmentStart}(function(o,l){if(l){for(var u=o.fragments,d=o.skippedSegments;d<u.length;d++)u[d].addStart(l);o.fragmentHint&&o.fragmentHint.addStart(l)}})(s,a)}function pa(n,s){s===void 0&&(s=1/0);var e=1e3*n.targetduration;if(n.updated){var t=n.fragments;if(t.length&&4*e>s){var r=1e3*t[t.length-1].duration;r<e&&(e=r)}}else e/=2;return Math.round(e)}function ya(n,s,e){if(!n)return null;var t=n.fragments[s-n.startSN];return t||((t=n.fragmentHint)&&t.sn===s?t:s<n.startSN&&e&&e.sn===s?e:null)}function Ea(n,s,e){return n?Ta(n.partList,s,e):null}function Ta(n,s,e){if(n)for(var t=n.length;t--;){var r=n[t];if(r.index===e&&r.fragment.sn===s)return r}return null}function Sa(n){n.forEach(function(s,e){var t;(t=s.details)==null||t.fragments.forEach(function(r){r.level=e,r.initSegment&&(r.initSegment.level=e)})})}function Zn(n,s){return!(n===s||!s)&&La(n)!==La(s)}function La(n){return n.replace(/\?[^?]*$/,"")}var Jn=function(n){function s(t){var r;return(r=n.call(this,"content-steering",t.logger)||this).hls=void 0,r.loader=null,r.uri=null,r.pathwayId=".",r._pathwayPriority=null,r.timeToLoad=300,r.reloadTimer=-1,r.updated=0,r.started=!1,r.enabled=!0,r.levels=null,r.audioTracks=null,r.subtitleTracks=null,r.penalizedPathways={},r.hls=t,r.registerListeners(),r}ct(s,n);var e=s.prototype;return e.registerListeners=function(){var t=this.hls;t.on(E.MANIFEST_LOADING,this.onManifestLoading,this),t.on(E.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(E.MANIFEST_PARSED,this.onManifestParsed,this),t.on(E.ERROR,this.onError,this)},e.unregisterListeners=function(){var t=this.hls;t&&(t.off(E.MANIFEST_LOADING,this.onManifestLoading,this),t.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(E.MANIFEST_PARSED,this.onManifestParsed,this),t.off(E.ERROR,this.onError,this))},e.pathways=function(){return(this.levels||[]).reduce(function(t,r){return t.indexOf(r.pathwayId)===-1&&t.push(r.pathwayId),t},[])},e.startLoad=function(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){var t=1e3*this.timeToLoad-(performance.now()-this.updated);if(t>0)return void this.scheduleRefresh(this.uri,t)}this.loadSteeringManifest(this.uri)}},e.stopLoad=function(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()},e.clearTimeout=function(){this.reloadTimer!==-1&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)},e.destroy=function(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null},e.removeLevel=function(t){var r=this.levels;r&&(this.levels=r.filter(function(i){return i!==t}))},e.onManifestLoading=function(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null},e.onManifestLoaded=function(t,r){var i=r.contentSteering;i!==null&&(this.pathwayId=i.pathwayId,this.uri=i.uri,this.started&&this.startLoad())},e.onManifestParsed=function(t,r){this.audioTracks=r.audioTracks,this.subtitleTracks=r.subtitleTracks},e.onError=function(t,r){var i=r.errorAction;if(i?.action===Ht&&i.flags===Ze){var a=this.levels,o=this._pathwayPriority,l=this.pathwayId;if(r.context){var u=r.context,d=u.groupId,h=u.pathwayId,c=u.type;d&&a?l=this.getPathwayForGroupId(d,c,l):h&&(l=h)}l in this.penalizedPathways||(this.penalizedPathways[l]=performance.now()),!o&&a&&(o=this.pathways()),o&&o.length>1&&(this.updatePathwayPriority(o),i.resolved=this.pathwayId!==l),r.details!==I.BUFFER_APPEND_ERROR||r.fatal?i.resolved||this.warn("Could not resolve "+r.details+' ("'+r.error.message+'") with content-steering for Pathway: '+l+" levels: "+(a&&a.length)+" priorities: "+It(o)+" penalized: "+It(this.penalizedPathways)):i.resolved=!0}},e.filterParsedLevels=function(t){this.levels=t;var r=this.getLevelsForPathway(this.pathwayId);if(r.length===0){var i=t[0].pathwayId;this.log("No levels found in Pathway "+this.pathwayId+'. Setting initial Pathway to "'+i+'"'),r=this.getLevelsForPathway(i),this.pathwayId=i}return r.length!==t.length&&this.log("Found "+r.length+"/"+t.length+' levels in Pathway "'+this.pathwayId+'"'),r},e.getLevelsForPathway=function(t){return this.levels===null?[]:this.levels.filter(function(r){return t===r.pathwayId})},e.updatePathwayPriority=function(t){var r;this._pathwayPriority=t;var i=this.penalizedPathways,a=performance.now();Object.keys(i).forEach(function(c){a-i[c]>3e5&&delete i[c]});for(var o=0;o<t.length;o++){var l=t[o];if(!(l in i)){if(l===this.pathwayId)return;var u=this.hls.nextLoadLevel,d=this.hls.levels[u];if((r=this.getLevelsForPathway(l)).length>0){this.log('Setting Pathway to "'+l+'"'),this.pathwayId=l,Sa(r),this.hls.trigger(E.LEVELS_UPDATED,{levels:r});var h=this.hls.levels[u];d&&h&&this.levels&&(h.attrs["STABLE-VARIANT-ID"]!==d.attrs["STABLE-VARIANT-ID"]&&h.bitrate!==d.bitrate&&this.log("Unstable Pathways change from bitrate "+d.bitrate+" to "+h.bitrate),this.hls.nextLoadLevel=u);break}}}},e.getPathwayForGroupId=function(t,r,i){for(var a=this.getLevelsForPathway(i).concat(this.levels||[]),o=0;o<a.length;o++)if(r===qt&&a[o].hasAudioGroup(t)||r===zt&&a[o].hasSubtitleGroup(t))return a[o].pathwayId;return i},e.clonePathways=function(t){var r=this,i=this.levels;if(i){var a={},o={};t.forEach(function(l){var u=l.ID,d=l["BASE-ID"],h=l["URI-REPLACEMENT"];if(!i.some(function(f){return f.pathwayId===u})){var c=r.getLevelsForPathway(d).map(function(f){var v=new gt(f.attrs);v["PATHWAY-ID"]=u;var g=v.AUDIO&&v.AUDIO+"_clone_"+u,m=v.SUBTITLES&&v.SUBTITLES+"_clone_"+u;g&&(a[v.AUDIO]=g,v.AUDIO=g),m&&(o[v.SUBTITLES]=m,v.SUBTITLES=m);var p=Aa(f.uri,v["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",h),y=new Oi({attrs:v,audioCodec:f.audioCodec,bitrate:f.bitrate,height:f.height,name:f.name,url:p,videoCodec:f.videoCodec,width:f.width});if(f.audioGroups)for(var T=1;T<f.audioGroups.length;T++)y.addGroupId("audio",f.audioGroups[T]+"_clone_"+u);if(f.subtitleGroups)for(var S=1;S<f.subtitleGroups.length;S++)y.addGroupId("text",f.subtitleGroups[S]+"_clone_"+u);return y});i.push.apply(i,c),Ra(r.audioTracks,a,h,u),Ra(r.subtitleTracks,o,h,u)}})}},e.loadSteeringManifest=function(t){var r,i=this,a=this.hls.config,o=a.loader;this.loader&&this.loader.destroy(),this.loader=new o(a);try{r=new self.URL(t)}catch{return this.enabled=!1,void this.log("Failed to parse Steering Manifest URI: "+t)}if(r.protocol!=="data:"){var l=0|(this.hls.bandwidthEstimate||a.abrEwmaDefaultEstimate);r.searchParams.set("_HLS_pathway",this.pathwayId),r.searchParams.set("_HLS_throughput",""+l)}var u={responseType:"json",url:r.href},d=a.steeringManifestLoadPolicy.default,h=d.errorRetry||d.timeoutRetry||{},c={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:h.maxNumRetry||0,retryDelay:h.retryDelayMs||0,maxRetryDelay:h.maxRetryDelayMs||0},f={onSuccess:function(v,g,m,p){i.log('Loaded steering manifest: "'+r+'"');var y=v.data;if(y?.VERSION===1){i.updated=performance.now(),i.timeToLoad=y.TTL;var T=y["RELOAD-URI"],S=y["PATHWAY-CLONES"],b=y["PATHWAY-PRIORITY"];if(T)try{i.uri=new self.URL(T,r).href}catch{return i.enabled=!1,void i.log("Failed to parse Steering Manifest RELOAD-URI: "+T)}i.scheduleRefresh(i.uri||m.url),S&&i.clonePathways(S);var L={steeringManifest:y,url:r.toString()};i.hls.trigger(E.STEERING_MANIFEST_LOADED,L),b&&i.updatePathwayPriority(b)}else i.log("Steering VERSION "+y.VERSION+" not supported!")},onError:function(v,g,m,p){if(i.log("Error loading steering manifest: "+v.code+" "+v.text+" ("+g.url+")"),i.stopLoad(),v.code===410)return i.enabled=!1,void i.log("Steering manifest "+g.url+" no longer available");var y=1e3*i.timeToLoad;if(v.code!==429)i.scheduleRefresh(i.uri||g.url,y);else{var T=i.loader;if(typeof T?.getResponseHeader=="function"){var S=T.getResponseHeader("Retry-After");S&&(y=1e3*parseFloat(S))}i.log("Steering manifest "+g.url+" rate limited")}},onTimeout:function(v,g,m){i.log("Timeout loading steering manifest ("+g.url+")"),i.scheduleRefresh(i.uri||g.url)}};this.log("Requesting steering manifest: "+r),this.loader.load(u,c,f)},e.scheduleRefresh=function(t,r){var i=this;r===void 0&&(r=1e3*this.timeToLoad),this.clearTimeout(),this.reloadTimer=self.setTimeout(function(){var a,o=(a=i.hls)==null?void 0:a.media;!o||o.ended?i.scheduleRefresh(t,1e3*i.timeToLoad):i.loadSteeringManifest(t)},r)},yt(s,[{key:"pathwayPriority",get:function(){return this._pathwayPriority},set:function(t){this.updatePathwayPriority(t)}}])}(Xt);function Ra(n,s,e,t){n&&Object.keys(s).forEach(function(r){var i=n.filter(function(a){return a.groupId===r}).map(function(a){var o=Et({},a);return o.details=void 0,o.attrs=new gt(o.attrs),o.url=o.attrs.URI=Aa(a.url,a.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",e),o.groupId=o.attrs["GROUP-ID"]=s[r],o.attrs["PATHWAY-ID"]=t,o});n.push.apply(n,i)})}function Aa(n,s,e,t){var r,i=t.HOST,a=t.PARAMS,o=t[e];s&&(r=o?.[s])&&(n=r);var l=new self.URL(n);return i&&!r&&(l.host=i),a&&Object.keys(a).sort().forEach(function(u){u&&l.searchParams.set(u,a[u])}),l.href}var ts=function(){function n(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()}var s=n.prototype;return s.setStreamController=function(e){this.streamController=e},s.registerListeners=function(){this.hls.on(E.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(E.MEDIA_DETACHING,this.onMediaDetaching,this)},s.unregisterListeners=function(){this.hls.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(E.MEDIA_DETACHING,this.onMediaDetaching,this)},s.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},s.onMediaAttaching=function(e,t){var r=this.hls.config;if(r.capLevelOnFPSDrop){var i=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=i,i&&typeof i.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}},s.onMediaDetaching=function(){this.media=null},s.checkFPS=function(e,t,r){var i=performance.now();if(t){if(this.lastTime){var a=i-this.lastTime,o=r-this.lastDroppedFrames,l=t-this.lastDecodedFrames,u=1e3*o/a,d=this.hls;if(d.trigger(E.FPS_DROP,{currentDropped:o,currentDecoded:l,totalDroppedFrames:r}),u>0&&o>d.config.fpsDroppedMonitoringThreshold*l){var h=d.currentLevel;d.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+h),h>0&&(d.autoLevelCapping===-1||d.autoLevelCapping>=h)&&(h-=1,d.trigger(E.FPS_DROP_LEVEL_CAPPING,{level:h,droppedLevel:d.currentLevel}),d.autoLevelCapping=h,this.streamController.nextLevelSwitch())}}this.lastTime=i,this.lastDroppedFrames=r,this.lastDecodedFrames=t}},s.checkFPSInterval=function(){var e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){var t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)},n}(),es=function(){function n(){this.chunks=[],this.dataLength=0}var s=n.prototype;return s.push=function(e){this.chunks.push(e),this.dataLength+=e.length},s.flush=function(){var e,t=this.chunks,r=this.dataLength;return t.length?(e=t.length===1?t[0]:function(i,a){for(var o=new Uint8Array(a),l=0,u=0;u<i.length;u++){var d=i[u];o.set(d,l),l+=d.length}return o}(t,r),this.reset(),e):new Uint8Array(0)},s.reset=function(){this.chunks.length=0,this.dataLength=0},n}();function ba(n,s){return s+10<=n.length&&n[s]===51&&n[s+1]===68&&n[s+2]===73&&n[s+3]<255&&n[s+4]<255&&n[s+6]<128&&n[s+7]<128&&n[s+8]<128&&n[s+9]<128}function Fr(n,s){return s+10<=n.length&&n[s]===73&&n[s+1]===68&&n[s+2]===51&&n[s+3]<255&&n[s+4]<255&&n[s+6]<128&&n[s+7]<128&&n[s+8]<128&&n[s+9]<128}function Je(n,s){var e=0;return e=(127&n[s])<<21,e|=(127&n[s+1])<<14,e|=(127&n[s+2])<<7,e|=127&n[s+3]}function tr(n,s){for(var e=s,t=0;Fr(n,s);)t+=10,t+=Je(n,s+6),ba(n,s+10)&&(t+=10),s+=t;if(t>0)return n.subarray(e,e+t)}function ka(n,s){return n[s]===255&&(246&n[s+1])==240}function Da(n,s){return 1&n[s+1]?7:9}function Mr(n,s){return(3&n[s+3])<<11|n[s+4]<<3|(224&n[s+5])>>>5}function er(n,s){return s+1<n.length&&ka(n,s)}function rs(n,s){if(er(n,s)){var e=Da(n,s);if(s+e>=n.length)return!1;var t=Mr(n,s);if(t<=e)return!1;var r=s+t;return r===n.length||er(n,r)}return!1}function _a(n,s,e,t,r){if(!n.samplerate){var i=function(a,o,l,u){var d=o[l+2],h=d>>2&15;if(!(h>12)){var c=1+(d>>6&3),f=o[l+3]>>6&3|(1&d)<<2,v="mp4a.40."+c,g=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][h],m=h;c!==5&&c!==29||(m-=3);var p=[c<<3|(14&m)>>1,(1&m)<<7|f<<3];return nt.log("manifest codec:"+u+", parsed codec:"+v+", channels:"+f+", rate:"+g+" (ADTS object type:"+c+" sampling index:"+h+")"),{config:p,samplerate:g,channelCount:f,codec:v,parsedCodec:v,manifestCodec:u}}var y=new Error("invalid ADTS sampling index:"+h);a.emit(E.ERROR,E.ERROR,{type:W.MEDIA_ERROR,details:I.FRAG_PARSING_ERROR,fatal:!0,error:y,reason:y.message})}(s,e,t,r);if(!i)return;Et(n,i)}}function Ia(n){return 9216e4/n}function Ca(n,s,e,t,r){var i,a=t+r*Ia(n.samplerate),o=function(v,g){var m=Da(v,g);if(g+m<=v.length){var p=Mr(v,g)-m;if(p>0)return{headerLength:m,frameLength:p}}}(s,e);if(o){var l=o.frameLength,u=o.headerLength,d=u+l,h=Math.max(0,e+d-s.length);h?(i=new Uint8Array(d-u)).set(s.subarray(e+u,s.length),0):i=s.subarray(e+u,e+d);var c={unit:i,pts:a};return h||n.samples.push(c),{sample:c,length:d,missing:h}}var f=s.length-e;return(i=new Uint8Array(f)).set(s.subarray(e,s.length),0),{sample:{unit:i,pts:a},length:f,missing:-1}}function is(n,s){return Fr(n,s)&&Je(n,s+6)+10<=n.length-s}function Nr(n,s,e){return s===void 0&&(s=0),e===void 0&&(e=1/0),function(t,r,i,a){var o=function(g){return g instanceof ArrayBuffer?g:g.buffer}(t),l=1;"BYTES_PER_ELEMENT"in a&&(l=a.BYTES_PER_ELEMENT);var u,d=(u=t)&&u.buffer instanceof ArrayBuffer&&u.byteLength!==void 0&&u.byteOffset!==void 0?t.byteOffset:0,h=(d+t.byteLength)/l,c=(d+r)/l,f=Math.floor(Math.max(0,Math.min(c,h))),v=Math.floor(Math.min(f+Math.max(i,0),h));return new a(o,f,v-f)}(n,s,e,Uint8Array)}function as(n){var s={key:n.type,description:"",data:"",mimeType:null,pictureType:null};if(!(n.size<2))if(n.data[0]===3){var e=n.data.subarray(1).indexOf(0);if(e!==-1){var t=Ft(Nr(n.data,1,e)),r=n.data[2+e],i=n.data.subarray(3+e).indexOf(0);if(i!==-1){var a,o=Ft(Nr(n.data,3+e,i));return a=t==="-->"?Ft(Nr(n.data,4+e+i)):function(l){return l instanceof ArrayBuffer?l:l.byteOffset==0&&l.byteLength==l.buffer.byteLength?l.buffer:new Uint8Array(l).buffer}(n.data.subarray(4+e+i)),s.mimeType=t,s.pictureType=r,s.description=o,s.data=a,s}}}else console.log("Ignore frame with unrecognized character encoding")}function ns(n){return n.type==="PRIV"?function(s){if(!(s.size<2)){var e=Ft(s.data,!0),t=new Uint8Array(s.data.subarray(e.length+1));return{key:s.type,info:e,data:t.buffer}}}(n):n.type[0]==="W"?function(s){if(s.type==="WXXX"){if(s.size<2)return;var e=1,t=Ft(s.data.subarray(e),!0);e+=t.length+1;var r=Ft(s.data.subarray(e));return{key:s.type,info:t,data:r}}var i=Ft(s.data);return{key:s.type,info:"",data:i}}(n):n.type==="APIC"?as(n):function(s){if(!(s.size<2)){if(s.type==="TXXX"){var e=1,t=Ft(s.data.subarray(e),!0);e+=t.length+1;var r=Ft(s.data.subarray(e));return{key:s.type,info:t,data:r}}var i=Ft(s.data.subarray(1));return{key:s.type,info:"",data:i}}}(n)}function ss(n){var s=String.fromCharCode(n[0],n[1],n[2],n[3]),e=Je(n,4);return{type:s,size:e,data:n.subarray(10,10+e)}}var rr=10,os=10;function Pa(n){for(var s=0,e=[];Fr(n,s);){var t=Je(n,s+6);n[s+5]>>6&1&&(s+=rr);for(var r=(s+=rr)+t;s+os<r;){var i=ss(n.subarray(s)),a=ns(i);a&&e.push(a),s+=i.size+rr}ba(n,s)&&(s+=rr)}return e}function wa(n){return n&&n.key==="PRIV"&&n.info==="com.apple.streaming.transportStreamTimestamp"}function ls(n){if(n.data.byteLength===8){var s=new Uint8Array(n.data),e=1&s[3],t=(s[4]<<23)+(s[5]<<15)+(s[6]<<7)+s[7];return t/=45,e&&(t+=4772185884e-2),Math.round(t)}}function xa(n){for(var s=Pa(n),e=0;e<s.length;e++){var t=s[e];if(wa(t))return ls(t)}}var Ct=function(n){return n.audioId3="org.id3",n.dateRange="com.apple.quicktime.HLS",n.emsg="https://aomedia.org/emsg/ID3",n.misbklv="urn:misb:KLV:bin:1910.1",n}({});function Kt(n,s){return n===void 0&&(n=""),s===void 0&&(s=9e4),{type:n,id:-1,pid:-1,inputTimeScale:s,sequenceNumber:-1,samples:[],dropped:0}}var Oa=function(){function n(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}var s=n.prototype;return s.resetInitSegment=function(e,t,r,i){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},s.resetTimeStamp=function(e){this.initPTS=e,this.resetContiguity()},s.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},s.canParse=function(e,t){return!1},s.appendFrame=function(e,t,r){},s.demux=function(e,t){this.cachedData&&(e=Nt(this.cachedData,e),this.cachedData=null);var r,i=tr(e,0),a=i?i.length:0,o=this._audioTrack,l=this._id3Track,u=i?xa(i):void 0,d=e.length;for((this.basePTS===null||this.frameIndex===0&&U(u))&&(this.basePTS=us(u,t,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),i&&i.length>0&&l.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:Ct.audioId3,duration:Number.POSITIVE_INFINITY});a<d;){if(this.canParse(e,a)){var h=this.appendFrame(o,e,a);h?(this.frameIndex++,this.lastPTS=h.sample.pts,r=a+=h.length):a=d}else is(e,a)?(i=tr(e,a),l.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:Ct.audioId3,duration:Number.POSITIVE_INFINITY}),r=a+=i.length):a++;if(a===d&&r!==d){var c=e.slice(r);this.cachedData?this.cachedData=Nt(this.cachedData,c):this.cachedData=c}}return{audioTrack:o,videoTrack:Kt(),id3Track:l,textTrack:Kt()}},s.demuxSampleAes=function(e,t,r){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},s.flush=function(e){var t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:Kt(),id3Track:this._id3Track,textTrack:Kt()}},s.destroy=function(){this.cachedData=null,this._audioTrack=this._id3Track=void 0},n}(),us=function(n,s,e){return U(n)?90*n:9e4*s+(e?9e4*e.baseTime/e.timescale:0)},ir=null,ds=[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],hs=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],fs=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],cs=[0,1,1,4];function Fa(n,s,e,t,r){if(!(e+24>s.length)){var i=Ma(s,e);if(i&&e+i.frameLength<=s.length){var a=t+r*(9e4*i.samplesPerFrame/i.sampleRate),o={unit:s.subarray(e,e+i.frameLength),pts:a,dts:a};return n.config=[],n.channelCount=i.channelCount,n.samplerate=i.sampleRate,n.samples.push(o),{sample:o,length:i.frameLength,missing:0}}}}function Ma(n,s){var e=n[s+1]>>3&3,t=n[s+1]>>1&3,r=n[s+2]>>4&15,i=n[s+2]>>2&3;if(e!==1&&r!==0&&r!==15&&i!==3){var a=n[s+2]>>1&1,o=n[s+3]>>6,l=1e3*ds[14*(e===3?3-t:t===3?3:4)+r-1],u=hs[3*(e===3?0:e===2?1:2)+i],d=o===3?1:2,h=fs[e][t],c=cs[t],f=8*h*c,v=Math.floor(h*l/u+a)*c;if(ir===null){var g=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);ir=g?parseInt(g[1]):0}return ir&&ir<=87&&t===2&&l>=224e3&&o===0&&(n[s+3]=128|n[s+3]),{sampleRate:u,channelCount:d,frameLength:v,samplesPerFrame:f}}}function Br(n,s){return n[s]===255&&(224&n[s+1])==224&&(6&n[s+1])!=0}function Na(n,s){return s+1<n.length&&Br(n,s)}function Ba(n,s){if(s+1<n.length&&Br(n,s)){var e=Ma(n,s),t=4;e!=null&&e.frameLength&&(t=e.frameLength);var r=s+t;return r===n.length||Na(n,r)}return!1}var vs=function(n){function s(t,r){var i;return(i=n.call(this)||this).observer=void 0,i.config=void 0,i.observer=t,i.config=r,i}ct(s,n);var e=s.prototype;return e.resetInitSegment=function(t,r,i,a){n.prototype.resetInitSegment.call(this,t,r,i,a),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:r,duration:a,inputTimeScale:9e4,dropped:0}},s.probe=function(t,r){if(!t)return!1;var i=tr(t,0),a=i?.length||0;if(Ba(t,a))return!1;for(var o=t.length;a<o;a++)if(rs(t,a))return r.log("ADTS sync word found !"),!0;return!1},e.canParse=function(t,r){return function(i,a){return function(o,l){return l+5<o.length}(i,a)&&ka(i,a)&&Mr(i,a)<=i.length-a}(t,r)},e.appendFrame=function(t,r,i){_a(t,this.observer,r,i,t.manifestCodec);var a=Ca(t,r,i,this.basePTS,this.frameIndex);if(a&&a.missing===0)return a},s}(Oa),gs=function(n){function s(){return n.apply(this,arguments)||this}ct(s,n);var e=s.prototype;return e.resetInitSegment=function(t,r,i,a){n.prototype.resetInitSegment.call(this,t,r,i,a),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:r,duration:a,inputTimeScale:9e4,dropped:0}},s.probe=function(t){if(!t)return!1;var r=tr(t,0),i=r?.length||0;if(r&&t[i]===11&&t[i+1]===119&&xa(r)!==void 0&&function(o,l){var u=0,d=5;l+=d;for(var h=new Uint32Array(1),c=new Uint32Array(1),f=new Uint8Array(1);d>0;){f[0]=o[l];var v=Math.min(d,8),g=8-v;c[0]=4278190080>>>24+g<<g,h[0]=(f[0]&c[0])>>g,u=u?u<<v|h[0]:h[0],l+=1,d-=v}return u}(t,i)<=16)return!1;for(var a=t.length;i<a;i++)if(Ba(t,i))return nt.log("MPEG Audio sync word found !"),!0;return!1},e.canParse=function(t,r){return function(i,a){return Br(i,a)&&4<=i.length-a}(t,r)},e.appendFrame=function(t,r,i){if(this.basePTS!==null)return Fa(t,r,i,this.basePTS,this.frameIndex)},s}(Oa),ms=function(){function n(s,e,t){this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=s,this.aesIV=e,this.aesMode=t}return n.prototype.decrypt=function(s,e){switch(this.aesMode){case Oe:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},e,s);case Pr:return this.subtle.decrypt({name:"AES-CTR",counter:this.aesIV,length:64},e,s);default:throw new Error("[AESCrypto] invalid aes mode "+this.aesMode)}},n}(),ps=function(){function n(){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()}var s=n.prototype;return s.uint8ArrayToUint32Array_=function(e){for(var t=new DataView(e),r=new Uint32Array(4),i=0;i<4;i++)r[i]=t.getUint32(4*i);return r},s.initTable=function(){var e=this.sBox,t=this.invSBox,r=this.subMix,i=r[0],a=r[1],o=r[2],l=r[3],u=this.invSubMix,d=u[0],h=u[1],c=u[2],f=u[3],v=new Uint32Array(256),g=0,m=0,p=0;for(p=0;p<256;p++)v[p]=p<128?p<<1:p<<1^283;for(p=0;p<256;p++){var y=m^m<<1^m<<2^m<<3^m<<4;y=y>>>8^255&y^99,e[g]=y,t[y]=g;var T=v[g],S=v[T],b=v[S],L=257*v[y]^16843008*y;i[g]=L<<24|L>>>8,a[g]=L<<16|L>>>16,o[g]=L<<8|L>>>24,l[g]=L,L=16843009*b^65537*S^257*T^16843008*g,d[y]=L<<24|L>>>8,h[y]=L<<16|L>>>16,c[y]=L<<8|L>>>24,f[y]=L,g?(g=T^v[v[v[b^T]]],m^=v[v[m]]):g=m=1}},s.expandKey=function(e){for(var t=this.uint8ArrayToUint32Array_(e),r=!0,i=0;i<t.length&&r;)r=t[i]===this.key[i],i++;if(!r){this.key=t;var a=this.keySize=t.length;if(a!==4&&a!==6&&a!==8)throw new Error("Invalid aes key size="+a);var o,l,u,d,h=this.ksRows=4*(a+6+1),c=this.keySchedule=new Uint32Array(h),f=this.invKeySchedule=new Uint32Array(h),v=this.sBox,g=this.rcon,m=this.invSubMix,p=m[0],y=m[1],T=m[2],S=m[3];for(o=0;o<h;o++)o<a?u=c[o]=t[o]:(d=u,o%a==0?(d=v[(d=d<<8|d>>>24)>>>24]<<24|v[d>>>16&255]<<16|v[d>>>8&255]<<8|v[255&d],d^=g[o/a|0]<<24):a>6&&o%a==4&&(d=v[d>>>24]<<24|v[d>>>16&255]<<16|v[d>>>8&255]<<8|v[255&d]),c[o]=u=(c[o-a]^d)>>>0);for(l=0;l<h;l++)o=h-l,d=3&l?c[o]:c[o-4],f[l]=l<4||o<=4?d:p[v[d>>>24]]^y[v[d>>>16&255]]^T[v[d>>>8&255]]^S[v[255&d]],f[l]=f[l]>>>0}},s.networkToHostOrderSwap=function(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24},s.decrypt=function(e,t,r){for(var i,a,o,l,u,d,h,c,f,v,g,m,p,y,T=this.keySize+6,S=this.invKeySchedule,b=this.invSBox,L=this.invSubMix,R=L[0],k=L[1],C=L[2],A=L[3],D=this.uint8ArrayToUint32Array_(r),_=D[0],M=D[1],O=D[2],P=D[3],w=new Int32Array(e),x=new Int32Array(w.length),N=this.networkToHostOrderSwap;t<w.length;){for(f=N(w[t]),v=N(w[t+1]),g=N(w[t+2]),m=N(w[t+3]),u=f^S[0],d=m^S[1],h=g^S[2],c=v^S[3],p=4,y=1;y<T;y++)i=R[u>>>24]^k[d>>16&255]^C[h>>8&255]^A[255&c]^S[p],a=R[d>>>24]^k[h>>16&255]^C[c>>8&255]^A[255&u]^S[p+1],o=R[h>>>24]^k[c>>16&255]^C[u>>8&255]^A[255&d]^S[p+2],l=R[c>>>24]^k[u>>16&255]^C[d>>8&255]^A[255&h]^S[p+3],u=i,d=a,h=o,c=l,p+=4;i=b[u>>>24]<<24^b[d>>16&255]<<16^b[h>>8&255]<<8^b[255&c]^S[p],a=b[d>>>24]<<24^b[h>>16&255]<<16^b[c>>8&255]<<8^b[255&u]^S[p+1],o=b[h>>>24]<<24^b[c>>16&255]<<16^b[u>>8&255]<<8^b[255&d]^S[p+2],l=b[c>>>24]<<24^b[u>>16&255]<<16^b[d>>8&255]<<8^b[255&h]^S[p+3],x[t]=N(i^_),x[t+1]=N(l^M),x[t+2]=N(o^O),x[t+3]=N(a^P),_=f,M=v,O=g,P=m,t+=4}return x.buffer},n}(),ys=function(){function n(s,e,t){this.subtle=void 0,this.key=void 0,this.aesMode=void 0,this.subtle=s,this.key=e,this.aesMode=t}return n.prototype.expandKey=function(){var s=function(e){switch(e){case Oe:return"AES-CBC";case Pr:return"AES-CTR";default:throw new Error("[FastAESKey] invalid aes mode "+e)}}(this.aesMode);return this.subtle.importKey("raw",this.key,{name:s},!1,["encrypt","decrypt"])},n}(),Ur=function(){function n(e,t){var r=(t===void 0?{}:t).removePKCS7Padding,i=r===void 0||r;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=i,i)try{var a=self.crypto;a&&(this.subtle=a.subtle||a.webkitSubtle)}catch{}this.useSoftware=!this.subtle}var s=n.prototype;return s.destroy=function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null},s.isSync=function(){return this.useSoftware},s.flush=function(){var e=this.currentResult,t=this.remainderData;if(!e||t)return this.reset(),null;var r,i,a,o=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?(i=(r=o).byteLength,(a=i&&new DataView(r.buffer).getUint8(i-1))?r.slice(0,i-a):r):o},s.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},s.decrypt=function(e,t,r,i){var a=this;return this.useSoftware?new Promise(function(o,l){var u=ArrayBuffer.isView(e)?e:new Uint8Array(e);a.softwareDecrypt(u,t,r,i);var d=a.flush();d?o(d.buffer):l(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,r,i)},s.softwareDecrypt=function(e,t,r,i){var a=this.currentIV,o=this.currentResult,l=this.remainderData;if(i!==Oe||t.byteLength!==16)return nt.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),l&&(e=Nt(l,e),this.remainderData=null);var u=this.getValidChunk(e);if(!u.length)return null;a&&(r=a);var d=this.softwareDecrypter;d||(d=this.softwareDecrypter=new ps),d.expandKey(t);var h=o;return this.currentResult=d.decrypt(u.buffer,0,r),this.currentIV=u.slice(-16).buffer,h||null},s.webCryptoDecrypt=function(e,t,r,i){var a=this;if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,r,i));this.key=t,this.fastAesKey=new ys(this.subtle,t,i)}return this.fastAesKey.expandKey().then(function(o){return a.subtle?(a.logOnce("WebCrypto AES decrypt"),new ms(a.subtle,new Uint8Array(r),i).decrypt(e.buffer,o)):Promise.reject(new Error("web crypto not initialized"))}).catch(function(o){return nt.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, "+o.name+": "+o.message),a.onWebCryptoError(e,t,r,i)})},s.onWebCryptoError=function(e,t,r,i){var a=this.enableSoftwareAES;if(a){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r,i);var o=this.flush();if(o)return o.buffer}throw new Error("WebCrypto"+(a?" and softwareDecrypt":"")+": failed to decrypt data")},s.getValidChunk=function(e){var t=e,r=e.length-e.length%16;return r!==e.length&&(t=e.slice(0,r),this.remainderData=e.slice(r)),t},s.logOnce=function(e){this.logEnabled&&(nt.log("[decrypter]: "+e),this.logEnabled=!1)},n}(),Es=/\/emsg[-/]ID3/i,Ts=function(){function n(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}var s=n.prototype;return s.resetTimeStamp=function(){},s.resetInitSegment=function(e,t,r,i){var a=this.videoTrack=Kt("video",1),o=this.audioTrack=Kt("audio",1),l=this.txtTrack=Kt("text",1);if(this.id3Track=Kt("id3",1),this.timeOffset=0,e!=null&&e.byteLength){var u=Li(e);if(u.video){var d=u.video,h=d.id,c=d.timescale,f=d.codec,v=d.supplemental;a.id=h,a.timescale=l.timescale=c,a.codec=f,a.supplemental=v}if(u.audio){var g=u.audio,m=g.id,p=g.timescale,y=g.codec;o.id=m,o.timescale=p,o.codec=y}l.id=yi.text,a.sampleDuration=0,a.duration=o.duration=i}},s.resetContiguity=function(){this.remainderData=null},n.probe=function(e){return function(t){for(var r=t.byteLength,i=0;i<r;){var a=H(t,i);if(a>8&&t[i+4]===109&&t[i+5]===111&&t[i+6]===111&&t[i+7]===102)return!0;i=a>1?i+a:r}return!1}(e)},s.demux=function(e,t){this.timeOffset=t;var r=e,i=this.videoTrack,a=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=Nt(this.remainderData,e));var o=function(u){var d={valid:null,remainder:null},h=X(u,["moof"]);if(h.length<2)return d.remainder=u,d;var c=h[h.length-1];return d.valid=u.slice(0,c.byteOffset-8),d.remainder=u.slice(c.byteOffset-8),d}(r);this.remainderData=o.remainder,i.samples=o.valid||new Uint8Array}else i.samples=r;var l=this.extractID3Track(i,t);return a.samples=Ai(t,i),{videoTrack:i,audioTrack:this.audioTrack,id3Track:l,textTrack:this.txtTrack}},s.flush=function(){var e=this.timeOffset,t=this.videoTrack,r=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;var i=this.extractID3Track(t,this.timeOffset);return r.samples=Ai(e,t),{videoTrack:t,audioTrack:Kt(),id3Track:i,textTrack:Kt()}},s.extractID3Track=function(e,t){var r=this,i=this.id3Track;if(e.samples.length){var a=X(e.samples,["emsg"]);a&&a.forEach(function(o){var l=function(f){var v=f[0],g="",m="",p=0,y=0,T=0,S=0,b=0,L=0;if(v===0){for(;Tt(f.subarray(L,L+1))!=="\0";)g+=Tt(f.subarray(L,L+1)),L+=1;for(g+=Tt(f.subarray(L,L+1)),L+=1;Tt(f.subarray(L,L+1))!=="\0";)m+=Tt(f.subarray(L,L+1)),L+=1;m+=Tt(f.subarray(L,L+1)),L+=1,p=H(f,12),y=H(f,16),S=H(f,20),b=H(f,24),L=28}else if(v===1){p=H(f,L+=4);var R=H(f,L+=4),k=H(f,L+=4);for(L+=4,T=Math.pow(2,32)*R+k,Ln(T)||(T=Number.MAX_SAFE_INTEGER,nt.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),S=H(f,L),b=H(f,L+=4),L+=4;Tt(f.subarray(L,L+1))!=="\0";)g+=Tt(f.subarray(L,L+1)),L+=1;for(g+=Tt(f.subarray(L,L+1)),L+=1;Tt(f.subarray(L,L+1))!=="\0";)m+=Tt(f.subarray(L,L+1)),L+=1;m+=Tt(f.subarray(L,L+1)),L+=1}return{schemeIdUri:g,value:m,timeScale:p,presentationTime:T,presentationTimeDelta:y,eventDuration:S,id:b,payload:f.subarray(L,f.byteLength)}}(o);if(Es.test(l.schemeIdUri)){var u=Ua(l,t),d=l.eventDuration===4294967295?Number.POSITIVE_INFINITY:l.eventDuration/l.timeScale;d<=.001&&(d=Number.POSITIVE_INFINITY);var h=l.payload;i.samples.push({data:h,len:h.byteLength,dts:u,pts:u,type:Ct.emsg,duration:d})}else if(r.config.enableEmsgKLVMetadata&&l.schemeIdUri.startsWith("urn:misb:KLV:bin:1910.1")){var c=Ua(l,t);i.samples.push({data:l.payload,len:l.payload.byteLength,dts:c,pts:c,type:Ct.misbklv,duration:Number.POSITIVE_INFINITY})}})}return i},s.demuxSampleAes=function(e,t,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},s.destroy=function(){this.config=null,this.remainderData=null,this.videoTrack=this.audioTrack=this.id3Track=this.txtTrack=void 0},n}();function Ua(n,s){return U(n.presentationTime)?n.presentationTime/n.timeScale:s+n.presentationTimeDelta/n.timeScale}var Ss=function(){function n(e,t,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new Ur(t,{removePKCS7Padding:!1})}var s=n.prototype;return s.decryptBuffer=function(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,Oe)},s.decryptAacSample=function(e,t,r){var i=this,a=e[t].unit;if(!(a.length<=16)){var o=a.subarray(16,a.length-a.length%16),l=o.buffer.slice(o.byteOffset,o.byteOffset+o.length);this.decryptBuffer(l).then(function(u){var d=new Uint8Array(u);a.set(d,16),i.decrypter.isSync()||i.decryptAacSamples(e,t+1,r)}).catch(r)}},s.decryptAacSamples=function(e,t,r){for(;;t++){if(t>=e.length)return void r();if(!(e[t].unit.length<32||(this.decryptAacSample(e,t,r),this.decrypter.isSync())))return}},s.getAvcEncryptedData=function(e){for(var t=16*Math.floor((e.length-48)/160)+16,r=new Int8Array(t),i=0,a=32;a<e.length-16;a+=160,i+=16)r.set(e.subarray(a,a+16),i);return r},s.getAvcDecryptedUnit=function(e,t){for(var r=new Uint8Array(t),i=0,a=32;a<e.length-16;a+=160,i+=16)e.set(r.subarray(i,i+16),a);return e},s.decryptAvcSample=function(e,t,r,i,a){var o=this,l=ki(a.data),u=this.getAvcEncryptedData(l);this.decryptBuffer(u.buffer).then(function(d){a.data=o.getAvcDecryptedUnit(l,d),o.decrypter.isSync()||o.decryptAvcSamples(e,t,r+1,i)}).catch(i)},s.decryptAvcSamples=function(e,t,r,i){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length)return void i();for(var a=e[t].units;!(r>=a.length);r++){var o=a[r];if(!(o.data.length<=48||o.type!==1&&o.type!==5||(this.decryptAvcSample(e,t,r,i,o),this.decrypter.isSync())))return}}},n}(),Ls=function(){function n(){this.VideoSample=null}var s=n.prototype;return s.createVideoSample=function(e,t,r){return{key:e,frame:!1,pts:t,dts:r,units:[],length:0}},s.getLastNalUnit=function(e){var t,r,i=this.VideoSample;if(i&&i.units.length!==0||(i=e[e.length-1]),(t=i)!=null&&t.units){var a=i.units;r=a[a.length-1]}return r},s.pushAccessUnit=function(e,t){if(e.units.length&&e.frame){if(e.pts===void 0){var r=t.samples,i=r.length;if(!i)return void t.dropped++;var a=r[i-1];e.pts=a.pts,e.dts=a.dts}t.samples.push(e)}},s.parseNALu=function(e,t,r){var i,a,o=t.byteLength,l=e.naluState||0,u=l,d=[],h=0,c=-1,f=0;for(l===-1&&(c=0,f=this.getNALuType(t,0),l=0,h=1);h<o;)if(i=t[h++],l)if(l!==1)if(i)if(i===1){if(a=h-l-1,c>=0){var v={data:t.subarray(c,a),type:f};d.push(v)}else{var g=this.getLastNalUnit(e.samples);g&&(u&&h<=4-u&&g.state&&(g.data=g.data.subarray(0,g.data.byteLength-u)),a>0&&(g.data=Nt(g.data,t.subarray(0,a)),g.state=0))}h<o?(c=h,f=this.getNALuType(t,h),l=0):l=-1}else l=0;else l=3;else l=i?0:2;else l=i?0:1;if(c>=0&&l>=0){var m={data:t.subarray(c,o),type:f,state:l};d.push(m)}if(d.length===0){var p=this.getLastNalUnit(e.samples);p&&(p.data=Nt(p.data,t))}return e.naluState=l,d},n}(),Ga=function(){function n(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}var s=n.prototype;return s.loadWord=function(){var e=this.data,t=this.bytesAvailable,r=e.byteLength-t,i=new Uint8Array(4),a=Math.min(4,t);if(a===0)throw new Error("no bytes available");i.set(e.subarray(r,r+a)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*a,this.bytesAvailable-=a},s.skipBits=function(e){var t;e=Math.min(e,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,e-=(t=e>>3)<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)},s.readBits=function(e){var t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;if(e>32&&nt.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return(t=e-t)>0&&this.bitsAvailable?r<<t|this.readBits(t):r},s.skipLZ=function(){var 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()},s.skipUEG=function(){this.skipBits(1+this.skipLZ())},s.skipEG=function(){this.skipBits(1+this.skipLZ())},s.readUEG=function(){var e=this.skipLZ();return this.readBits(e+1)-1},s.readEG=function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)},s.readBoolean=function(){return this.readBits(1)===1},s.readUByte=function(){return this.readBits(8)},s.readUShort=function(){return this.readBits(16)},s.readUInt=function(){return this.readBits(32)},n}(),Rs=function(n){function s(){return n.apply(this,arguments)||this}ct(s,n);var e=s.prototype;return e.parsePES=function(t,r,i,a){var o,l=this,u=this.parseNALu(t,i.data,a),d=this.VideoSample,h=!1;i.data=null,d&&u.length&&!t.audFound&&(this.pushAccessUnit(d,t),d=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),u.forEach(function(c){var f,v;switch(c.type){case 1:var g=!1;o=!0;var m,p=c.data;if(h&&p.length>4){var y=l.readSliceType(p);y!==2&&y!==4&&y!==7&&y!==9||(g=!0)}g&&(m=d)!=null&&m.frame&&!d.key&&(l.pushAccessUnit(d,t),d=l.VideoSample=null),d||(d=l.VideoSample=l.createVideoSample(!0,i.pts,i.dts)),d.frame=!0,d.key=g;break;case 5:o=!0,(f=d)!=null&&f.frame&&!d.key&&(l.pushAccessUnit(d,t),d=l.VideoSample=null),d||(d=l.VideoSample=l.createVideoSample(!0,i.pts,i.dts)),d.key=!0,d.frame=!0;break;case 6:o=!0,bi(c.data,1,i.pts,r.samples);break;case 7:var T,S;o=!0,h=!0;var b=c.data,L=l.readSPS(b);if(!t.sps||t.width!==L.width||t.height!==L.height||((T=t.pixelRatio)==null?void 0:T[0])!==L.pixelRatio[0]||((S=t.pixelRatio)==null?void 0:S[1])!==L.pixelRatio[1]){t.width=L.width,t.height=L.height,t.pixelRatio=L.pixelRatio,t.sps=[b];for(var R=b.subarray(1,4),k="avc1.",C=0;C<3;C++){var A=R[C].toString(16);A.length<2&&(A="0"+A),k+=A}t.codec=k}break;case 8:o=!0,t.pps=[c.data];break;case 9:o=!0,t.audFound=!0,(v=d)!=null&&v.frame&&(l.pushAccessUnit(d,t),d=null),d||(d=l.VideoSample=l.createVideoSample(!1,i.pts,i.dts));break;case 12:o=!0;break;default:o=!1}d&&o&&d.units.push(c)}),a&&d&&(this.pushAccessUnit(d,t),this.VideoSample=null)},e.getNALuType=function(t,r){return 31&t[r]},e.readSliceType=function(t){var r=new Ga(t);return r.readUByte(),r.readUEG(),r.readUEG()},e.skipScalingList=function(t,r){for(var i=8,a=8,o=0;o<t;o++)a!==0&&(a=(i+r.readEG()+256)%256),i=a===0?i:a},e.readSPS=function(t){var r,i,a,o=new Ga(t),l=0,u=0,d=0,h=0,c=o.readUByte.bind(o),f=o.readBits.bind(o),v=o.readUEG.bind(o),g=o.readBoolean.bind(o),m=o.skipBits.bind(o),p=o.skipEG.bind(o),y=o.skipUEG.bind(o),T=this.skipScalingList.bind(this);c();var S=c();if(f(5),m(3),c(),y(),S===100||S===110||S===122||S===244||S===44||S===83||S===86||S===118||S===128){var b=v();if(b===3&&m(1),y(),y(),m(1),g())for(i=b!==3?8:12,a=0;a<i;a++)g()&&T(a<6?16:64,o)}y();var L=v();if(L===0)v();else if(L===1)for(m(1),p(),p(),r=v(),a=0;a<r;a++)p();y(),m(1);var R=v(),k=v(),C=f(1);C===0&&m(1),m(1),g()&&(l=v(),u=v(),d=v(),h=v());var A=[1,1];if(g()&&g())switch(c()){case 1:A=[1,1];break;case 2:A=[12,11];break;case 3:A=[10,11];break;case 4:A=[16,11];break;case 5:A=[40,33];break;case 6:A=[24,11];break;case 7:A=[20,11];break;case 8:A=[32,11];break;case 9:A=[80,33];break;case 10:A=[18,11];break;case 11:A=[15,11];break;case 12:A=[64,33];break;case 13:A=[160,99];break;case 14:A=[4,3];break;case 15:A=[3,2];break;case 16:A=[2,1];break;case 255:A=[c()<<8|c(),c()<<8|c()]}return{width:Math.ceil(16*(R+1)-2*l-2*u),height:(2-C)*(k+1)*16-(C?2:4)*(d+h),pixelRatio:A}},s}(Ls),Lt=188,As=function(){function n(e,t,r,i){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=r,this.logger=i,this.videoParser=null}n.probe=function(e,t){var r=n.syncOffset(e);return r>0&&t.warn("MPEG2-TS detected but first sync word found @ offset "+r),r!==-1},n.syncOffset=function(e){for(var t=e.length,r=Math.min(940,t-Lt)+1,i=0;i<r;){for(var a=!1,o=-1,l=0,u=i;u<t;u+=Lt){if(e[u]!==71||t-u!==Lt&&e[u+Lt]!==71){if(l)return-1;break}if(l++,o===-1&&(o=u)!==0&&(r=Math.min(o+18612,e.length-Lt)+1),a||(a=Gr(e,u)===0),a&&l>1&&(o===0&&l>2||u+Lt>r))return o}i++}return-1},n.createTrack=function(e,t){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:yi[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}};var s=n.prototype;return s.resetInitSegment=function(e,t,r,i){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=n.createTrack("video"),this._videoTrack.duration=i,this._audioTrack=n.createTrack("audio",i),this._id3Track=n.createTrack("id3"),this._txtTrack=n.createTrack("text"),this._audioTrack.segmentCodec="aac",this.videoParser=null,this.aacOverFlow=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=r},s.resetTimeStamp=function(){},s.resetContiguity=function(){var e=this._audioTrack,t=this._videoTrack,r=this._id3Track;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.remainderData=null},s.demux=function(e,t,r,i){var a;r===void 0&&(r=!1),i===void 0&&(i=!1),r||(this.sampleAes=null);var o=this._videoTrack,l=this._audioTrack,u=this._id3Track,d=this._txtTrack,h=o.pid,c=o.pesData,f=l.pid,v=u.pid,g=l.pesData,m=u.pesData,p=null,y=this.pmtParsed,T=this._pmtId,S=e.length;if(this.remainderData&&(S=(e=Nt(this.remainderData,e)).length,this.remainderData=null),S<Lt&&!i)return this.remainderData=e,{audioTrack:l,videoTrack:o,id3Track:u,textTrack:d};var b=Math.max(0,n.syncOffset(e));(S-=(S-b)%Lt)<e.byteLength&&!i&&(this.remainderData=new Uint8Array(e.buffer,S,e.buffer.byteLength-S));for(var L=0,R=b;R<S;R+=Lt)if(e[R]===71){var k=!!(64&e[R+1]),C=Gr(e,R),A=void 0;if((48&e[R+3])>>4>1){if((A=R+5+e[R+4])===R+Lt)continue}else A=R+4;switch(C){case h:k&&(c&&(a=ye(c,this.logger))&&(this.readyVideoParser(o.segmentCodec),this.videoParser!==null&&this.videoParser.parsePES(o,d,a,!1)),c={data:[],size:0}),c&&(c.data.push(e.subarray(A,R+Lt)),c.size+=R+Lt-A);break;case f:if(k){if(g&&(a=ye(g,this.logger)))switch(l.segmentCodec){case"aac":this.parseAACPES(l,a);break;case"mp3":this.parseMPEGPES(l,a)}g={data:[],size:0}}g&&(g.data.push(e.subarray(A,R+Lt)),g.size+=R+Lt-A);break;case v:k&&(m&&(a=ye(m,this.logger))&&this.parseID3PES(u,a),m={data:[],size:0}),m&&(m.data.push(e.subarray(A,R+Lt)),m.size+=R+Lt-A);break;case 0:k&&(A+=e[A]+1),T=this._pmtId=bs(e,A);break;case T:k&&(A+=e[A]+1);var D=ks(e,A,this.typeSupported,r,this.observer,this.logger);(h=D.videoPid)>0&&(o.pid=h,o.segmentCodec=D.segmentVideoCodec),(f=D.audioPid)>0&&(l.pid=f,l.segmentCodec=D.segmentAudioCodec),(v=D.id3Pid)>0&&(u.pid=v),p===null||y||(this.logger.warn("MPEG-TS PMT found at "+R+" after unknown PID '"+p+"'. Backtracking to sync byte @"+b+" to parse all TS packets."),p=null,R=b-188),y=this.pmtParsed=!0;break;case 17:case 8191:break;default:p=C}}else L++;L>0&&ar(this.observer,new Error("Found "+L+" TS packet/s that do not start with 0x47"),void 0,this.logger),o.pesData=c,l.pesData=g,u.pesData=m;var _={audioTrack:l,videoTrack:o,id3Track:u,textTrack:d};return i&&this.extractRemainingSamples(_),_},s.flush=function(){var e,t=this.remainderData;return this.remainderData=null,e=t?this.demux(t,-1,!1,!0):{videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e},s.extractRemainingSamples=function(e){var t,r=e.audioTrack,i=e.videoTrack,a=e.id3Track,o=e.textTrack,l=i.pesData,u=r.pesData,d=a.pesData;if(l&&(t=ye(l,this.logger))?(this.readyVideoParser(i.segmentCodec),this.videoParser!==null&&(this.videoParser.parsePES(i,o,t,!0),i.pesData=null)):i.pesData=l,u&&(t=ye(u,this.logger))){switch(r.segmentCodec){case"aac":this.parseAACPES(r,t);break;case"mp3":this.parseMPEGPES(r,t)}r.pesData=null}else u!=null&&u.size&&this.logger.log("last AAC PES packet truncated,might overlap between fragments"),r.pesData=u;d&&(t=ye(d,this.logger))?(this.parseID3PES(a,t),a.pesData=null):a.pesData=d},s.demuxSampleAes=function(e,t,r){var i=this.demux(e,r,!0,!this.config.progressive),a=this.sampleAes=new Ss(this.observer,this.config,t);return this.decrypt(i,a)},s.readyVideoParser=function(e){this.videoParser===null&&e==="avc"&&(this.videoParser=new Rs)},s.decrypt=function(e,t){return new Promise(function(r){var i=e.audioTrack,a=e.videoTrack;i.samples&&i.segmentCodec==="aac"?t.decryptAacSamples(i.samples,0,function(){a.samples?t.decryptAvcSamples(a.samples,0,0,function(){r(e)}):r(e)}):a.samples&&t.decryptAvcSamples(a.samples,0,0,function(){r(e)})})},s.destroy=function(){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},s.parseAACPES=function(e,t){var r,i,a,o=0,l=this.aacOverFlow,u=t.data;if(l){this.aacOverFlow=null;var d=l.missing,h=l.sample.unit.byteLength;if(d===-1)u=Nt(l.sample.unit,u);else{var c=h-d;l.sample.unit.set(u.subarray(0,d),c),e.samples.push(l.sample),o=l.missing}}for(r=o,i=u.length;r<i-1&&!er(u,r);r++);if(r!==o){var f,v=r<i-1;if(f=v?"AAC PES did not start with ADTS header,offset:"+r:"No ADTS header found in AAC PES",ar(this.observer,new Error(f),v,this.logger),!v)return}if(_a(e,this.observer,u,r,this.audioCodec),t.pts!==void 0)a=t.pts;else{if(!l)return void this.logger.warn("[tsdemuxer]: AAC PES unknown PTS");var g=Ia(e.samplerate);a=l.sample.pts+g}for(var m,p=0;r<i;){if(r+=(m=Ca(e,u,r,a,p)).length,m.missing){this.aacOverFlow=m;break}for(p++;r<i-1&&!er(u,r);r++);}},s.parseMPEGPES=function(e,t){var r=t.data,i=r.length,a=0,o=0,l=t.pts;if(l!==void 0)for(;o<i;)if(Na(r,o)){var u=Fa(e,r,o,l,a);if(!u)break;o+=u.length,a++}else o++;else this.logger.warn("[tsdemuxer]: MPEG PES unknown PTS")},s.parseAC3PES=function(e,t){},s.parseID3PES=function(e,t){if(t.pts!==void 0){var r=Et({},t,{type:this._videoTrack?Ct.emsg:Ct.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(r)}else this.logger.warn("[tsdemuxer]: ID3 PES unknown PTS")},n}();function Gr(n,s){return((31&n[s+1])<<8)+n[s+2]}function bs(n,s){return(31&n[s+10])<<8|n[s+11]}function ks(n,s,e,t,r,i){var a={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},o=s+3+((15&n[s+1])<<8|n[s+2])-4;for(s+=12+((15&n[s+10])<<8|n[s+11]);s<o;){var l=Gr(n,s),u=(15&n[s+3])<<8|n[s+4];switch(n[s]){case 207:if(!t){Vr("ADTS AAC",i);break}case 15:a.audioPid===-1&&(a.audioPid=l);break;case 21:a.id3Pid===-1&&(a.id3Pid=l);break;case 219:if(!t){Vr("H.264",i);break}case 27:a.videoPid===-1&&(a.videoPid=l);break;case 3:case 4:e.mpeg||e.mp3?a.audioPid===-1&&(a.audioPid=l,a.segmentAudioCodec="mp3"):i.log("MPEG audio found, not supported in this browser");break;case 193:if(!t){Vr("AC-3",i);break}case 129:i.warn("AC-3 in M2TS support not included in build");break;case 6:if(a.audioPid===-1&&u>0)for(var d=s+5,h=u;h>2;){n[d]===106&&i.warn("AC-3 in M2TS support not included in build");var c=n[d+1]+2;d+=c,h-=c}break;case 194:case 135:return ar(r,new Error("Unsupported EC-3 in M2TS found"),void 0,i),a;case 36:return ar(r,new Error("Unsupported HEVC in M2TS found"),void 0,i),a}s+=u+5}return a}function ar(n,s,e,t){t.warn("parsing error: "+s.message),n.emit(E.ERROR,E.ERROR,{type:W.MEDIA_ERROR,details:I.FRAG_PARSING_ERROR,fatal:!1,levelRetry:e,error:s,reason:s.message})}function Vr(n,s){s.log(n+" with AES-128-CBC encryption found in unencrypted stream")}function ye(n,s){var e,t,r,i,a,o=0,l=n.data;if(!n||n.size===0)return null;for(;l[0].length<19&&l.length>1;)l[0]=Nt(l[0],l[1]),l.splice(1,1);if(((e=l[0])[0]<<16)+(e[1]<<8)+e[2]===1){if((t=(e[4]<<8)+e[5])&&t>n.size-6)return null;var u=e[7];192&u&&(i=536870912*(14&e[9])+4194304*(255&e[10])+16384*(254&e[11])+128*(255&e[12])+(254&e[13])/2,64&u?i-(a=536870912*(14&e[14])+4194304*(255&e[15])+16384*(254&e[16])+128*(255&e[17])+(254&e[18])/2)>54e5&&(s.warn(Math.round((i-a)/9e4)+"s delta between PTS and DTS, align them"),i=a):a=i);var d=(r=e[8])+9;if(n.size<=d)return null;n.size-=d;for(var h=new Uint8Array(n.size),c=0,f=l.length;c<f;c++){var v=(e=l[c]).byteLength;if(d){if(d>v){d-=v;continue}e=e.subarray(d),v-=d,d=0}h.set(e,o),o+=v}return t&&(t-=r+3),{data:h,pts:i,dts:a,len:t}}return null}var Ds=function(){function n(){}return n.getSilentFrame=function(s,e){if(s==="mp4a.40.2"){if(e===1)return new Uint8Array([0,200,0,128,35,128]);if(e===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(e===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(e===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(e===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(e===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])}else{if(e===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(e===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(e===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])}},n}(),ne=Math.pow(2,32)-1,St=function(){function n(){}return n.init=function(){var s;for(s in n.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:[]},n.types)n.types.hasOwnProperty(s)&&(n.types[s]=[s.charCodeAt(0),s.charCodeAt(1),s.charCodeAt(2),s.charCodeAt(3)]);var e=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]),t=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]);n.HDLR_TYPES={video:e,audio:t};var r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),i=new Uint8Array([0,0,0,0,0,0,0,0]);n.STTS=n.STSC=n.STCO=i,n.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),n.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),n.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),n.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var a=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);n.FTYP=n.box(n.types.ftyp,a,l,a,o),n.DINF=n.box(n.types.dinf,n.box(n.types.dref,r))},n.box=function(s){for(var e=8,t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];for(var a=r.length,o=a;a--;)e+=r[a].byteLength;var l=new Uint8Array(e);for(l[0]=e>>24&255,l[1]=e>>16&255,l[2]=e>>8&255,l[3]=255&e,l.set(s,4),a=0,e=8;a<o;a++)l.set(r[a],e),e+=r[a].byteLength;return l},n.hdlr=function(s){return n.box(n.types.hdlr,n.HDLR_TYPES[s])},n.mdat=function(s){return n.box(n.types.mdat,s)},n.mdhd=function(s,e){e*=s;var t=Math.floor(e/(ne+1)),r=Math.floor(e%(ne+1));return n.box(n.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,s>>24&255,s>>16&255,s>>8&255,255&s,t>>24,t>>16&255,t>>8&255,255&t,r>>24,r>>16&255,r>>8&255,255&r,85,196,0,0]))},n.mdia=function(s){return n.box(n.types.mdia,n.mdhd(s.timescale||0,s.duration||0),n.hdlr(s.type),n.minf(s))},n.mfhd=function(s){return n.box(n.types.mfhd,new Uint8Array([0,0,0,0,s>>24,s>>16&255,s>>8&255,255&s]))},n.minf=function(s){return s.type==="audio"?n.box(n.types.minf,n.box(n.types.smhd,n.SMHD),n.DINF,n.stbl(s)):n.box(n.types.minf,n.box(n.types.vmhd,n.VMHD),n.DINF,n.stbl(s))},n.moof=function(s,e,t){return n.box(n.types.moof,n.mfhd(s),n.traf(t,e))},n.moov=function(s){for(var e=s.length,t=[];e--;)t[e]=n.trak(s[e]);return n.box.apply(null,[n.types.moov,n.mvhd(s[0].timescale||0,s[0].duration||0)].concat(t).concat(n.mvex(s)))},n.mvex=function(s){for(var e=s.length,t=[];e--;)t[e]=n.trex(s[e]);return n.box.apply(null,[n.types.mvex].concat(t))},n.mvhd=function(s,e){e*=s;var t=Math.floor(e/(ne+1)),r=Math.floor(e%(ne+1)),i=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,s>>24&255,s>>16&255,s>>8&255,255&s,t>>24,t>>16&255,t>>8&255,255&t,r>>24,r>>16&255,r>>8&255,255&r,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return n.box(n.types.mvhd,i)},n.sdtp=function(s){var e,t,r=s.samples||[],i=new Uint8Array(4+r.length);for(e=0;e<r.length;e++)t=r[e].flags,i[e+4]=t.dependsOn<<4|t.isDependedOn<<2|t.hasRedundancy;return n.box(n.types.sdtp,i)},n.stbl=function(s){return n.box(n.types.stbl,n.stsd(s),n.box(n.types.stts,n.STTS),n.box(n.types.stsc,n.STSC),n.box(n.types.stsz,n.STSZ),n.box(n.types.stco,n.STCO))},n.avc1=function(s){var e,t,r,i=[],a=[];for(e=0;e<s.sps.length;e++)r=(t=s.sps[e]).byteLength,i.push(r>>>8&255),i.push(255&r),i=i.concat(Array.prototype.slice.call(t));for(e=0;e<s.pps.length;e++)r=(t=s.pps[e]).byteLength,a.push(r>>>8&255),a.push(255&r),a=a.concat(Array.prototype.slice.call(t));var o=n.box(n.types.avcC,new Uint8Array([1,i[3],i[4],i[5],255,224|s.sps.length].concat(i).concat([s.pps.length]).concat(a))),l=s.width,u=s.height,d=s.pixelRatio[0],h=s.pixelRatio[1];return n.box(n.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,l>>8&255,255&l,u>>8&255,255&u,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,n.box(n.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),n.box(n.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,255&d,h>>24,h>>16&255,h>>8&255,255&h])))},n.esds=function(s){var e=s.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].concat(e,[6,1,2]))},n.audioStsd=function(s){var e=s.samplerate||0;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,s.channelCount||0,0,16,0,0,0,0,e>>8&255,255&e,0,0])},n.mp4a=function(s){return n.box(n.types.mp4a,n.audioStsd(s),n.box(n.types.esds,n.esds(s)))},n.mp3=function(s){return n.box(n.types[".mp3"],n.audioStsd(s))},n.ac3=function(s){return n.box(n.types["ac-3"],n.audioStsd(s),n.box(n.types.dac3,s.config))},n.stsd=function(s){var e=s.segmentCodec;if(s.type==="audio"){if(e==="aac")return n.box(n.types.stsd,n.STSD,n.mp4a(s));if(e==="mp3"&&s.codec==="mp3")return n.box(n.types.stsd,n.STSD,n.mp3(s))}else{if(!s.pps||!s.sps)throw new Error("video track missing pps or sps");if(e==="avc")return n.box(n.types.stsd,n.STSD,n.avc1(s))}throw new Error("unsupported "+s.type+" segment codec ("+e+"/"+s.codec+")")},n.tkhd=function(s){var e=s.id,t=(s.duration||0)*(s.timescale||0),r=s.width||0,i=s.height||0,a=Math.floor(t/(ne+1)),o=Math.floor(t%(ne+1));return n.box(n.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,0,0,0,0,a>>24,a>>16&255,a>>8&255,255&a,o>>24,o>>16&255,o>>8&255,255&o,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,r>>8&255,255&r,0,0,i>>8&255,255&i,0,0]))},n.traf=function(s,e){var t=n.sdtp(s),r=s.id,i=Math.floor(e/(ne+1)),a=Math.floor(e%(ne+1));return n.box(n.types.traf,n.box(n.types.tfhd,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r])),n.box(n.types.tfdt,new Uint8Array([1,0,0,0,i>>24,i>>16&255,i>>8&255,255&i,a>>24,a>>16&255,a>>8&255,255&a])),n.trun(s,t.length+16+20+8+16+8+8),t)},n.trak=function(s){return s.duration=s.duration||4294967295,n.box(n.types.trak,n.tkhd(s),n.mdia(s))},n.trex=function(s){var e=s.id;return n.box(n.types.trex,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},n.trun=function(s,e){var t,r,i,a,o,l,u=s.samples||[],d=u.length,h=12+16*d,c=new Uint8Array(h);for(e+=8+h,c.set([s.type==="video"?1:0,0,15,1,d>>>24&255,d>>>16&255,d>>>8&255,255&d,e>>>24&255,e>>>16&255,e>>>8&255,255&e],0),t=0;t<d;t++)i=(r=u[t]).duration,a=r.size,o=r.flags,l=r.cts,c.set([i>>>24&255,i>>>16&255,i>>>8&255,255&i,a>>>24&255,a>>>16&255,a>>>8&255,255&a,o.isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,61440&o.degradPrio,15&o.degradPrio,l>>>24&255,l>>>16&255,l>>>8&255,255&l],12+16*t);return n.box(n.types.trun,c)},n.initSegment=function(s){n.types||n.init();var e=n.moov(s);return Nt(n.FTYP,e)},n.hvc1=function(s){return new Uint8Array},n}();function Ne(n,s){return function(e,t,r,i){var a=e*t*r;return Math.round(a)}(n,1e3,1/9e4)}function Va(n){var s=n.baseTime,e=n.timescale;return s/e+" ("+s+"/"+e+") trackId: "+n.trackId}St.types=void 0,St.HDLR_TYPES=void 0,St.STTS=void 0,St.STSC=void 0,St.STCO=void 0,St.STSZ=void 0,St.VMHD=void 0,St.SMHD=void 0,St.STSD=void 0,St.FTYP=void 0,St.DINF=void 0;var Ee=null,Hr=null;function Ha(n,s,e,t){return{duration:s,size:e,cts:t,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:n?2:1,isNonSync:n?0:1}}}var Kr=function(n){function s(t,r,i,a){var o;if((o=n.call(this,"mp4-remuxer",a)||this).observer=void 0,o.config=void 0,o.typeSupported=void 0,o.ISGenerated=!1,o._initPTS=null,o._initDTS=null,o.nextVideoTs=null,o.nextAudioTs=null,o.videoSampleDuration=null,o.isAudioContiguous=!1,o.isVideoContiguous=!1,o.videoTrackConfig=void 0,o.observer=t,o.config=r,o.typeSupported=i,o.ISGenerated=!1,Ee===null){var l=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Ee=l?parseInt(l[1]):0}if(Hr===null){var u=navigator.userAgent.match(/Safari\/(\d+)/i);Hr=u?parseInt(u[1]):0}return o}ct(s,n);var e=s.prototype;return e.destroy=function(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null},e.resetTimeStamp=function(t){var r=this._initPTS;r&&t&&t.trackId===r.trackId&&t.baseTime===r.baseTime&&t.timescale===r.timescale||this.log("Reset initPTS: "+(r&&Va(r))+" > "+(t&&Va(t))),this._initPTS=this._initDTS=t},e.resetNextTimestamp=function(){this.log("reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},e.resetInitSegment=function(){this.log("ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0},e.getVideoStartPts=function(t){var r=!1,i=t[0].pts,a=t.reduce(function(o,l){var u=l.pts,d=u-o;return d<-4294967296&&(r=!0,d=(u=xt(u,i))-o),d>0?o:u},i);return r&&this.debug("PTS rollover detected"),a},e.remux=function(t,r,i,a,o,l,u,d){var h,c,f,v,g,m,p=o,y=o,T=t.pid>-1,S=r.pid>-1,b=r.samples.length,L=t.samples.length>0,R=u&&b>0||b>1;if((!T||L)&&(!S||R)||this.ISGenerated||u){if(this.ISGenerated){var k,C,A,D,_=this.videoTrackConfig;(_&&(r.width!==_.width||r.height!==_.height||((k=r.pixelRatio)==null?void 0:k[0])!==((C=_.pixelRatio)==null?void 0:C[0])||((A=r.pixelRatio)==null?void 0:A[1])!==((D=_.pixelRatio)==null?void 0:D[1]))||!_&&R||this.nextAudioTs===null&&L)&&this.resetInitSegment()}this.ISGenerated||(f=this.generateIS(t,r,o,l));var M,O=this.isVideoContiguous,P=-1;if(R&&(P=function(B){for(var V=0;V<B.length;V++)if(B[V].key)return V;return-1}(r.samples),!O&&this.config.forceKeyFrameOnDiscontinuity))if(m=!0,P>0){this.warn("Dropped "+P+" out of "+b+" video samples due to a missing keyframe");var w=this.getVideoStartPts(r.samples);r.samples=r.samples.slice(P),r.dropped+=P,M=y+=(r.samples[0].pts-w)/r.inputTimeScale}else P===-1&&(this.warn("No keyframe found out of "+b+" video samples"),m=!1);if(this.ISGenerated){if(L&&R){var x=this.getVideoStartPts(r.samples),N=(xt(t.samples[0].pts,x)-x)/r.inputTimeScale;p+=Math.max(0,N),y+=Math.max(0,-N)}if(L){if(t.samplerate||(this.warn("regenerate InitSegment as audio detected"),f=this.generateIS(t,r,o,l)),c=this.remuxAudio(t,p,this.isAudioContiguous,l,S||R||d===ge?y:void 0),R){var G=c?c.endPTS-c.startPTS:0;r.inputTimeScale||(this.warn("regenerate InitSegment as video detected"),f=this.generateIS(t,r,o,l)),h=this.remuxVideo(r,y,O,G)}}else R&&(h=this.remuxVideo(r,y,O,0));h&&(h.firstKeyFrame=P,h.independent=P!==-1,h.firstKeyFramePTS=M)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(g=Ka(i,o,this._initPTS,this._initDTS)),a.samples.length&&(v=Ya(a,o,this._initPTS))),{audio:c,video:h,initSegment:f,independent:m,text:v,id3:g}},e.computeInitPts=function(t,r,i,a){var o=Math.round(i*r),l=xt(t,o);if(l<o+r)for(this.log("Adjusting PTS for rollover in timeline near "+(o-l)/r+" "+a);l<o+r;)l+=8589934592;return l-o},e.generateIS=function(t,r,i,a){var o,l,u,d=t.samples,h=r.samples,c=this.typeSupported,f={},v=this._initPTS,g=!v||a,m="audio/mp4",p=-1;if(g&&(o=l=1/0),t.config&&d.length){switch(t.timescale=t.samplerate,t.segmentCodec){case"mp3":c.mpeg?(m="audio/mpeg",t.codec=""):c.mp3&&(t.codec="mp3");break;case"ac3":t.codec="ac-3"}f.audio={id:"audio",container:m,codec:t.codec,initSegment:t.segmentCodec==="mp3"&&c.mpeg?new Uint8Array(0):St.initSegment([t]),metadata:{channelCount:t.channelCount}},g&&(p=t.id,u=t.inputTimeScale,v&&u===v.timescale?g=!1:o=l=this.computeInitPts(d[0].pts,u,i,"audio"))}if(r.sps&&r.pps&&h.length){if(r.timescale=r.inputTimeScale,f.video={id:"main",container:"video/mp4",codec:r.codec,initSegment:St.initSegment([r]),metadata:{width:r.width,height:r.height}},g)if(p=r.id,u=r.inputTimeScale,v&&u===v.timescale)g=!1;else{var y=this.getVideoStartPts(h),T=xt(h[0].dts,y),S=this.computeInitPts(T,u,i,"video"),b=this.computeInitPts(y,u,i,"video");l=Math.min(l,S),o=Math.min(o,b)}this.videoTrackConfig={width:r.width,height:r.height,pixelRatio:r.pixelRatio}}if(Object.keys(f).length)return this.ISGenerated=!0,g?(v&&this.warn("Timestamps at playlist time: "+(a?"":"~")+i+" "+o/u+" != initPTS: "+v.baseTime/v.timescale+" ("+v.baseTime+"/"+v.timescale+") trackId: "+v.trackId),this.log("Found initPTS at playlist time: "+i+" offset: "+o/u+" ("+o+"/"+u+") trackId: "+p),this._initPTS={baseTime:o,timescale:u,trackId:p},this._initDTS={baseTime:l,timescale:u,trackId:p}):o=u=void 0,{tracks:f,initPTS:o,timescale:u,trackId:p}},e.remuxVideo=function(t,r,i,a){var o,l,u=t.inputTimeScale,d=t.samples,h=[],c=d.length,f=this._initPTS,v=f.baseTime*u/f.timescale,g=this.nextVideoTs,m=8,p=this.videoSampleDuration,y=Number.POSITIVE_INFINITY,T=Number.NEGATIVE_INFINITY,S=!1;if(!i||g===null){var b=v+r*u,L=d[0].pts-xt(d[0].dts,d[0].pts);Ee&&g!==null&&Math.abs(b-L-(g+v))<15e3?i=!0:g=b-L-v}for(var R=g+v,k=0;k<c;k++){var C=d[k];C.pts=xt(C.pts,R),C.dts=xt(C.dts,R),C.dts<d[k>0?k-1:k].dts&&(S=!0)}S&&d.sort(function(Ot,dr){var Wt=Ot.dts-dr.dts,Jr=Ot.pts-dr.pts;return Wt||Jr}),o=d[0].dts;var A=(l=d[d.length-1].dts)-o,D=A?Math.round(A/(c-1)):p||t.inputTimeScale/30;if(i){var _=o-R,M=_>D,O=_<-1;if((M||O)&&(M?this.warn((t.segmentCodec||"").toUpperCase()+": "+Ne(_)+" ms ("+_+"dts) hole between fragments detected at "+r.toFixed(3)):this.warn((t.segmentCodec||"").toUpperCase()+": "+Ne(-_)+" ms ("+_+"dts) overlapping between fragments detected at "+r.toFixed(3)),!O||R>=d[0].pts||Ee)){o=R;var P=d[0].pts-_;if(M)d[0].dts=o,d[0].pts=P;else for(var w=!0,x=0;x<d.length&&!(d[x].dts>P&&w);x++){var N=d[x].pts;if(d[x].dts-=_,d[x].pts-=_,x<d.length-1){var G=d[x+1].pts;w=G<=d[x].pts==G<=N}}this.log("Video: Initial PTS/DTS adjusted: "+Ne(P)+"/"+Ne(o)+", delta: "+Ne(_)+" ms")}}for(var B=0,V=0,st=o=Math.max(0,o),tt=0;tt<c;tt++){for(var $=d[tt],ot=$.units,rt=ot.length,K=0,Z=0;Z<rt;Z++)K+=ot[Z].data.length;V+=K,B+=rt,$.length=K,$.dts<st?($.dts=st,st+=D/4|0||1):st=$.dts,y=Math.min($.pts,y),T=Math.max($.pts,T)}l=d[c-1].dts;var Q,j=V+4*B+8;try{Q=new Uint8Array(j)}catch(Ot){return void this.observer.emit(E.ERROR,E.ERROR,{type:W.MUX_ERROR,details:I.REMUX_ALLOC_ERROR,fatal:!1,error:Ot,bytes:j,reason:"fail allocating video mdat "+j})}var at=new DataView(Q.buffer);at.setUint32(0,j),Q.set(St.types.mdat,4);for(var dt=!1,it=Number.POSITIVE_INFINITY,q=Number.POSITIVE_INFINITY,ht=Number.NEGATIVE_INFINITY,mt=Number.NEGATIVE_INFINITY,Y=0;Y<c;Y++){for(var lt=d[Y],Pt=lt.units,Rt=0,At=0,bt=Pt.length;At<bt;At++){var pt=Pt[At],kt=pt.data,Dt=pt.data.byteLength;at.setUint32(m,Dt),m+=4,Q.set(kt,m),m+=Dt,Rt+=4+Dt}var vt=void 0;if(Y<c-1)p=d[Y+1].dts-lt.dts,vt=d[Y+1].pts-lt.pts;else{var Yt=this.config,oe=Y>0?lt.dts-d[Y-1].dts:D;if(vt=Y>0?lt.pts-d[Y-1].pts:D,Yt.stretchShortVideoTrack&&this.nextAudioTs!==null){var Re=Math.floor(Yt.maxBufferHole*u),fe=(a?y+a*u:this.nextAudioTs+v)-lt.pts;fe>Re?((p=fe-oe)<0?p=oe:dt=!0,this.log("It is approximately "+fe/90+" ms to the next segment; using duration "+p/90+" ms for the last video frame.")):p=oe}else p=oe}var ce=Math.round(lt.pts-lt.dts);it=Math.min(it,p),ht=Math.max(ht,p),q=Math.min(q,vt),mt=Math.max(mt,vt),h.push(Ha(lt.key,p,Rt,ce))}if(h.length){if(Ee){if(Ee<70){var le=h[0].flags;le.dependsOn=2,le.isNonSync=0}}else if(Hr&&mt-q<ht-it&&D/ht<.025&&h[0].cts===0){this.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var ue=o,_t=0,z=h.length;_t<z;_t++){var ut=ue+h[_t].duration,ft=ue+h[_t].cts;if(_t<z-1){var Bt=ut+h[_t+1].cts;h[_t].duration=Bt-ft}else h[_t].duration=_t?h[_t-1].duration:D;h[_t].cts=0,ue=ut}}}var ur=l+(p=dt||!p?D:p);this.nextVideoTs=g=ur-v,this.videoSampleDuration=p,this.isVideoContiguous=!0;var He={data1:St.moof(t.sequenceNumber++,o,Et(t,{samples:h})),data2:Q,startPTS:(y-v)/u,endPTS:(T+p-v)/u,startDTS:(o-v)/u,endDTS:g/u,type:"video",hasAudio:!1,hasVideo:!0,nb:h.length,dropped:t.dropped};return t.samples=[],t.dropped=0,He},e.getSamplesPerFrame=function(t){switch(t.segmentCodec){case"mp3":return 1152;case"ac3":return 1536;default:return 1024}},e.remuxAudio=function(t,r,i,a,o){var l=t.inputTimeScale,u=l/(t.samplerate?t.samplerate:l),d=this.getSamplesPerFrame(t),h=d*u,c=this._initPTS,f=t.segmentCodec==="mp3"&&this.typeSupported.mpeg,v=[],g=o!==void 0,m=t.samples,p=f?0:8,y=this.nextAudioTs||-1,T=c.baseTime*l/c.timescale,S=T+r*l;if(this.isAudioContiguous=i=i||m.length&&y>0&&(a&&Math.abs(S-(y+T))<9e3||Math.abs(xt(m[0].pts,S)-(y+T))<20*h),m.forEach(function(it){it.pts=xt(it.pts,S)}),!i||y<0){var b=m.length;if(m=m.filter(function(it){return it.pts>=0}),b!==m.length&&this.warn("Removed "+(m.length-b)+" of "+b+" samples (initPTS "+T+" / "+l+")"),!m.length)return;y=o===0?0:a&&!g?Math.max(0,S-T):m[0].pts-T}if(t.segmentCodec==="aac")for(var L=this.config.maxAudioFramesDrift,R=0,k=y+T;R<m.length;R++){var C=m[R],A=C.pts,D=A-k,_=Math.abs(1e3*D/l);if(D<=-L*h&&g)R===0&&(this.warn("Audio frame @ "+(A/l).toFixed(3)+"s overlaps marker by "+Math.round(1e3*D/l)+" ms."),this.nextAudioTs=y=A-T,k=A);else if(D>=L*h&&_<1e4&&g){var M=Math.round(D/h);for(k=A-M*h;k<0&&M&&h;)M--,k+=h;R===0&&(this.nextAudioTs=y=k-T),this.warn("Injecting "+M+" audio frames @ "+((k-T)/l).toFixed(3)+"s due to "+Math.round(1e3*D/l)+" ms gap.");for(var O=0;O<M;O++){var P=Ds.getSilentFrame(t.parsedCodec||t.manifestCodec||t.codec,t.channelCount);P||(this.log("Unable to get silent frame for given audio codec; duplicating last frame instead."),P=C.unit.subarray()),m.splice(R,0,{unit:P,pts:k}),k+=h,R++}}C.pts=k,k+=h}for(var w,x=null,N=null,G=0,B=m.length;B--;)G+=m[B].unit.byteLength;for(var V=0,st=m.length;V<st;V++){var tt=m[V],$=tt.unit,ot=tt.pts;if(N!==null)v[V-1].duration=Math.round((ot-N)/u);else{if(i&&t.segmentCodec==="aac"&&(ot=y+T),x=ot,!(G>0))return;G+=p;try{w=new Uint8Array(G)}catch(it){return void this.observer.emit(E.ERROR,E.ERROR,{type:W.MUX_ERROR,details:I.REMUX_ALLOC_ERROR,fatal:!1,error:it,bytes:G,reason:"fail allocating audio mdat "+G})}f||(new DataView(w.buffer).setUint32(0,G),w.set(St.types.mdat,4))}w.set($,p);var rt=$.byteLength;p+=rt,v.push(Ha(!0,d,rt,0)),N=ot}var K=v.length;if(K){var Z=v[v.length-1];y=N-T,this.nextAudioTs=y+u*Z.duration;var Q=f?new Uint8Array(0):St.moof(t.sequenceNumber++,x/u,Et({},t,{samples:v}));t.samples=[];var j=(x-T)/l,at=y/l,dt={data1:Q,data2:w,startPTS:j,endPTS:at,startDTS:j,endDTS:at,type:"audio",hasAudio:!0,hasVideo:!1,nb:K};return this.isAudioContiguous=!0,dt}},s}(Xt);function xt(n,s){var e;if(s===null)return n;for(e=s<n?-8589934592:8589934592;Math.abs(n-s)>4294967296;)n+=e;return n}function Ka(n,s,e,t){var r=n.samples.length;if(r){for(var i=n.inputTimeScale,a=0;a<r;a++){var o=n.samples[a];o.pts=xt(o.pts-e.baseTime*i/e.timescale,s*i)/i,o.dts=xt(o.dts-t.baseTime*i/t.timescale,s*i)/i}var l=n.samples;return n.samples=[],{samples:l}}}function Ya(n,s,e){var t=n.samples.length;if(t){for(var r=n.inputTimeScale,i=0;i<t;i++){var a=n.samples[i];a.pts=xt(a.pts-e.baseTime*r/e.timescale,s*r)/r}n.samples.sort(function(l,u){return l.pts-u.pts});var o=n.samples;return n.samples=[],{samples:o}}}var Zt,_s=function(n){function s(t,r,i,a){var o;return(o=n.call(this,"passthrough-remuxer",a)||this).emitInitSegment=!1,o.audioCodec=void 0,o.videoCodec=void 0,o.initData=void 0,o.initPTS=null,o.initTracks=void 0,o.lastEndTime=null,o.isVideoContiguous=!1,o}ct(s,n);var e=s.prototype;return e.destroy=function(){},e.resetTimeStamp=function(t){this.lastEndTime=null;var r=this.initPTS;r&&t&&r.baseTime===t.baseTime&&r.timescale===t.timescale||(this.initPTS=t)},e.resetNextTimestamp=function(){this.isVideoContiguous=!1,this.lastEndTime=null},e.resetInitSegment=function(t,r,i,a){this.audioCodec=r,this.videoCodec=i,this.generateInitSegment(t,a),this.emitInitSegment=!0},e.generateInitSegment=function(t,r){var i=this.audioCodec,a=this.videoCodec;if(t==null||!t.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var o=this.initData=Li(t),l=o.audio,u=o.video;if(r)(function(c,f){if(c&&f){var v=f.keyId;v&&f.isCommonEncryption&&Ri(c,function(g,m){var p=g.subarray(8,24);p.some(function(y){return y!==0})||(nt.log("[eme] Patching keyId in 'enc"+(m?"a":"v")+">sinf>>tenc' box: "+Ie(p)+" -> "+Ie(v)),g.set(v,8))})}})(t,r);else{var d=l||u;d!=null&&d.encrypted&&this.warn('Init segment with encrypted track with has no key ("'+d.codec+'")!')}l&&(i=Wa(l,Ut,this)),u&&(a=Wa(u,Qt,this));var h={};l&&u?h.audiovideo={container:"video/mp4",codec:i+","+a,supplemental:u.supplemental,encrypted:u.encrypted,initSegment:t,id:"main"}:l?h.audio={container:"audio/mp4",codec:i,encrypted:l.encrypted,initSegment:t,id:"audio"}:u?h.video={container:"video/mp4",codec:a,supplemental:u.supplemental,encrypted:u.encrypted,initSegment:t,id:"main"}:this.warn("initSegment does not contain moov or trak boxes."),this.initTracks=h},e.remux=function(t,r,i,a,o,l){var u,d,h=this.initPTS,c=this.lastEndTime,f={audio:void 0,video:void 0,text:a,id3:i,initSegment:void 0};U(c)||(c=this.lastEndTime=o||0);var v=r.samples;if(!v.length)return f;var g={initPTS:void 0,timescale:void 0,trackId:void 0},m=this.initData;if((u=m)!=null&&u.length||(this.generateInitSegment(v),m=this.initData),(d=m)==null||!d.length)return this.warn("Failed to generate initSegment."),f;this.emitInitSegment&&(g.tracks=this.initTracks,this.emitInitSegment=!1);var p=function($,ot,rt){for(var K={},Z=X($,["moof","traf"]),Q=0;Q<Z.length;Q++){var j=Z[Q],at=X(j,["tfhd"])[0],dt=H(at,4),it=ot[dt];if(it){K[dt]||(K[dt]={start:NaN,duration:0,sampleCount:0,timescale:it.timescale,type:it.type});var q=K[dt],ht=X(j,["tfdt"])[0];if(ht){var mt=ht[0],Y=H(ht,4);mt===1&&(Y===pi?rt.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"):(Y*=pi+1,Y+=H(ht,8))),U(Y)&&(!U(q.start)||Y<q.start)&&(q.start=Y)}var lt=it.default,Pt=H(at,0)|lt?.flags,Rt=lt?.duration||0;8&Pt&&(Rt=H(at,2&Pt?12:8));for(var At=X(j,["trun"]),bt=q.start||0,pt=0,kt=Rt,Dt=0;Dt<At.length;Dt++){var vt=At[Dt],Yt=H(vt,4),oe=q.sampleCount;q.sampleCount+=Yt;var Re=1&vt[3],fe=4&vt[3],ce=1&vt[2],le=2&vt[2],ue=4&vt[2],_t=8&vt[2],z=8,ut=Yt;for(Re&&(z+=4),fe&&Yt&&(1&vt[z+1]||q.keyFrameIndex!==void 0||(q.keyFrameIndex=oe),z+=4,ce?(kt=H(vt,z),z+=4):kt=Rt,le&&(z+=4),_t&&(z+=4),bt+=kt,pt+=kt,ut--);ut--;)ce?(kt=H(vt,z),z+=4):kt=Rt,le&&(z+=4),ue&&(1&vt[z+1]||q.keyFrameIndex===void 0&&(q.keyFrameIndex=q.sampleCount-(ut+1),q.keyFrameStart=bt),z+=4),_t&&(z+=4),bt+=kt,pt+=kt;!pt&&Rt&&(pt+=Rt*Yt)}q.duration+=pt}}if(!Object.keys(K).some(function(Wt){return K[Wt].duration})){for(var ft=1/0,Bt=0,ur=X($,["sidx"]),He=0;He<ur.length;He++){var Ot=In(ur[He]);if(Ot!=null&&Ot.references){ft=Math.min(ft,Ot.earliestPresentationTime/Ot.timescale);var dr=Ot.references.reduce(function(Wt,Jr){return Wt+Jr.info.duration||0},0);Bt=Math.max(Bt,dr+Ot.earliestPresentationTime/Ot.timescale)}}Bt&&U(Bt)&&Object.keys(K).forEach(function(Wt){K[Wt].duration||(K[Wt].duration=Bt*K[Wt].timescale-K[Wt].start)})}return K}(v,m,this),y=m.audio?p[m.audio.id]:null,T=m.video?p[m.video.id]:null,S=nr(T,1/0),b=nr(y,1/0),L=nr(T,0,!0),R=nr(y,0,!0),k=o,C=0,A=y&&(!T||!h&&b<S||h&&h.trackId===m.audio.id),D=A?y:T;if(D){var _=D.timescale,M=D.start-o*_,O=A?m.audio.id:m.video.id;k=D.start/_,C=A?R-b:L-S,!l&&h||!function($,ot,rt,K){if($===null)return!0;var Z=Math.max(K,1),Q=ot-$.baseTime/$.timescale;return Math.abs(Q-rt)>Z}(h,k,o,C)&&_===h.timescale||(h&&this.warn("Timestamps at playlist time: "+(l?"":"~")+o+" "+M/_+" != initPTS: "+h.baseTime/h.timescale+" ("+h.baseTime+"/"+h.timescale+") trackId: "+h.trackId),this.log("Found initPTS at playlist time: "+o+" offset: "+(k-o)+" ("+M+"/"+_+") trackId: "+O),h=null,g.initPTS=M,g.timescale=_,g.trackId=O)}else this.warn("No audio or video samples found for initPTS at playlist time: "+o);h?(g.initPTS=h.baseTime,g.timescale=h.timescale,g.trackId=h.trackId):(g.timescale&&g.trackId!==void 0&&g.initPTS!==void 0||(this.warn("Could not set initPTS"),g.initPTS=k,g.timescale=1,g.trackId=-1),this.initPTS=h={baseTime:g.initPTS,timescale:g.timescale,trackId:g.trackId});var P=k-h.baseTime/h.timescale,w=P+C;C>0?this.lastEndTime=w:(this.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var x=!!m.audio,N=!!m.video,G="";x&&(G+="audio"),N&&(G+="video");var B={data1:v,startPTS:P,startDTS:P,endPTS:w,endDTS:w,type:G,hasAudio:x,hasVideo:N,nb:1,dropped:0,encrypted:!!m.audio&&m.audio.encrypted||!!m.video&&m.video.encrypted};f.audio=x&&!N?B:void 0,f.video=N?B:void 0;var V=T?.sampleCount;if(V){var st=T.keyFrameIndex,tt=st!==-1;B.nb=V,B.dropped=st===0||this.isVideoContiguous?0:tt?st:V,B.independent=tt,B.firstKeyFrame=st,tt&&T.keyFrameStart&&(B.firstKeyFramePTS=(T.keyFrameStart-h.baseTime)/h.timescale),this.isVideoContiguous||(f.independent=tt),this.isVideoContiguous||(this.isVideoContiguous=tt),B.dropped&&this.warn("fmp4 does not start with IDR: firstIDR "+st+"/"+V+" dropped: "+B.dropped+" start: "+(B.firstKeyFramePTS||"NA"))}return f.initSegment=g,f.id3=Ka(i,o,h,h),a.samples.length&&(f.text=Ya(a,o,h)),f},s}(Xt);function nr(n,s,e){return e===void 0&&(e=!1),n?.start!==void 0?(n.start+(e?n.duration:0))/n.timescale:s}function Wa(n,s,e){var t=n.codec;return t&&t.length>4?t:s===Ut?t==="ec-3"||t==="ac-3"||t==="alac"?t:t==="fLaC"||t==="Opus"?je(t,!1):(e.warn('Unhandled audio codec "'+t+'" in mp4 MAP'),t||"mp4a"):(e.warn('Unhandled video codec "'+t+'" in mp4 MAP'),t||"avc1")}try{Zt=self.performance.now.bind(self.performance)}catch{Zt=Date.now}var Yr=[{demux:Ts,remux:_s},{demux:As,remux:Kr},{demux:vs,remux:Kr},{demux:gs,remux:Kr}],Wr=function(){function n(e,t,r,i,a,o){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=r,this.id=a,this.logger=o}var s=n.prototype;return s.configure=function(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()},s.push=function(e,t,r,i){var a=this,o=r.transmuxing;o.executeStart=Zt();var l=new Uint8Array(e),u=this.currentTransmuxState,d=this.transmuxConfig;i&&(this.currentTransmuxState=i);var h=i||u,c=h.contiguous,f=h.discontinuity,v=h.trackSwitch,g=h.accurateTimeOffset,m=h.timeOffset,p=h.initSegmentChange,y=d.audioCodec,T=d.videoCodec,S=d.defaultInitPts,b=d.duration,L=d.initSegmentData,R=function(w,x){var N=null;return w.byteLength>0&&x?.key!=null&&x.iv!==null&&x.method!=null&&(N=x),N}(l,t);if(R&&Fe(R.method)){var k=this.getDecrypter(),C=ea(R.method);if(!k.isSync())return this.asyncResult=!0,this.decryptionPromise=k.webCryptoDecrypt(l,R.key.buffer,R.iv.buffer,C).then(function(w){var x=a.push(w,null,r);return a.decryptionPromise=null,x}),this.decryptionPromise;var A=k.softwareDecrypt(l,R.key.buffer,R.iv.buffer,C);if(r.part>-1){var D=k.flush();A=D&&D.buffer}if(!A)return o.executeEnd=Zt(),jr(r);l=new Uint8Array(A)}var _=this.needsProbing(f,v);if(_){var M=this.configureTransmuxer(l);if(M)return this.logger.warn("[transmuxer] "+M.message),this.observer.emit(E.ERROR,E.ERROR,{type:W.MEDIA_ERROR,details:I.FRAG_PARSING_ERROR,fatal:!1,error:M,reason:M.message}),o.executeEnd=Zt(),jr(r)}(f||v||p||_)&&this.resetInitSegment(L,y,T,b,t),(f||p||_)&&this.resetInitialTimestamp(S),c||this.resetContiguity();var O=this.transmux(l,R,m,g,r);this.asyncResult=de(O);var P=this.currentTransmuxState;return P.contiguous=!0,P.discontinuity=!1,P.trackSwitch=!1,o.executeEnd=Zt(),O},s.flush=function(e){var t=this,r=e.transmuxing;r.executeStart=Zt();var i=this.decrypter,a=this.currentTransmuxState,o=this.decryptionPromise;if(o)return this.asyncResult=!0,o.then(function(){return t.flush(e)});var l=[],u=a.timeOffset;if(i){var d=i.flush();d&&l.push(this.push(d.buffer,null,e))}var h=this.demuxer,c=this.remuxer;if(!h||!c){r.executeEnd=Zt();var f=[jr(e)];return this.asyncResult?Promise.resolve(f):f}var v=h.flush(u);return de(v)?(this.asyncResult=!0,v.then(function(g){return t.flushRemux(l,g,e),l})):(this.flushRemux(l,v,e),this.asyncResult?Promise.resolve(l):l)},s.flushRemux=function(e,t,r){var i=t.audioTrack,a=t.videoTrack,o=t.id3Track,l=t.textTrack,u=this.currentTransmuxState,d=u.accurateTimeOffset,h=u.timeOffset;this.logger.log("[transmuxer.ts]: Flushed "+this.id+" sn: "+r.sn+(r.part>-1?" part: "+r.part:"")+" of "+(this.id===J?"level":"track")+" "+r.level);var c=this.remuxer.remux(i,a,o,l,h,d,!0,this.id);e.push({remuxResult:c,chunkMeta:r}),r.transmuxing.executeEnd=Zt()},s.resetInitialTimestamp=function(e){var t=this.demuxer,r=this.remuxer;t&&r&&(t.resetTimeStamp(e),r.resetTimeStamp(e))},s.resetContiguity=function(){var e=this.demuxer,t=this.remuxer;e&&t&&(e.resetContiguity(),t.resetNextTimestamp())},s.resetInitSegment=function(e,t,r,i,a){var o=this.demuxer,l=this.remuxer;o&&l&&(o.resetInitSegment(e,t,r,i),l.resetInitSegment(e,t,r,a))},s.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},s.transmux=function(e,t,r,i,a){return t&&t.method==="SAMPLE-AES"?this.transmuxSampleAes(e,t,r,i,a):this.transmuxUnencrypted(e,r,i,a)},s.transmuxUnencrypted=function(e,t,r,i){var a=this.demuxer.demux(e,t,!1,!this.config.progressive),o=a.audioTrack,l=a.videoTrack,u=a.id3Track,d=a.textTrack;return{remuxResult:this.remuxer.remux(o,l,u,d,t,r,!1,this.id),chunkMeta:i}},s.transmuxSampleAes=function(e,t,r,i,a){var o=this;return this.demuxer.demuxSampleAes(e,t,r).then(function(l){return{remuxResult:o.remuxer.remux(l.audioTrack,l.videoTrack,l.id3Track,l.textTrack,r,i,!1,o.id),chunkMeta:a}})},s.configureTransmuxer=function(e){for(var t,r=this.config,i=this.observer,a=this.typeSupported,o=0,l=Yr.length;o<l;o++){var u;if((u=Yr[o].demux)!=null&&u.probe(e,this.logger)){t=Yr[o];break}}if(!t)return new Error("Failed to find demuxer by probing fragment data");var d=this.demuxer,h=this.remuxer,c=t.remux,f=t.demux;h&&h instanceof c||(this.remuxer=new c(i,r,a,this.logger)),d&&d instanceof f||(this.demuxer=new f(i,r,a,this.logger),this.probe=f.probe)},s.needsProbing=function(e,t){return!this.demuxer||!this.remuxer||e||t},s.getDecrypter=function(){var e=this.decrypter;return e||(e=this.decrypter=new Ur(this.config)),e},n}(),jr=function(n){return{remuxResult:{},chunkMeta:n}};function de(n){return"then"in n&&n.then instanceof Function}var Is=function(n,s,e,t,r){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=n,this.videoCodec=s,this.initSegmentData=e,this.duration=t,this.defaultInitPts=r||null},Cs=function(n,s,e,t,r,i){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=n,this.contiguous=s,this.accurateTimeOffset=e,this.trackSwitch=t,this.timeOffset=r,this.initSegmentChange=i},Ps=/(\d+)-(\d+)\/(\d+)/,ja=function(){function n(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||ws,this.controller=new self.AbortController,this.stats=new pr}var s=n.prototype;return s.destroy=function(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null},s.abortInternal=function(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())},s.abort=function(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},s.load=function(e,t,r){var i=this,a=this.stats;if(a.loading.start)throw new Error("Loader can only be used once.");a.loading.start=self.performance.now();var o=function(f,v){var g={method:"GET",mode:"cors",credentials:"same-origin",signal:v,headers:new self.Headers(Et({},f.headers))};return f.rangeEnd&&g.headers.set("Range","bytes="+f.rangeStart+"-"+String(f.rangeEnd-1)),g}(e,this.controller.signal),l=e.responseType==="arraybuffer",u=l?"byteLength":"length",d=t.loadPolicy,h=d.maxTimeToFirstByteMs,c=d.maxLoadTimeMs;this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,o),self.clearTimeout(this.requestTimeout),t.timeout=h&&U(h)?h:c,this.requestTimeout=self.setTimeout(function(){i.callbacks&&(i.abortInternal(),i.callbacks.onTimeout(a,e,i.response))},t.timeout),(de(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then(function(f){var v;i.response=i.loader=f;var g=Math.max(self.performance.now(),a.loading.start);if(self.clearTimeout(i.requestTimeout),t.timeout=c,i.requestTimeout=self.setTimeout(function(){i.callbacks&&(i.abortInternal(),i.callbacks.onTimeout(a,e,i.response))},c-(g-a.loading.start)),!f.ok){var m=f.status,p=f.statusText;throw new xs(p||"fetch, bad network response",m,f)}a.loading.first=g,a.total=function(T){var S=T.get("Content-Range");if(S){var b=function(R){var k=Ps.exec(R);if(k)return parseInt(k[2])-parseInt(k[1])+1}(S);if(U(b))return b}var L=T.get("Content-Length");if(L)return parseInt(L)}(f.headers)||a.total;var y=(v=i.callbacks)==null?void 0:v.onProgress;return y&&U(t.highWaterMark)?i.loadProgressively(f,a,e,t.highWaterMark,y):l?f.arrayBuffer():e.responseType==="json"?f.json():f.text()}).then(function(f){var v,g,m=i.response;if(!m)throw new Error("loader destroyed");self.clearTimeout(i.requestTimeout),a.loading.end=Math.max(self.performance.now(),a.loading.first);var p=f[u];p&&(a.loaded=a.total=p);var y={url:m.url,data:f,code:m.status},T=(v=i.callbacks)==null?void 0:v.onProgress;T&&!U(t.highWaterMark)&&T(a,e,f,m),(g=i.callbacks)==null||g.onSuccess(y,a,e,m)}).catch(function(f){var v;if(self.clearTimeout(i.requestTimeout),!a.aborted){var g=f&&f.code||0,m=f?f.message:null;(v=i.callbacks)==null||v.onError({code:g,text:m},e,f?f.details:null,a)}})},s.getCacheAge=function(){var e=null;if(this.response){var t=this.response.headers.get("age");e=t?parseFloat(t):null}return e},s.getResponseHeader=function(e){return this.response?this.response.headers.get(e):null},s.loadProgressively=function(e,t,r,i,a){i===void 0&&(i=0);var o=new es,l=e.body.getReader(),u=function(){return l.read().then(function(d){if(d.done)return o.dataLength&&a(t,r,o.flush().buffer,e),Promise.resolve(new ArrayBuffer(0));var h=d.value,c=h.length;return t.loaded+=c,c<i||o.dataLength?(o.push(h),o.dataLength>=i&&a(t,r,o.flush().buffer,e)):a(t,r,h.buffer,e),u()}).catch(function(){return Promise.reject()})};return u()},n}();function ws(n,s){return new self.Request(n.url,s)}var xs=function(n){function s(e,t,r){var i;return(i=n.call(this,e)||this).code=void 0,i.details=void 0,i.code=t,i.details=r,i}return ct(s,n),s}(De(Error)),Os=/^age:\s*[\d.]+\s*$/im,qa=function(){function n(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 pr,this.retryDelay=0}var s=n.prototype;return s.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null},s.abortInternal=function(){var 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()))},s.abort=function(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},s.load=function(e,t,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=r,this.loadInternal()},s.loadInternal=function(){var e=this,t=this.config,r=this.context;if(t&&r){var i=this.loader=new self.XMLHttpRequest,a=this.stats;a.loading.first=0,a.loaded=0,a.aborted=!1;var o=this.xhrSetup;o?Promise.resolve().then(function(){if(e.loader===i&&!e.stats.aborted)return o(i,r.url)}).catch(function(l){if(e.loader===i&&!e.stats.aborted)return i.open("GET",r.url,!0),o(i,r.url)}).then(function(){e.loader!==i||e.stats.aborted||e.openAndSendXhr(i,r,t)}).catch(function(l){var u;(u=e.callbacks)==null||u.onError({code:i.status,text:l.message},r,i,a)}):this.openAndSendXhr(i,r,t)}},s.openAndSendXhr=function(e,t,r){e.readyState||e.open("GET",t.url,!0);var i=t.headers,a=r.loadPolicy,o=a.maxTimeToFirstByteMs,l=a.maxLoadTimeMs;if(i)for(var u in i)e.setRequestHeader(u,i[u]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),r.timeout=o&&U(o)?o:l,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),e.send()},s.readystatechange=function(){var e=this.context,t=this.loader,r=this.stats;if(e&&t){var i=t.readyState,a=this.config;if(!r.aborted&&i>=2&&(r.loading.first===0&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),a.timeout!==a.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),a.timeout=a.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),a.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start)))),i===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;var o=t.status,l=t.responseType==="text"?t.responseText:null;if(o>=200&&o<300){var u=l??t.response;if(u!=null){var d,h;r.loading.end=Math.max(self.performance.now(),r.loading.first);var c=t.responseType==="arraybuffer"?u.byteLength:u.length;r.loaded=r.total=c,r.bwEstimate=8e3*r.total/(r.loading.end-r.loading.first);var f=(d=this.callbacks)==null?void 0:d.onProgress;f&&f(r,e,u,t);var v={url:t.responseURL,data:u,code:o};return void((h=this.callbacks)==null||h.onSuccess(v,r,e,t))}}var g,m=a.loadPolicy.errorRetry;Qe(m,r.retry,!1,{url:e.url,data:void 0,code:o})?this.retry(m):(nt.error(o+" while loading "+e.url),(g=this.callbacks)==null||g.onError({code:o,text:t.statusText},e,t,r))}}},s.loadtimeout=function(){if(this.config){var e=this.config.loadPolicy.timeoutRetry;if(Qe(e,this.stats.retry,!0))this.retry(e);else{var t;nt.warn("timeout while loading "+((t=this.context)==null?void 0:t.url));var r=this.callbacks;r&&(this.abortInternal(),r.onTimeout(this.stats,this.context,this.loader))}}},s.retry=function(e){var t=this.context,r=this.stats;this.retryDelay=_r(e,r.retry),r.retry++,nt.warn((status?"HTTP Status "+status:"Timeout")+" while loading "+t?.url+", retrying "+r.retry+"/"+e.maxNumRetry+" in "+this.retryDelay+"ms"),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)},s.loadprogress=function(e){var t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)},s.getCacheAge=function(){var e=null;if(this.loader&&Os.test(this.loader.getAllResponseHeaders())){var t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e},s.getResponseHeader=function(e){return this.loader&&new RegExp("^"+e+":\\s*[\\d.]+\\s*$","im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null},n}(),za={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},Fs=wt(wt({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:6e7,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:qa,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:Nn,bufferController:Kn,capLevelController:Yn,errorController:Vn,fpsController:ts,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:null,requireKeySystemAccessOnStart:!1,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableEmsgKLVMetadata:!1,enableID3MetadataCues:!0,enableInterstitialPlayback:!1,interstitialAppendInPlace:!0,interstitialLiveLookAhead:10,useMediaCapabilities:!1,preserveManualLevelOnError:!1,certLoadPolicy:{default:za},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:za},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},{cueHandler:kn,enableWebVTT:!1,enableIMSC1:!1,enableCEA708Captions:!1,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:void 0,subtitleTrackController:void 0,timelineController:void 0,audioStreamController:void 0,audioTrackController:void 0,emeController:void 0,cmcdController:void 0,contentSteeringController:Jn,interstitialsController:void 0});function qr(n){return n&&typeof n=="object"?Array.isArray(n)?n.map(qr):Object.keys(n).reduce(function(s,e){return s[e]=qr(n[e]),s},{}):n}function Ms(n,s){var e=n.loader;e!==ja&&e!==qa?(s.log("[config]: Custom loader detected, cannot enable progressive streaming"),n.progressive=!1):function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}()&&(n.loader=ja,n.progressive=!0,n.enableSoftwareAES=!0,s.log("[config]: Progressive streaming enabled, using FetchLoader"))}var Xa="NOT_LOADED",Qa="APPENDING",Be="PARTIAL",Ue="OK",Ns=function(){function n(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()}var s=n.prototype;return s._registerListeners=function(){var e=this.hls;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))},s._unregisterListeners=function(){var e=this.hls;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))},s.destroy=function(){this._unregisterListeners(),this.hls=this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null},s.getAppendedFrag=function(e,t){var r=this.activePartLists[t];if(r)for(var i=r.length;i--;){var a=r[i];if(!a)break;if(a.start<=e&&e<=a.end&&a.loaded)return a}return this.getBufferedFrag(e,t)},s.getBufferedFrag=function(e,t){return this.getFragAtPos(e,t,!0)},s.getFragAtPos=function(e,t,r){for(var i=this.fragments,a=Object.keys(i),o=a.length;o--;){var l=i[a[o]];if(l?.body.type===t&&(!r||l.buffered)){var u=l.body;if(u.start<=e&&e<=u.end)return u}}return null},s.detectEvictedFragments=function(e,t,r,i,a){var o=this;this.timeRanges&&(this.timeRanges[e]=t);var l=i?.fragment.sn||-1;Object.keys(this.fragments).forEach(function(u){var d=o.fragments[u];if(d&&!(l>=d.body.sn))if(d.buffered||d.loaded&&!a){var h=d.range[e];h&&(h.time.length!==0?h.time.some(function(c){var f=!o.isTimeBuffered(c.startPTS,c.endPTS,t);return f&&o.removeFragment(d.body),f}):o.removeFragment(d.body))}else d.body.type===r&&o.removeFragment(d.body)})},s.detectPartialFragments=function(e){var t=this,r=this.timeRanges;if(r&&e.frag.sn!=="initSegment"){var i=e.frag,a=Te(i),o=this.fragments[a];if(!(!o||o.buffered&&i.gap)){var l=!i.relurl;Object.keys(r).forEach(function(u){var d=i.elementaryStreams[u];if(d){var h=r[u],c=l||d.partial===!0;o.range[u]=t.getBufferedTimes(i,e.part,c,h)}}),o.loaded=null,Object.keys(o.range).length?(o.buffered=!0,(o.body.endList=i.endList||o.body.endList)&&(this.endListFragments[o.body.type]=o),sr(o)||this.removeParts(i.sn-1,i.type)):this.removeFragment(o.body)}}},s.removeParts=function(e,t){var r=this.activePartLists[t];r&&(this.activePartLists[t]=$a(r,function(i){return i.fragment.sn>=e}))},s.fragBuffered=function(e,t){var r=Te(e),i=this.fragments[r];!i&&t&&(i=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),i&&(i.loaded=null,i.buffered=!0)},s.getBufferedTimes=function(e,t,r,i){for(var a={time:[],partial:r},o=e.start,l=e.end,u=e.minEndPTS||l,d=e.maxStartPTS||o,h=0;h<i.length;h++){var c=i.start(h)-this.bufferPadding,f=i.end(h)+this.bufferPadding;if(d>=c&&u<=f){a.time.push({startPTS:Math.max(o,i.start(h)),endPTS:Math.min(l,i.end(h))});break}if(o<f&&l>c){var v=Math.max(o,i.start(h)),g=Math.min(l,i.end(h));g>v&&(a.partial=!0,a.time.push({startPTS:v,endPTS:g}))}else if(l<=c)break}return a},s.getPartialFragment=function(e){var t,r,i,a=null,o=0,l=this.bufferPadding,u=this.fragments;return Object.keys(u).forEach(function(d){var h=u[d];h&&sr(h)&&(r=h.body.start-l,i=h.body.end+l,e>=r&&e<=i&&(t=Math.min(e-r,i-e),o<=t&&(a=h.body,o=t)))}),a},s.isEndListAppended=function(e){var t=this.endListFragments[e];return t!==void 0&&(t.buffered||sr(t))},s.getState=function(e){var t=Te(e),r=this.fragments[t];return r?r.buffered?sr(r)?Be:Ue:Qa:Xa},s.isTimeBuffered=function(e,t,r){for(var i,a,o=0;o<r.length;o++){if(i=r.start(o)-this.bufferPadding,a=r.end(o)+this.bufferPadding,e>=i&&t<=a)return!0;if(t<=i)return!1}return!1},s.onManifestLoading=function(){this.removeAllFragments()},s.onFragLoaded=function(e,t){if(t.frag.sn!=="initSegment"&&!t.frag.bitrateTest){var r=t.frag,i=t.part?null:t,a=Te(r);this.fragments[a]={body:r,appendedPTS:null,loaded:i,buffered:!1,range:Object.create(null)}}},s.onBufferAppended=function(e,t){var r=t.frag,i=t.part,a=t.timeRanges,o=t.type;if(r.sn!=="initSegment"){var l=r.type;if(i){var u=this.activePartLists[l];u||(this.activePartLists[l]=u=[]),u.push(i)}this.timeRanges=a;var d=a[o];this.detectEvictedFragments(o,d,l,i)}},s.onFragBuffered=function(e,t){this.detectPartialFragments(t)},s.hasFragment=function(e){var t=Te(e);return!!this.fragments[t]},s.hasFragments=function(e){var t=this.fragments,r=Object.keys(t);if(!e)return r.length>0;for(var i=r.length;i--;){var a=t[r[i]];if(a?.body.type===e)return!0}return!1},s.hasParts=function(e){var t;return!((t=this.activePartLists[e])==null||!t.length)},s.removeFragmentsInRange=function(e,t,r,i,a){var o=this;i&&!this.hasGaps||Object.keys(this.fragments).forEach(function(l){var u=o.fragments[l];if(u){var d=u.body;d.type!==r||i&&!d.gap||d.start<t&&d.end>e&&(u.buffered||a)&&o.removeFragment(d)}})},s.removeFragment=function(e){var t=Te(e);e.clearElementaryStreamInfo();var r=this.activePartLists[e.type];if(r){var i=e.sn;this.activePartLists[e.type]=$a(r,function(a){return a.fragment.sn!==i})}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]},s.removeAllFragments=function(){var e;this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1;var t=(e=this.hls)==null||(e=e.latestLevelDetails)==null?void 0:e.partList;t&&t.forEach(function(r){return r.clearElementaryStreamInfo()})},n}();function sr(n){var s,e,t;return n.buffered&&!!(n.body.gap||(s=n.range.video)!=null&&s.partial||(e=n.range.audio)!=null&&e.partial||(t=n.range.audiovideo)!=null&&t.partial)}function Te(n){return n.type+"_"+n.level+"_"+n.sn}function $a(n,s){return n.filter(function(e){var t=s(e);return t||e.clearElementaryStreamInfo(),t})}var Za=Math.pow(2,17),Bs=function(){function n(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}var s=n.prototype;return s.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},s.abort=function(){this.loader&&this.loader.abort()},s.load=function(e,t){var r=this,i=e.url;if(!i)return Promise.reject(new Jt({type:W.NETWORK_ERROR,details:I.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error("Fragment does not have a "+(i?"part list":"url")),networkDetails:null}));this.abort();var a=this.config,o=a.fLoader,l=a.loader;return new Promise(function(u,d){if(r.loader&&r.loader.destroy(),e.gap){if(e.tagList.some(function(m){return m[0]==="GAP"}))return void d(tn(e));e.gap=!1}var h=r.loader=o?new o(a):new l(a),c=Ja(e);e.loader=h;var f=Ki(a.fragLoadPolicy.default),v={loadPolicy:f,timeout:f.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:Za};e.stats=h.stats;var g={onSuccess:function(m,p,y,T){r.resetLoader(e,h);var S=m.data;y.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(S.slice(0,16)),S=S.slice(16)),u({frag:e,part:null,payload:S,networkDetails:T})},onError:function(m,p,y,T){r.resetLoader(e,h),d(new Jt({type:W.NETWORK_ERROR,details:I.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:wt({url:i,data:void 0},m),error:new Error("HTTP Error "+m.code+" "+m.text),networkDetails:y,stats:T}))},onAbort:function(m,p,y){r.resetLoader(e,h),d(new Jt({type:W.NETWORK_ERROR,details:I.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:y,stats:m}))},onTimeout:function(m,p,y){r.resetLoader(e,h),d(new Jt({type:W.NETWORK_ERROR,details:I.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error("Timeout after "+v.timeout+"ms"),networkDetails:y,stats:m}))}};t&&(g.onProgress=function(m,p,y,T){return t({frag:e,part:null,payload:y,networkDetails:T})}),h.load(c,v,g)})},s.loadPart=function(e,t,r){var i=this;this.abort();var a=this.config,o=a.fLoader,l=a.loader;return new Promise(function(u,d){if(i.loader&&i.loader.destroy(),e.gap||t.gap)d(tn(e,t));else{var h=i.loader=o?new o(a):new l(a),c=Ja(e,t);e.loader=h;var f=Ki(a.fragLoadPolicy.default),v={loadPolicy:f,timeout:f.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:Za};t.stats=h.stats,h.load(c,v,{onSuccess:function(g,m,p,y){i.resetLoader(e,h),i.updateStatsFromPart(e,t);var T={frag:e,part:t,payload:g.data,networkDetails:y};r(T),u(T)},onError:function(g,m,p,y){i.resetLoader(e,h),d(new Jt({type:W.NETWORK_ERROR,details:I.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:wt({url:c.url,data:void 0},g),error:new Error("HTTP Error "+g.code+" "+g.text),networkDetails:p,stats:y}))},onAbort:function(g,m,p){e.stats.aborted=t.stats.aborted,i.resetLoader(e,h),d(new Jt({type:W.NETWORK_ERROR,details:I.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:p,stats:g}))},onTimeout:function(g,m,p){i.resetLoader(e,h),d(new Jt({type:W.NETWORK_ERROR,details:I.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error("Timeout after "+v.timeout+"ms"),networkDetails:p,stats:g}))}})}})},s.updateStatsFromPart=function(e,t){var r=e.stats,i=t.stats,a=i.total;if(r.loaded+=i.loaded,a){var o=Math.round(e.duration/t.duration),l=Math.min(Math.round(r.loaded/a),o),u=(o-l)*Math.round(r.loaded/l);r.total=r.loaded+u}else r.total=Math.max(r.loaded,r.total);var d=r.loading,h=i.loading;d.start?d.first+=h.first-h.start:(d.start=h.start,d.first=h.first),d.end=h.end},s.resetLoader=function(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()},n}();function Ja(n,s){s===void 0&&(s=null);var e,t=s||n,r={frag:n,part:s,responseType:"arraybuffer",url:t.url,headers:{},rangeStart:0,rangeEnd:0},i=t.byteRangeStartOffset,a=t.byteRangeEndOffset;if(U(i)&&U(a)){var o,l=i,u=a;if(n.sn==="initSegment"&&((e=(o=n.decryptdata)==null?void 0:o.method)==="AES-128"||e==="AES-256")){var d=a-i;d%16&&(u=a+(16-d%16)),i!==0&&(r.resetIV=!0,l=i-16)}r.rangeStart=l,r.rangeEnd=u}return r}function tn(n,s){var e=new Error("GAP "+(n.gap?"tag":"attribute")+" found"),t={type:W.MEDIA_ERROR,details:I.FRAG_GAP,fatal:!1,frag:n,error:e,networkDetails:null};return s&&(t.part=s),(s||n).stats.aborted=!0,new Jt(t)}var Jt=function(n){function s(e){var t;return(t=n.call(this,e.error.message)||this).data=void 0,t.data=e,t}return ct(s,n),s}(De(Error)),en=function(n){function s(t,r){var i;return(i=n.call(this,t,r)||this)._boundTick=void 0,i._tickTimer=null,i._tickInterval=null,i._tickCallCount=0,i._boundTick=i.tick.bind(i),i}ct(s,n);var e=s.prototype;return e.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},e.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},e.onHandlerDestroyed=function(){},e.hasInterval=function(){return!!this._tickInterval},e.hasNextTick=function(){return!!this._tickTimer},e.setInterval=function(t){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,t),!0)},e.clearInterval=function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)},e.clearNextTick=function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)},e.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},e.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},e.doTick=function(){},s}(Xt),rn=function(n,s,e,t,r,i){t===void 0&&(t=0),r===void 0&&(r=-1),i===void 0&&(i=!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={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=n,this.sn=s,this.id=e,this.size=t,this.part=r,this.partial=i};function Ge(n,s){for(var e=0,t=n.length;e<t;e++){var r;if(((r=n[e])==null?void 0:r.cc)===s)return n[e]}return null}function an(n,s){var e=n.start+s;n.startPTS=e,n.setStart(e),n.endPTS=e+n.duration}function nn(n,s){for(var e=s.fragments,t=0,r=e.length;t<r;t++)an(e[t],n);s.fragmentHint&&an(s.fragmentHint,n),s.alignedSliding=!0}function Us(n,s){n&&(function(e,t){if(function(o,l){return!!(o&&l.startCC<o.endCC&&l.endCC>o.startCC)}(t,e)){var r=Math.min(t.endCC,e.endCC),i=Ge(t.fragments,r),a=Ge(e.fragments,r);i&&a&&(nt.log("Aligning playlist at start of dicontinuity sequence "+r),nn(i.start-a.start,e))}}(s,n),s.alignedSliding||function(e,t){if(e.hasProgramDateTime&&t.hasProgramDateTime){var r,i,a=e.fragments,o=t.fragments;if(a.length&&o.length){var l=Math.min(t.endCC,e.endCC);t.startCC<l&&e.startCC<l&&(r=Ge(o,l),i=Ge(a,l)),r&&i||(i=Ge(a,(r=o[Math.floor(o.length/2)]).cc)||a[Math.floor(a.length/2)]);var u=r.programDateTime,d=i.programDateTime;u&&d&&nn((d-u)/1e3-(i.start-r.start),e)}}}(s,n),s.alignedSliding||s.skippedSegments||ma(n,s,!1))}function he(n,s,e){se(n,s,e),n.addEventListener(s,e)}function se(n,s,e){n.removeEventListener(s,e)}var Gs=function(n){for(var s="",e=n.length,t=0;t<e;t++)s+="["+n.start(t).toFixed(3)+"-"+n.end(t).toFixed(3)+"]";return s},F={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_LEVEL:"WAITING_LEVEL"},Vs=function(n){function s(t,r,i,a,o){var l;return(l=n.call(this,a,t.logger)||this).hls=void 0,l.fragPrevious=null,l.fragCurrent=null,l.fragmentTracker=void 0,l.transmuxer=null,l._state=F.STOPPED,l.playlistType=void 0,l.media=null,l.mediaBuffer=null,l.config=void 0,l.bitrateTest=!1,l.lastCurrentTime=0,l.nextLoadPosition=0,l.startPosition=0,l.startTimeOffset=null,l.retryDate=0,l.levels=null,l.fragmentLoader=void 0,l.keyLoader=void 0,l.levelLastLoaded=null,l.startFragRequested=!1,l.decrypter=void 0,l.initPTS=[],l.buffering=!0,l.loadingParts=!1,l.loopSn=void 0,l.onMediaSeeking=function(){var u=l,d=u.config,h=u.fragCurrent,c=u.media,f=u.mediaBuffer,v=u.state,g=c?c.currentTime:0,m=et.bufferInfo(f||c,g,d.maxBufferHole),p=!m.len;if(l.log("Media seeking to "+(U(g)?g.toFixed(3):g)+", state: "+v+", "+(p?"out of":"in")+" buffer"),l.state===F.ENDED)l.resetLoadingState();else if(h){var y=d.maxFragLookUpTolerance,T=h.start-y,S=h.start+h.duration+y;if(p||S<m.start||T>m.end){var b=g>S;(g<T||b)&&(b&&h.loader&&(l.log("Cancelling fragment load for seek (sn: "+h.sn+")"),h.abortRequests(),l.resetLoadingState()),l.fragPrevious=null)}}if(c&&(l.fragmentTracker.removeFragmentsInRange(g,1/0,l.playlistType,!0),g>l.lastCurrentTime&&(l.lastCurrentTime=g),!l.loadingParts)){var L=Math.max(m.end,g),R=l.shouldLoadParts(l.getLevelDetails(),L);R&&(l.log("LL-Part loading ON after seeking to "+g.toFixed(2)+" with buffer @"+L.toFixed(2)),l.loadingParts=R)}l.hls.hasEnoughToStart||(l.log("Setting "+(p?"startPosition":"nextLoadPosition")+" to "+g+" for seek without enough to start"),l.nextLoadPosition=g,p&&(l.startPosition=g)),p&&l.state===F.IDLE&&l.tickImmediate()},l.onMediaEnded=function(){l.log("setting startPosition to 0 because media ended"),l.startPosition=l.lastCurrentTime=0},l.playlistType=o,l.hls=t,l.fragmentLoader=new Bs(t.config),l.keyLoader=i,l.fragmentTracker=r,l.config=t.config,l.decrypter=new Ur(t.config),l}ct(s,n);var e=s.prototype;return e.registerListeners=function(){var t=this.hls;t.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(E.MANIFEST_LOADING,this.onManifestLoading,this),t.on(E.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(E.ERROR,this.onError,this)},e.unregisterListeners=function(){var t=this.hls;t.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(E.MANIFEST_LOADING,this.onManifestLoading,this),t.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(E.ERROR,this.onError,this)},e.doTick=function(){this.onTickEnd()},e.onTickEnd=function(){},e.startLoad=function(t){},e.stopLoad=function(){if(this.state!==F.STOPPED){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);var t=this.fragCurrent;t!=null&&t.loader&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=F.STOPPED}},e.pauseBuffering=function(){this.buffering=!1},e.resumeBuffering=function(){this.buffering=!0},e._streamEnded=function(t,r){if(r.live||!this.media)return!1;var i=t.end||0,a=this.config.timelineOffset||0;if(i<=a)return!1;var o=t.buffered;this.config.maxBufferHole&&o&&o.length>1&&(t=et.bufferedInfo(o,t.start,0));var l=t.nextStart;if(l&&l>a&&l<r.edge||this.media.currentTime<t.start)return!1;var u=r.partList;if(u!=null&&u.length){var d=u[u.length-1];return et.isBuffered(this.media,d.start+d.duration/2)}var h=r.fragments[r.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(h)},e.getLevelDetails=function(){if(this.levels&&this.levelLastLoaded!==null)return this.levelLastLoaded.details},e.onMediaAttached=function(t,r){var i=this.media=this.mediaBuffer=r.media;he(i,"seeking",this.onMediaSeeking),he(i,"ended",this.onMediaEnded);var a=this.config;this.levels&&a.autoStartLoad&&this.state===F.STOPPED&&this.startLoad(a.startPosition)},e.onMediaDetaching=function(t,r){var i=!!r.transferMedia,a=this.media;if(a!==null){if(a.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),se(a,"seeking",this.onMediaSeeking),se(a,"ended",this.onMediaEnded),this.keyLoader&&!i&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loopSn=void 0,i)return this.resetLoadingState(),void this.resetTransmuxer();this.loadingParts=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}},e.onManifestLoading=function(){this.initPTS=[],this.levels=this.levelLastLoaded=this.fragCurrent=null,this.lastCurrentTime=this.startPosition=0,this.startFragRequested=!1},e.onError=function(t,r){},e.onManifestLoaded=function(t,r){this.startTimeOffset=r.startTimeOffset},e.onHandlerDestroying=function(){this.stopLoad(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),n.prototype.onHandlerDestroying.call(this),this.hls=this.onMediaSeeking=this.onMediaEnded=null},e.onHandlerDestroyed=function(){this.state=F.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,n.prototype.onHandlerDestroyed.call(this)},e.loadFragment=function(t,r,i){this.startFragRequested=!0,this._loadFragForPlayback(t,r,i)},e._loadFragForPlayback=function(t,r,i){var a=this;this._doFragLoad(t,r,i,function(o){var l=o.frag;if(a.fragContextChanged(l))return a.warn(l.type+" sn: "+l.sn+(o.part?" part: "+o.part.index:"")+" of "+a.fragInfo(l,!1,o.part)+") was dropped during download."),void a.fragmentTracker.removeFragment(l);l.stats.chunkCount++,a._handleFragmentLoadProgress(o)}).then(function(o){if(o){var l=a.state,u=o.frag;a.fragContextChanged(u)?(l===F.FRAG_LOADING||!a.fragCurrent&&l===F.PARSING)&&(a.fragmentTracker.removeFragment(u),a.state=F.IDLE):("payload"in o&&(a.log("Loaded "+u.type+" sn: "+u.sn+" of "+a.playlistLabel()+" "+u.level),a.hls.trigger(E.FRAG_LOADED,o)),a._handleFragmentLoadComplete(o))}}).catch(function(o){a.state!==F.STOPPED&&a.state!==F.ERROR&&(a.warn("Frag error: "+(o?.message||o)),a.resetFragmentLoading(t))})},e.clearTrackerIfNeeded=function(t){var r,i=this.fragmentTracker;if(i.getState(t)===Qa){var a=t.type,o=this.getFwdBufferInfo(this.mediaBuffer,a),l=Math.max(t.duration,o?o.len:this.config.maxBufferLength),u=this.backtrackFragment;((u?t.sn-u.sn:0)==1||this.reduceMaxBufferLength(l,t.duration))&&i.removeFragment(t)}else((r=this.mediaBuffer)==null?void 0:r.buffered.length)===0?i.removeAllFragments():i.hasParts(t.type)&&(i.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type}),i.getState(t)===Be&&i.removeFragment(t))},e.checkLiveUpdate=function(t){if(t.updated&&!t.live){var r=t.fragments[t.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:r,part:null,stats:r.stats,id:r.type})}t.fragments[0]||(t.deltaUpdateFailed=!0)},e.waitForLive=function(t){var r=t.details;return r?.live&&r.type!=="EVENT"&&(this.levelLastLoaded!==t||r.expired)},e.flushMainBuffer=function(t,r,i){if(i===void 0&&(i=null),t-r){var a={startOffset:t,endOffset:r,type:i};this.hls.trigger(E.BUFFER_FLUSHING,a)}},e._loadInitSegment=function(t,r){var i=this;this._doFragLoad(t,r).then(function(a){var o=a?.frag;if(!o||i.fragContextChanged(o)||!i.levels)throw new Error("init load aborted");return a}).then(function(a){var o=i.hls,l=a.frag,u=a.payload,d=l.decryptdata;if(u&&u.byteLength>0&&d!=null&&d.key&&d.iv&&Fe(d.method)){var h=self.performance.now();return i.decrypter.decrypt(new Uint8Array(u),d.key.buffer,d.iv.buffer,ea(d.method)).catch(function(c){throw o.trigger(E.ERROR,{type:W.MEDIA_ERROR,details:I.FRAG_DECRYPT_ERROR,fatal:!1,error:c,reason:c.message,frag:l}),c}).then(function(c){var f=self.performance.now();return o.trigger(E.FRAG_DECRYPTED,{frag:l,payload:c,stats:{tstart:h,tdecrypt:f}}),a.payload=c,i.completeInitSegmentLoad(a)})}return i.completeInitSegmentLoad(a)}).catch(function(a){i.state!==F.STOPPED&&i.state!==F.ERROR&&(i.warn(a),i.resetFragmentLoading(t))})},e.completeInitSegmentLoad=function(t){if(!this.levels)throw new Error("init load aborted, missing levels");var r=t.frag.stats;this.state!==F.STOPPED&&(this.state=F.IDLE),t.frag.data=new Uint8Array(t.payload),r.parsing.start=r.buffering.start=self.performance.now(),r.parsing.end=r.buffering.end=self.performance.now(),this.tick()},e.unhandledEncryptionError=function(t,r){var i,a,o=t.tracks;if(o&&!r.encrypted&&((i=o.audio)!=null&&i.encrypted||(a=o.video)!=null&&a.encrypted)&&(!this.config.emeEnabled||!this.keyLoader.emeController)){var l=this.media,u=new Error("EME not supported (light build)");return this.warn(u.message),!(!l||l.mediaKeys)&&(this.hls.trigger(E.ERROR,{type:W.KEY_SYSTEM_ERROR,details:I.KEY_SYSTEM_NO_KEYS,fatal:!0,error:u,frag:r}),this.resetTransmuxer(),!0)}return!1},e.fragContextChanged=function(t){var r=this.fragCurrent;return!t||!r||t.sn!==r.sn||t.level!==r.level},e.fragBufferedComplete=function(t,r){var i=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log("Buffered "+t.type+" sn: "+t.sn+(r?" part: "+r.index:"")+" of "+this.fragInfo(t,!1,r)+" > buffer:"+(i?Gs(et.getBuffered(i)):"(detached)")+")"),Mt(t)){var a;if(t.type!==_e){var o=t.elementaryStreams;if(!Object.keys(o).some(function(u){return!!o[u]}))return void(this.state=F.IDLE)}var l=(a=this.levels)==null?void 0:a[t.level];l!=null&&l.fragmentError&&(this.log("Resetting level fragment error count of "+l.fragmentError+" on frag buffered"),l.fragmentError=0)}this.state=F.IDLE},e._handleFragmentLoadComplete=function(t){var r=this.transmuxer;if(r){var i=t.frag,a=t.part,o=t.partsLoaded,l=!o||o.length===0||o.some(function(d){return!d}),u=new rn(i.level,i.sn,i.stats.chunkCount+1,0,a?a.index:-1,!l);r.flush(u)}},e._handleFragmentLoadProgress=function(t){},e._doFragLoad=function(t,r,i,a){var o,l=this;i===void 0&&(i=null),this.fragCurrent=t;var u=r.details;if(!this.levels||!u)throw new Error("frag load aborted, missing level"+(u?"":" detail")+"s");var d=null;if(!t.encrypted||(o=t.decryptdata)!=null&&o.key)t.encrypted||(d=this.keyLoader.loadClear(t,u.encryptedFragments,this.startFragRequested))&&this.log("[eme] blocking frag load until media-keys acquired");else if(this.log("Loading key for "+t.sn+" of ["+u.startSN+"-"+u.endSN+"], "+this.playlistLabel()+" "+t.level),this.state=F.KEY_LOADING,this.fragCurrent=t,d=this.keyLoader.load(t).then(function(S){if(!l.fragContextChanged(S.frag))return l.hls.trigger(E.KEY_LOADED,S),l.state===F.KEY_LOADING&&(l.state=F.IDLE),S}),this.hls.trigger(E.KEY_LOADING,{frag:t}),this.fragCurrent===null)return this.log("context changed in KEY_LOADING"),Promise.resolve(null);var h,c=this.fragPrevious;if(Mt(t)&&(!c||t.sn!==c.sn)){var f=this.shouldLoadParts(r.details,t.end);f!==this.loadingParts&&(this.log("LL-Part loading "+(f?"ON":"OFF")+" loading sn "+c?.sn+"->"+t.sn),this.loadingParts=f)}if(i=Math.max(t.start,i||0),this.loadingParts&&Mt(t)){var v=u.partList;if(v&&a){i>u.fragmentEnd&&u.fragmentHint&&(t=u.fragmentHint);var g=this.getNextPart(v,t,i);if(g>-1){var m,p=v[g];return t=this.fragCurrent=p.fragment,this.log("Loading "+t.type+" sn: "+t.sn+" part: "+p.index+" ("+g+"/"+(v.length-1)+") of "+this.fragInfo(t,!1,p)+") cc: "+t.cc+" ["+u.startSN+"-"+u.endSN+"], target: "+parseFloat(i.toFixed(3))),this.nextLoadPosition=p.start+p.duration,this.state=F.FRAG_LOADING,m=d?d.then(function(S){return!S||l.fragContextChanged(S.frag)?null:l.doFragPartsLoad(t,p,r,a)}).catch(function(S){return l.handleFragLoadError(S)}):this.doFragPartsLoad(t,p,r,a).catch(function(S){return l.handleFragLoadError(S)}),this.hls.trigger(E.FRAG_LOADING,{frag:t,part:p,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):m}if(!t.url||this.loadedEndOfParts(v,i))return Promise.resolve(null)}}if(Mt(t)&&this.loadingParts)this.log("LL-Part loading OFF after next part miss @"+i.toFixed(2)+" Check buffer at sn: "+t.sn+" loaded parts: "+((h=u.partList)==null?void 0:h.filter(function(S){return S.loaded}).map(function(S){return"["+S.start+"-"+S.end+"]"}))),this.loadingParts=!1;else if(!t.url)return Promise.resolve(null);this.log("Loading "+t.type+" sn: "+t.sn+" of "+this.fragInfo(t,!1)+") cc: "+t.cc+" ["+u.startSN+"-"+u.endSN+"], target: "+parseFloat(i.toFixed(3))),U(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=F.FRAG_LOADING;var y,T=this.config.progressive;return y=T&&d?d.then(function(S){return!S||l.fragContextChanged(S.frag)?null:l.fragmentLoader.load(t,a)}).catch(function(S){return l.handleFragLoadError(S)}):Promise.all([this.fragmentLoader.load(t,T?a:void 0),d]).then(function(S){var b=S[0];return!T&&a&&a(b),b}).catch(function(S){return l.handleFragLoadError(S)}),this.hls.trigger(E.FRAG_LOADING,{frag:t,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):y},e.doFragPartsLoad=function(t,r,i,a){var o=this;return new Promise(function(l,u){var d,h=[],c=(d=i.details)==null?void 0:d.partList,f=function(v){o.fragmentLoader.loadPart(t,v,a).then(function(g){h[v.index]=g;var m=g.part;o.hls.trigger(E.FRAG_LOADED,g);var p=Ea(i.details,t.sn,v.index+1)||Ta(c,t.sn,v.index+1);if(!p)return l({frag:t,part:m,partsLoaded:h});f(p)}).catch(u)};f(r)})},e.handleFragLoadError=function(t){if("data"in t){var r=t.data;r.frag&&r.details===I.INTERNAL_ABORTED?this.handleFragLoadAborted(r.frag,r.part):r.frag&&r.type===W.KEY_SYSTEM_ERROR?(r.frag.abortRequests(),this.resetStartWhenNotLoaded(),this.resetFragmentLoading(r.frag)):this.hls.trigger(E.ERROR,r)}else this.hls.trigger(E.ERROR,{type:W.OTHER_ERROR,details:I.INTERNAL_EXCEPTION,err:t,error:t,fatal:!0});return null},e._handleTransmuxerFlush=function(t){var r=this.getCurrentContext(t);if(r&&this.state===F.PARSING){var i=r.frag,a=r.part,o=r.level,l=self.performance.now();i.stats.parsing.end=l,a&&(a.stats.parsing.end=l);var u=this.getLevelDetails(),d=u&&i.sn>u.endSN||this.shouldLoadParts(u,i.end);d!==this.loadingParts&&(this.log("LL-Part loading "+(d?"ON":"OFF")+" after parsing segment ending @"+i.end.toFixed(2)),this.loadingParts=d),this.updateLevelTiming(i,a,o,t.partial)}else this.fragCurrent||this.state===F.STOPPED||this.state===F.ERROR||(this.state=F.IDLE)},e.shouldLoadParts=function(t,r){if(this.config.lowLatencyMode){if(!t)return this.loadingParts;if(t.partList){var i,a,o=t.partList[0];if(o.fragment.type===_e)return!1;if(r>=o.end+(((i=t.fragmentHint)==null?void 0:i.duration)||0)&&(this.hls.hasEnoughToStart?((a=this.media)==null?void 0:a.currentTime)||this.lastCurrentTime:this.getLoadPosition())>o.start-o.fragment.duration)return!0}}return!1},e.getCurrentContext=function(t){var r=this.levels,i=this.fragCurrent,a=t.level,o=t.sn,l=t.part;if(r==null||!r[a])return this.warn("Levels object was unset while buffering fragment "+o+" of "+this.playlistLabel()+" "+a+". The current chunk will not be buffered."),null;var u=r[a],d=u.details,h=l>-1?Ea(d,o,l):null,c=h?h.fragment:ya(d,o,i);return c?(i&&i!==c&&(c.stats=i.stats),{frag:c,part:h,level:u}):null},e.bufferFragmentData=function(t,r,i,a,o){if(this.state===F.PARSING){var l=t.data1,u=t.data2,d=l;if(u&&(d=Nt(l,u)),d.length){var h=this.initPTS[r.cc],c=h?-h.baseTime/h.timescale:void 0,f={type:t.type,frag:r,part:i,chunkMeta:a,offset:c,parent:r.type,data:d};if(this.hls.trigger(E.BUFFER_APPENDING,f),t.dropped&&t.independent&&!i){if(o)return;this.flushBufferGap(r)}}}},e.flushBufferGap=function(t){var r=this.media;if(r)if(et.isBuffered(r,r.currentTime)){var i=r.currentTime,a=et.bufferInfo(r,i,0),o=t.duration,l=Math.min(2*this.config.maxFragLookUpTolerance,.25*o),u=Math.max(Math.min(t.start-l,a.end-l),i+l);t.start-u>l&&this.flushMainBuffer(u,t.start)}else this.flushMainBuffer(0,t.start)},e.getFwdBufferInfo=function(t,r){var i,a=this.getLoadPosition();if(!U(a))return null;var o=this.lastCurrentTime>a||(i=this.media)!=null&&i.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(t,a,r,o)},e.getFwdBufferInfoAtPos=function(t,r,i,a){var o=et.bufferInfo(t,r,a);if(o.len===0&&o.nextStart!==void 0){var l=this.fragmentTracker.getBufferedFrag(r,i);if(l&&(o.nextStart<=l.end||l.gap)){var u=Math.max(Math.min(o.nextStart,l.end)-r,a);return et.bufferInfo(t,r,u)}}return o},e.getMaxBufferLength=function(t){var r,i=this.config;return r=t?Math.max(8*i.maxBufferSize/t,i.maxBufferLength):i.maxBufferLength,Math.min(r,i.maxMaxBufferLength)},e.reduceMaxBufferLength=function(t,r){var i=this.config,a=Math.max(Math.min(t-r,i.maxBufferLength),r),o=Math.max(t-3*r,i.maxMaxBufferLength/2,a);return o>=a&&(i.maxMaxBufferLength=o,this.warn("Reduce max buffer length to "+o+"s"),!0)},e.getAppendedFrag=function(t,r){r===void 0&&(r=J);var i=this.fragmentTracker?this.fragmentTracker.getAppendedFrag(t,r):null;return i&&"fragment"in i?i.fragment:i},e.getNextFragment=function(t,r){var i=r.fragments,a=i.length;if(!a)return null;var o=this.config,l=i[0].start,u=o.lowLatencyMode&&!!r.partList,d=null;if(r.live){var h=o.initialLiveManifestSize;if(a<h)return this.warn("Not enough fragments to start playback (have: "+a+", need: "+h+")"),null;if(!r.PTSKnown&&!this.startFragRequested&&this.startPosition===-1||t<l){var c;u&&!this.loadingParts&&(this.log("LL-Part loading ON for initial live fragment"),this.loadingParts=!0),d=this.getInitialLiveFragment(r);var f=this.hls.startPosition,v=this.hls.liveSyncPosition,g=d?(f!==-1&&f>=l?f:v)||d.start:t;this.log("Setting startPosition to "+g+" to match start frag at live edge. mainStart: "+f+" liveSyncPosition: "+v+" frag.start: "+((c=d)==null?void 0:c.start)),this.startPosition=this.nextLoadPosition=g}}else t<=l&&(d=i[0]);if(!d){var m=this.loadingParts?r.partEnd:r.fragmentEnd;d=this.getFragmentAtPosition(t,m,r)}var p=this.filterReplacedPrimary(d,r);if(!p&&d){var y=d.sn-r.startSN;p=this.filterReplacedPrimary(i[y+1]||null,r)}return this.mapToInitFragWhenRequired(p)},e.isLoopLoading=function(t,r){var i=this.fragmentTracker.getState(t);return(i===Ue||i===Be&&!!t.gap)&&this.nextLoadPosition>r},e.getNextFragmentLoopLoading=function(t,r,i,a,o){var l=null;if(t.gap&&(l=this.getNextFragment(this.nextLoadPosition,r))&&!l.gap&&i.nextStart){var u=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,a,0);if(u!==null&&i.len+u.len>=o){var d=l.sn;return this.loopSn!==d&&(this.log('buffer full after gaps in "'+a+'" playlist starting at sn: '+d),this.loopSn=d),null}}return this.loopSn=void 0,l},e.filterReplacedPrimary=function(t,r){return t&&(this.config,t)},e.mapToInitFragWhenRequired=function(t){return t==null||!t.initSegment||t.initSegment.data||this.bitrateTest?t:t.initSegment},e.getNextPart=function(t,r,i){for(var a=-1,o=!1,l=!0,u=0,d=t.length;u<d;u++){var h=t[u];if(l=l&&!h.independent,a>-1&&i<h.start)break;var c=h.loaded;c?a=-1:(o||(h.independent||l)&&h.fragment===r)&&(h.fragment!==r&&this.warn("Need buffer at "+i+" but next unloaded part starts at "+h.start),a=u),o=c}return a},e.loadedEndOfParts=function(t,r){for(var i,a=t.length;a--;){if(!(i=t[a]).loaded)return!1;if(r>i.start)return!0}return!1},e.getInitialLiveFragment=function(t){var r=t.fragments,i=this.fragPrevious,a=null;if(i){if(t.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+i.programDateTime),a=function(d,h,c){if(h===null||!Array.isArray(d)||!d.length||!U(h)||h<(d[0].programDateTime||0)||h>=(d[d.length-1].endProgramDateTime||0))return null;for(var f=0;f<d.length;++f){var v=d[f];if(Un(h,c,v))return v}return null}(r,i.endProgramDateTime,this.config.maxFragLookUpTolerance)),!a){var o=i.sn+1;if(o>=t.startSN&&o<=t.endSN){var l=r[o-t.startSN];i.cc===l.cc&&(a=l,this.log("Live playlist, switching playlist, load frag with next SN: "+a.sn))}a||(a=function(d,h,c){if(d&&d.startCC<=h&&d.endCC>=h){var f,v=d.fragments,g=d.fragmentHint;return g&&(v=v.concat(g)),Bi(v,function(m){return m.cc<h?1:m.cc>h?-1:(f=m,m.end<=c?1:m.start>c?-1:0)}),f||null}return null}(t,i.cc,i.end),a&&this.log("Live playlist, switching playlist, load frag with same CC: "+a.sn))}}else{var u=this.hls.liveSyncPosition;u!==null&&(a=this.getFragmentAtPosition(u,this.bitrateTest?t.fragmentEnd:t.edge,t))}return a},e.getFragmentAtPosition=function(t,r,i){var a,o,l=this.config,u=this.fragPrevious,d=i.fragments,h=i.endSN,c=i.fragmentHint,f=l.maxFragLookUpTolerance,v=i.partList,g=!!(this.loadingParts&&v!=null&&v.length&&c);if(g&&!this.bitrateTest&&v[v.length-1].fragment.sn===c.sn&&(d=d.concat(c),h=c.sn),a=t<r?Dr(u,d,t,t<this.lastCurrentTime||t>r-f||(o=this.media)!=null&&o.paused||!this.startFragRequested?0:f):d[d.length-1]){var m=a.sn-i.startSN,p=this.fragmentTracker.getState(a);if((p===Ue||p===Be&&a.gap)&&(u=a),u&&a.sn===u.sn&&(!g||v[0].fragment.sn>a.sn||!i.live)&&a.level===u.level){var y=d[m+1];a=a.sn<h&&this.fragmentTracker.getState(y)!==Ue?y:null}}return a},e.alignPlaylists=function(t,r,i){var a=t.fragments.length;if(!a)return this.warn("No fragments in live playlist"),0;var o=t.fragmentStart,l=!r,u=t.alignedSliding&&U(o);if(l||!u&&!o){Us(i,t);var d=t.fragmentStart;return this.log("Live playlist sliding: "+d.toFixed(2)+" start-sn: "+(r?r.startSN:"na")+"->"+t.startSN+" fragments: "+a),d}return o},e.waitForCdnTuneIn=function(t){return t.live&&t.canBlockReload&&t.partTarget&&t.tuneInGoal>Math.max(t.partHoldBack,3*t.partTarget)},e.setStartPosition=function(t,r){var i=this.startPosition;i<r&&(i=-1);var a=this.timelineOffset;if(i===-1){var o=this.startTimeOffset!==null,l=o?this.startTimeOffset:t.startTimeOffset;l!==null&&U(l)?(i=r+l,l<0&&(i+=t.edge),i=Math.min(Math.max(r,i),r+t.totalduration),this.log("Setting startPosition to "+i+" for start time offset "+l+" found in "+(o?"multivariant":"media")+" playlist"),this.startPosition=i):t.live?(i=this.hls.liveSyncPosition||r,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+a}this.nextLoadPosition=i+a},e.getLoadPosition=function(){var t,r=this.media,i=0;return(t=this.hls)!=null&&t.hasEnoughToStart&&r?i=r.currentTime:this.nextLoadPosition>=0&&(i=this.nextLoadPosition),i},e.handleFragLoadAborted=function(t,r){this.transmuxer&&t.type===this.playlistType&&Mt(t)&&t.stats.aborted&&(this.log("Fragment "+t.sn+(r?" part "+r.index:"")+" of "+this.playlistLabel()+" "+t.level+" was aborted"),this.resetFragmentLoading(t))},e.resetFragmentLoading=function(t){this.fragCurrent&&(this.fragContextChanged(t)||this.state===F.FRAG_LOADING_WAITING_RETRY)||(this.state=F.IDLE)},e.onFragmentOrKeyLoadError=function(t,r){var i;if(r.chunkMeta&&!r.frag){var a=this.getCurrentContext(r.chunkMeta);a&&(r.frag=a.frag)}var o=r.frag;if(o&&o.type===t&&this.levels)if(this.fragContextChanged(o)){var l;this.warn("Frag load error must match current frag to retry "+o.url+" > "+((l=this.fragCurrent)==null?void 0:l.url))}else{var u=r.details===I.FRAG_GAP;u&&this.fragmentTracker.fragBuffered(o,!0);var d=r.errorAction;if(d){var h=d.action,c=d.flags,f=d.retryCount,v=f===void 0?0:f,g=d.retryConfig,m=!!g,p=m&&h===$e,y=m&&!d.resolved&&c===Ze,T=(i=this.hls.latestLevelDetails)==null?void 0:i.live;if(!p&&y&&Mt(o)&&!o.endList&&T&&!Vi(r))this.resetFragmentErrors(t),this.treatAsGap(o),d.resolved=!0;else if((p||y)&&v<g.maxNumRetry){var S,b=Ir((S=r.response)==null?void 0:S.code),L=_r(g,v);if(this.resetStartWhenNotLoaded(),this.retryDate=self.performance.now()+L,this.state=F.FRAG_LOADING_WAITING_RETRY,d.resolved=!0,b)return this.log("Waiting for connection (offline)"),this.retryDate=1/0,void(r.reason="offline");this.warn("Fragment "+o.sn+" of "+t+" "+o.level+" errored with "+r.details+", retrying loading "+(v+1)+"/"+g.maxNumRetry+" in "+L+"ms")}else if(g){if(this.resetFragmentErrors(t),!(v<g.maxNumRetry))return void this.warn(r.details+" reached or exceeded max retry ("+v+")");u||h===Gn||(d.resolved=!0)}else this.state=h===Ht?F.WAITING_LEVEL:F.ERROR;this.tickImmediate()}else this.state=F.ERROR}},e.checkRetryDate=function(){var t=self.performance.now(),r=this.retryDate,i=r===1/0;(!r||t>=r||i&&!Ir(0))&&(i&&this.log("Connection restored (online)"),this.resetStartWhenNotLoaded(),this.state=F.IDLE)},e.reduceLengthAndFlushBuffer=function(t){if(this.state===F.PARSING||this.state===F.PARSED){var r=t.frag,i=t.parent,a=this.getFwdBufferInfo(this.mediaBuffer,i),o=a&&a.len>.5;o&&this.reduceMaxBufferLength(a.len,r?.duration||10);var l=!o;return l&&this.warn("Buffer full error while media.currentTime ("+this.getLoadPosition()+") is not buffered, flush "+i+" buffer"),r&&(this.fragmentTracker.removeFragment(r),this.nextLoadPosition=r.start),this.resetLoadingState(),l}return!1},e.resetFragmentErrors=function(t){t===ge&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==F.STOPPED&&(this.state=F.IDLE)},e.afterBufferFlushed=function(t,r,i){if(t){var a=et.getBuffered(t);this.fragmentTracker.detectEvictedFragments(r,a,i),this.state===F.ENDED&&this.resetLoadingState()}},e.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==F.STOPPED&&(this.state=F.IDLE)},e.resetStartWhenNotLoaded=function(){if(!this.hls.hasEnoughToStart){this.startFragRequested=!1;var t=this.levelLastLoaded,r=t?t.details:null;r!=null&&r.live?(this.log("resetting startPosition for live start"),this.startPosition=-1,this.setStartPosition(r,r.fragmentStart),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},e.resetWhenMissingContext=function(t){this.log("Loading context changed while buffering sn "+t.sn+" of "+this.playlistLabel()+" "+(t.level===-1?"<removed>":t.level)+". This chunk will not be buffered."),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(),this.resetLoadingState()},e.removeUnbufferedFrags=function(t){t===void 0&&(t=0),this.fragmentTracker.removeFragmentsInRange(t,1/0,this.playlistType,!1,!0)},e.updateLevelTiming=function(t,r,i,a){var o=this,l=i.details;if(l){var u;if(!Object.keys(t.elementaryStreams).reduce(function(h,c){var f=t.elementaryStreams[c];if(f){var v=f.endPTS-f.startPTS;if(v<=0)return o.warn("Could not parse fragment "+t.sn+" "+c+" duration reliably ("+v+")"),h||!1;var g=a?0:va(l,t,f.startPTS,f.endPTS,f.startDTS,f.endDTS,o);return o.hls.trigger(E.LEVEL_PTS_UPDATED,{details:l,level:i,drift:g,type:c,frag:t,start:f.startPTS,end:f.endPTS}),!0}return h},!1)&&(i.fragmentError===0&&this.treatAsGap(t,i),((u=this.transmuxer)==null?void 0:u.error)===null)){var d=new Error("Found no media in fragment "+t.sn+" of "+this.playlistLabel()+" "+t.level+" resetting transmuxer to fallback to playlist timing");if(this.warn(d.message),this.hls.trigger(E.ERROR,{type:W.MEDIA_ERROR,details:I.FRAG_PARSING_ERROR,fatal:!1,error:d,frag:t,reason:"Found no media in msn "+t.sn+" of "+this.playlistLabel()+' "'+i.url+'"'}),!this.hls)return;this.resetTransmuxer()}this.state=F.PARSED,this.log("Parsed "+t.type+" sn: "+t.sn+(r?" part: "+r.index:"")+" of "+this.fragInfo(t,!1,r)+")"),this.hls.trigger(E.FRAG_PARSED,{frag:t,part:r})}else this.warn("level.details undefined")},e.playlistLabel=function(){return this.playlistType===J?"level":"track"},e.fragInfo=function(t,r,i){var a,o;return r===void 0&&(r=!0),this.playlistLabel()+" "+t.level+" ("+(i?"part":"frag")+":["+((a=r&&!i?t.startPTS:(i||t).start)!=null?a:NaN).toFixed(3)+"-"+((o=r&&!i?t.endPTS:(i||t).end)!=null?o:NaN).toFixed(3)+"]"+(i&&t.type==="main"?"INDEPENDENT="+(i.independent?"YES":"NO"):"")},e.treatAsGap=function(t,r){r&&r.fragmentError++,t.gap=!0,this.fragmentTracker.removeFragment(t),this.fragmentTracker.fragBuffered(t,!0)},e.resetTransmuxer=function(){var t;(t=this.transmuxer)==null||t.reset()},e.recoverWorkerError=function(t){t.event==="demuxerWorker"&&(this.fragmentTracker.removeAllFragments(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),this.resetStartWhenNotLoaded(),this.resetLoadingState())},yt(s,[{key:"startPositionValue",get:function(){var t=this.nextLoadPosition,r=this.startPosition;return r===-1&&t?t:r}},{key:"bufferingEnabled",get:function(){return this.buffering}},{key:"inFlightFrag",get:function(){return{frag:this.fragCurrent,state:this.state}}},{key:"timelineOffset",get:function(){var t,r=this.config.timelineOffset;return r?((t=this.getLevelDetails())==null?void 0:t.appliedTimelineOffset)||r:0}},{key:"primaryPrefetch",get:function(){return this.config,!1}},{key:"state",get:function(){return this._state},set:function(t){var r=this._state;r!==t&&(this._state=t,this.log(r+"->"+t))}}])}(en),Hs=function(n){function s(t,r){var i;return(i=n.call(this,"gap-controller",t.logger)||this).hls=void 0,i.fragmentTracker=void 0,i.media=null,i.mediaSource=void 0,i.nudgeRetry=0,i.stallReported=!1,i.stalled=null,i.moved=!1,i.seeking=!1,i.buffered={},i.lastCurrentTime=0,i.ended=0,i.waiting=0,i.onMediaPlaying=function(){i.ended=0,i.waiting=0},i.onMediaWaiting=function(){var a;(a=i.media)!=null&&a.seeking||(i.waiting=self.performance.now(),i.tick())},i.onMediaEnded=function(){var a;i.hls&&(i.ended=((a=i.media)==null?void 0:a.currentTime)||1,i.hls.trigger(E.MEDIA_ENDED,{stalled:!1}))},i.hls=t,i.fragmentTracker=r,i.registerListeners(),i}ct(s,n);var e=s.prototype;return e.registerListeners=function(){var t=this.hls;t&&(t.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(E.BUFFER_APPENDED,this.onBufferAppended,this))},e.unregisterListeners=function(){var t=this.hls;t&&(t.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(E.BUFFER_APPENDED,this.onBufferAppended,this))},e.destroy=function(){n.prototype.destroy.call(this),this.unregisterListeners(),this.media=this.hls=this.fragmentTracker=null,this.mediaSource=void 0},e.onMediaAttached=function(t,r){this.setInterval(100),this.mediaSource=r.mediaSource;var i=this.media=r.media;he(i,"playing",this.onMediaPlaying),he(i,"waiting",this.onMediaWaiting),he(i,"ended",this.onMediaEnded)},e.onMediaDetaching=function(t,r){this.clearInterval();var i=this.media;i&&(se(i,"playing",this.onMediaPlaying),se(i,"waiting",this.onMediaWaiting),se(i,"ended",this.onMediaEnded),this.media=null),this.mediaSource=void 0},e.onBufferAppended=function(t,r){this.buffered=r.timeRanges},e.tick=function(){var t;if((t=this.media)!=null&&t.readyState&&this.hasBuffered){var r=this.media.currentTime;this.poll(r,this.lastCurrentTime),this.lastCurrentTime=r}},e.poll=function(t,r){var i,a,o=(i=this.hls)==null?void 0:i.config;if(o){var l=this.media;if(l){var u=l.seeking,d=this.seeking&&!u,h=!this.seeking&&u,c=l.paused&&!u||l.ended||l.playbackRate===0;if(this.seeking=u,t!==r)return r&&(this.ended=0),this.moved=!0,u||(this.nudgeRetry=0,o.nudgeOnVideoHole&&!c&&t>r&&this.nudgeOnVideoHole(t,r)),void(this.waiting===0&&this.stallResolved(t));if(h||d)d&&this.stallResolved(t);else{if(c)return this.nudgeRetry=0,this.stallResolved(t),void(!this.ended&&l.ended&&this.hls&&(this.ended=t||1,this.hls.trigger(E.MEDIA_ENDED,{stalled:!1})));if(et.getBuffered(l).length){var f=et.bufferInfo(l,t,0),v=f.nextStart||0,g=this.fragmentTracker;if(u&&g&&this.hls){var m=sn(this.hls.inFlightFragments,t),p=f.len>2,y=!v||m||v-t>2&&!g.getPartialFragment(t);if(p||y)return;this.moved=!1}var T=(a=this.hls)==null?void 0:a.latestLevelDetails;if(!this.moved&&this.stalled!==null&&g){if(!(f.len>0||v))return;var S=Math.max(v,f.start||0)-t,b=T!=null&&T.live?2*T.targetduration:2,L=or(t,g);if(S>0&&(S<=b||L))return void(l.paused||this._trySkipBufferHole(L))}var R=o.detectStallWithCurrentTimeMs,k=self.performance.now(),C=this.waiting,A=this.stalled;if(A===null){if(!(C>0&&k-C<R))return void(this.stalled=k);A=this.stalled=C}var D=k-A;if(!u&&(D>=R||C)&&this.hls){var _;if(((_=this.mediaSource)==null?void 0:_.readyState)==="ended"&&(T==null||!T.live)&&Math.abs(t-(T?.edge||0))<1)return this.ended?void 0:(this.ended=t||1,void this.hls.trigger(E.MEDIA_ENDED,{stalled:!0}));if(this._reportStall(f),!this.media||!this.hls)return}var M=et.bufferInfo(l,t,o.maxBufferHole);this._tryFixBufferStall(M,D,t)}else this.nudgeRetry=0}}}},e.stallResolved=function(t){var r=this.stalled;if(r&&this.hls&&(this.stalled=null,this.stallReported)){var i=self.performance.now()-r;this.log("playback not stuck anymore @"+t+", after "+Math.round(i)+"ms"),this.stallReported=!1,this.waiting=0,this.hls.trigger(E.STALL_RESOLVED,{})}},e.nudgeOnVideoHole=function(t,r){var i,a=this.buffered.video;if(this.hls&&this.media&&this.fragmentTracker&&(i=this.buffered.audio)!=null&&i.length&&a&&a.length>1&&t>a.end(0)){var o=et.bufferedInfo(et.timeRangesToArray(this.buffered.audio),t,0);if(o.len>1&&r>=o.start){var l=et.timeRangesToArray(a),u=et.bufferedInfo(l,r,0).bufferedIndex;if(u>-1&&u<l.length-1){var d=et.bufferedInfo(l,t,0).bufferedIndex,h=l[u].end,c=l[u+1].start;if((d===-1||d>u)&&c-h<1&&t-h<2){var f=new Error("nudging playhead to flush pipeline after video hole. currentTime: "+t+" hole: "+h+" -> "+c+" buffered index: "+d);this.warn(f.message),this.media.currentTime+=1e-6;var v=or(t,this.fragmentTracker);v&&"fragment"in v?v=v.fragment:v||(v=void 0);var g=et.bufferInfo(this.media,t,0);this.hls.trigger(E.ERROR,{type:W.MEDIA_ERROR,details:I.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:f,reason:f.message,frag:v,buffer:g.len,bufferInfo:g})}}}}},e._tryFixBufferStall=function(t,r,i){var a,o,l=this.fragmentTracker,u=this.media,d=(a=this.hls)==null?void 0:a.config;if(u&&l&&d){var h=(o=this.hls)==null?void 0:o.latestLevelDetails,c=or(i,l);if((c||h!=null&&h.live&&i<h.fragmentStart)&&(this._trySkipBufferHole(c)||!this.media))return;var f=t.buffered,v=this.adjacentTraversal(t,i);(f&&f.length>1&&t.len>d.maxBufferHole||t.nextStart&&(t.nextStart-i<d.maxBufferHole||v))&&(r>1e3*d.highBufferWatchdogPeriod||this.waiting)&&(this.warn("Trying to nudge playhead over buffer-hole"),this._tryNudgeBuffer(t))}},e.adjacentTraversal=function(t,r){var i=this.fragmentTracker,a=t.nextStart;if(i&&a){var o=i.getFragAtPos(r,J),l=i.getFragAtPos(a,J);if(o&&l)return l.sn-o.sn<2}return!1},e._reportStall=function(t){var r=this.hls,i=this.media,a=this.stallReported,o=this.stalled;if(!a&&o!==null&&i&&r){this.stallReported=!0;var l=new Error("Playback stalling at @"+i.currentTime+" due to low buffer ("+It(t)+")");this.warn(l.message),r.trigger(E.ERROR,{type:W.MEDIA_ERROR,details:I.BUFFER_STALLED_ERROR,fatal:!1,error:l,buffer:t.len,bufferInfo:t,stalled:{start:o}})}},e._trySkipBufferHole=function(t){var r,i=this.fragmentTracker,a=this.media,o=(r=this.hls)==null?void 0:r.config;if(!a||!i||!o)return 0;var l=a.currentTime,u=et.bufferInfo(a,l,0),d=l<u.start?u.start:u.nextStart;if(d&&this.hls){var h=u.len<=o.maxBufferHole,c=u.len>0&&u.len<1&&a.readyState<3,f=d-l;if(f>0&&(h||c)){if(f>o.maxBufferHole){var v=!1;if(l===0){var g=i.getAppendedFrag(0,J);g&&d<g.end&&(v=!0)}if(!v&&t){var m;if((m=this.hls.loadLevelObj)==null||!m.details||sn(this.hls.inFlightFragments,d))return 0;for(var p=!1,y=t.end;y<d;){var T=or(y,i);if(!T){p=!0;break}y+=T.duration}if(p)return 0}}var S=Math.max(d+.05,l+.1);if(this.warn("skipping hole, adjusting currentTime from "+l+" to "+S),this.moved=!0,a.currentTime=S,t==null||!t.gap){var b=new Error("fragment loaded with buffer holes, seeking from "+l+" to "+S),L={type:W.MEDIA_ERROR,details:I.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:b,reason:b.message,buffer:u.len,bufferInfo:u};t&&("fragment"in t?L.part=t:L.frag=t),this.hls.trigger(E.ERROR,L)}return S}}return 0},e._tryNudgeBuffer=function(t){var r=this.hls,i=this.media,a=this.nudgeRetry,o=r?.config;if(!i||!o)return 0;var l=i.currentTime;if(this.nudgeRetry++,a<o.nudgeMaxRetry){var u=l+(a+1)*o.nudgeOffset,d=new Error("Nudging 'currentTime' from "+l+" to "+u);this.warn(d.message),i.currentTime=u,r.trigger(E.ERROR,{type:W.MEDIA_ERROR,details:I.BUFFER_NUDGE_ON_STALL,error:d,fatal:!1,buffer:t.len,bufferInfo:t})}else{var h=new Error("Playhead still not moving while enough data buffered @"+l+" after "+o.nudgeMaxRetry+" nudges");this.error(h.message),r.trigger(E.ERROR,{type:W.MEDIA_ERROR,details:I.BUFFER_STALLED_ERROR,error:h,fatal:!0,buffer:t.len,bufferInfo:t})}},yt(s,[{key:"hasBuffered",get:function(){return Object.keys(this.buffered).length>0}}])}(en);function sn(n,s){var e=on(n.main);if(e&&e.start<=s)return e;var t=on(n.audio);return t&&t.start<=s?t:null}function on(n){if(!n)return null;switch(n.state){case F.IDLE:case F.STOPPED:case F.ENDED:case F.ERROR:return null}return n.frag}function or(n,s){return s.getAppendedFrag(n,J)||s.getPartialFragment(n)}function Ks(n,s){var e;try{e=new Event("addtrack")}catch{(e=document.createEvent("Event")).initEvent("addtrack",!1,!1)}e.track=n,s.dispatchEvent(e)}function Ys(n,s,e,t){var r=n.mode;if(r==="disabled"&&(n.mode="hidden"),n.cues&&n.cues.length>0)for(var i=function(o,l,u){var d=[],h=function(g,m){if(m<=g[0].startTime)return 0;var p=g.length-1;if(m>g[p].endTime)return-1;for(var y,T=0,S=p;T<=S;)if(m<g[y=Math.floor((S+T)/2)].startTime)S=y-1;else{if(!(m>g[y].startTime&&T<p))return y;T=y+1}return g[T].startTime-m<m-g[S].startTime?T:S}(o,l);if(h>-1)for(var c=h,f=o.length;c<f;c++){var v=o[c];if(v.startTime>=l&&v.endTime<=u)d.push(v);else if(v.startTime>u)return d}return d}(n.cues,s,e),a=0;a<i.length;a++)t&&!t(i[a])||n.removeCue(i[a]);r==="disabled"&&(n.mode=r)}function zr(){if(typeof self<"u")return self.VTTCue||self.TextTrackCue}function ln(n,s,e,t,r){var i=new n(s,e,"");try{i.value=t,r&&(i.type=r)}catch{i=new n(s,e,It(r?wt({type:r},t):t))}return i}var lr=function(){var n=zr();try{n&&new n(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}(),Ws=function(){function n(e){var t=this;this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=!0,this.assetCue=void 0,this.onEventCueEnter=function(){t.hls&&t.hls.trigger(E.EVENT_CUE_ENTER,{})},this.hls=e,this._registerListeners()}var s=n.prototype;return s.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=this.onEventCueEnter=null},s._registerListeners=function(){var 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.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))},s._unregisterListeners=function(){var 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.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))},s.onMediaAttaching=function(e,t){var r;this.media=t.media,((r=t.overrides)==null?void 0:r.cueRemoval)===!1&&(this.removeCues=!1)},s.onMediaAttached=function(){var e,t=(e=this.hls)==null?void 0:e.latestLevelDetails;t&&this.updateDateRangeCues(t)},s.onMediaDetaching=function(e,t){this.media=null,t.transferMedia||(this.id3Track&&(this.removeCues&&function(r,i){var a=r.mode;if(a==="disabled"&&(r.mode="hidden"),r.cues)for(var o=r.cues.length;o--;)i&&r.cues[o].removeEventListener("enter",i),r.removeCue(r.cues[o]);a==="disabled"&&(r.mode=a)}(this.id3Track,this.onEventCueEnter),this.id3Track=null),this.dateRangeCuesAppended={})},s.onManifestLoading=function(){this.dateRangeCuesAppended={}},s.createTrack=function(e){var t=this.getID3Track(e.textTracks);return t.mode="hidden",t},s.getID3Track=function(e){if(this.media){for(var t=0;t<e.length;t++){var r=e[t];if(r.kind==="metadata"&&r.label==="id3")return Ks(r,this.media),r}return this.media.addTextTrack("metadata","id3")}},s.onFragParsingMetadata=function(e,t){if(this.media&&this.hls){var r=this.hls.config,i=r.enableEmsgMetadataCues,a=r.enableID3MetadataCues;if(i||a){var o=t.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));var l=zr();if(l)for(var u=0;u<o.length;u++){var d=o[u].type;if((d!==Ct.emsg||i)&&a){var h=Pa(o[u].data),c=o[u].pts,f=c+o[u].duration;f>lr&&(f=lr),f-c<=0&&(f=c+.25);for(var v=0;v<h.length;v++){var g=h[v];if(!wa(g)){this.updateId3CueEnds(c,d);var m=ln(l,c,f,g,d);m&&this.id3Track.addCue(m)}}}}}}},s.updateId3CueEnds=function(e,t){var r,i=(r=this.id3Track)==null?void 0:r.cues;if(i)for(var a=i.length;a--;){var o=i[a];o.type===t&&o.startTime<e&&o.endTime===lr&&(o.endTime=e)}},s.onBufferFlushing=function(e,t){var r=t.startOffset,i=t.endOffset,a=t.type,o=this.id3Track,l=this.hls;if(l){var u=l.config,d=u.enableEmsgMetadataCues,h=u.enableID3MetadataCues;o&&(d||h)&&Ys(o,r,i,a==="audio"?function(c){return c.type===Ct.audioId3&&h}:a==="video"?function(c){return c.type===Ct.emsg&&d}:function(c){return c.type===Ct.audioId3&&h||c.type===Ct.emsg&&d})}},s.onLevelUpdated=function(e,t){var r=t.details;this.updateDateRangeCues(r,!0)},s.onLevelPtsUpdated=function(e,t){Math.abs(t.drift)>.01&&this.updateDateRangeCues(t.details)},s.updateDateRangeCues=function(e,t){var r=this;if(this.hls&&this.media){var i=this.hls.config;i.assetPlayerId,i.timelineOffset;var a=i.enableDateRangeMetadataCues;if(i.interstitialsController,a){var o=zr();if(e.hasProgramDateTime){var l,u=this.id3Track,d=e.dateRanges,h=Object.keys(d),c=this.dateRangeCuesAppended;if(u&&t)if((l=u.cues)!=null&&l.length)for(var f=Object.keys(c).filter(function(T){return!h.includes(T)}),v=function(){var T,S=f[g],b=(T=c[S])==null?void 0:T.cues;delete c[S],b&&Object.keys(b).forEach(function(L){var R=b[L];if(R){R.removeEventListener("enter",r.onEventCueEnter);try{u.removeCue(R)}catch{}}})},g=f.length;g--;)v();else c=this.dateRangeCuesAppended={};var m=e.fragments[e.fragments.length-1];if(h.length!==0&&U(m?.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var p=function(){var T=h[y],S=d[T],b=S.startTime,L=c[T],R=L?.cues||{},k=L?.durationKnown||!1,C=lr,A=S.duration;if(S.endDate&&A!==null)C=b+A,k=!0;else if(S.endOnNext&&!k){var D=h.reduce(function(G,B){if(B!==S.id){var V=d[B];if(V.class===S.class&&V.startDate>S.startDate&&(!G||S.startDate<G.startDate))return V}return G},null);D&&(C=D.startTime,k=!0)}for(var _,M=Object.keys(S.attr),O=0;O<M.length;O++){var P=M[O];if((_=P)!=="ID"&&_!=="CLASS"&&_!=="CUE"&&_!=="START-DATE"&&_!=="DURATION"&&_!=="END-DATE"&&_!=="END-ON-NEXT"){var w=R[P];if(w)!k||L!=null&&L.durationKnown?Math.abs(w.startTime-b)>.01&&(w.startTime=b,w.endTime=C):w.endTime=C;else if(o){var x=S.attr[P];jn(P)&&(x=vi(x));var N=ln(o,b,C,{key:P,data:x},Ct.dateRange);N&&(N.id=T,r.id3Track.addCue(N),R[P]=N)}}}c[T]={cues:R,dateRange:S,durationKnown:k}},y=0;y<h.length;y++)p()}}}}},n}(),js=function(){function n(e){var t=this;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=function(){var r=t.media,i=t.levelDetails;if(r&&i){t.currentTime=r.currentTime;var a=t.computeLatency();if(a!==null){t._latency=a;var o=t.config,l=o.lowLatencyMode,u=o.maxLiveSyncPlaybackRate;if(l&&u!==1&&i.live){var d=t.targetLatency;if(d!==null){var h=a-d;if(h<Math.min(t.maxLatency,d+i.targetduration)&&h>.05&&t.forwardBufferLength>1){var c=Math.min(2,Math.max(1,u)),f=Math.round(2/(1+Math.exp(-.75*h-t.edgeStalled))*20)/20,v=Math.min(c,Math.max(1,f));t.changeMediaPlaybackRate(r,v)}else r.playbackRate!==1&&r.playbackRate!==0&&t.changeMediaPlaybackRate(r,1)}}}}},this.hls=e,this.config=e.config,this.registerListeners()}var s=n.prototype;return s.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.hls=null},s.registerListeners=function(){var e=this.hls;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))},s.unregisterListeners=function(){var e=this.hls;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))},s.onMediaAttached=function(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.onTimeupdate)},s.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.onTimeupdate),this.media=null)},s.onManifestLoading=function(){this._latency=null,this.stallCount=0},s.onLevelUpdated=function(e,t){var r=t.details;r.advanced&&this.onTimeupdate(),!r.live&&this.media&&this.media.removeEventListener("timeupdate",this.onTimeupdate)},s.onError=function(e,t){var r;t.details===I.BUFFER_STALLED_ERROR&&(this.stallCount++,this.hls&&(r=this.levelDetails)!=null&&r.live&&this.hls.logger.warn("[latency-controller]: Stall detected, adjusting target latency"))},s.changeMediaPlaybackRate=function(e,t){var r,i;e.playbackRate!==t&&((r=this.hls)==null||r.logger.debug("[latency-controller]: latency="+this.latency.toFixed(3)+", targetLatency="+((i=this.targetLatency)==null?void 0:i.toFixed(3))+", forwardBufferLength="+this.forwardBufferLength.toFixed(3)+": adjusting playback rate from "+e.playbackRate+" to "+t),e.playbackRate=t)},s.estimateLiveEdge=function(){var e=this.levelDetails;return e===null?null:e.edge+e.age},s.computeLatency=function(){var e=this.estimateLiveEdge();return e===null?null:e-this.currentTime},yt(n,[{key:"levelDetails",get:function(){var e;return((e=this.hls)==null?void 0:e.latestLevelDetails)||null}},{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var e=this.config;if(e.liveMaxLatencyDuration!==void 0)return e.liveMaxLatencyDuration;var t=this.levelDetails;return t?e.liveMaxLatencyDurationCount*t.targetduration:0}},{key:"targetLatency",get:function(){var e=this.levelDetails;if(e===null||this.hls===null)return null;var t=e.holdBack,r=e.partHoldBack,i=e.targetduration,a=this.config,o=a.liveSyncDuration,l=a.liveSyncDurationCount,u=a.lowLatencyMode,d=this.hls.userConfig,h=u&&r||t;(this._targetLatencyUpdated||d.liveSyncDuration||d.liveSyncDurationCount||h===0)&&(h=o!==void 0?o:l*i);var c=i;return h+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,c)},set:function(e){this.stallCount=0,this.config.liveSyncDuration=e,this._targetLatencyUpdated=!0}},{key:"liveSyncPosition",get:function(){var e=this.estimateLiveEdge(),t=this.targetLatency;if(e===null||t===null)return null;var r=this.levelDetails;if(r===null)return null;var i=r.edge,a=e-t-this.edgeStalled,o=i-r.totalduration,l=i-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(o,a),l)}},{key:"drift",get:function(){var e=this.levelDetails;return e===null?1:e.drift}},{key:"edgeStalled",get:function(){var e=this.levelDetails;if(e===null)return 0;var t=3*(this.config.lowLatencyMode&&e.partTarget||e.targetduration);return Math.max(e.age-t,0)}},{key:"forwardBufferLength",get:function(){var e=this.media,t=this.levelDetails;if(!e||!t)return 0;var r=e.buffered.length;return(r?e.buffered.end(r-1):t.edge)-this.currentTime}}])}(),qs=function(n){function s(t,r){var i;return(i=n.call(this,r,t.logger)||this).hls=void 0,i.canLoad=!1,i.timer=-1,i.hls=t,i}ct(s,n);var e=s.prototype;return e.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},e.clearTimer=function(){this.timer!==-1&&(self.clearTimeout(this.timer),this.timer=-1)},e.startLoad=function(){this.canLoad=!0,this.loadPlaylist()},e.stopLoad=function(){this.canLoad=!1,this.clearTimer()},e.switchParams=function(t,r,i){var a=r?.renditionReports;if(a){for(var o=-1,l=0;l<a.length;l++){var u=a[l],d=void 0;try{d=new self.URL(u.URI,r.url).href}catch(m){this.warn("Could not construct new URL for Rendition Report: "+m),d=u.URI||""}if(d===t){o=l;break}d===t.substring(0,d.length)&&(o=l)}if(o!==-1){var h=a[o],c=parseInt(h["LAST-MSN"])||r.lastPartSn,f=parseInt(h["LAST-PART"])||r.lastPartIndex;if(this.hls.config.lowLatencyMode){var v=Math.min(r.age-r.partTarget,r.targetduration);f>=0&&v>r.partTarget&&(f+=1)}var g=i&&wi(i);return new xi(c,f>=0?f:void 0,g)}}},e.loadPlaylist=function(t){this.clearTimer()},e.loadingPlaylist=function(t,r){this.clearTimer()},e.shouldLoadPlaylist=function(t){return this.canLoad&&!!t&&!!t.url&&(!t.details||t.details.live)},e.getUrlWithDirectives=function(t,r){if(r)try{return r.addDirectives(t)}catch(i){this.warn("Could not construct new URL with HLS Delivery Directives: "+i)}return t},e.playlistLoaded=function(t,r,i){var a=r.details,o=r.stats,l=self.performance.now(),u=o.loading.first?Math.max(0,l-o.loading.first):0;a.advancedDateTime=Date.now()-u;var d=this.hls.config.timelineOffset;if(d!==a.appliedTimelineOffset){var h=Math.max(d||0,0);a.appliedTimelineOffset=h,a.fragments.forEach(function(w){w.setStart(w.playlistOffset+h)})}if(a.live||i!=null&&i.live){var c="levelInfo"in r?r.levelInfo:r.track;if(a.reloaded(i),i&&a.fragments.length>0){$n(i,a,this);var f=a.playlistParsingError;if(f){this.warn(f);var v=this.hls;if(!v.config.ignorePlaylistParsingErrors){var g,m=r.networkDetails;return void v.trigger(E.ERROR,{type:W.NETWORK_ERROR,details:I.LEVEL_PARSING_ERROR,fatal:!1,url:a.url,error:f,reason:f.message,level:r.level||void 0,parent:(g=a.fragments[0])==null?void 0:g.type,networkDetails:m,stats:o})}a.playlistParsingError=null}}a.requestScheduled===-1&&(a.requestScheduled=o.loading.start);var p,y=this.hls.mainForwardBufferInfo,T=y?y.end-y.len:0,S=pa(a,1e3*(a.edge-T));if(a.requestScheduled+S<l?a.requestScheduled=l:a.requestScheduled+=S,this.log("live playlist "+t+" "+(a.advanced?"REFRESHED "+a.lastPartSn+"-"+a.lastPartIndex:a.updated?"UPDATED":"MISSED")),!this.canLoad||!a.live)return;var b=void 0,L=void 0;if(a.canBlockReload&&a.endSN&&a.advanced){var R=this.hls.config.lowLatencyMode,k=a.lastPartSn,C=a.endSN,A=a.lastPartIndex,D=k===C;A!==-1?D?(b=C+1,L=R?0:A):(b=k,L=R?A+1:a.maxPartIndex):b=C+1;var _=a.age,M=_+a.ageHeader,O=Math.min(M-a.partTarget,1.5*a.targetduration);if(O>0){if(M>3*a.targetduration)this.log("Playlist last advanced "+_.toFixed(2)+"s ago. Omitting segment and part directives."),b=void 0,L=void 0;else if(i!=null&&i.tuneInGoal&&M-a.partTarget>i.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+i.tuneInGoal+" to: "+O+" with playlist age: "+a.age),O=0;else{var P=Math.floor(O/a.targetduration);b+=P,L!==void 0&&(L+=Math.round(O%a.targetduration/a.partTarget)),this.log("CDN Tune-in age: "+a.ageHeader+"s last advanced "+_.toFixed(2)+"s goal: "+O+" skip sn "+P+" to part "+L)}a.tuneInGoal=O}if(p=this.getDeliveryDirectives(a,r.deliveryDirectives,b,L),R||!D)return a.requestScheduled=l,void this.loadingPlaylist(c,p)}else(a.canBlockReload||a.canSkipUntil)&&(p=this.getDeliveryDirectives(a,r.deliveryDirectives,b,L));p&&b!==void 0&&a.canBlockReload&&(a.requestScheduled=o.loading.first+Math.max(S-2*u,S/2)),this.scheduleLoading(c,p,a)}else this.clearTimer()},e.scheduleLoading=function(t,r,i){var a=this,o=i||t.details;if(o){var l=self.performance.now(),u=o.requestScheduled;if(l>=u)this.loadingPlaylist(t,r);else{var d=u-l;this.log("reload live playlist "+(t.name||t.bitrate+"bps")+" in "+Math.round(d)+" ms"),this.clearTimer(),this.timer=self.setTimeout(function(){return a.loadingPlaylist(t,r)},d)}}else this.loadingPlaylist(t,r)},e.getDeliveryDirectives=function(t,r,i,a){var o=wi(t);return r!=null&&r.skip&&t.deltaUpdateFailed&&(i=r.msn,a=r.part,o=Pi),new xi(i,a,o)},e.checkRetry=function(t){var r=this,i=t.details,a=Xe(t),o=t.errorAction,l=o||{},u=l.action,d=l.retryCount,h=d===void 0?0:d,c=l.retryConfig,f=!!o&&!!c&&(u===$e||!o.resolved&&u===Ht);if(f){var v;if(h>=c.maxNumRetry)return!1;if(a&&(v=t.context)!=null&&v.deliveryDirectives)this.warn("Retrying playlist loading "+(h+1)+"/"+c.maxNumRetry+' after "'+i+'" without delivery-directives'),this.loadPlaylist();else{var g=_r(c,h);this.clearTimer(),this.timer=self.setTimeout(function(){return r.loadPlaylist()},g),this.warn("Retrying playlist loading "+(h+1)+"/"+c.maxNumRetry+' after "'+i+'" in '+g+"ms")}t.levelRetry=!0,o.resolved=!0}return f},s}(Xt),zs=function(n){function s(t,r){var i;return(i=n.call(this,t,"level-controller")||this)._levels=[],i._firstLevel=-1,i._maxAutoLevel=-1,i._startLevel=void 0,i.currentLevel=null,i.currentLevelIndex=-1,i.manualLevelIndex=-1,i.steering=void 0,i.onParsedComplete=void 0,i.steering=r,i._registerListeners(),i}ct(s,n);var e=s.prototype;return e._registerListeners=function(){var t=this.hls;t.on(E.MANIFEST_LOADING,this.onManifestLoading,this),t.on(E.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(E.LEVEL_LOADED,this.onLevelLoaded,this),t.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(E.FRAG_BUFFERED,this.onFragBuffered,this),t.on(E.ERROR,this.onError,this)},e._unregisterListeners=function(){var t=this.hls;t.off(E.MANIFEST_LOADING,this.onManifestLoading,this),t.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(E.LEVEL_LOADED,this.onLevelLoaded,this),t.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(E.FRAG_BUFFERED,this.onFragBuffered,this),t.off(E.ERROR,this.onError,this)},e.destroy=function(){this._unregisterListeners(),this.steering=null,this.resetLevels(),n.prototype.destroy.call(this)},e.stopLoad=function(){this._levels.forEach(function(t){t.loadError=0,t.fragmentError=0}),n.prototype.stopLoad.call(this)},e.resetLevels=function(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1},e.onManifestLoading=function(t,r){this.resetLevels()},e.onManifestLoaded=function(t,r){var i=this,a=this.hls.config.preferManagedMediaSource,o=[],l={},u={},d=!1,h=!1,c=!1;r.levels.forEach(function(f){var v=f.attrs,g=f.audioCodec,m=f.videoCodec;g&&(f.audioCodec=g=je(g,a)||void 0),m&&(m=f.videoCodec=function(P){for(var w=P.split(","),x=0;x<w.length;x++){var N=w[x].split(".");N.length>2&&N[0]==="avc1"&&(w[x]="avc1."+parseInt(N[1]).toString(16)+("000"+parseInt(N[2]).toString(16)).slice(-4))}return w.join(",")}(m));var p=f.width,y=f.height,T=f.unknownCodecs,S=T?.length||0;if(d||(d=!(!p||!y)),h||(h=!!m),c||(c=!!g),S||g&&!i.isAudioSupported(g)||m&&!i.isVideoSupported(m))i.log('Some or all CODECS not supported "'+v.CODECS+'"');else{var b=v.CODECS,L=v["FRAME-RATE"],R=v["HDCP-LEVEL"],k=v["PATHWAY-ID"],C=v.RESOLUTION,A=v["VIDEO-RANGE"],D=(k||".")+"-"+f.bitrate+"-"+C+"-"+L+"-"+b+"-"+A+"-"+R;if(l[D])if(l[D].uri===f.url||f.attrs["PATHWAY-ID"])l[D].addGroupId("audio",v.AUDIO),l[D].addGroupId("text",v.SUBTITLES);else{var _=u[D]+=1;f.attrs["PATHWAY-ID"]=new Array(_+1).join(".");var M=i.createLevel(f);l[D]=M,o.push(M)}else{var O=i.createLevel(f);l[D]=O,u[D]=1,o.push(O)}}}),this.filterAndSortMediaOptions(o,r,d,h,c)},e.createLevel=function(t){var r=new Oi(t),i=t.supplemental;if(i!=null&&i.videoCodec&&!this.isVideoSupported(i.videoCodec)){var a=new Error('SUPPLEMENTAL-CODECS not supported "'+i.videoCodec+'"');this.log(a.message),r.supportedResult=ci.getUnsupportedResult(a,[])}return r},e.isAudioSupported=function(t){return Ce(t,"audio",this.hls.config.preferManagedMediaSource)},e.isVideoSupported=function(t){return Ce(t,"video",this.hls.config.preferManagedMediaSource)},e.filterAndSortMediaOptions=function(t,r,i,a,o){var l,u=this,d=[],h=[],c=t,f=((l=r.stats)==null?void 0:l.parsing)||{};if((i||a)&&o&&(c=c.filter(function(A){var D,_=A.videoCodec,M=A.videoRange,O=A.width,P=A.height;return(!!_||!(!O||!P))&&!!(D=M)&&ze.indexOf(D)>-1})),c.length===0)return Promise.resolve().then(function(){if(u.hls){var A="no level with compatible codecs found in manifest",D=A;r.levels.length&&(D="one or more CODECS in variant not supported: "+It(r.levels.map(function(M){return M.attrs.CODECS}).filter(function(M,O,P){return P.indexOf(M)===O})),u.warn(D),A+=" ("+D+")");var _=new Error(A);u.hls.trigger(E.ERROR,{type:W.MEDIA_ERROR,details:I.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:r.url,error:_,reason:D})}}),void(f.end=performance.now());r.audioTracks&&un(d=r.audioTracks.filter(function(A){return!A.audioCodec||u.isAudioSupported(A.audioCodec)})),r.subtitles&&un(h=r.subtitles);var v=c.slice(0);c.sort(function(A,D){if(A.attrs["HDCP-LEVEL"]!==D.attrs["HDCP-LEVEL"])return(A.attrs["HDCP-LEVEL"]||"")>(D.attrs["HDCP-LEVEL"]||"")?1:-1;if(i&&A.height!==D.height)return A.height-D.height;if(A.frameRate!==D.frameRate)return A.frameRate-D.frameRate;if(A.videoRange!==D.videoRange)return ze.indexOf(A.videoRange)-ze.indexOf(D.videoRange);if(A.videoCodec!==D.videoCodec){var _=_i(A.videoCodec),M=_i(D.videoCodec);if(_!==M)return M-_}if(A.uri===D.uri&&A.codecSet!==D.codecSet){var O=We(A.codecSet),P=We(D.codecSet);if(O!==P)return P-O}return A.averageBitrate!==D.averageBitrate?A.averageBitrate-D.averageBitrate:0});var g=v[0];if(this.steering&&(c=this.steering.filterParsedLevels(c)).length!==v.length){for(var m=0;m<v.length;m++)if(v[m].pathwayId===c[0].pathwayId){g=v[m];break}}this._levels=c;for(var p=0;p<c.length;p++)if(c[p]===g){var y;this._firstLevel=p;var T=g.bitrate,S=this.hls.bandwidthEstimate;if(this.log("manifest loaded, "+c.length+" level(s) found, first bitrate: "+T),((y=this.hls.userConfig)==null?void 0:y.abrEwmaDefaultEstimate)===void 0){var b=Math.min(T,this.hls.config.abrEwmaDefaultEstimateMax);b>S&&S===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=b)}break}var L=o&&!a,R=this.hls.config,k=!(!R.audioStreamController||!R.audioTrackController),C={levels:c,audioTracks:d,subtitleTracks:h,sessionData:r.sessionData,sessionKeys:r.sessionKeys,firstLevel:this._firstLevel,stats:r.stats,audio:o,video:a,altAudio:k&&!L&&d.some(function(A){return!!A.url})};f.end=performance.now(),this.hls.trigger(E.MANIFEST_PARSED,C)},e.onError=function(t,r){!r.fatal&&r.context&&r.context.type===jt&&r.context.level===this.level&&this.checkRetry(r)},e.onFragBuffered=function(t,r){var i=r.frag;if(i!==void 0&&i.type===J){var a=i.elementaryStreams;if(!Object.keys(a).some(function(l){return!!a[l]}))return;var o=this._levels[i.level];o!=null&&o.loadError&&(this.log("Resetting level error count of "+o.loadError+" on frag buffered"),o.loadError=0)}},e.onLevelLoaded=function(t,r){var i,a,o=r.level,l=r.details,u=r.levelInfo;if(!u)return this.warn("Invalid level index "+o),void((a=r.deliveryDirectives)!=null&&a.skip&&(l.deltaUpdateFailed=!0));if(u===this.currentLevel||r.withoutMultiVariant){u.fragmentError===0&&(u.loadError=0);var d=u.details;d===r.details&&d.advanced&&(d=void 0),this.playlistLoaded(o,r,d)}else(i=r.deliveryDirectives)!=null&&i.skip&&(l.deltaUpdateFailed=!0)},e.loadPlaylist=function(t){n.prototype.loadPlaylist.call(this),this.shouldLoadPlaylist(this.currentLevel)&&this.scheduleLoading(this.currentLevel,t)},e.loadingPlaylist=function(t,r){n.prototype.loadingPlaylist.call(this,t,r);var i=this.getUrlWithDirectives(t.uri,r),a=this.currentLevelIndex,o=t.attrs["PATHWAY-ID"],l=t.details,u=l?.age;this.log("Loading level index "+a+(r?.msn!==void 0?" at sn "+r.msn+" part "+r.part:"")+(o?" Pathway "+o:"")+(u&&l.live?" age "+u.toFixed(1)+(l.type&&" "+l.type||""):"")+" "+i),this.hls.trigger(E.LEVEL_LOADING,{url:i,level:a,levelInfo:t,pathwayId:t.attrs["PATHWAY-ID"],id:0,deliveryDirectives:r||null})},e.removeLevel=function(t){var r,i=this;if(this._levels.length!==1){var a=this._levels.filter(function(l,u){return u!==t||(i.steering&&i.steering.removeLevel(l),l===i.currentLevel&&(i.currentLevel=null,i.currentLevelIndex=-1,l.details&&l.details.fragments.forEach(function(d){return d.level=-1})),!1)});Sa(a),this._levels=a,this.currentLevelIndex>-1&&(r=this.currentLevel)!=null&&r.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.manualLevelIndex>-1&&(this.manualLevelIndex=this.currentLevelIndex);var o=a.length-1;this._firstLevel=Math.min(this._firstLevel,o),this._startLevel&&(this._startLevel=Math.min(this._startLevel,o)),this.hls.trigger(E.LEVELS_UPDATED,{levels:a})}},e.onLevelsUpdated=function(t,r){var i=r.levels;this._levels=i},e.checkMaxAutoUpdated=function(){var t=this.hls,r=t.autoLevelCapping,i=t.maxAutoLevel,a=t.maxHdcpLevel;this._maxAutoLevel!==i&&(this._maxAutoLevel=i,this.hls.trigger(E.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:r,levels:this.levels,maxAutoLevel:i,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:a}))},yt(s,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"loadLevelObj",get:function(){return this.currentLevel}},{key:"level",get:function(){return this.currentLevelIndex},set:function(t){var r=this._levels;if(r.length!==0){if(t<0||t>=r.length){var i=new Error("invalid level idx"),a=t<0;if(this.hls.trigger(E.ERROR,{type:W.OTHER_ERROR,details:I.LEVEL_SWITCH_ERROR,level:t,fatal:a,error:i,reason:i.message}),a)return;t=Math.min(t,r.length-1)}var o=this.currentLevelIndex,l=this.currentLevel,u=l?l.attrs["PATHWAY-ID"]:void 0,d=r[t],h=d.attrs["PATHWAY-ID"];if(this.currentLevelIndex=t,this.currentLevel=d,o!==t||!l||u!==h){this.log("Switching to level "+t+" ("+(d.height?d.height+"p ":"")+(d.videoRange?d.videoRange+" ":"")+(d.codecSet?d.codecSet+" ":"")+"@"+d.bitrate+")"+(h?" with Pathway "+h:"")+" from level "+o+(u?" with Pathway "+u:""));var c={level:t,attrs:d.attrs,details:d.details,bitrate:d.bitrate,averageBitrate:d.averageBitrate,maxBitrate:d.maxBitrate,realBitrate:d.realBitrate,width:d.width,height:d.height,codecSet:d.codecSet,audioCodec:d.audioCodec,videoCodec:d.videoCodec,audioGroups:d.audioGroups,subtitleGroups:d.subtitleGroups,loaded:d.loaded,loadError:d.loadError,fragmentError:d.fragmentError,name:d.name,id:d.id,uri:d.uri,url:d.url,urlId:0,audioGroupIds:d.audioGroupIds,textGroupIds:d.textGroupIds};this.hls.trigger(E.LEVEL_SWITCHING,c);var f=d.details;if(!f||f.live){var v=this.switchParams(d.uri,l?.details,f);this.loadPlaylist(v)}}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(t){this.manualLevelIndex=t,this._startLevel===void 0&&(this._startLevel=t),t!==-1&&(this.level=t)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(t){this._firstLevel=t}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var t=this.hls.config.startLevel;return t!==void 0?t:this.hls.firstAutoLevel}return this._startLevel},set:function(t){this._startLevel=t}},{key:"pathways",get:function(){return this.steering?this.steering.pathways():[]}},{key:"pathwayPriority",get:function(){return this.steering?this.steering.pathwayPriority:null},set:function(t){if(this.steering){var r=this.steering.pathways(),i=t.filter(function(a){return r.indexOf(a)!==-1});if(t.length<1)return void this.warn("pathwayPriority "+t+" should contain at least one pathway from list: "+r);this.steering.pathwayPriority=i}}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(t){this.level=t,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=t)}}])}(qs);function un(n){var s={};n.forEach(function(e){var t=e.groupId||"";e.id=s[t]=s[t]||0,s[t]++})}var Xr=[];function Qr(n,s,e){if(!((t=s.remuxResult).audio||t.video||t.text||t.id3||t.initSegment))return!1;var t,r=[],i=s.remuxResult,a=i.audio,o=i.video;return a&&dn(r,a),o&&dn(r,o),n.postMessage({event:"transmuxComplete",data:s,instanceNo:e},r),!0}function dn(n,s){s.data1&&n.push(s.data1.buffer),s.data2&&n.push(s.data2.buffer)}function hn(n,s,e,t){s.reduce(function(r,i){return Qr(n,i,t)||r},!1)||n.postMessage({event:"transmuxComplete",data:s[0],instanceNo:t}),n.postMessage({event:"flush",data:e,instanceNo:t})}function Se(n,s,e){self.postMessage({event:n,data:s,instanceNo:e})}te!==void 0&&te&&self.addEventListener("message",function(n){var s=n.data,e=s.instanceNo;if(e!==void 0){var t=Xr[e];if(s.cmd==="reset"&&(delete Xr[s.resetNo],t&&t.destroy(),s.cmd="init"),s.cmd==="init"){var r=JSON.parse(s.config),i=new cr;i.on(E.FRAG_DECRYPTED,Se),i.on(E.ERROR,Se);var a=di(r.debug,s.id);return function(d,h){var c=function(v){d[v]=function(){var g=Array.prototype.join.call(arguments," ");Se("workerLog",{logType:v,message:g},h)}};for(var f in d)c(f)}(a,e),Xr[e]=new Wr(i,s.typeSupported,r,"",s.id,a),void Se("init",null,e)}if(t)switch(s.cmd){case"configure":t.configure(s.config);break;case"demux":var o=t.push(s.data,s.decryptdata,s.chunkMeta,s.state);de(o)?o.then(function(d){Qr(self,d,e)}).catch(function(d){Se(E.ERROR,{instanceNo:e,type:W.MEDIA_ERROR,details:I.FRAG_PARSING_ERROR,chunkMeta:s.chunkMeta,fatal:!1,error:d,err:d,reason:"transmuxer-worker push error"},e)}):Qr(self,o,e);break;case"flush":var l=s.chunkMeta,u=t.flush(l);de(u)?u.then(function(d){hn(self,d,l,e)}).catch(function(d){Se(E.ERROR,{type:W.MEDIA_ERROR,details:I.FRAG_PARSING_ERROR,chunkMeta:s.chunkMeta,fatal:!1,error:d,err:d,reason:"transmuxer-worker flush error"},e)}):hn(self,u,l,e)}}});var Ve="1.6.14",Le={},fn=0,Xs=function(){function n(e,t,r,i){var a=this;this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=fn++,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=function(c){var f=c.data,v=a.hls;if(v&&f!=null&&f.event&&f.instanceNo===a.instanceNo)switch(f.event){case"init":var g,m=(g=a.workerContext)==null?void 0:g.objectURL;m&&self.URL.revokeObjectURL(m);break;case"transmuxComplete":a.handleTransmuxComplete(f.data);break;case"flush":a.onFlush(f.data);break;case"workerLog":v.logger[f.data.logType]&&v.logger[f.data.logType](f.data.message);break;default:f.data=f.data||{},f.data.frag=a.frag,f.data.part=a.part,f.data.id=a.id,v.trigger(f.event,f.data)}},this.onWorkerError=function(c){if(a.hls){var f=new Error(c.message+" ("+c.filename+":"+c.lineno+")");a.hls.config.enableWorker=!1,a.hls.logger.warn('Error in "'+a.id+'" Web Worker, fallback to inline'),a.hls.trigger(E.ERROR,{type:W.OTHER_ERROR,details:I.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:f})}};var o=e.config;this.hls=e,this.id=t,this.useWorker=!!o.enableWorker,this.onTransmuxComplete=r,this.onFlush=i;var l=function(c,f){(f=f||{}).frag=a.frag||void 0,c===E.ERROR&&(f.parent=a.id,f.part=a.part,a.error=f.error),a.hls.trigger(c,f)};this.observer=new cr,this.observer.on(E.FRAG_DECRYPTED,l),this.observer.on(E.ERROR,l);var u=Ci(o.preferManagedMediaSource);if(this.useWorker&&typeof Worker<"u"){var d=this.hls.logger;o.workerPath;try{o.workerPath?(d.log("loading Web Worker "+o.workerPath+' for "'+t+'"'),this.workerContext=function(c){var f=Le[c];if(f)return f.clientCount++,f;var v=new self.URL(c,self.location.href).href,g={worker:new self.Worker(v),scriptURL:v,clientCount:1};return Le[c]=g,g}(o.workerPath)):(d.log('injecting Web Worker for "'+t+'"'),this.workerContext=function(){var c=Le[Ve];if(c)return c.clientCount++,c;var f=new self.Blob(["var exports={};var module={exports:exports};function define(f){f()};define.amd=true;("+be.toString()+")(true);"],{type:"text/javascript"}),v=self.URL.createObjectURL(f),g={worker:new self.Worker(v),objectURL:v,clientCount:1};return Le[Ve]=g,g}());var h=this.workerContext.worker;h.addEventListener("message",this.onWorkerMessage),h.addEventListener("error",this.onWorkerError),h.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:u,id:t,config:It(o)})}catch(c){d.warn('Error setting up "'+t+'" Web Worker, fallback to inline',c),this.terminateWorker(),this.error=null,this.transmuxer=new Wr(this.observer,u,o,"",t,e.logger)}}else this.transmuxer=new Wr(this.observer,u,o,"",t,e.logger)}var s=n.prototype;return s.reset=function(){if(this.frag=null,this.part=null,this.workerContext){var e=this.instanceNo;this.instanceNo=fn++;var t=this.hls.config,r=Ci(t.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:e,typeSupported:r,id:this.id,config:It(t)})}},s.terminateWorker=function(){if(this.workerContext){var e=this.workerContext.worker;this.workerContext=null,e.removeEventListener("message",this.onWorkerMessage),e.removeEventListener("error",this.onWorkerError),function(t){var r=Le[t||Ve];if(r&&r.clientCount--==1){var i=r.worker,a=r.objectURL;delete Le[t||Ve],a&&self.URL.revokeObjectURL(a),i.terminate()}}(this.hls.config.workerPath)}},s.destroy=function(){if(this.workerContext)this.terminateWorker(),this.onWorkerMessage=this.onWorkerError=null;else{var e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}var t=this.observer;t&&t.removeAllListeners(),this.frag=null,this.part=null,this.observer=null,this.hls=null},s.push=function(e,t,r,i,a,o,l,u,d,h){var c,f,v=this;d.transmuxing.start=self.performance.now();var g=this.instanceNo,m=this.transmuxer,p=o?o.start:a.start,y=a.decryptdata,T=this.frag,S=!(T&&a.cc===T.cc),b=!(T&&d.level===T.level),L=T?d.sn-T.sn:-1,R=this.part?d.part-this.part.index:-1,k=L===0&&d.id>1&&d.id===T?.stats.chunkCount,C=!b&&(L===1||L===0&&(R===1||k&&R<=0)),A=self.performance.now();(b||L||a.stats.parsing.start===0)&&(a.stats.parsing.start=A),!o||!R&&C||(o.stats.parsing.start=A);var D=!(T&&((c=a.initSegment)==null?void 0:c.url)===((f=T.initSegment)==null?void 0:f.url)),_=new Cs(S,C,u,b,p,D);if(!C||S||D){this.hls.logger.log("[transmuxer-interface]: Starting new transmux session for "+a.type+" sn: "+d.sn+(d.part>-1?" part: "+d.part:"")+" "+(this.id===J?"level":"track")+": "+d.level+" id: "+d.id+`
22
+ discontinuity: `+S+`
23
+ trackSwitch: `+b+`
24
+ contiguous: `+C+`
25
+ accurateTimeOffset: `+u+`
26
+ timeOffset: `+p+`
27
+ initSegmentChange: `+D);var M=new Is(r,i,t,l,h);this.configureTransmuxer(M)}if(this.frag=a,this.part=o,this.workerContext)this.workerContext.worker.postMessage({instanceNo:g,cmd:"demux",data:e,decryptdata:y,chunkMeta:d,state:_},e instanceof ArrayBuffer?[e]:[]);else if(m){var O=m.push(e,y,d,_);de(O)?O.then(function(P){v.handleTransmuxComplete(P)}).catch(function(P){v.transmuxerError(P,d,"transmuxer-interface push error")}):this.handleTransmuxComplete(O)}},s.flush=function(e){var t=this;e.transmuxing.start=self.performance.now();var r=this.instanceNo,i=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:r,cmd:"flush",chunkMeta:e});else if(i){var a=i.flush(e);de(a)?a.then(function(o){t.handleFlushResult(o,e)}).catch(function(o){t.transmuxerError(o,e,"transmuxer-interface flush error")}):this.handleFlushResult(a,e)}},s.transmuxerError=function(e,t,r){this.hls&&(this.error=e,this.hls.trigger(E.ERROR,{type:W.MEDIA_ERROR,details:I.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,part:this.part||void 0,fatal:!1,error:e,err:e,reason:r}))},s.handleFlushResult=function(e,t){var r=this;e.forEach(function(i){r.handleTransmuxComplete(i)}),this.onFlush(t)},s.configureTransmuxer=function(e){var t=this.instanceNo,r=this.transmuxer;this.workerContext?this.workerContext.worker.postMessage({instanceNo:t,cmd:"configure",config:e}):r&&r.configure(e)},s.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},n}();function cn(){return self.SourceBuffer||self.WebKitSourceBuffer}function vn(){if(!ae())return!1;var n=cn();return!n||n.prototype&&typeof n.prototype.appendBuffer=="function"&&typeof n.prototype.remove=="function"}var Qs=function(n){function s(t,r,i){var a;return(a=n.call(this,t,r,i,"stream-controller",J)||this).audioCodecSwap=!1,a.level=-1,a._forceStartLoad=!1,a._hasEnoughToStart=!1,a.altAudio=0,a.audioOnly=!1,a.fragPlaying=null,a.fragLastKbps=0,a.couldBacktrack=!1,a.backtrackFragment=null,a.audioCodecSwitch=!1,a.videoBuffer=null,a.onMediaPlaying=function(){a.tick()},a.onMediaSeeked=function(){var o=a.media,l=o?o.currentTime:null;if(l!==null&&U(l)&&(a.log("Media seeked to "+l.toFixed(3)),a.getBufferedFrag(l))){var u=a.getFwdBufferInfoAtPos(o,l,J,0);u!==null&&u.len!==0?a.tick():a.warn("Main forward buffer length at "+l+' on "seeked" event '+(u?u.len:"empty")+")")}},a.registerListeners(),a}ct(s,n);var e=s.prototype;return e.registerListeners=function(){n.prototype.registerListeners.call(this);var t=this.hls;t.on(E.MANIFEST_PARSED,this.onManifestParsed,this),t.on(E.LEVEL_LOADING,this.onLevelLoading,this),t.on(E.LEVEL_LOADED,this.onLevelLoaded,this),t.on(E.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(E.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(E.BUFFER_CREATED,this.onBufferCreated,this),t.on(E.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(E.FRAG_BUFFERED,this.onFragBuffered,this)},e.unregisterListeners=function(){n.prototype.unregisterListeners.call(this);var t=this.hls;t.off(E.MANIFEST_PARSED,this.onManifestParsed,this),t.off(E.LEVEL_LOADED,this.onLevelLoaded,this),t.off(E.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(E.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(E.BUFFER_CREATED,this.onBufferCreated,this),t.off(E.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(E.FRAG_BUFFERED,this.onFragBuffered,this)},e.onHandlerDestroying=function(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),n.prototype.onHandlerDestroying.call(this)},e.startLoad=function(t,r){if(this.levels){var i=this.lastCurrentTime,a=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,!this.startFragRequested){var o=a.startLevel;o===-1&&(a.config.testBandwidth&&this.levels.length>1?(o=0,this.bitrateTest=!0):o=a.firstAutoLevel),a.nextLoadLevel=o,this.level=a.loadLevel,this._hasEnoughToStart=!!r}i>0&&t===-1&&!r&&(this.log("Override startPosition with lastCurrentTime @"+i.toFixed(3)),t=i),this.state=F.IDLE,this.nextLoadPosition=this.lastCurrentTime=t+this.timelineOffset,this.startPosition=r?-1:t,this.tick()}else this._forceStartLoad=!0,this.state=F.STOPPED},e.stopLoad=function(){this._forceStartLoad=!1,n.prototype.stopLoad.call(this)},e.doTick=function(){switch(this.state){case F.WAITING_LEVEL:var t=this.levels,r=this.level,i=t?.[r],a=i?.details;if(a&&(!a.live||this.levelLastLoaded===i&&!this.waitForLive(i))){if(this.waitForCdnTuneIn(a))break;this.state=F.IDLE;break}if(this.hls.nextLoadLevel!==this.level){this.state=F.IDLE;break}break;case F.FRAG_LOADING_WAITING_RETRY:this.checkRetryDate()}this.state===F.IDLE&&this.doTickIdle(),this.onTickEnd()},e.onTickEnd=function(){var t;n.prototype.onTickEnd.call(this),(t=this.media)!=null&&t.readyState&&this.media.seeking===!1&&(this.lastCurrentTime=this.media.currentTime),this.checkFragmentChanged()},e.doTickIdle=function(){var t=this.hls,r=this.levelLastLoaded,i=this.levels,a=this.media;if(r!==null&&(a||this.primaryPrefetch||!this.startFragRequested&&t.config.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)){var o=this.buffering?t.nextLoadLevel:t.loadLevel;if(i!=null&&i[o]){var l=i[o],u=this.getMainFwdBufferInfo();if(u!==null){var d=this.getLevelDetails();if(d&&this._streamEnded(u,d)){var h={};return this.altAudio===2&&(h.type="video"),this.hls.trigger(E.BUFFER_EOS,h),void(this.state=F.ENDED)}if(this.buffering){t.loadLevel!==o&&t.manualLevel===-1&&this.log("Adapting to level "+o+" from level "+this.level),this.level=t.nextLoadLevel=o;var c=l.details;if(!c||this.state===F.WAITING_LEVEL||this.waitForLive(l))return this.level=o,this.state=F.WAITING_LEVEL,void(this.startFragRequested=!1);var f=u.len,v=this.getMaxBufferLength(l.maxBitrate);if(!(f>=v)){this.backtrackFragment&&this.backtrackFragment.start>u.end&&(this.backtrackFragment=null);var g=this.backtrackFragment?this.backtrackFragment.start:u.end,m=this.getNextFragment(g,c);if(this.couldBacktrack&&!this.fragPrevious&&m&&Mt(m)&&this.fragmentTracker.getState(m)!==Ue){var p,y=((p=this.backtrackFragment)!=null?p:m).sn-c.startSN,T=c.fragments[y-1];T&&m.cc===T.cc&&(m=T,this.fragmentTracker.removeFragment(T))}else this.backtrackFragment&&u.len&&(this.backtrackFragment=null);if(m&&this.isLoopLoading(m,g)){if(!m.gap){var S=this.audioOnly&&!this.altAudio?Ut:Qt,b=(S===Qt?this.videoBuffer:this.mediaBuffer)||this.media;b&&this.afterBufferFlushed(b,S,J)}m=this.getNextFragmentLoopLoading(m,c,u,J,v)}m&&(!m.initSegment||m.initSegment.data||this.bitrateTest||(m=m.initSegment),this.loadFragment(m,l,g))}}}}}},e.loadFragment=function(t,r,i){var a=this.fragmentTracker.getState(t);a===Xa||a===Be?Mt(t)?this.bitrateTest?(this.log("Fragment "+t.sn+" of level "+t.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(t,r)):n.prototype.loadFragment.call(this,t,r,i):this._loadInitSegment(t,r):this.clearTrackerIfNeeded(t)},e.getBufferedFrag=function(t){return this.fragmentTracker.getBufferedFrag(t,J)},e.followingBufferedFrag=function(t){return t?this.getBufferedFrag(t.end+.5):null},e.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},e.nextLevelSwitch=function(){var t=this.levels,r=this.media;if(r!=null&&r.readyState){var i,a=this.getAppendedFrag(r.currentTime);a&&a.start>1&&this.flushMainBuffer(0,a.start-1);var o=this.getLevelDetails();if(o!=null&&o.live){var l=this.getMainFwdBufferInfo();if(!l||l.len<2*o.targetduration)return}if(!r.paused&&t){var u=t[this.hls.nextLoadLevel],d=this.fragLastKbps;i=d&&this.fragCurrent?this.fragCurrent.duration*u.maxBitrate/(1e3*d)+1:0}else i=0;var h=this.getBufferedFrag(r.currentTime+i);if(h){var c=this.followingBufferedFrag(h);if(c){this.abortCurrentFrag();var f=c.maxStartPTS?c.maxStartPTS:c.start,v=c.duration,g=Math.max(h.end,f+Math.min(Math.max(v-this.config.maxFragLookUpTolerance,v*(this.couldBacktrack?.5:.125)),v*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(g,Number.POSITIVE_INFINITY)}}}},e.abortCurrentFrag=function(){var t=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,t&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.state){case F.KEY_LOADING:case F.FRAG_LOADING:case F.FRAG_LOADING_WAITING_RETRY:case F.PARSING:case F.PARSED:this.state=F.IDLE}this.nextLoadPosition=this.getLoadPosition()},e.flushMainBuffer=function(t,r){n.prototype.flushMainBuffer.call(this,t,r,this.altAudio===2?"video":null)},e.onMediaAttached=function(t,r){n.prototype.onMediaAttached.call(this,t,r);var i=r.media;he(i,"playing",this.onMediaPlaying),he(i,"seeked",this.onMediaSeeked)},e.onMediaDetaching=function(t,r){var i=this.media;i&&(se(i,"playing",this.onMediaPlaying),se(i,"seeked",this.onMediaSeeked)),this.videoBuffer=null,this.fragPlaying=null,n.prototype.onMediaDetaching.call(this,t,r),r.transferMedia||(this._hasEnoughToStart=!1)},e.onManifestLoading=function(){n.prototype.onManifestLoading.call(this),this.log("Trigger BUFFER_RESET"),this.hls.trigger(E.BUFFER_RESET,void 0),this.couldBacktrack=!1,this.fragLastKbps=0,this.fragPlaying=this.backtrackFragment=null,this.altAudio=0,this.audioOnly=!1},e.onManifestParsed=function(t,r){for(var i,a,o=!1,l=!1,u=0;u<r.levels.length;u++){var d=r.levels[u].audioCodec;d&&(o=o||d.indexOf("mp4a.40.2")!==-1,l=l||d.indexOf("mp4a.40.5")!==-1)}this.audioCodecSwitch=o&&l&&typeof((a=cn())==null||(i=a.prototype)==null?void 0:i.changeType)!="function",this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=r.levels,this.startFragRequested=!1},e.onLevelLoading=function(t,r){if(this.levels&&this.state===F.IDLE){var i=r.levelInfo;(!i.details||i.details.live&&(this.levelLastLoaded!==i||i.details.expired)||this.waitForCdnTuneIn(i.details))&&(this.state=F.WAITING_LEVEL)}},e.onLevelLoaded=function(t,r){var i,a=this.levels,o=this.startFragRequested,l=r.level,u=r.details,d=u.totalduration;if(a){this.log("Level "+l+" loaded ["+u.startSN+","+u.endSN+"]"+(u.lastPartSn?"[part-"+u.lastPartSn+"-"+u.lastPartIndex+"]":"")+", cc ["+u.startCC+", "+u.endCC+"] duration:"+d);var h=r.levelInfo,c=this.fragCurrent;!c||this.state!==F.FRAG_LOADING&&this.state!==F.FRAG_LOADING_WAITING_RETRY||c.level!==r.level&&c.loader&&this.abortCurrentFrag();var f=0;if(u.live||(i=h.details)!=null&&i.live){var v;if(this.checkLiveUpdate(u),u.deltaUpdateFailed)return;f=this.alignPlaylists(u,h.details,(v=this.levelLastLoaded)==null?void 0:v.details)}if(h.details=u,this.levelLastLoaded=h,o||this.setStartPosition(u,f),this.hls.trigger(E.LEVEL_UPDATED,{details:u,level:l}),this.state===F.WAITING_LEVEL){if(this.waitForCdnTuneIn(u))return;this.state=F.IDLE}o&&u.live&&this.synchronizeToLiveEdge(u),this.tick()}else this.warn("Levels were reset while loading level "+l)},e.synchronizeToLiveEdge=function(t){var r=this.config,i=this.media;if(i){var a=this.hls.liveSyncPosition,o=this.getLoadPosition(),l=t.fragmentStart,u=t.edge,d=o>=l-r.maxFragLookUpTolerance&&o<=u;if(a!==null&&i.duration>a&&(o<a||!d)){var h=r.liveMaxLatencyDuration!==void 0?r.liveMaxLatencyDuration:r.liveMaxLatencyDurationCount*t.targetduration;if((!d&&i.readyState<4||o<u-h)&&(this._hasEnoughToStart||(this.nextLoadPosition=a),i.readyState))if(this.warn("Playback: "+o.toFixed(3)+" is located too far from the end of live sliding playlist: "+u+", reset currentTime to : "+a.toFixed(3)),this.config.liveSyncMode==="buffered"){var c,f=et.bufferInfo(i,a,0);if((c=f.buffered)==null||!c.length||f.start<=o)return void(i.currentTime=a);var v=et.bufferedInfo(f.buffered,o,0).nextStart;v&&(i.currentTime=v)}else i.currentTime=a}}},e._handleFragmentLoadProgress=function(t){var r,i=t.frag,a=t.part,o=t.payload,l=this.levels;if(l){var u=l[i.level];if(u){var d=u.details;if(!d)return this.warn("Dropping fragment "+i.sn+" of level "+i.level+" after level details were reset"),void this.fragmentTracker.removeFragment(i);var h=u.videoCodec,c=d.PTSKnown||!d.live,f=(r=i.initSegment)==null?void 0:r.data,v=this._getAudioCodec(u),g=this.transmuxer=this.transmuxer||new Xs(this.hls,J,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),m=a?a.index:-1,p=m!==-1,y=new rn(i.level,i.sn,i.stats.chunkCount,o.byteLength,m,p),T=this.initPTS[i.cc];g.push(o,f,v,h,i,a,d.totalduration,c,y,T)}else this.warn("Level "+i.level+" not found on progress")}else this.warn("Levels were reset while fragment load was in progress. Fragment "+i.sn+" of level "+i.level+" will not be buffered")},e.onAudioTrackSwitching=function(t,r){var i=this,a=this.hls,o=this.altAudio===2;if(Ni(r.url,a))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;var l=this.fragCurrent;l&&(this.log("Switching to main audio track, cancel main fragment load"),l.abortRequests(),this.fragmentTracker.removeFragment(l)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();if(o)return this.fragmentTracker.removeAllFragments(),a.once(E.BUFFER_FLUSHED,function(){i.hls&&i.hls.trigger(E.AUDIO_TRACK_SWITCHED,r)}),void a.trigger(E.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});a.trigger(E.AUDIO_TRACK_SWITCHED,r)}},e.onAudioTrackSwitched=function(t,r){var i=Ni(r.url,this.hls);if(i){var a=this.videoBuffer;a&&this.mediaBuffer!==a&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=a)}this.altAudio=i?2:0,this.tick()},e.onBufferCreated=function(t,r){var i,a,o=r.tracks,l=!1;for(var u in o){var d=o[u];if(d.id==="main"){if(a=u,i=d,u==="video"){var h=o[u];h&&(this.videoBuffer=h.buffer)}}else l=!0}l&&i?(this.log("Alternate track found, use "+a+".buffered to schedule main fragment loading"),this.mediaBuffer=i.buffer):this.mediaBuffer=this.media},e.onFragBuffered=function(t,r){var i=r.frag,a=r.part,o=i.type===J;if(o){if(this.fragContextChanged(i))return this.warn("Fragment "+i.sn+(a?" p: "+a.index:"")+" of level "+i.level+" finished buffering, but was aborted. state: "+this.state),void(this.state===F.PARSED&&(this.state=F.IDLE));var l=a?a.stats:i.stats;this.fragLastKbps=Math.round(8*l.total/(l.buffering.end-l.loading.first)),Mt(i)&&(this.fragPrevious=i),this.fragBufferedComplete(i,a)}var u=this.media;u&&(!this._hasEnoughToStart&&et.getBuffered(u).length&&(this._hasEnoughToStart=!0,this.seekToStartPos()),o&&this.tick())},e.onError=function(t,r){var i;if(r.fatal)this.state=F.ERROR;else switch(r.details){case I.FRAG_GAP:case I.FRAG_PARSING_ERROR:case I.FRAG_DECRYPT_ERROR:case I.FRAG_LOAD_ERROR:case I.FRAG_LOAD_TIMEOUT:case I.KEY_LOAD_ERROR:case I.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(J,r);break;case I.LEVEL_LOAD_ERROR:case I.LEVEL_LOAD_TIMEOUT:case I.LEVEL_PARSING_ERROR:r.levelRetry||this.state!==F.WAITING_LEVEL||((i=r.context)==null?void 0:i.type)!==jt||(this.state=F.IDLE);break;case I.BUFFER_ADD_CODEC_ERROR:case I.BUFFER_APPEND_ERROR:if(r.parent!=="main")return;this.reduceLengthAndFlushBuffer(r)&&this.resetLoadingState();break;case I.BUFFER_FULL_ERROR:if(r.parent!=="main")return;this.reduceLengthAndFlushBuffer(r)&&(!this.config.interstitialsController&&this.config.assetPlayerId?this._hasEnoughToStart=!0:this.flushMainBuffer(0,Number.POSITIVE_INFINITY));break;case I.INTERNAL_EXCEPTION:this.recoverWorkerError(r)}},e.onFragLoadEmergencyAborted=function(){this.state=F.IDLE,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()},e.onBufferFlushed=function(t,r){var i=r.type;if(i!==Ut||!this.altAudio){var a=(i===Qt?this.videoBuffer:this.mediaBuffer)||this.media;a&&(this.afterBufferFlushed(a,i,J),this.tick())}},e.onLevelsUpdated=function(t,r){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level,this.level===-1&&this.resetWhenMissingContext(this.fragCurrent)),this.levels=r.levels},e.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},e.seekToStartPos=function(){var t=this.media;if(t){var r=t.currentTime,i=this.startPosition;if(i>=0&&r<i){if(t.seeking)return void this.log("could not seek to "+i+", already seeking at "+r);var a=this.timelineOffset;a&&i&&(i+=a);var o=this.getLevelDetails(),l=et.getBuffered(t),u=l.length?l.start(0):0,d=u-i,h=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);(this.config.startOnSegmentBoundary||d>0&&(d<h||this.loadingParts&&d<2*(o?.partTarget||0)))&&(this.log("adjusting start position by "+d+" to match buffer start"),i+=d,this.startPosition=i),r<i&&(this.log("seek to target start position "+i+" from current time "+r+" buffer start "+u),t.currentTime=i)}}},e._getAudioCodec=function(t){var r=this.config.defaultAudioCodec||t.audioCodec;return this.audioCodecSwap&&r&&(this.log("Swapping audio codec"),r=r.indexOf("mp4a.40.5")!==-1?"mp4a.40.2":"mp4a.40.5"),r},e._loadBitrateTestFrag=function(t,r){var i=this;t.bitrateTest=!0,this._doFragLoad(t,r).then(function(a){var o=i.hls,l=a?.frag;if(l&&!i.fragContextChanged(l)){r.fragmentError=0,i.state=F.IDLE,i.startFragRequested=!1,i.bitrateTest=!1;var u=l.stats;u.parsing.start=u.parsing.end=u.buffering.start=u.buffering.end=self.performance.now(),o.trigger(E.FRAG_LOADED,a),l.bitrateTest=!1}}).catch(function(a){i.state!==F.STOPPED&&i.state!==F.ERROR&&(i.warn(a),i.resetFragmentLoading(t))})},e._handleTransmuxComplete=function(t){var r=this.playlistType,i=this.hls,a=t.remuxResult,o=t.chunkMeta,l=this.getCurrentContext(o);if(l){var u=l.frag,d=l.part,h=l.level,c=a.video,f=a.text,v=a.id3,g=a.initSegment,m=h.details,p=this.altAudio?void 0:a.audio;if(this.fragContextChanged(u))this.fragmentTracker.removeFragment(u);else{if(this.state=F.PARSING,g){var y=g.tracks;if(y){var T=u.initSegment||u;if(this.unhandledEncryptionError(g,u))return;this._bufferInitSegment(h,y,T,o),i.trigger(E.FRAG_PARSING_INIT_SEGMENT,{frag:T,id:r,tracks:y})}var S=g.initPTS,b=g.timescale,L=this.initPTS[u.cc];if(U(S)&&(!L||L.baseTime!==S||L.timescale!==b)){var R=g.trackId;this.initPTS[u.cc]={baseTime:S,timescale:b,trackId:R},i.trigger(E.INIT_PTS_FOUND,{frag:u,id:r,initPTS:S,timescale:b,trackId:R})}}if(c&&m){p&&c.type==="audiovideo"&&this.logMuxedErr(u);var k=m.fragments[u.sn-1-m.startSN],C=u.sn===m.startSN,A=!k||u.cc>k.cc;if(a.independent!==!1){var D=c.startPTS,_=c.endPTS,M=c.startDTS,O=c.endDTS;if(d)d.elementaryStreams[c.type]={startPTS:D,endPTS:_,startDTS:M,endDTS:O};else if(c.firstKeyFrame&&c.independent&&o.id===1&&!A&&(this.couldBacktrack=!0),c.dropped&&c.independent){var P=this.getMainFwdBufferInfo(),w=(P?P.end:this.getLoadPosition())+this.config.maxBufferHole,x=c.firstKeyFramePTS?c.firstKeyFramePTS:D;if(!C&&w<x-this.config.maxBufferHole&&!A)return void this.backtrack(u);A&&(u.gap=!0),u.setElementaryStreamInfo(c.type,u.start,_,u.start,O,!0)}else C&&D-(m.appliedTimelineOffset||0)>2&&(u.gap=!0);u.setElementaryStreamInfo(c.type,D,_,M,O),this.backtrackFragment&&(this.backtrackFragment=u),this.bufferFragmentData(c,u,d,o,C||A)}else{if(!C&&!A)return void this.backtrack(u);u.gap=!0}}if(p){var N=p.startPTS,G=p.endPTS,B=p.startDTS,V=p.endDTS;d&&(d.elementaryStreams[Ut]={startPTS:N,endPTS:G,startDTS:B,endDTS:V}),u.setElementaryStreamInfo(Ut,N,G,B,V),this.bufferFragmentData(p,u,d,o)}if(m&&v!=null&&v.samples.length){var st={id:r,frag:u,details:m,samples:v.samples};i.trigger(E.FRAG_PARSING_METADATA,st)}if(m&&f){var tt={id:r,frag:u,details:m,samples:f.samples};i.trigger(E.FRAG_PARSING_USERDATA,tt)}}}else this.resetWhenMissingContext(o)},e.logMuxedErr=function(t){this.warn((Mt(t)?"Media":"Init")+" segment with muxed audiovideo where only video expected: "+t.url)},e._bufferInitSegment=function(t,r,i,a){var o=this;if(this.state===F.PARSING){this.audioOnly=!!r.audio&&!r.video,this.altAudio&&!this.audioOnly&&(delete r.audio,r.audiovideo&&this.logMuxedErr(i));var l=r.audio,u=r.video,d=r.audiovideo;if(l){var h=t.audioCodec,c=qe(l.codec,h);c==="mp4a"&&(c="mp4a.40.5");var f=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){c&&(c=c.indexOf("mp4a.40.5")!==-1?"mp4a.40.2":"mp4a.40.5");var v=l.metadata;v&&"channelCount"in v&&(v.channelCount||1)!==1&&f.indexOf("firefox")===-1&&(c="mp4a.40.5")}c&&c.indexOf("mp4a.40.5")!==-1&&f.indexOf("android")!==-1&&l.container!=="audio/mpeg"&&(c="mp4a.40.2",this.log("Android: force audio codec to "+c)),h&&h!==c&&this.log('Swapping manifest audio codec "'+h+'" for "'+c+'"'),l.levelCodec=c,l.id=J,this.log("Init audio buffer, container:"+l.container+", codecs[selected/level/parsed]=["+(c||"")+"/"+(h||"")+"/"+l.codec+"]"),delete r.audiovideo}if(u){u.levelCodec=t.videoCodec,u.id=J;var g=u.codec;if(g?.length===4)switch(g){case"hvc1":case"hev1":u.codec="hvc1.1.6.L120.90";break;case"av01":u.codec="av01.0.04M.08";break;case"avc1":u.codec="avc1.42e01e"}this.log("Init video buffer, container:"+u.container+", codecs[level/parsed]=["+(t.videoCodec||"")+"/"+g+"]"+(u.codec!==g?" parsed-corrected="+u.codec:"")+(u.supplemental?" supplemental="+u.supplemental:"")),delete r.audiovideo}d&&(this.log("Init audiovideo buffer, container:"+d.container+", codecs[level/parsed]=["+t.codecs+"/"+d.codec+"]"),delete r.video,delete r.audio);var m=Object.keys(r);if(m.length){if(this.hls.trigger(E.BUFFER_CODECS,r),!this.hls)return;m.forEach(function(p){var y=r[p].initSegment;y!=null&&y.byteLength&&o.hls.trigger(E.BUFFER_APPENDING,{type:p,data:y,frag:i,part:null,chunkMeta:a,parent:i.type})})}this.tickImmediate()}},e.getMainFwdBufferInfo=function(){var t=this.mediaBuffer&&this.altAudio===2?this.mediaBuffer:this.media;return this.getFwdBufferInfo(t,J)},e.backtrack=function(t){this.couldBacktrack=!0,this.backtrackFragment=t,this.resetTransmuxer(),this.flushBufferGap(t),this.fragmentTracker.removeFragment(t),this.fragPrevious=null,this.nextLoadPosition=t.start,this.state=F.IDLE},e.checkFragmentChanged=function(){var t=this.media,r=null;if(t&&t.readyState>1&&t.seeking===!1){var i=t.currentTime;if(et.isBuffered(t,i)?r=this.getAppendedFrag(i):et.isBuffered(t,i+.1)&&(r=this.getAppendedFrag(i+.1)),r){this.backtrackFragment=null;var a=this.fragPlaying,o=r.level;a&&r.sn===a.sn&&a.level===o||(this.fragPlaying=r,this.hls.trigger(E.FRAG_CHANGED,{frag:r}),a&&a.level===o||this.hls.trigger(E.LEVEL_SWITCHED,{level:o}))}}},yt(s,[{key:"hasEnoughToStart",get:function(){return this._hasEnoughToStart}},{key:"maxBufferLength",get:function(){var t=this.levels,r=this.level,i=t?.[r];return i?this.getMaxBufferLength(i.maxBitrate):this.config.maxBufferLength}},{key:"nextLevel",get:function(){var t=this.nextBufferedFrag;return t?t.level:-1}},{key:"currentFrag",get:function(){var t;if(this.fragPlaying)return this.fragPlaying;var r=((t=this.media)==null?void 0:t.currentTime)||this.lastCurrentTime;return U(r)?this.getAppendedFrag(r):null}},{key:"currentProgramDateTime",get:function(){var t,r=((t=this.media)==null?void 0:t.currentTime)||this.lastCurrentTime;if(U(r)){var i=this.getLevelDetails(),a=this.currentFrag||(i?Dr(null,i.fragments,r):null);if(a){var o=a.programDateTime;if(o!==null){var l=o+1e3*(r-a.start);return new Date(l)}}}return null}},{key:"currentLevel",get:function(){var t=this.currentFrag;return t?t.level:-1}},{key:"nextBufferedFrag",get:function(){var t=this.currentFrag;return t?this.followingBufferedFrag(t):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}])}(Vs),$s=function(n){function s(t,r){var i;return(i=n.call(this,"key-loader",r)||this).config=void 0,i.keyIdToKeyInfo={},i.emeController=null,i.config=t,i}ct(s,n);var e=s.prototype;return e.abort=function(t){for(var r in this.keyIdToKeyInfo){var i=this.keyIdToKeyInfo[r].loader;if(i){var a;if(t&&t!==((a=i.context)==null?void 0:a.frag.type))return;i.abort()}}},e.detach=function(){for(var t in this.keyIdToKeyInfo){var r=this.keyIdToKeyInfo[t];(r.mediaKeySessionContext||r.decryptdata.isCommonEncryption)&&delete this.keyIdToKeyInfo[t]}},e.destroy=function(){for(var t in this.detach(),this.keyIdToKeyInfo){var r=this.keyIdToKeyInfo[t].loader;r&&r.destroy()}this.keyIdToKeyInfo={}},e.createKeyLoadError=function(t,r,i,a,o){return r===void 0&&(r=I.KEY_LOAD_ERROR),new Jt({type:W.NETWORK_ERROR,details:r,fatal:!1,frag:t,response:o,error:i,networkDetails:a})},e.loadClear=function(t,r,i){return null},e.load=function(t){var r=this;return!t.decryptdata&&t.encrypted&&this.emeController&&this.config.emeEnabled?this.emeController.selectKeySystemFormat(t).then(function(i){return r.loadInternal(t,i)}):this.loadInternal(t)},e.loadInternal=function(t,r){var i,a,o=t.decryptdata;if(!o){var l=new Error(r?"Expected frag.decryptdata to be defined after setting format "+r:"Missing decryption data on fragment in onKeyLoading (emeEnabled with controller: "+(this.emeController&&this.config.emeEnabled)+")");return Promise.reject(this.createKeyLoadError(t,I.KEY_LOAD_ERROR,l))}var u=o.uri;if(!u)return Promise.reject(this.createKeyLoadError(t,I.KEY_LOAD_ERROR,new Error('Invalid key URI: "'+u+'"')));var d=$r(o),h=this.keyIdToKeyInfo[d];if((i=h)!=null&&i.decryptdata.key)return o.key=h.decryptdata.key,Promise.resolve({frag:t,keyInfo:h});if(this.emeController&&(a=h)!=null&&a.keyLoadPromise)switch(this.emeController.getKeyStatus(h.decryptdata)){case"usable":case"usable-in-future":return h.keyLoadPromise.then(function(c){var f=c.keyInfo;return o.key=f.decryptdata.key,{frag:t,keyInfo:f}})}switch(this.log((this.keyIdToKeyInfo[d]?"Rel":"L")+"oading"+(o.keyId?" keyId: "+Ie(o.keyId):"")+" URI: "+o.uri+" from "+t.type+" "+t.level),h=this.keyIdToKeyInfo[d]={decryptdata:o,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},o.method){case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return o.keyFormat==="identity"?this.loadKeyHTTP(h,t):this.loadKeyEME(h,t);case"AES-128":case"AES-256":case"AES-256-CTR":return this.loadKeyHTTP(h,t);default:return Promise.reject(this.createKeyLoadError(t,I.KEY_LOAD_ERROR,new Error('Key supplied with unsupported METHOD: "'+o.method+'"')))}},e.loadKeyEME=function(t,r){var i={frag:r,keyInfo:t};if(this.emeController&&this.config.emeEnabled){var a;if(!t.decryptdata.keyId&&(a=r.initSegment)!=null&&a.data){var o=function(d){var h=[];return Ri(d,function(c){return h.push(c.subarray(8,24))}),h}(r.initSegment.data);if(o.length){var l=o[0];l.some(function(d){return d!==0})&&(this.log("Using keyId found in init segment "+Ie(l)),t.decryptdata.keyId=l,ia.setKeyIdForUri(t.decryptdata.uri,l))}}var u=this.emeController.loadKey(i);return(t.keyLoadPromise=u.then(function(d){return t.mediaKeySessionContext=d,i})).catch(function(d){throw t.keyLoadPromise=null,"data"in d&&(d.data.frag=r),d})}return Promise.resolve(i)},e.loadKeyHTTP=function(t,r){var i=this,a=this.config,o=new a.loader(a);return r.keyLoader=t.loader=o,t.keyLoadPromise=new Promise(function(l,u){var d={keyInfo:t,frag:r,responseType:"arraybuffer",url:t.decryptdata.uri},h=a.keyLoadPolicy.default,c={loadPolicy:h,timeout:h.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},f={onSuccess:function(v,g,m,p){var y=m.frag,T=m.keyInfo,S=$r(T.decryptdata);if(!y.decryptdata||T!==i.keyIdToKeyInfo[S])return u(i.createKeyLoadError(y,I.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),p));T.decryptdata.key=y.decryptdata.key=new Uint8Array(v.data),y.keyLoader=null,T.loader=null,l({frag:y,keyInfo:T})},onError:function(v,g,m,p){i.resetLoader(g),u(i.createKeyLoadError(r,I.KEY_LOAD_ERROR,new Error("HTTP Error "+v.code+" loading key "+v.text),m,wt({url:d.url,data:void 0},v)))},onTimeout:function(v,g,m){i.resetLoader(g),u(i.createKeyLoadError(r,I.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),m))},onAbort:function(v,g,m){i.resetLoader(g),u(i.createKeyLoadError(r,I.INTERNAL_ABORTED,new Error("key loading aborted"),m))}};o.load(d,c,f)})},e.resetLoader=function(t){var r=t.frag,i=t.keyInfo,a=t.url,o=i.loader;r.keyLoader===o&&(r.keyLoader=null,i.loader=null);var l=$r(i.decryptdata)||a;delete this.keyIdToKeyInfo[l],o&&o.destroy()},s}(Xt);function $r(n){return n.uri}function gn(n){switch(n.type){case qt:return ge;case zt:return _e;default:return J}}function Zr(n,s){var e=n.url;return e!==void 0&&e.indexOf("data:")!==0||(e=s.url),e}var Zs=function(){function n(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=e,this.registerListeners()}var s=n.prototype;return s.startLoad=function(e){},s.stopLoad=function(){this.destroyInternalLoaders()},s.registerListeners=function(){var e=this.hls;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)},s.unregisterListeners=function(){var e=this.hls;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)},s.createInternalLoader=function(e){var t=this.hls.config,r=t.pLoader,i=t.loader,a=new(r||i)(t);return this.loaders[e.type]=a,a},s.getInternalLoader=function(e){return this.loaders[e.type]},s.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},s.destroyInternalLoaders=function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}},s.destroy=function(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()},s.onManifestLoading=function(e,t){var r=t.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:re,url:r,deliveryDirectives:null,levelOrTrack:null})},s.onLevelLoading=function(e,t){var r=t.id,i=t.level,a=t.pathwayId,o=t.url,l=t.deliveryDirectives,u=t.levelInfo;this.load({id:r,level:i,pathwayId:a,responseType:"text",type:jt,url:o,deliveryDirectives:l,levelOrTrack:u})},s.onAudioTrackLoading=function(e,t){var r=t.id,i=t.groupId,a=t.url,o=t.deliveryDirectives,l=t.track;this.load({id:r,groupId:i,level:null,responseType:"text",type:qt,url:a,deliveryDirectives:o,levelOrTrack:l})},s.onSubtitleTrackLoading=function(e,t){var r=t.id,i=t.groupId,a=t.url,o=t.deliveryDirectives,l=t.track;this.load({id:r,groupId:i,level:null,responseType:"text",type:zt,url:a,deliveryDirectives:o,levelOrTrack:l})},s.onLevelsUpdated=function(e,t){var r=this.loaders[jt];if(r){var i=r.context;i&&!t.levels.some(function(a){return a===i.levelOrTrack})&&(r.abort(),delete this.loaders[jt])}},s.load=function(e){var t,r,i,a=this,o=this.hls.config,l=this.getInternalLoader(e);if(l){var u=this.hls.logger,d=l.context;if(d&&d.levelOrTrack===e.levelOrTrack&&(d.url===e.url||d.deliveryDirectives&&!e.deliveryDirectives))return void(d.url===e.url?u.log("[playlist-loader]: ignore "+e.url+" ongoing request"):u.log("[playlist-loader]: ignore "+e.url+" in favor of "+d.url));u.log("[playlist-loader]: aborting previous loader for type: "+e.type),l.abort()}if(r=e.type===re?o.manifestLoadPolicy.default:Et({},o.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),l=this.createInternalLoader(e),U((t=e.deliveryDirectives)==null?void 0:t.part)&&(e.type===jt&&e.level!==null?i=this.hls.levels[e.level].details:e.type===qt&&e.id!==null?i=this.hls.audioTracks[e.id].details:e.type===zt&&e.id!==null&&(i=this.hls.subtitleTracks[e.id].details),i)){var h=i.partTarget,c=i.targetduration;if(h&&c){var f=1e3*Math.max(3*h,.8*c);r=Et({},r,{maxTimeToFirstByteMs:Math.min(f,r.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(f,r.maxTimeToFirstByteMs)})}}var v=r.errorRetry||r.timeoutRetry||{},g={loadPolicy:r,timeout:r.maxLoadTimeMs,maxRetry:v.maxNumRetry||0,retryDelay:v.retryDelayMs||0,maxRetryDelay:v.maxRetryDelayMs||0},m={onSuccess:function(p,y,T,S){var b=a.getInternalLoader(T);a.resetInternalLoader(T.type);var L=p.data;y.parsing.start=performance.now(),Me.isMediaPlaylist(L)||T.type!==re?a.handleTrackOrLevelPlaylist(p,y,T,S||null,b):a.handleMasterPlaylist(p,y,T,S)},onError:function(p,y,T,S){a.handleNetworkError(y,T,!1,p,S)},onTimeout:function(p,y,T){a.handleNetworkError(y,T,!0,void 0,p)}};l.load(e,g,m)},s.checkAutostartLoad=function(){if(this.hls){var e=this.hls,t=e.config,r=t.autoStartLoad,i=t.startPosition,a=e.forceStartLoad;(r||a)&&(this.hls.logger.log((r?"auto":"force")+" startLoad with configured startPosition "+i),this.hls.startLoad(i))}},s.handleMasterPlaylist=function(e,t,r,i){var a=this,o=this.hls,l=e.data,u=Zr(e,r),d=Me.parseMasterPlaylist(l,u);if(d.playlistParsingError)return t.parsing.end=performance.now(),void this.handleManifestParsingError(e,r,d.playlistParsingError,i,t);var h=d.contentSteering,c=d.levels,f=d.sessionData,v=d.sessionKeys,g=d.startTimeOffset,m=d.variableList;this.variableList=m,c.forEach(function(L){var R=L.unknownCodecs;if(R)for(var k=a.hls.config.preferManagedMediaSource,C=L.audioCodec,A=L.videoCodec,D=R.length;D--;){var _=R[D];Ce(_,"audio",k)?(L.audioCodec=C=C?C+","+_:_,pe.audio[C.substring(0,4)]=2,R.splice(D,1)):Ce(_,"video",k)&&(L.videoCodec=A=A?A+","+_:_,pe.video[A.substring(0,4)]=2,R.splice(D,1))}});var p=Me.parseMasterPlaylistMedia(l,u,d),y=p.AUDIO,T=y===void 0?[]:y,S=p.SUBTITLES,b=p["CLOSED-CAPTIONS"];T.length&&(T.some(function(L){return!L.url})||!c[0].audioCodec||c[0].attrs.AUDIO||(this.hls.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),T.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new gt({}),bitrate:0,url:""}))),o.trigger(E.MANIFEST_LOADED,{levels:c,audioTracks:T,subtitles:S,captions:b,contentSteering:h,url:u,stats:t,networkDetails:i,sessionData:f,sessionKeys:v,startTimeOffset:g,variableList:m})},s.handleTrackOrLevelPlaylist=function(e,t,r,i,a){var o=this.hls,l=r.id,u=r.level,d=r.type,h=Zr(e,r),c=U(u)?u:U(l)?l:0,f=gn(r),v=Me.parseLevelPlaylist(e.data,h,c,f,0,this.variableList);if(d===re){var g={attrs:new gt({}),bitrate:0,details:v,name:"",url:h};v.requestScheduled=t.loading.start+pa(v,0),o.trigger(E.MANIFEST_LOADED,{levels:[g],audioTracks:[],url:h,stats:t,networkDetails:i,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),r.levelDetails=v,this.handlePlaylistLoaded(v,e,t,r,i,a)},s.handleManifestParsingError=function(e,t,r,i,a){this.hls.trigger(E.ERROR,{type:W.NETWORK_ERROR,details:I.MANIFEST_PARSING_ERROR,fatal:t.type===re,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:i,stats:a})},s.handleNetworkError=function(e,t,r,i,a){r===void 0&&(r=!1);var o="A network "+(r?"timeout":"error"+(i?" (status "+i.code+")":""))+" occurred while loading "+e.type;e.type===jt?o+=": "+e.level+" id: "+e.id:e.type!==qt&&e.type!==zt||(o+=" id: "+e.id+' group-id: "'+e.groupId+'"');var l=new Error(o);this.hls.logger.warn("[playlist-loader]: "+o);var u=I.UNKNOWN,d=!1,h=this.getInternalLoader(e);switch(e.type){case re:u=r?I.MANIFEST_LOAD_TIMEOUT:I.MANIFEST_LOAD_ERROR,d=!0;break;case jt:u=r?I.LEVEL_LOAD_TIMEOUT:I.LEVEL_LOAD_ERROR,d=!1;break;case qt:u=r?I.AUDIO_TRACK_LOAD_TIMEOUT:I.AUDIO_TRACK_LOAD_ERROR,d=!1;break;case zt:u=r?I.SUBTITLE_TRACK_LOAD_TIMEOUT:I.SUBTITLE_LOAD_ERROR,d=!1}h&&this.resetInternalLoader(e.type);var c={type:W.NETWORK_ERROR,details:u,fatal:d,url:e.url,loader:h,context:e,error:l,networkDetails:t,stats:a};if(i){var f=t?.url||e.url;c.response=wt({url:f,data:void 0},i)}this.hls.trigger(E.ERROR,c)},s.handlePlaylistLoaded=function(e,t,r,i,a,o){var l=this.hls,u=i.type,d=i.level,h=i.levelOrTrack,c=i.id,f=i.groupId,v=i.deliveryDirectives,g=Zr(t,i),m=gn(i),p=typeof i.level=="number"&&m===J?d:void 0,y=e.playlistParsingError;if(y){if(this.hls.logger.warn(y+" "+e.url),!l.config.ignorePlaylistParsingErrors)return void l.trigger(E.ERROR,{type:W.NETWORK_ERROR,details:I.LEVEL_PARSING_ERROR,fatal:!1,url:g,error:y,reason:y.message,response:t,context:i,level:p,parent:m,networkDetails:a,stats:r});e.playlistParsingError=null}if(e.fragments.length)switch(e.live&&o&&(o.getCacheAge&&(e.ageHeader=o.getCacheAge()||0),o.getCacheAge&&!isNaN(e.ageHeader)||(e.ageHeader=0)),u){case re:case jt:if(p)if(h){if(h!==l.levels[p]){var T=l.levels.indexOf(h);T>-1&&(p=T)}}else p=0;l.trigger(E.LEVEL_LOADED,{details:e,levelInfo:h||l.levels[0],level:p||0,id:c||0,stats:r,networkDetails:a,deliveryDirectives:v,withoutMultiVariant:u===re});break;case qt:l.trigger(E.AUDIO_TRACK_LOADED,{details:e,track:h,id:c||0,groupId:f||"",stats:r,networkDetails:a,deliveryDirectives:v});break;case zt:l.trigger(E.SUBTITLE_TRACK_LOADED,{details:e,track:h,id:c||0,groupId:f||"",stats:r,networkDetails:a,deliveryDirectives:v})}else{var S=e.playlistParsingError=new Error("No Segments found in Playlist");l.trigger(E.ERROR,{type:W.NETWORK_ERROR,details:I.LEVEL_EMPTY_ERROR,fatal:!1,url:g,error:S,reason:S.message,response:t,context:i,level:p,parent:m,networkDetails:a,stats:r})}},n}(),Js={supported:!1,smooth:!1,powerEfficient:!1},to={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]};function eo(n,s,e,t){t===void 0&&(t={});var r=n.videoCodec;if(!r&&!n.audioCodec||!e)return Promise.resolve(to);for(var i=[],a=function(v){var g,m=(g=v.videoCodec)==null?void 0:g.split(","),p=mn(v),y=v.width||640,T=v.height||480,S=v.frameRate||30,b=v.videoRange.toLowerCase();return m?m.map(function(L){var R={contentType:Pe(xn(L),"video"),width:y,height:T,bitrate:p,framerate:S};return b!=="sdr"&&(R.transferFunction=b),R}):[]}(n),o=a.length,l=function(v,g,m){var p,y=(p=v.audioCodec)==null?void 0:p.split(","),T=mn(v);return y&&v.audioGroups?v.audioGroups.reduce(function(S,b){var L,R=b?(L=g.groups[b])==null?void 0:L.tracks:null;return R?R.reduce(function(k,C){if(C.groupId===b){var A=parseFloat(C.channels||"");y.forEach(function(D){var _={contentType:Pe(D,"audio"),bitrate:m?ro(D,T):T};A&&(_.channels=""+A),k.push(_)})}return k},S):S},[]):[]}(n,s,o>0),u=l.length,d=o||1*u||1;d--;){var h={type:"media-source"};if(o&&(h.video=a[d%o]),u){h.audio=l[d%u];var c=h.audio.bitrate;h.video&&c&&(h.video.bitrate-=c)}i.push(h)}if(r){var f=navigator.userAgent;if(r.split(",").some(function(v){return Sr(v)})&&Di())return Promise.resolve(function(v,g){return{supported:!1,configurations:g,decodingInfoResults:[Js],error:v}}(new Error("Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent string: ("+f+")"),i))}return Promise.all(i.map(function(v){var g,m,p,y,T=(m="",p=(g=v).audio,(y=g.video)&&(m+=br(y.contentType)+"_r"+y.height+"x"+y.width+"f"+Math.ceil(y.framerate)+(y.transferFunction||"sd")+"_"+Math.ceil(y.bitrate/1e5)),p&&(m+=(y?"_":"")+br(p.contentType)+"_c"+p.channels),m);return t[T]||(t[T]=e.decodingInfo(v))})).then(function(v){return{supported:!v.some(function(g){return!g.supported}),configurations:i,decodingInfoResults:v}}).catch(function(v){return{supported:!1,configurations:i,decodingInfoResults:[],error:v}})}function ro(n,s){if(s<=1)return 1;var e=128e3;return n==="ec-3"?e=768e3:n==="ac-3"&&(e=64e4),Math.min(s/2,e)}function mn(n){return 1e3*Math.ceil(Math.max(.9*n.bitrate,n.averageBitrate)/1e3)||1}var pn=function(){function n(e){e===void 0&&(e={}),this.config=void 0,this.userConfig=void 0,this.logger=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new cr,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;var t=this.logger=di(e.debug||!1,"Hls instance",e.assetPlayerId),r=this.config=function(P,w,x){if((w.liveSyncDurationCount||w.liveMaxLatencyDurationCount)&&(w.liveSyncDuration||w.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(w.liveMaxLatencyDurationCount!==void 0&&(w.liveSyncDurationCount===void 0||w.liveMaxLatencyDurationCount<=w.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(w.liveMaxLatencyDuration!==void 0&&(w.liveSyncDuration===void 0||w.liveMaxLatencyDuration<=w.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var N=qr(P),G=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach(function(B){var V=(B==="level"?"playlist":B)+"LoadPolicy",st=w[V]===void 0,tt=[];G.forEach(function($){var ot=B+"Loading"+$,rt=w[ot];if(rt!==void 0&&st){tt.push(ot);var K=N[V].default;switch(w[V]={default:K},$){case"TimeOut":K.maxLoadTimeMs=rt,K.maxTimeToFirstByteMs=rt;break;case"MaxRetry":K.errorRetry.maxNumRetry=rt,K.timeoutRetry.maxNumRetry=rt;break;case"RetryDelay":K.errorRetry.retryDelayMs=rt,K.timeoutRetry.retryDelayMs=rt;break;case"MaxRetryTimeout":K.errorRetry.maxRetryDelayMs=rt,K.timeoutRetry.maxRetryDelayMs=rt}}}),tt.length&&x.warn('hls.js config: "'+tt.join('", "')+'" setting(s) are deprecated, use "'+V+'": '+It(w[V]))}),wt(wt({},N),w)}(n.DefaultConfig,e,t);this.userConfig=e,r.progressive&&Ms(r,t);var i=r.abrController,a=r.bufferController,o=r.capLevelController,l=r.errorController,u=r.fpsController,d=new l(this),h=this.abrController=new i(this),c=new Ns(this),f=r.interstitialsController,v=f?this.interstitialsController=new f(this,n):null,g=this.bufferController=new a(this,c),m=this.capLevelController=new o(this),p=new u(this),y=new Zs(this),T=r.contentSteeringController,S=T?new T(this):null,b=this.levelController=new zs(this,S),L=new Ws(this),R=new $s(this.config,this.logger),k=this.streamController=new Qs(this,c,R),C=this.gapController=new Hs(this,c);m.setStreamController(k),p.setStreamController(k);var A=[y,b,k];v&&A.splice(1,0,v),S&&A.splice(1,0,S),this.networkControllers=A;var D=[h,g,C,m,p,L,c];this.audioTrackController=this.createController(r.audioTrackController,A);var _=r.audioStreamController;_&&A.push(this.audioStreamController=new _(this,c,R)),this.subtitleTrackController=this.createController(r.subtitleTrackController,A);var M=r.subtitleStreamController;M&&A.push(this.subtititleStreamController=new M(this,c,R)),this.createController(r.timelineController,D),R.emeController=this.emeController=this.createController(r.emeController,D),this.cmcdController=this.createController(r.cmcdController,D),this.latencyController=this.createController(js,D),this.coreComponents=D,A.push(d);var O=d.onErrorOut;typeof O=="function"&&this.on(E.ERROR,O,d),this.on(E.MANIFEST_LOADED,y.onManifestLoaded,y)}n.isMSESupported=function(){return vn()},n.isSupported=function(){return function(){if(!vn())return!1;var e=ae();return typeof e?.isTypeSupported=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(function(t){return e.isTypeSupported(Pe(t,"video"))})||["mp4a.40.2","fLaC"].some(function(t){return e.isTypeSupported(Pe(t,"audio"))}))}()},n.getMediaSource=function(){return ae()};var s=n.prototype;return s.createController=function(e,t){if(e){var r=new e(this);return t&&t.push(r),r}return null},s.on=function(e,t,r){r===void 0&&(r=this),this._emitter.on(e,t,r)},s.once=function(e,t,r){r===void 0&&(r=this),this._emitter.once(e,t,r)},s.removeAllListeners=function(e){this._emitter.removeAllListeners(e)},s.off=function(e,t,r,i){r===void 0&&(r=this),this._emitter.off(e,t,r,i)},s.listeners=function(e){return this._emitter.listeners(e)},s.emit=function(e,t,r){return this._emitter.emit(e,t,r)},s.trigger=function(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;var r=e===E.ERROR;this.trigger(E.ERROR,{type:W.OTHER_ERROR,details:I.INTERNAL_EXCEPTION,fatal:r,event:e,error:i}),this.triggeringException=!1}}return!1},s.listenerCount=function(e){return this._emitter.listenerCount(e)},s.destroy=function(){this.logger.log("destroy"),this.trigger(E.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this._url=null,this.networkControllers.forEach(function(t){return t.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(t){return t.destroy()}),this.coreComponents.length=0;var e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null},s.attachMedia=function(e){if(!e||"media"in e&&!e.media){var t=new Error("attachMedia failed: invalid argument ("+e+")");this.trigger(E.ERROR,{type:W.OTHER_ERROR,details:I.ATTACH_MEDIA_ERROR,fatal:!0,error:t})}else{this.logger.log("attachMedia"),this._media&&(this.logger.warn("media must be detached before attaching"),this.detachMedia());var r="media"in e,i=r?e.media:e,a=r?e:{media:i};this._media=i,this.trigger(E.MEDIA_ATTACHING,a)}},s.detachMedia=function(){this.logger.log("detachMedia"),this.trigger(E.MEDIA_DETACHING,{}),this._media=null},s.transferMedia=function(){this._media=null;var e=this.bufferController.transferMedia();return this.trigger(E.MEDIA_DETACHING,{transferMedia:e}),e},s.loadSource=function(e){this.stopLoad();var t=this.media,r=this._url,i=this._url=vr.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log("loadSource:"+i),t&&r&&(r!==i||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(E.MANIFEST_LOADING,{url:e})},s.startLoad=function(e,t){e===void 0&&(e=-1),this.logger.log("startLoad("+e+(t?", <skip seek to start>":"")+")"),this.started=!0,this.resumeBuffering();for(var r=0;r<this.networkControllers.length&&(this.networkControllers[r].startLoad(e,t),this.started&&this.networkControllers);r++);},s.stopLoad=function(){this.logger.log("stopLoad"),this.started=!1;for(var e=0;e<this.networkControllers.length&&(this.networkControllers[e].stopLoad(),!this.started&&this.networkControllers);e++);},s.resumeBuffering=function(){this.bufferingEnabled||(this.logger.log("resume buffering"),this.networkControllers.forEach(function(e){e.resumeBuffering&&e.resumeBuffering()}))},s.pauseBuffering=function(){this.bufferingEnabled&&(this.logger.log("pause buffering"),this.networkControllers.forEach(function(e){e.pauseBuffering&&e.pauseBuffering()}))},s.swapAudioCodec=function(){this.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},s.recoverMediaError=function(){this.logger.log("recoverMediaError");var e=this._media,t=e?.currentTime;this.detachMedia(),e&&(this.attachMedia(e),t&&this.startLoad(t))},s.removeLevel=function(e){this.levelController.removeLevel(e)},s.setAudioOption=function(e){var t;return((t=this.audioTrackController)==null?void 0:t.setAudioOption(e))||null},s.setSubtitleOption=function(e){var t;return((t=this.subtitleTrackController)==null?void 0:t.setSubtitleOption(e))||null},s.getMediaDecodingInfo=function(e,t){return t===void 0&&(t=this.allAudioTracks),eo(e,Mi(t),navigator.mediaCapabilities)},yt(n,[{key:"url",get:function(){return this._url}},{key:"hasEnoughToStart",get:function(){return this.streamController.hasEnoughToStart}},{key:"startPosition",get:function(){return this.streamController.startPositionValue}},{key:"loadingEnabled",get:function(){return this.started}},{key:"bufferingEnabled",get:function(){return this.streamController.bufferingEnabled}},{key:"inFlightFragments",get:function(){var e,t=((e={})[J]=this.streamController.inFlightFrag,e);return this.audioStreamController&&(t[ge]=this.audioStreamController.inFlightFrag),this.subtititleStreamController&&(t[_e]=this.subtititleStreamController.inFlightFrag),t}},{key:"sessionId",get:function(){var e=this._sessionId;return e||(e=this._sessionId=function(){try{return crypto.randomUUID()}catch{try{var t=URL.createObjectURL(new Blob),r=t.toString();return URL.revokeObjectURL(t),r.slice(r.lastIndexOf("/")+1)}catch{var i=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(l){var u=(i+16*Math.random())%16|0;return i=Math.floor(i/16),(l=="x"?u:3&u|8).toString(16)})}}}()),e}},{key:"levels",get:function(){var e=this.levelController.levels;return e||[]}},{key:"latestLevelDetails",get:function(){return this.streamController.getLevelDetails()||null}},{key:"loadLevelObj",get:function(){return this.levelController.loadLevelObj}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(e){this.logger.log("set currentLevel:"+e),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(e){this.logger.log("set nextLevel:"+e),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(e){this.logger.log("set loadLevel:"+e),this.levelController.manualLevel=e}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(e){this.levelController.nextLoadLevel=e}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(e){this.logger.log("set firstLevel:"+e),this.levelController.firstLevel=e}},{key:"startLevel",get:function(){var e=this.levelController.startLevel;return e===-1&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e},set:function(e){this.logger.log("set startLevel:"+e),e!==-1&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(e){var t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(e){this._autoLevelCapping!==e&&(this.logger.log("set autoLevelCapping:"+e),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}},{key:"bandwidthEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimate():NaN},set:function(e){this.abrController.resetEstimator(e)}},{key:"abrEwmaDefaultEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.defaultEstimate:NaN}},{key:"ttfbEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimateTTFB():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(e){(function(t){return kr.indexOf(t)>-1})(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var e=this.levels,t=this.config.minAutoBitrate;if(!e)return 0;for(var r=e.length,i=0;i<r;i++)if(e[i].maxBitrate>=t)return i;return 0}},{key:"maxAutoLevel",get:function(){var e,t=this.levels,r=this.autoLevelCapping,i=this.maxHdcpLevel;if(e=r===-1&&t!=null&&t.length?t.length-1:r,i)for(var a=e;a--;){var o=t[a].attrs["HDCP-LEVEL"];if(o&&o<=i)return a}return e}},{key:"firstAutoLevel",get:function(){return this.abrController.firstAutoLevel}},{key:"nextAutoLevel",get:function(){return this.abrController.nextAutoLevel},set:function(e){this.abrController.nextAutoLevel=e}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"maxBufferLength",get:function(){return this.streamController.maxBufferLength}},{key:"allAudioTracks",get:function(){var e=this.audioTrackController;return e?e.allAudioTracks:[]}},{key:"audioTracks",get:function(){var e=this.audioTrackController;return e?e.audioTracks:[]}},{key:"audioTrack",get:function(){var e=this.audioTrackController;return e?e.audioTrack:-1},set:function(e){var t=this.audioTrackController;t&&(t.audioTrack=e)}},{key:"allSubtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}},{key:"subtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTrack:-1},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var e=this.subtitleTrackController;return!!e&&e.subtitleDisplay},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(e){this.config.lowLatencyMode=e}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency},set:function(e){this.latencyController.targetLatency=e}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}},{key:"pathways",get:function(){return this.levelController.pathways}},{key:"pathwayPriority",get:function(){return this.levelController.pathwayPriority},set:function(e){this.levelController.pathwayPriority=e}},{key:"bufferedToEnd",get:function(){var e;return!((e=this.bufferController)==null||!e.bufferedToEnd)}},{key:"interstitialsManager",get:function(){var e;return((e=this.interstitialsController)==null?void 0:e.interstitialsManager)||null}}],[{key:"version",get:function(){return Ve}},{key:"Events",get:function(){return E}},{key:"MetadataSchema",get:function(){return Ct}},{key:"ErrorTypes",get:function(){return W}},{key:"ErrorDetails",get:function(){return I}},{key:"DefaultConfig",get:function(){return n.defaultConfig?n.defaultConfig:Fs},set:function(e){n.defaultConfig=e}}])}();return pn.defaultConfig=void 0,pn},Ae.exports=ee()})(!1)}(ti)),ti.exports}var En=no();const so=io.getDefaultExportFromCjs(En),oo=ao({__proto__:null,default:so},[En]);exports.hls_light_min=oo;