@castlabs/prestoplay 6.30.0 → 6.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/CHANGELOG.md +247 -179
  2. package/cjs/cl.adobe.js +3 -3
  3. package/cjs/cl.airplay.js +3 -3
  4. package/cjs/cl.broadpeak.js +19 -7
  5. package/cjs/cl.cast.js +120 -120
  6. package/cjs/cl.conviva.js +31 -31
  7. package/cjs/cl.core.js +567 -566
  8. package/cjs/cl.crypto.js +10 -10
  9. package/cjs/cl.dash.js +95 -92
  10. package/cjs/cl.externs.js +224 -40
  11. package/cjs/cl.freewheel.js +26 -25
  12. package/cjs/cl.hls.js +79 -78
  13. package/cjs/cl.hlssmpte.js +4 -4
  14. package/cjs/cl.htmlcue.js +19 -19
  15. package/cjs/cl.ima.js +26 -25
  16. package/cjs/cl.mediatailor.js +3 -3
  17. package/cjs/cl.mse.js +352 -350
  18. package/cjs/cl.muxdata.js +13 -13
  19. package/cjs/cl.onboard.js +2 -2
  20. package/cjs/cl.persistent.js +13 -13
  21. package/cjs/cl.playlist.js +6 -6
  22. package/cjs/cl.simid.js +10 -10
  23. package/cjs/cl.smooth.js +71 -71
  24. package/cjs/cl.thumbnails.js +16 -16
  25. package/cjs/cl.tizen.js +72 -72
  26. package/cjs/cl.ttml.js +15 -15
  27. package/cjs/cl.verimatrix.js +5 -5
  28. package/cjs/cl.vimond.js +11 -11
  29. package/cjs/cl.vr.js +12 -12
  30. package/cjs/cl.vtt.js +12 -12
  31. package/cjs/cl.yospace.js +4 -4
  32. package/cjs/cl.youbora.js +35 -35
  33. package/cl.adobe.js +3 -3
  34. package/cl.airplay.js +3 -3
  35. package/cl.broadpeak.js +14 -6
  36. package/cl.cast.js +99 -98
  37. package/cl.conviva.js +26 -26
  38. package/cl.core.js +413 -412
  39. package/cl.crypto.js +8 -8
  40. package/cl.dash.js +87 -84
  41. package/cl.externs.js +225 -37
  42. package/cl.freewheel.js +20 -19
  43. package/cl.hls.js +76 -76
  44. package/cl.hlssmpte.js +5 -5
  45. package/cl.htmlcue.js +26 -26
  46. package/cl.ima.js +20 -19
  47. package/cl.mediatailor.js +2 -2
  48. package/cl.mse.js +299 -300
  49. package/cl.muxdata.js +12 -12
  50. package/cl.onboard.js +4 -4
  51. package/cl.persistent.js +10 -10
  52. package/cl.playlist.js +5 -5
  53. package/cl.simid.js +14 -14
  54. package/cl.smooth.js +62 -60
  55. package/cl.thumbnails.js +17 -17
  56. package/cl.tizen.js +55 -55
  57. package/cl.ttml.js +22 -22
  58. package/cl.verimatrix.js +4 -4
  59. package/cl.vimond.js +8 -8
  60. package/cl.vr.js +15 -15
  61. package/cl.vtt.js +12 -12
  62. package/cl.yospace.js +3 -3
  63. package/cl.youbora.js +31 -31
  64. package/package.json +8 -7
  65. package/typings.d.ts +85 -61
