@castlabs/prestoplay 6.25.2 → 6.26.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 (68) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +5 -5
  3. package/cjs/cl.adobe.js +3 -3
  4. package/cjs/cl.airplay.js +3 -3
  5. package/cjs/cl.broadpeak.js +7 -7
  6. package/cjs/cl.cast.js +112 -112
  7. package/cjs/cl.conviva.js +32 -32
  8. package/cjs/cl.core.js +601 -600
  9. package/cjs/cl.crypto.js +9 -9
  10. package/cjs/cl.dash.js +89 -88
  11. package/cjs/cl.externs.js +37 -31
  12. package/cjs/cl.freewheel.js +24 -24
  13. package/cjs/cl.hls.js +77 -77
  14. package/cjs/cl.hlssmpte.js +6 -6
  15. package/cjs/cl.htmlcue.js +30 -30
  16. package/cjs/cl.ima.js +23 -23
  17. package/cjs/cl.mediatailor.js +3 -3
  18. package/cjs/cl.mse.js +341 -334
  19. package/cjs/cl.muxdata.js +15 -15
  20. package/cjs/cl.onboard.js +3 -3
  21. package/cjs/cl.persistent.js +14 -14
  22. package/cjs/cl.playlist.js +6 -6
  23. package/cjs/cl.sessions.js +16 -16
  24. package/cjs/cl.simid.js +17 -17
  25. package/cjs/cl.smooth.js +72 -72
  26. package/cjs/cl.thumbnails.js +26 -26
  27. package/cjs/cl.tizen.js +71 -71
  28. package/cjs/cl.ttml.js +29 -29
  29. package/cjs/cl.verimatrix.js +5 -5
  30. package/cjs/cl.vimond.js +12 -12
  31. package/cjs/cl.vr.js +19 -19
  32. package/cjs/cl.vtt.js +14 -14
  33. package/cjs/cl.yospace.js +4 -4
  34. package/cjs/cl.youbora.js +38 -36
  35. package/cl.adobe.js +3 -3
  36. package/cl.airplay.js +3 -3
  37. package/cl.broadpeak.js +5 -5
  38. package/cl.cast.js +87 -87
  39. package/cl.conviva.js +27 -27
  40. package/cl.core.js +489 -488
  41. package/cl.crypto.js +9 -9
  42. package/cl.dash.js +82 -82
  43. package/cl.externs.js +37 -31
  44. package/cl.freewheel.js +19 -19
  45. package/cl.hls.js +79 -80
  46. package/cl.hlssmpte.js +5 -5
  47. package/cl.htmlcue.js +26 -26
  48. package/cl.ima.js +17 -17
  49. package/cl.mediatailor.js +3 -3
  50. package/cl.mse.js +299 -292
  51. package/cl.muxdata.js +13 -13
  52. package/cl.onboard.js +4 -4
  53. package/cl.persistent.js +10 -10
  54. package/cl.playlist.js +5 -5
  55. package/cl.sessions.js +10 -10
  56. package/cl.simid.js +14 -14
  57. package/cl.smooth.js +60 -60
  58. package/cl.thumbnails.js +19 -19
  59. package/cl.tizen.js +57 -57
  60. package/cl.ttml.js +22 -22
  61. package/cl.verimatrix.js +4 -4
  62. package/cl.vimond.js +8 -8
  63. package/cl.vr.js +14 -14
  64. package/cl.vtt.js +12 -12
  65. package/cl.yospace.js +3 -3
  66. package/cl.youbora.js +28 -27
  67. package/package.json +3 -3
  68. package/typings.d.ts +41 -3