package/cl.freewheel.js CHANGED
@@ -1,19 +1,20 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var ST="clpp-freewheel",TT="clpp.freewheel.AdsManagerFactory",UT="freewheel",VT=function(a){switch(a){case 0:return tv.freewheel.SDK.ADUNIT_PREROLL;case 1:return tv.freewheel.SDK.ADUNIT_MIDROLL;case 2:return tv.freewheel.SDK.ADUNIT_POSTROLL;default:return""}},WT=function(a){const b=[];typeof a.networkId!==_.r&&b.push("networkId");typeof a.serverUrl!==_.Tf&&b.push("serverUrl");typeof a.profileId!==_.Tf&&b.push("profileId");typeof a.videoAssetId!==_.Tf&&typeof a.videoAssetId!==_.r&&b.push("videoAssetId");
2
- if(b.length)throw new _.I(1,9,12001,{missingKeys:b.join(", ")});},XT=function(){return _.w(function*(){var a=new _.Ev;let b=tv.freewheel.SDK.VIDEO_ASSET_AUTO_PLAY_TYPE_NONE;const c=yield a.canPlay(!1);a=yield a.canPlay(!0);c?b=tv.freewheel.SDK.VIDEO_ASSET_AUTO_PLAY_TYPE_ATTENDED:a&&(b=tv.freewheel.SDK.VIDEO_ASSET_AUTO_PLAY_TYPE_UNATTENDED);return b})},YT=function(a){a.h.on(a.a,tv.freewheel.SDK.EVENT_REQUEST_COMPLETE,a.L.bind(a));a.h.on(a.a,tv.freewheel.SDK.EVENT_SLOT_STARTED,a.P.bind(a));a.h.on(a.a,
3
- tv.freewheel.SDK.EVENT_SLOT_ENDED,a.M.bind(a));a.h.on(a.a,tv.freewheel.SDK.EVENT_AD,a.K.bind(a));a.h.on(a.m,_.fg,a.J.bind(a));a.h.on(a.m,_.Qf,a.I.bind(a))},ZT=function(a){const b=a.m.md(UT).Pc();b&&a.m.getSurface().hide(b);a.m.getSurface().showMediaElement()},$T=function(a){const b=a.m.md(UT).Pc();b&&(a.m.getSurface().show(b),a.m.getSurface().hideMediaElement(),a.a.registerVideoDisplayBase(ST),a.m.isMuted()?a.setVolume(0):a.setVolume(a.m.getVolume()||1))},aU=function(a,b,c){var d=null;a.a&&c&&(c.adInstance||
4
- c.slot)&&(c=(d=c.adInstance||null)?d.getSlot():c.slot,d={ad:new X(a.a,c,d)});a.m.trigger(new _.H(b,d))},bU=class extends _.Ov{constructor(){super();this.f=this.a=null}onPlayerCreated(a){if(window.tv&&tv.freewheel&&tv.freewheel.SDK)this.a=_.Bi(_.Fd,{id:ST}),this.f=_.Bi(_.t,{"class":_.cd}),this.a.appendChild(this.f),a.getSurface().addElementToContainer(this.a,!0),a.getSurface().hide(this.a);else a.onError(new _.I(1,9,12E3))}onPlayerWillDestroy(a){this.a&&(a.getSurface().removeElementFromContainer(this.a),
5
- this.f=this.a=null)}id(){return UT}Pc(){return this.a}Qh(){return this.f}};_.x("clpp.freewheel.FreeWheelPlugin",bU);bU.prototype.getAdVideo=bU.prototype.Qh;bU.prototype.getAdContainer=bU.prototype.Pc;bU.Id=UT;bU.AD_CONTAINER_ID=ST;var cU=class{create(){return new bU}};var X=class{constructor(a,b,c){this.h=a;this.f=b;this.a=c}nb(){return"FreeWheel AdManager SDK"}ob(){return tv.freewheel.SDK.version}ub(){return 0}getId(){return this.a?this.a.getAdId():""}getCreativeId(){const a=(this.a||{})._creativeId;return typeof a===_.Tf?a:""}Qb(){return""}getApiFramework(){return this.a?this.a.getActiveCreativeRendition().getCreativeApi():""}getAdSystem(){return""}getAdvertiserName(){return""}getTitle(){return""}getDuration(){return this.a?this.a.getActiveCreativeRendition().getDuration():
6
- 0}getPosition(){return 0}getSkipTimeOffset(){return 0}Ub(){return!1}pb(){return this.a&&this.a.getEventCallbackUrls(tv.freewheel.SDK.EVENT_AD_CLICK,tv.freewheel.SDK.EVENT_TYPE_CLICK)[0]||""}getMediaUrl(){return this.a?this.a.getActiveCreativeRendition().getPrimaryCreativeRenditionAsset().getUrl():""}eb(){return this.a?this.a.getActiveCreativeRendition().getWidth():0}cb(){return this.a?this.a.getActiveCreativeRendition().getHeight():0}Pa(){return 0}Qa(){switch(this.f.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:return 0;
7
- case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:return 2;default:return 1}}getPodIndex(){switch(this.Qa()){case 0:return 0;case 2:return-1}return this.h.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL).indexOf(this.f)+1}Hb(){switch(this.Qa()){case 0:return 0;case 2:return-1;default:return this.f.getTimePosition()}}rb(){return this.a?this.f.getAdInstances().indexOf(this.a)+1:1}fb(){return this.f.getAdCount()}getWrapperAdIds(){return[]}canSeek(){return!1}getWrapperAdSystems(){return[]}getWrapperCreativeIds(){return[]}Sb(){return null}};
8
- X.prototype.getVideoElement=X.prototype.Sb;X.prototype.getWrapperCreativeIds=X.prototype.getWrapperCreativeIds;X.prototype.getWrapperAdSystems=X.prototype.getWrapperAdSystems;X.prototype.canSeek=X.prototype.canSeek;X.prototype.getWrapperAdIds=X.prototype.getWrapperAdIds;X.prototype.getSequenceLength=X.prototype.fb;X.prototype.getPositionInSequence=X.prototype.rb;X.prototype.getPodTimeOffset=X.prototype.Hb;X.prototype.getPodIndex=X.prototype.getPodIndex;X.prototype.getPodType=X.prototype.Qa;
9
- X.prototype.getMediaBitrate=X.prototype.Pa;X.prototype.getMediaHeight=X.prototype.cb;X.prototype.getMediaWidth=X.prototype.eb;X.prototype.getMediaUrl=X.prototype.getMediaUrl;X.prototype.getClickThroughUrl=X.prototype.pb;X.prototype.isBumper=X.prototype.Ub;X.prototype.getSkipTimeOffset=X.prototype.getSkipTimeOffset;X.prototype.getPosition=X.prototype.getPosition;X.prototype.getDuration=X.prototype.getDuration;X.prototype.getTitle=X.prototype.getTitle;X.prototype.getAdvertiserName=X.prototype.getAdvertiserName;
10
- X.prototype.getAdSystem=X.prototype.getAdSystem;X.prototype.getApiFramework=X.prototype.getApiFramework;X.prototype.getSourceId=X.prototype.Qb;X.prototype.getCreativeId=X.prototype.getCreativeId;X.prototype.getId=X.prototype.getId;X.prototype.getTechnology=X.prototype.ub;X.prototype.getAdManagerVersion=X.prototype.ob;X.prototype.getAdManagerName=X.prototype.nb;var dU=class{constructor(a){this.a=a}getCuePoints(){return this.a.getTemporalSlots().map(a=>{switch(a.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:return 0;case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:return-1;default:return a.getTimePosition()}})}Jb(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL).length}Ib(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL).length}};
11
- dU.prototype.hasPostroll=dU.prototype.Ib;dU.prototype.hasPreroll=dU.prototype.Jb;dU.prototype.getCuePoints=dU.prototype.getCuePoints;var eU=class{constructor(a){this.g=new _.T("clpp.freewheel.AdsManager");this.m=a;this.h=new _.Kt;this.F=new tv.freewheel.SDK.AdManager;this.f=this.a=null;this.H=[];this.C=[];this.G=[];this.B=new _.Hl;this.w=null}load(){const a=this;return _.w(function*(){const b=a.m.getConfiguration().freewheel||{};try{WT(b)}catch(d){return a.m.onError(d),a.B.resolve(),a.B}a.F.setNetwork(b.networkId);a.F.setServer(b.serverUrl);a.a=a.F.newContext();a.a.setProfile(b.profileId);typeof b.siteSectionId!==_.Tf&&typeof b.siteSectionId!==
12
- _.r||a.a.setSiteSection(b.siteSectionId);const c=yield XT();a.a.setVideoAsset(b.videoAssetId,a.m.getDuration(),void 0,void 0,c);if(Array.isArray(b.pods))for(const d of b.pods)a.a.addTemporalSlot(d.id,VT(d.type),d.position,d.slotProfile,d.cuepointSequence,d.maxDuration,d.minDuration,d.acceptContentType);b.keyValues&&typeof b.keyValues===_.He&&Object.keys(b.keyValues).forEach(d=>a.a.addKeyValue(d,b.keyValues[d]));a.a.setParameter(tv.freewheel.SDK.PARAMETER_EXTENSION_CONTENT_VIDEO_ENABLED,!1,tv.freewheel.SDK.PARAMETER_LEVEL_GLOBAL);
13
- if(Array.isArray(b.parameters))for(const d of b.parameters)a.a.setParameter(d.name,d.value,d.level);YT(a);a.a.submitRequest();return a.B})}A(){if(this.H.length){$T(this);this.f=this.H.shift();this.f.play();var a=!1}else ZT(this),a=!0;return a}o(){}resume(){this.f&&this.f.resume()}pause(){this.f&&this.f.pause()}skip(){this.f&&this.f.skipCurrentAd()}getVolume(){return this.a?this.a.getAdVolume():1}setVolume(a){this.a&&this.a.setAdVolume(a)}getPosition(){return this.f?this.f.getPlayheadTime():-1}l(){return!0}j(){const a=
14
- this;return _.w(function*(){a.h.release();a.w&&(a.w.stop(),a.w=null);ZT(a);a.a&&(a.a.dispose(),a.a=null)})}L(a){if(a.success)this.H=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL),this.C=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL),this.G=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL),this.m.trigger(new _.H(_.pc,{adsTimeline:new dU(this.a)})),this.w=new _.Cv(this.m.getSurface(),(b,c)=>this.a.resize(b,
15
- c),this.m.md(UT).f);else this.m.onError(new _.I(1,9,10003,{errorType:0},void 0));this.B.resolve()}P(a){aU(this,_.Tb,a);this.w.start()}M(a){this.f=null;a=a.slot;aU(this,_.Ub);this.w.stop();ZT(this);a&&a.getTimePositionClass()===tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL||this.m.play()}K(a){const b=a.subType;this.g.debug("ad event",b);switch(b){case tv.freewheel.SDK.EVENT_AD_IMPRESSION:aU(this,_.lc,a);aU(this,_.bc,a);break;case tv.freewheel.SDK.EVENT_AD_IMPRESSION_END:aU(this,_.mc,a);break;case tv.freewheel.SDK.EVENT_AD_FIRST_QUARTILE:aU(this,
16
- _.Yb,a);break;case tv.freewheel.SDK.EVENT_AD_MIDPOINT:aU(this,_.gc,a);break;case tv.freewheel.SDK.EVENT_AD_THIRD_QUARTILE:aU(this,_.nc,a);break;case tv.freewheel.SDK.EVENT_AD_COMPLETE:aU(this,_.Xb,a);break;case tv.freewheel.SDK.EVENT_AD_CLICK:aU(this,_.Wb,a);break;case tv.freewheel.SDK.EVENT_AD_PAUSE:aU(this,_.hc,a);break;case tv.freewheel.SDK.EVENT_AD_RESUME:aU(this,_.jc,a);break;case tv.freewheel.SDK.EVENT_AD_SKIPPED:aU(this,_.kc,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_START:aU(this,_.Vb,
17
- a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_END:aU(this,_.ic,a);break;case tv.freewheel.SDK.EVENT_ERROR:this.m.onError(new _.I(1,9,10003,{errorType:1},{fwCode:a[tv.freewheel.SDK.INFO_KEY_ERROR_CODE],fwInfo:a[tv.freewheel.SDK.INFO_KEY_ERROR_INFO],fwModule:a[tv.freewheel.SDK.INFO_KEY_ERROR_MODULE]}))}}J(){if(!this.f){var a=this.m.getPosition();if(this.f=this.C.find(b=>.5>Math.abs(a-b.getTimePosition()))||null){const b=this.C.findIndex(c=>c===this.f);this.C.splice(b,1);this.m.pause();$T(this);
18
- this.f.play()}}}I(a){if((a=a.detail)&&this.a)switch(a.currentState){case 3:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PLAYING);break;case 4:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PAUSED);break;case 5:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_COMPLETED);this.G.length?($T(this),this.f=this.G.shift(),this.f.play()):ZT(this);break;case _.zs:case _.ps:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_STOPPED)}}};eU.prototype.getPosition=eU.prototype.getPosition;
19
- eU.prototype.setVolume=eU.prototype.setVolume;eU.prototype.getVolume=eU.prototype.getVolume;eU.prototype.skip=eU.prototype.skip;eU.prototype.pause=eU.prototype.pause;eU.prototype.resume=eU.prototype.resume;_.Fh(new class{constructor(){this.Sa=new _.T(TT)}name(){return TT}a(a,b){return a.namespace()!==_.hd&&b&&b.freewheel?window.tv&&tv.freewheel&&tv.freewheel.SDK?!0:(this.Sa.warn("FreeWheel SDK is not loaded."),!1):!1}create(a){return new eU(a)}});_.Qn(new cU);};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var TT="clpp-freewheel",UT="clpp.freewheel.AdsManagerFactory",VT="freewheel",WT=function(a){switch(a){case 0:return tv.freewheel.SDK.ADUNIT_PREROLL;case 1:return tv.freewheel.SDK.ADUNIT_MIDROLL;case 2:return tv.freewheel.SDK.ADUNIT_POSTROLL;default:return""}},XT=function(a){const b=[];typeof a.networkId!==_.r&&b.push("networkId");typeof a.serverUrl!==_.Tf&&b.push("serverUrl");typeof a.profileId!==_.Tf&&b.push("profileId");typeof a.videoAssetId!==_.Tf&&typeof a.videoAssetId!==_.r&&b.push("videoAssetId");
2
+ if(b.length)throw new _.I(1,9,12001,{missingKeys:b.join(", ")});},YT=function(){return _.w(function*(){var a=new _.Fv;let b=tv.freewheel.SDK.VIDEO_ASSET_AUTO_PLAY_TYPE_NONE;const c=yield a.canPlay(!1);a=yield a.canPlay(!0);c?b=tv.freewheel.SDK.VIDEO_ASSET_AUTO_PLAY_TYPE_ATTENDED:a&&(b=tv.freewheel.SDK.VIDEO_ASSET_AUTO_PLAY_TYPE_UNATTENDED);return b})},ZT=function(a){a.l.on(a.a,tv.freewheel.SDK.EVENT_REQUEST_COMPLETE,a.W.bind(a));a.l.on(a.a,tv.freewheel.SDK.EVENT_SLOT_STARTED,a.$.bind(a));a.l.on(a.a,
3
+ tv.freewheel.SDK.EVENT_SLOT_ENDED,a.X.bind(a));a.l.on(a.a,tv.freewheel.SDK.EVENT_AD,a.U.bind(a));a.l.on(a.m,_.fg,a.S.bind(a));a.l.on(a.m,_.Qf,a.R.bind(a))},$T=function(a){const b=a.m.wd(VT).Sc();b&&a.m.getSurface().hide(b);a.m.getSurface().showMediaElement()},aU=function(a){const b=a.m.wd(VT).Sc();b&&(a.m.getSurface().show(b),a.m.getSurface().hideMediaElement(),a.a.registerVideoDisplayBase(TT),a.m.isMuted()?a.setVolume(0):a.setVolume(a.m.getVolume()||1))},bU=function(a,b,c){var d=null;a.a&&c&&(c.adInstance||
4
+ c.slot)&&(c=(d=c.adInstance||null)?d.getSlot():c.slot,d={ad:new X(a.a,c,d)});a.m.trigger(new _.H(b,d))},cU=class extends _.Pv{constructor(){super();this.f=this.a=null}onPlayerCreated(a){if(window.tv&&tv.freewheel&&tv.freewheel.SDK)this.a=_.Bi(_.Fd,{id:TT}),this.f=_.Bi(_.t,{"class":_.ad}),this.a.appendChild(this.f),a.getSurface().addElementToContainer(this.a,!0),a.getSurface().hide(this.a);else a.onError(new _.I(1,9,12E3))}onPlayerWillDestroy(a){this.a&&(a.getSurface().removeElementFromContainer(this.a),
5
+ this.f=this.a=null)}id(){return VT}Sc(){return this.a}Qh(){return this.f}};_.x("clpp.freewheel.FreeWheelPlugin",cU);cU.prototype.getAdVideo=cU.prototype.Qh;cU.prototype.getAdContainer=cU.prototype.Sc;cU.Id=VT;cU.AD_CONTAINER_ID=TT;var dU=class{create(){return new cU}};var X=class{constructor(a,b,c){this.h=a;this.f=b;this.a=c}bb(){return"FreeWheel AdManager SDK"}cb(){return tv.freewheel.SDK.version}fb(){return 0}getId(){return this.a?this.a.getAdId():""}getCreativeId(){const a=(this.a||{})._creativeId;return typeof a===_.Tf?a:""}xb(){return""}getApiFramework(){return this.a?this.a.getActiveCreativeRendition().getCreativeApi():""}getAdSystem(){return""}getAdvertiserName(){return""}getTitle(){return""}getDuration(){return this.a?this.a.getActiveCreativeRendition().getDuration():
6
+ 0}getPosition(){return 0}getSkipTimeOffset(){return 0}zb(){return!1}Ra(){return this.a&&this.a.getEventCallbackUrls(tv.freewheel.SDK.EVENT_AD_CLICK,tv.freewheel.SDK.EVENT_TYPE_CLICK)[0]||""}getMediaUrl(){return this.a?this.a.getActiveCreativeRendition().getPrimaryCreativeRenditionAsset().getUrl():""}Ua(){return this.a?this.a.getActiveCreativeRendition().getWidth():0}Ta(){return this.a?this.a.getActiveCreativeRendition().getHeight():0}Ba(){return 0}Ca(){switch(this.f.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:return 0;
7
+ case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:return 2;default:return 1}}getPodIndex(){switch(this.Ca()){case 0:return 0;case 2:return-1}return this.h.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL).indexOf(this.f)+1}ob(){switch(this.Ca()){case 0:return 0;case 2:return-1;default:return this.f.getTimePosition()}}eb(){return this.a?this.f.getAdInstances().indexOf(this.a)+1:1}Va(){return this.f.getAdCount()}getWrapperAdIds(){return[]}canSeek(){return!1}getWrapperAdSystems(){return[]}getWrapperCreativeIds(){return[]}yb(){return null}};
8
+ X.prototype.getVideoElement=X.prototype.yb;X.prototype.getWrapperCreativeIds=X.prototype.getWrapperCreativeIds;X.prototype.getWrapperAdSystems=X.prototype.getWrapperAdSystems;X.prototype.canSeek=X.prototype.canSeek;X.prototype.getWrapperAdIds=X.prototype.getWrapperAdIds;X.prototype.getSequenceLength=X.prototype.Va;X.prototype.getPositionInSequence=X.prototype.eb;X.prototype.getPodTimeOffset=X.prototype.ob;X.prototype.getPodIndex=X.prototype.getPodIndex;X.prototype.getPodType=X.prototype.Ca;
9
+ X.prototype.getMediaBitrate=X.prototype.Ba;X.prototype.getMediaHeight=X.prototype.Ta;X.prototype.getMediaWidth=X.prototype.Ua;X.prototype.getMediaUrl=X.prototype.getMediaUrl;X.prototype.getClickThroughUrl=X.prototype.Ra;X.prototype.isBumper=X.prototype.zb;X.prototype.getSkipTimeOffset=X.prototype.getSkipTimeOffset;X.prototype.getPosition=X.prototype.getPosition;X.prototype.getDuration=X.prototype.getDuration;X.prototype.getTitle=X.prototype.getTitle;X.prototype.getAdvertiserName=X.prototype.getAdvertiserName;
10
+ X.prototype.getAdSystem=X.prototype.getAdSystem;X.prototype.getApiFramework=X.prototype.getApiFramework;X.prototype.getSourceId=X.prototype.xb;X.prototype.getCreativeId=X.prototype.getCreativeId;X.prototype.getId=X.prototype.getId;X.prototype.getTechnology=X.prototype.fb;X.prototype.getAdManagerVersion=X.prototype.cb;X.prototype.getAdManagerName=X.prototype.bb;var eU=class{constructor(a){this.a=a}getCuePoints(){return this.a.getTemporalSlots().map(a=>{switch(a.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:return 0;case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:return-1;default:return a.getTimePosition()}})}Nb(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL).length}Mb(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL).length}};
11
+ eU.prototype.hasPostroll=eU.prototype.Mb;eU.prototype.hasPreroll=eU.prototype.Nb;eU.prototype.getCuePoints=eU.prototype.getCuePoints;var fU=class{constructor(a){this.g=new _.T("clpp.freewheel.AdsManager");this.m=a;this.l=new _.Lt;this.L=new tv.freewheel.SDK.AdManager;this.f=this.a=null;this.N=[];this.J=[];this.M=[];this.I=new _.Gl;this.C=null;this.F=!1;this.H=1;this.K=!1;this.G=!0}load(){const a=this;return _.w(function*(){const b=a.m.getConfiguration().freewheel||{};try{XT(b)}catch(d){return a.m.onError(d),a.I.resolve(),a.I}a.L.setNetwork(b.networkId);a.L.setServer(b.serverUrl);a.a=a.L.newContext();a.a.setProfile(b.profileId);
12
+ typeof b.siteSectionId!==_.Tf&&typeof b.siteSectionId!==_.r||a.a.setSiteSection(b.siteSectionId);const c=yield YT();a.a.setVideoAsset(b.videoAssetId,a.m.getDuration(),void 0,void 0,c);if(Array.isArray(b.pods))for(const d of b.pods)a.a.addTemporalSlot(d.id,WT(d.type),d.position,d.slotProfile,d.cuepointSequence,d.maxDuration,d.minDuration,d.acceptContentType);b.keyValues&&typeof b.keyValues===_.He&&Object.keys(b.keyValues).forEach(d=>a.a.addKeyValue(d,b.keyValues[d]));a.a.setParameter(tv.freewheel.SDK.PARAMETER_EXTENSION_CONTENT_VIDEO_ENABLED,
13
+ !1,tv.freewheel.SDK.PARAMETER_LEVEL_GLOBAL);if(Array.isArray(b.parameters))for(const d of b.parameters)a.a.setParameter(d.name,d.value,d.level);ZT(a);a.a.submitRequest();return a.I})}j(){if(this.N.length){aU(this);this.f=this.N.shift();this.f.play();var a=!1}else this.f?(this.f.resume(),a=!1):($T(this),a=!0);return a}B(){}hb(){this.f&&this.f.pause()}skip(){this.f&&this.f.skipCurrentAd()}getAdVolume(){return!this.a||this.F?this.H:this.a.getAdVolume()}h(a){this.H=a;this.F||this.a&&this.a.setAdVolume(a)}setMuted(a){this.F=
14
+ a;this.a&&(a?this.a.setAdVolume(0):this.a.setAdVolume(this.H))}isMuted(){return this.F}o(){return this.K}isPaused(){return this.G}getPosition(){return this.f?this.f.getPlayheadTime():-1}setVolume(a){this.h(a)}getVolume(){return this.getAdVolume()}pause(){this.hb()}resume(){this.j()}A(){return!0}w(){const a=this;return _.w(function*(){a.l.release();a.C&&(a.C.stop(),a.C=null);$T(a);a.a&&(a.a.dispose(),a.a=null)})}W(a){if(a.success)this.N=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL),
15
+ this.J=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL),this.M=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL),this.m.trigger(new _.H(_.pc,{adsTimeline:new eU(this.a)})),this.C=new _.Dv(this.m.getSurface(),(b,c)=>this.a.resize(b,c),this.m.wd(VT).f);else this.m.onError(new _.I(1,9,10003,{errorType:0},void 0));this.I.resolve()}$(a){bU(this,_.Tb,a);this.C.start()}X(a){this.f=null;a=a.slot;bU(this,_.Ub);this.C.stop();$T(this);a&&a.getTimePositionClass()===
16
+ tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL||this.m.play()}U(a){const b=a.subType;this.g.debug("ad event",b);switch(b){case tv.freewheel.SDK.EVENT_AD_IMPRESSION:this.setMuted(this.F);this.h(this.H);this.K=!0;this.G=!1;bU(this,_.lc,a);bU(this,_.bc,a);break;case tv.freewheel.SDK.EVENT_AD_IMPRESSION_END:bU(this,_.mc,a);this.G=this.K=!1;break;case tv.freewheel.SDK.EVENT_AD_FIRST_QUARTILE:bU(this,_.Yb,a);break;case tv.freewheel.SDK.EVENT_AD_MIDPOINT:bU(this,_.dc,a);break;case tv.freewheel.SDK.EVENT_AD_THIRD_QUARTILE:bU(this,
17
+ _.nc,a);break;case tv.freewheel.SDK.EVENT_AD_COMPLETE:bU(this,_.Xb,a);break;case tv.freewheel.SDK.EVENT_AD_CLICK:bU(this,_.Wb,a);break;case tv.freewheel.SDK.EVENT_AD_PAUSE:this.G=!0;bU(this,_.gc,a);break;case tv.freewheel.SDK.EVENT_AD_RESUME:this.G=!1;bU(this,_.jc,a);break;case tv.freewheel.SDK.EVENT_AD_SKIPPED:bU(this,_.kc,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_START:bU(this,_.Vb,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_END:bU(this,_.ic,a);break;case tv.freewheel.SDK.EVENT_ERROR:this.m.onError(new _.I(1,
18
+ 9,10003,{errorType:1},{fwCode:a[tv.freewheel.SDK.INFO_KEY_ERROR_CODE],fwInfo:a[tv.freewheel.SDK.INFO_KEY_ERROR_INFO],fwModule:a[tv.freewheel.SDK.INFO_KEY_ERROR_MODULE]}))}}S(){if(!this.f){var a=this.m.getPosition();if(this.f=this.J.find(b=>.5>Math.abs(a-b.getTimePosition()))||null){const b=this.J.findIndex(c=>c===this.f);this.J.splice(b,1);this.m.pause();aU(this);this.f.play()}}}R(a){if((a=a.detail)&&this.a)switch(a.currentState){case 3:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PLAYING);break;
19
+ case 4:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PAUSED);break;case 5:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_COMPLETED);this.M.length?(aU(this),this.f=this.M.shift(),this.f.play()):$T(this);break;case _.xs:case _.qs:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_STOPPED)}}};fU.prototype.resume=fU.prototype.resume;fU.prototype.pause=fU.prototype.pause;fU.prototype.getVolume=fU.prototype.getVolume;fU.prototype.setVolume=fU.prototype.setVolume;fU.prototype.getPosition=fU.prototype.getPosition;
20
+ fU.prototype.skip=fU.prototype.skip;_.Fh(new class{constructor(){this.Xa=new _.T(UT)}name(){return UT}a(a,b){return a.namespace()!==_.hd&&b&&b.freewheel?window.tv&&tv.freewheel&&tv.freewheel.SDK?!0:(this.Xa.warn("FreeWheel SDK is not loaded."),!1):!1}create(a){return new fU(a)}});_.Pn(new dU);};f.call(g, window);
package/cl.hls.js CHANGED
@@ -3,80 +3,80 @@ import {clpp} from "./cl.core.js";import './cl.mse.js';let g={};const _ = clpp._
3
3
  for(let e=0;e<c.length;e++){var d=c[e];if(!(d in b))continue;const f=a[d];d=b[d];if(f instanceof Date&&d instanceof Date&&f.getTime()!==d.getTime())return!0;if(typeof f===_.He&&typeof d===_.He){if(eJ(f,d))return!0}else{if(f instanceof Array&&d instanceof Array){if(f.length!==d.length)return!0;for(let g=0;g<f.length;g++)if(f[g]!==d[g])return!0}if(f!==d)return!0}}return!1},fJ=function(a){if(null!==a&&void 0!==a)return Number(a)},gJ=function(a){return 0>a?[]:Array.from({length:a},(b,c)=>c)},hJ=function(a){return new Uint8Array([a>>
4
4
  24&255,a>>16&255,a>>8&255,a&255])},iJ=function(a,b=0){return b+10<=a.length&&73===a[b]&&68===a[b+1]&&51===a[b+2]&&255>a[b+3]&&255>a[b+4]&&128>a[b+6]&&128>a[b+7]&&128>a[b+8]&&128>a[b+9]?!0:!1},jJ=function(a,b){return a.filter(c=>c.name===b)},kJ=function(a){const b=/^[a-zA-Z0-9_-]+$/,c=new Set;a.forEach(d=>{const e=_.L(d,"VALUE"),f=_.L(d,_.Sa),g=_.L(d,"IMPORT"),h=_.L(d,"QUERYPARAM");if(1!==[f,g,h].filter(Boolean).length||f&&null==e)throw new _.I(_.D,4,4044,{message:"Invalid tag.",text:d.toString()});
5
5
  d=f||g||h;if(c.has(d))throw new _.I(_.D,4,4044,`EXT-X-DEFINE redefined variable "${d}".`);if(!b.test(d))throw new _.I(_.D,4,4044,`EXT-X-DEFINE invalid variable name "${d}".`);c.add(d)})},lJ=function(a,b){const c=Array.isArray(b)?b:[b];return a.filter(d=>{d=aJ(d,_.tb);return c.includes(d)})},mJ=function(a,b){return a.some(c=>c.name===b)},nJ=function(a,b,c){c=void 0===c?{}:c;a=a.find(d=>d.name===b)||null;if(!a&&c.required)throw new _.I(_.D,4,4024,{missingTag:b});return a},oJ=function(a){var b=nJ(a,
6
- "EXT-X-TILES");if(!b)return{sd:1,Nd:1,durationPerTile:null};a=_.L(b,"LAYOUT")||"1x1";b=_.L(b,JI);a=_.zB(a);return{sd:a.sd,Nd:a.Nd,durationPerTile:b?Number(b):null}},pJ=function(a){const b=new Set;a.variants.forEach(c=>{c.audio&&b.add(c.audio);c.video&&b.add(c.video)});a.textStreams.forEach(c=>b.add(c));a.thumbStreams.forEach(c=>b.add(c));return Array.from(b)},qJ=function(a,b){Array.isArray(a)||(a=[a]);a.forEach(c=>{for(const d of pJ(c))b(d,c)})},rJ=function(a){return a.some(b=>mJ(b.aa,"EXT-X-ENDLIST"))},
7
- sJ=function(a){return a.type===_.q||a.type===_.t},tJ=function(a){if(nJ(a,"EXT-X-ENDLIST"))return _.Fb;a=nJ(a,"EXT-X-PLAYLIST-TYPE");if(!a)return"LIVE";if(a.value===_.Fb)return _.Fb;if("EVENT"===a.value)return"EVENT";throw new _.I(_.D,4,4044,`Invalid EXT-X-PLAYLIST-TYPE value: ${a.value}`);},uJ=function(a){a={AUDIO:_.q,VIDEO:_.t,SUBTITLES:_.K,"CLOSED-CAPTIONS":_.K}[a.toUpperCase()];if(!a)throw new _.I(_.D,4,4044,"EXT-X-MEDIA tag has an invalid TYPE attribute.");return a},vJ=function(a,b,c){c=void 0===
8
- c?!1:c;var d=0;let e=null;if(a){d=a.split("@");a=Number(d[0]);if(0>=a)throw new _.I(_.D,4,4044,"Byte range length must be positive.");if(d[1]){if(d=Number(d[1]),0>d)throw new _.I(_.D,4,4044,"Byte range start byte must not be negative.");}else{if(c)throw new _.I(_.D,4,4044,"Invalid byte range, offset is required but missing.");if(null==b)throw new _.I(_.D,4,4044,"Invalid byte range, cannot calculate offset based on previous byte ranges.");d=b+1}e=d+a-1}return{ma:d,ja:e}},wJ=function(a,b){a=nJ(a,"EXT-X-BYTERANGE");
9
- return vJ(a?a.value:null,b)},xJ=function(a){a=nJ(a,"EXTINF",{required:!0}).value.split(",");const b=Number(a[0]);if(isNaN(b))throw new _.I(_.D,4,4044,"#EXTINF must be a number.");return{duration:b,title:a[1]||null}},yJ=function(a,b){b=void 0===b?{}:b;const c={Wf:!1,Ah:!1,Bh:null,di:null,Jg:null};a=nJ(a,"EXT-X-SERVER-CONTROL",{required:b.Sg});if(!a)return c;const d=e=>null==e?null:Number(e);c.Wf="YES"===_.L(a,"CAN-BLOCK-RELOAD");c.Ah="YES"===_.L(a,"CAN-SKIP-DATERANGES");c.Bh=d(_.L(a,"CAN-SKIP-UNTIL"));
10
- c.di=d(_.L(a,"HOLD-BACK"));c.Jg=d(_.L(a,"PART-HOLD-BACK",void 0,{required:b.Sg}));return c},zJ=function(a,b,c){c=void 0===c?!1:c;a=_.L(a,"BYTERANGE");return vJ(a,b,c)},AJ=function(a){const b=jJ(a,OI),c=jJ(a,RI);a=jJ(a,"EXT-X-IMAGE-STREAM-INF");return{Ec:{Qf:lJ(b,[_.lA,_.Db]),closedCaptions:lJ(b,HI),Yi:lJ(b,WI)},Od:c,Qe:a}},CJ=function(a,b){const c=wJ(a.aa,null);return new BJ(0,0,0,()=>[a.a],c.ma,c.ja,0,b)},DJ=function(a){let b=Infinity,c=Infinity;pJ(a).filter(sJ).forEach(d=>{{d=d.S;var e=d[0].startTime;
11
- const f=d[d.length-1].endTime;d=e;e=f-e}b=Math.min(b,d);c=Math.min(c,e)});return{Wc:b,duration:c}},EJ=function(a){return a.map(b=>{({duration:b}=DJ(b));return b}).reduce((b,c)=>b+c,0)},FJ=function(a){return(a.video?a.video.Da:"")+" - "+(a.audio?a.audio.Da:"")},GJ=function(a,b,c,d,e){if(b===_.Fb)return{delay:0,Md:0};b=nJ(a,"EXT-X-PART-INF");if(c&&b){e=Number(aJ(b,"PART-TARGET"));if(null!=d)return{delay:d,Md:e};({Jg:d}=yJ(a,{Sg:!0}));return{delay:d,Md:e}}a=nJ(a,"EXT-X-TARGETDURATION",{required:!0});
12
- a=Number(a.value);e=e||a;return null!=d?{delay:d,Md:e}:{delay:3*a,Md:e}},IJ=function(a){const b=new Map;a.forEach(c=>{var d=`${HJ(c).type}:${HJ(c).groupId}`;b.has(d)?(d=b.get(d),d.includes(c)||d.push(c)):b.set(d,[c])});return b},JJ=function(a){const b=new Map;for(const c of a){a=_.L(c,_.Ka);a=_.Hn(a||_.kg);const d=aJ(c,_.Ea),e=aJ(c,"INSTREAM-ID");b.has(d)||b.set(d,new Map);b.get(d).set(e,a)}return b},KJ=function(a){return a.filter(b=>"mp4a.40.34"!==b)},LJ=function(a,b,c,d,e){var f=e&&e.Kd,g=e&&e.schemeIdUri,
13
- h=_.L(a,"ID");f=_.L(a,"START-DATE")||f;if(null===h||!f)return _.fv.warn("Invalid EXT-X-DATERANGE missing mandatory ID or required START-DATE attribute, ignoring the EXT-X-DATERANGE tag.",a),null;b=d?c-b:-b;d=new Date(f);c=d.getTime()/1E3+b;h={id:h,startTime:c,startDate:d,Kd:f};f=fJ(_.L(a,JI));void 0!==f&&0<=f&&(h.duration=f);f=fJ(_.L(a,"PLANNED-DURATION"));void 0!==f&&0<=f&&(h.plannedDuration=f);g=_.L(a,"CLASS")||g||null;null!==g&&(h.schemeIdUri=g);f=(f=_.L(a,"END-DATE"))?new Date(f):null;null!==
14
- f&&f.getTime()>=d.getTime()&&(h.endDate=f);f=a.attributes;if(null==f)var k=null;else{d={};for(k of f)k.name.trim().startsWith("X-")&&(d[k.name]=k.value);k=_.fh(d)?d:null}k=k||{};(d=_.L(a,"CUE"))&&(k.CUE=d.split(","));if(_.gk(g)){f=a.attributes;if(null==f)var l=null;else{d={};for(l of f)switch(l.name){case _.Mb:d[_.Mb]=l.value;break;case _.Lb:d[_.Lb]=l.value;break;case _.Rb:d[_.Rb]=fJ(l.value);break;case _.Pb:d[_.Pb]=fJ(l.value);break;case "X-SNAP":d["X-SNAP"]=l.value.split(",");break;case _.Qb:d[_.Qb]=
15
- l.value.split(",")}l=_.fh(d)?d:null}l&&(k=Object.assign(k,l))}_.fh(k)&&(h.customAttributes=k);if(eJ(e,h))return _.fv.warn("EXT-X-DATERANGE augmented and previous values differ.Ignoring the EXT-X-DATERANGE tag.",a),null;h=_.ch(e,h);if(_.gk(g)&&!_.hk(h.customAttributes))return _.fv.warn("Invalid EXT-X-DATERANGE Interstitial attributes X-ASSET-URI, X-ASSET-LIST"),null;let m;h.endDate?m=h.endDate.getTime()/1E3+b:h.duration?m=c+h.duration:h.plannedDuration?m=c+h.plannedDuration:m=c;h.endTime=m;h.type=
16
- _.de;return h},MJ=function(a,b){if(!a)return null;const c=a.Da;return b.find(d=>HJ(d).Da===c)||null},NJ=function(a){return(a=_.L(a,"CHANNELS"))?parseInt(a.split("/")[0],10):null},OJ=function(a){return a.some(b=>b.startsWith("#EXT-X-TARGETDURATION"))?1:0},PJ=function(a,b){const c=new Map,d=new URL(b);a.forEach(e=>{var f=_.L(e,_.Sa),g=_.L(e,"QUERYPARAM");if(f)g=aJ(e,"VALUE"),c.set(f,g);else if(g){f=d.searchParams.get(g);if(null==f)throw new _.I(_.D,4,4044,`Query param '${g}' missing in playlist URI.`);
17
- if(!f)throw new _.I(_.D,4,4044,`Query param '${g}' has no associated value`+" in playlist URI.");c.set(g,decodeURIComponent(f))}});return c},QJ=function(a,b){return a.replace(/\{\$([a-zA-Z0-9_-]+)\}/g,(c,d)=>{c=b.get(d);if(null==c)throw new _.I(_.D,4,4044,`Undefined variable '${d}'`);return c})},RJ=function(a,b){a.forEach(c=>{c.attributes.forEach(d=>{d.value=QJ(d.value,b)})})},UJ=function(a,b,c){const d=[];for(let e=0;e<b.length;e++){const f=SJ(a,b[e]);d.push(f);if(f.name===RI){const g=b[e+1];if(!g)throw new _.I(_.D,
18
- 4,4044,"EXT-X-STREAM-INF is not followed by a URI.");f.attributes.push(new _.lr(_.vb,g));e++}}b=jJ(d,"EXT-X-DEFINE");kJ(b);b=PJ(b,c);a.a=b;RJ(d,a.a);return new TJ(c,0,d)},YJ=function(a,b,c){const {Li:d,ci:e,ij:f}=VJ(b),g=WJ(a,f,c);b=e.map(k=>SJ(a,k,g));const h=XJ(a,c,d,g);return new TJ(c,1,b,h)},ZJ=function(a,b,c){b=b.trim().split(/\n+/m).map(d=>d.trim()).filter(d=>d.length&&!/^#(?!EXT)/m.test(d));if(!/^#EXTM3U($|[ \t\n])/m.test(b[0]))throw new _.I(_.D,4,4015);b=b.slice(1);return 0===OJ(b)?UJ(a,b,
19
- c):YJ(a,b,c)},VJ=function(a){const b=[],c=[],d=[];for(const e of a)$J.test(e)?d.push(e):aK.test(e)?c.push(e):b.push(e);return{Li:b,ci:c,ij:d}},WJ=function(a,b,c){b=b.map(e=>SJ(a,e));kJ(b);const d=PJ(b,c);b.map(e=>_.L(e,"IMPORT")).filter(Boolean).forEach(e=>{const f=a.a.get(e);if(null==f)throw new _.I(_.D,4,4044,`Cannot import variable '${e}' as it is not defined `+"in the master playlist");d.set(e,f)});return d},SJ=function(a,b,c){a=_.nr(a.h++,b);c&&RJ([a],c);return a},XJ=function(a,b,c,d){const e=
20
- [];let f=[],g=[];c.forEach(h=>{/^(#EXT)/.test(h)?(h=SJ(a,h,d),"EXT-X-PART"===h.name||"EXT-X-PRELOAD-HINT"===h.name&&"PART"===_.L(h,_.tb)?g.push(h):f.push(h)):(mJ(f,"EXT-X-GAP")||(h=QJ(h,d),h=_.Qm(h,b),e.push(new bK(h,f,g))),f=[],g=[])});0<g.length&&e.push(new bK(null,f,g));return e},cK=function(a,b,c){const d=[],e=[];e.push(new _.lr(_.ma,"0"));e.push(new _.lr(_.vb,b));c.length&&e.push(new _.lr(_.pa,c));d.push(new _.mr(a.h++,RI,e));return new TJ(b,0,d)},dK=function(a){function b(h,k,l){let m="";for(;k<
6
+ "EXT-X-TILES");if(!b)return{Bd:1,Vd:1,durationPerTile:null};a=_.L(b,"LAYOUT")||"1x1";b=_.L(b,JI);a=_.BB(a);return{Bd:a.Bd,Vd:a.Vd,durationPerTile:b?Number(b):null}},pJ=function(a){const b=new Set;a.variants.forEach(c=>{c.audio&&b.add(c.audio);c.video&&b.add(c.video)});a.textStreams.forEach(c=>b.add(c));a.thumbStreams.forEach(c=>b.add(c));return Array.from(b)},qJ=function(a,b){Array.isArray(a)||(a=[a]);a.forEach(c=>{for(const d of pJ(c))b(d,c)})},rJ=function(a){return a.some(b=>mJ(b.ca,"EXT-X-ENDLIST"))},
7
+ sJ=function(a){return a.type===_.q||a.type===_.t},tJ=function(a){if(nJ(a,"EXT-X-ENDLIST"))return _.Eb;a=nJ(a,"EXT-X-PLAYLIST-TYPE");if(!a)return"LIVE";if(a.value===_.Eb)return _.Eb;if("EVENT"===a.value)return"EVENT";throw new _.I(_.D,4,4044,`Invalid EXT-X-PLAYLIST-TYPE value: ${a.value}`);},uJ=function(a){a={AUDIO:_.q,VIDEO:_.t,SUBTITLES:_.K,"CLOSED-CAPTIONS":_.K}[a.toUpperCase()];if(!a)throw new _.I(_.D,4,4044,"EXT-X-MEDIA tag has an invalid TYPE attribute.");return a},vJ=function(a,b,c){c=void 0===
8
+ c?!1:c;var d=0;let e=null;if(a){d=a.split("@");a=Number(d[0]);if(0>=a)throw new _.I(_.D,4,4044,"Byte range length must be positive.");if(d[1]){if(d=Number(d[1]),0>d)throw new _.I(_.D,4,4044,"Byte range start byte must not be negative.");}else{if(c)throw new _.I(_.D,4,4044,"Invalid byte range, offset is required but missing.");if(null==b)throw new _.I(_.D,4,4044,"Invalid byte range, cannot calculate offset based on previous byte ranges.");d=b+1}e=d+a-1}return{na:d,ja:e}},wJ=function(a,b){a=nJ(a,"EXT-X-BYTERANGE");
9
+ return vJ(a?a.value:null,b)},xJ=function(a){a=nJ(a,"EXTINF",{required:!0}).value.split(",");const b=Number(a[0]);if(isNaN(b))throw new _.I(_.D,4,4044,"#EXTINF must be a number.");return{duration:b,title:a[1]||null}},yJ=function(a,b){b=void 0===b?{}:b;const c={Yf:!1,Ah:!1,Bh:null,di:null,Jg:null};a=nJ(a,"EXT-X-SERVER-CONTROL",{required:b.Sg});if(!a)return c;const d=e=>null==e?null:Number(e);c.Yf="YES"===_.L(a,"CAN-BLOCK-RELOAD");c.Ah="YES"===_.L(a,"CAN-SKIP-DATERANGES");c.Bh=d(_.L(a,"CAN-SKIP-UNTIL"));
10
+ c.di=d(_.L(a,"HOLD-BACK"));c.Jg=d(_.L(a,"PART-HOLD-BACK",void 0,{required:b.Sg}));return c},zJ=function(a,b,c){c=void 0===c?!1:c;a=_.L(a,"BYTERANGE");return vJ(a,b,c)},AJ=function(a){const b=jJ(a,OI),c=jJ(a,RI);a=jJ(a,"EXT-X-IMAGE-STREAM-INF");return{Gc:{Sf:lJ(b,[_.mA,_.Db]),closedCaptions:lJ(b,HI),Yi:lJ(b,WI)},Wd:c,Te:a}},CJ=function(a,b){const c=wJ(a.ca,null);return new BJ(0,0,0,()=>[a.a],c.na,c.ja,0,b)},DJ=function(a){let b=Infinity,c=Infinity;pJ(a).filter(sJ).forEach(d=>{{d=d.T;var e=d[0].startTime;
11
+ const f=d[d.length-1].endTime;d=e;e=f-e}b=Math.min(b,d);c=Math.min(c,e)});return{ed:b,duration:c}},EJ=function(a){return a.map(b=>{({duration:b}=DJ(b));return b}).reduce((b,c)=>b+c,0)},FJ=function(a){return(a.video?a.video.$a:"")+" - "+(a.audio?a.audio.$a:"")},GJ=function(a,b,c,d,e){if(b===_.Eb)return{delay:0,Ud:0};b=nJ(a,"EXT-X-PART-INF");if(c&&b){e=Number(aJ(b,"PART-TARGET"));if(null!=d)return{delay:d,Ud:e};({Jg:d}=yJ(a,{Sg:!0}));return{delay:d,Ud:e}}a=nJ(a,"EXT-X-TARGETDURATION",{required:!0});
12
+ a=Number(a.value);e=e||a;return null!=d?{delay:d,Ud:e}:{delay:3*a,Ud:e}},HJ=function(a){const b=new Map;a.forEach(c=>{var d=`${c.zc()}:${c.streams[0].groupId}`;b.has(d)?(d=b.get(d),d.includes(c)||d.push(c)):b.set(d,[c])});return b},IJ=function(a){const b=new Map;for(const c of a){a=_.L(c,_.Ka);a=_.Gn(a||_.kg);const d=aJ(c,_.Ea),e=aJ(c,"INSTREAM-ID");b.has(d)||b.set(d,new Map);b.get(d).set(e,a)}return b},JJ=function(a){return a.filter(b=>"mp4a.40.34"!==b)},KJ=function(a,b,c,d,e){var f=e&&e.Sd,g=e&&
13
+ e.schemeIdUri,h=_.L(a,"ID");f=_.L(a,"START-DATE")||f;if(null===h||!f)return _.gv.warn("Invalid EXT-X-DATERANGE missing mandatory ID or required START-DATE attribute, ignoring the EXT-X-DATERANGE tag.",a),null;b=d?c-b:-b;d=new Date(f);c=d.getTime()/1E3+b;h={id:h,startTime:c,startDate:d,Sd:f};f=fJ(_.L(a,JI));void 0!==f&&0<=f&&(h.duration=f);f=fJ(_.L(a,"PLANNED-DURATION"));void 0!==f&&0<=f&&(h.plannedDuration=f);g=_.L(a,"CLASS")||g||null;null!==g&&(h.schemeIdUri=g);f=(f=_.L(a,"END-DATE"))?new Date(f):
14
+ null;null!==f&&f.getTime()>=d.getTime()&&(h.endDate=f);f=a.attributes;if(null==f)var k=null;else{d={};for(k of f)k.name.trim().startsWith("X-")&&(d[k.name]=k.value);k=_.fh(d)?d:null}k=k||{};(d=_.L(a,"CUE"))&&(k.CUE=d.split(","));if(_.fk(g)){f=a.attributes;if(null==f)var l=null;else{d={};for(l of f)switch(l.name){case _.Mb:d[_.Mb]=l.value;break;case _.Lb:d[_.Lb]=l.value;break;case _.Rb:d[_.Rb]=fJ(l.value);break;case _.Pb:d[_.Pb]=fJ(l.value);break;case "X-SNAP":d["X-SNAP"]=l.value.split(",");break;
15
+ case _.Qb:d[_.Qb]=l.value.split(",")}l=_.fh(d)?d:null}l&&(k=Object.assign(k,l))}_.fh(k)&&(h.customAttributes=k);if(eJ(e,h))return _.gv.warn("EXT-X-DATERANGE augmented and previous values differ.Ignoring the EXT-X-DATERANGE tag.",a),null;h=_.ch(e,h);if(_.fk(g)&&!_.gk(h.customAttributes))return _.gv.warn("Invalid EXT-X-DATERANGE Interstitial attributes X-ASSET-URI, X-ASSET-LIST"),null;let m;h.endDate?m=h.endDate.getTime()/1E3+b:h.duration?m=c+h.duration:h.plannedDuration?m=c+h.plannedDuration:m=c;h.endTime=
16
+ m;h.type=_.de;return h},LJ=function(a,b){if(!a)return null;const c=a.$a;return b.find(d=>d.streams[0].$a===c)||null},MJ=function(a){return(a=_.L(a,"CHANNELS"))?parseInt(a.split("/")[0],10):null},NJ=function(a){return a.some(b=>b.startsWith("#EXT-X-TARGETDURATION"))?1:0},OJ=function(a,b){const c=new Map,d=new URL(b);a.forEach(e=>{var f=_.L(e,_.Sa),g=_.L(e,"QUERYPARAM");if(f)g=aJ(e,"VALUE"),c.set(f,g);else if(g){f=d.searchParams.get(g);if(null==f)throw new _.I(_.D,4,4044,`Query param '${g}' missing in playlist URI.`);
17
+ if(!f)throw new _.I(_.D,4,4044,`Query param '${g}' has no associated value`+" in playlist URI.");c.set(g,decodeURIComponent(f))}});return c},PJ=function(a,b){return a.replace(/\{\$([a-zA-Z0-9_-]+)\}/g,(c,d)=>{c=b.get(d);if(null==c)throw new _.I(_.D,4,4044,`Undefined variable '${d}'`);return c})},QJ=function(a,b){a.forEach(c=>{c.attributes.forEach(d=>{d.value=PJ(d.value,b)})})},TJ=function(a,b,c){const d=[];for(let e=0;e<b.length;e++){const f=RJ(a,b[e]);d.push(f);if(f.name===RI){const g=b[e+1];if(!g)throw new _.I(_.D,
18
+ 4,4044,"EXT-X-STREAM-INF is not followed by a URI.");f.attributes.push(new _.lr(_.vb,g));e++}}b=jJ(d,"EXT-X-DEFINE");kJ(b);b=OJ(b,c);a.a=b;QJ(d,a.a);return new SJ(c,0,d)},XJ=function(a,b,c){const {Li:d,ci:e,jj:f}=UJ(b),g=VJ(a,f,c);b=e.map(k=>RJ(a,k,g));const h=WJ(a,c,d,g);return new SJ(c,1,b,h)},YJ=function(a,b,c){b=b.trim().split(/\n+/m).map(d=>d.trim()).filter(d=>d.length&&!/^#(?!EXT)/m.test(d));if(!/^#EXTM3U($|[ \t\n])/m.test(b[0]))throw new _.I(_.D,4,4015);b=b.slice(1);return 0===NJ(b)?TJ(a,b,
19
+ c):XJ(a,b,c)},UJ=function(a){const b=[],c=[],d=[];for(const e of a)ZJ.test(e)?d.push(e):$J.test(e)?c.push(e):b.push(e);return{Li:b,ci:c,jj:d}},VJ=function(a,b,c){b=b.map(e=>RJ(a,e));kJ(b);const d=OJ(b,c);b.map(e=>_.L(e,"IMPORT")).filter(Boolean).forEach(e=>{const f=a.a.get(e);if(null==f)throw new _.I(_.D,4,4044,`Cannot import variable '${e}' as it is not defined `+"in the master playlist");d.set(e,f)});return d},RJ=function(a,b,c){a=_.nr(a.h++,b);c&&QJ([a],c);return a},WJ=function(a,b,c,d){const e=
20
+ [];let f=[],g=[];c.forEach(h=>{/^(#EXT)/.test(h)?(h=RJ(a,h,d),"EXT-X-PART"===h.name||"EXT-X-PRELOAD-HINT"===h.name&&"PART"===_.L(h,_.tb)?g.push(h):f.push(h)):(mJ(f,"EXT-X-GAP")||(h=PJ(h,d),h=_.Pm(h,b),e.push(new aK(h,f,g))),f=[],g=[])});0<g.length&&e.push(new aK(null,f,g));return e},bK=function(a,b,c){const d=[],e=[];e.push(new _.lr(_.ma,"0"));e.push(new _.lr(_.vb,b));c.length&&e.push(new _.lr(_.pa,c));d.push(new _.mr(a.h++,RI,e));return new SJ(b,0,d)},cK=function(a){function b(h,k,l){let m="";for(;k<
21
21
  l;k++)m+="%"+("00"+h[k].toString(16)).slice(-2);return m}function c(h){return h[0]<<21|h[1]<<14|h[2]<<7|h[3]}function d(){throw new _.I(_.D,4,4030);}iJ(a)||d();let e=10;a[5]&64&&(e=e+4+c(a.subarray(10,14)));do{var f=c(a.subarray(e+4,e+8));1>f&&d();var g=String.fromCharCode(a[e],a[e+1],a[e+2],a[e+3]);if("PRIV"===g){g=a.subarray(e+10,e+f+10);for(let h=0;h<g.byteLength;h++)if(0===g[h]){if("com.apple.streaming.transportStreamTimestamp"===unescape(b(g,0,h)))return a=g.subarray(h+1),f=(a[3]&1)<<30|a[4]<<
22
- 22|a[5]<<14|a[6]<<6|a[7]>>>2,f*=4,f+=a[7]&3,Math.round(f/9E4);break}}iJ(a,e)||d();e+=10;e+=f}while(e<a.byteLength);return d()},eK=function(a,b){let c=null,d=0;try{(new _.ip).N(_.De,_.bp).N(_.hg,_.bp).N(_.ye,_.bp).ea("mdhd",g=>{g.reader.skip(0===g.version?8:16);d=_.N(g.reader);g.parser.stop()}).parse(b,!0)}catch(g){c=g}if(c||!d)throw _.Mv.error("Unable to find timescale in init segment!"),new _.I(_.D,4,4030,II,c);let e=0,f=!1;try{(new _.ip).N("moof",_.bp).N("traf",_.bp).ea("tfdt",g=>{var h=d;if(0===
23
- g.version)h=_.N(g.reader)/h;else{{const k=_.N(g.reader),l=_.N(g.reader);if(!(2097151>=k||h>=Math.pow(2,12)))throw Error("Cannot accurately parse MP4 timestamp, base time is too high and timescale is \x3c\x3d 2^12");h=k/h*Math.pow(2,32)+l/h}}e=h;f=!0;g.parser.stop()}).parse(a,!0)}catch(g){c=g}if(c||!f)throw new _.I(_.D,4,4030,II,c);return e},fK=function(a){for(;a.getPosition()<a.Oa()-1;){const b=a.getPosition();if(71===_.Uo(a))return bJ(a),b}return-1},gK=function(a){function b(){d.seek(e+188);f=_.Uo(d);
24
- 71!==f&&(d.seek(e+192),f=_.Uo(d));71!==f&&(d.seek(e+204),f=_.Uo(d));71!==f&&c();bJ(d)}function c(){throw new _.I(_.D,4,4030);}const d=new _.aq(new DataView(a),!1);let e=0,f=0;e=fK(d);0>e&&(_.Mv.error("Unable to find sync byte in TS after scanning."),c());for(;;){e=d.getPosition();f=_.Uo(d);71!==f&&c();a=_.Vo(d);if(8191===(a&8191)){b();continue}if(!(a&16384)){b();continue}a=(_.Uo(d)&48)>>4;0!==a&&2!==a||c();3===a&&(a=_.Uo(d),d.skip(a));if(1!==_.N(d)>>8){b();continue}d.skip(3);a=_.Uo(d)>>6;0!==a&&1!==
25
- a||c();0===_.Uo(d)&&c();a=_.Uo(d);const g=_.Vo(d),h=_.Vo(d);return(1073741824*((a&14)>>1)+((g&65534)<<14|(h&65534)>>1))/9E4}},jK=function(a){const b=hK(a),c=iK(a);a.forEach(d=>{const e=d.S,f=e.findIndex(h=>h.sa===b);let g=e.findIndex(h=>h.sa===c+1);-1===g&&(g=e.length);d.S=e.slice(f,g)})},iK=function(a){a=a.map(b=>b.S[b.S.length-1].sa);return Math.min(...a)},hK=function(a){a=a.map(b=>b.S[0].sa);return Math.max(...a)},mK=function(a){var b=aJ(a,UI);if(!kK.includes(b))return lK.error("PlayReady in HLS is only supported with [",
26
- kK.join(", "),"], not",b),null;a=aJ(a,_.vb);b=_.gm(a);a=null;b=_.G(b.data);try{a=_.$A(_.hq(b))}catch(c){a=b}return _.nB(_.ud,[{initDataType:_.Wc,initData:a}],"")},oK=function(a){if(0===a.length)return nK();if(a.some(c=>"whole-segment"===c.type)||a.every(c=>c.type===_.Ge))return a[0];a=a.filter(c=>c.type===$I);const b=_.ci(a.flatMap(c=>c.drmInfos));return{keyId:a[a.length-1].keyId,type:$I,drmInfos:b}},rK=function(a,b){return pK(a).map(c=>qK(c.aa,b)).filter(Boolean)},pK=function(a){return a.filter(b=>
27
- mJ(b.aa,MI))},qK=function(a,b){a=jJ(a,MI).filter(d=>"AES-128"!==aJ(d,UI));if(0===a.length)return null;var c=aJ(a[0],UI);if(1===a.length&&"NONE"===c)return nK();c=a.map(d=>aJ(d,UI));if(!c.every(d=>"SAMPLE-AES"===d)&&!c.every(d=>d===VI))throw sK.warn(`EXT-X-KEY methods ${c.join(", ")} are incompatible.`),new _.I(_.D,4,4044,"Multiple EXT-X-KEY tags with incompatible METHOD values.");a=a.map(d=>{const e=_.L(d,"KEYFORMAT","identity");{const f=tK[e]||null;d=f?f(d,b):null}d||sK.warn("Unsupported HLS KEYFORMAT",
28
- e);return d}).filter(Boolean);if(0===a.length)throw new _.I(_.D,4,4026);return{keyId:a.map(d=>d.keyIds).reduce((d,e)=>d.concat(e),[]).reverse()[0]||null,type:$I,drmInfos:a}},nK=function(){return{type:_.Ge,drmInfos:[],keyId:null}},uK=function(a,b,c){a=jJ(a,MI)[0];if(!a||"AES-128"!==aJ(a,UI))return null;var d=_.L(a,"IV","");d?c={iv:_.cm((d||"0x").slice(2)),generatedIv:!1}:(d=_.L(a,"KEYFORMAT"),c=null==d||"identity"===d?{iv:_.fm(new Uint8Array(12),hJ(c)),generatedIv:!0}:{iv:null,generatedIv:!1});const {iv:e,
29
- generatedIv:f}=c;return{method:"AES-128",url:_.Qm(aJ(a,_.vb),b),iv:e,generatedIv:f}},vK=function(a,b,c){return _.w(function*(){const d=b.f(),e=_.VB(b.Ea(),b.ma,b.ma+2048-1,a.a.attemptParameters);e.type=2;const f=_.VB(b.Ea(),b.ma,b.ja,a.a.attemptParameters);f.type=2;d&&(f.keyInfo=d);try{return yield a.f(c?f:e)}catch(g){if(7001===g.code||c)throw g;a.g.warn("Unable to fetch a partial HLS segment! Falling back to a full segment request, which is expensive! Your server should support Range requests and CORS pre-flights.",
30
- e.uris[0]);try{return yield a.f(f)}catch(h){throw a.g.error("Failed to fetch media segment to parse its start timestamp.",f.uris[0],h),new _.I(_.D,4,4030,"Failed to fetch the media segment.");}}})},wK=function(a,b,c,d,e,f){return _.w(function*(){a.g.debug("Fetching segment to find start time");if("audio/mpeg"===d||d===_.Gc||d===_.Fc)return 0;if(d===_.Ec){var g=yield vK(a,c,f);g=_.G(g.data);if(!iJ(g))throw new _.I(_.D,4,4030,"AAC segment does not contain an ID3 tag.");return dK(g)}if(d===_.zg||d===
31
- _.Hc)return g=[vK(a,c,f)],b&&g.push(vK(a,b,!0)),g=yield Promise.all(g),eK(g[0].data,(g[1]||g[0]).data);if(d===_.yg)return g=yield vK(a,c,f),gK(g.data);if(!_.gt(`${d.split("/")[0]||""}/mp4;codecs="${e}"`))return 0;throw new _.I(_.D,4,4030);})},xK=function(a,b){a=a.map(c=>c.streams[b]);return a.some(c=>null==c)?null:a},yK=function(a,b){a=a.streams.find(c=>{c=c.S;return c[0].position<=b&&b<=c[c.length-1].position});return null==a?null:a.S.find(c=>c.position===b)||null},HJ=function(a){return a.streams[0]},
32
- zK=function(a,b){a.streams.forEach(c=>{c.Be=b})},AK=function(a,b){a.streams.forEach(c=>{c.width=b})},BK=function(a,b){a.streams.forEach(c=>{c.height=b})},CK=function(a,b){a.streams.forEach(c=>{c.frameRate=b})},DK=function(a,b){a.streams.forEach(c=>{c.bandwidth=b})},EK=function(a,b){a=a.map(c=>c.a[b]);return a.some(c=>null==c)?null:a},FK=function(a,b){const c=new Set(a.map(d=>d.sa));return b.filter(d=>!c.has(d.sa))},HK=function(a,b){for(;a[0].sa<b[0].sa;)a.splice(0,1);var c=a[0];let d=b[0];c.startTime===
33
- d.startTime&&c.endTime===d.endTime||GK(c,d);const e=a.length-1;c=a[e];d=b[e];0<e&&(c.startTime!==d.startTime||c.endTime!==d.endTime)&&GK(c,d);for(c=e+1;c<b.length;)a.push(b[c]),c++},MK=function(a,b,c,d,e){var f=b[0].length();f=gJ(f).map(g=>{var h=EK(b,g)||[];const k=xK(c,g)||[];g=xK(d,g)||[];{const l=[...IK(h),...k,...g].filter(Boolean);JK(l);const {sa:m,duration:n}=l[0];h={configurationId:a,variants:h,textStreams:k,thumbStreams:g,startTime:0,id:`P${m}`,endTime:n,duration:n,sa:m}}return h});e&&KK(f[0]);
34
- LK(f);return f},IK=function(a){a=new Set(a.flatMap(b=>[b.video,b.audio]).filter(Boolean));return Array.from(a)},KK=function(a){const b=IK(a.variants)[0].S[0].Ca;a.startTime+=b;a.endTime+=b},LK=function(a){for(let b=0;b<a.length;b++){const c=a[b],d=a[b-1];c.startTime=d?d.endTime:c.startTime;c.endTime=c.startTime+c.duration}},GK=function(a,b){a.startTime=b.startTime;a.endTime=b.endTime;a.duration=b.duration;NK(a.variants,b.variants);OK(pJ(a),pJ(b))},NK=function(a,b){const c=new Map(a.map(d=>[FJ(d),
35
- d]));b.forEach(d=>{c.get(FJ(d)).drmInfos=d.drmInfos})},OK=function(a,b){const c=new Map(a.map(d=>[d.Da,d]));b.forEach(d=>{const e=c.get(d.Da);e.S=d.S;d.S.forEach(f=>{f.initSegment=e.initSegmentReference});e.segmentIndex.replace(d.S);e.Wc=d.Wc;e.Ue=d.Ue;e.duration=d.duration;e.eg=d.eg;e.encrypted=d.encrypted;e.drmInfos=d.drmInfos;e.keyId=d.keyId})},JK=function(a){const b=PK(a);a.forEach(c=>{_.RB(c.segmentIndex,b);c.duration=b;c.Ue=c.Wc+b})},PK=function(a){let b=Infinity;a.filter(sJ).forEach(c=>{b=
36
- Math.min(b,c.duration)});return b},TK=function(a){if(!(2>a.length)&&QK(a)){a=a.map(e=>({playlist:e,ag:RK(e.S[0])}));var b=a.map(e=>e.ag),c=Math.max(...b);b=Math.min(...b);if(!(1E3>c-b)){a.forEach(e=>{const f=e.playlist;for(e=e.ag;0<f.S.length&&1E3<c-e;){var g=f.S.shift(),h=f.S[0];if(!h)break;SK(g,h);h=RK(h);null!=h?e=h:({duration:h}=xJ(g.aa),e+=1E3*h)}});a=a.map(e=>e.playlist);if(a.some(e=>0===e.S.length))throw new _.I(_.D,4,4048,"Media playlists are completely out of sync.");var d=Math.min(...a.map(e=>
37
- e.S.length));a.forEach(e=>{for(;e.S.length>d;)e.S.pop()})}}},QK=function(a){return a.every(b=>!!RK(b.S[0]))},SK=function(a,b){a&&b&&[NI,MI].forEach(c=>{if(!mJ(b.aa,c)){var d=a.aa.filter(e=>e.name===c);0!==d.length&&d.forEach(e=>{b.aa.push(e)})}})},UK=function(a,b){qJ(b,(c,d)=>{_.hC(a,c.S,d.startTime)});_.$B(a.a,b[0].startTime,b[b.length-1].endTime)},VK=function(a){return null===a.o?[]:[a.o.audio,a.o.video].filter(b=>b).map(b=>b.Da)},WK=function(a,b){return _.w(function*(){var c=_.wk([b],a.a.attemptParameters);
38
- c.type=1;c=yield a.H(c);let d="";try{d=_.ni(c.data)}catch(e){throw new _.I(_.D,4,4042);}d=d.replace(/\r\n|\r(?=[^\n]|$)/gm,"\n");d=d.trim();return{text:d,response:c}})},gL=function(a,b){return _.w(function*(){var c=XK(a,b,a.w,"");if(1===c.type){var d=c.S[0].a;c=YK(d);if(!c)throw new _.I(_.D,4,4021,`Unknown file extension ${d}`);d="";c===_.t?d="avc1.42E01E":c===_.q&&(d="mp4a.40.2");c=cK(a.R,a.w,a.a.hlsDefaultCodecs||d)}d=AJ(c.aa);c=ZK(d.Ec.Qf);c.forEach(m=>{a.J.add(m.groupId)});var e=yield $K(a,d);
39
- var f=e.mi;const g=e.periods;var h=e.Fi;const k=e.$i;d=e.alternativeVariants;const l=e.alternativeTextStreams;e=e.alternativeImageStreams;if(!a.D)throw new _.I(_.D,7,7001);aL(a,g);h=bL(a,f.delay,g,h);cL(a)||(a.G=f.Md,dL(a));eL(a,h,g);f=fL(a,k);c={presentationTimeline:h,periods:g,minBufferTime:0,cues:f,muxedAudioTracks:c};d&&(c.alternativeVariants=d);l&&(c.alternativeTextStreams=l);e&&(c.alternativeImageStreams=e);a.g.debug("HLS playlist parsed",c);return c})},iL=function(a,b){return Promise.all(b.map(c=>
40
- hL(a,c)))},kL=function(a,b){b.forEach(c=>{a:{var d=a.j.get(c.verbatimUri),e=!cL(a),f=nJ(c.aa,"EXT-X-DISCONTINUITY-SEQUENCE");if(f)var g=Number(f.value);else{d?(f=d.streams[d.streams.length-1].S,f=f[f.length-1].sa):f=0;if(e&&0<f)try{{const k=nJ(c.aa,PI);if(!k)throw jL.error("Failed to infer discontinuity number, because EXT-X-MEDIA-SEQUENCE tag is missing."),Error(SI);const l=Number(k.value),m=yK(d,l);if(!m)throw jL.error("Failed to infer discontinuity number, could not find the appropriate segment in the previous playlist"+
41
- ` (segment position = ${l})`),Error(SI);var h=m.sa}g=h;break a}catch(k){throw new _.I(_.D,4,4024,"EXT-X-DISCONTINUITY-SEQUENCE tag is required for discontinuous HLS live streams.");}g=0}}c=c.S||[];for(const k of c)mJ(k.aa,LI)&&g++,k.sa=g});jK(b)},nL=function(a,b){return _.w(function*(){const {textStreams:c,thumbStreams:d,vh:e}=yield lL(a,b);var f=a.f.periods[0].variants;a.a.lowLatencyMode&&null!==a.o&&(f=f.filter(g=>g.id===a.o.id));f=f.map(g=>{const h=MJ(g.audio,e),k=MJ(g.video,e);g=mL(a,h,k,g.bandwidth);
42
- if(!g)throw new _.I(_.D,4,4047,{message:"Video and audio are encrypted in an incompatible way.",Lj:k?HJ(k).Da:void 0,audio:h?HJ(h).Da:void 0});return g});return MK(a.D.configurationId,f,c,d,!0)})},aL=function(a,b){cL(a)||2!==a.a.timeline.version||(a.I||(a.I=b[0].startTime),_.hD(b,-a.I))},oL=function(a,b){b=b.flatMap(d=>d.S[0].aa);b=nJ(b,QI);if(!b)return null;const c=(new Date(b.value)).getTime();return isNaN(c)?(a.g.warn("Failed to parse EXT-X-PROGRAM-DATE-TIME tag "+`value (value: ${b.value}).`),
43
- null):c/1E3},pL=function(a,b,c){b=b.find(e=>null!==nJ(e.aa,KI));if(!b)return[];if(null===c)throw new _.I(_.D,4,4024,"EXT-X-PROGRAM-DATE-TIME tag is required when EXT-X-DATERANGE tags are present");var d=b.aa.filter(e=>e.name===KI);b=new Map;for(const e of d)d=(d=_.L(e,"ID"))?b.get(d):void 0,(d=LJ(e,c,a.C,!cL(a),d))&&b.set(d.id,d);return Array.from(b.values())},fL=function(a,b){const c=new Set(b.map(d=>d.id));a.B.forEach((d,e)=>{c.has(e)||a.B.delete(e)});for(const d of b){if((b=a.B.get(d.id))&&b.Kd!==
44
- d.Kd)a.D.onError(new _.I(1,4,4044,"EXT-X-DATERANGE START-DATE has changed for"+` ID=${d.id}`));const e={configurationId:a.D.configurationId,schemeIdUri:d.schemeIdUri,customAttributes:d.customAttributes,value:"",startTime:d.startTime,Kd:d.Kd,endTime:d.endTime,id:d.id,type:_.de,eventElement:null};b&&!dJ(b,e)||a.B.set(d.id,e)}return Array.from(a.B.values())},qL=function(a,b,c){a.A=_.Fb;_.dC(b,!0);b.f=c[c.length-1].endTime},XK=function(a,b,c,d){a=ZJ(a.R,b,c);a.verbatimUri=d;return a},ZK=function(a){return a.filter(b=>
45
- b.name===OI&&_.L(b,_.tb)===_.lA&&!_.L(b,_.vb)).map(b=>{const c=NJ(b),d=_.L(b,_.Ka)||_.kg;return{groupId:aJ(b,_.Ea),id:_.oI++,label:aJ(b,_.Sa),language:d,channelsCount:c,primary:"YES"===_.L(b,"DEFAULT")}})},$K=function(a,b){return _.w(function*(){var c=JJ(b.Ec.closedCaptions),d=rL(a,b.Od),e=yield sL(a,b),f=Object.values(e).flat().map(k=>k.playlist),g=f[0];const h=tJ(g.aa);a.A=h;kL(a,f);!cL(a)&&TK(f);a.K=yJ(g.aa);f=GJ(g.aa,h,a.a.lowLatencyMode||!1,a.a.suggestedPresentationDelay,a.a.liveRefreshPeriod);
46
- g=yield tL(a,e.Rf,d);c=yield uL(a,e.Od,g,c);d=yield vL(a,e.Xi,d);g=yield wL(a,e.Qe);d=MK(a.D.configurationId,c,d,g,!cL(a));a.D.filterAllPeriods(d);c=[...e.Od,...e.Rf].map(k=>k.playlist);e=oL(a,c);c=pL(a,c,e);return{periods:d,Fi:e,$i:c,mi:f}})},bL=function(a,b,c,d){let e=!0,f=null,g=0;cL(a)||(e=!1,f=0,g=b);b=a.a.timeline||{};b.type=void 0;a=new _.sI(b,f,g,!0,void 0,!!a.a.lowLatencyMode);_.dC(a,e);UK(a,c);d&&_.cC(a,d);return a},dL=function(a){var b=0;for(var c of a.j.values())b=Math.max(b,c.streams[0].Wc);
47
- for(c=0;95443.7176888889<=b;)c+=95443.7176888889,b-=95443.7176888889;if(c){a.g.debug("Offsetting live streams by",c,"to compensate for rollover");for(const d of a.j.values())b=d.streams[0],95443.7176888889>b.Wc?(a.g.debug("Offset applied to",b.type),b.segmentIndex.offset(c)):a.g.debug("Offset NOT applied to",b.type)}},eL=function(a,b,c){c=EJ(c);"LIVE"===a.A||"EVENT"===a.A?(c=Math.max(c,b.J),isNaN(a.a.availabilityWindowOverride)||(c=a.a.availabilityWindowOverride),b.A=c):a.A===_.Fb&&(b.f=c)},lL=function(a,
48
- b){return _.w(function*(){const c=g=>HJ(g.stream).type===_.t||HJ(g.stream).type===_.q;var d=b.filter(c),e=b.filter(g=>!c(g)),f=g=>{g=g.map(h=>{var k=HJ(h.stream);k={language:k.language,channelsCount:k.channelsCount,spatialAudio:k.spatialAudio,closedCaptions:k.closedCaptions,primary:k.primary,kind:k.kind||null,groupId:k.groupId,type:k.type,codecs:k.codecs,name:k.originalId,uri:k.Da,Pd:{width:k.width,height:k.height,frameRate:k.frameRate}};h=Object.assign({},{playlist:h.playlist},k);return xL(a,h)});
49
- return Promise.all(g)};d=yield f(d);f=yield f(e);yL(a,d.concat(f));e=f.filter(g=>HJ(g).type===_.RA);f=f.filter(g=>HJ(g).type===_.ge);return{textStreams:e,thumbStreams:f,vh:d}})},mL=function(a,b,c,d,e){const f=[],g=(c||b).length();for(let n=0;n<g;n++){var h=b?b.streams[n]||null:null,k=c?c.streams[n]||null:null,l=h,m=k;l=l&&m?_.GB(l.drmInfos,m.drmInfos)?_.FB(l.drmInfos,m.drmInfos):null:l?l.drmInfos:m?m.drmInfos:null;if(!l)return null;m=d;h={id:e?e:a.h++,language:h?h.language:_.kg,primary:!!h&&h.primary||
50
- !!k&&k.primary,audio:h,video:k,bandwidth:m,drmInfos:l,allowedByApplication:!0,allowedByKeySystem:!0};f.push(h)}return new zL(f)},xL=function(a,b){return _.w(function*(){const c=b.playlist,d=b.codecs,e=b.type,f=b.Uc,g=b.lc,h=b.groupId,k=b.muxedAudioId,l=b.primary;var m=b.kind;const n=b.name,p=b.channelsCount,u=b.spatialAudio,v=b.closedCaptions,y=b.Pd,A=_.Hn(f||_.kg);if(1!==c.type)throw new _.I(_.D,4,4017);const E=yield AL(a,c,e,d),B=a.a.lowLatencyMode?_.IA:_.HA;let F=m;e!==_.K||m||(F=_.RA);const ia=
51
- tJ(c.aa);m=E.map(Xa=>{const cb=Xa.S,rc=Xa.Gh,Ob=Xa.mimeType,cc=Xa.sa,dc=cb[0].startTime,Eb=cb[cb.length-1].endTime,ib=Eb-dc,wa=new _.tI(cb),wb=cb[0].initSegment||null;return{id:null===g?_.oI++:g,originalId:n,createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:wa.f.bind(wa),getSegmentReference:wa.get.bind(wa),adjustSegmentDurations:wa.h.bind(wa),getDuration:wa.getDuration.bind(wa),segmentIndex:wa,segmentLookupStrategy:B,initSegmentReference:wb,mimeType:Ob,codecs:d,kind:F,eg:rc.type,
52
- encrypted:rc.type===$I,aesEncrypted:Xa.aesEncrypted,keyId:rc.keyId,language:A,originalLanguage:f||_.kg,label:n,type:e,primary:l,trickModeVideo:null,emsgSchemeIdUris:null,frameRate:y?y.frameRate:void 0,width:y?y.width:void 0,height:y?y.height:void 0,bandwidth:void 0,roles:[],channelsCount:p,spatialAudio:u,closedCaptions:v,S:cb,drmInfos:rc.drmInfos,sa:cc,Da:c.verbatimUri,Be:c.a,Wc:dc,Ue:Eb,duration:ib,groupId:h,Cj:ia,muxedAudioId:k}});return new BL(m)})},yL=function(a,b){b.forEach(c=>{a.j.a.set(HJ(c).Da,
53
- c)})},rL=function(a,b){const c=new Map;for(const f of b){var d=_.L(f,_.lA);b=_.L(f,_.Db);var e=_.L(f,WI);const g=CL(a,f);if(e){const h=_.Fr(_.K,g);c.set(`${_.K}:${e}`,h);e=g.indexOf(h);-1<e&&g.splice(e,1)}d&&(e=DL(_.q,g),c.set(`${"audio"}:${d}`,e));b&&(d=DL(_.t,g),c.set(`${"video"}:${b}`,d))}return c},sL=function(a,b){return _.w(function*(){const c=yield Promise.all([EL(a,b.Ec.Qf),EL(a,b.Ec.Yi),EL(a,b.Od),EL(a,b.Qe)]),[d,e,f,g]=c;return{Rf:d,Xi:e,Od:f,Qe:g}})},tL=function(a,b,c){return _.w(function*(){if(0===
54
- b.length)return new Map;var d=[FL(a,b[0],c)];yield d[0];d=d.concat(b.slice(1).map(e=>FL(a,e,c)));d=yield Promise.all(d);return IJ(d)})},uL=function(a,b,c,d){return _.w(function*(){const e=new Set;var f=[...b];let g=0;var h=Infinity;for(let k=0;k<f.length;++k){const l=Number(aJ(f[k].tag,_.ma));l<h&&(h=l,g=k)}h=f.splice(g,1).pop();h=yield GL(a,h,c,d,e);f=f.map(k=>GL(a,k,c,d,e));f=yield Promise.all(f);f.splice(g,0,h);return f.reduce(_.kB,[])})},vL=function(a,b,c){return Promise.all(b.map(d=>FL(a,d,c)))},
55
- wL=function(a,b){return Promise.all(b.map(c=>HL(a,c)))},IL=function(a,b){return _.w(function*(){const c=_.Qm(b.verbatimUri,a.w),{response:d,text:e}=yield WK(a,c);return XK(a,e,d.uri,b.verbatimUri)})},JL=function(a,b,c){return _.w(function*(){const d=yield xL(a,{playlist:c,codecs:b.codecs,type:b.type,Uc:b.originalLanguage,lc:b.id,groupId:b.groupId,primary:b.primary,kind:b.kind||null,name:b.label,channelsCount:b.channelsCount,spatialAudio:b.spatialAudio||!1,closedCaptions:b.closedCaptions,Pd:{width:b.width,
56
- height:b.height,frameRate:b.frameRate}});b.bandwidth&&DK(d,b.bandwidth);return d})},cL=function(a){return a.A===_.Fb},EL=function(a,b){return _.w(function*(){return(yield Promise.all(b.map(c=>_.w(function*(){const d=yield KL(a,c);return d?{tag:c,playlist:d}:null})))).filter(Boolean)})},hL=function(a,b){return _.w(function*(){var c=new URL(HJ(b).Be);if(a.a.lowLatencyMode&&a.K&&a.K.Wf){var d=b.streams[b.streams.length-1].segmentIndex;if(d=d.a[d.a.length-1]){var e=d.a,f=e.length-1;d={ni:d.position,Ai:e&&
57
- 0<e.length?f:null}}else d=null;if(e=d)d=c.searchParams,f=e.Ai,d.set("_HLS_msn",e.ni.toString()),null===f&&d.get(XI)&&d.delete(XI),null!==f&&d.set(XI,f.toString())}const {response:g,text:h}=yield WK(a,c.toString());c=HJ(b).Da;d=HJ(b).Be;e=g.uri;d!==e&&(d=e,zK(b,d));c=XK(a,h,d,c);return{stream:b,playlist:c}})},CL=function(a,b){var c=_.L(b,_.pa,a.a.hlsDefaultCodecs||"avc1.42E01E,mp4a.40.2").split(/\s*,\s*/);c=KJ(c);b=new Set;const d=[];for(const e of c)c=_.qB(e),b.has(c)?a.g.debug("Ignoring duplicate codec"):
58
- (d.push(e),b.add(c));return d},DL=function(a,b){if(1===b.length)return b[0];a=_.Fr(a,b);if(null!=a)return a;throw new _.I(_.D,4,4025,{codecList:b});},FL=function(a,b,c){return _.w(function*(){const d=b.tag,e=b.playlist;return LL(a,e.verbatimUri,()=>_.w(function*(){const f=aJ(d,_.Ea),g=uJ(aJ(d,_.tb));var h=aJ(d,_.tb).toUpperCase();if(uJ(h)!==_.K)h=null;else{var k=d.getAttribute("FORCED");k=!(!k||!k.value||"YES"!==k.value.toUpperCase());var l=_.RA;h===HI&&(l=_.CA);k&&(l=_.Zd);h=l}k=c.get(`${g}:${f}`)||
59
- "";l=_.L(d,_.Ka);const m=_.L(d,_.Sa),n=_.L(d,"DEFAULT"),p=g===_.q?NJ(d):null;var u=g===_.q?(u=_.L(d,"CHANNELS"))?u.includes("/JOC"):!1:!1;return yield xL(a,{playlist:e,codecs:k,type:g,Uc:l,primary:"YES"===n,name:m,channelsCount:p,spatialAudio:u,groupId:f,kind:h,lc:null,closedCaptions:null,Pd:null})}))})},HL=function(a,b){return _.w(function*(){const c=b.tag,d=b.playlist;return LL(a,d.verbatimUri,()=>_.w(function*(){var e=_.L(c,_.pa)||"jpg",f=_.L(c,_.Ka);const g=_.L(c,_.Sa);e=yield xL(a,{playlist:d,
60
- codecs:e,type:_.ge,Uc:f,name:g,primary:!1,kind:null,channelsCount:null,spatialAudio:!1,closedCaptions:null,lc:null,groupId:null,Pd:null});(f=_.L(c,_.ma))&&DK(e,Number(f));return e}))})},GL=function(a,b,c,d,e){return _.w(function*(){var f=b.tag,g=Number(aJ(f,_.ma));if(f.hasAttribute("FRAME-RATE")||f.hasAttribute(_.mb)){var h=_.L(f,"FRAME-RATE");f=_.L(f,_.mb);var [k,l]=f?f.split("x"):[null,null];h={frameRate:fJ(h),width:fJ(k),height:fJ(l)}}else h=null;if(f=yield ML(a,b,h,c,d)){h=f.video;f=f.audio;var m=
61
- 0<f.length?f:[null];h=0<h.length?h:[null];f=[];for(const n of m)for(const p of h){m=(p?HJ(p).Da:"")+" - "+(n?HJ(n).Da:"");if(e.has(m)){a.g.debug("Skipping variant which only differs in text streams.");continue}const u=mL(a,n,p,g);null==u?a.g.warn("Incompatible DRM info in HLS variant. Skipping."):(f.push(u),e.add(m))}g=f}else g=[];return g})},NL=function(a,b,c,d,e,f){let g=CL(a,b);a.g.debug("Guessing stream type for",b.toString());b=!1;const h=_.Fr(_.t,g),k=d+e;1!==g.length||c||h?!k&&1<g.length?(a.g.debug("Guessing multiplexed audio+video"),
62
- c=_.t,g=[g.join(",")]):d&&f?(a.g.debug(TI),c=_.q,b=!0):e?(a.g.debug(TI),c=_.q):(a.g.debug("Guessing video-only"),c=_.t):(c=_.q,a.g.debug(TI));return{type:c,th:g,ei:b}},LL=function(a,b,c){if(a.j.has(b))return a=a.j.get(b),Promise.resolve(a);if(a.j.f.has(b))return a.j.f.get(b)||null;c=c();a.j.set(b,c);return c},ML=function(a,b,c,d,e){return _.w(function*(){var f=b.tag,g=b.playlist,h=_.L(f,_.lA),k=_.L(f,_.Db);h=h?d.get(`${"audio"}:${h}`)||[]:[];k=k?d.get(`${"video"}:${k}`)||[]:[];k={audio:h,video:k};
63
- const l=g.verbatimUri;g=k.audio.find(u=>HJ(u).Da===l);const {type:m,th:n,ei:p}=NL(a,f,c,k.audio.length,k.video.length,g);f=null;p||(f=yield OL(a,b,n,m,e,c));if(null==f)return null;k[m]=[f];m===_.q&&c&&k.video.forEach(u=>{AK(u,c.width);BK(u,c.height);CK(u,c.frameRate)});return k})},OL=function(a,b,c,d,e,f){return _.w(function*(){const g=b.tag,h=b.playlist;return LL(a,h.verbatimUri,()=>_.w(function*(){var k=_.L(g,HI);let l=null;d===_.t&&k&&"NONE"!==k&&(l=e.get(k));k=(k=_.L(g,_.lA)||void 0)&&a.J.has(k)?
64
- k:void 0;var m=DL(d,c);if(k){const n=DL(_.q,c);m+=`,${n}`}return yield xL(a,{playlist:h,codecs:m,type:d,closedCaptions:l,primary:!1,kind:null,Uc:null,name:null,channelsCount:null,spatialAudio:!1,lc:null,groupId:null,muxedAudioId:k,Pd:f})}))})},AL=function(a,b,c,d){return _.w(function*(){var e=b.verbatimUri,f=b.S;var g=void 0===g?0:g;var h=(h=nJ(b.aa,PI))?Number(h.value):g;g=[];e=yield PL(a,b.a,e,f,h,c,d);if(0===f.length)f=[];else{var k=[],l=[];for(var m of f)mJ(m.aa,LI)&&0<l.length&&(k.push(l),l=
65
- []),l.push(m);k.push(l);f=k}for(m=0;m<f.length;m++)k=f[m],l=yield QL(a,b.a,k,h,e,c,d,g[g.length-1]||null),g.push(l),h+=k.length;RL(g);return g})},KL=function(a,b){return _.w(function*(){var c=b.name!==OI?!0:_.L(b,_.tb)===WI;c=_.L(b,_.vb,void 0,{required:c});if(!c)return null;const d=_.Qm(c,a.w),e=Date.now(),{response:f,text:g}=yield WK(a,d);a.D.onEvent(new _.H(ZI,{detail:{duration:Date.now()-e,type:"media"}}));return XK(a,g,f.uri,c)})},RL=function(a){if(1<(new Set(a.map(b=>b.mimeType))).size)throw new _.I(_.D,
66
- 4,4045,"Media playlist contains discontinuities with different MIME types. This is valid, but not yet supported.");},SL=function(a,b,c){a=jJ(a.aa,NI);if(1<a.length)throw new _.I(_.D,4,4020);a=a[0];if(!a)return null;const d=aJ(a,_.vb),e=_.Qm(d,b);b=zJ(a,null,!0);return new _.pI(()=>[e],b.ma,b.ja,c)},TL=function(a,b,c,d,e,f,g){const h=[];for(let p=0;p<b.f.length;p++){const u=b.f[p];var k=0===p,l=k?a:h[h.length-1],m=k?d:l.endTime,n=Number(_.L(u,JI));n=m+n;k=zJ(u,k?null:l.ja,k);l=String(_.L(u,_.vb));
67
- const v=(l=_.Qm(l,g))?[l]:[];m=new BJ(c,m,n,()=>v,k.ma,k.ja,e,f,!1,null,null,null,null);if("YES"===_.L(u,"INDEPENDENT")||0===p)m.h=!0;h.push(m)}return h},UL=function(a,b,c,d,e,f,g,h,k,l,m){const n=c.aa;var p=c.a;0<jJ(n,NI).length&&(m=SL(c,k,g));const u=null!=p,v=p?[p]:[];if(!u&&!a.a.lowLatencyMode)return null;a=0;p={ma:0,ja:null};let y=null;u?({duration:c}=xJ(n),a=e+c,p=wJ(n,b?b.ja:null)):(b=TL(b,c,d,e,f,g,k),a=b[b.length-1].endTime,y=b);h=h===_.ge?oJ(n):null;d=new BJ(d,e,a,()=>v,p.ma,p.ja,f,g,!1,
68
- null,h?h.sd:null,h?h.Nd:null,h?h.durationPerTile:null,y,m);d.sa=l;return d},PL=function(a,b,c,d,e,f,g){return _.w(function*(){var h=d[0];if(null!=a.C)return a.C;if(!cL(a)&&a.f)try{var k=a.j.get(c);var l=k?yK(k,e)||null:null;if(!l)throw new _.I(_.D,4,4030,"Segment not found in pervious playlist update.");var m=l.startTime+l.Ca;a.g.debug(`Setting playlist start time to ${m}.`);return a.C=m}catch(n){if(h=a.j.get(c))m=h.streams[h.streams.length-1].S,m=m[m.length-1],a.g.warn(`Last #EXT-X-MEDIA-SEQUENCE values ${h.streams[0].S[0].position} - ${m.position}`+
69
- `, new values ${e} - ${e+d.length-1}.`,b,h);throw new _.I(_.D,4,4047,{message:"The updated playlist does not share any segments with the previous one.",uri:c});}m=yield VL(a,f,g,h);l=uK(h.aa,a.w,e);k=SL(h,b,l);h=yield WL(a,k,h,l,m,g);a.g.debug(`Setting playlist start time to ${h}.`);return a.C=h})},QL=function(a,b,c,d,e,f,g,h){return _.w(function*(){var k=c[0],l=null==h;const m=yield VL(a,f,g,k);var n=h?h.ki:null;if(mJ(c[0].aa,MI)||null===n)n=rK(c,m),n=0===n.length?[nK()]:n;else{var p=rK(c,m);n=[n,
70
- ...p]}p=n;n=p[p.length-1];p=oK(p);let u=h?h.li:null;var v=XL(u,k.aa,a.w,d);let y=SL(k,b,v)||(h?h.fi:null);const A=k.sa;k=l?e:yield YL(a,A,y,k,d,v,m,g);l=[];v=!1;for(let B=0;B<c.length;B++){var E=c[B];const F=l[l.length-1]||null,ia=0===B?0:F.endTime,Xa=d+B,cb=XL(u,E.aa,a.w,Xa);(u=cb)&&(v=!0);if(E=UL(a,F,E,Xa,ia,k,cb,f,b,A,y))y=E.initSegment,l.push(E)}return{S:l,Gh:p,ki:n,aesEncrypted:v,mimeType:m,endTime:l[l.length-1].endTime,sa:A,fi:y,li:u}})},VL=function(a,b,c,d){return _.w(function*(){const e=d.a;
71
- var f=nJ(d.aa,NI);f=f?aJ(f,_.vb):null;return ZL(a,b,c,e,f)})},WL=function(a,b,c,d,e,f){return _.w(function*(){if(null==c.a)return 0;const g=CJ(c,d);return wK(a.T,b,g,e,f,null!=d)})},XL=function(a,b,c,d){return b.some(e=>e.name===MI&&"NONE"===_.L(e,UI))?null:(b=uK(b,c,d))?b:a&&a.generatedIv?Object.assign({},a,{iv:_.fm(new Uint8Array(12),hJ(d))}):a},YL=function(a,b,c,d,e,f,g,h){return _.w(function*(){if(a.L.has(b))return a.L.get(b);const k=yield WL(a,c,d,f,g,h);a.g.debug(`Segment #${e} has raw media timestamp `+
72
- `${k} s.`);a.L.set(b,k);return k})},ZL=function(a,b,c,d,e){return _.w(function*(){const f=[d,e].filter(Boolean);var g=_.Ir(f,b,c);if(g)return g;g=_.wk([d],a.a.attemptParameters);g.method="HEAD";g.type=2;g=(yield a.H(g)).headers["content-type"];if(!g)throw new _.I(_.D,4,4021,"Unknown MIME type of: "+f.join(", "));return g.toLowerCase().split(";")[0]})},YK=a=>{a=_.Rm(a)||"";return null!=_.wu.video[a]?_.t:null!=_.wu.audio[a]?_.q:null},TJ=class{constructor(a,b,c,d){if(1===b){if(!d||0===d.length)throw new _.I(_.D,
73
- 4,4043,"Media playlist must have at least one segment!");if(null==d[0].a)throw new _.I(_.D,4,4043,"Media playlist must have at least one full segment!");}this.a=a;this.verbatimUri="";this.type=b;this.aa=c;this.S=1===b?d:null}},bK=class{constructor(a,b,c){c=void 0===c?[]:c;this.aa=b;this.a=a;this.f=c;this.sa=-1}},BJ=class extends _.uC{constructor(a,b,c,d,e,f,g,h,k,l,m,n,p,u,v){u=void 0===u?[]:u;super(a,b,c,d,e,f,g,void 0===h?null:h,void 0===k?!1:k,void 0===l?null:l,void 0===m?null:m,void 0===n?null:
74
- n,void 0===p?null:p,u,void 0===v?null:v);this.sa=0}},$J=/^#EXT-X-DEFINE/,aK=/^#(EXT-X-DISCONTINUITY-SEQUENCE|EXT-X-ENDLIST|EXT-X-I-FRAMES-ONLY|EXT-X-MEDIA-SEQUENCE|EXT-X-PART-INF|EXT-X-PLAYLIST-TYPE|EXT-X-SERVER-CONTROL|EXT-X-TARGETDURATION|EXT-X-DATERANGE|EXT-X-VERSION)/,$L=class{constructor(){this.h=0;this.a=new Map}},aM=class{constructor(){this.a=new Map;this.f=new Map}set(a,b){this.f.set(a,b);return b.then(c=>this.a.set(a,c)).catch(()=>{}).then(()=>this.f.delete(a))}has(a){return this.a.has(a)}get(a){return this.a.get(a)||
75
- null}values(){return Array.from(this.a.values())}clear(){this.f.clear();this.a.clear()}},jL=new _.T("clpp.hls.DiscontinuityUtils");var tK={"com.apple.streamingkeydelivery":function(a,b){if(b===_.yg)throw new _.I(_.D,4,4041);if(aJ(a,UI)===VI)throw new _.I(_.D,4,4044,"EXT-X-KEY:METHOD SAMPLE-AES-CTR is not supported in FairPlay.");return _.nB(_.sd,[{initDataType:_.Mf,initData:new Uint8Array(0)}],"")},"com.microsoft.playready":mK,"urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":mK,"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":function(a){var b=aJ(a,UI);if(!kK.includes(b))return lK.error("Widevine in HLS is only supported with [",
76
- kK.join(", "),"], not",b),null;b=aJ(a,_.vb);b=_.gm(b);b=_.G(b.data);b=_.nB(_.wd,[{initDataType:_.Wc,initData:b}],"");if(a=_.L(a,"KEYID"))b.keyIds=[a.substr(2).toLowerCase()];return b}},kK=["SAMPLE-AES",VI],lK=new _.T("clpp.hls.DrmParser");var sK=new _.T("clpp.hls.EncryptionUtils");var bM=class{constructor(a){this.g=new _.T("clpp.hls.MediaReader");this.f=a;this.a={attemptParameters:_.sk()}}};var BL=class{constructor(a){this.streams=a}length(){return this.streams.length}};var zL=class{constructor(a){this.a=a}length(){return this.a.length}};var RK=a=>{if(!a)return null;a=nJ(a.aa,QI);if(!a)return null;a=Date.parse(a.value);return isNaN(a)?null:a};var cM=class{constructor(){this.a=this.D=null;this.h=1;this.j=new aM;this.w="";this.R=new $L;this.G=0;this.o=null;this.l=new _.Li(()=>{this.Wb()});this.A=_.Fb;this.f=null;this.F=new _.Zt;this.K=this.C=null;this.g=new _.T("clpp.hls.HlsParser");this.L=new Map;this.T=new bM(this.H.bind(this));this.P=!1;this.I=null;this.M=!1;this.B=new Map;this.J=new Set}configure(a){this.a=a;this.T.a=a}setCurrentVariant(a){this.o=a}start(a,b){const c=this;return _.w(function*(){if(c.P)throw Error("start() may be called only once!");
77
- c.P=!0;c.D=b;var d=Date.now();const {response:e,text:f}=yield WK(c,a);c.D.onEvent(new _.H(ZI,{detail:{duration:Date.now()-d,type:"master"}}));c.w=e.uri;d=yield gL(c,f);c.f=d;const g=c.G;c.l&&0<g&&c.l.la(g);return d})}requestStop(){this.M=!0}stop(){this.l&&(this.l.stop(),this.l=null);const a=[];this.F&&(a.push(this.F.destroy()),this.F=null);this.j.clear();this.f=this.a=this.D=this.o=null;this.B.clear();this.J.clear();return Promise.all(a)}update(){const a=this;return _.w(function*(){const b=a.f;if(!cL(a)&&
78
- b){var c=b.presentationTimeline;"LIVE"===a.A&&(a.C=null);var d=Array.from(a.j.values());if(a.a.lowLatencyMode&&null!==a.o){const g=VK(a);d=d.filter(h=>g.includes(HJ(h).Da))}var e=yield iL(a,d);d=e.map(g=>g.playlist);kL(a,d);e=yield nL(a,e);FK(b.periods,e).forEach(g=>{a.D.filterNewPeriod(g)});aL(a,e);var f=oL(a,d);f=pL(a,d,f);b.cues=fL(a,f);HK(b.periods,e);UK(c,e);if(d=rJ(d))!0!==a.a.keepTimelineLive&&qL(a,c,e),a.l.stop(),a.l=null;if(a.D.onUpdate)a.D.onUpdate(b);if(d&&a.D.onTurnedStatic)a.D.onTurnedStatic();
79
- a.M&&(yield a.stop());return b}})}loadVariant(a,b){const c=this;return _.w(function*(){const d=a.id;var e=c.f.periods.find(k=>k.id===b);if(e&&(e=e.variants.find(k=>k.id===d)))return e;e=c.f.alternativeVariants.find(k=>k.id===d);if(!e)throw new _.ql(`No alternative variant with id: ${d}`);var f=null,g=null;if(e.audio){const k=e.audio;f=LL(c,k.verbatimUri,()=>_.w(function*(){const l=yield IL(c,k);return JL(c,k,l)}))}if(e.video){const k=e.video;g=LL(c,k.verbatimUri,()=>_.w(function*(){const l=yield IL(c,
80
- k);return JL(c,k,l)}))}f=yield f;g=yield g;e=mL(c,f,g,e.bandwidth,e.id);let h;e&&(e=MK(c.D.configurationId,[e],[],[],!cL(c)),c.D.filterAllPeriods(e),e.forEach((k,l)=>{c.f.periods[l].variants.push(k.variants[0]);b===c.f.periods[l].id&&(h=k.variants[0])}));if(!h)throw new _.ql(`Could load variant with id: ${d}`);return h})}loadTextStream(a,b){const c=this;return _.w(function*(){let d;var e=c.f.periods.find(f=>f.id===b);e&&(e=e.textStreams.find(f=>f.id===a)||null)&&(d=e);if(!d&&c.f.alternativeTextStreams){const f=
81
- c.f.alternativeTextStreams.find(h=>h.id===a)||null;if(!f)throw new _.ql(`Could not load text stream with id: ${a}`);const g=yield LL(c,f.verbatimUri,()=>_.w(function*(){const h=yield IL(c,f);return JL(c,f,h)}));g&&c.f.periods.forEach((h,k)=>{h=g.streams[k];c.f.periods[k].textStreams.push(h);h.id===a&&(d=h)})}if(!d)throw new _.ql(`Could not load text stream with id: ${a}`);return d})}Wb(){const a=this;return _.w(function*(){a.g.debug(_.xA);if(a.D)try{yield a.update(),a.l&&0<a.G&&a.l.la(a.G)}catch(b){if(!(b instanceof
82
- _.I))throw b;a.D&&(a.D.onError(b),1===b.severity&&a.l&&a.l.la(.1))}})}H(a){if(!this.F)throw new _.I(_.D,7,7001);a=this.D.networkingEngine.fetch(a);_.Gl(this.F,a);return a.U}};_.x("clpp.hls.HlsComponent",class extends _.yv{install(){_.Et.m3u8=cM;_.Dt[_.ul]=cM;_.Dt[YI]=cM}uninstall(){_.QC("m3u8");_.RC(_.ul);_.RC(YI)}id(){return"hls"}});};f.call(g, window);
22
+ 22|a[5]<<14|a[6]<<6|a[7]>>>2,f*=4,f+=a[7]&3,Math.round(f/9E4);break}}iJ(a,e)||d();e+=10;e+=f}while(e<a.byteLength);return d()},dK=function(a,b){let c=null,d=0;try{(new _.ip).O(_.De,_.bp).O(_.hg,_.bp).O(_.ye,_.bp).fa("mdhd",g=>{g.reader.skip(0===g.version?8:16);d=_.N(g.reader);g.parser.stop()}).parse(b,!0)}catch(g){c=g}if(c||!d)throw _.Nv.error("Unable to find timescale in init segment!"),new _.I(_.D,4,4030,II,c);let e=0,f=!1;try{(new _.ip).O("moof",_.bp).O("traf",_.bp).fa("tfdt",g=>{var h=d;if(0===
23
+ g.version)h=_.N(g.reader)/h;else{{const k=_.N(g.reader),l=_.N(g.reader);if(!(2097151>=k||h>=Math.pow(2,12)))throw Error("Cannot accurately parse MP4 timestamp, base time is too high and timescale is \x3c\x3d 2^12");h=k/h*Math.pow(2,32)+l/h}}e=h;f=!0;g.parser.stop()}).parse(a,!0)}catch(g){c=g}if(c||!f)throw new _.I(_.D,4,4030,II,c);return e},eK=function(a){for(;a.getPosition()<a.Sa()-1;){const b=a.getPosition();if(71===_.Uo(a))return bJ(a),b}return-1},fK=function(a){function b(){d.seek(e+188);f=_.Uo(d);
24
+ 71!==f&&(d.seek(e+192),f=_.Uo(d));71!==f&&(d.seek(e+204),f=_.Uo(d));71!==f&&c();bJ(d)}function c(){throw new _.I(_.D,4,4030);}const d=new _.aq(new DataView(a),!1);let e=0,f=0;e=eK(d);0>e&&(_.Nv.error("Unable to find sync byte in TS after scanning."),c());for(;;){e=d.getPosition();f=_.Uo(d);71!==f&&c();a=_.Vo(d);if(8191===(a&8191)){b();continue}if(!(a&16384)){b();continue}a=(_.Uo(d)&48)>>4;0!==a&&2!==a||c();3===a&&(a=_.Uo(d),d.skip(a));if(1!==_.N(d)>>8){b();continue}d.skip(3);a=_.Uo(d)>>6;0!==a&&1!==
25
+ a||c();0===_.Uo(d)&&c();a=_.Uo(d);const g=_.Vo(d),h=_.Vo(d);return(1073741824*((a&14)>>1)+((g&65534)<<14|(h&65534)>>1))/9E4}},iK=function(a){const b=gK(a),c=hK(a);a.forEach(d=>{const e=d.T,f=e.findIndex(h=>h.ma===b);let g=e.findIndex(h=>h.ma===c+1);-1===g&&(g=e.length);d.T=e.slice(f,g)})},hK=function(a){a=a.map(b=>b.T[b.T.length-1].ma);return Math.min(...a)},gK=function(a){a=a.map(b=>b.T[0].ma);return Math.max(...a)},lK=function(a){var b=aJ(a,UI);if(!jK.includes(b))return kK.error("PlayReady in HLS is only supported with [",
26
+ jK.join(", "),"], not",b),null;a=aJ(a,_.vb);b=_.fm(a);a=null;b=_.G(b.data);try{a=_.bB(_.hq(b))}catch(c){a=b}return _.pB(_.ud,[{initDataType:_.Wc,initData:a}],"")},nK=function(a){if(0===a.length)return mK();if(a.some(c=>"whole-segment"===c.type)||a.every(c=>c.type===_.Ge))return a[0];a=a.filter(c=>c.type===$I);const b=_.ci(a.flatMap(c=>c.drmInfos));return{keyId:a[a.length-1].keyId,type:$I,drmInfos:b}},qK=function(a,b){return oK(a).map(c=>pK(c.ca,b)).filter(Boolean)},oK=function(a){return a.filter(b=>
27
+ mJ(b.ca,MI))},pK=function(a,b){a=jJ(a,MI).filter(d=>"AES-128"!==aJ(d,UI));if(0===a.length)return null;var c=aJ(a[0],UI);if(1===a.length&&"NONE"===c)return mK();c=a.map(d=>aJ(d,UI));if(!c.every(d=>"SAMPLE-AES"===d)&&!c.every(d=>d===VI))throw rK.warn(`EXT-X-KEY methods ${c.join(", ")} are incompatible.`),new _.I(_.D,4,4044,"Multiple EXT-X-KEY tags with incompatible METHOD values.");a=a.map(d=>{const e=_.L(d,"KEYFORMAT","identity");{const f=sK[e]||null;d=f?f(d,b):null}d||rK.warn("Unsupported HLS KEYFORMAT",
28
+ e);return d}).filter(Boolean);if(0===a.length)throw new _.I(_.D,4,4026);return{keyId:a.map(d=>d.keyIds).reduce((d,e)=>d.concat(e),[]).reverse()[0]||null,type:$I,drmInfos:a}},mK=function(){return{type:_.Ge,drmInfos:[],keyId:null}},tK=function(a,b,c){a=jJ(a,MI)[0];if(!a||"AES-128"!==aJ(a,UI))return null;var d=_.L(a,"IV","");d?c={iv:_.bm((d||"0x").slice(2)),generatedIv:!1}:(d=_.L(a,"KEYFORMAT"),c=null==d||"identity"===d?{iv:_.em(new Uint8Array(12),hJ(c)),generatedIv:!0}:{iv:null,generatedIv:!1});const {iv:e,
29
+ generatedIv:f}=c;return{method:"AES-128",url:_.Pm(aJ(a,_.vb),b),iv:e,generatedIv:f}},uK=function(a,b,c){return _.w(function*(){const d=b.f(),e=_.XB(b.Da(),b.na,b.na+2048-1,a.a.attemptParameters);e.type=2;const f=_.XB(b.Da(),b.na,b.ja,a.a.attemptParameters);f.type=2;d&&(f.keyInfo=d);try{return yield a.f(c?f:e)}catch(g){if(7001===g.code||c)throw g;a.g.warn("Unable to fetch a partial HLS segment! Falling back to a full segment request, which is expensive! Your server should support Range requests and CORS pre-flights.",
30
+ e.uris[0]);try{return yield a.f(f)}catch(h){throw a.g.error("Failed to fetch media segment to parse its start timestamp.",f.uris[0],h),new _.I(_.D,4,4030,"Failed to fetch the media segment.");}}})},vK=function(a,b,c,d,e,f){return _.w(function*(){a.g.debug("Fetching segment to find start time");if("audio/mpeg"===d||d===_.Gc||d===_.Fc)return 0;if(d===_.Ec){var g=yield uK(a,c,f);g=_.G(g.data);if(!iJ(g))throw new _.I(_.D,4,4030,"AAC segment does not contain an ID3 tag.");return cK(g)}if(d===_.zg||d===
31
+ _.Hc)return g=[uK(a,c,f)],b&&g.push(uK(a,b,!0)),g=yield Promise.all(g),dK(g[0].data,(g[1]||g[0]).data);if(d===_.yg)return g=yield uK(a,c,f),fK(g.data);if(!_.ht(`${d.split("/")[0]||""}/mp4;codecs="${e}"`))return 0;throw new _.I(_.D,4,4030);})},wK=function(a,b){a=a.map(c=>c.streams[b]);return a.some(c=>null==c)?null:a},xK=function(a,b){a=a.streams.find(c=>{c=c.T;return c[0].position<=b&&b<=c[c.length-1].position});return null==a?null:a.T.find(c=>c.position===b)||null},yK=function(a,b){a.streams.forEach(c=>
32
+ {c.Ee=b})},zK=function(a,b){a.streams.forEach(c=>{c.width=b})},AK=function(a,b){a.streams.forEach(c=>{c.height=b})},BK=function(a,b){a.streams.forEach(c=>{c.frameRate=b})},CK=function(a,b){a.streams.forEach(c=>{c.bandwidth=b})},DK=function(a,b){a=a.map(c=>c.a[b]);return a.some(c=>null==c)?null:a},EK=function(a,b){const c=new Set(a.map(d=>d.ma));return b.filter(d=>!c.has(d.ma))},GK=function(a,b){for(;a[0].ma<b[0].ma;)a.splice(0,1);var c=a[0];let d=b[0];c.startTime===d.startTime&&c.endTime===d.endTime||
33
+ FK(c,d);const e=a.length-1;c=a[e];d=b[e];0<e&&(c.startTime!==d.startTime||c.endTime!==d.endTime)&&FK(c,d);for(c=e+1;c<b.length;)a.push(b[c]),c++},KK=function(a,b,c,d,e){var f=b[0].length();f=gJ(f).map(g=>{var h=DK(b,g)||[];const k=wK(c,g)||[];g=wK(d,g)||[];{const l=[...HK(h),...k,...g].filter(Boolean);IK(l);const {ma:m,duration:n}=l[0];h={configurationId:a,variants:h,textStreams:k,thumbStreams:g,startTime:0,id:`P${m}`,endTime:n,duration:n,ma:m}}return h});f[0].startTime+=e;f[0].endTime+=e;JK(f);return f},
34
+ HK=function(a){a=new Set(a.flatMap(b=>[b.video,b.audio]).filter(Boolean));return Array.from(a)},JK=function(a){for(let b=0;b<a.length;b++){const c=a[b],d=a[b-1];c.startTime=d?d.endTime:c.startTime;c.endTime=c.startTime+c.duration}},FK=function(a,b){a.startTime=b.startTime;a.endTime=b.endTime;a.duration=b.duration;LK(a.variants,b.variants);MK(pJ(a),pJ(b))},LK=function(a,b){const c=new Map(a.map(d=>[FJ(d),d]));b.forEach(d=>{c.get(FJ(d)).drmInfos=d.drmInfos})},MK=function(a,b){const c=new Map(a.map(d=>
35
+ [d.$a,d]));b.forEach(d=>{const e=c.get(d.$a);e.T=d.T;d.T.forEach(f=>{f.initSegment=e.initSegmentReference});e.segmentIndex.replace(d.T);e.ed=d.ed;e.Xe=d.Xe;e.duration=d.duration;e.gg=d.gg;e.encrypted=d.encrypted;e.drmInfos=d.drmInfos;e.keyId=d.keyId})},IK=function(a){const b=NK(a);a.forEach(c=>{_.TB(c.segmentIndex,b);c.duration=b;c.Xe=c.ed+b})},NK=function(a){let b=Infinity;a.filter(sJ).forEach(c=>{b=Math.min(b,c.duration)});return b},RK=function(a){if(!(2>a.length)&&OK(a)){a=a.map(e=>({playlist:e,
36
+ cg:PK(e.T[0])}));var b=a.map(e=>e.cg),c=Math.max(...b);b=Math.min(...b);if(!(1E3>c-b)){a.forEach(e=>{const f=e.playlist;for(e=e.cg;0<f.T.length&&1E3<c-e;){var g=f.T.shift(),h=f.T[0];if(!h)break;QK(g,h);h=PK(h);null!=h?e=h:({duration:h}=xJ(g.ca),e+=1E3*h)}});a=a.map(e=>e.playlist);if(a.some(e=>0===e.T.length))throw new _.I(_.D,4,4048,"Media playlists are completely out of sync.");var d=Math.min(...a.map(e=>e.T.length));a.forEach(e=>{for(;e.T.length>d;)e.T.pop()})}}},OK=function(a){return a.every(b=>
37
+ !!PK(b.T[0]))},QK=function(a,b){a&&b&&[NI,MI].forEach(c=>{if(!mJ(b.ca,c)){var d=a.ca.filter(e=>e.name===c);0!==d.length&&d.forEach(e=>{b.ca.push(e)})}})},SK=function(a,b){qJ(b,(c,d)=>{_.jC(a,c.T,d.startTime)});_.bC(a.a,b[0].startTime,b[b.length-1].endTime)},TK=function(a,b){return _.w(function*(){var c=_.vk([b],a.a.attemptParameters);c.type=1;c=yield a.I(c);let d="";try{d=_.ni(c.data)}catch(e){throw new _.I(_.D,4,4042);}d=d.replace(/\r\n|\r(?=[^\n]|$)/gm,"\n");d=d.trim();return{text:d,response:c}})},
38
+ dL=function(a,b){return _.w(function*(){var c=UK(a,b,a.o,"");if(1===c.type){var d=c.T[0].a;c=VK(d);if(!c)throw new _.I(_.D,4,4021,`Unknown file extension ${d}`);d="";c===_.t?d="avc1.42E01E":c===_.q&&(d="mp4a.40.2");c=bK(a.S,a.o,a.a.hlsDefaultCodecs||d)}d=AJ(c.ca);c=WK(d.Gc.Sf);c.forEach(m=>{a.K.add(m.groupId)});var e=yield XK(a,d);var f=e.mi;const g=e.periods;var h=e.Fi;const k=e.$i;d=e.alternativeVariants;const l=e.alternativeTextStreams;e=e.alternativeImageStreams;if(!a.D)throw new _.I(_.D,7,7001);
39
+ YK(a,g);h=ZK(a,f.delay,g,h);$K(a)||(a.G=f.Ud,a.g.info(`Update playlist each ${a.G} s`),aL(a));bL(a,h,g);f=cL(a,k);c={presentationTimeline:h,periods:g,minBufferTime:0,cues:f,muxedAudioTracks:c};d&&(c.alternativeVariants=d);l&&(c.alternativeTextStreams=l);e&&(c.alternativeImageStreams=e);a.g.debug("HLS playlist parsed",c);return c})},fL=function(a,b){return Promise.all(b.map(c=>eL(a,c)))},hL=function(a,b){b.forEach(c=>{a:{var d=a.j.get(c.verbatimUri),e=!$K(a),f=nJ(c.ca,"EXT-X-DISCONTINUITY-SEQUENCE");
40
+ if(f)var g=Number(f.value);else{d?(f=d.streams[d.streams.length-1].T,f=f[f.length-1].ma):f=0;if(e&&0<f)try{{const k=nJ(c.ca,PI);if(!k)throw gL.error("Failed to infer discontinuity number, because EXT-X-MEDIA-SEQUENCE tag is missing."),Error(SI);const l=Number(k.value),m=xK(d,l);if(!m)throw gL.error("Failed to infer discontinuity number, could not find the appropriate segment in the previous playlist"+` (segment position = ${l})`),Error(SI);var h=m.ma}g=h;break a}catch(k){throw new _.I(_.D,4,4024,
41
+ "EXT-X-DISCONTINUITY-SEQUENCE tag is required for discontinuous HLS live streams.");}g=0}}c=c.T||[];for(const k of c)mJ(k.ca,LI)&&g++,k.ma=g});iK(b)},kL=function(a,b){return _.w(function*(){"LIVE"===a.w&&(a.M=!0,a.H=!0);const {textStreams:c,thumbStreams:d,vh:e}=yield iL(a,b),f=a.f.periods[0].variants.map(g=>{const h=LJ(g.audio,e),k=LJ(g.video,e);g=jL(a,h,k,g.bandwidth);if(!g)throw new _.I(_.D,4,4047,{message:"Video and audio are encrypted in an incompatible way.",Mj:k?k.streams[0].$a:void 0,audio:h?
42
+ h.streams[0].$a:void 0});return g});return KK(a.D.configurationId,f,c,d,a.B)})},YK=function(a,b){$K(a)||2!==a.a.timeline.version||(a.J||(a.J=b[0].startTime),_.fD(b,-a.J))},lL=function(a,b){b=b.flatMap(d=>d.T[0].ca);b=nJ(b,QI);if(!b)return null;const c=(new Date(b.value)).getTime();return isNaN(c)?(a.g.warn("Failed to parse EXT-X-PROGRAM-DATE-TIME tag "+`value (value: ${b.value}).`),null):c/1E3},mL=function(a,b,c){b=b.find(e=>null!==nJ(e.ca,KI));if(!b)return[];if(null===c)throw new _.I(_.D,4,4024,
43
+ "EXT-X-PROGRAM-DATE-TIME tag is required when EXT-X-DATERANGE tags are present");var d=b.ca.filter(e=>e.name===KI);b=new Map;for(const e of d)d=(d=_.L(e,"ID"))?b.get(d):void 0,(d=KJ(e,c,a.B,!$K(a),d))&&b.set(d.id,d);return Array.from(b.values())},cL=function(a,b){const c=new Set(b.map(d=>d.id));a.A.forEach((d,e)=>{c.has(e)||a.A.delete(e)});for(const d of b){if((b=a.A.get(d.id))&&b.Sd!==d.Sd)a.D.onError(new _.I(1,4,4044,"EXT-X-DATERANGE START-DATE has changed for"+` ID=${d.id}`));const e={configurationId:a.D.configurationId,
44
+ schemeIdUri:d.schemeIdUri,customAttributes:d.customAttributes,value:"",startTime:d.startTime,Sd:d.Sd,endTime:d.endTime,id:d.id,type:_.de,eventElement:null};b&&!dJ(b,e)||a.A.set(d.id,e)}return Array.from(a.A.values())},nL=function(a,b,c){a.w=_.Eb;_.fC(b,!0);b.f=c[c.length-1].endTime},UK=function(a,b,c,d){a=YJ(a.S,b,c);a.verbatimUri=d;return a},WK=function(a){return a.filter(b=>b.name===OI&&_.L(b,_.tb)===_.mA&&!_.L(b,_.vb)).map(b=>{const c=MJ(b),d=_.L(b,_.Ka)||_.kg;return{groupId:aJ(b,_.Ea),id:_.nI++,
45
+ label:aJ(b,_.Sa),language:d,channelsCount:c,primary:"YES"===_.L(b,"DEFAULT")}})},XK=function(a,b){return _.w(function*(){var c=IJ(b.Gc.closedCaptions),d=oL(a,b.Wd),e=yield pL(a,b),f=Object.values(e).flat().map(k=>k.playlist),g=f[0];const h=tJ(g.ca);a.w=h;h!==_.Eb&&(a.H=!0);hL(a,f);!$K(a)&&RK(f);a.L=yJ(g.ca);f=GJ(g.ca,h,a.a.lowLatencyMode||!1,a.a.suggestedPresentationDelay,a.a.liveRefreshPeriod);g=yield qL(a,e.Tf,d);c=yield rL(a,e.Wd,g,c);d=yield sL(a,e.Xi,d);g=yield tL(a,e.Te);d=KK(a.D.configurationId,
46
+ c,d,g,a.B);a.D.filterAllPeriods(d);c=[...e.Wd,...e.Tf].map(k=>k.playlist);e=lL(a,c);c=mL(a,c,e);return{periods:d,Fi:e,$i:c,mi:f}})},ZK=function(a,b,c,d){let e=!0,f=null,g=0;$K(a)||(e=!1,f=0,g=b);b=a.a.timeline||{};b.type=void 0;a=new _.sI(b,f,g,!0,void 0,!!a.a.lowLatencyMode);_.fC(a,e);SK(a,c);d&&_.eC(a,d);return a},aL=function(a){var b=0;for(var c of a.j.values())b=Math.max(b,c.streams[0].ed);for(c=0;95443.7176888889<=b;)c+=95443.7176888889,b-=95443.7176888889;if(c){a.g.debug("Offsetting live streams by",
47
+ c,"to compensate for rollover");for(const d of a.j.values())b=d.streams[0],95443.7176888889>b.ed?(a.g.debug("Offset applied to",b.type),b.segmentIndex.offset(c)):a.g.debug("Offset NOT applied to",b.type)}},bL=function(a,b,c){c=EJ(c);"LIVE"===a.w||"EVENT"===a.w?(c=Math.max(c,b.J),isNaN(a.a.availabilityWindowOverride)||(c=a.a.availabilityWindowOverride),b.A=c):a.w===_.Eb&&(b.f=c)},iL=function(a,b){return _.w(function*(){const c=h=>h.stream.zc()===_.t||h.stream.zc()===_.q;var d=b.filter(c),e=b.filter(h=>
48
+ !c(h)),f=h=>{var k=h.stream.streams[0];k={language:k.language,channelsCount:k.channelsCount,spatialAudio:k.spatialAudio,closedCaptions:k.closedCaptions,primary:k.primary,kind:k.kind||null,groupId:k.groupId,type:k.type,codecs:k.codecs,name:k.originalId,uri:k.$a,Xd:{width:k.width,height:k.height,frameRate:k.frameRate}};h=Object.assign({},{playlist:h.playlist,bc:null},k);return uL(a,h)};const g=[];for(const h of d)g.push(yield f(h));d=[];for(const h of e)d.push(yield f(h));vL(a,g.concat(d));e=d.filter(h=>
49
+ h.zc()===_.TA);f=d.filter(h=>h.zc()===_.ge);return{textStreams:e,thumbStreams:f,vh:g}})},jL=function(a,b,c,d,e){const f=[],g=(c||b).length();for(let n=0;n<g;n++){var h=b?b.streams[n]||null:null,k=c?c.streams[n]||null:null,l=h,m=k;l=l&&m?_.IB(l.drmInfos,m.drmInfos)?_.HB(l.drmInfos,m.drmInfos):null:l?l.drmInfos:m?m.drmInfos:null;if(!l)return null;m=d;h={id:e?e:a.h++,language:h?h.language:_.kg,primary:!!h&&h.primary||!!k&&k.primary,audio:h,video:k,bandwidth:m,drmInfos:l,allowedByApplication:!0,allowedByKeySystem:!0};
50
+ f.push(h)}return new wL(f)},uL=function(a,b){return _.w(function*(){const c=b.playlist,d=b.codecs,e=b.type,f=b.bd,g=b.bc,h=b.groupId,k=b.muxedAudioId,l=b.primary;var m=b.kind;const n=b.name,p=b.channelsCount,u=b.spatialAudio,v=b.closedCaptions,y=b.Xd,A=_.Gn(f||_.kg);if(1!==c.type)throw new _.I(_.D,4,4017);const E=yield xL(a,c,e,d),B=a.a.lowLatencyMode?_.KA:_.JA;let F=m;e!==_.K||m||(F=_.TA);const ka=tJ(c.ca);m=E.map(Ya=>{const db=Ya.T,tc=Ya.Gh,Ob=Ya.mimeType,ec=Ya.ma,fc=db[0].startTime,Hb=db[db.length-
51
+ 1].endTime,jb=Hb-fc,xa=new _.tI(db),wb=db[0].initSegment||null;return{id:null==g?_.nI++:g,originalId:n,createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:xa.f.bind(xa),getSegmentReference:xa.get.bind(xa),adjustSegmentDurations:xa.h.bind(xa),getDuration:xa.getDuration.bind(xa),segmentIndex:xa,segmentLookupStrategy:B,initSegmentReference:wb,mimeType:Ob,codecs:d,kind:F,gg:tc.type,encrypted:tc.type===$I,aesEncrypted:Ya.aesEncrypted,keyId:tc.keyId,language:A,originalLanguage:f||_.kg,
52
+ label:n,type:e,primary:l,trickModeVideo:null,emsgSchemeIdUris:null,frameRate:y?y.frameRate:void 0,width:y?y.width:void 0,height:y?y.height:void 0,bandwidth:void 0,roles:[],channelsCount:p,spatialAudio:u,closedCaptions:v,T:db,drmInfos:tc.drmInfos,ma:ec,$a:c.verbatimUri,Ee:c.a,ed:fc,Xe:Hb,duration:jb,groupId:h,Dj:ka,muxedAudioId:k}});return new yL(m)})},vL=function(a,b){b.forEach(c=>{a.j.a.set(c.streams[0].$a,c)})},oL=function(a,b){const c=new Map;for(const f of b){var d=_.L(f,_.mA);b=_.L(f,_.Db);var e=
53
+ _.L(f,WI);const g=zL(a,f);if(e){const h=_.Er(_.K,g);c.set(`${_.K}:${e}`,h);e=g.indexOf(h);-1<e&&g.splice(e,1)}d&&(e=AL(_.q,g),c.set(`${"audio"}:${d}`,e));b&&(d=AL(_.t,g),c.set(`${"video"}:${b}`,d))}return c},pL=function(a,b){return _.w(function*(){const c=yield Promise.all([BL(a,b.Gc.Sf),BL(a,b.Gc.Yi),BL(a,b.Wd),BL(a,b.Te)]),[d,e,f,g]=c;return{Tf:d,Xi:e,Wd:f,Te:g}})},qL=function(a,b,c){return _.w(function*(){if(0===b.length)return new Map;var d=[CL(a,b[0],c)];yield d[0];d=d.concat(b.slice(1).map(e=>
54
+ CL(a,e,c)));d=yield Promise.all(d);return HJ(d)})},rL=function(a,b,c,d){return _.w(function*(){const e=new Set;var f=[...b];let g=0;var h=Infinity;for(let k=0;k<f.length;++k){const l=Number(aJ(f[k].tag,_.ma));l<h&&(h=l,g=k)}h=f.splice(g,1).pop();h=yield DL(a,h,c,d,e);f=f.map(k=>DL(a,k,c,d,e));f=yield Promise.all(f);f.splice(g,0,h);return f.reduce(_.mB,[])})},sL=function(a,b,c){return Promise.all(b.map(d=>CL(a,d,c)))},tL=function(a,b){return Promise.all(b.map(c=>EL(a,c)))},FL=function(a,b){return _.w(function*(){const c=
55
+ _.Pm(b.verbatimUri,a.o),{response:d,text:e}=yield TK(a,c);return UK(a,e,d.uri,b.verbatimUri)})},GL=function(a,b,c){return _.w(function*(){const d=yield uL(a,{playlist:c,codecs:b.codecs,type:b.type,bd:b.originalLanguage,bc:b.id,groupId:b.groupId,primary:b.primary,kind:b.kind||null,name:b.label,channelsCount:b.channelsCount,spatialAudio:b.spatialAudio||!1,closedCaptions:b.closedCaptions,Xd:{width:b.width,height:b.height,frameRate:b.frameRate}});b.bandwidth&&CK(d,b.bandwidth);return d})},$K=function(a){return a.w===
56
+ _.Eb},BL=function(a,b){return _.w(function*(){return(yield Promise.all(b.map(c=>_.w(function*(){const d=yield HL(a,c);return d?{tag:c,playlist:d}:null})))).filter(Boolean)})},eL=function(a,b){return _.w(function*(){var c=new URL(b.streams[0].Ee);if(a.a.lowLatencyMode&&a.L&&a.L.Yf){var d=b.streams[b.streams.length-1].segmentIndex;if(d=d.a[d.a.length-1]){var e=d.a,f=e.length-1;d={ni:d.position,Ai:e&&0<e.length?f:null}}else d=null;if(e=d)d=c.searchParams,f=e.Ai,d.set("_HLS_msn",e.ni.toString()),null===
57
+ f&&d.get(XI)&&d.delete(XI),null!==f&&d.set(XI,f.toString())}const {response:g,text:h}=yield TK(a,c.toString());c=b.streams[0].$a;d=b.streams[0].Ee;e=g.uri;d!==e&&(d=e,yK(b,d));c=UK(a,h,d,c);return{stream:b,playlist:c}})},zL=function(a,b){var c=_.L(b,_.pa,a.a.hlsDefaultCodecs||"avc1.42E01E,mp4a.40.2").split(/\s*,\s*/);c=JJ(c);b=new Set;const d=[];for(const e of c)c=_.sB(e),b.has(c)?a.g.debug("Ignoring duplicate codec"):(d.push(e),b.add(c));return d},AL=function(a,b){if(1===b.length)return b[0];a=_.Er(a,
58
+ b);if(null!=a)return a;throw new _.I(_.D,4,4025,{codecList:b});},CL=function(a,b,c){return _.w(function*(){const d=b.tag,e=b.playlist;return IL(a,e.verbatimUri,()=>_.w(function*(){const f=aJ(d,_.Ea),g=uJ(aJ(d,_.tb));var h=aJ(d,_.tb).toUpperCase();if(uJ(h)!==_.K)h=null;else{var k=d.getAttribute("FORCED");k=!(!k||!k.value||"YES"!==k.value.toUpperCase());var l=_.TA;h===HI&&(l=_.EA);k&&(l=_.Zd);h=l}k=c.get(`${g}:${f}`)||"";l=_.L(d,_.Ka);const m=_.L(d,_.Sa),n=_.L(d,"DEFAULT"),p=g===_.q?MJ(d):null;var u=
59
+ g===_.q?(u=_.L(d,"CHANNELS"))?u.includes("/JOC"):!1:!1;return yield uL(a,{playlist:e,codecs:k,type:g,bd:l,primary:"YES"===n,name:m,channelsCount:p,spatialAudio:u,groupId:f,kind:h,bc:null,closedCaptions:null,Xd:null})}))})},EL=function(a,b){return _.w(function*(){const c=b.tag,d=b.playlist;return IL(a,d.verbatimUri,()=>_.w(function*(){var e=_.L(c,_.pa)||"jpg",f=_.L(c,_.Ka);const g=_.L(c,_.Sa);e=yield uL(a,{playlist:d,codecs:e,type:_.ge,bd:f,name:g,primary:!1,kind:null,channelsCount:null,spatialAudio:!1,
60
+ closedCaptions:null,bc:null,groupId:null,Xd:null});(f=_.L(c,_.ma))&&CK(e,Number(f));return e}))})},DL=function(a,b,c,d,e){return _.w(function*(){var f=b.tag,g=Number(aJ(f,_.ma));if(f.hasAttribute("FRAME-RATE")||f.hasAttribute(_.mb)){var h=_.L(f,"FRAME-RATE");f=_.L(f,_.mb);var [k,l]=f?f.split("x"):[null,null];h={frameRate:fJ(h),width:fJ(k),height:fJ(l)}}else h=null;if(f=yield JL(a,b,h,c,d)){h=f.video;f=f.audio;var m=0<f.length?f:[null];h=0<h.length?h:[null];f=[];for(const n of m)for(const p of h){m=
61
+ (p?p.streams[0].$a:"")+" - "+(n?n.streams[0].$a:"");if(e.has(m)){a.g.debug("Skipping variant which only differs in text streams.");continue}const u=jL(a,n,p,g);null==u?a.g.warn("Incompatible DRM info in HLS variant. Skipping."):(f.push(u),e.add(m))}g=f}else g=[];return g})},KL=function(a,b,c,d,e,f){let g=zL(a,b);a.g.debug("Guessing stream type for",b.toString());b=!1;const h=_.Er(_.t,g),k=d+e;1!==g.length||c||h?!k&&1<g.length?(a.g.debug("Guessing multiplexed audio+video"),c=_.t,g=[g.join(",")]):d&&
62
+ f?(a.g.debug(TI),c=_.q,b=!0):e?(a.g.debug(TI),c=_.q):(a.g.debug("Guessing video-only"),c=_.t):(c=_.q,a.g.debug(TI));return{type:c,th:g,ei:b}},IL=function(a,b,c){if(a.j.has(b))return a=a.j.get(b),Promise.resolve(a);if(a.j.f.has(b))return a.j.f.get(b)||null;c=c();a.j.set(b,c);return c},JL=function(a,b,c,d,e){return _.w(function*(){var f=b.tag,g=b.playlist,h=_.L(f,_.mA),k=_.L(f,_.Db);h=h?d.get(`${"audio"}:${h}`)||[]:[];k=k?d.get(`${"video"}:${k}`)||[]:[];k={audio:h,video:k};const l=g.verbatimUri;g=k.audio.find(u=>
63
+ u.streams[0].$a===l);const {type:m,th:n,ei:p}=KL(a,f,c,k.audio.length,k.video.length,g);f=null;p||(f=yield LL(a,b,n,m,e,c));if(null==f)return null;k[m]=[f];m===_.q&&c&&k.video.forEach(u=>{zK(u,c.width);AK(u,c.height);BK(u,c.frameRate)});return k})},LL=function(a,b,c,d,e,f){return _.w(function*(){const g=b.tag,h=b.playlist;return IL(a,h.verbatimUri,()=>_.w(function*(){var k=_.L(g,HI);let l=null;d===_.t&&k&&"NONE"!==k&&(l=e.get(k));k=(k=_.L(g,_.mA)||void 0)&&a.K.has(k)?k:void 0;var m=AL(d,c);if(k){const n=
64
+ AL(_.q,c);m+=`,${n}`}return yield uL(a,{playlist:h,codecs:m,type:d,closedCaptions:l,primary:!1,kind:null,bd:null,name:null,channelsCount:null,spatialAudio:!1,bc:null,groupId:null,muxedAudioId:k,Xd:f})}))})},xL=function(a,b,c,d){return _.w(function*(){var e=b.verbatimUri,f=b.T;var g=void 0===g?0:g;var h=nJ(b.ca,PI);var k=h?Number(h.value):g;g=[];h=null;if(a.H){a.H=!1;var l=a.B;a.B=yield ML(a,b.a,e,f,k,c,d);null!=l&&(h=a.B-l)}e=k;if(0===f.length)f=[];else{k=[];l=[];for(var m of f)mJ(m.ca,LI)&&0<l.length&&
65
+ (k.push(l),l=[]),l.push(m);k.push(l);f=k}for(m=0;m<f.length;m++)k=f[m],l=yield NL(a,b.a,k,e,c,d,g[g.length-1]||null,h),g.push(l),e+=k.length;OL(g);return g})},HL=function(a,b){return _.w(function*(){var c=b.name!==OI?!0:_.L(b,_.tb)===WI;c=_.L(b,_.vb,void 0,{required:c});if(!c)return null;const d=_.Pm(c,a.o),e=Date.now(),{response:f,text:g}=yield TK(a,d);a.D.onEvent(new _.H(ZI,{detail:{duration:Date.now()-e,type:"media"}}));return UK(a,g,f.uri,c)})},OL=function(a){if(1<(new Set(a.map(b=>b.mimeType))).size)throw new _.I(_.D,
66
+ 4,4045,"Media playlist contains discontinuities with different MIME types. This is valid, but not yet supported.");},PL=function(a,b,c){a=jJ(a.ca,NI);if(1<a.length)throw new _.I(_.D,4,4020);a=a[0];if(!a)return null;const d=aJ(a,_.vb),e=_.Pm(d,b);b=zJ(a,null,!0);return new _.oI(()=>[e],b.na,b.ja,c)},QL=function(a,b,c,d,e,f,g){const h=[];for(let p=0;p<b.f.length;p++){const u=b.f[p];var k=0===p,l=k?a:h[h.length-1],m=k?d:l.endTime,n=Number(_.L(u,JI));n=m+n;k=zJ(u,k?null:l.ja,k);l=String(_.L(u,_.vb));
67
+ const v=(l=_.Pm(l,g))?[l]:[];m=new BJ(c,m,n,()=>v,k.na,k.ja,e,f,!1,null,null,null,null);if("YES"===_.L(u,"INDEPENDENT")||0===p)m.h=!0;h.push(m)}return h},RL=function(a,b,c,d,e,f,g,h,k,l,m){const n=c.ca;var p=c.a;0<jJ(n,NI).length&&(m=PL(c,k,g));const u=null!=p,v=p?[p]:[];if(!u&&!a.a.lowLatencyMode)return null;a=0;p={na:0,ja:null};let y=null;u?({duration:c}=xJ(n),a=e+c,p=wJ(n,b?b.ja:null)):(b=QL(b,c,d,e,f,g,k),a=b[b.length-1].endTime,y=b);h=h===_.ge?oJ(n):null;d=new BJ(d,e,a,()=>v,p.na,p.ja,f,g,!1,
68
+ null,h?h.Bd:null,h?h.Vd:null,h?h.durationPerTile:null,y,m);d.ma=l;return d},ML=function(a,b,c,d,e,f,g){return _.w(function*(){var h=d[0];if(!$K(a)&&a.f)try{return SL(a,c,e)}catch(n){if(h=a.j.get(c)){var k=h.streams[h.streams.length-1].T;k=k[k.length-1];a.g.warn(`Last #EXT-X-MEDIA-SEQUENCE values ${h.streams[0].T[0].position} - ${k.position}`+`, new values ${e} - ${e+d.length-1}.`,b,h)}throw new _.I(_.D,4,4047,{message:"The updated playlist does not share any segments with the previous one.",uri:c});
69
+ }k=yield TL(a,f,g,h);const l=tK(h.ca,a.o,e),m=PL(h,b,l);h=yield UL(a,m,h,l,k,g);a.g.debug(`Setting playlist start time to ${h}.`);return h})},NL=function(a,b,c,d,e,f,g,h){return _.w(function*(){var k=c[0];const l=yield TL(a,e,f,k);var m=g?g.ki:null;if(mJ(c[0].ca,MI)||null===m)m=qK(c,l),m=0===m.length?[mK()]:m;else{var n=qK(c,l);m=[m,...n]}n=m;m=n[n.length-1];n=nK(n);let p=g?g.li:null;var u=VL(p,k.ca,a.o,d);let v=PL(k,b,u)||(g?g.fi:null);const y=k.ma;k=yield WL(a,y,v,k,d,u,l,f,h,null==g);u=[];let A=
70
+ !1;for(let B=0;B<c.length;B++){var E=c[B];const F=u[u.length-1]||null,ka=0===B?0:F.endTime,Ya=d+B,db=VL(p,E.ca,a.o,Ya);(p=db)&&(A=!0);if(E=RL(a,F,E,Ya,ka,k,db,e,b,y,v))v=E.initSegment,u.push(E)}return{T:u,Gh:n,ki:m,aesEncrypted:A,mimeType:l,endTime:u[u.length-1].endTime,ma:y,fi:v,li:p}})},SL=function(a,b,c){const d=XL(a,b,c);if(!d)throw new _.I(_.D,4,4030,"Segment not found in previous playlist update.");return a.f.periods.find(e=>e.ma===d.ma).startTime+d.startTime},TL=function(a,b,c,d){return _.w(function*(){const e=
71
+ d.a;var f=nJ(d.ca,NI);f=f?aJ(f,_.vb):null;return YL(a,b,c,e,f)})},UL=function(a,b,c,d,e,f){return _.w(function*(){if(null==c.a)return 0;const g=CJ(c,d);return vK(a.U,b,g,e,f,null!=d)})},VL=function(a,b,c,d){return b.some(e=>e.name===MI&&"NONE"===_.L(e,UI))?null:(b=tK(b,c,d))?b:a&&a.generatedIv?Object.assign({},a,{iv:_.em(new Uint8Array(12),hJ(d))}):a},WL=function(a,b,c,d,e,f,g,h,k,l){return _.w(function*(){if(a.C.has(b)&&l&&a.M&&null!=k){var m=a.f.periods.filter(p=>p.ma<b).map(p=>p.duration).reduce((p,
72
+ u)=>p+u,0);m=k-m;const n=a.C.get(b);a.C.set(b,n+m);a.M=!1}if(a.C.has(b))return a.C.get(b);m=yield UL(a,c,d,f,g,h);a.g.debug(`Segment #${e} has raw media timestamp `+`${m} s.`);a.C.set(b,m);return m})},XL=function(a,b,c){return(a=a.j.get(b))?xK(a,c)||null:null},YL=function(a,b,c,d,e){return _.w(function*(){const f=[d,e].filter(Boolean);var g=_.Hr(f,b,c);if(g)return g;g=_.vk([d],a.a.attemptParameters);g.method="HEAD";g.type=2;g=(yield a.I(g)).headers["content-type"];if(!g)throw new _.I(_.D,4,4021,"Unknown MIME type of: "+
73
+ f.join(", "));return g.toLowerCase().split(";")[0]})},VK=a=>{a=_.Qm(a)||"";return null!=_.xu.video[a]?_.t:null!=_.xu.audio[a]?_.q:null},SJ=class{constructor(a,b,c,d){if(1===b){if(!d||0===d.length)throw new _.I(_.D,4,4043,"Media playlist must have at least one segment!");if(null==d[0].a)throw new _.I(_.D,4,4043,"Media playlist must have at least one full segment!");}this.a=a;this.verbatimUri="";this.type=b;this.ca=c;this.T=1===b?d:null}},aK=class{constructor(a,b,c){c=void 0===c?[]:c;this.ca=b;this.a=
74
+ a;this.f=c;this.ma=-1}},BJ=class extends _.pI{constructor(a,b,c,d,e,f,g,h,k,l,m,n,p,u,v){u=void 0===u?[]:u;super(a,b,c,d,e,f,g,void 0===h?null:h,void 0===k?!1:k,void 0===l?null:l,void 0===m?null:m,void 0===n?null:n,void 0===p?null:p,u,void 0===v?null:v);this.ma=0}},ZJ=/^#EXT-X-DEFINE/,$J=/^#(EXT-X-DISCONTINUITY-SEQUENCE|EXT-X-ENDLIST|EXT-X-I-FRAMES-ONLY|EXT-X-MEDIA-SEQUENCE|EXT-X-PART-INF|EXT-X-PLAYLIST-TYPE|EXT-X-SERVER-CONTROL|EXT-X-TARGETDURATION|EXT-X-DATERANGE|EXT-X-VERSION)/,ZL=class{constructor(){this.h=
75
+ 0;this.a=new Map}},$L=class{constructor(){this.a=new Map;this.f=new Map}set(a,b){this.f.set(a,b);return b.then(c=>this.a.set(a,c)).catch(()=>{}).then(()=>this.f.delete(a))}has(a){return this.a.has(a)}get(a){return this.a.get(a)||null}values(){return Array.from(this.a.values())}clear(){this.f.clear();this.a.clear()}},gL=new _.T("clpp.hls.DiscontinuityUtils");var sK={"com.apple.streamingkeydelivery":function(a,b){if(b===_.yg)throw new _.I(_.D,4,4041);if(aJ(a,UI)===VI)throw new _.I(_.D,4,4044,"EXT-X-KEY:METHOD SAMPLE-AES-CTR is not supported in FairPlay.");return _.pB(_.sd,[{initDataType:_.Mf,initData:new Uint8Array(0)}],"")},"com.microsoft.playready":lK,"urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":lK,"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":function(a){var b=aJ(a,UI);if(!jK.includes(b))return kK.error("Widevine in HLS is only supported with [",
76
+ jK.join(", "),"], not",b),null;b=aJ(a,_.vb);b=_.fm(b);b=_.G(b.data);b=_.pB(_.wd,[{initDataType:_.Wc,initData:b}],"");if(a=_.L(a,"KEYID"))b.keyIds=[a.substr(2).toLowerCase()];return b}},jK=["SAMPLE-AES",VI],kK=new _.T("clpp.hls.DrmParser");var rK=new _.T("clpp.hls.EncryptionUtils");var aM=class{constructor(a){this.g=new _.T("clpp.hls.MediaReader");this.f=a;this.a={attemptParameters:_.rk()}}};var yL=class{constructor(a){this.streams=a}length(){return this.streams.length}zc(){return this.streams[0].type}};var wL=class{constructor(a){this.a=a}length(){return this.a.length}};var PK=a=>{if(!a)return null;a=nJ(a.ca,QI);if(!a)return null;a=Date.parse(a.value);return isNaN(a)?null:a};var bM=class{constructor(){this.a=this.D=null;this.h=1;this.j=new $L;this.o="";this.S=new ZL;this.G=0;this.l=new _.Li(()=>{this.Yb()});this.w=_.Eb;this.f=null;this.F=new _.$t;this.B=0;this.L=null;this.g=new _.T("clpp.hls.HlsParser");this.C=new Map;this.H=this.M=!1;this.U=new aM(this.I.bind(this));this.N=!1;this.J=null;this.R=!1;this.A=new Map;this.K=new Set}configure(a){this.a=a;this.U.a=a}setCurrentVariant(){}start(a,b){const c=this;return _.w(function*(){if(c.N)throw Error("start() may be called only once!");
77
+ c.N=!0;c.D=b;var d=Date.now();const {response:e,text:f}=yield TK(c,a);c.D.onEvent(new _.H(ZI,{detail:{duration:Date.now()-d,type:"master"}}));c.o=e.uri;d=yield dL(c,f);c.f=d;const g=c.G;c.l&&0<g&&c.l.la(g);return d})}requestStop(){this.R=!0}stop(){this.l&&(this.l.stop(),this.l=null);const a=[];this.F&&(a.push(this.F.destroy()),this.F=null);this.j.clear();this.f=this.a=this.D=null;this.A.clear();this.K.clear();return Promise.all(a)}update(){const a=this;return _.w(function*(){const b=a.f;if(!$K(a)&&
78
+ b){var c=b.presentationTimeline,d=Array.from(a.j.values()),e=yield fL(a,d);d=e.map(g=>g.playlist);hL(a,d);e=yield kL(a,e);EK(b.periods,e).forEach(g=>{a.D.filterNewPeriod(g)});YK(a,e);var f=lL(a,d);f=mL(a,d,f);b.cues=cL(a,f);GK(b.periods,e);SK(c,e);if(d=rJ(d))!0!==a.a.keepTimelineLive&&nL(a,c,e),a.l.stop(),a.l=null;if(a.D.onUpdate)a.D.onUpdate(b);if(d&&a.D.onTurnedStatic)a.D.onTurnedStatic();a.R&&(yield a.stop());return b}})}loadVariant(a,b){const c=this;return _.w(function*(){const d=a.id;var e=c.f.periods.find(k=>
79
+ k.id===b);if(e&&(e=e.variants.find(k=>k.id===d)))return e;e=c.f.alternativeVariants.find(k=>k.id===d);if(!e)throw new _.pl(`No alternative variant with id: ${d}`);var f=null,g=null;if(e.audio){const k=e.audio;f=IL(c,k.verbatimUri,()=>_.w(function*(){const l=yield FL(c,k);return GL(c,k,l)}))}if(e.video){const k=e.video;g=IL(c,k.verbatimUri,()=>_.w(function*(){const l=yield FL(c,k);return GL(c,k,l)}))}f=yield f;g=yield g;e=jL(c,f,g,e.bandwidth,e.id);let h;e&&(e=KK(c.D.configurationId,[e],[],[],0),c.D.filterAllPeriods(e),
80
+ e.forEach((k,l)=>{c.f.periods[l].variants.push(k.variants[0]);b===c.f.periods[l].id&&(h=k.variants[0])}));if(!h)throw new _.pl(`Could load variant with id: ${d}`);return h})}loadTextStream(a,b){const c=this;return _.w(function*(){let d;var e=c.f.periods.find(f=>f.id===b);e&&(e=e.textStreams.find(f=>f.id===a)||null)&&(d=e);if(!d&&c.f.alternativeTextStreams){const f=c.f.alternativeTextStreams.find(h=>h.id===a)||null;if(!f)throw new _.pl(`Could not load text stream with id: ${a}`);const g=yield IL(c,
81
+ f.verbatimUri,()=>_.w(function*(){const h=yield FL(c,f);hL(c,[h]);return GL(c,f,h)}));g&&c.f.periods.forEach((h,k)=>{h=g.streams[k];c.f.periods[k].textStreams.push(h);h.id===a&&(d=h)})}if(!d)throw new _.pl(`Could not load text stream with id: ${a}`);return d})}Yb(){const a=this;return _.w(function*(){a.g.debug(_.zA);if(a.D)try{yield a.update(),a.l&&0<a.G&&a.l.la(a.G)}catch(b){if(!(b instanceof _.I))throw b;a.D&&(a.D.onError(b),1===b.severity&&a.l&&a.l.la(.1))}})}I(a){if(!this.F)throw new _.I(_.D,
82
+ 7,7001);a=this.D.networkingEngine.fetch(a);_.Fl(this.F,a);return a.V}};_.x("clpp.hls.HlsComponent",class extends _.zv{install(){_.Ft.m3u8=bM;_.Et[_.tl]=bM;_.Et[YI]=bM}uninstall(){_.OC("m3u8");_.PC(_.tl);_.PC(YI)}id(){return"hls"}});};f.call(g, window);
package/cl.hlssmpte.js CHANGED
@@ -1,5 +1,5 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var JT=function(a){a.a.one(a.m,_.te,()=>IT(a))},IT=function(a){const b=a.m.getSurface().getMedia();if(b)if(a.h){a.a.on(b.textTracks,_.oc,d=>KT(a,d));var c=Array.from(b.textTracks);c.filter(d=>d.kind===_.Ae).forEach(d=>{KT(a,{track:d})});!LT(c)&&a.l&&(a.g.warn("The metadata track is not present. Changing an audio track in order to enforce the creation of the metadata track."),MT(a,b))}else a.g.warn("The clpp.ttml.TextParser class is not available. Please register the ttml component first.");
2
- else a.g.warn("A video element is not available. Skipping.")},KT=function(a,b){b=b.track;b.kind===_.Ae&&(a.g.info("The metadata track has been added."),b.mode=_.ce,a.a.on(b,_.Bd,c=>NT(a,c)))},LT=function(a){return a.some(b=>b.kind===_.Ae)},MT=function(a,b){const c=a.m.getTrackManager(),d=c.pa(),e=c.getAudioTracks().find(g=>g!==d);if(e){var f=()=>c.za(d);a.a.on(b.textTracks,_.oc,g=>{g.track.kind===_.Ae&&(a.a.off(b.textTracks,_.oc,f),c.za(d))});c.za(e)}else a.g.warn("Can't enforce the creation of the metadata track if single audio track. Skipping.")},
3
- NT=function(a,b){const c=OT(a);c&&Array.from(b.target.activeCues||[]).forEach(d=>{if(d!==a.f&&Number.isFinite(d.startTime)&&Number.isFinite(d.endTime)&&"org.id3"===d.type&&d.value&&"TXXX"===d.value.key){var e=new PT(d);if(e.f===c&&null!==e.a){a.f=d;d=a.h.parseMedia(_.ri(e.a),{periodStart:a.j,segmentStart:e.startTime,segmentEnd:e.endTime});const f=a.m.getTextDisplayer();f.remove(0,e.startTime);f.append(d.cues,d.styles)}}})},OT=function(a){return(a=a.m.getTrackManager().va())&&a.language&&a.language.toLowerCase()},
4
- PT=class{constructor(a){this.startTime=a.startTime;this.endTime=a.endTime;this.a=this.f=null;a=a.value;if(!_.z(a)){a:{var b=a.info;if(_.jh(b)&&(b=b.toLowerCase().match(/lang:(\w+)/))&&b[1]){b=b[1].toLowerCase();break a}b=null}this.f=b;a=a.data;this.a=a=_.jh(a)?a:null}}};var QT=class{constructor(a,b,c){this.m=a;this.l=b;this.j=c;this.a=new _.Kt;this.h=(a=_.ut(_.Bc))?new a(this.m.getConfiguration()):null;this.g=new _.T("clpp.hlssmpte.ImageCueHandler");this.f=null;JT(this)}destroy(){this.a.release();this.f=null;return Promise.resolve()}};var RT=class extends _.Ov{constructor(){super();this.a=null;this.f=!1}onPlayerCreated(){}onContentWillLoad(a){if(this.f=_.Zi()){var b=a.getConfiguration();b=_.dh(b.hlssmpte||{});typeof b.patchMetadataTrack!==_.Nc&&(b.patchMetadataTrack=!1);_.kh(b.timestampOffset)||(b.timestampOffset=0);this.a=new QT(a,b.patchMetadataTrack,b.timestampOffset)}}onPlayerWillDestroy(){const a=this;return _.w(function*(){a.a&&(yield a.a.destroy(),a.a=null)})}id(){return"hlssmpte"}};_.x("clpp.hlssmpte.HlsSmptePlugin",RT);
5
- RT.Id="hlssmpte";_.Qn(new class{create(){return new RT}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var KT=function(a){a.a.one(a.m,_.qe,()=>JT(a))},JT=function(a){const b=a.m.getSurface().getMedia();if(b)if(a.h){a.a.on(b.textTracks,_.oc,d=>LT(a,d));var c=Array.from(b.textTracks);c.filter(d=>d.kind===_.Ae).forEach(d=>{LT(a,{track:d})});!MT(c)&&a.l&&(a.g.warn("The metadata track is not present. Changing an audio track in order to enforce the creation of the metadata track."),NT(a,b))}else a.g.warn("The clpp.ttml.TextParser class is not available. Please register the ttml component first.");
2
+ else a.g.warn("A video element is not available. Skipping.")},LT=function(a,b){b=b.track;b.kind===_.Ae&&(a.g.info("The metadata track has been added."),b.mode=_.ce,a.a.on(b,_.Bd,c=>OT(a,c)))},MT=function(a){return a.some(b=>b.kind===_.Ae)},NT=function(a,b){const c=a.m.getTrackManager(),d=c.ra(),e=c.getAudioTracks().find(g=>g!==d);if(e){var f=()=>c.Aa(d);a.a.on(b.textTracks,_.oc,g=>{g.track.kind===_.Ae&&(a.a.off(b.textTracks,_.oc,f),c.Aa(d))});c.Aa(e)}else a.g.warn("Can't enforce the creation of the metadata track if single audio track. Skipping.")},
3
+ OT=function(a,b){const c=PT(a);c&&Array.from(b.target.activeCues||[]).forEach(d=>{if(d!==a.f&&Number.isFinite(d.startTime)&&Number.isFinite(d.endTime)&&"org.id3"===d.type&&d.value&&"TXXX"===d.value.key){var e=new QT(d);if(e.f===c&&null!==e.a){a.f=d;d=a.h.parseMedia(_.ri(e.a),{periodStart:a.j,segmentStart:e.startTime,segmentEnd:e.endTime});const f=a.m.getTextDisplayer();f.remove(0,e.startTime);f.append(d.cues,d.styles)}}})},PT=function(a){return(a=a.m.getTrackManager().va())&&a.language&&a.language.toLowerCase()},
4
+ QT=class{constructor(a){this.startTime=a.startTime;this.endTime=a.endTime;this.a=this.f=null;a=a.value;if(!_.z(a)){a:{var b=a.info;if(_.jh(b)&&(b=b.toLowerCase().match(/lang:(\w+)/))&&b[1]){b=b[1].toLowerCase();break a}b=null}this.f=b;a=a.data;this.a=a=_.jh(a)?a:null}}};var RT=class{constructor(a,b,c){this.m=a;this.l=b;this.j=c;this.a=new _.Lt;this.h=(a=_.vt(_.Bc))?new a(this.m.getConfiguration()):null;this.g=new _.T("clpp.hlssmpte.ImageCueHandler");this.f=null;KT(this)}destroy(){this.a.release();this.f=null;return Promise.resolve()}};var ST=class extends _.Pv{constructor(){super();this.a=null;this.f=!1}onPlayerCreated(){}onContentWillLoad(a){if(this.f=_.Yi()){var b=a.getConfiguration();b=_.dh(b.hlssmpte||{});typeof b.patchMetadataTrack!==_.Nc&&(b.patchMetadataTrack=!1);_.kh(b.timestampOffset)||(b.timestampOffset=0);this.a=new RT(a,b.patchMetadataTrack,b.timestampOffset)}}onPlayerWillDestroy(){const a=this;return _.w(function*(){a.a&&(yield a.a.destroy(),a.a=null)})}id(){return"hlssmpte"}};_.x("clpp.hlssmpte.HlsSmptePlugin",ST);
5
+ ST.Id="hlssmpte";_.Pn(new class{create(){return new ST}});};f.call(g, window);