package/cl.freewheel.js CHANGED
@@ -1,19 +1,19 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var NU="clpp-freewheel",OU="clpp.freewheel.AdsManagerFactory",PU="freewheel",QU=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""}},RU=function(a){const b=[];typeof a.networkId!==_.t&&b.push("networkId");typeof a.serverUrl!==_.Nf&&b.push("serverUrl");typeof a.profileId!==_.Nf&&b.push("profileId");typeof a.videoAssetId!==_.Nf&&typeof a.videoAssetId!==_.t&&b.push("videoAssetId");
2
- if(b.length)throw new _.I(1,9,12001,{missingKeys:b.join(", ")});},SU=function(){return _.x(function*(){var a=new _.Hv;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})},TU=function(a){a.j.on(a.a,tv.freewheel.SDK.EVENT_REQUEST_COMPLETE,a.K.bind(a));a.j.on(a.a,tv.freewheel.SDK.EVENT_SLOT_STARTED,a.M.bind(a));a.j.on(a.a,
3
- tv.freewheel.SDK.EVENT_SLOT_ENDED,a.L.bind(a));a.j.on(a.a,tv.freewheel.SDK.EVENT_AD,a.J.bind(a));a.j.on(a.m,_.Zf,a.I.bind(a));a.j.on(a.m,_.Kf,a.H.bind(a))},WU=function(a){return _.x(function*(){a.G.length?(UU(a),a.f=a.G.shift(),a.f.play()):(VU(a),yield a.m.a.play())})},VU=function(a){const b=a.m.jd(PU).Pc();b&&a.m.getSurface().hide(b);a.m.getSurface().showMediaElement()},UU=function(a){const b=a.m.jd(PU).Pc();b&&(a.m.getSurface().show(b),a.m.getSurface().hideMediaElement(),a.a.registerVideoDisplayBase(NU),
4
- a.m.isMuted()?a.setVolume(0):a.setVolume(a.m.getVolume()||1))},XU=function(a){a.F.length?(UU(a),a.f=a.F.shift(),a.f.play()):VU(a)},YU=function(a,b,c){var d=null;a.a&&c&&(c.adInstance||c.slot)&&(c=(d=c.adInstance||null)?d.getSlot():c.slot,d={ad:new Y(a.a,c,d)});a.m.trigger(new _.F(b,d))},ZU=class extends _.Pv{constructor(){super();this.f=this.a=null}onPlayerCreated(a){if(window.tv&&tv.freewheel&&tv.freewheel.SDK)this.a=_.op(_.Cd,{id:NU}),this.f=_.op(_.w,{"class":_.Yc}),this.a.appendChild(this.f),a.getSurface().addElementToContainer(this.a,
5
- !0),a.getSurface().hide(this.a);else a.onError(new _.I(1,9,12E3))}onPlayerWillDestroy(a){this.a&&(a.getSurface().removeElementFromContainer(this.a),this.f=this.a=null)}id(){return PU}Pc(){return this.a}wh(){return this.f}};_.z("clpp.freewheel.FreeWheelPlugin",ZU);ZU.prototype.getAdVideo=ZU.prototype.wh;ZU.prototype.getAdContainer=ZU.prototype.Pc;ZU.Id=PU;ZU.AD_CONTAINER_ID=NU;_.Ir(new class{create(){return new ZU}});var Y=class{constructor(a,b,c){this.h=a;this.f=b;this.a=c}ob(){return"FreeWheel AdManager SDK"}pb(){return tv.freewheel.SDK.version}ub(){return 0}getId(){return this.a?this.a.getAdId():""}getCreativeId(){const a=(this.a||{})._creativeId;return typeof a===_.Nf?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}Tb(){return!1}qb(){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():""}fb(){return this.a?this.a.getActiveCreativeRendition().getWidth():0}eb(){return this.a?this.a.getActiveCreativeRendition().getHeight():0}Oa(){return 0}Pa(){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.Pa()){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.Pa()){case 0:return 0;case 2:return-1;default:return this.f.getTimePosition()}}sb(){return this.a?this.f.getAdInstances().indexOf(this.a)+1:1}gb(){return this.f.getAdCount()}getWrapperAdIds(){return[]}canSeek(){return!1}getWrapperAdSystems(){return[]}getWrapperCreativeIds(){return[]}Sb(){return null}};
8
- Y.prototype.getVideoElement=Y.prototype.Sb;Y.prototype.getWrapperCreativeIds=Y.prototype.getWrapperCreativeIds;Y.prototype.getWrapperAdSystems=Y.prototype.getWrapperAdSystems;Y.prototype.canSeek=Y.prototype.canSeek;Y.prototype.getWrapperAdIds=Y.prototype.getWrapperAdIds;Y.prototype.getSequenceLength=Y.prototype.gb;Y.prototype.getPositionInSequence=Y.prototype.sb;Y.prototype.getPodTimeOffset=Y.prototype.Hb;Y.prototype.getPodIndex=Y.prototype.getPodIndex;Y.prototype.getPodType=Y.prototype.Pa;
9
- Y.prototype.getMediaBitrate=Y.prototype.Oa;Y.prototype.getMediaHeight=Y.prototype.eb;Y.prototype.getMediaWidth=Y.prototype.fb;Y.prototype.getMediaUrl=Y.prototype.getMediaUrl;Y.prototype.getClickThroughUrl=Y.prototype.qb;Y.prototype.isBumper=Y.prototype.Tb;Y.prototype.getSkipTimeOffset=Y.prototype.getSkipTimeOffset;Y.prototype.getPosition=Y.prototype.getPosition;Y.prototype.getDuration=Y.prototype.getDuration;Y.prototype.getTitle=Y.prototype.getTitle;Y.prototype.getAdvertiserName=Y.prototype.getAdvertiserName;
10
- Y.prototype.getAdSystem=Y.prototype.getAdSystem;Y.prototype.getApiFramework=Y.prototype.getApiFramework;Y.prototype.getSourceId=Y.prototype.Qb;Y.prototype.getCreativeId=Y.prototype.getCreativeId;Y.prototype.getId=Y.prototype.getId;Y.prototype.getTechnology=Y.prototype.ub;Y.prototype.getAdManagerVersion=Y.prototype.pb;Y.prototype.getAdManagerName=Y.prototype.ob;var $U=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()}})}Kb(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL).length}Jb(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL).length}};
11
- $U.prototype.hasPostroll=$U.prototype.Jb;$U.prototype.hasPreroll=$U.prototype.Kb;$U.prototype.getCuePoints=$U.prototype.getCuePoints;var aV=class{constructor(a){this.g=new _.S("clpp.freewheel.AdsManager");this.m=a;this.j=new _.Nt;this.C=new tv.freewheel.SDK.AdManager;this.f=this.a=null;this.G=[];this.B=[];this.F=[];this.A=new _.bn;this.w=null}load(){const a=this;return _.x(function*(){const b=a.m.getConfiguration().freewheel||{};try{RU(b)}catch(d){return a.m.onError(d),a.A.resolve(),a.A}a.C.setNetwork(b.networkId);a.C.setServer(b.serverUrl);a.a=a.C.newContext();a.a.setProfile(b.profileId);typeof b.siteSectionId!==_.Nf&&typeof b.siteSectionId!==
12
- _.t||a.a.setSiteSection(b.siteSectionId);const c=yield SU();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,QU(d.type),d.position,d.slotProfile,d.cuepointSequence,d.maxDuration,d.minDuration,d.acceptContentType);b.keyValues&&typeof b.keyValues===_.Ce&&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);TU(a);a.a.submitRequest();return a.A})}start(){const a=this;return _.x(function*(){yield WU(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}h(){const a=this;return _.x(function*(){a.j.release();
14
- a.w&&(a.w.stop(),a.w=null);VU(a);a.a&&(a.a.dispose(),a.a=null)})}K(a){if(a.success)this.G=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL),this.B=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL),this.F=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL),this.m.trigger(new _.F(_.oc,{adsTimeline:new $U(this.a)})),this.w=new _.Fv(this.m.getSurface(),(b,c)=>this.a.resize(b,c),this.m.jd(PU).f);else this.m.onError(new _.I(1,
15
- 9,10003,{errorType:0},void 0));this.A.resolve()}M(a){YU(this,_.Rb,a);this.w.start()}L(a){this.f=null;a=a.slot;YU(this,_.Sb);this.w.stop();if(a)switch(a.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:WU(this);break;case tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL:VU(this);this.m.play();break;case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:XU(this)}}J(a){const b=a.subType;this.g.debug("ad event",b);switch(b){case tv.freewheel.SDK.EVENT_AD_IMPRESSION:YU(this,_.jc,a);YU(this,
16
- _.$b,a);break;case tv.freewheel.SDK.EVENT_AD_IMPRESSION_END:YU(this,_.lc,a);break;case tv.freewheel.SDK.EVENT_AD_FIRST_QUARTILE:YU(this,_.Wb,a);break;case tv.freewheel.SDK.EVENT_AD_MIDPOINT:YU(this,_.bc,a);break;case tv.freewheel.SDK.EVENT_AD_THIRD_QUARTILE:YU(this,_.mc,a);break;case tv.freewheel.SDK.EVENT_AD_COMPLETE:YU(this,_.Vb,a);break;case tv.freewheel.SDK.EVENT_AD_CLICK:YU(this,_.Ub,a);break;case tv.freewheel.SDK.EVENT_AD_PAUSE:YU(this,_.cc,a);break;case tv.freewheel.SDK.EVENT_AD_RESUME:YU(this,
17
- _.ec,a);break;case tv.freewheel.SDK.EVENT_AD_SKIPPED:YU(this,_.fc,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_START:YU(this,_.Tb,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_END:YU(this,_.dc,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]}))}}I(){if(!this.f){var a=this.m.getPosition();if(this.f=this.B.find(b=>
18
- .5>Math.abs(a-b.getTimePosition()))||null){const b=this.B.findIndex(c=>c===this.f);this.B.splice(b,1);this.m.pause();UU(this);this.f.play()}}}H(a){if((a=a.detail)&&this.a)switch(a.currentState){case _.Wo:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PLAYING);break;case _.Vo:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PAUSED);break;case _.Lo:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_COMPLETED);XU(this);break;case _.To:case _.Mo:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_STOPPED)}}};
19
- aV.prototype.getPosition=aV.prototype.getPosition;aV.prototype.setVolume=aV.prototype.setVolume;aV.prototype.getVolume=aV.prototype.getVolume;aV.prototype.skip=aV.prototype.skip;aV.prototype.pause=aV.prototype.pause;aV.prototype.resume=aV.prototype.resume;_.mp(new class{constructor(){this.Ra=new _.S(OU)}name(){return OU}a(a,b){return a.namespace()!==_.dd&&b&&b.freewheel?window.tv&&tv.freewheel&&tv.freewheel.SDK?!0:(this.Ra.warn("FreeWheel SDK is not loaded."),!1):!1}create(a){return new aV(a)}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var aV="clpp-freewheel",bV="clpp.freewheel.AdsManagerFactory",cV="freewheel",dV=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""}},eV=function(a){const b=[];typeof a.networkId!==_.t&&b.push("networkId");typeof a.serverUrl!==_.Pf&&b.push("serverUrl");typeof a.profileId!==_.Pf&&b.push("profileId");typeof a.videoAssetId!==_.Pf&&typeof a.videoAssetId!==_.t&&b.push("videoAssetId");
2
+ if(b.length)throw new _.I(1,9,12001,{missingKeys:b.join(", ")});},fV=function(){return _.x(function*(){var a=new _.Kv;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})},gV=function(a){a.j.on(a.a,tv.freewheel.SDK.EVENT_REQUEST_COMPLETE,a.K.bind(a));a.j.on(a.a,tv.freewheel.SDK.EVENT_SLOT_STARTED,a.M.bind(a));a.j.on(a.a,
3
+ tv.freewheel.SDK.EVENT_SLOT_ENDED,a.L.bind(a));a.j.on(a.a,tv.freewheel.SDK.EVENT_AD,a.J.bind(a));a.j.on(a.m,_.ag,a.I.bind(a));a.j.on(a.m,_.Mf,a.H.bind(a))},jV=function(a){return _.x(function*(){a.G.length?(hV(a),a.f=a.G.shift(),a.f.play()):(iV(a),yield a.m.a.play())})},iV=function(a){const b=a.m.kd(cV).Pc();b&&a.m.getSurface().hide(b);a.m.getSurface().showMediaElement()},hV=function(a){const b=a.m.kd(cV).Pc();b&&(a.m.getSurface().show(b),a.m.getSurface().hideMediaElement(),a.a.registerVideoDisplayBase(aV),
4
+ a.m.isMuted()?a.setVolume(0):a.setVolume(a.m.getVolume()||1))},kV=function(a){a.F.length?(hV(a),a.f=a.F.shift(),a.f.play()):iV(a)},lV=function(a,b,c){var d=null;a.a&&c&&(c.adInstance||c.slot)&&(c=(d=c.adInstance||null)?d.getSlot():c.slot,d={ad:new Y(a.a,c,d)});a.m.trigger(new _.F(b,d))},mV=class extends _.Sv{constructor(){super();this.f=this.a=null}onPlayerCreated(a){if(window.tv&&tv.freewheel&&tv.freewheel.SDK)this.a=_.rp(_.Cd,{id:aV}),this.f=_.rp(_.w,{"class":_.Zc}),this.a.appendChild(this.f),a.getSurface().addElementToContainer(this.a,
5
+ !0),a.getSurface().hide(this.a);else a.onError(new _.I(1,9,12E3))}onPlayerWillDestroy(a){this.a&&(a.getSurface().removeElementFromContainer(this.a),this.f=this.a=null)}id(){return cV}Pc(){return this.a}xh(){return this.f}};_.z("clpp.freewheel.FreeWheelPlugin",mV);mV.prototype.getAdVideo=mV.prototype.xh;mV.prototype.getAdContainer=mV.prototype.Pc;mV.Id=cV;mV.AD_CONTAINER_ID=aV;_.Mr(new class{create(){return new mV}});var Y=class{constructor(a,b,c){this.h=a;this.f=b;this.a=c}ob(){return"FreeWheel AdManager SDK"}pb(){return tv.freewheel.SDK.version}ub(){return 0}getId(){return this.a?this.a.getAdId():""}getCreativeId(){const a=(this.a||{})._creativeId;return typeof a===_.Pf?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}Tb(){return!1}qb(){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():""}fb(){return this.a?this.a.getActiveCreativeRendition().getWidth():0}eb(){return this.a?this.a.getActiveCreativeRendition().getHeight():0}Qa(){return 0}Ra(){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.Ra()){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.Ra()){case 0:return 0;case 2:return-1;default:return this.f.getTimePosition()}}sb(){return this.a?this.f.getAdInstances().indexOf(this.a)+1:1}gb(){return this.f.getAdCount()}getWrapperAdIds(){return[]}canSeek(){return!1}getWrapperAdSystems(){return[]}getWrapperCreativeIds(){return[]}Sb(){return null}};
8
+ Y.prototype.getVideoElement=Y.prototype.Sb;Y.prototype.getWrapperCreativeIds=Y.prototype.getWrapperCreativeIds;Y.prototype.getWrapperAdSystems=Y.prototype.getWrapperAdSystems;Y.prototype.canSeek=Y.prototype.canSeek;Y.prototype.getWrapperAdIds=Y.prototype.getWrapperAdIds;Y.prototype.getSequenceLength=Y.prototype.gb;Y.prototype.getPositionInSequence=Y.prototype.sb;Y.prototype.getPodTimeOffset=Y.prototype.Hb;Y.prototype.getPodIndex=Y.prototype.getPodIndex;Y.prototype.getPodType=Y.prototype.Ra;
9
+ Y.prototype.getMediaBitrate=Y.prototype.Qa;Y.prototype.getMediaHeight=Y.prototype.eb;Y.prototype.getMediaWidth=Y.prototype.fb;Y.prototype.getMediaUrl=Y.prototype.getMediaUrl;Y.prototype.getClickThroughUrl=Y.prototype.qb;Y.prototype.isBumper=Y.prototype.Tb;Y.prototype.getSkipTimeOffset=Y.prototype.getSkipTimeOffset;Y.prototype.getPosition=Y.prototype.getPosition;Y.prototype.getDuration=Y.prototype.getDuration;Y.prototype.getTitle=Y.prototype.getTitle;Y.prototype.getAdvertiserName=Y.prototype.getAdvertiserName;
10
+ Y.prototype.getAdSystem=Y.prototype.getAdSystem;Y.prototype.getApiFramework=Y.prototype.getApiFramework;Y.prototype.getSourceId=Y.prototype.Qb;Y.prototype.getCreativeId=Y.prototype.getCreativeId;Y.prototype.getId=Y.prototype.getId;Y.prototype.getTechnology=Y.prototype.ub;Y.prototype.getAdManagerVersion=Y.prototype.pb;Y.prototype.getAdManagerName=Y.prototype.ob;var nV=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()}})}Kb(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL).length}Jb(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL).length}};
11
+ nV.prototype.hasPostroll=nV.prototype.Jb;nV.prototype.hasPreroll=nV.prototype.Kb;nV.prototype.getCuePoints=nV.prototype.getCuePoints;var oV=class{constructor(a){this.g=new _.T("clpp.freewheel.AdsManager");this.m=a;this.j=new _.Rt;this.C=new tv.freewheel.SDK.AdManager;this.f=this.a=null;this.G=[];this.B=[];this.F=[];this.A=new _.Ij;this.w=null}load(){const a=this;return _.x(function*(){const b=a.m.getConfiguration().freewheel||{};try{eV(b)}catch(d){return a.m.onError(d),a.A.resolve(),a.A}a.C.setNetwork(b.networkId);a.C.setServer(b.serverUrl);a.a=a.C.newContext();a.a.setProfile(b.profileId);typeof b.siteSectionId!==_.Pf&&typeof b.siteSectionId!==
12
+ _.t||a.a.setSiteSection(b.siteSectionId);const c=yield fV();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,dV(d.type),d.position,d.slotProfile,d.cuepointSequence,d.maxDuration,d.minDuration,d.acceptContentType);b.keyValues&&typeof b.keyValues===_.Ee&&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);gV(a);a.a.submitRequest();return a.A})}start(){const a=this;return _.x(function*(){yield jV(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}h(){const a=this;return _.x(function*(){a.j.release();
14
+ a.w&&(a.w.stop(),a.w=null);iV(a);a.a&&(a.a.dispose(),a.a=null)})}K(a){if(a.success)this.G=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL),this.B=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL),this.F=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL),this.m.trigger(new _.F(_.pc,{adsTimeline:new nV(this.a)})),this.w=new _.Iv(this.m.getSurface(),(b,c)=>this.a.resize(b,c),this.m.kd(cV).f);else this.m.onError(new _.I(1,
15
+ 9,10003,{errorType:0},void 0));this.A.resolve()}M(a){lV(this,_.Sb,a);this.w.start()}L(a){this.f=null;a=a.slot;lV(this,_.Tb);this.w.stop();if(a)switch(a.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:jV(this);break;case tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL:iV(this);this.m.play();break;case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:kV(this)}}J(a){const b=a.subType;this.g.debug("ad event",b);switch(b){case tv.freewheel.SDK.EVENT_AD_IMPRESSION:lV(this,_.hc,a);lV(this,
16
+ _.ac,a);break;case tv.freewheel.SDK.EVENT_AD_IMPRESSION_END:lV(this,_.lc,a);break;case tv.freewheel.SDK.EVENT_AD_FIRST_QUARTILE:lV(this,_.Xb,a);break;case tv.freewheel.SDK.EVENT_AD_MIDPOINT:lV(this,_.cc,a);break;case tv.freewheel.SDK.EVENT_AD_THIRD_QUARTILE:lV(this,_.nc,a);break;case tv.freewheel.SDK.EVENT_AD_COMPLETE:lV(this,_.Wb,a);break;case tv.freewheel.SDK.EVENT_AD_CLICK:lV(this,_.Vb,a);break;case tv.freewheel.SDK.EVENT_AD_PAUSE:lV(this,_.dc,a);break;case tv.freewheel.SDK.EVENT_AD_RESUME:lV(this,
17
+ _.fc,a);break;case tv.freewheel.SDK.EVENT_AD_SKIPPED:lV(this,_.gc,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_START:lV(this,_.Ub,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_END:lV(this,_.ec,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]}))}}I(){if(!this.f){var a=this.m.getPosition();if(this.f=this.B.find(b=>
18
+ .5>Math.abs(a-b.getTimePosition()))||null){const b=this.B.findIndex(c=>c===this.f);this.B.splice(b,1);this.m.pause();hV(this);this.f.play()}}}H(a){if((a=a.detail)&&this.a)switch(a.currentState){case _.Zo:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PLAYING);break;case _.Yo:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PAUSED);break;case _.Oo:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_COMPLETED);kV(this);break;case _.Wo:case _.Po:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_STOPPED)}}};
19
+ oV.prototype.getPosition=oV.prototype.getPosition;oV.prototype.setVolume=oV.prototype.setVolume;oV.prototype.getVolume=oV.prototype.getVolume;oV.prototype.skip=oV.prototype.skip;oV.prototype.pause=oV.prototype.pause;oV.prototype.resume=oV.prototype.resume;_.pp(new class{constructor(){this.Ta=new _.T(bV)}name(){return bV}a(a,b){return a.namespace()!==_.dd&&b&&b.freewheel?window.tv&&tv.freewheel&&tv.freewheel.SDK?!0:(this.Ta.warn("FreeWheel SDK is not loaded."),!1):!1}create(a){return new oV(a)}});};f.call(g, window);
package/cl.hls.js CHANGED
@@ -1,80 +1,79 @@
1
- import {clpp} from "./cl.core.js";import './cl.mse.js';let g={};const _ = clpp._;var f=function(window){'use strict';var EJ="CLOSED-CAPTIONS",FJ="Could not parse MP4 segment start time.",GJ="DURATION",HJ="EXT-X-DATERANGE",IJ="EXT-X-DISCONTINUITY",JJ="EXT-X-KEY",KJ="EXT-X-MAP",LJ="EXT-X-MEDIA",MJ="EXT-X-MEDIA-SEQUENCE",NJ="EXT-X-STREAM-INF",OJ="Failed to infer discontinuity number",PJ="Guessing audio-only",QJ="METHOD",RJ="SAMPLE-AES-CTR",SJ="SUBTITLES",TJ="application/vnd.apple.mpegurl",UJ="manifestloaded",VJ="sample",WJ=function(a,b){return _.J(a,b,void 0,{required:!0})},XJ=function(a){if(1>a.a)throw _.Zl();
2
- --a.a},YJ=function(a,b){for(const c in a){if(!(c in b))return!1;const d=a[c],e=b[c];if(d&&typeof d===_.Ce&&e&&typeof e===_.Ce){if(!YJ(d,e))return!1}else if(void 0!==d&&void 0!==e&&d!==e)return!1}return!0},ZJ=function(a,b){if(!YJ(a,b))return!1;for(const c in b){if(!(c in a))return!0;const d=a[c],e=b[c];if(!d&&e||d&&typeof d===_.Ce&&e&&typeof e===_.Ce&&ZJ(d,e))return!0}return!1},$J=function(a){if(null!==a&&void 0!==a)return Number(a)},aK=function(a,b){return a.filter(c=>c.name===b)},bK=function(a){const b=
3
- /^[a-zA-Z0-9_-]+$/,c=new Set;a.forEach(d=>{const e=_.J(d,"VALUE"),f=_.J(d,_.Sa),g=_.J(d,"IMPORT"),h=_.J(d,"QUERYPARAM");if(1!==[f,g,h].filter(Boolean).length||f&&null==e)throw new _.I(_.G,4,4044,{message:"Invalid tag.",text:d.toString()});d=f||g||h;if(c.has(d))throw new _.I(_.G,4,4044,`EXT-X-DEFINE redefined variable "${d}".`);if(!b.test(d))throw new _.I(_.G,4,4044,`EXT-X-DEFINE invalid variable name "${d}".`);c.add(d)})},cK=function(a,b){const c=Array.isArray(b)?b:[b];return a.filter(d=>{d=WJ(d,
4
- _.rb);return c.includes(d)})},dK=function(a,b){return a.some(c=>c.name===b)},eK=function(a,b,c){c=void 0===c?{}:c;a=a.find(d=>d.name===b)||null;if(!a&&c.required)throw new _.I(_.G,4,4024,{missingTag:b});return a},fK=function(a){var b=eK(a,"EXT-X-TILES");if(!b)return{ld:1,Fd:1,durationPerTile:null};a=_.J(b,"LAYOUT")||"1x1";b=_.J(b,GJ);a=_.uC(a);return{ld:a.ld,Fd:a.Fd,durationPerTile:b?Number(b):null}},gK=function(a,b){var c=void 0===c?!0:c;a=new _.mi(a);b=new _.mi(b);b=a.resolve(b).toString();return c?
5
- b:decodeURI(b)},hK=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)},iK=function(a,b){Array.isArray(a)||(a=[a]);a.forEach(c=>{for(const d of hK(c))b(d,c)})},jK=function(a){return a.some(b=>dK(b.ha,"EXT-X-ENDLIST"))},kK=function(a){return a.type===_.p||a.type===_.w},lK=function(a){if(eK(a,"EXT-X-ENDLIST"))return _.Cb;a=eK(a,"EXT-X-PLAYLIST-TYPE");if(!a)return"LIVE";
6
- if(a.value===_.Cb)return _.Cb;if("EVENT"===a.value)return"EVENT";throw new _.I(_.G,4,4044,`Invalid EXT-X-PLAYLIST-TYPE value: ${a.value}`);},mK=function(a){a={AUDIO:_.p,VIDEO:_.w,SUBTITLES:_.H,"CLOSED-CAPTIONS":_.H}[a.toUpperCase()];if(!a)throw new _.I(_.G,4,4044,"EXT-X-MEDIA tag has an invalid TYPE attribute.");return a},nK=function(a,b,c){c=void 0===c?!1:c;var d=0;let e=null;if(a){d=a.split("@");a=Number(d[0]);if(0>=a)throw new _.I(_.G,4,4044,"Byte range length must be positive.");if(d[1]){if(d=
7
- Number(d[1]),0>d)throw new _.I(_.G,4,4044,"Byte range start byte must not be negative.");}else{if(c)throw new _.I(_.G,4,4044,"Invalid byte range, offset is required but missing.");if(null==b)throw new _.I(_.G,4,4044,"Invalid byte range, cannot calculate offset based on previous byte ranges.");d=b+1}e=d+a-1}return{ya:d,pa:e}},oK=function(a,b){a=eK(a,"EXT-X-BYTERANGE");return nK(a?a.value:null,b)},pK=function(a){a=eK(a,"EXTINF",{required:!0}).value.split(",");return{duration:Number(a[0]),title:a[1]||
8
- null}},qK=function(a,b){b=void 0===b?{}:b;const c={Kf:!1,fh:!1,gh:null,Mh:null,tg:null};a=eK(a,"EXT-X-SERVER-CONTROL",{required:b.zg});if(!a)return c;const d=e=>null==e?null:Number(e);c.Kf="YES"===_.J(a,"CAN-BLOCK-RELOAD");c.fh="YES"===_.J(a,"CAN-SKIP-DATERANGES");c.gh=d(_.J(a,"CAN-SKIP-UNTIL"));c.Mh=d(_.J(a,"HOLD-BACK"));c.tg=d(_.J(a,"PART-HOLD-BACK",void 0,{required:b.zg}));return c},rK=function(a,b,c){c=void 0===c?!1:c;a=_.J(a,"BYTERANGE");return nK(a,b,c)},sK=function(a){const b=aK(a,LJ),c=aK(a,
9
- NJ);a=aK(a,"EXT-X-IMAGE-STREAM-INF");return{Bc:{Ff:cK(b,[_.rB,_.Bb]),closedCaptions:cK(b,EJ),Fi:cK(b,SJ)},Gd:c,Fe:a}},uK=function(a,b){const c=oK(a.ha,null);return new tK(0,0,0,()=>[a.a],c.ya,c.pa,0,b)},vK=function(a){let b=Infinity,c=Infinity;hK(a).filter(kK).forEach(d=>{{d=d.U;var e=d[0].startTime;const f=d[d.length-1].endTime;d=e;e=f-e}b=Math.min(b,d);c=Math.min(c,e)});return{Uc:b,duration:c}},wK=function(a){return a.map(b=>{({duration:b}=vK(b));return b}).reduce((b,c)=>b+c,0)},xK=function(a){return(a.video?
10
- a.video.Da:"")+" - "+(a.audio?a.audio.Da:"")},yK=function(a,b,c,d,e){if(b===_.Cb)return{delay:0,Ed:0};b=eK(a,"EXT-X-PART-INF");if(c&&b){e=Number(WJ(b,"PART-TARGET"));if(null!=d)return{delay:d,Ed:e};({tg:d}=qK(a,{zg:!0}));return{delay:d,Ed:e}}a=eK(a,"EXT-X-TARGETDURATION",{required:!0});a=Number(a.value);e=e||a;return null!=d?{delay:d,Ed:e}:{delay:3*a,Ed:e}},AK=function(a){const b=new Map;a.forEach(c=>{var d=`${zK(c).type}:${zK(c).groupId}`;b.has(d)?(d=b.get(d),d.includes(c)||d.push(c)):b.set(d,[c])});
11
- return b},BK=function(a){const b=new Map;for(const c of a){a=_.J(c,_.Ka);a=_.Bi(a||_.dg);const d=WJ(c,_.Ea),e=WJ(c,"INSTREAM-ID");b.has(d)||b.set(d,new Map);b.get(d).set(e,a)}return b},CK=function(a){return a.filter(b=>"mp4a.40.34"!==b)},DK=function(a,b){if(!a)return null;const c=a.Da;return b.find(d=>zK(d).Da===c)||null},EK=function(a){return(a=_.J(a,"CHANNELS"))?parseInt(a.split("/")[0],10):null},FK=function(a){return a.some(b=>b.startsWith("#EXT-X-TARGETDURATION"))?1:0},GK=function(a,b){const c=
12
- new Map,d=new URL(b);a.forEach(e=>{var f=_.J(e,_.Sa),g=_.J(e,"QUERYPARAM");if(f)g=WJ(e,"VALUE"),c.set(f,g);else if(g){f=d.searchParams.get(g);if(null==f)throw new _.I(_.G,4,4044,`Query param '${g}' missing in playlist URI.`);if(!f)throw new _.I(_.G,4,4044,`Query param '${g}' has no associated value`+" in playlist URI.");c.set(g,decodeURIComponent(f))}});return c},HK=function(a,b){return a.replace(/\{\$([a-zA-Z0-9_-]+)\}/g,(c,d)=>{c=b.get(d);if(null==c)throw new _.I(_.G,4,4044,`Undefined variable '${d}'`);
13
- return c})},IK=function(a,b){a.forEach(c=>{c.attributes.forEach(d=>{d.value=HK(d.value,b)})})},LK=function(a,b,c){const d=[];for(let e=0;e<b.length;e++){const f=JK(a,b[e]);d.push(f);if(f.name===NJ){const g=b[e+1];if(!g)throw new _.I(_.G,4,4044,"EXT-X-STREAM-INF is not followed by a URI.");f.attributes.push(new _.Gi(_.tb,g));e++}}b=aK(d,"EXT-X-DEFINE");bK(b);b=GK(b,c);a.a=b;IK(d,a.a);return new KK(c,0,d)},PK=function(a,b,c){const {si:d,Jh:e,Oi:f}=MK(b),g=NK(a,f,c);b=e.map(k=>JK(a,k,g));const h=OK(a,
14
- c,d,g);return new KK(c,1,b,h)},QK=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(_.G,4,4015);b=b.slice(1);return 0===FK(b)?LK(a,b,c):PK(a,b,c)},MK=function(a){const b=[],c=[],d=[];for(const e of a)RK.test(e)?d.push(e):SK.test(e)?c.push(e):b.push(e);return{si:b,Jh:c,Oi:d}},NK=function(a,b,c){b=b.map(e=>JK(a,e));bK(b);const d=GK(b,c);b.map(e=>_.J(e,"IMPORT")).filter(Boolean).forEach(e=>{const f=
15
- a.a.get(e);if(null==f)throw new _.I(_.G,4,4044,`Cannot import variable '${e}' as it is not defined `+"in the master playlist");d.set(e,f)});return d},JK=function(a,b,c){a=_.Ii(a.h++,b);c&&IK([a],c);return a},OK=function(a,b,c,d){const e=[];let f=[],g=[];c.forEach(h=>{/^(#EXT)/.test(h)?(h=JK(a,h,d),"EXT-X-PART"===h.name||"EXT-X-PRELOAD-HINT"===h.name&&"PART"===_.J(h,_.rb)?g.push(h):f.push(h)):(dK(f,"EXT-X-GAP")||(h=HK(h,d),h=gK(b,h),e.push(new TK(h,f,g))),f=[],g=[])});0<g.length&&e.push(new TK(null,
16
- f,g));return e},UK=function(a,b,c){const d=[],e=[];e.push(new _.Gi(_.la,"0"));e.push(new _.Gi(_.tb,b));c.length&&e.push(new _.Gi(_.oa,c));d.push(new _.Hi(a.h++,NJ,e));return new KK(b,0,d)},VK=function*(a){let b=-1,c=void 0,d=void 0;for(const e of a)0<=b&&(yield{eg:b,item:d,ii:c,next:e}),b++,c=d,d=e;-1!==b&&(yield{eg:b,ii:c,item:d,next:void 0})},WK=function(a){return 0>a?[]:Array.from({length:a},(b,c)=>c)},XK=function(a){return new Uint8Array([a>>24&255,a>>16&255,a>>8&255,a&255])},YK=function(a,b=
17
- 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},ZK=function(a){function b(h,k,l){let m="";for(;k<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(_.G,4,4030);}YK(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"===
18
- 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|a[5]<<14|a[6]<<6|a[7]>>>2,f*=4,f+=a[7]&3,Math.round(f/9E4);break}}YK(a,e)||d();e+=10;e+=f}while(e<a.byteLength);return d()},$K=function(a,b){let c=null,d=0;try{(new _.om).N(_.ye,_.hm).N(_.ag,_.hm).N(_.qe,_.hm).ea("mdhd",g=>{g.reader.skip(0===g.version?8:16);d=_.P(g.reader);g.parser.stop()}).parse(b,!0)}catch(g){c=
19
- g}if(c||!d)throw _.Jv.error("Unable to find timescale in init segment!"),new _.I(_.G,4,4030,FJ,c);let e=0,f=!1;try{(new _.om).N("moof",_.hm).N("traf",_.hm).ea("tfdt",g=>{var h=d;if(0===g.version)h=_.P(g.reader)/h;else{{const k=_.P(g.reader),l=_.P(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(_.G,
20
- 4,4030,FJ,c);return e},aL=function(a){for(;a.getPosition()<a.Na()-1;){const b=a.getPosition();if(71===_.$l(a))return XJ(a),b}return-1},bL=function(a){function b(){d.seek(e+188);f=_.$l(d);71!==f&&(d.seek(e+192),f=_.$l(d));71!==f&&(d.seek(e+204),f=_.$l(d));71!==f&&c();XJ(d)}function c(){throw new _.I(_.G,4,4030);}const d=new _.ln(new DataView(a),!1);let e=0,f=0;e=aL(d);0>e&&(_.Jv.error("Unable to find sync byte in TS after scanning."),c());for(;;){e=d.getPosition();f=_.$l(d);71!==f&&c();a=_.am(d);if(8191===
21
- (a&8191)){b();continue}if(!(a&16384)){b();continue}a=(_.$l(d)&48)>>4;0!==a&&2!==a||c();3===a&&(a=_.$l(d),d.skip(a));if(1!==_.P(d)>>8){b();continue}d.skip(3);a=_.$l(d)>>6;0!==a&&1!==a||c();0===_.$l(d)&&c();a=_.$l(d);const g=_.am(d),h=_.am(d);return(1073741824*((a&14)>>1)+((g&65534)<<14|(h&65534)>>1))/9E4}},eL=function(a){const b=cL(a),c=dL(a);a.forEach(d=>{const e=d.U,f=e.findIndex(h=>h.oa===b);let g=e.findIndex(h=>h.oa===c+1);-1===g&&(g=e.length);d.U=e.slice(f,g)})},dL=function(a){a=a.map(b=>b.U[b.U.length-
22
- 1].oa);return Math.min(...a)},cL=function(a){a=a.map(b=>b.U[0].oa);return Math.max(...a)},hL=function(a){var b=WJ(a,QJ);if(!fL.includes(b))return gL.error("PlayReady in HLS is only supported with [",fL.join(", "),"], not",b),null;a=WJ(a,_.tb);b=_.vt(a);a=null;b=_.K(b.data);try{a=_.cC(_.tn(b))}catch(c){a=b}return _.qC(_.rd,[{initDataType:_.Tc,initData:a}],"")},jL=function(a){if(0===a.length)return iL();if(a.some(c=>"whole-segment"===c.type)||a.every(c=>c.type===_.Be))return a[0];a=a.filter(c=>c.type===
23
- VJ);const b=_.di(a.flatMap(c=>c.drmInfos));return{keyId:a[a.length-1].keyId,type:VJ,drmInfos:b}},mL=function(a,b){return kL(a).map(c=>lL(c.ha,b)).filter(Boolean)},kL=function(a){return a.filter(b=>dK(b.ha,JJ))},lL=function(a,b){a=aK(a,JJ).filter(d=>"AES-128"!==WJ(d,QJ));if(0===a.length)return null;var c=WJ(a[0],QJ);if(1===a.length&&"NONE"===c)return iL();c=a.map(d=>WJ(d,QJ));if(!c.every(d=>"SAMPLE-AES"===d)&&!c.every(d=>d===RJ))throw nL.warn(`EXT-X-KEY methods ${c.join(", ")} are incompatible.`),
24
- new _.I(_.G,4,4044,"Multiple EXT-X-KEY tags with incompatible METHOD values.");a=a.map(d=>{const e=_.J(d,"KEYFORMAT","identity");{const f=oL[e]||null;d=f?f(d,b):null}d||nL.warn("Unsupported HLS KEYFORMAT",e);return d}).filter(Boolean);if(0===a.length)throw new _.I(_.G,4,4026);return{keyId:a.map(d=>d.keyIds).reduce((d,e)=>d.concat(e),[]).reverse()[0]||null,type:VJ,drmInfos:a}},iL=function(){return{type:_.Be,drmInfos:[],keyId:null}},pL=function(a,b,c){a=aK(a,JJ)[0];if(!a||"AES-128"!==WJ(a,QJ))return null;
25
- var d=_.J(a,"IV","");d?c={iv:_.Kl((d||"0x").slice(2)),generatedIv:!1}:(d=_.J(a,"KEYFORMAT"),c=null==d||"identity"===d?{iv:_.Nl(new Uint8Array(12),XK(c)),generatedIv:!0}:{iv:null,generatedIv:!1});const {iv:e,generatedIv:f}=c;return{method:"AES-128",url:gK(b,WJ(a,_.tb)),iv:e,generatedIv:f}},qL=function(a,b,c){return _.x(function*(){const d=b.f(),e=_.YC(b.Ya(),b.ya,b.ya+2048-1,a.a.attemptParameters);e.type=2;const f=_.YC(b.Ya(),b.ya,b.pa,a.a.attemptParameters);f.type=2;d&&(f.keyInfo=d);try{return yield a.f(c?
26
- 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.",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(_.G,4,4030,"Failed to fetch the media segment.");}}})},rL=function(a,b,c,d,e,f){return _.x(function*(){a.g.debug("Fetching segment to find start time");
27
- if("audio/mpeg"===d||d===_.Ec||d===_.Dc)return 0;if(d===_.Ac){var g=yield qL(a,c,f);g=_.K(g.data);if(!YK(g))throw new _.I(_.G,4,4030,"AAC segment does not contain an ID3 tag.");return ZK(g)}if(d===_.pg||d===_.Fc)return g=[qL(a,c,f)],b&&g.push(qL(a,b,!0)),g=yield Promise.all(g),$K(g[0].data,(g[1]||g[0]).data);if(d===_.og)return g=yield qL(a,c,f),bL(g.data);if(!_.Ds(`${d.split("/")[0]||""}/mp4;codecs="${e}"`))return 0;throw new _.I(_.G,4,4030);})},sL=function(a,b){a=a.map(c=>c.streams[b]);return a.some(c=>
28
- null==c)?null:a},tL=function(a,b){a=a.streams.find(c=>{c=c.U;return c[0].position<=b&&b<=c[c.length-1].position});return null==a?null:a.U.find(c=>c.position===b)||null},zK=function(a){return a.streams[0]},uL=function(a,b){a.streams.forEach(c=>{c.re=b})},vL=function(a,b){a.streams.forEach(c=>{c.width=b})},wL=function(a,b){a.streams.forEach(c=>{c.height=b})},xL=function(a,b){a.streams.forEach(c=>{c.frameRate=b})},yL=function(a,b){a.streams.forEach(c=>{c.bandwidth=b})},zL=function(a,b){a=a.map(c=>c.a[b]);
29
- return a.some(c=>null==c)?null:a},AL=function(a,b){const c=new Set(a.map(d=>d.oa));return b.filter(d=>!c.has(d.oa))},CL=function(a,b){for(;a[0].oa<b[0].oa;)a.splice(0,1);var c=a[0];let d=b[0];c.startTime===d.startTime&&c.endTime===d.endTime||BL(c,d);const e=a.length-1;c=a[e];d=b[e];0<e&&(c.startTime!==d.startTime||c.endTime!==d.endTime)&&BL(c,d);for(c=e+1;c<b.length;)a.push(b[c]),c++},HL=function(a,b,c,d,e){var f=b[0].length();f=WK(f).map(g=>{var h=zL(b,g)||[];const k=sL(c,g)||[];g=sL(d,g)||[];{const l=
30
- [...DL(h),...k,...g].filter(Boolean);EL(l);const {oa:m,duration:n}=l[0];h={configurationId:a,variants:h,textStreams:k,thumbStreams:g,startTime:0,id:`P${m}`,endTime:n,duration:n,oa:m}}return h});e&&FL(f[0]);GL(f);return f},DL=function(a){a=new Set(a.flatMap(b=>[b.video,b.audio]).filter(Boolean));return Array.from(a)},FL=function(a){const b=DL(a.variants)[0].U[0].Ca;a.startTime+=b;a.endTime+=b},GL=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=
31
- c.startTime+c.duration}},BL=function(a,b){a.startTime=b.startTime;a.endTime=b.endTime;a.duration=b.duration;IL(a.variants,b.variants);JL(hK(a),hK(b))},IL=function(a,b){const c=new Map(a.map(d=>[xK(d),d]));b.forEach(d=>{c.get(xK(d)).drmInfos=d.drmInfos})},JL=function(a,b){const c=new Map(a.map(d=>[d.Da,d]));b.forEach(d=>{const e=c.get(d.Da);e.U=d.U;d.U.forEach(f=>{f.initSegment=e.initSegmentReference});e.segmentIndex.replace(d.U);e.Uc=d.Uc;e.Ke=d.Ke;e.duration=d.duration;e.Sf=d.Sf;e.encrypted=d.encrypted;
32
- e.drmInfos=d.drmInfos;e.keyId=d.keyId})},EL=function(a){const b=KL(a);a.forEach(c=>{_.UC(c.segmentIndex,b);c.duration=b;c.Ke=c.Uc+b})},KL=function(a){let b=Infinity;a.filter(kK).forEach(c=>{b=Math.min(b,c.duration)});return b},LL=function(a,b){iK(b,(c,d)=>{_.gD(a,c.U,d.startTime)});_.ZC(a.a,b[0].startTime,b[b.length-1].endTime)},ML=function(a){return null===a.o?[]:[a.o.audio,a.o.video].filter(b=>b).map(b=>b.Da)},NL=function(a,b){return _.x(function*(){var c=_.mj([b],a.a.attemptParameters);c.type=
33
- 1;c=yield a.H(c);let d="";try{d=_.Ui(c.data)}catch(e){throw new _.I(_.G,4,4042);}d=d.replace(/\r\n|\r(?=[^\n]|$)/gm,"\n");d=d.trim();return{text:d,response:c}})},YL=function(a,b){return _.x(function*(){var c=OL(a,b,a.w,"");if(1===c.type){var d=c.U[0].a;c=PL(d);if(!c)throw new _.I(_.G,4,4021,`Unknown file extension ${d}`);d="";c===_.w?d="avc1.42E01E":c===_.p&&(d="mp4a.40.2");c=UK(a.R,a.w,a.a.hlsDefaultCodecs||d)}d=sK(c.ha);c=QL(d.Bc.Ff);c.forEach(m=>{a.J.add(m.groupId)});var e=yield RL(a,d);var f=
34
- e.Wh;const g=e.periods;var h=e.ki;const k=e.Hi;d=e.alternativeVariants;const l=e.alternativeTextStreams;e=e.alternativeImageStreams;if(!a.D)throw new _.I(_.G,7,7001);SL(a,g);h=TL(a,f.delay,g,h);UL(a)||(a.G=f.Ed,VL(a));WL(a,h,g);f=XL(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})},$L=function(a,b){return Promise.all(b.map(c=>
35
- ZL(a,c)))},bM=function(a,b){b.forEach(c=>{a:{var d=a.j.get(c.verbatimUri),e=!UL(a),f=eK(c.ha,"EXT-X-DISCONTINUITY-SEQUENCE");if(f)var g=Number(f.value);else{d?(f=d.streams[d.streams.length-1].U,f=f[f.length-1].oa):f=0;if(e&&0<f)try{{const k=eK(c.ha,MJ);if(!k)throw aM.error("Failed to infer discontinuity number, because EXT-X-MEDIA-SEQUENCE tag is missing."),Error(OJ);const l=Number(k.value),m=tL(d,l);if(!m)throw aM.error("Failed to infer discontinuity number, could not find the appropriate segment in the previous playlist"+
36
- ` (segment position = ${l})`),Error(OJ);var h=m.oa}g=h;break a}catch(k){throw new _.I(_.G,4,4024,"EXT-X-DISCONTINUITY-SEQUENCE tag is required for discontinuous HLS live streams.");}g=0}}c=c.U||[];for(const k of c)dK(k.ha,IJ)&&g++,k.oa=g});eL(b)},eM=function(a,b){return _.x(function*(){const {textStreams:c,thumbStreams:d,$g:e}=yield cM(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=DK(g.audio,e),k=DK(g.video,e);g=dM(a,h,k,g.bandwidth);
37
- if(!g)throw new _.I(_.G,4,4047,{message:"Video and audio are encrypted in an incompatible way.",oj:k?zK(k).Da:void 0,audio:h?zK(h).Da:void 0});return g});return HL(a.D.configurationId,f,c,d,!0)})},SL=function(a,b){UL(a)||2!==a.a.timeline.version||(a.I||(a.I=b[0].startTime),_.qE(b,-a.I))},fM=function(a,b){b=b.flatMap(d=>d.U[0].ha);b=eK(b,"EXT-X-PROGRAM-DATE-TIME");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}).`),
38
- null):c/1E3},gM=function(a,b,c){b=b.find(d=>null!==eK(d.ha,HJ));if(!b)return[];if(null===c)throw new _.I(_.G,4,4024,"EXT-X-PROGRAM-DATE-TIME tag is required when EXT-X-DATERANGE tags are present");return b.ha.filter(d=>d.name===HJ).map(d=>{a:{var e=a.C,f=!UL(a),g=_.J(d,"ID"),h=_.J(d,"START-DATE");if(null===g||null===h)_.ju.warn("Invalid EXT-X-DATERANGE missing mandatory ID or START-DATE attribute, ignoring the EXT-X-DATERANGE tag.",d),d=null;else{e=f?e-c:-c;var k=new Date(h);f=k.getTime()/1E3+e;
39
- g={id:g,startTime:f,startDate:k,oe:h};h=$J(_.J(d,GJ));void 0!==h&&0<=h&&(g.duration=h);var l=$J(_.J(d,"PLANNED-DURATION"));void 0!==l&&0<=l&&(g.plannedDuration=l);var m=_.J(d,"CLASS");null!==m&&(g.schemeIdUri=m);var n=_.J(d,"END-DATE");n=n?new Date(n):null;null!==n&&n.getTime()>=k.getTime()&&(g.endDate=n);{const v=d.attributes;if(null==v)var r=null;else{k={};for(r of v)r.name.trim().startsWith("X-")&&(k[r.name]=r.value);r=_.Zg(k)?k:null}}r=r||{};(k=_.J(d,"CUE"))&&(r.CUE=k.split(","));if(_.zi(m)){k=
40
- d.attributes;if(null==k)var u=null;else{m={};for(u of k)switch(u.name){case _.Kb:m[_.Kb]=u.value;break;case _.Jb:m[_.Jb]=u.value;break;case _.Nb:m[_.Nb]=$J(u.value);break;case _.Lb:m[_.Lb]=$J(u.value);break;case "X-SNAP":m["X-SNAP"]=u.value.split(",");break;case _.Mb:m[_.Mb]=u.value.split(",")}m[_.Kb]&&m[_.Jb]||!m[_.Kb]&&!m[_.Jb]?(_.ju.warn("Invalid EXT-X-DATERANGE Interstitial attributes X-ASSET-URI, X-ASSET-LIST"),u=null):u=_.Zg(m)?m:null}if(null===u){_.ju.warn("Invalid interstitial attributes, ignoring the EXT-X-DATERANGE tag.",
41
- d);d=null;break a}r=Object.assign(r,u)}_.Zg(r)&&(g.customAttributes=r);g.endTime=n?n.getTime()/1E3+e:h?f+h:l?f+l:f;g.type=_.Qh;d=g}}return d}).filter(Boolean)},XL=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.oe!==d.oe)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,
42
- value:"",startTime:d.startTime,oe:d.oe,endTime:d.endTime,id:d.id,type:_.Qh,eventElement:null};b&&!ZJ(b,e)||a.B.set(d.id,e)}return Array.from(a.B.values())},hM=function(a,b,c){a.A=_.Cb;_.cD(b,!0);b.f=c[c.length-1].endTime},OL=function(a,b,c,d){a=QK(a.R,b,c);a.verbatimUri=d;return a},QL=function(a){return a.filter(b=>b.name===LJ&&_.J(b,_.rb)===_.rB&&!_.J(b,_.tb)).map(b=>{const c=EK(b),d=_.J(b,_.Ka)||_.dg;return{groupId:WJ(b,_.Ea),id:_.oJ++,label:WJ(b,_.Sa),language:d,channelsCount:c,primary:"YES"===
43
- _.J(b,"DEFAULT")}})},RL=function(a,b){return _.x(function*(){var c=BK(b.Bc.closedCaptions),d=iM(a,b.Gd),e=yield jM(a,b),f=Object.values(e).flat().map(h=>h.playlist);bM(a,f);f=f[0];var g=lK(f.ha);a.A=g;a.K=qK(f.ha);f=yK(f.ha,g,a.a.lowLatencyMode||!1,a.a.suggestedPresentationDelay,a.a.liveRefreshPeriod);g=yield kM(a,e.Gf,d);c=yield lM(a,e.Gd,g,c);d=yield mM(a,e.Ei,d);g=yield nM(a,e.Fe);d=HL(a.D.configurationId,c,d,g,!UL(a));a.D.filterAllPeriods(d);c=[...e.Gd,...e.Gf].map(h=>h.playlist);e=fM(a,c);c=
44
- gM(a,c,e);return{periods:d,ki:e,Hi:c,Wh:f}})},TL=function(a,b,c,d){let e=!0,f=null,g=0;UL(a)||(e=!1,f=0,g=b);b=a.a.timeline||{};b.type=void 0;a=new _.rJ(b,f,g,!0,void 0,!!a.a.lowLatencyMode);_.cD(a,e);LL(a,c);d&&_.bD(a,d);return a},VL=function(a){var b=0;for(var c of a.j.values())b=Math.max(b,c.streams[0].Uc);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>
45
- b.Uc?(a.g.debug("Offset applied to",b.type),b.segmentIndex.offset(c)):a.g.debug("Offset NOT applied to",b.type)}},WL=function(a,b,c){c=wK(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===_.Cb&&(b.f=c)},cM=function(a,b){return _.x(function*(){const c=g=>zK(g.stream).type===_.w||zK(g.stream).type===_.p;var d=b.filter(c),e=b.filter(g=>!c(g)),f=g=>{g=g.map(h=>{var k=zK(h.stream);k={language:k.language,channelsCount:k.channelsCount,
46
- 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,Hd:{width:k.width,height:k.height,frameRate:k.frameRate}};h=Object.assign({},{playlist:h.playlist},k);return oM(a,h)});return Promise.all(g)};d=yield f(d);f=yield f(e);pM(a,d.concat(f));e=f.filter(g=>zK(g).type===_.XB);f=f.filter(g=>zK(g).type===_.be);return{textStreams:e,thumbStreams:f,$g:d}})},dM=function(a,b,c,d,e){const f=[],g=
47
- (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?_.wC(l.drmInfos,m.drmInfos)?_.vC(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:_.dg,primary:!!h&&h.primary||!!k&&k.primary,audio:h,video:k,bandwidth:m,drmInfos:l,allowedByApplication:!0,allowedByKeySystem:!0};f.push(h)}return new qM(f)},oM=function(a,b){return _.x(function*(){const c=b.playlist,d=b.codecs,e=b.type,
48
- f=b.Sc,g=b.hc,h=b.groupId,k=b.muxedAudioId,l=b.primary;var m=b.kind;const n=b.name,r=b.channelsCount,u=b.spatialAudio,v=b.closedCaptions,y=b.Hd,A=_.Bi(f||_.dg);if(1!==c.type)throw new _.I(_.G,4,4017);const D=yield rM(a,c,e,d),E=a.a.lowLatencyMode?_.OB:_.NB;let X=m;e!==_.H||m||(X=_.XB);const cd=lK(c.ha);m=D.map(gc=>{const Ob=gc.U,Vd=gc.mh,Pb=gc.mimeType,hc=gc.oa,ic=Ob[0].startTime,Gb=Ob[Ob.length-1].endTime,hb=Gb-ic,ua=new _.sJ(Ob),zb=Ob[0].initSegment||null;return{id:null===g?_.oJ++:g,originalId:n,
49
- createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:ua.f.bind(ua),getSegmentReference:ua.get.bind(ua),adjustSegmentDurations:ua.h.bind(ua),getDuration:ua.getDuration.bind(ua),segmentIndex:ua,segmentLookupStrategy:E,initSegmentReference:zb,mimeType:Pb,codecs:d,kind:X,Sf:Vd.type,encrypted:Vd.type===VJ,aesEncrypted:gc.aesEncrypted,keyId:Vd.keyId,language:A,originalLanguage:f||_.dg,label:n,type:e,primary:l,trickModeVideo:null,emsgSchemeIdUris:null,frameRate:y?y.frameRate:void 0,width:y?
50
- y.width:void 0,height:y?y.height:void 0,bandwidth:void 0,roles:[],channelsCount:r,spatialAudio:u,closedCaptions:v,U:Ob,drmInfos:Vd.drmInfos,oa:hc,Da:c.verbatimUri,re:c.a,Uc:ic,Ke:Gb,duration:hb,groupId:h,hj:cd,muxedAudioId:k}});return new sM(m)})},pM=function(a,b){b.forEach(c=>{a.j.a.set(zK(c).Da,c)})},iM=function(a,b){const c=new Map;for(const f of b){var d=_.J(f,_.rB);b=_.J(f,_.Bb);var e=_.J(f,SJ);const g=tM(a,f);if(e){const h=_.Yj(_.H,g);c.set(`${_.H}:${e}`,h);e=g.indexOf(h);-1<e&&g.splice(e,1)}d&&
51
- (e=uM(_.p,g),c.set(`${"audio"}:${d}`,e));b&&(d=uM(_.w,g),c.set(`${"video"}:${b}`,d))}return c},jM=function(a,b){return _.x(function*(){const c=yield Promise.all([vM(a,b.Bc.Ff),vM(a,b.Bc.Fi),vM(a,b.Gd),vM(a,b.Fe)]),[d,e,f,g]=c;return{Gf:d,Ei:e,Gd:f,Fe:g}})},kM=function(a,b,c){return _.x(function*(){if(0===b.length)return new Map;var d=[wM(a,b[0],c)];yield d[0];d=d.concat(b.slice(1).map(e=>wM(a,e,c)));d=yield Promise.all(d);return AK(d)})},lM=function(a,b,c,d){return _.x(function*(){const e=new Set;
52
- var f=[...b];let g=0;var h=Infinity;for(let k=0;k<f.length;++k){const l=Number(WJ(f[k].tag,_.la));l<h&&(h=l,g=k)}h=f.splice(g,1).pop();h=yield xM(a,h,c,d,e);f=f.map(k=>xM(a,k,c,d,e));f=yield Promise.all(f);f.splice(g,0,h);return f.reduce(_.nC,[])})},mM=function(a,b,c){return Promise.all(b.map(d=>wM(a,d,c)))},nM=function(a,b){return Promise.all(b.map(c=>yM(a,c)))},zM=function(a,b){return _.x(function*(){const c=gK(a.w,b.verbatimUri),{response:d,text:e}=yield NL(a,c);return OL(a,e,d.uri,b.verbatimUri)})},
53
- AM=function(a,b,c){return _.x(function*(){const d=yield oM(a,{playlist:c,codecs:b.codecs,type:b.type,Sc:b.originalLanguage,hc: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,Hd:{width:b.width,height:b.height,frameRate:b.frameRate}});b.bandwidth&&yL(d,b.bandwidth);return d})},UL=function(a){return a.A===_.Cb},vM=function(a,b){return _.x(function*(){return(yield Promise.all(b.map(c=>
54
- _.x(function*(){const d=yield BM(a,c);return d?{tag:c,playlist:d}:null})))).filter(Boolean)})},ZL=function(a,b){return _.x(function*(){var c=new _.mi(zK(b).re);if(a.a.lowLatencyMode&&a.K&&a.K.Kf){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={Xh:d.position,di:e&&0<e.length?f:null}}else d=null;if(e=d)d=e.Xh,e=e.di,f=_.Mj(c.a.toString()),f._HLS_msn=d.toString(),null===e&&f._HLS_part&&delete f._HLS_part,null!==e&&(f._HLS_part=e.toString()),d=_.Lj(f,
55
- !0),d=new _.ti(d),_.pi(c,d)}const {response:g,text:h}=yield NL(a,c.toString());c=zK(b).Da;d=zK(b).re;e=g.uri;d!==e&&(d=e,uL(b,d));c=OL(a,h,d,c);return{stream:b,playlist:c}})},tM=function(a,b){var c=_.J(b,_.oa,a.a.hlsDefaultCodecs||"avc1.42E01E,mp4a.40.2").split(/\s*,\s*/);c=CK(c);b=new Set;const d=[];for(const e of c)c=_.CC(e),b.has(c)?a.g.debug("Ignoring duplicate codec"):(d.push(e),b.add(c));return d},uM=function(a,b){if(1===b.length)return b[0];a=_.Yj(a,b);if(null!=a)return a;throw new _.I(_.G,
56
- 4,4025,{codecList:b});},wM=function(a,b,c){return _.x(function*(){const d=b.tag,e=b.playlist;return CM(a,e.verbatimUri,()=>_.x(function*(){const f=WJ(d,_.Ea),g=mK(WJ(d,_.rb));var h=WJ(d,_.rb).toUpperCase();if(mK(h)!==_.H)h=null;else{var k=d.getAttribute("FORCED");k=!(!k||!k.value||"YES"!==k.value.toUpperCase());var l=_.XB;h===EJ&&(l=_.JB);k&&(l=_.Ud);h=l}k=c.get(`${g}:${f}`)||"";l=_.J(d,_.Ka);const m=_.J(d,_.Sa),n=_.J(d,"DEFAULT"),r=g===_.p?EK(d):null;var u=g===_.p?(u=_.J(d,"CHANNELS"))?u.includes("/JOC"):
57
- !1:!1;return yield oM(a,{playlist:e,codecs:k,type:g,Sc:l,primary:"YES"===n,name:m,channelsCount:r,spatialAudio:u,groupId:f,kind:h,hc:null,closedCaptions:null,Hd:null})}))})},yM=function(a,b){return _.x(function*(){const c=b.tag,d=b.playlist;return CM(a,d.verbatimUri,()=>_.x(function*(){var e=_.J(c,_.oa)||"jpg",f=_.J(c,_.Ka);const g=_.J(c,_.Sa);e=yield oM(a,{playlist:d,codecs:e,type:_.be,Sc:f,name:g,primary:!1,kind:null,channelsCount:null,spatialAudio:!1,closedCaptions:null,hc:null,groupId:null,Hd:null});
58
- (f=_.J(c,_.la))&&yL(e,Number(f));return e}))})},xM=function(a,b,c,d,e){return _.x(function*(){var f=b.tag,g=Number(WJ(f,_.la));if(f.hasAttribute("FRAME-RATE")||f.hasAttribute(_.kb)){var h=_.J(f,"FRAME-RATE");f=_.J(f,_.kb);var [k,l]=f?f.split("x"):[null,null];h={frameRate:$J(h),width:$J(k),height:$J(l)}}else h=null;if(f=yield DM(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 r of h){m=(r?zK(r).Da:"")+" - "+(n?zK(n).Da:"");if(e.has(m)){a.g.debug("Skipping variant which only differs in text streams.");
59
- continue}const u=dM(a,n,r,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})},EM=function(a,b,c,d,e,f){let g=tM(a,b);a.g.debug("Guessing stream type for",b.toString());b=!1;const h=_.Yj(_.w,g),k=d+e;1!==g.length||c||h?!k&&1<g.length?(a.g.debug("Guessing multiplexed audio+video"),c=_.w,g=[g.join(",")]):d&&f?(a.g.debug(PJ),c=_.p,b=!0):e?(a.g.debug(PJ),c=_.p):(a.g.debug("Guessing video-only"),c=_.w):(c=_.p,a.g.debug(PJ));return{type:c,
60
- Yg:g,Nh:b}},CM=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},DM=function(a,b,c,d,e){return _.x(function*(){var f=b.tag,g=b.playlist,h=_.J(f,_.rB),k=_.J(f,_.Bb);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=>zK(u).Da===l);const {type:m,Yg:n,Nh:r}=EM(a,f,c,k.audio.length,k.video.length,g);f=null;r||(f=yield FM(a,b,n,m,e,c));
61
- if(null==f)return null;k[m]=[f];m===_.p&&c&&k.video.forEach(u=>{vL(u,c.width);wL(u,c.height);xL(u,c.frameRate)});return k})},FM=function(a,b,c,d,e,f){return _.x(function*(){const g=b.tag,h=b.playlist;return CM(a,h.verbatimUri,()=>_.x(function*(){var k=_.J(g,EJ);let l=null;d===_.w&&k&&"NONE"!==k&&(l=e.get(k));k=(k=_.J(g,_.rB)||void 0)&&a.J.has(k)?k:void 0;var m=uM(d,c);if(k){const n=uM(_.p,c);m+=`,${n}`}return yield oM(a,{playlist:h,codecs:m,type:d,closedCaptions:l,primary:!1,kind:null,Sc:null,name:null,
62
- channelsCount:null,spatialAudio:!1,hc:null,groupId:null,muxedAudioId:k,Hd:f})}))})},rM=function(a,b,c,d){return _.x(function*(){var e=b.verbatimUri,f=b.U;var g=void 0===g?0:g;var h=(h=eK(b.ha,MJ))?Number(h.value):g;g=[];e=yield GM(a,b.a,e,f,h,c,d);if(0===f.length)f=[];else{var k=[],l=[];for(var m of f)dK(m.ha,IJ)&&0<l.length&&(k.push(l),l=[]),l.push(m);k.push(l);f=k}for(m=0;m<f.length;m++)k=f[m],l=yield HM(a,b.a,k,h,e,c,d,g[g.length-1]||null),g.push(l),h+=k.length;IM(g);return g})},BM=function(a,
63
- b){return _.x(function*(){var c=b.name!==LJ?!0:_.J(b,_.rb)===SJ;c=_.J(b,_.tb,void 0,{required:c});if(!c)return null;const d=gK(a.w,c),e=Date.now(),{response:f,text:g}=yield NL(a,d);a.D.onEvent(new _.F(UJ,{detail:{duration:Date.now()-e,type:"media"}}));return OL(a,g,f.uri,c)})},IM=function(a){if(1<(new Set(a.map(b=>b.mimeType))).size)throw new _.I(_.G,4,4045,"Media playlist contains discontinuities with different MIME types. This is valid, but not yet supported.");},JM=function(a){a=a.map(b=>b.a?b.a:
64
- b.f.map(c=>_.J(c,_.tb))||null).map(b=>_.iu(b));if(1<(new Set(a)).size)throw new _.I(_.G,4,4044,"Unexpected change in file format.");},KM=function(a,b,c){a=aK(a.ha,KJ);if(1<a.length)throw new _.I(_.G,4,4020);a=a[0];if(!a)return null;const d=WJ(a,_.tb),e=gK(b,d);b=rK(a,null,!0);return new _.nJ(()=>[e],b.ya,b.pa,c)},LM=function(a,b,c,d,e,f,g){const h=[];for(const r of VK(b.f)){b=r.eg;const u=r.item;{var k=0===b,l=k?a:h[h.length-1],m=k?d:l.endTime,n=Number(_.J(u,GJ));n=m+n;k=rK(u,k?null:l.pa,k);l=_.J(u,
65
- _.tb);const v=(l=gK(g,l))?[l]:[];m=new tK(c,m,n,()=>v,k.ya,k.pa,e,f,!1,null,null,null,null);if("YES"===_.J(u,"INDEPENDENT")||0===b)m.h=!0;h.push(m)}}return h},MM=function(a,b,c,d,e,f,g,h,k,l,m){const n=c.ha;var r=c.a;0<aK(n,KJ).length&&(m=KM(c,k,g));const u=null!=r,v=r?[r]:[];if(!u&&!a.a.lowLatencyMode)return null;a=0;r={ya:0,pa:null};let y=null;u?({duration:c}=pK(n),a=e+c,r=oK(n,b?b.pa:null)):(b=LM(b,c,d,e,f,g,k),a=b[b.length-1].endTime,y=b);h=h===_.be?fK(n):null;d=new tK(d,e,a,()=>v,r.ya,r.pa,f,
66
- g,!1,null,h?h.ld:null,h?h.Fd:null,h?h.durationPerTile:null,y,m);d.oa=l;return d},GM=function(a,b,c,d,e,f,g){return _.x(function*(){var h=d[0];if(null!=a.C)return a.C;if(!UL(a)&&a.f)try{var k=a.j.get(c);var l=k?tL(k,e)||null:null;if(!l)throw new _.I(_.G,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].U,m=m[m.length-1],a.g.warn(`Last #EXT-X-MEDIA-SEQUENCE values ${h.streams[0].U[0].position} - ${m.position}`+
67
- `, new values ${e} - ${e+d.length-1}.`,b,h);throw new _.I(_.G,4,4047,{message:"The updated playlist does not share any segments with the previous one.",uri:c});}m=yield NM(a,f,g,h);l=pL(h.ha,a.w,e);k=KM(h,b,l);h=yield OM(a,k,h,l,m,g);a.g.debug(`Setting playlist start time to ${h}.`);return a.C=h})},HM=function(a,b,c,d,e,f,g,h){return _.x(function*(){var k=c[0],l=null==h;JM(c);const m=yield NM(a,f,g,k);var n=h?h.Uh:null;if(dK(c[0].ha,JJ)||null===n)n=mL(c,m),n=0===n.length?[iL()]:n;else{var r=mL(c,
68
- m);n=[n,...r]}r=n;n=r[r.length-1];r=jL(r);let u=h?h.Vh:null;var v=PM(u,k.ha,a.w,d);let y=KM(k,b,v)||(h?h.Oh:null);const A=k.oa;k=l?e:yield QM(a,A,y,k,d,v,m,g);l=[];v=!1;for(let E=0;E<c.length;E++){var D=c[E];const X=l[l.length-1]||null,cd=0===E?0:X.endTime,gc=d+E,Ob=PM(u,D.ha,a.w,gc);(u=Ob)&&(v=!0);if(D=MM(a,X,D,gc,cd,k,Ob,f,b,A,y))y=D.initSegment,l.push(D)}return{U:l,mh:r,Uh:n,aesEncrypted:v,mimeType:m,endTime:l[l.length-1].endTime,oa:A,Oh:y,Vh:u}})},NM=function(a,b,c,d){return _.x(function*(){const e=
69
- d.a;var f=eK(d.ha,KJ);f=f?WJ(f,_.tb):null;return RM(a,b,c,e,f)})},OM=function(a,b,c,d,e,f){return _.x(function*(){if(null==c.a)return 0;const g=uK(c,d);return rL(a.S,b,g,e,f,null!=d)})},PM=function(a,b,c,d){return b.some(e=>e.name===JJ&&"NONE"===_.J(e,QJ))?null:(b=pL(b,c,d))?b:a&&a.generatedIv?Object.assign({},a,{iv:_.Nl(new Uint8Array(12),XK(d))}):a},QM=function(a,b,c,d,e,f,g,h){return _.x(function*(){if(a.L.has(b))return a.L.get(b);const k=yield OM(a,c,d,f,g,h);a.g.debug(`Segment #${e} has raw media timestamp `+
70
- `${k} s.`);a.L.set(b,k);return k})},RM=function(a,b,c,d,e){return _.x(function*(){const f=[d,e].filter(Boolean);var g=_.bk(f,b,c);if(g)return g;g=_.mj([d],a.a.attemptParameters);g.method="HEAD";g.type=2;g=(yield a.H(g)).headers["content-type"];if(!g)throw new _.I(_.G,4,4021,"Unknown MIME type of: "+f.join(", "));return g.toLowerCase().split(";")[0]})},PL=a=>{a=_.iu(a)||"";return null!=_.hu.video[a]?_.w:null!=_.hu.audio[a]?_.p:null},KK=class{constructor(a,b,c,d){if(1===b){if(!d||0===d.length)throw new _.I(_.G,
71
- 4,4043,"Media playlist must have at least one segment!");if(null==d[0].a)throw new _.I(_.G,4,4043,"Media playlist must have at least one full segment!");}this.a=a;this.verbatimUri="";this.type=b;this.ha=c;this.U=1===b?d:null}},TK=class{constructor(a,b,c){c=void 0===c?[]:c;this.ha=b;this.a=a;this.f=c;this.oa=-1}},tK=class extends _.sD{constructor(a,b,c,d,e,f,g,h,k,l,m,n,r,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:
72
- n,void 0===r?null:r,u,void 0===v?null:v);this.oa=0}},RK=/^#EXT-X-DEFINE/,SK=/^#(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)/,SM=class{constructor(){this.h=0;this.a=new Map}},TM=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)||
73
- null}values(){return Array.from(this.a.values())}clear(){this.f.clear();this.a.clear()}},aM=new _.S("clpp.hls.DiscontinuityUtils");var oL={"com.apple.streamingkeydelivery":function(a,b){if(b===_.og)throw new _.I(_.G,4,4041);if(WJ(a,QJ)===RJ)throw new _.I(_.G,4,4044,"EXT-X-KEY:METHOD SAMPLE-AES-CTR is not supported in FairPlay.");return _.qC(_.pd,[{initDataType:_.Gf,initData:new Uint8Array(0)}],"")},"com.microsoft.playready":hL,"urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":hL,"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":function(a){var b=WJ(a,QJ);if(!fL.includes(b))return gL.error("Widevine in HLS is only supported with [",
74
- fL.join(", "),"], not",b),null;b=WJ(a,_.tb);b=_.vt(b);b=_.K(b.data);b=_.qC(_.td,[{initDataType:_.Tc,initData:b}],"");if(a=_.J(a,"KEYID"))b.keyIds=[a.substr(2).toLowerCase()];return b}},fL=["SAMPLE-AES",RJ],gL=new _.S("clpp.hls.DrmParser");var nL=new _.S("clpp.hls.EncryptionUtils");var UM=class{constructor(a){this.g=new _.S("clpp.hls.MediaReader");this.f=a;this.a={attemptParameters:_.ij()}}};var sM=class{constructor(a){this.streams=a}length(){return this.streams.length}};var qM=class{constructor(a){this.a=a}length(){return this.a.length}};var VM=class{constructor(){this.a=this.D=null;this.h=1;this.j=new TM;this.w="";this.R=new SM;this.G=0;this.o=null;this.l=new _.rk(()=>{this.Vb()});this.A=_.Cb;this.f=null;this.F=new _.lu;this.K=this.C=null;this.g=new _.S("clpp.hls.HlsParser");this.L=new Map;this.S=new UM(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.S.a=a}setCurrentVariant(a){this.o=a}start(a,b){const c=this;return _.x(function*(){if(c.P)throw Error("start() may be called only once!");
75
- c.P=!0;c.D=b;var d=Date.now();const {response:e,text:f}=yield NL(c,a);c.D.onEvent(new _.F(UJ,{detail:{duration:Date.now()-d,type:"master"}}));c.w=e.uri;d=yield YL(c,f);c.f=d;const g=c.G;c.l&&0<g&&c.l.ka(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 _.x(function*(){const b=a.f;if(!UL(a)&&
76
- 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=ML(a);d=d.filter(h=>g.includes(zK(h).Da))}var e=yield $L(a,d);d=e.map(g=>g.playlist);bM(a,d);e=yield eM(a,e);AL(b.periods,e).forEach(g=>{a.D.filterNewPeriod(g)});SL(a,e);var f=fM(a,d);f=gM(a,d,f);b.cues=XL(a,f);CL(b.periods,e);LL(c,e);if(d=jK(d))!0!==a.a.keepTimelineLive&&hM(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();
77
- a.M&&(yield a.stop());return b}})}loadVariant(a,b){const c=this;return _.x(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 _.ji(`No alternative variant with id: ${d}`);var f=null,g=null;if(e.audio){const k=e.audio;f=CM(c,k.verbatimUri,()=>_.x(function*(){const l=yield zM(c,k);return AM(c,k,l)}))}if(e.video){const k=e.video;g=CM(c,k.verbatimUri,()=>_.x(function*(){const l=yield zM(c,
78
- k);return AM(c,k,l)}))}f=yield f;g=yield g;e=dM(c,f,g,e.bandwidth,e.id);let h;e&&(e=HL(c.D.configurationId,[e],[],[],!UL(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 _.ji(`Could load variant with id: ${d}`);return h})}loadTextStream(a,b){const c=this;return _.x(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=
79
- c.f.alternativeTextStreams.find(h=>h.id===a)||null;if(!f)throw new _.ji(`Could not load text stream with id: ${a}`);const g=yield CM(c,f.verbatimUri,()=>_.x(function*(){const h=yield zM(c,f);return AM(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 _.ji(`Could not load text stream with id: ${a}`);return d})}Vb(){const a=this;return _.x(function*(){a.g.debug(_.DB);if(a.D)try{yield a.update(),a.l&&0<a.G&&a.l.ka(a.G)}catch(b){if(!(b instanceof
80
- _.I))throw b;a.D&&(a.D.onError(b),1===b.severity&&a.l&&a.l.ka(.1))}})}H(a){if(!this.F)throw new _.I(_.G,7,7001);a=this.D.networkingEngine.fetch(a);_.vj(this.F,a);return a.T}};_.z("clpp.hls.HlsComponent",class extends _.Av{f(){_.$s.m3u8=VM;_.Ys[_.kl]=VM;_.Ys[TJ]=VM}a(){_.RD("m3u8");_.SD(_.kl);_.SD(TJ)}id(){return"hls"}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";import './cl.mse.js';let g={};const _ = clpp._;var f=function(window){'use strict';var NJ="CLOSED-CAPTIONS",OJ="Could not parse MP4 segment start time.",PJ="DURATION",QJ="EXT-X-DATERANGE",RJ="EXT-X-DISCONTINUITY",SJ="EXT-X-KEY",TJ="EXT-X-MAP",UJ="EXT-X-MEDIA",VJ="EXT-X-MEDIA-SEQUENCE",WJ="EXT-X-STREAM-INF",XJ="Failed to infer discontinuity number",YJ="Guessing audio-only",ZJ="METHOD",$J="SAMPLE-AES-CTR",aK="SUBTITLES",bK="application/vnd.apple.mpegurl",cK="manifestloaded",dK="sample",eK=function(a,b){return _.J(a,b,void 0,{required:!0})},fK=function(a){if(1>a.a)throw _.dm();
2
+ --a.a},gK=function(a,b){for(const c in a){if(!(c in b))return!1;const d=a[c],e=b[c];if(d&&typeof d===_.Ee&&e&&typeof e===_.Ee){if(!gK(d,e))return!1}else if(void 0!==d&&void 0!==e&&d!==e)return!1}return!0},hK=function(a,b){if(!gK(a,b))return!1;for(const c in b){if(!(c in a))return!0;const d=a[c],e=b[c];if(!d&&e||d&&typeof d===_.Ee&&e&&typeof e===_.Ee&&hK(d,e))return!0}return!1},iK=function(a){if(null!==a&&void 0!==a)return Number(a)},jK=function(a,b){return a.filter(c=>c.name===b)},kK=function(a){const b=
3
+ /^[a-zA-Z0-9_-]+$/,c=new Set;a.forEach(d=>{const e=_.J(d,"VALUE"),f=_.J(d,_.Ta),g=_.J(d,"IMPORT"),h=_.J(d,"QUERYPARAM");if(1!==[f,g,h].filter(Boolean).length||f&&null==e)throw new _.I(_.G,4,4044,{message:"Invalid tag.",text:d.toString()});d=f||g||h;if(c.has(d))throw new _.I(_.G,4,4044,`EXT-X-DEFINE redefined variable "${d}".`);if(!b.test(d))throw new _.I(_.G,4,4044,`EXT-X-DEFINE invalid variable name "${d}".`);c.add(d)})},lK=function(a,b){const c=Array.isArray(b)?b:[b];return a.filter(d=>{d=eK(d,
4
+ _.sb);return c.includes(d)})},mK=function(a,b){return a.some(c=>c.name===b)},nK=function(a,b,c){c=void 0===c?{}:c;a=a.find(d=>d.name===b)||null;if(!a&&c.required)throw new _.I(_.G,4,4024,{missingTag:b});return a},oK=function(a){var b=nK(a,"EXT-X-TILES");if(!b)return{nd:1,Kd:1,durationPerTile:null};a=_.J(b,"LAYOUT")||"1x1";b=_.J(b,PJ);a=_.yC(a);return{nd:a.nd,Kd:a.Kd,durationPerTile:b?Number(b):null}},pK=function(a){const b=new Set;a.variants.forEach(c=>{c.audio&&b.add(c.audio);c.video&&b.add(c.video)});
5
+ a.textStreams.forEach(c=>b.add(c));a.thumbStreams.forEach(c=>b.add(c));return Array.from(b)},qK=function(a,b){Array.isArray(a)||(a=[a]);a.forEach(c=>{for(const d of pK(c))b(d,c)})},rK=function(a){return a.some(b=>mK(b.ha,"EXT-X-ENDLIST"))},sK=function(a){return a.type===_.p||a.type===_.w},tK=function(a){if(nK(a,"EXT-X-ENDLIST"))return _.Db;a=nK(a,"EXT-X-PLAYLIST-TYPE");if(!a)return"LIVE";if(a.value===_.Db)return _.Db;if("EVENT"===a.value)return"EVENT";throw new _.I(_.G,4,4044,`Invalid EXT-X-PLAYLIST-TYPE value: ${a.value}`);
6
+ },uK=function(a){a={AUDIO:_.p,VIDEO:_.w,SUBTITLES:_.H,"CLOSED-CAPTIONS":_.H}[a.toUpperCase()];if(!a)throw new _.I(_.G,4,4044,"EXT-X-MEDIA tag has an invalid TYPE attribute.");return a},vK=function(a,b,c){c=void 0===c?!1:c;var d=0;let e=null;if(a){d=a.split("@");a=Number(d[0]);if(0>=a)throw new _.I(_.G,4,4044,"Byte range length must be positive.");if(d[1]){if(d=Number(d[1]),0>d)throw new _.I(_.G,4,4044,"Byte range start byte must not be negative.");}else{if(c)throw new _.I(_.G,4,4044,"Invalid byte range, offset is required but missing.");
7
+ if(null==b)throw new _.I(_.G,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}},wK=function(a,b){a=nK(a,"EXT-X-BYTERANGE");return vK(a?a.value:null,b)},xK=function(a){a=nK(a,"EXTINF",{required:!0}).value.split(",");return{duration:Number(a[0]),title:a[1]||null}},yK=function(a,b){b=void 0===b?{}:b;const c={Lf:!1,gh:!1,hh:null,Nh:null,ug:null};a=nK(a,"EXT-X-SERVER-CONTROL",{required:b.Ag});if(!a)return c;const d=e=>null==e?null:Number(e);
8
+ c.Lf="YES"===_.J(a,"CAN-BLOCK-RELOAD");c.gh="YES"===_.J(a,"CAN-SKIP-DATERANGES");c.hh=d(_.J(a,"CAN-SKIP-UNTIL"));c.Nh=d(_.J(a,"HOLD-BACK"));c.ug=d(_.J(a,"PART-HOLD-BACK",void 0,{required:b.Ag}));return c},zK=function(a,b,c){c=void 0===c?!1:c;a=_.J(a,"BYTERANGE");return vK(a,b,c)},AK=function(a){const b=jK(a,UJ),c=jK(a,WJ);a=jK(a,"EXT-X-IMAGE-STREAM-INF");return{Bc:{Gf:lK(b,[_.uB,_.Cb]),closedCaptions:lK(b,NJ),Gi:lK(b,aK)},Ld:c,He:a}},CK=function(a,b){const c=wK(a.ha,null);return new BK(0,0,0,()=>
9
+ [a.a],c.ma,c.ja,0,b)},DK=function(a){let b=Infinity,c=Infinity;pK(a).filter(sK).forEach(d=>{{d=d.U;var e=d[0].startTime;const f=d[d.length-1].endTime;d=e;e=f-e}b=Math.min(b,d);c=Math.min(c,e)});return{Vc:b,duration:c}},EK=function(a){return a.map(b=>{({duration:b}=DK(b));return b}).reduce((b,c)=>b+c,0)},FK=function(a){return(a.video?a.video.Da:"")+" - "+(a.audio?a.audio.Da:"")},GK=function(a,b,c,d,e){if(b===_.Db)return{delay:0,Jd:0};b=nK(a,"EXT-X-PART-INF");if(c&&b){e=Number(eK(b,"PART-TARGET"));
10
+ if(null!=d)return{delay:d,Jd:e};({ug:d}=yK(a,{Ag:!0}));return{delay:d,Jd:e}}a=nK(a,"EXT-X-TARGETDURATION",{required:!0});a=Number(a.value);e=e||a;return null!=d?{delay:d,Jd:e}:{delay:3*a,Jd:e}},IK=function(a){const b=new Map;a.forEach(c=>{var d=`${HK(c).type}:${HK(c).groupId}`;b.has(d)?(d=b.get(d),d.includes(c)||d.push(c)):b.set(d,[c])});return b},JK=function(a){const b=new Map;for(const c of a){a=_.J(c,_.La);a=_.Di(a||_.fg);const d=eK(c,_.Fa),e=eK(c,"INSTREAM-ID");b.has(d)||b.set(d,new Map);b.get(d).set(e,
11
+ a)}return b},KK=function(a){return a.filter(b=>"mp4a.40.34"!==b)},LK=function(a,b){if(!a)return null;const c=a.Da;return b.find(d=>HK(d).Da===c)||null},MK=function(a){return(a=_.J(a,"CHANNELS"))?parseInt(a.split("/")[0],10):null},NK=function*(a){let b=-1,c=void 0,d=void 0;for(const e of a)0<=b&&(yield{fg:b,item:d,ji:c,next:e}),b++,c=d,d=e;-1!==b&&(yield{fg:b,ji:c,item:d,next:void 0})},OK=function(a){return a.some(b=>b.startsWith("#EXT-X-TARGETDURATION"))?1:0},PK=function(a,b){const c=new Map,d=new URL(b);
12
+ a.forEach(e=>{var f=_.J(e,_.Ta),g=_.J(e,"QUERYPARAM");if(f)g=eK(e,"VALUE"),c.set(f,g);else if(g){f=d.searchParams.get(g);if(null==f)throw new _.I(_.G,4,4044,`Query param '${g}' missing in playlist URI.`);if(!f)throw new _.I(_.G,4,4044,`Query param '${g}' has no associated value`+" in playlist URI.");c.set(g,decodeURIComponent(f))}});return c},QK=function(a,b){return a.replace(/\{\$([a-zA-Z0-9_-]+)\}/g,(c,d)=>{c=b.get(d);if(null==c)throw new _.I(_.G,4,4044,`Undefined variable '${d}'`);return c})},
13
+ RK=function(a,b){a.forEach(c=>{c.attributes.forEach(d=>{d.value=QK(d.value,b)})})},UK=function(a,b,c){const d=[];for(let e=0;e<b.length;e++){const f=SK(a,b[e]);d.push(f);if(f.name===WJ){const g=b[e+1];if(!g)throw new _.I(_.G,4,4044,"EXT-X-STREAM-INF is not followed by a URI.");f.attributes.push(new _.kj(_.ub,g));e++}}b=jK(d,"EXT-X-DEFINE");kK(b);b=PK(b,c);a.a=b;RK(d,a.a);return new TK(c,0,d)},YK=function(a,b,c){const {vi:d,Kh:e,Pi:f}=VK(b),g=WK(a,f,c);b=e.map(k=>SK(a,k,g));const h=XK(a,c,d,g);return new TK(c,
14
+ 1,b,h)},ZK=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(_.G,4,4015);b=b.slice(1);return 0===OK(b)?UK(a,b,c):YK(a,b,c)},VK=function(a){const b=[],c=[],d=[];for(const e of a)$K.test(e)?d.push(e):aL.test(e)?c.push(e):b.push(e);return{vi:b,Kh:c,Pi:d}},WK=function(a,b,c){b=b.map(e=>SK(a,e));kK(b);const d=PK(b,c);b.map(e=>_.J(e,"IMPORT")).filter(Boolean).forEach(e=>{const f=a.a.get(e);if(null==f)throw new _.I(_.G,
15
+ 4,4044,`Cannot import variable '${e}' as it is not defined `+"in the master playlist");d.set(e,f)});return d},SK=function(a,b,c){a=_.mj(a.h++,b);c&&RK([a],c);return a},XK=function(a,b,c,d){const e=[];let f=[],g=[];c.forEach(h=>{/^(#EXT)/.test(h)?(h=SK(a,h,d),"EXT-X-PART"===h.name||"EXT-X-PRELOAD-HINT"===h.name&&"PART"===_.J(h,_.sb)?g.push(h):f.push(h)):(mK(f,"EXT-X-GAP")||(h=QK(h,d),h=_.ij(h,b),e.push(new bL(h,f,g))),f=[],g=[])});0<g.length&&e.push(new bL(null,f,g));return e},cL=function(a,b,c){const d=
16
+ [],e=[];e.push(new _.kj(_.la,"0"));e.push(new _.kj(_.ub,b));c.length&&e.push(new _.kj(_.pa,c));d.push(new _.lj(a.h++,WJ,e));return new TK(b,0,d)},dL=function(a){return 0>a?[]:Array.from({length:a},(b,c)=>c)},eL=function(a){return new Uint8Array([a>>24&255,a>>16&255,a>>8&255,a&255])},fL=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},gL=function(a){function b(h,k,l){let m="";for(;k<l;k++)m+="%"+
17
+ ("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(_.G,4,4030);}fL(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|a[5]<<14|
18
+ a[6]<<6|a[7]>>>2,f*=4,f+=a[7]&3,Math.round(f/9E4);break}}fL(a,e)||d();e+=10;e+=f}while(e<a.byteLength);return d()},hL=function(a,b){let c=null,d=0;try{(new _.tm).N(_.Ae,_.mm).N(_.cg,_.mm).N(_.re,_.mm).ea("mdhd",g=>{g.reader.skip(0===g.version?8:16);d=_.P(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(_.G,4,4030,OJ,c);let e=0,f=!1;try{(new _.tm).N("moof",_.mm).N("traf",_.mm).ea("tfdt",g=>{var h=d;if(0===g.version)h=
19
+ _.P(g.reader)/h;else{{const k=_.P(g.reader),l=_.P(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(_.G,4,4030,OJ,c);return e},iL=function(a){for(;a.getPosition()<a.Pa()-1;){const b=a.getPosition();if(71===_.em(a))return fK(a),b}return-1},jL=function(a){function b(){d.seek(e+188);f=_.em(d);71!==f&&
20
+ (d.seek(e+192),f=_.em(d));71!==f&&(d.seek(e+204),f=_.em(d));71!==f&&c();fK(d)}function c(){throw new _.I(_.G,4,4030);}const d=new _.pn(new DataView(a),!1);let e=0,f=0;e=iL(d);0>e&&(_.Mv.error("Unable to find sync byte in TS after scanning."),c());for(;;){e=d.getPosition();f=_.em(d);71!==f&&c();a=_.fm(d);if(8191===(a&8191)){b();continue}if(!(a&16384)){b();continue}a=(_.em(d)&48)>>4;0!==a&&2!==a||c();3===a&&(a=_.em(d),d.skip(a));if(1!==_.P(d)>>8){b();continue}d.skip(3);a=_.em(d)>>6;0!==a&&1!==a||c();
21
+ 0===_.em(d)&&c();a=_.em(d);const g=_.fm(d),h=_.fm(d);return(1073741824*((a&14)>>1)+((g&65534)<<14|(h&65534)>>1))/9E4}},mL=function(a){const b=kL(a),c=lL(a);a.forEach(d=>{const e=d.U,f=e.findIndex(h=>h.ra===b);let g=e.findIndex(h=>h.ra===c+1);-1===g&&(g=e.length);d.U=e.slice(f,g)})},lL=function(a){a=a.map(b=>b.U[b.U.length-1].ra);return Math.min(...a)},kL=function(a){a=a.map(b=>b.U[0].ra);return Math.max(...a)},pL=function(a){var b=eK(a,ZJ);if(!nL.includes(b))return oL.error("PlayReady in HLS is only supported with [",
22
+ nL.join(", "),"], not",b),null;a=eK(a,_.ub);b=_.zt(a);a=null;b=_.K(b.data);try{a=_.gC(_.wn(b))}catch(c){a=b}return _.uC(_.rd,[{initDataType:_.Uc,initData:a}],"")},rL=function(a){if(0===a.length)return qL();if(a.some(c=>"whole-segment"===c.type)||a.every(c=>c.type===_.De))return a[0];a=a.filter(c=>c.type===dK);const b=_.fi(a.flatMap(c=>c.drmInfos));return{keyId:a[a.length-1].keyId,type:dK,drmInfos:b}},uL=function(a,b){return sL(a).map(c=>tL(c.ha,b)).filter(Boolean)},sL=function(a){return a.filter(b=>
23
+ mK(b.ha,SJ))},tL=function(a,b){a=jK(a,SJ).filter(d=>"AES-128"!==eK(d,ZJ));if(0===a.length)return null;var c=eK(a[0],ZJ);if(1===a.length&&"NONE"===c)return qL();c=a.map(d=>eK(d,ZJ));if(!c.every(d=>"SAMPLE-AES"===d)&&!c.every(d=>d===$J))throw vL.warn(`EXT-X-KEY methods ${c.join(", ")} are incompatible.`),new _.I(_.G,4,4044,"Multiple EXT-X-KEY tags with incompatible METHOD values.");a=a.map(d=>{const e=_.J(d,"KEYFORMAT","identity");{const f=wL[e]||null;d=f?f(d,b):null}d||vL.warn("Unsupported HLS KEYFORMAT",
24
+ e);return d}).filter(Boolean);if(0===a.length)throw new _.I(_.G,4,4026);return{keyId:a.map(d=>d.keyIds).reduce((d,e)=>d.concat(e),[]).reverse()[0]||null,type:dK,drmInfos:a}},qL=function(){return{type:_.De,drmInfos:[],keyId:null}},xL=function(a,b,c){a=jK(a,SJ)[0];if(!a||"AES-128"!==eK(a,ZJ))return null;var d=_.J(a,"IV","");d?c={iv:_.Pl((d||"0x").slice(2)),generatedIv:!1}:(d=_.J(a,"KEYFORMAT"),c=null==d||"identity"===d?{iv:_.Sl(new Uint8Array(12),eL(c)),generatedIv:!0}:{iv:null,generatedIv:!1});const {iv:e,
25
+ generatedIv:f}=c;return{method:"AES-128",url:_.ij(eK(a,_.ub),b),iv:e,generatedIv:f}},yL=function(a,b,c){return _.x(function*(){const d=b.f(),e=_.bD(b.Ea(),b.ma,b.ma+2048-1,a.a.attemptParameters);e.type=2;const f=_.bD(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.",
26
+ 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(_.G,4,4030,"Failed to fetch the media segment.");}}})},zL=function(a,b,c,d,e,f){return _.x(function*(){a.g.debug("Fetching segment to find start time");if("audio/mpeg"===d||d===_.Fc||d===_.Ec)return 0;if(d===_.Bc){var g=yield yL(a,c,f);g=_.K(g.data);if(!fL(g))throw new _.I(_.G,4,4030,"AAC segment does not contain an ID3 tag.");return gL(g)}if(d===_.rg||d===
27
+ _.Gc)return g=[yL(a,c,f)],b&&g.push(yL(a,b,!0)),g=yield Promise.all(g),hL(g[0].data,(g[1]||g[0]).data);if(d===_.qg)return g=yield yL(a,c,f),jL(g.data);if(!_.Ks(`${d.split("/")[0]||""}/mp4;codecs="${e}"`))return 0;throw new _.I(_.G,4,4030);})},AL=function(a,b){a=a.map(c=>c.streams[b]);return a.some(c=>null==c)?null:a},BL=function(a,b){a=a.streams.find(c=>{c=c.U;return c[0].position<=b&&b<=c[c.length-1].position});return null==a?null:a.U.find(c=>c.position===b)||null},HK=function(a){return a.streams[0]},
28
+ CL=function(a,b){a.streams.forEach(c=>{c.se=b})},DL=function(a,b){a.streams.forEach(c=>{c.width=b})},EL=function(a,b){a.streams.forEach(c=>{c.height=b})},FL=function(a,b){a.streams.forEach(c=>{c.frameRate=b})},GL=function(a,b){a.streams.forEach(c=>{c.bandwidth=b})},HL=function(a,b){a=a.map(c=>c.a[b]);return a.some(c=>null==c)?null:a},IL=function(a,b){const c=new Set(a.map(d=>d.ra));return b.filter(d=>!c.has(d.ra))},KL=function(a,b){for(;a[0].ra<b[0].ra;)a.splice(0,1);var c=a[0];let d=b[0];c.startTime===
29
+ d.startTime&&c.endTime===d.endTime||JL(c,d);const e=a.length-1;c=a[e];d=b[e];0<e&&(c.startTime!==d.startTime||c.endTime!==d.endTime)&&JL(c,d);for(c=e+1;c<b.length;)a.push(b[c]),c++},PL=function(a,b,c,d,e){var f=b[0].length();f=dL(f).map(g=>{var h=HL(b,g)||[];const k=AL(c,g)||[];g=AL(d,g)||[];{const l=[...LL(h),...k,...g].filter(Boolean);ML(l);const {ra:m,duration:n}=l[0];h={configurationId:a,variants:h,textStreams:k,thumbStreams:g,startTime:0,id:`P${m}`,endTime:n,duration:n,ra:m}}return h});e&&NL(f[0]);
30
+ OL(f);return f},LL=function(a){a=new Set(a.flatMap(b=>[b.video,b.audio]).filter(Boolean));return Array.from(a)},NL=function(a){const b=LL(a.variants)[0].U[0].Ca;a.startTime+=b;a.endTime+=b},OL=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}},JL=function(a,b){a.startTime=b.startTime;a.endTime=b.endTime;a.duration=b.duration;QL(a.variants,b.variants);RL(pK(a),pK(b))},QL=function(a,b){const c=new Map(a.map(d=>[FK(d),
31
+ d]));b.forEach(d=>{c.get(FK(d)).drmInfos=d.drmInfos})},RL=function(a,b){const c=new Map(a.map(d=>[d.Da,d]));b.forEach(d=>{const e=c.get(d.Da);e.U=d.U;d.U.forEach(f=>{f.initSegment=e.initSegmentReference});e.segmentIndex.replace(d.U);e.Vc=d.Vc;e.Le=d.Le;e.duration=d.duration;e.Tf=d.Tf;e.encrypted=d.encrypted;e.drmInfos=d.drmInfos;e.keyId=d.keyId})},ML=function(a){const b=SL(a);a.forEach(c=>{_.YC(c.segmentIndex,b);c.duration=b;c.Le=c.Vc+b})},SL=function(a){let b=Infinity;a.filter(sK).forEach(c=>{b=
32
+ Math.min(b,c.duration)});return b},TL=function(a,b){qK(b,(c,d)=>{_.kD(a,c.U,d.startTime)});_.cD(a.a,b[0].startTime,b[b.length-1].endTime)},UL=function(a){return null===a.o?[]:[a.o.audio,a.o.video].filter(b=>b).map(b=>b.Da)},VL=function(a,b){return _.x(function*(){var c=_.sj([b],a.a.attemptParameters);c.type=1;c=yield a.H(c);let d="";try{d=_.Si(c.data)}catch(e){throw new _.I(_.G,4,4042);}d=d.replace(/\r\n|\r(?=[^\n]|$)/gm,"\n");d=d.trim();return{text:d,response:c}})},fM=function(a,b){return _.x(function*(){var c=
33
+ WL(a,b,a.w,"");if(1===c.type){var d=c.U[0].a;c=XL(d);if(!c)throw new _.I(_.G,4,4021,`Unknown file extension ${d}`);d="";c===_.w?d="avc1.42E01E":c===_.p&&(d="mp4a.40.2");c=cL(a.R,a.w,a.a.hlsDefaultCodecs||d)}d=AK(c.ha);c=YL(d.Bc.Gf);c.forEach(m=>{a.J.add(m.groupId)});var e=yield ZL(a,d);var f=e.Xh;const g=e.periods;var h=e.li;const k=e.Ii;d=e.alternativeVariants;const l=e.alternativeTextStreams;e=e.alternativeImageStreams;if(!a.D)throw new _.I(_.G,7,7001);$L(a,g);h=aM(a,f.delay,g,h);bM(a)||(a.G=f.Jd,
34
+ cM(a));dM(a,h,g);f=eM(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})},hM=function(a,b){return Promise.all(b.map(c=>gM(a,c)))},jM=function(a,b){b.forEach(c=>{a:{var d=a.j.get(c.verbatimUri),e=!bM(a),f=nK(c.ha,"EXT-X-DISCONTINUITY-SEQUENCE");if(f)var g=Number(f.value);else{d?(f=d.streams[d.streams.length-1].U,f=f[f.length-1].ra):
35
+ f=0;if(e&&0<f)try{{const k=nK(c.ha,VJ);if(!k)throw iM.error("Failed to infer discontinuity number, because EXT-X-MEDIA-SEQUENCE tag is missing."),Error(XJ);const l=Number(k.value),m=BL(d,l);if(!m)throw iM.error("Failed to infer discontinuity number, could not find the appropriate segment in the previous playlist"+` (segment position = ${l})`),Error(XJ);var h=m.ra}g=h;break a}catch(k){throw new _.I(_.G,4,4024,"EXT-X-DISCONTINUITY-SEQUENCE tag is required for discontinuous HLS live streams.");}g=0}}c=
36
+ c.U||[];for(const k of c)mK(k.ha,RJ)&&g++,k.ra=g});mL(b)},mM=function(a,b){return _.x(function*(){const {textStreams:c,thumbStreams:d,ah:e}=yield kM(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=LK(g.audio,e),k=LK(g.video,e);g=lM(a,h,k,g.bandwidth);if(!g)throw new _.I(_.G,4,4047,{message:"Video and audio are encrypted in an incompatible way.",rj:k?HK(k).Da:void 0,audio:h?HK(h).Da:void 0});return g});return PL(a.D.configurationId,
37
+ f,c,d,!0)})},$L=function(a,b){bM(a)||2!==a.a.timeline.version||(a.I||(a.I=b[0].startTime),_.xE(b,-a.I))},nM=function(a,b){b=b.flatMap(d=>d.U[0].ha);b=nK(b,"EXT-X-PROGRAM-DATE-TIME");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},oM=function(a,b,c){b=b.find(d=>null!==nK(d.ha,QJ));if(!b)return[];if(null===c)throw new _.I(_.G,4,4024,"EXT-X-PROGRAM-DATE-TIME tag is required when EXT-X-DATERANGE tags are present");
38
+ return b.ha.filter(d=>d.name===QJ).map(d=>{a:{var e=a.C,f=!bM(a),g=_.J(d,"ID"),h=_.J(d,"START-DATE");if(null===g||null===h)_.nu.warn("Invalid EXT-X-DATERANGE missing mandatory ID or START-DATE attribute, ignoring the EXT-X-DATERANGE tag.",d),d=null;else{e=f?e-c:-c;var k=new Date(h);f=k.getTime()/1E3+e;g={id:g,startTime:f,startDate:k,pe:h};h=iK(_.J(d,PJ));void 0!==h&&0<=h&&(g.duration=h);var l=iK(_.J(d,"PLANNED-DURATION"));void 0!==l&&0<=l&&(g.plannedDuration=l);var m=_.J(d,"CLASS");null!==m&&(g.schemeIdUri=
39
+ m);var n=_.J(d,"END-DATE");n=n?new Date(n):null;null!==n&&n.getTime()>=k.getTime()&&(g.endDate=n);{const v=d.attributes;if(null==v)var q=null;else{k={};for(q of v)q.name.trim().startsWith("X-")&&(k[q.name]=q.value);q=_.ah(k)?k:null}}q=q||{};(k=_.J(d,"CUE"))&&(q.CUE=k.split(","));if(_.Bi(m)){k=d.attributes;if(null==k)var u=null;else{m={};for(u of k)switch(u.name){case _.Lb:m[_.Lb]=u.value;break;case _.Kb:m[_.Kb]=u.value;break;case _.Qb:m[_.Qb]=iK(u.value);break;case _.Mb:m[_.Mb]=iK(u.value);break;
40
+ case "X-SNAP":m["X-SNAP"]=u.value.split(",");break;case _.Nb:m[_.Nb]=u.value.split(",")}m[_.Lb]&&m[_.Kb]||!m[_.Lb]&&!m[_.Kb]?(_.nu.warn("Invalid EXT-X-DATERANGE Interstitial attributes X-ASSET-URI, X-ASSET-LIST"),u=null):u=_.ah(m)?m:null}if(null===u){_.nu.warn("Invalid interstitial attributes, ignoring the EXT-X-DATERANGE tag.",d);d=null;break a}q=Object.assign(q,u)}_.ah(q)&&(g.customAttributes=q);g.endTime=n?n.getTime()/1E3+e:h?f+h:l?f+l:f;g.type=_.Sh;d=g}}return d}).filter(Boolean)},eM=function(a,
41
+ 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.pe!==d.pe)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,pe:d.pe,endTime:d.endTime,id:d.id,type:_.Sh,eventElement:null};b&&!hK(b,e)||a.B.set(d.id,e)}return Array.from(a.B.values())},pM=function(a,b,
42
+ c){a.A=_.Db;_.gD(b,!0);b.f=c[c.length-1].endTime},WL=function(a,b,c,d){a=ZK(a.R,b,c);a.verbatimUri=d;return a},YL=function(a){return a.filter(b=>b.name===UJ&&_.J(b,_.sb)===_.uB&&!_.J(b,_.ub)).map(b=>{const c=MK(b),d=_.J(b,_.La)||_.fg;return{groupId:eK(b,_.Fa),id:_.xJ++,label:eK(b,_.Ta),language:d,channelsCount:c,primary:"YES"===_.J(b,"DEFAULT")}})},ZL=function(a,b){return _.x(function*(){var c=JK(b.Bc.closedCaptions),d=qM(a,b.Ld),e=yield rM(a,b),f=Object.values(e).flat().map(h=>h.playlist);jM(a,f);
43
+ f=f[0];var g=tK(f.ha);a.A=g;a.K=yK(f.ha);f=GK(f.ha,g,a.a.lowLatencyMode||!1,a.a.suggestedPresentationDelay,a.a.liveRefreshPeriod);g=yield sM(a,e.Hf,d);c=yield tM(a,e.Ld,g,c);d=yield uM(a,e.Fi,d);g=yield vM(a,e.He);d=PL(a.D.configurationId,c,d,g,!bM(a));a.D.filterAllPeriods(d);c=[...e.Ld,...e.Hf].map(h=>h.playlist);e=nM(a,c);c=oM(a,c,e);return{periods:d,li:e,Ii:c,Xh:f}})},aM=function(a,b,c,d){let e=!0,f=null,g=0;bM(a)||(e=!1,f=0,g=b);b=a.a.timeline||{};b.type=void 0;a=new _.AJ(b,f,g,!0,void 0,!!a.a.lowLatencyMode);
44
+ _.gD(a,e);TL(a,c);d&&_.fD(a,d);return a},cM=function(a){var b=0;for(var c of a.j.values())b=Math.max(b,c.streams[0].Vc);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.Vc?(a.g.debug("Offset applied to",b.type),b.segmentIndex.offset(c)):a.g.debug("Offset NOT applied to",b.type)}},dM=function(a,b,c){c=EK(c);"LIVE"===a.A||"EVENT"===a.A?(c=Math.max(c,
45
+ b.J),isNaN(a.a.availabilityWindowOverride)||(c=a.a.availabilityWindowOverride),b.A=c):a.A===_.Db&&(b.f=c)},kM=function(a,b){return _.x(function*(){const c=g=>HK(g.stream).type===_.w||HK(g.stream).type===_.p;var d=b.filter(c),e=b.filter(g=>!c(g)),f=g=>{g=g.map(h=>{var k=HK(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,
46
+ Md:{width:k.width,height:k.height,frameRate:k.frameRate}};h=Object.assign({},{playlist:h.playlist},k);return wM(a,h)});return Promise.all(g)};d=yield f(d);f=yield f(e);xM(a,d.concat(f));e=f.filter(g=>HK(g).type===_.$B);f=f.filter(g=>HK(g).type===_.ce);return{textStreams:e,thumbStreams:f,ah:d}})},lM=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?_.AC(l.drmInfos,m.drmInfos)?_.zC(l.drmInfos,m.drmInfos):
47
+ null:l?l.drmInfos:m?m.drmInfos:null;if(!l)return null;m=d;h={id:e?e:a.h++,language:h?h.language:_.fg,primary:!!h&&h.primary||!!k&&k.primary,audio:h,video:k,bandwidth:m,drmInfos:l,allowedByApplication:!0,allowedByKeySystem:!0};f.push(h)}return new yM(f)},wM=function(a,b){return _.x(function*(){const c=b.playlist,d=b.codecs,e=b.type,f=b.Tc,g=b.ic,h=b.groupId,k=b.muxedAudioId,l=b.primary;var m=b.kind;const n=b.name,q=b.channelsCount,u=b.spatialAudio,v=b.closedCaptions,y=b.Md,A=_.Di(f||_.fg);if(1!==c.type)throw new _.I(_.G,
48
+ 4,4017);const D=yield zM(a,c,e,d),E=a.a.lowLatencyMode?_.RB:_.QB;let oa=m;e!==_.H||m||(oa=_.$B);const te=tK(c.ha);m=D.map(ic=>{const Ob=ic.U,Xd=ic.nh,Pb=ic.mimeType,jc=ic.ra,kc=Ob[0].startTime,Gb=Ob[Ob.length-1].endTime,hb=Gb-kc,ua=new _.BJ(Ob),zb=Ob[0].initSegment||null;return{id:null===g?_.xJ++:g,originalId:n,createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:ua.f.bind(ua),getSegmentReference:ua.get.bind(ua),adjustSegmentDurations:ua.h.bind(ua),getDuration:ua.getDuration.bind(ua),
49
+ segmentIndex:ua,segmentLookupStrategy:E,initSegmentReference:zb,mimeType:Pb,codecs:d,kind:oa,Tf:Xd.type,encrypted:Xd.type===dK,aesEncrypted:ic.aesEncrypted,keyId:Xd.keyId,language:A,originalLanguage:f||_.fg,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:q,spatialAudio:u,closedCaptions:v,U:Ob,drmInfos:Xd.drmInfos,ra:jc,Da:c.verbatimUri,se:c.a,Vc:kc,Le:Gb,duration:hb,
50
+ groupId:h,ij:te,muxedAudioId:k}});return new AM(m)})},xM=function(a,b){b.forEach(c=>{a.j.a.set(HK(c).Da,c)})},qM=function(a,b){const c=new Map;for(const f of b){var d=_.J(f,_.uB);b=_.J(f,_.Cb);var e=_.J(f,aK);const g=BM(a,f);if(e){const h=_.dk(_.H,g);c.set(`${_.H}:${e}`,h);e=g.indexOf(h);-1<e&&g.splice(e,1)}d&&(e=CM(_.p,g),c.set(`${"audio"}:${d}`,e));b&&(d=CM(_.w,g),c.set(`${"video"}:${b}`,d))}return c},rM=function(a,b){return _.x(function*(){const c=yield Promise.all([DM(a,b.Bc.Gf),DM(a,b.Bc.Gi),
51
+ DM(a,b.Ld),DM(a,b.He)]),[d,e,f,g]=c;return{Hf:d,Fi:e,Ld:f,He:g}})},sM=function(a,b,c){return _.x(function*(){if(0===b.length)return new Map;var d=[EM(a,b[0],c)];yield d[0];d=d.concat(b.slice(1).map(e=>EM(a,e,c)));d=yield Promise.all(d);return IK(d)})},tM=function(a,b,c,d){return _.x(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(eK(f[k].tag,_.la));l<h&&(h=l,g=k)}h=f.splice(g,1).pop();h=yield FM(a,h,c,d,e);f=f.map(k=>FM(a,k,c,d,e));f=yield Promise.all(f);
52
+ f.splice(g,0,h);return f.reduce(_.rC,[])})},uM=function(a,b,c){return Promise.all(b.map(d=>EM(a,d,c)))},vM=function(a,b){return Promise.all(b.map(c=>GM(a,c)))},HM=function(a,b){return _.x(function*(){const c=_.ij(b.verbatimUri,a.w),{response:d,text:e}=yield VL(a,c);return WL(a,e,d.uri,b.verbatimUri)})},IM=function(a,b,c){return _.x(function*(){const d=yield wM(a,{playlist:c,codecs:b.codecs,type:b.type,Tc:b.originalLanguage,ic:b.id,groupId:b.groupId,primary:b.primary,kind:b.kind||null,name:b.label,
53
+ channelsCount:b.channelsCount,spatialAudio:b.spatialAudio||!1,closedCaptions:b.closedCaptions,Md:{width:b.width,height:b.height,frameRate:b.frameRate}});b.bandwidth&&GL(d,b.bandwidth);return d})},bM=function(a){return a.A===_.Db},DM=function(a,b){return _.x(function*(){return(yield Promise.all(b.map(c=>_.x(function*(){const d=yield JM(a,c);return d?{tag:c,playlist:d}:null})))).filter(Boolean)})},gM=function(a,b){return _.x(function*(){var c=new _.oi(HK(b).se);if(a.a.lowLatencyMode&&a.K&&a.K.Lf){var d=
54
+ b.streams[b.streams.length-1].segmentIndex;if(d=d.a[d.a.length-1]){var e=d.a,f=e.length-1;d={Yh:d.position,ei:e&&0<e.length?f:null}}else d=null;if(e=d)d=e.Yh,e=e.ei,f=_.hj(c.a.toString()),f._HLS_msn=d.toString(),null===e&&f._HLS_part&&delete f._HLS_part,null!==e&&(f._HLS_part=e.toString()),d=_.gj(f,!0),d=new _.vi(d),_.ri(c,d)}const {response:g,text:h}=yield VL(a,c.toString());c=HK(b).Da;d=HK(b).se;e=g.uri;d!==e&&(d=e,CL(b,d));c=WL(a,h,d,c);return{stream:b,playlist:c}})},BM=function(a,b){var c=_.J(b,
55
+ _.pa,a.a.hlsDefaultCodecs||"avc1.42E01E,mp4a.40.2").split(/\s*,\s*/);c=KK(c);b=new Set;const d=[];for(const e of c)c=_.GC(e),b.has(c)?a.g.debug("Ignoring duplicate codec"):(d.push(e),b.add(c));return d},CM=function(a,b){if(1===b.length)return b[0];a=_.dk(a,b);if(null!=a)return a;throw new _.I(_.G,4,4025,{codecList:b});},EM=function(a,b,c){return _.x(function*(){const d=b.tag,e=b.playlist;return KM(a,e.verbatimUri,()=>_.x(function*(){const f=eK(d,_.Fa),g=uK(eK(d,_.sb));var h=eK(d,_.sb).toUpperCase();
56
+ if(uK(h)!==_.H)h=null;else{var k=d.getAttribute("FORCED");k=!(!k||!k.value||"YES"!==k.value.toUpperCase());var l=_.$B;h===NJ&&(l=_.MB);k&&(l=_.Ud);h=l}k=c.get(`${g}:${f}`)||"";l=_.J(d,_.La);const m=_.J(d,_.Ta),n=_.J(d,"DEFAULT"),q=g===_.p?MK(d):null;var u=g===_.p?(u=_.J(d,"CHANNELS"))?u.includes("/JOC"):!1:!1;return yield wM(a,{playlist:e,codecs:k,type:g,Tc:l,primary:"YES"===n,name:m,channelsCount:q,spatialAudio:u,groupId:f,kind:h,ic:null,closedCaptions:null,Md:null})}))})},GM=function(a,b){return _.x(function*(){const c=
57
+ b.tag,d=b.playlist;return KM(a,d.verbatimUri,()=>_.x(function*(){var e=_.J(c,_.pa)||"jpg",f=_.J(c,_.La);const g=_.J(c,_.Ta);e=yield wM(a,{playlist:d,codecs:e,type:_.ce,Tc:f,name:g,primary:!1,kind:null,channelsCount:null,spatialAudio:!1,closedCaptions:null,ic:null,groupId:null,Md:null});(f=_.J(c,_.la))&&GL(e,Number(f));return e}))})},FM=function(a,b,c,d,e){return _.x(function*(){var f=b.tag,g=Number(eK(f,_.la));if(f.hasAttribute("FRAME-RATE")||f.hasAttribute(_.lb)){var h=_.J(f,"FRAME-RATE");f=_.J(f,
58
+ _.lb);var [k,l]=f?f.split("x"):[null,null];h={frameRate:iK(h),width:iK(k),height:iK(l)}}else h=null;if(f=yield LM(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 q of h){m=(q?HK(q).Da:"")+" - "+(n?HK(n).Da:"");if(e.has(m)){a.g.debug("Skipping variant which only differs in text streams.");continue}const u=lM(a,n,q,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})},MM=function(a,
59
+ b,c,d,e,f){let g=BM(a,b);a.g.debug("Guessing stream type for",b.toString());b=!1;const h=_.dk(_.w,g),k=d+e;1!==g.length||c||h?!k&&1<g.length?(a.g.debug("Guessing multiplexed audio+video"),c=_.w,g=[g.join(",")]):d&&f?(a.g.debug(YJ),c=_.p,b=!0):e?(a.g.debug(YJ),c=_.p):(a.g.debug("Guessing video-only"),c=_.w):(c=_.p,a.g.debug(YJ));return{type:c,Zg:g,Oh:b}},KM=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},LM=
60
+ function(a,b,c,d,e){return _.x(function*(){var f=b.tag,g=b.playlist,h=_.J(f,_.uB),k=_.J(f,_.Cb);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=>HK(u).Da===l);const {type:m,Zg:n,Oh:q}=MM(a,f,c,k.audio.length,k.video.length,g);f=null;q||(f=yield NM(a,b,n,m,e,c));if(null==f)return null;k[m]=[f];m===_.p&&c&&k.video.forEach(u=>{DL(u,c.width);EL(u,c.height);FL(u,c.frameRate)});return k})},NM=function(a,b,c,d,e,f){return _.x(function*(){const g=
61
+ b.tag,h=b.playlist;return KM(a,h.verbatimUri,()=>_.x(function*(){var k=_.J(g,NJ);let l=null;d===_.w&&k&&"NONE"!==k&&(l=e.get(k));k=(k=_.J(g,_.uB)||void 0)&&a.J.has(k)?k:void 0;var m=CM(d,c);if(k){const n=CM(_.p,c);m+=`,${n}`}return yield wM(a,{playlist:h,codecs:m,type:d,closedCaptions:l,primary:!1,kind:null,Tc:null,name:null,channelsCount:null,spatialAudio:!1,ic:null,groupId:null,muxedAudioId:k,Md:f})}))})},zM=function(a,b,c,d){return _.x(function*(){var e=b.verbatimUri,f=b.U;var g=void 0===g?0:g;
62
+ var h=(h=nK(b.ha,VJ))?Number(h.value):g;g=[];e=yield OM(a,b.a,e,f,h,c,d);if(0===f.length)f=[];else{var k=[],l=[];for(var m of f)mK(m.ha,RJ)&&0<l.length&&(k.push(l),l=[]),l.push(m);k.push(l);f=k}for(m=0;m<f.length;m++)k=f[m],l=yield PM(a,b.a,k,h,e,c,d,g[g.length-1]||null),g.push(l),h+=k.length;QM(g);return g})},JM=function(a,b){return _.x(function*(){var c=b.name!==UJ?!0:_.J(b,_.sb)===aK;c=_.J(b,_.ub,void 0,{required:c});if(!c)return null;const d=_.ij(c,a.w),e=Date.now(),{response:f,text:g}=yield VL(a,
63
+ d);a.D.onEvent(new _.F(cK,{detail:{duration:Date.now()-e,type:"media"}}));return WL(a,g,f.uri,c)})},QM=function(a){if(1<(new Set(a.map(b=>b.mimeType))).size)throw new _.I(_.G,4,4045,"Media playlist contains discontinuities with different MIME types. This is valid, but not yet supported.");},RM=function(a){a=a.map(b=>b.a?b.a:b.f.map(c=>_.J(c,_.ub))||null).map(b=>_.mu(b));if(1<(new Set(a)).size)throw new _.I(_.G,4,4044,"Unexpected change in file format.");},SM=function(a,b,c){a=jK(a.ha,TJ);if(1<a.length)throw new _.I(_.G,
64
+ 4,4020);a=a[0];if(!a)return null;const d=eK(a,_.ub),e=_.ij(d,b);b=zK(a,null,!0);return new _.wJ(()=>[e],b.ma,b.ja,c)},TM=function(a,b,c,d,e,f,g){const h=[];for(const q of NK(b.f)){b=q.fg;const u=q.item;{var k=0===b,l=k?a:h[h.length-1],m=k?d:l.endTime,n=Number(_.J(u,PJ));n=m+n;k=zK(u,k?null:l.ja,k);l=_.J(u,_.ub);const v=(l=_.ij(l,g))?[l]:[];m=new BK(c,m,n,()=>v,k.ma,k.ja,e,f,!1,null,null,null,null);if("YES"===_.J(u,"INDEPENDENT")||0===b)m.h=!0;h.push(m)}}return h},UM=function(a,b,c,d,e,f,g,h,k,l,m){const n=
65
+ c.ha;var q=c.a;0<jK(n,TJ).length&&(m=SM(c,k,g));const u=null!=q,v=q?[q]:[];if(!u&&!a.a.lowLatencyMode)return null;a=0;q={ma:0,ja:null};let y=null;u?({duration:c}=xK(n),a=e+c,q=wK(n,b?b.ja:null)):(b=TM(b,c,d,e,f,g,k),a=b[b.length-1].endTime,y=b);h=h===_.ce?oK(n):null;d=new BK(d,e,a,()=>v,q.ma,q.ja,f,g,!1,null,h?h.nd:null,h?h.Kd:null,h?h.durationPerTile:null,y,m);d.ra=l;return d},OM=function(a,b,c,d,e,f,g){return _.x(function*(){var h=d[0];if(null!=a.C)return a.C;if(!bM(a)&&a.f)try{var k=a.j.get(c);
66
+ var l=k?BL(k,e)||null:null;if(!l)throw new _.I(_.G,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].U,m=m[m.length-1],a.g.warn(`Last #EXT-X-MEDIA-SEQUENCE values ${h.streams[0].U[0].position} - ${m.position}`+`, new values ${e} - ${e+d.length-1}.`,b,h);throw new _.I(_.G,4,4047,{message:"The updated playlist does not share any segments with the previous one.",
67
+ uri:c});}m=yield VM(a,f,g,h);l=xL(h.ha,a.w,e);k=SM(h,b,l);h=yield WM(a,k,h,l,m,g);a.g.debug(`Setting playlist start time to ${h}.`);return a.C=h})},PM=function(a,b,c,d,e,f,g,h){return _.x(function*(){var k=c[0],l=null==h;RM(c);const m=yield VM(a,f,g,k);var n=h?h.Vh:null;if(mK(c[0].ha,SJ)||null===n)n=uL(c,m),n=0===n.length?[qL()]:n;else{var q=uL(c,m);n=[n,...q]}q=n;n=q[q.length-1];q=rL(q);let u=h?h.Wh:null;var v=XM(u,k.ha,a.w,d);let y=SM(k,b,v)||(h?h.Ph:null);const A=k.ra;k=l?e:yield YM(a,A,y,k,d,
68
+ v,m,g);l=[];v=!1;for(let E=0;E<c.length;E++){var D=c[E];const oa=l[l.length-1]||null,te=0===E?0:oa.endTime,ic=d+E,Ob=XM(u,D.ha,a.w,ic);(u=Ob)&&(v=!0);if(D=UM(a,oa,D,ic,te,k,Ob,f,b,A,y))y=D.initSegment,l.push(D)}return{U:l,nh:q,Vh:n,aesEncrypted:v,mimeType:m,endTime:l[l.length-1].endTime,ra:A,Ph:y,Wh:u}})},VM=function(a,b,c,d){return _.x(function*(){const e=d.a;var f=nK(d.ha,TJ);f=f?eK(f,_.ub):null;return ZM(a,b,c,e,f)})},WM=function(a,b,c,d,e,f){return _.x(function*(){if(null==c.a)return 0;const g=
69
+ CK(c,d);return zL(a.S,b,g,e,f,null!=d)})},XM=function(a,b,c,d){return b.some(e=>e.name===SJ&&"NONE"===_.J(e,ZJ))?null:(b=xL(b,c,d))?b:a&&a.generatedIv?Object.assign({},a,{iv:_.Sl(new Uint8Array(12),eL(d))}):a},YM=function(a,b,c,d,e,f,g,h){return _.x(function*(){if(a.L.has(b))return a.L.get(b);const k=yield WM(a,c,d,f,g,h);a.g.debug(`Segment #${e} has raw media timestamp `+`${k} s.`);a.L.set(b,k);return k})},ZM=function(a,b,c,d,e){return _.x(function*(){const f=[d,e].filter(Boolean);var g=_.gk(f,b,
70
+ c);if(g)return g;g=_.sj([d],a.a.attemptParameters);g.method="HEAD";g.type=2;g=(yield a.H(g)).headers["content-type"];if(!g)throw new _.I(_.G,4,4021,"Unknown MIME type of: "+f.join(", "));return g.toLowerCase().split(";")[0]})},XL=a=>{a=_.mu(a)||"";return null!=_.lu.video[a]?_.w:null!=_.lu.audio[a]?_.p:null},TK=class{constructor(a,b,c,d){if(1===b){if(!d||0===d.length)throw new _.I(_.G,4,4043,"Media playlist must have at least one segment!");if(null==d[0].a)throw new _.I(_.G,4,4043,"Media playlist must have at least one full segment!");
71
+ }this.a=a;this.verbatimUri="";this.type=b;this.ha=c;this.U=1===b?d:null}},bL=class{constructor(a,b,c){c=void 0===c?[]:c;this.ha=b;this.a=a;this.f=c;this.ra=-1}},BK=class extends _.wD{constructor(a,b,c,d,e,f,g,h,k,l,m,n,q,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===q?null:q,u,void 0===v?null:v);this.ra=0}},$K=/^#EXT-X-DEFINE/,aL=/^#(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)/,
72
+ $M=class{constructor(){this.h=0;this.a=new Map}},aN=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()}},iM=new _.T("clpp.hls.DiscontinuityUtils");var wL={"com.apple.streamingkeydelivery":function(a,b){if(b===_.qg)throw new _.I(_.G,4,4041);if(eK(a,ZJ)===$J)throw new _.I(_.G,4,4044,"EXT-X-KEY:METHOD SAMPLE-AES-CTR is not supported in FairPlay.");return _.uC(_.pd,[{initDataType:_.If,initData:new Uint8Array(0)}],"")},"com.microsoft.playready":pL,"urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":pL,"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":function(a){var b=eK(a,ZJ);if(!nL.includes(b))return oL.error("Widevine in HLS is only supported with [",
73
+ nL.join(", "),"], not",b),null;b=eK(a,_.ub);b=_.zt(b);b=_.K(b.data);b=_.uC(_.td,[{initDataType:_.Uc,initData:b}],"");if(a=_.J(a,"KEYID"))b.keyIds=[a.substr(2).toLowerCase()];return b}},nL=["SAMPLE-AES",$J],oL=new _.T("clpp.hls.DrmParser");var vL=new _.T("clpp.hls.EncryptionUtils");var bN=class{constructor(a){this.g=new _.T("clpp.hls.MediaReader");this.f=a;this.a={attemptParameters:_.oj()}}};var AM=class{constructor(a){this.streams=a}length(){return this.streams.length}};var yM=class{constructor(a){this.a=a}length(){return this.a.length}};var cN=class{constructor(){this.a=this.D=null;this.h=1;this.j=new aN;this.w="";this.R=new $M;this.G=0;this.o=null;this.l=new _.wk(()=>{this.Vb()});this.A=_.Db;this.f=null;this.F=new _.pu;this.K=this.C=null;this.g=new _.T("clpp.hls.HlsParser");this.L=new Map;this.S=new bN(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.S.a=a}setCurrentVariant(a){this.o=a}start(a,b){const c=this;return _.x(function*(){if(c.P)throw Error("start() may be called only once!");
74
+ c.P=!0;c.D=b;var d=Date.now();const {response:e,text:f}=yield VL(c,a);c.D.onEvent(new _.F(cK,{detail:{duration:Date.now()-d,type:"master"}}));c.w=e.uri;d=yield fM(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 _.x(function*(){const b=a.f;if(!bM(a)&&
75
+ 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=UL(a);d=d.filter(h=>g.includes(HK(h).Da))}var e=yield hM(a,d);d=e.map(g=>g.playlist);jM(a,d);e=yield mM(a,e);IL(b.periods,e).forEach(g=>{a.D.filterNewPeriod(g)});$L(a,e);var f=nM(a,d);f=oM(a,d,f);b.cues=eM(a,f);KL(b.periods,e);TL(c,e);if(d=rK(d))!0!==a.a.keepTimelineLive&&pM(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();
76
+ a.M&&(yield a.stop());return b}})}loadVariant(a,b){const c=this;return _.x(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 _.li(`No alternative variant with id: ${d}`);var f=null,g=null;if(e.audio){const k=e.audio;f=KM(c,k.verbatimUri,()=>_.x(function*(){const l=yield HM(c,k);return IM(c,k,l)}))}if(e.video){const k=e.video;g=KM(c,k.verbatimUri,()=>_.x(function*(){const l=yield HM(c,
77
+ k);return IM(c,k,l)}))}f=yield f;g=yield g;e=lM(c,f,g,e.bandwidth,e.id);let h;e&&(e=PL(c.D.configurationId,[e],[],[],!bM(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 _.li(`Could load variant with id: ${d}`);return h})}loadTextStream(a,b){const c=this;return _.x(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=
78
+ c.f.alternativeTextStreams.find(h=>h.id===a)||null;if(!f)throw new _.li(`Could not load text stream with id: ${a}`);const g=yield KM(c,f.verbatimUri,()=>_.x(function*(){const h=yield HM(c,f);return IM(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 _.li(`Could not load text stream with id: ${a}`);return d})}Vb(){const a=this;return _.x(function*(){a.g.debug(_.GB);if(a.D)try{yield a.update(),a.l&&0<a.G&&a.l.la(a.G)}catch(b){if(!(b instanceof
79
+ _.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(_.G,7,7001);a=this.D.networkingEngine.fetch(a);_.Bj(this.F,a);return a.T}};_.z("clpp.hls.HlsComponent",class extends _.Dv{f(){_.dt.m3u8=cN;_.bt[_.pl]=cN;_.bt[bK]=cN}a(){_.VD("m3u8");_.WD(_.pl);_.WD(bK)}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 EU=function(a){a.a.one(a.m,_.le,()=>DU(a))},DU=function(a){const b=a.m.getSurface().getMedia();if(b)if(a.h){a.a.on(b.textTracks,_.nc,d=>FU(a,d));var c=Array.from(b.textTracks);c.filter(d=>d.kind===_.se).forEach(d=>{FU(a,{track:d})});!GU(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."),HU(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.")},FU=function(a,b){b=b.track;b.kind===_.se&&(a.g.info("The metadata track has been added."),b.mode=_.$d,a.a.on(b,_.yd,c=>IU(a,c)))},GU=function(a){return a.some(b=>b.kind===_.se)},HU=function(a,b){const c=a.m.getTrackManager(),d=c.qa(),e=c.getAudioTracks().find(g=>g!==d);if(e){var f=()=>c.xa(d);a.a.on(b.textTracks,_.nc,g=>{g.track.kind===_.se&&(a.a.off(b.textTracks,_.nc,f),c.xa(d))});c.xa(e)}else a.g.warn("Can't enforce the creation of the metadata track if single audio track. Skipping.")},
3
- IU=function(a,b){const c=JU(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 KU(d);if(e.f===c&&null!==e.a){a.f=d;d=a.h.parseMedia(_.Yi(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)}}})},JU=function(a){return(a=a.m.getTrackManager().wa())&&a.language&&a.language.toLowerCase()},
4
- KU=class{constructor(a){this.startTime=a.startTime;this.endTime=a.endTime;this.a=this.f=null;a=a.value;if(!_.B(a)){a:{var b=a.info;if(_.ch(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=_.ch(a)?a:null}}};var LU=class{constructor(a,b,c){this.m=a;this.l=b;this.j=c;this.a=new _.Nt;this.h=(a=_.zt(_.xc))?new a(this.m.getConfiguration()):null;this.g=new _.S("clpp.hlssmpte.ImageCueHandler");this.f=null;EU(this)}destroy(){this.a.release();this.f=null;return Promise.resolve()}};var MU=class extends _.Pv{constructor(){super();this.a=null;this.f=!1}onPlayerCreated(){}onContentWillLoad(a){if(this.f=_.Fk()){var b=a.getConfiguration();b=_.Xg(b.hlssmpte||{});typeof b.patchMetadataTrack!==_.Lc&&(b.patchMetadataTrack=!1);_.dh(b.timestampOffset)||(b.timestampOffset=0);this.a=new LU(a,b.patchMetadataTrack,b.timestampOffset)}}onPlayerWillDestroy(){const a=this;return _.x(function*(){a.a&&(yield a.a.destroy(),a.a=null)})}id(){return"hlssmpte"}};_.z("clpp.hlssmpte.HlsSmptePlugin",MU);
5
- MU.Id="hlssmpte";_.Ir(new class{create(){return new MU}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var SU=function(a){a.a.one(a.m,_.me,()=>RU(a))},RU=function(a){const b=a.m.getSurface().getMedia();if(b)if(a.h){a.a.on(b.textTracks,_.oc,d=>TU(a,d));var c=Array.from(b.textTracks);c.filter(d=>d.kind===_.ue).forEach(d=>{TU(a,{track:d})});!UU(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."),VU(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.")},TU=function(a,b){b=b.track;b.kind===_.ue&&(a.g.info("The metadata track has been added."),b.mode=_.$d,a.a.on(b,_.yd,c=>WU(a,c)))},UU=function(a){return a.some(b=>b.kind===_.ue)},VU=function(a,b){const c=a.m.getTrackManager(),d=c.oa(),e=c.getAudioTracks().find(g=>g!==d);if(e){var f=()=>c.ya(d);a.a.on(b.textTracks,_.oc,g=>{g.track.kind===_.ue&&(a.a.off(b.textTracks,_.oc,f),c.ya(d))});c.ya(e)}else a.g.warn("Can't enforce the creation of the metadata track if single audio track. Skipping.")},
3
+ WU=function(a,b){const c=XU(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 YU(d);if(e.f===c&&null!==e.a){a.f=d;d=a.h.parseMedia(_.Wi(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)}}})},XU=function(a){return(a=a.m.getTrackManager().ta())&&a.language&&a.language.toLowerCase()},
4
+ YU=class{constructor(a){this.startTime=a.startTime;this.endTime=a.endTime;this.a=this.f=null;a=a.value;if(!_.B(a)){a:{var b=a.info;if(_.eh(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=_.eh(a)?a:null}}};var ZU=class{constructor(a,b,c){this.m=a;this.l=b;this.j=c;this.a=new _.Rt;this.h=(a=_.Dt(_.yc))?new a(this.m.getConfiguration()):null;this.g=new _.T("clpp.hlssmpte.ImageCueHandler");this.f=null;SU(this)}destroy(){this.a.release();this.f=null;return Promise.resolve()}};var $U=class extends _.Sv{constructor(){super();this.a=null;this.f=!1}onPlayerCreated(){}onContentWillLoad(a){if(this.f=_.Kk()){var b=a.getConfiguration();b=_.Zg(b.hlssmpte||{});typeof b.patchMetadataTrack!==_.Mc&&(b.patchMetadataTrack=!1);_.fh(b.timestampOffset)||(b.timestampOffset=0);this.a=new ZU(a,b.patchMetadataTrack,b.timestampOffset)}}onPlayerWillDestroy(){const a=this;return _.x(function*(){a.a&&(yield a.a.destroy(),a.a=null)})}id(){return"hlssmpte"}};_.z("clpp.hlssmpte.HlsSmptePlugin",$U);
5
+ $U.Id="hlssmpte";_.Mr(new class{create(){return new $U}});};f.call(g, window);