@castlabs/prestoplay 6.23.1 → 6.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/cjs/cl.adobe.js +3 -3
  3. package/cjs/cl.airplay.js +3 -3
  4. package/cjs/cl.broadpeak.js +7 -7
  5. package/cjs/cl.cast.js +116 -116
  6. package/cjs/cl.conviva.js +32 -32
  7. package/cjs/cl.core.js +607 -591
  8. package/cjs/cl.crypto.js +9 -9
  9. package/cjs/cl.dash.js +88 -86
  10. package/cjs/cl.externs.js +105 -54
  11. package/cjs/cl.freewheel.js +25 -24
  12. package/cjs/cl.hls.js +77 -71
  13. package/cjs/cl.hlssmpte.js +6 -6
  14. package/cjs/cl.htmlcue.js +30 -30
  15. package/cjs/cl.ima.js +24 -23
  16. package/cjs/cl.mse.js +352 -342
  17. package/cjs/cl.muxdata.js +15 -15
  18. package/cjs/cl.onboard.js +3 -3
  19. package/cjs/cl.persistent.js +15 -14
  20. package/cjs/cl.playlist.js +6 -6
  21. package/cjs/cl.sessions.js +16 -16
  22. package/cjs/cl.simid.js +15 -15
  23. package/cjs/cl.smooth.js +72 -72
  24. package/cjs/cl.thumbnails.js +26 -26
  25. package/cjs/cl.tizen.js +72 -72
  26. package/cjs/cl.ttml.js +29 -29
  27. package/cjs/cl.verimatrix.js +5 -5
  28. package/cjs/cl.vimond.js +12 -12
  29. package/cjs/cl.vr.js +19 -19
  30. package/cjs/cl.vtt.js +14 -14
  31. package/cjs/cl.yospace.js +4 -4
  32. package/cjs/cl.youbora.js +37 -37
  33. package/cl.adobe.js +3 -3
  34. package/cl.airplay.js +3 -3
  35. package/cl.broadpeak.js +5 -5
  36. package/cl.cast.js +88 -88
  37. package/cl.conviva.js +27 -27
  38. package/cl.core.js +491 -478
  39. package/cl.crypto.js +9 -9
  40. package/cl.dash.js +82 -80
  41. package/cl.externs.js +105 -54
  42. package/cl.freewheel.js +19 -19
  43. package/cl.hls.js +79 -74
  44. package/cl.hlssmpte.js +5 -5
  45. package/cl.htmlcue.js +26 -26
  46. package/cl.ima.js +18 -17
  47. package/cl.mse.js +310 -306
  48. package/cl.muxdata.js +13 -13
  49. package/cl.onboard.js +4 -4
  50. package/cl.persistent.js +10 -10
  51. package/cl.playlist.js +5 -5
  52. package/cl.sessions.js +10 -10
  53. package/cl.simid.js +13 -13
  54. package/cl.smooth.js +60 -59
  55. package/cl.thumbnails.js +19 -19
  56. package/cl.tizen.js +57 -57
  57. package/cl.ttml.js +22 -22
  58. package/cl.verimatrix.js +4 -4
  59. package/cl.vimond.js +8 -8
  60. package/cl.vr.js +14 -14
  61. package/cl.vtt.js +12 -12
  62. package/cl.yospace.js +3 -3
  63. package/cl.youbora.js +28 -28
  64. package/package.json +1 -1
  65. package/typings.d.ts +54 -25
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 AU="clpp-freewheel",BU="clpp.freewheel.AdsManagerFactory",CU="freewheel",DU=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""}},EU=function(a){const b=[];typeof a.networkId!==_.t&&b.push("networkId");typeof a.serverUrl!==_.Vf&&b.push("serverUrl");typeof a.profileId!==_.Vf&&b.push("profileId");typeof a.videoAssetId!==_.Vf&&typeof a.videoAssetId!==_.t&&b.push("videoAssetId");
2
- if(b.length)throw new _.H(1,9,12001,{missingKeys:b.join(", ")});},FU=function(){return _.x(function*(){var a=new _.xv;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})},GU=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,_.bg,a.I.bind(a));a.j.on(a.m,_.Sf,a.H.bind(a))},JU=function(a){return _.x(function*(){a.G.length?(HU(a),a.f=a.G.shift(),a.f.play()):(IU(a),yield a.m.a.play())})},IU=function(a){const b=a.m.Zc(CU).Gc();b&&a.m.getSurface().hide(b);a.m.getSurface().showMediaElement()},HU=function(a){const b=a.m.Zc(CU).Gc();b&&(a.m.getSurface().show(b),a.m.getSurface().hideMediaElement(),a.a.registerVideoDisplayBase(AU),
4
- a.m.isMuted()?a.setVolume(0):a.setVolume(a.m.getVolume()||1))},KU=function(a){a.F.length?(HU(a),a.f=a.F.shift(),a.f.play()):IU(a)},LU=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 _.E(b,d))},MU=class extends _.Fv{constructor(){super();this.f=this.a=null}onPlayerCreated(a){if(window.tv&&tv.freewheel&&tv.freewheel.SDK)this.a=_.vp(_.Ld,{id:AU}),this.f=_.vp(_.w,{"class":_.id}),this.a.appendChild(this.f),a.getSurface().addElementToContainer(this.a,
5
- !0),a.getSurface().hide(this.a);else a.onError(new _.H(1,9,12E3))}onPlayerWillDestroy(a){this.a&&(a.getSurface().removeElementFromContainer(this.a),this.f=this.a=null)}id(){return CU}Gc(){return this.a}dh(){return this.f}};_.z("clpp.freewheel.FreeWheelPlugin",MU);MU.prototype.getAdVideo=MU.prototype.dh;MU.prototype.getAdContainer=MU.prototype.Gc;MU.Id=CU;MU.AD_CONTAINER_ID=AU;_.ur(new class{create(){return new MU}});var Y=class{constructor(a,b,c){this.h=a;this.f=b;this.a=c}lb(){return"FreeWheel AdManager SDK"}nb(){return tv.freewheel.SDK.version}qb(){return 0}getId(){return this.a?this.a.getAdId():""}getCreativeId(){const a=(this.a||{})._creativeId;return typeof a===_.Vf?a:""}Nb(){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}Qb(){return!1}ob(){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():""}bb(){return this.a?this.a.getActiveCreativeRendition().getWidth():0}ab(){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}Cb(){switch(this.Ra()){case 0:return 0;case 2:return-1;default:return this.f.getTimePosition()}}Db(){return this.a?this.f.getAdInstances().indexOf(this.a)+1:1}cb(){return this.f.getAdCount()}getWrapperAdIds(){return[]}getWrapperAdSystems(){return[]}getWrapperCreativeIds(){return[]}Pb(){return null}};
8
- Y.prototype.getVideoElement=Y.prototype.Pb;Y.prototype.getWrapperCreativeIds=Y.prototype.getWrapperCreativeIds;Y.prototype.getWrapperAdSystems=Y.prototype.getWrapperAdSystems;Y.prototype.getWrapperAdIds=Y.prototype.getWrapperAdIds;Y.prototype.getSequenceLength=Y.prototype.cb;Y.prototype.getPositionInSequence=Y.prototype.Db;Y.prototype.getPodTimeOffset=Y.prototype.Cb;Y.prototype.getPodIndex=Y.prototype.getPodIndex;Y.prototype.getPodType=Y.prototype.Ra;Y.prototype.getMediaBitrate=Y.prototype.Qa;
9
- Y.prototype.getMediaHeight=Y.prototype.ab;Y.prototype.getMediaWidth=Y.prototype.bb;Y.prototype.getMediaUrl=Y.prototype.getMediaUrl;Y.prototype.getClickThroughUrl=Y.prototype.ob;Y.prototype.isBumper=Y.prototype.Qb;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;Y.prototype.getAdSystem=Y.prototype.getAdSystem;
10
- Y.prototype.getApiFramework=Y.prototype.getApiFramework;Y.prototype.getSourceId=Y.prototype.Nb;Y.prototype.getCreativeId=Y.prototype.getCreativeId;Y.prototype.getId=Y.prototype.getId;Y.prototype.getTechnology=Y.prototype.qb;Y.prototype.getAdManagerVersion=Y.prototype.nb;Y.prototype.getAdManagerName=Y.prototype.lb;var NU=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()}})}Fb(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL).length}Eb(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL).length}};
11
- NU.prototype.hasPostroll=NU.prototype.Eb;NU.prototype.hasPreroll=NU.prototype.Fb;NU.prototype.getCuePoints=NU.prototype.getCuePoints;var OU=class{constructor(a){this.g=new _.S("clpp.freewheel.AdsManager");this.m=a;this.j=new _.xt;this.C=new tv.freewheel.SDK.AdManager;this.f=this.a=null;this.G=[];this.B=[];this.F=[];this.A=new _.hn;this.w=null}load(){const a=this;return _.x(function*(){const b=a.m.getConfiguration().freewheel||{};try{EU(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!==_.Vf&&typeof b.siteSectionId!==
12
- _.t||a.a.setSiteSection(b.siteSectionId);const c=yield FU();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,DU(d.type),d.position,d.slotProfile,d.cuepointSequence,d.maxDuration,d.minDuration,d.acceptContentType);b.keyValues&&typeof b.keyValues===_.Ke&&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);GU(a);a.a.submitRequest();return a.A})}start(){const a=this;return _.x(function*(){yield JU(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);IU(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 _.E(_.Ac,{adsTimeline:new NU(this.a)})),this.w=new _.vv(this.m.getSurface(),(b,c)=>this.a.resize(b,c),this.m.Zc(CU).f);else this.m.onError(new _.H(1,
15
- 9,10003,{errorType:0},void 0));this.A.resolve()}M(a){LU(this,_.cc,a);this.w.start()}L(a){this.f=null;a=a.slot;LU(this,_.ec);this.w.stop();if(a)switch(a.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:JU(this);break;case tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL:IU(this);this.m.play();break;case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:KU(this)}}J(a){const b=a.subType;this.g.debug("ad event",b);switch(b){case tv.freewheel.SDK.EVENT_AD_IMPRESSION:LU(this,_.uc,a);LU(this,
16
- _.mc,a);break;case tv.freewheel.SDK.EVENT_AD_IMPRESSION_END:LU(this,_.xc,a);break;case tv.freewheel.SDK.EVENT_AD_FIRST_QUARTILE:LU(this,_.ic,a);break;case tv.freewheel.SDK.EVENT_AD_MIDPOINT:LU(this,_.oc,a);break;case tv.freewheel.SDK.EVENT_AD_THIRD_QUARTILE:LU(this,_.yc,a);break;case tv.freewheel.SDK.EVENT_AD_COMPLETE:LU(this,_.hc,a);break;case tv.freewheel.SDK.EVENT_AD_CLICK:LU(this,_.gc,a);break;case tv.freewheel.SDK.EVENT_AD_PAUSE:LU(this,_.pc,a);break;case tv.freewheel.SDK.EVENT_AD_RESUME:LU(this,
17
- _.rc,a);break;case tv.freewheel.SDK.EVENT_AD_SKIPPED:LU(this,_.tc,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_START:LU(this,_.fc,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_END:LU(this,_.qc,a);break;case tv.freewheel.SDK.EVENT_ERROR:this.m.onError(new _.H(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();HU(this);this.f.play()}}}H(a){if((a=a.detail)&&this.a)switch(a.currentState){case _.ap:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PLAYING);break;case _.$o:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PAUSED);break;case _.Qo:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_COMPLETED);KU(this);break;case _.Yo:case _.Ro:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_STOPPED)}}};
19
- OU.prototype.getPosition=OU.prototype.getPosition;OU.prototype.setVolume=OU.prototype.setVolume;OU.prototype.getVolume=OU.prototype.getVolume;OU.prototype.skip=OU.prototype.skip;OU.prototype.pause=OU.prototype.pause;OU.prototype.resume=OU.prototype.resume;_.tp(new class{constructor(){this.f=new _.S(BU)}name(){return BU}a(a,b){return a.namespace()!==_.md&&b&&b.freewheel?window.tv&&tv.freewheel&&tv.freewheel.SDK?!0:(this.f.warn("FreeWheel SDK is not loaded."),!1):!1}create(a){return new OU(a)}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var xV="clpp-freewheel",yV="clpp.freewheel.AdsManagerFactory",zV="freewheel",AV=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""}},BV=function(a){const b=[];typeof a.networkId!==_.t&&b.push("networkId");typeof a.serverUrl!==_.cg&&b.push("serverUrl");typeof a.profileId!==_.cg&&b.push("profileId");typeof a.videoAssetId!==_.cg&&typeof a.videoAssetId!==_.t&&b.push("videoAssetId");
2
+ if(b.length)throw new _.I(1,9,12001,{missingKeys:b.join(", ")});},CV=function(){return _.x(function*(){var a=new _.Rv;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})},DV=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,_.og,a.I.bind(a));a.j.on(a.m,_.$f,a.H.bind(a))},GV=function(a){return _.x(function*(){a.G.length?(EV(a),a.f=a.G.shift(),a.f.play()):(FV(a),yield a.m.a.play())})},FV=function(a){const b=a.m.fd(zV).Nc();b&&a.m.getSurface().hide(b);a.m.getSurface().showMediaElement()},EV=function(a){const b=a.m.fd(zV).Nc();b&&(a.m.getSurface().show(b),a.m.getSurface().hideMediaElement(),a.a.registerVideoDisplayBase(xV),
4
+ a.m.isMuted()?a.setVolume(0):a.setVolume(a.m.getVolume()||1))},HV=function(a){a.F.length?(EV(a),a.f=a.F.shift(),a.f.play()):FV(a)},IV=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 _.D(b,d))},JV=class extends _.Zv{constructor(){super();this.f=this.a=null}onPlayerCreated(a){if(window.tv&&tv.freewheel&&tv.freewheel.SDK)this.a=_.Dp(_.Sd,{id:xV}),this.f=_.Dp(_.w,{"class":_.pd}),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 zV}Nc(){return this.a}ph(){return this.f}};_.z("clpp.freewheel.FreeWheelPlugin",JV);JV.prototype.getAdVideo=JV.prototype.ph;JV.prototype.getAdContainer=JV.prototype.Nc;JV.Id=zV;JV.AD_CONTAINER_ID=xV;_.Nr(new class{create(){return new JV}});var Y=class{constructor(a,b,c){this.h=a;this.f=b;this.a=c}sb(){return"FreeWheel AdManager SDK"}tb(){return tv.freewheel.SDK.version}xb(){return 0}getId(){return this.a?this.a.getAdId():""}getCreativeId(){const a=(this.a||{})._creativeId;return typeof a===_.cg?a:""}Sb(){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}Vb(){return!1}ub(){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():""}ib(){return this.a?this.a.getActiveCreativeRendition().getWidth():0}hb(){return this.a?this.a.getActiveCreativeRendition().getHeight():0}Ta(){return 0}Ua(){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.Ua()){case 0:return 0;case 2:return-1}return this.h.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL).indexOf(this.f)+1}Ib(){switch(this.Ua()){case 0:return 0;case 2:return-1;default:return this.f.getTimePosition()}}wb(){return this.a?this.f.getAdInstances().indexOf(this.a)+1:1}jb(){return this.f.getAdCount()}getWrapperAdIds(){return[]}canSeek(){return!1}getWrapperAdSystems(){return[]}getWrapperCreativeIds(){return[]}Ub(){return null}};
8
+ Y.prototype.getVideoElement=Y.prototype.Ub;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.jb;Y.prototype.getPositionInSequence=Y.prototype.wb;Y.prototype.getPodTimeOffset=Y.prototype.Ib;Y.prototype.getPodIndex=Y.prototype.getPodIndex;Y.prototype.getPodType=Y.prototype.Ua;
9
+ Y.prototype.getMediaBitrate=Y.prototype.Ta;Y.prototype.getMediaHeight=Y.prototype.hb;Y.prototype.getMediaWidth=Y.prototype.ib;Y.prototype.getMediaUrl=Y.prototype.getMediaUrl;Y.prototype.getClickThroughUrl=Y.prototype.ub;Y.prototype.isBumper=Y.prototype.Vb;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.Sb;Y.prototype.getCreativeId=Y.prototype.getCreativeId;Y.prototype.getId=Y.prototype.getId;Y.prototype.getTechnology=Y.prototype.xb;Y.prototype.getAdManagerVersion=Y.prototype.tb;Y.prototype.getAdManagerName=Y.prototype.sb;var KV=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()}})}Lb(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL).length}Kb(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL).length}};
11
+ KV.prototype.hasPostroll=KV.prototype.Kb;KV.prototype.hasPreroll=KV.prototype.Lb;KV.prototype.getCuePoints=KV.prototype.getCuePoints;var LV=class{constructor(a){this.g=new _.S("clpp.freewheel.AdsManager");this.m=a;this.j=new _.St;this.C=new tv.freewheel.SDK.AdManager;this.f=this.a=null;this.G=[];this.B=[];this.F=[];this.A=new _.rn;this.l=null}load(){const a=this;return _.x(function*(){const b=a.m.getConfiguration().freewheel||{};try{BV(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!==_.cg&&typeof b.siteSectionId!==
12
+ _.t||a.a.setSiteSection(b.siteSectionId);const c=yield CV();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,AV(d.type),d.position,d.slotProfile,d.cuepointSequence,d.maxDuration,d.minDuration,d.acceptContentType);b.keyValues&&typeof b.keyValues===_.Se&&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);DV(a);a.a.submitRequest();return a.A})}start(){const a=this;return _.x(function*(){yield GV(a)})}w(){}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}o(){return!0}h(){const a=this;return _.x(function*(){a.j.release();
14
+ a.l&&(a.l.stop(),a.l=null);FV(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 _.D(_.Fc,{adsTimeline:new KV(this.a)})),this.l=new _.Pv(this.m.getSurface(),(b,c)=>this.a.resize(b,c),this.m.fd(zV).f);else this.m.onError(new _.I(1,
15
+ 9,10003,{errorType:0},void 0));this.A.resolve()}M(a){IV(this,_.jc,a);this.l.start()}L(a){this.f=null;a=a.slot;IV(this,_.kc);this.l.stop();if(a)switch(a.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:GV(this);break;case tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL:FV(this);this.m.play();break;case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:HV(this)}}J(a){const b=a.subType;this.g.debug("ad event",b);switch(b){case tv.freewheel.SDK.EVENT_AD_IMPRESSION:IV(this,_.zc,a);IV(this,
16
+ _.sc,a);break;case tv.freewheel.SDK.EVENT_AD_IMPRESSION_END:IV(this,_.Cc,a);break;case tv.freewheel.SDK.EVENT_AD_FIRST_QUARTILE:IV(this,_.oc,a);break;case tv.freewheel.SDK.EVENT_AD_MIDPOINT:IV(this,_.uc,a);break;case tv.freewheel.SDK.EVENT_AD_THIRD_QUARTILE:IV(this,_.Dc,a);break;case tv.freewheel.SDK.EVENT_AD_COMPLETE:IV(this,_.nc,a);break;case tv.freewheel.SDK.EVENT_AD_CLICK:IV(this,_.mc,a);break;case tv.freewheel.SDK.EVENT_AD_PAUSE:IV(this,_.vc,a);break;case tv.freewheel.SDK.EVENT_AD_RESUME:IV(this,
17
+ _.xc,a);break;case tv.freewheel.SDK.EVENT_AD_SKIPPED:IV(this,_.yc,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_START:IV(this,_.lc,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_END:IV(this,_.wc,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();EV(this);this.f.play()}}}H(a){if((a=a.detail)&&this.a)switch(a.currentState){case _.kp:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PLAYING);break;case _.jp:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PAUSED);break;case _.$o:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_COMPLETED);HV(this);break;case _.hp:case _.ap:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_STOPPED)}}};
19
+ LV.prototype.getPosition=LV.prototype.getPosition;LV.prototype.setVolume=LV.prototype.setVolume;LV.prototype.getVolume=LV.prototype.getVolume;LV.prototype.skip=LV.prototype.skip;LV.prototype.pause=LV.prototype.pause;LV.prototype.resume=LV.prototype.resume;_.Bp(new class{constructor(){this.Wa=new _.S(yV)}name(){return yV}a(a,b){return a.namespace()!==_.ud&&b&&b.freewheel?window.tv&&tv.freewheel&&tv.freewheel.SDK?!0:(this.Wa.warn("FreeWheel SDK is not loaded."),!1):!1}create(a){return new LV(a)}});};f.call(g, window);
package/cl.hls.js CHANGED
@@ -1,74 +1,79 @@
1
- import {clpp} from "./cl.core.js";import './cl.mse.js';let g={};const _ = clpp._;var f=function(window){'use strict';var QJ="CLOSED-CAPTIONS",RJ="Could not parse MP4 segment start time.",SJ="DURATION",TJ="EXT-X-STREAM-INF",UJ="Failed to infer discontinuity number",VJ="Guessing audio-only",WJ="METHOD",XJ="SAMPLE-AES-CTR",YJ="SUBTITLES",ZJ="Two EXT-X-KEY tags, one with METHOD\x3dAES-128 are applied to one ",$J="application/vnd.apple.mpegurl",aK="sample",bK="whole-segment",cK=function(a,b){return _.J(a,b,void 0,{required:!0})},dK=function(a){if(1>a.a)throw _.em();--a.a},eK=function(a,b){for(const c in a){if(!(c in
2
- b))return!1;const d=a[c],e=b[c];if(d&&typeof d===_.Ke&&e&&typeof e===_.Ke){if(!eK(d,e))return!1}else if(void 0!==d&&void 0!==e&&d!==e)return!1}return!0},fK=function(a,b){if(!eK(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===_.Ke&&e&&typeof e===_.Ke&&fK(d,e))return!0}return!1},gK=function(a){if(null!==a&&void 0!==a)return Number(a)},hK=function*(a){let b=-1,c=void 0,d=void 0;for(const e of a)0<=b&&(yield{Rf:b,item:d,Lh:c,next:e}),b++,c=d,d=e;-1!==
3
- b&&(yield{Rf:b,Lh:c,item:d,next:void 0})},iK=function(a,b){return a.filter(c=>c.name===b)},jK=function(a){const b=/^[a-zA-Z0-9_-]+$/,c=new Set;a.forEach(d=>{const e=_.J(d,"VALUE"),f=_.J(d,"NAME"),g=_.J(d,"IMPORT"),h=_.J(d,"QUERYPARAM");if(1!==[f,g,h].filter(Boolean).length||f&&null==e)throw new _.H(_.F,4,4044,{message:"Invalid tag.",text:d.toString()});d=f||g||h;if(c.has(d))throw new _.H(_.F,4,4044,`EXT-X-DEFINE redefined variable "${d}".`);if(!b.test(d))throw new _.H(_.F,4,4044,`EXT-X-DEFINE invalid variable name "${d}".`);
4
- c.add(d)})},kK=function(a,b){const c=Array.isArray(b)?b:[b];return a.filter(d=>{d=cK(d,_.Hb);return c.includes(d)})},lK=function(a,b){return a.some(c=>c.name===b)},mK=function(a,b,c){c=void 0===c?{}:c;a=a.find(d=>d.name===b)||null;if(!a&&c.required)throw new _.H(_.F,4,4024,{missingTag:b});return a},nK=function(a){var b=mK(a,"EXT-X-TILES");if(!b)return{bd:1,vd:1,durationPerTile:null};a=_.J(b,"LAYOUT")||"1x1";b=_.J(b,SJ);a=_.RC(a);return{bd:a.bd,vd:a.vd,durationPerTile:b?Number(b):null}},oK=function(a,
5
- b,c){c=void 0===c?!0:c;a=new _.ni(a);b=new _.ni(b);b=a.resolve(b).toString();return c?b:decodeURI(b)},pK=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)},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=>lK(b.ba,_.Da))},sK=function(a){return a.type===_.p||a.type===_.w},tK=function(a){if(mK(a,
6
- _.Da))return _.Sb;a=mK(a,_.Ia);if(!a)return"LIVE";if(a.value===_.Sb)return _.Sb;if("EVENT"===a.value)return"EVENT";throw new _.H(_.F,4,4044,`Invalid EXT-X-PLAYLIST-TYPE value: ${a.value}`);},uK=function(a){a={AUDIO:_.p,VIDEO:_.w,SUBTITLES:_.G,"CLOSED-CAPTIONS":_.G}[a.toUpperCase()];if(!a)throw new _.H(_.F,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 _.H(_.F,4,4044,"Byte range length must be positive.");
7
- if(d[1]){if(d=Number(d[1]),0>d)throw new _.H(_.F,4,4044,"Byte range start byte must not be negative.");}else{if(c)throw new _.H(_.F,4,4044,"Invalid byte range, offset is required but missing.");if(null==b)throw new _.H(_.F,4,4044,"Invalid byte range, cannot calculate offset based on previous byte ranges.");d=b+1}e=d+a-1}return{ya:d,na:e}},wK=function(a,b){a=mK(a,_.za);return vK(a?a.value:null,b)},xK=function(a){a=mK(a,"EXTINF",{required:!0}).value.split(",");return{duration:Number(a[0]),title:a[1]||
8
- null}},yK=function(a,b){b=void 0===b?{}:b;const c={xf:!1,Ng:!1,Og:null,rh:null,eg:null};a=mK(a,_.La,{required:b.kg});if(!a)return c;const d=e=>null==e?null:Number(e);c.xf="YES"===_.J(a,"CAN-BLOCK-RELOAD");c.Ng="YES"===_.J(a,"CAN-SKIP-DATERANGES");c.Og=d(_.J(a,"CAN-SKIP-UNTIL"));c.rh=d(_.J(a,"HOLD-BACK"));c.eg=d(_.J(a,"PART-HOLD-BACK",void 0,{required:b.kg}));return c},zK=function(a,b,c){c=void 0===c?!1:c;a=_.J(a,"BYTERANGE");return vK(a,b,c)},BK=function(a,b){const c=wK(a.ba,null);return new AK(0,
9
- 0,0,()=>[a.a],c.ya,c.na,0,b)},CK=function(a,b){if(null==a)return null;a=Object.assign({},a);null==a.iv&&(a.iv=_.kj(new Uint8Array(12),new Uint8Array([b>>24&255,b>>16&255,b>>8&255,b&255])));return a},DK=function(a){let b=Infinity,c=Infinity;pK(a).filter(sK).forEach(d=>{{d=d.T;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{Lc: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?
10
- a.video.Fa:"")+" - "+(a.audio?a.audio.Fa:"")},GK=function(a,b,c,d){if(b===_.Sb)return{delay:0,ud:0};b=mK(a,_.Ha);if(c&&b){c=Number(cK(b,"PART-TARGET"));if(null!=d)return{delay:d,ud:c};({eg:d}=yK(a,{kg:!0}));return{delay:d,ud:c}}a=mK(a,_.Na,{required:!0});a=Number(a.value);return null!=d?{delay:d,ud:a}:{delay:3*a,ud:a}},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;
11
- for(const c of a){a=_.J(c,_.$a);a=_.Di(a||_.fg);const d=cK(c,_.Sa),e=cK(c,"INSTREAM-ID");b.has(d)||b.set(d,new Map);b.get(d).set(e,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.Fa;return b.find(d=>HK(d).Fa===c)||null},MK=function(a){for(const b of a)if(b.startsWith("#EXT-")&&(a=_.pj(0,b),_.Xt.has(a.name)))return 1;return 0},NK=function(a,b){return a.replace(/\{\$([a-zA-Z0-9_-]+)\}/g,(c,d)=>{c=b.get(d);if(null==c)throw new _.H(_.F,4,
12
- 4044,`Undefined variable '${d}'`);return c})},OK=function(a,b){a.forEach(c=>{c.attributes.forEach(d=>{d.value=NK(d.value,b)})})},PK=function(a,b,c){OK(a,c);b.forEach(d=>{d.a&&(d.a=NK(d.a,c));OK(d.ba,c);OK(d.f,c)})},QK=function(a,b){const c=new Map,d=new URL(b);a.forEach(e=>{var f=_.J(e,"NAME"),g=_.J(e,"QUERYPARAM");if(f)g=cK(e,"VALUE"),c.set(f,g);else if(g){f=d.searchParams.get(g);if(null==f)throw new _.H(_.F,4,4044,`Query param '${g}' missing in playlist URI.`);if(!f)throw new _.H(_.F,4,4044,`Query param '${g}' has no associated value`+
13
- " in playlist URI.");c.set(g,decodeURIComponent(f))}});return c},TK=function(a,b,c){const d=[];for(let e=1;e<b.length;e++){const f=RK(a,b[e]);d.push(f);if(f.name===TJ){const g=b[e+1];if(!g)throw new _.H(_.F,4,4044,"EXT-X-STREAM-INF is not followed by a URI.");f.attributes.push(new _.nj(_.Jb,g));e++}}b=iK(d,"EXT-X-DEFINE");jK(b);b=QK(b,c);a.a=b;PK(d,[],a.a);return new SK(c,0,d)},WK=function(a,b,c){let d=[];for(var e=1;e<b.length;){const f=RK(a,b[e]);if(_.Yt.has(f.name))break;d.push(f);e++}b=UK(a,c,
14
- b.slice(e));e=b.T;d=d.concat(b.ba);a=VK(a,d,c);PK(d,e,a);return new SK(c,1,d,b.T)},XK=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 _.H(_.F,4,4015);return 0===MK(b)?TK(a,b,c):WK(a,b,c)},RK=function(a,b){return _.pj(a.h++,b)},UK=function(a,b,c){const d=[],e=[];let f=[],g=[];c.forEach(h=>{/^(#EXT)/.test(h)?(h=RK(a,h),_.Xt.has(h.name)||_.$t.has(h.name)?d.push(h):_.Zt.has(h.name)?"EXT-X-PART"===h.name?
15
- g.push(h):h.name===_.Ja&&"PART"===_.J(h,_.Hb)&&g.push(h):f.push(h)):/^#(?!EXT)/m.test(h)||(h=oK(b,h.trim(),!1),e.push(new YK(h,f,g)),f=[],g=[])});0<g.length&&e.push(new YK(null,f,g));return{T:e,ba:d}},VK=function(a,b,c){b=iK(b,"EXT-X-DEFINE");jK(b);const d=QK(b,c);b.map(e=>_.J(e,"IMPORT")).filter(Boolean).forEach(e=>{const f=a.a.get(e);if(null==f)throw new _.H(_.F,4,4044,`Cannot import variable '${e}' as it is not defined `+"in the master playlist");d.set(e,f)});return d},ZK=function(a){return 0>
16
- a?[]:Array.from({length:a},(b,c)=>c)},$K=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},aL=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 _.H(_.F,4,4030);}$K(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],
17
- 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|a[6]<<6|a[7]>>>2,f*=4,f+=a[7]&3,Math.round(f/9E4);break}}$K(a,e)||d();e+=10;e+=f}while(e<a.byteLength);return d()},bL=function(a,b){let c=null,d=0;try{(new _.um).N(_.Ge,_.nm).N(_.cg,_.nm).N(_.Be,_.nm).ca("mdhd",g=>{g.reader.skip(0===g.version?8:16);d=_.P(g.reader);
18
- g.parser.stop()}).parse(b,!0)}catch(g){c=g}if(c||!d)throw _.zv.error("Unable to find timescale in init segment!"),new _.H(_.F,4,4030,RJ,c);let e=0,f=!1;try{(new _.um).N("moof",_.nm).N("traf",_.nm).ca("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,
19
- !0)}catch(g){c=g}if(c||!f)throw new _.H(_.F,4,4030,RJ,c);return e},cL=function(a){for(;a.getPosition()<a.Pa()-1;){const b=a.getPosition();if(71===_.fm(a))return dK(a),b}return-1},dL=function(a){function b(){d.seek(e+188);f=_.fm(d);71!==f&&(d.seek(e+192),f=_.fm(d));71!==f&&(d.seek(e+204),f=_.fm(d));71!==f&&c();dK(d)}function c(){throw new _.H(_.F,4,4030);}const d=new _.rn(new DataView(a),!1);let e=0,f=0;e=cL(d);0>e&&(_.zv.error("Unable to find sync byte in TS after scanning."),c());for(;;){e=d.getPosition();
20
- f=_.fm(d);71!==f&&c();a=_.gm(d);if(8191===(a&8191)){b();continue}if(!(a&16384)){b();continue}a=(_.fm(d)&48)>>4;0!==a&&2!==a||c();3===a&&(a=_.fm(d),d.skip(a));if(1!==_.P(d)>>8){b();continue}d.skip(3);a=_.fm(d)>>6;0!==a&&1!==a||c();0===_.fm(d)&&c();a=_.fm(d);const g=_.gm(d),h=_.gm(d);return(1073741824*((a&14)>>1)+((g&65534)<<14|(h&65534)>>1))/9E4}},gL=function(a){const b=eL(a),c=fL(a);a.forEach(d=>{const e=d.T,f=e.findIndex(h=>h.ma===b);let g=e.findIndex(h=>h.ma===c+1);-1===g&&(g=e.length);d.T=e.slice(f,
21
- g)})},fL=function(a){a=a.map(b=>b.T[b.T.length-1].ma);return Math.min(...a)},eL=function(a){a=a.map(b=>b.T[0].ma);return Math.max(...a)},jL=function(a){var b=cK(a,WJ);if(!hL.includes(b))return iL.error("PlayReady in HLS is only supported with [",hL.join(", "),"], not",b),null;a=cK(a,_.Jb);b=_.ht(a);a=null;b=_.K(b.data);try{a=_.AC(_.zn(b))}catch(c){a=b}return _.NC(_.Ad,[{initDataType:_.dd,initData:a}],"")},lL=function(a){if(0===a.length)return kL();if(a.some(c=>c.type===bK)||a.every(c=>c.type===_.Je))return a[0];
22
- a=a.filter(c=>c.type===aK);const b=_.ei(a.flatMap(c=>c.drmInfos));return{keyInfo:null,keyId:a[a.length-1].keyId,type:aK,drmInfos:b}},oL=function(a){a=mL(a);if(a.some(b=>nL(b))&&1<a.length)throw new _.H(_.F,4,4046,"Two EXT-X-KEY tags, one with METHOD\x3dAES-128 are applied to one playlist.");},nL=function(a){return iK(a.ba,_.Ea).some(b=>"AES-128"===_.J(b,WJ))},qL=function(a,b,c){return mL(a).map(d=>pL(d.ba,b,c))},rL=function(a){return a.filter(b=>lK(b.ba,_.Ea)).length},mL=function(a){return a.filter(b=>
23
- lK(b.ba,_.Ea))},pL=function(a,b,c){a=iK(a,_.Ea);if(0===a.length)return null;var d=cK(a[0],WJ);if(1===a.length){if("NONE"===d)return kL();if("AES-128"===d)return a=a[0],d=_.J(a,"IV",""),{type:bK,keyInfo:{method:"AES-128",url:oK(b,cK(a,_.Jb)),iv:d?_.hj((d||"0x").slice(2)):null},drmInfos:[],keyId:null}}b=a.map(e=>cK(e,WJ));if(!b.every(e=>"SAMPLE-AES"===e)&&!b.every(e=>e===XJ))throw sL.warn(`EXT-X-KEY methods ${b.join(", ")} are incompatible.`),new _.H(_.F,4,4044,"Multiple EXT-X-KEY tags with incompatible METHOD values.");
24
- b=a.map(e=>{const f=_.J(e,"KEYFORMAT","identity");{const g=tL[f]||null;e=g?g(e,c):null}e||sL.warn("Unsupported HLS KEYFORMAT",f);return e}).filter(Boolean);if(0===b.length)throw new _.H(_.F,4,4026);return{keyInfo:null,keyId:b.map(e=>e.keyIds).reduce((e,f)=>e.concat(f),[]).reverse()[0]||null,type:aK,drmInfos:b}},kL=function(){return{type:_.Je,keyInfo:null,drmInfos:[],keyId:null}},uL=function(a,b,c){return _.x(function*(){const d=b.f(),e=_.uD(b.Xa(),b.ya,b.ya+2048-1,a.a.attemptParameters);e.type=2;
25
- const f=_.uD(b.Xa(),b.ya,b.na,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.",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 _.H(_.F,4,4030,"Failed to fetch the media segment.");
26
- }}})},vL=function(a,b,c,d,e,f){return _.x(function*(){a.g.debug("Fetching segment to find start time");if("audio/mpeg"===d||d===_.Oc||d===_.Nc)return 0;if(d===_.Mc){var g=yield uL(a,c,f);g=_.K(g.data);if(!$K(g))throw new _.H(_.F,4,4030,"AAC segment does not contain an ID3 tag.");return aL(g)}if(d===_.vg||d===_.Pc)return g=[uL(a,c,f)],b&&g.push(uL(a,b,!0)),g=yield Promise.all(g),bL(g[0].data,(g[1]||g[0]).data);if(d===_.ug)return g=yield uL(a,c,f),dL(g.data);if(!_.ss(`${d.split("/")[0]||""}/mp4;codecs="${e}"`))return 0;
27
- throw new _.H(_.F,4,4030);})},wL=function(a,b){a=a.map(c=>c.streams[b]);return a.some(c=>null==c)?null:a},xL=function(a,b){a=a.streams.find(c=>{c=c.T;return c[0].position<=b&&b<=c[c.length-1].position});return null==a?null:a.T.find(c=>c.position===b)||null},HK=function(a){return a.streams[0]},yL=function(a,b){a.streams.forEach(c=>{c.ee=b})},zL=function(a,b){a.streams.forEach(c=>{c.width=b})},AL=function(a,b){a.streams.forEach(c=>{c.height=b})},BL=function(a,b){a.streams.forEach(c=>{c.frameRate=b})},
28
- CL=function(a,b){a.streams.forEach(c=>{c.bandwidth=b})},DL=function(a,b){a=a.map(c=>c.a[b]);return a.some(c=>null==c)?null:a},EL=function(a,b){const c=new Set(a.map(d=>d.ma));return b.filter(d=>!c.has(d.ma))},GL=function(a,b){for(;a[0].ma<b[0].ma;)a.splice(0,1);var c=a[0];let d=b[0];c.startTime===d.startTime&&c.endTime===d.endTime||FL(c,d);const e=a.length-1;c=a[e];d=b[e];0<e&&(c.startTime!==d.startTime||c.endTime!==d.endTime)&&FL(c,d);for(c=e+1;c<b.length;)a.push(b[c]),c++},LL=function(a,b,c,d,e){var f=
29
- b[0].length();f=ZK(f).map(g=>{var h=DL(b,g)||[];const k=wL(c,g)||[];g=wL(d,g)||[];{const l=[...HL(h),...k,...g].filter(Boolean);IL(l);const {ma:m,duration:n}=l[0];h={configurationId:a,variants:h,textStreams:k,thumbStreams:g,startTime:0,id:`P${m}`,endTime:n,duration:n,ma:m}}return h});e&&JL(f[0]);KL(f);return f},HL=function(a){a=new Set(a.flatMap(b=>[b.video,b.audio]).filter(Boolean));return Array.from(a)},JL=function(a){const b=HL(a.variants)[0].T[0].Ea;a.startTime+=b;a.endTime+=b},KL=function(a){for(let b=
30
- 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}},FL=function(a,b){a.startTime=b.startTime;a.endTime=b.endTime;a.duration=b.duration;ML(a.variants,b.variants);NL(pK(a),pK(b))},ML=function(a,b){const c=new Map(a.map(d=>[FK(d),d]));b.forEach(d=>{c.get(FK(d)).drmInfos=d.drmInfos})},NL=function(a,b){const c=new Map(a.map(d=>[d.Fa,d]));b.forEach(d=>{const e=c.get(d.Fa);e.T=d.T;e.segmentIndex.replace(d.T);e.Lc=d.Lc;e.xe=d.xe;e.duration=d.duration;
31
- e.Ef=d.Ef;e.encrypted=d.encrypted;e.drmInfos=d.drmInfos;e.keyId=d.keyId})},IL=function(a){const b=OL(a);a.forEach(c=>{_.qD(c.segmentIndex,b);c.duration=b;c.xe=c.Lc+b})},OL=function(a){let b=Infinity;a.filter(sK).forEach(c=>{b=Math.min(b,c.duration)});return b},PL=function(a,b){qK(b,(c,d)=>{_.DD(a,c.T,d.startTime)});_.vD(a.a,b[0].startTime,b[b.length-1].endTime)},QL=function(a){return null===a.l?[]:[a.l.audio,a.l.video].filter(b=>b).map(b=>b.Fa)},RL=function(a,b){return _.x(function*(){var c=_.xj([b],
32
- a.a.attemptParameters);c.type=1;c=yield a.H(c);let d="";try{d=_.Ri(c.data)}catch(e){throw new _.H(_.F,4,4042);}d=d.replace(/\r\n|\r(?=[^\n]|$)/gm,"\n");d=d.trim();return{text:d,response:c}})},XL=function(a,b){return _.x(function*(){var c=SL(a,b,a.A,"");if(1===c.type){c=_.Tt(c.T[0].a)||"";c=null!=_.St.video[c]?_.w:null!=_.St.audio[c]?_.p:null;var d="";c===_.w?d="avc1.42E01E":c===_.p&&(d="mp4a.40.2");c=a.O;var e=a.A;d=a.a.hlsDefaultCodecs||d;var f=[],g=[];g.push(new _.nj(_.la,"0"));g.push(new _.nj(_.Jb,
33
- e));d.length&&g.push(new _.nj(_.oa,d));f.push(new _.oj(c.h++,TJ,g));c=new SK(e,0,f)}d=c.ba;c=iK(d,"EXT-X-MEDIA");e=iK(d,TJ);d=iK(d,"EXT-X-IMAGE-STREAM-INF");c={Kc:{Ig:kK(c,["AUDIO",_.Rb]),closedCaptions:kK(c,QJ),di:kK(c,YJ)},wd:e,te:d};f=yield TL(a,c);var h=f.zh;d=f.periods;var k=f.Nh;g=f.fi;c=f.alternativeVariants;e=f.alternativeTextStreams;f=f.alternativeImageStreams;if(!a.D)throw new _.H(_.F,7,7001);UL(a,d);{let q=!0;var l=null;let u=0;VL(a)||(q=!1,l=0,u=h.delay);const v=a.a.timeline||{};v.type=
34
- void 0;l=new _.CJ(v,l,u,!0,void 0,!!a.a.lowLatencyMode);_.zD(l,q);PL(l,d);k&&_.yD(l,k);k=l}if(!VL(a)){a.G=h.ud;h=0;for(var m of a.f.values())h=Math.max(h,m.streams[0].Lc);for(m=0;95443.7176888889<=h;)m+=95443.7176888889,h-=95443.7176888889;if(m){a.g.debug("Offsetting live streams by",m,"to compensate for rollover");for(var n of a.f.values())h=n.streams[0],95443.7176888889>h.Lc?(a.g.debug("Offset applied to",h.type),h.segmentIndex.offset(m)):a.g.debug("Offset NOT applied to",h.type)}}n=EK(d);"LIVE"===
35
- a.o||"EVENT"===a.o?(n=Math.max(n,k.J),isNaN(a.a.availabilityWindowOverride)||(n=a.a.availabilityWindowOverride),k.A=n):a.o===_.Sb&&(k.f=n);n=WL(a,g);n={presentationTimeline:k,periods:d,minBufferTime:0,cues:n};c&&(n.alternativeVariants=c);e&&(n.alternativeTextStreams=e);f&&(n.alternativeImageStreams=f);a.g.debug("HLS playlist parsed",n);return n})},ZL=function(a,b){return Promise.all(b.map(c=>YL(a,c)))},aM=function(a,b){b.forEach(c=>{a:{var d=a.f.get(c.verbatimUri),e=!VL(a),f=mK(c.ba,_.Ca);if(f)var g=
36
- Number(f.value);else{d?(f=d.streams[d.streams.length-1].T,f=f[f.length-1].ma):f=0;if(e&&0<f)try{{const k=mK(c.ba,_.Ga);if(!k)throw $L.error("Failed to infer discontinuity number, because EXT-X-MEDIA-SEQUENCE tag is missing."),Error(UJ);const l=Number(k.value),m=xL(d,l);if(!m)throw $L.error("Failed to infer discontinuity number, could not find the appropriate segment in the previous playlist"+` (segment position = ${l})`),Error(UJ);var h=m.ma}g=h;break a}catch(k){throw new _.H(_.F,4,4024,"EXT-X-DISCONTINUITY-SEQUENCE tag is required for discontinuous HLS live streams.");
37
- }g=0}}c=c.T||[];for(const k of c)lK(k.ba,_.Ba)&&g++,k.ma=g});gL(b)},dM=function(a,b){return _.x(function*(){const {textStreams:c,thumbStreams:d,Jg:e}=yield bM(a,b);var f=a.C.periods[0].variants;a.a.lowLatencyMode&&null!==a.l&&(f=f.filter(g=>g.id===a.l.id));f=f.map(g=>{const h=LK(g.audio,e),k=LK(g.video,e);g=cM(a,h,k,g.bandwidth);if(!g)throw new _.H(_.F,4,4047,{message:"Video and audio are encrypted in an incompatible way.",Oi:k?HK(k).Fa:void 0,audio:h?HK(h).Fa:void 0});return g});return LL(a.D.configurationId,
38
- f,c,d,!0)})},UL=function(a,b){VL(a)||2!==a.a.timeline.version||(a.I||(a.I=b[0].startTime),_.NE(b,-a.I))},eM=function(a,b){b=b.flatMap(d=>d.T[0].ba);b=mK(b,_.Ka);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},fM=function(a,b,c){b=b.find(d=>null!==mK(d.ba,_.Aa));if(!b)return[];if(null===c)throw new _.H(_.F,4,4024,"EXT-X-PROGRAM-DATE-TIME tag is required when EXT-X-DATERANGE tags are present");
39
- return b.ba.filter(d=>d.name===_.Aa).map(d=>{a:{var e=a.B,f=!VL(a),g=_.J(d,"ID"),h=_.J(d,"START-DATE");if(null===g||null===h)_.Wt.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);h=k.getTime()/1E3+e;g={id:g,startTime:h,startDate:k};f=gK(_.J(d,SJ));void 0!==f&&0<=f&&(g.duration=f);var l=gK(_.J(d,"PLANNED-DURATION"));void 0!==l&&0<=l&&(g.plannedDuration=l);var m=_.J(d,"CLASS");null!==m&&(g.schemeIdUri=
40
- 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=_.bh(k)?k:null}}q=q||{};(k=_.J(d,"CUE"))&&(q.CUE=k.split(","));if(m===_.yd){k=d.attributes;if(null==k)var u=null;else{m={};for(u of k)switch(u.name){case _.Zb:m[_.Zb]=u.value;break;case _.Yb:m[_.Yb]=u.value;break;case _.ac:m[_.ac]=gK(u.value);break;case _.$b:m[_.$b]=gK(u.value);break;
41
- case "X-SNAP":m["X-SNAP"]=u.value.split(",");break;case "X-RESTRICT":m["X-RESTRICT"]=u.value.split(",")}m[_.Zb]&&m[_.Yb]||!m[_.Zb]&&!m[_.Yb]?(_.Wt.warn("Invalid EXT-X-DATERANGE Interstitial attributes X-ASSET-URI, X-ASSET-LIST"),u=null):u=_.bh(m)?m:null}if(null===u){_.Wt.warn("Invalid interstitial attributes, ignoring the EXT-X-DATERANGE tag.",d);d=null;break a}q=Object.assign(q,u)}_.bh(q)&&(g.customAttributes=q);g.endTime=n?n.getTime()/1E3+e:f?h+f:l?h+l:h;g.type=_.Ph;d=g}}return d}).filter(Boolean)},
42
- WL=function(a,b){const c=new Set(b.map(d=>d.id));a.w.forEach((d,e)=>{c.has(e)||a.w.delete(e)});for(const d of b){if((b=a.w.get(d.id))&&b.startTime!==d.startTime)a.D.onError(new _.H(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,endTime:d.endTime,id:d.id,type:_.Ph,eventElement:null};b&&!fK(b,e)||a.w.set(d.id,e)}return Array.from(a.w.values())},
43
- gM=function(a,b,c){a.o=_.Sb;_.zD(b,!0);b.f=c[c.length-1].endTime},SL=function(a,b,c,d){a=XK(a.O,b,c);a.verbatimUri=d;return a},TL=function(a,b){return _.x(function*(){var c=JK(b.Kc.closedCaptions),d=hM(a,b.wd),e=yield iM(a,b),f=Object.values(e).flat().map(h=>h.playlist);aM(a,f);f=f[0];var g=tK(f.ba);a.o=g;a.J=yK(f.ba);f=GK(f.ba,g,a.a.lowLatencyMode||!1,a.a.suggestedPresentationDelay);g=yield jM(a,e.rf,d);c=yield kM(a,e.wd,g,c);d=yield lM(a,e.ci,d);g=yield mM(a,e.te);d=LL(a.D.configurationId,c,d,g,
44
- !VL(a));a.D.filterAllPeriods(d);c=[...e.wd,...e.rf].map(h=>h.playlist);e=eM(a,c);c=fM(a,c,e);return{periods:d,Nh:e,fi:c,zh:f}})},bM=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,
45
- uri:k.Fa,ce:{width:k.width,height:k.height,frameRate:k.frameRate}};h=Object.assign({},{playlist:h.playlist},k);return nM(a,h)});return Promise.all(g)};d=yield f(d);f=yield f(e);oM(a,d.concat(f));e=f.filter(g=>HK(g).type===_.tC);f=f.filter(g=>HK(g).type===_.je);return{textStreams:e,thumbStreams:f,Jg:d}})},cM=function(a,b,c,d){const e=[],f=(c||b).length();for(let m=0;m<f;m++){var g=b?b.streams[m]||null:null,h=c?c.streams[m]||null:null,k=g,l=h;k=k&&l?_.UC(k.drmInfos,l.drmInfos)?_.TC(k.drmInfos,l.drmInfos):
46
- null:k?k.drmInfos:l?l.drmInfos:null;if(!k)return null;l=d;g={id:a.h++,language:g?g.language:_.fg,primary:!!g&&g.primary||!!h&&h.primary,audio:g,video:h,bandwidth:l,drmInfos:k,allowedByApplication:!0,allowedByKeySystem:!0};e.push(g)}return new pM(e)},nM=function(a,b){return _.x(function*(){const c=b.playlist,d=b.codecs,e=b.type,f=b.hd,g=b.tc,h=b.groupId,k=b.primary;var l=b.kind;const m=b.name,n=b.channelsCount,q=b.spatialAudio,u=b.closedCaptions,v=b.ce,y=_.Di(f||_.fg);if(1!==c.type)throw new _.H(_.F,
47
- 4,4017);const A=yield qM(a,c,e,d),D=a.a.lowLatencyMode?_.iC:_.hC;let I=l;e!==_.G||l||(I=_.tC);const X=tK(c.ba);l=A.map(sb=>{const bc=sb.T,xd=sb.Ug,og=sb.mimeType;sb=sb.ma;const Db=bc[0].startTime,Kb=bc[bc.length-1].endTime,sc=Kb-Db,Ta=new _.DJ(bc),hb=bc[0].initSegment||null;return{id:null===g?_.zJ++:g,originalId:m,createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:Ta.f.bind(Ta),getSegmentReference:Ta.get.bind(Ta),adjustSegmentDurations:Ta.h.bind(Ta),getDuration:Ta.getDuration.bind(Ta),
48
- segmentIndex:Ta,segmentLookupStrategy:D,initSegmentReference:hb,mimeType:og,codecs:d,kind:I,Ef:xd.type,encrypted:xd.type===aK,aesEncrypted:!!xd.keyInfo,keyId:xd.keyId,language:y,originalLanguage:f||_.fg,label:m,type:e,primary:k,trickModeVideo:null,emsgSchemeIdUris:null,frameRate:v?v.frameRate:void 0,width:v?v.width:void 0,height:v?v.height:void 0,bandwidth:void 0,roles:[],channelsCount:n,spatialAudio:q,closedCaptions:u,T:bc,drmInfos:xd.drmInfos,ma:sb,Fa:c.verbatimUri,ee:c.a,Lc:Db,xe:Kb,duration:sc,
49
- groupId:h,Ii:X}});return new rM(l)})},oM=function(a,b){b.forEach(c=>{a.f.a.set(HK(c).Fa,c)})},hM=function(a,b){const c=new Map;for(const f of b){var d=_.J(f,"AUDIO");b=_.J(f,_.Rb);var e=_.J(f,YJ);const g=sM(a,f);if(e){const h=_.hk(_.G,g);c.set(`${_.G}:${e}`,h);e=g.indexOf(h);-1<e&&g.splice(e,1)}d&&(e=tM(_.p,g),c.set(`${"audio"}:${d}`,e));b&&(d=tM(_.w,g),c.set(`${"video"}:${b}`,d))}return c},iM=function(a,b){return _.x(function*(){const c=yield Promise.all([uM(a,b.Kc.Ig),uM(a,b.Kc.di),uM(a,b.wd),uM(a,
50
- b.te)]),[d,e,f,g]=c;return{rf:d,ci:e,wd:f,te:g}})},jM=function(a,b,c){return _.x(function*(){if(0===b.length)return new Map;var d=[vM(a,b[0],c)];yield d[0];d=d.concat(b.slice(1).map(e=>vM(a,e,c)));d=yield Promise.all(d);return IK(d)})},kM=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(cK(f[k].tag,_.la));l<h&&(h=l,g=k)}h=f.splice(g,1).pop();h=yield wM(a,h,c,d,e);f=f.map(k=>wM(a,k,c,d,e));f=yield Promise.all(f);
51
- f.splice(g,0,h);return f.reduce(_.KC,[])})},lM=function(a,b,c){return Promise.all(b.map(d=>vM(a,d,c)))},mM=function(a,b){return Promise.all(b.map(c=>xM(a,c)))},VL=function(a){return a.o===_.Sb},uM=function(a,b){return _.x(function*(){return(yield Promise.all(b.map(c=>_.x(function*(){const d=yield yM(a,c);return d?{tag:c,playlist:d}:null})))).filter(Boolean)})},YL=function(a,b){return _.x(function*(){var c=new _.ni(HK(b).ee);if(a.a.lowLatencyMode&&a.J&&a.J.xf){var d=b.streams[b.streams.length-1].segmentIndex;
52
- if(d=d.a[d.a.length-1]){var e=d.a,f=e.length-1;d={Ah:d.position,Gh:e&&0<e.length?f:null}}else d=null;if(e=d)d=e.Ah,e=e.Gh,f=_.Vj(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=_.Uj(f,!0),d=new _.vi(d),_.ri(c,d)}const {response:g,text:h}=yield RL(a,c.toString());c=HK(b).Fa;d=HK(b).ee;e=g.uri;d!==e&&(d=e,yL(b,d));c=SL(a,h,d,c);return{stream:b,playlist:c}})},sM=function(a,b){var c=_.J(b,_.oa,a.a.hlsDefaultCodecs||"avc1.42E01E,mp4a.40.2").split(/\s*,\s*/);
53
- c=KK(c);b=new Set;const d=[];for(const e of c)c=_.ZC(e),b.has(c)?a.g.debug("Ignoring duplicate codec"):(d.push(e),b.add(c));return d},tM=function(a,b){if(1===b.length)return b[0];a=_.hk(a,b);if(null!=a)return a;throw new _.H(_.F,4,4025,{codecList:b});},vM=function(a,b,c){return _.x(function*(){const d=b.tag,e=b.playlist;return zM(a,e.verbatimUri,()=>_.x(function*(){const f=cK(d,_.Sa),g=uK(cK(d,_.Hb));var h=cK(d,_.Hb).toUpperCase();if(uK(h)!==_.G)h=null;else{var k=d.getAttribute("FORCED");k=!(!k||
54
- !k.value||"YES"!==k.value.toUpperCase());var l=_.tC;h===QJ&&(l=_.cC);k&&(l=_.de);h=l}k=c.get(`${g}:${f}`)||"";l=_.J(d,_.$a);const m=_.J(d,"NAME"),n=d.getAttribute("DEFAULT"),q=d.getAttribute("AUTOSELECT");var u=_.J(d,"CHANNELS");u=g===_.p?u?parseInt(u.split("/")[0],10):null:null;var v=g===_.p?(v=_.J(d,"CHANNELS"))?v.includes("/JOC"):!1:!1;return yield nM(a,{playlist:e,codecs:k,type:g,hd:l,primary:!!n&&!!q,name:m,channelsCount:u,spatialAudio:v,groupId:f,kind:h,tc:null,closedCaptions:null,ce:null})}))})},
55
- xM=function(a,b){return _.x(function*(){const c=b.tag,d=b.playlist;return zM(a,d.verbatimUri,()=>_.x(function*(){var e=_.J(c,_.oa)||"jpg",f=_.J(c,_.$a);const g=_.J(c,"NAME");e=yield nM(a,{playlist:d,codecs:e,type:_.je,hd:f,name:g,primary:!1,kind:null,channelsCount:null,spatialAudio:!1,closedCaptions:null,tc:null,groupId:null,ce:null});(f=_.J(c,_.la))&&CL(e,Number(f));return e}))})},wM=function(a,b,c,d,e){return _.x(function*(){var f=b.tag,g=Number(cK(f,_.la));if(f.hasAttribute("FRAME-RATE")||f.hasAttribute(_.zb)){var h=
56
- _.J(f,"FRAME-RATE");f=_.J(f,_.zb);var [k,l]=f?f.split("x"):[null,null];h={frameRate:gK(h),width:gK(k),height:gK(l)}}else h=null;if(f=yield AM(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).Fa:"")+" - "+(n?HK(n).Fa:"");if(e.has(m)){a.g.debug("Skipping variant which only differs in text streams.");continue}const u=cM(a,n,q,g);null==u?a.g.warn("Incompatible DRM info in HLS variant. Skipping."):(f.push(u),e.add(m))}g=
57
- f}else g=[];return g})},zM=function(a,b,c){if(a.f.has(b))return a=a.f.get(b),Promise.resolve(a);if(a.f.f.has(b))return a.f.f.get(b)||null;c=c();a.f.set(b,c);return c},BM=function(a,b,c,d,e,f){let g=sM(a,b);a.g.debug("Guessing stream type for",b.toString());b=!1;const h=_.hk(_.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(VJ),c=_.p,b=!0):e?(a.g.debug(VJ),c=_.p):(a.g.debug("Guessing video-only"),c=_.w):(c=_.p,a.g.debug(VJ));
58
- return{type:c,Gg:g,sh:b}},AM=function(a,b,c,d,e){return _.x(function*(){var f=b.tag,g=b.playlist,h=_.J(f,"AUDIO"),k=_.J(f,_.Rb);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).Fa===l);const {type:m,Gg:n,sh:q}=BM(a,f,c,k.audio.length,k.video.length,g);f=null;q||(f=yield CM(a,b,n,m,e,c));if(null==f)return null;k[m]=[f];m===_.p&&c&&k.video.forEach(u=>{zL(u,c.width);AL(u,c.height);BL(u,c.frameRate)});return k})},
59
- CM=function(a,b,c,d,e,f){return _.x(function*(){const g=b.tag,h=b.playlist;return zM(a,h.verbatimUri,()=>_.x(function*(){var k=_.J(g,QJ);let l=null;d===_.w&&k&&"NONE"!==k&&(l=e.get(k));k=tM(d,c);return yield nM(a,{playlist:h,codecs:k,type:d,closedCaptions:l,primary:!1,kind:null,hd:null,name:null,channelsCount:null,spatialAudio:!1,tc:null,groupId:null,ce:f})}))})},qM=function(a,b,c,d){return _.x(function*(){var e=b.verbatimUri,f=b.T;var g=void 0===g?0:g;var h=(h=mK(b.ba,_.Ga))?Number(h.value):g;g=
60
- [];!VL(a)&&oL(f);e=yield DM(a,b.a,e,f,h,c,d);if(0===f.length)f=[];else{var k=[],l=[];for(var m of f)lK(m.ba,_.Ba)&&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 EM(a,b.a,k,h,e,c,d,g[g.length-1]||null,f.length),g.push(l),h+=k.length;FM(g);return g})},yM=function(a,b){return _.x(function*(){var c="EXT-X-MEDIA"!==b.name?!0:_.J(b,_.Hb)===YJ;c=_.J(b,_.Jb,void 0,{required:c});if(!c)return null;const d=oK(a.A,c),{response:e,text:f}=yield RL(a,d);return SL(a,f,
61
- e.uri,c)})},FM=function(a){if(1<(new Set(a.map(b=>b.mimeType))).size)throw new _.H(_.F,4,4045,"Media playlist contains discontinuities with different MIME types. This is valid, but not yet supported.");},GM=function(a){a=a.map(b=>b.a?b.a:b.f.map(c=>_.J(c,_.Jb))||null).map(b=>_.Tt(b));if(1<(new Set(a)).size)throw new _.H(_.F,4,4044,"Unexpected change in file format.");},HM=function(a,b,c){a=iK(a.ba,_.Fa);if(1<a.length)throw new _.H(_.F,4,4020);a=a[0];if(!a)return null;const d=cK(a,_.Jb),e=oK(b,d);
62
- b=zK(a,null,!0);return new _.yJ(()=>[e],b.ya,b.na,c)},IM=function(a,b,c,d,e,f,g){const h=[];for(const q of hK(b.f)){b=q.Rf;const u=q.item;{var k=0===b,l=k?a:h[h.length-1],m=k?d:l.endTime,n=Number(_.J(u,SJ));n=m+n;k=zK(u,k?null:l.na,k);l=_.J(u,_.Jb);const v=(l=oK(g,l))?[l]:[];m=new AK(c,m,n,()=>v,k.ya,k.na,e,f,!1,null,null,null,null);if("YES"===_.J(u,"INDEPENDENT")||0===b)m.h=!0;h.push(m)}}return h},JM=function(a,b,c,d,e,f,g,h,k,l,m){const n=c.ba;var q=c.a;0<iK(n,_.Fa).length&&(m=HM(c,k,g));const u=
63
- null!=q,v=q?[q]:[];if(!u&&!a.a.lowLatencyMode)return null;a=0;q={ya:0,na:null};let y=null;u?({duration:c}=xK(n),a=e+c,q=wK(n,b?b.na:null)):(b=IM(b,c,d,e,f,g,k),a=b[b.length-1].endTime,y=b);h=h===_.je?nK(n):null;d=new AK(d,e,a,()=>v,q.ya,q.na,f,g,!1,null,h?h.bd:null,h?h.vd:null,h?h.durationPerTile:null,y,m);d.ma=l;return d},DM=function(a,b,c,d,e,f,g){return _.x(function*(){var h=d[0];if(null!=a.B)return a.B;if(!VL(a)&&a.C)try{var k=a.f.get(c);var l=k?xL(k,e)||null:null;if(!l)throw new _.H(_.F,4,4030,
64
- "Segment not found in pervious playlist update.");var m=l.startTime+l.Ea;a.g.debug(`Setting playlist start time to ${m}.`);return a.B=m}catch(n){if(h=a.f.get(c))m=h.streams[h.streams.length-1].T,m=m[m.length-1],a.g.warn(`Last #EXT-X-MEDIA-SEQUENCE values ${h.streams[0].T[0].position} - ${m.position}`+`, new values ${e} - ${e+d.length-1}.`,b,h);throw new _.H(_.F,4,4047,{message:"The updated playlist does not share any segments with the previous one.",uri:c});}m=yield KM(a,f,g,h);k=pL(h.ba,a.A,m)||
65
- kL();l=HM(h,b,k.keyInfo);k=CK(k.keyInfo,e);h=yield LM(a,l,h,k,m,g);a.g.debug(`Setting playlist start time to ${h}.`);return a.B=h})},EM=function(a,b,c,d,e,f,g,h,k){return _.x(function*(){var l=c[0],m=null==h;GM(c);const n=yield KM(a,f,g,l);var q=a.A,u=h?h.yh:null;var v=1===k;if(c.slice(1).some(nL))throw new _.H(_.F,4,4046,v?"Media playlist contains an EXT-X-KEY tag with METHOD\x3dAES-128 which is not at the beginning of the playlist.":"Media playlist contains an EXT-X-KEY tag with METHOD\x3dAES-128 which is not marked by an EXT-X-DISCONTINUITY tag and is not at the beginning of the playlist.");
66
- if(lK(c[0].ba,_.Ea)||null===u)if((u=pL(c[0].ba,q,n))&&u.type===bK){if(1<rL(c))throw new _.H(_.F,4,4046,ZJ+`${v?"playlist":"discontinuity"}.`);v=[u]}else v=qL(c,q,n),v=0===v.length?[kL()]:v;else if(q=qL(c,q,n),u.type===_.Je||u.type===aK)v=[u,...q];else{if(0<rL(c))throw new _.H(_.F,4,4046,ZJ+`${v?"playlist":"discontinuity"}.`);v=[u]}q=v;v=q[q.length-1];q=lL(q);u=HM(l,b,q.keyInfo)||(h?h.th:null);var y=CK(q.keyInfo,d);const A=l.ma;l=m?e:yield MM(a,A,u,l,d,y,n,g);m=[];for(y=0;y<c.length;y++){var D=c[y];
67
- const I=m[m.length-1]||null,X=0===y?0:I.endTime,sb=d+y,bc=CK(q.keyInfo,sb);if(D=JM(a,I,D,sb,X,l,bc,f,b,A,u))u=D.initSegment,m.push(D)}return{T:m,Ug:q,yh:v,mimeType:n,endTime:m[m.length-1].endTime,ma:A,th:u}})},KM=function(a,b,c,d){return _.x(function*(){const e=d.a;var f=mK(d.ba,_.Fa);f=f?cK(f,_.Jb):null;return NM(a,b,c,e,f)})},LM=function(a,b,c,d,e,f){return _.x(function*(){if(null==c.a)return 0;const g=BK(c,d);return vL(a.R,b,g,e,f,null!=d)})},MM=function(a,b,c,d,e,f,g,h){return _.x(function*(){if(a.K.has(b))return a.K.get(b);
68
- const k=yield LM(a,c,d,f,g,h);a.g.debug(`Segment #${e} has raw media timestamp `+`${k} s.`);a.K.set(b,k);return k})},NM=function(a,b,c,d,e){return _.x(function*(){const f=[d,e].filter(Boolean);var g=_.kk(f,b,c);if(g)return g;g=_.xj([d],a.a.attemptParameters);g.method="HEAD";g.type=2;g=(yield a.H(g)).headers["content-type"];if(!g)throw new _.H(_.F,4,4021,"Unknown MIME type of: "+f.join(", "));return g.split(";")[0]})},SK=class{constructor(a,b,c,d){if(1===b){if(!d||0===d.length)throw new _.H(_.F,4,
69
- 4043,"Media playlist must have at least one segment!");if(null==d[0].a)throw new _.H(_.F,4,4043,"Media playlist must have at least one full segment!");}this.a=a;this.verbatimUri="";this.type=b;this.ba=c;this.T=1===b?d:null}},YK=class{constructor(a,b,c){c=void 0===c?[]:c;this.ba=b;this.a=a;this.f=c;this.ma=-1}},AK=class extends _.PD{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:
70
- n,void 0===q?null:q,u,void 0===v?null:v);this.ma=0}},OM=class{constructor(){this.h=0;this.a=new Map}},PM=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()}},$L=new _.S("clpp.hls.DiscontinuityUtils");var tL={"com.apple.streamingkeydelivery":function(a,b){if(b===_.ug)throw new _.H(_.F,4,4041);if(cK(a,WJ)===XJ)throw new _.H(_.F,4,4044,"EXT-X-KEY:METHOD SAMPLE-AES-CTR is not supported in FairPlay.");return _.NC(_.wd,[{initDataType:_.Of,initData:new Uint8Array(0)}],"")},"com.microsoft.playready":jL,"urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":jL,"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":function(a){var b=cK(a,WJ);if(!hL.includes(b))return iL.error("Widevine in HLS is only supported with [",
71
- hL.join(", "),"], not",b),null;b=cK(a,_.Jb);b=_.ht(b);b=_.K(b.data);b=_.NC(_.Cd,[{initDataType:_.dd,initData:b}],"");if(a=_.J(a,"KEYID"))b.keyIds=[a.substr(2).toLowerCase()];return b}},hL=["SAMPLE-AES",XJ],iL=new _.S("clpp.hls.DrmParser");var sL=new _.S("clpp.hls.EncryptionUtils");var QM=class{constructor(a){this.g=new _.S("clpp.hls.MediaReader");this.f=a;this.a={attemptParameters:_.rj()}}};var rM=class{constructor(a){this.streams=a}length(){return this.streams.length}};var pM=class{constructor(a){this.a=a}length(){return this.a.length}};var RM=class{constructor(){this.a=this.D=null;this.h=1;this.f=new PM;this.A="";this.O=new OM;this.G=0;this.l=null;this.j=new _.Ck(()=>{this.Sb()});this.o=_.Sb;this.C=null;this.F=new _.au;this.J=this.B=null;this.g=new _.S("clpp.hls.HlsParser");this.K=new Map;this.R=new QM(this.H.bind(this));this.M=!1;this.I=null;this.L=!1;this.w=new Map}configure(a){this.a=a;this.R.a=a}setCurrentVariant(a){this.l=a}start(a,b){const c=this;return _.x(function*(){if(c.M)throw Error("start() may be called only once!");
72
- c.M=!0;c.D=b;const {response:d,text:e}=yield RL(c,a);c.A=d.uri;const f=yield XL(c,e);c.C=f;const g=c.G;c.j&&0<g&&c.j.ga(g);return f})}requestStop(){this.L=!0}stop(){this.j&&(this.j.stop(),this.j=null);const a=[];this.F&&(a.push(this.F.destroy()),this.F=null);this.f.clear();this.C=this.a=this.D=this.l=null;this.w.clear();return Promise.all(a)}update(){const a=this;return _.x(function*(){const b=a.C;if(!VL(a)&&b){var c=b.presentationTimeline;"LIVE"===a.o&&(a.B=null);var d=Array.from(a.f.values());if(a.a.lowLatencyMode&&
73
- null!==a.l){const g=QL(a);d=d.filter(h=>g.includes(HK(h).Fa))}var e=yield ZL(a,d);d=e.map(g=>g.playlist);aM(a,d);e=yield dM(a,e);EL(b.periods,e).forEach(g=>{a.D.filterNewPeriod(g)});UL(a,e);var f=eM(a,d);f=fM(a,d,f);b.cues=WL(a,f);GL(b.periods,e);PL(c,e);if(d=rK(d))!0!==a.a.keepTimelineLive&&gM(a,c,e),a.j.stop(),a.j=null;if(a.D.onUpdate)a.D.onUpdate(b);if(d&&a.D.onTurnedStatic)a.D.onTurnedStatic();a.L&&(yield a.stop());return b}})}Sb(){const a=this;return _.x(function*(){a.g.debug(_.XB);if(a.D)try{yield a.update(),
74
- a.j&&0<a.G&&a.j.ga(a.G)}catch(b){if(!(b instanceof _.H))throw b;a.D&&(a.D.onError(b),1===b.severity&&a.j&&a.j.ga(.1))}})}H(a){if(!this.F)throw new _.H(_.F,7,7001);a=this.D.networkingEngine.fetch(a);_.Gj(this.F,a);return a.U}};_.z("clpp.hls.HlsComponent",class extends _.pv{f(){_.Ms.m3u8=RM;_.Ks[_.xl]=RM;_.Ks[$J]=RM}a(){_.nE("m3u8");_.oE(_.xl);_.oE($J)}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 wK="CLOSED-CAPTIONS",xK="Could not parse MP4 segment start time.",yK="DURATION",zK="EXT-X-MEDIA",AK="EXT-X-STREAM-INF",BK="Failed to infer discontinuity number",CK="Guessing audio-only",DK="METHOD",EK="SAMPLE-AES-CTR",FK="SUBTITLES",GK="application/vnd.apple.mpegurl",HK="sample",IK=function(a,b){return _.J(a,b,void 0,{required:!0})},JK=function(a){if(1>a.a)throw _.nm();--a.a},KK=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===_.Se&&e&&typeof e===
2
+ _.Se){if(!KK(d,e))return!1}else if(void 0!==d&&void 0!==e&&d!==e)return!1}return!0},LK=function(a,b){if(!KK(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===_.Se&&e&&typeof e===_.Se&&LK(d,e))return!0}return!1},MK=function(a){if(null!==a&&void 0!==a)return Number(a)},NK=function(a,b){return a.filter(c=>c.name===b)},OK=function(a){const b=/^[a-zA-Z0-9_-]+$/,c=new Set;a.forEach(d=>{const e=_.J(d,"VALUE"),f=_.J(d,_.gb),g=_.J(d,"IMPORT"),h=_.J(d,"QUERYPARAM");
3
+ if(1!==[f,g,h].filter(Boolean).length||f&&null==e)throw new _.I(_.F,4,4044,{message:"Invalid tag.",text:d.toString()});d=f||g||h;if(c.has(d))throw new _.I(_.F,4,4044,`EXT-X-DEFINE redefined variable "${d}".`);if(!b.test(d))throw new _.I(_.F,4,4044,`EXT-X-DEFINE invalid variable name "${d}".`);c.add(d)})},PK=function(a,b){const c=Array.isArray(b)?b:[b];return a.filter(d=>{d=IK(d,_.Ib);return c.includes(d)})},QK=function(a,b){return a.some(c=>c.name===b)},RK=function(a,b,c){c=void 0===c?{}:c;a=a.find(d=>
4
+ d.name===b)||null;if(!a&&c.required)throw new _.I(_.F,4,4024,{missingTag:b});return a},SK=function(a){var b=RK(a,"EXT-X-TILES");if(!b)return{hd:1,Dd:1,durationPerTile:null};a=_.J(b,"LAYOUT")||"1x1";b=_.J(b,yK);a=_.lD(a);return{hd:a.hd,Dd:a.Dd,durationPerTile:b?Number(b):null}},TK=function(a,b,c){c=void 0===c?!0:c;a=new _.Ci(a);b=new _.Ci(b);b=a.resolve(b).toString();return c?b:decodeURI(b)},UK=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=>
5
+ b.add(c));a.thumbStreams.forEach(c=>b.add(c));return Array.from(b)},VK=function(a,b){Array.isArray(a)||(a=[a]);a.forEach(c=>{for(const d of UK(c))b(d,c)})},WK=function(a){return a.some(b=>QK(b.ca,_.Fa))},XK=function(a){return a.type===_.p||a.type===_.w},YK=function(a){if(RK(a,_.Fa))return _.Ub;a=RK(a,_.Ka);if(!a)return"LIVE";if(a.value===_.Ub)return _.Ub;if("EVENT"===a.value)return"EVENT";throw new _.I(_.F,4,4044,`Invalid EXT-X-PLAYLIST-TYPE value: ${a.value}`);},ZK=function(a){a={AUDIO:_.p,VIDEO:_.w,
6
+ SUBTITLES:_.H,"CLOSED-CAPTIONS":_.H}[a.toUpperCase()];if(!a)throw new _.I(_.F,4,4044,"EXT-X-MEDIA tag has an invalid TYPE attribute.");return a},$K=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(_.F,4,4044,"Byte range length must be positive.");if(d[1]){if(d=Number(d[1]),0>d)throw new _.I(_.F,4,4044,"Byte range start byte must not be negative.");}else{if(c)throw new _.I(_.F,4,4044,"Invalid byte range, offset is required but missing.");
7
+ if(null==b)throw new _.I(_.F,4,4044,"Invalid byte range, cannot calculate offset based on previous byte ranges.");d=b+1}e=d+a-1}return{za:d,qa:e}},aL=function(a,b){a=RK(a,_.Aa);return $K(a?a.value:null,b)},bL=function(a){a=RK(a,"EXTINF",{required:!0}).value.split(",");return{duration:Number(a[0]),title:a[1]||null}},cL=function(a,b){b=void 0===b?{}:b;const c={Ef:!1,Yg:!1,Zg:null,Dh:null,mg:null};a=RK(a,_.Oa,{required:b.rg});if(!a)return c;const d=e=>null==e?null:Number(e);c.Ef="YES"===_.J(a,"CAN-BLOCK-RELOAD");
8
+ c.Yg="YES"===_.J(a,"CAN-SKIP-DATERANGES");c.Zg=d(_.J(a,"CAN-SKIP-UNTIL"));c.Dh=d(_.J(a,"HOLD-BACK"));c.mg=d(_.J(a,"PART-HOLD-BACK",void 0,{required:b.rg}));return c},dL=function(a,b,c){c=void 0===c?!1:c;a=_.J(a,"BYTERANGE");return $K(a,b,c)},eL=function(a){const b=NK(a,zK),c=NK(a,AK);a=NK(a,"EXT-X-IMAGE-STREAM-INF");return{zc:{zf:PK(b,[_.EB,_.Tb]),closedCaptions:PK(b,wK),vi:PK(b,FK)},Ed:c,Ae:a}},gL=function(a,b){const c=aL(a.ca,null);return new fL(0,0,0,()=>[a.a],c.za,c.qa,0,b)},hL=function(a){let b=
9
+ Infinity,c=Infinity;UK(a).filter(XK).forEach(d=>{{d=d.T;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{Sc:b,duration:c}},iL=function(a){return a.map(b=>{({duration:b}=hL(b));return b}).reduce((b,c)=>b+c,0)},jL=function(a){return(a.video?a.video.Ga:"")+" - "+(a.audio?a.audio.Ga:"")},kL=function(a,b,c,d,e){if(b===_.Ub)return{delay:0,Cd:0};b=RK(a,_.Ja);if(c&&b){e=Number(IK(b,"PART-TARGET"));if(null!=d)return{delay:d,Cd:e};({mg:d}=cL(a,{rg:!0}));
10
+ return{delay:d,Cd:e}}a=RK(a,_.Pa,{required:!0});a=Number(a.value);e=e||a;return null!=d?{delay:d,Cd:e}:{delay:3*a,Cd:e}},mL=function(a){const b=new Map;a.forEach(c=>{var d=`${lL(c).type}:${lL(c).groupId}`;b.has(d)?(d=b.get(d),d.includes(c)||d.push(c)):b.set(d,[c])});return b},nL=function(a){const b=new Map;for(const c of a){a=_.J(c,_.$a);a=_.Qi(a||_.tg);const d=IK(c,_.Ua),e=IK(c,"INSTREAM-ID");b.has(d)||b.set(d,new Map);b.get(d).set(e,a)}return b},oL=function(a){return a.filter(b=>"mp4a.40.34"!==
11
+ b)},pL=function(a,b){if(!a)return null;const c=a.Ga;return b.find(d=>lL(d).Ga===c)||null},qL=function(a){return(a=_.J(a,"CHANNELS"))?parseInt(a.split("/")[0],10):null},rL=function(a){for(const b of a)if(b.startsWith("#EXT-")&&(a=_.Xi(0,b),_.pu.has(a.name)))return 1;return 0},sL=function(a,b){return a.replace(/\{\$([a-zA-Z0-9_-]+)\}/g,(c,d)=>{c=b.get(d);if(null==c)throw new _.I(_.F,4,4044,`Undefined variable '${d}'`);return c})},tL=function(a,b){a.forEach(c=>{c.attributes.forEach(d=>{d.value=sL(d.value,
12
+ b)})})},uL=function(a,b,c){tL(a,c);b.forEach(d=>{d.a&&(d.a=sL(d.a,c));tL(d.ca,c);tL(d.f,c)})},vL=function(a,b){const c=new Map,d=new URL(b);a.forEach(e=>{var f=_.J(e,_.gb),g=_.J(e,"QUERYPARAM");if(f)g=IK(e,"VALUE"),c.set(f,g);else if(g){f=d.searchParams.get(g);if(null==f)throw new _.I(_.F,4,4044,`Query param '${g}' missing in playlist URI.`);if(!f)throw new _.I(_.F,4,4044,`Query param '${g}' has no associated value`+" in playlist URI.");c.set(g,decodeURIComponent(f))}});return c},yL=function(a,b,
13
+ c){const d=[];for(let e=1;e<b.length;e++){const f=wL(a,b[e]);d.push(f);if(f.name===AK){const g=b[e+1];if(!g)throw new _.I(_.F,4,4044,"EXT-X-STREAM-INF is not followed by a URI.");f.attributes.push(new _.Vi(_.Kb,g));e++}}b=NK(d,_.Ca);OK(b);b=vL(b,c);a.a=b;uL(d,[],a.a);return new xL(c,0,d)},BL=function(a,b,c){let d=[];for(var e=1;e<b.length;){const f=wL(a,b[e]);if(_.qu.has(f.name))break;d.push(f);e++}b=zL(a,c,b.slice(e));e=b.T;d=d.concat(b.ca);a=AL(a,d,c);uL(d,e,a);return new xL(c,1,d,b.T)},CL=function(a,
14
+ 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(_.F,4,4015);return 0===rL(b)?yL(a,b,c):BL(a,b,c)},wL=function(a,b){return _.Xi(a.h++,b)},zL=function(a,b,c){const d=[],e=[];let f=[],g=[];c.forEach(h=>{/^(#EXT)/.test(h)?(h=wL(a,h),_.pu.has(h.name)||_.tu.has(h.name)||_.su.has(h.name)?d.push(h):_.ru.has(h.name)?"EXT-X-PART"===h.name?g.push(h):h.name===_.La&&"PART"===_.J(h,_.Ib)&&g.push(h):f.push(h)):/^#(?!EXT)/m.test(h)||
15
+ (h=TK(b,h.trim(),!1),e.push(new DL(h,f,g)),f=[],g=[])});0<g.length&&e.push(new DL(null,f,g));return{T:e,ca:d}},AL=function(a,b,c){b=NK(b,_.Ca);OK(b);const d=vL(b,c);b.map(e=>_.J(e,"IMPORT")).filter(Boolean).forEach(e=>{const f=a.a.get(e);if(null==f)throw new _.I(_.F,4,4044,`Cannot import variable '${e}' as it is not defined `+"in the master playlist");d.set(e,f)});return d},EL=function(a,b,c){const d=[],e=[];e.push(new _.Vi(_.la,"0"));e.push(new _.Vi(_.Kb,b));c.length&&e.push(new _.Vi(_.oa,c));d.push(new _.Wi(a.h++,
16
+ AK,e));return new xL(b,0,d)},FL=function*(a){let b=-1,c=void 0,d=void 0;for(const e of a)0<=b&&(yield{Yf:b,item:d,Zh:c,next:e}),b++,c=d,d=e;-1!==b&&(yield{Yf:b,Zh:c,item:d,next:void 0})},GL=function(a){return 0>a?[]:Array.from({length:a},(b,c)=>c)},HL=function(a){return new Uint8Array([a>>24&255,a>>16&255,a>>8&255,a&255])},IL=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},JL=function(a){function b(h,
17
+ 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(_.F,4,4030);}IL(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),
18
+ 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}}IL(a,e)||d();e+=10;e+=f}while(e<a.byteLength);return d()},KL=function(a,b){let c=null,d=0;try{(new _.Dm).N(_.Oe,_.wm).N(_.qg,_.wm).N(_.Je,_.wm).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 _.Tv.error("Unable to find timescale in init segment!"),new _.I(_.F,4,4030,xK,c);let e=0,f=!1;try{(new _.Dm).N("moof",_.wm).N("traf",_.wm).ea("tfdt",
19
+ 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(_.F,4,4030,xK,c);return e},LL=function(a){for(;a.getPosition()<a.Sa()-1;){const b=a.getPosition();if(71===_.om(a))return JK(a),b}return-1},ML=function(a){function b(){d.seek(e+
20
+ 188);f=_.om(d);71!==f&&(d.seek(e+192),f=_.om(d));71!==f&&(d.seek(e+204),f=_.om(d));71!==f&&c();JK(d)}function c(){throw new _.I(_.F,4,4030);}const d=new _.An(new DataView(a),!1);let e=0,f=0;e=LL(d);0>e&&(_.Tv.error("Unable to find sync byte in TS after scanning."),c());for(;;){e=d.getPosition();f=_.om(d);71!==f&&c();a=_.pm(d);if(8191===(a&8191)){b();continue}if(!(a&16384)){b();continue}a=(_.om(d)&48)>>4;0!==a&&2!==a||c();3===a&&(a=_.om(d),d.skip(a));if(1!==_.P(d)>>8){b();continue}d.skip(3);a=_.om(d)>>
21
+ 6;0!==a&&1!==a||c();0===_.om(d)&&c();a=_.om(d);const g=_.pm(d),h=_.pm(d);return(1073741824*((a&14)>>1)+((g&65534)<<14|(h&65534)>>1))/9E4}},PL=function(a){const b=NL(a),c=OL(a);a.forEach(d=>{const e=d.T,f=e.findIndex(h=>h.pa===b);let g=e.findIndex(h=>h.pa===c+1);-1===g&&(g=e.length);d.T=e.slice(f,g)})},OL=function(a){a=a.map(b=>b.T[b.T.length-1].pa);return Math.min(...a)},NL=function(a){a=a.map(b=>b.T[0].pa);return Math.max(...a)},SL=function(a){var b=IK(a,DK);if(!QL.includes(b))return RL.error("PlayReady in HLS is only supported with [",
22
+ QL.join(", "),"], not",b),null;a=IK(a,_.Kb);b=_.At(a);a=null;b=_.K(b.data);try{a=_.UC(_.In(b))}catch(c){a=b}return _.hD(_.Hd,[{initDataType:_.kd,initData:a}],"")},UL=function(a){if(0===a.length)return TL();if(a.some(c=>"whole-segment"===c.type)||a.every(c=>c.type===_.Re))return a[0];a=a.filter(c=>c.type===HK);const b=_.ti(a.flatMap(c=>c.drmInfos));return{keyId:a[a.length-1].keyId,type:HK,drmInfos:b}},XL=function(a,b){return VL(a).map(c=>WL(c.ca,b)).filter(Boolean)},VL=function(a){return a.filter(b=>
23
+ QK(b.ca,_.Ga))},WL=function(a,b){a=NK(a,_.Ga).filter(d=>"AES-128"!==IK(d,DK));if(0===a.length)return null;var c=IK(a[0],DK);if(1===a.length&&"NONE"===c)return TL();c=a.map(d=>IK(d,DK));if(!c.every(d=>"SAMPLE-AES"===d)&&!c.every(d=>d===EK))throw YL.warn(`EXT-X-KEY methods ${c.join(", ")} are incompatible.`),new _.I(_.F,4,4044,"Multiple EXT-X-KEY tags with incompatible METHOD values.");a=a.map(d=>{const e=_.J(d,"KEYFORMAT","identity");{const f=ZL[e]||null;d=f?f(d,b):null}d||YL.warn("Unsupported HLS KEYFORMAT",
24
+ e);return d}).filter(Boolean);if(0===a.length)throw new _.I(_.F,4,4026);return{keyId:a.map(d=>d.keyIds).reduce((d,e)=>d.concat(e),[]).reverse()[0]||null,type:HK,drmInfos:a}},TL=function(){return{type:_.Re,drmInfos:[],keyId:null}},$L=function(a,b,c){a=NK(a,_.Ga)[0];if(!a||"AES-128"!==IK(a,DK))return null;var d=_.J(a,"IV","");d?c={iv:_.Zl((d||"0x").slice(2)),generatedIv:!1}:(d=_.J(a,"KEYFORMAT"),c=null==d||"identity"===d?{iv:_.bm(new Uint8Array(12),HL(c)),generatedIv:!0}:{iv:null,generatedIv:!1});const {iv:e,
25
+ generatedIv:f}=c;return{method:"AES-128",url:TK(b,IK(a,_.Kb)),iv:e,generatedIv:f}},aM=function(a,b,c){return _.x(function*(){const d=b.f(),e=_.PD(b.ab(),b.za,b.za+2048-1,a.a.attemptParameters);e.type=2;const f=_.PD(b.ab(),b.za,b.qa,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(_.F,4,4030,"Failed to fetch the media segment.");}}})},bM=function(a,b,c,d,e,f){return _.x(function*(){a.g.debug("Fetching segment to find start time");if("audio/mpeg"===d||d===_.Tc||d===_.Sc)return 0;if(d===_.Rc){var g=yield aM(a,c,f);g=_.K(g.data);if(!IL(g))throw new _.I(_.F,4,4030,"AAC segment does not contain an ID3 tag.");return JL(g)}if(d===_.Ig||d===
27
+ _.Uc)return g=[aM(a,c,f)],b&&g.push(aM(a,b,!0)),g=yield Promise.all(g),KL(g[0].data,(g[1]||g[0]).data);if(d===_.Hg)return g=yield aM(a,c,f),ML(g.data);if(!_.Is(`${d.split("/")[0]||""}/mp4;codecs="${e}"`))return 0;throw new _.I(_.F,4,4030);})},cM=function(a,b){a=a.map(c=>c.streams[b]);return a.some(c=>null==c)?null:a},dM=function(a,b){a=a.streams.find(c=>{c=c.T;return c[0].position<=b&&b<=c[c.length-1].position});return null==a?null:a.T.find(c=>c.position===b)||null},lL=function(a){return a.streams[0]},
28
+ eM=function(a,b){a.streams.forEach(c=>{c.le=b})},fM=function(a,b){a.streams.forEach(c=>{c.width=b})},gM=function(a,b){a.streams.forEach(c=>{c.height=b})},hM=function(a,b){a.streams.forEach(c=>{c.frameRate=b})},iM=function(a,b){a.streams.forEach(c=>{c.bandwidth=b})},jM=function(a,b){a=a.map(c=>c.a[b]);return a.some(c=>null==c)?null:a},kM=function(a,b){const c=new Set(a.map(d=>d.pa));return b.filter(d=>!c.has(d.pa))},mM=function(a,b){for(;a[0].pa<b[0].pa;)a.splice(0,1);var c=a[0];let d=b[0];c.startTime===
29
+ d.startTime&&c.endTime===d.endTime||lM(c,d);const e=a.length-1;c=a[e];d=b[e];0<e&&(c.startTime!==d.startTime||c.endTime!==d.endTime)&&lM(c,d);for(c=e+1;c<b.length;)a.push(b[c]),c++},rM=function(a,b,c,d,e){var f=b[0].length();f=GL(f).map(g=>{var h=jM(b,g)||[];const k=cM(c,g)||[];g=cM(d,g)||[];{const l=[...nM(h),...k,...g].filter(Boolean);oM(l);const {pa:m,duration:n}=l[0];h={configurationId:a,variants:h,textStreams:k,thumbStreams:g,startTime:0,id:`P${m}`,endTime:n,duration:n,pa:m}}return h});e&&pM(f[0]);
30
+ qM(f);return f},nM=function(a){a=new Set(a.flatMap(b=>[b.video,b.audio]).filter(Boolean));return Array.from(a)},pM=function(a){const b=nM(a.variants)[0].T[0].Fa;a.startTime+=b;a.endTime+=b},qM=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}},lM=function(a,b){a.startTime=b.startTime;a.endTime=b.endTime;a.duration=b.duration;sM(a.variants,b.variants);tM(UK(a),UK(b))},sM=function(a,b){const c=new Map(a.map(d=>[jL(d),
31
+ d]));b.forEach(d=>{c.get(jL(d)).drmInfos=d.drmInfos})},tM=function(a,b){const c=new Map(a.map(d=>[d.Ga,d]));b.forEach(d=>{const e=c.get(d.Ga);e.T=d.T;d.T.forEach(f=>{f.initSegment=e.initSegmentReference});e.segmentIndex.replace(d.T);e.Sc=d.Sc;e.Ee=d.Ee;e.duration=d.duration;e.Lf=d.Lf;e.encrypted=d.encrypted;e.drmInfos=d.drmInfos;e.keyId=d.keyId})},oM=function(a){const b=uM(a);a.forEach(c=>{_.LD(c.segmentIndex,b);c.duration=b;c.Ee=c.Sc+b})},uM=function(a){let b=Infinity;a.filter(XK).forEach(c=>{b=
32
+ Math.min(b,c.duration)});return b},vM=function(a,b){VK(b,(c,d)=>{_.YD(a,c.T,d.startTime)});_.QD(a.a,b[0].startTime,b[b.length-1].endTime)},wM=function(a){return null===a.o?[]:[a.o.audio,a.o.video].filter(b=>b).map(b=>b.Ga)},xM=function(a,b){return _.x(function*(){var c=_.Bj([b],a.a.attemptParameters);c.type=1;c=yield a.H(c);let d="";try{d=_.ij(c.data)}catch(e){throw new _.I(_.F,4,4042);}d=d.replace(/\r\n|\r(?=[^\n]|$)/gm,"\n");d=d.trim();return{text:d,response:c}})},IM=function(a,b){return _.x(function*(){var c=
33
+ yM(a,b,a.w,"");if(1===c.type){var d=c.T[0].a;c=zM(d);if(!c)throw new _.I(_.F,4,4021,`Unknown file extension ${d}`);d="";c===_.w?d="avc1.42E01E":c===_.p&&(d="mp4a.40.2");c=EL(a.R,a.w,a.a.hlsDefaultCodecs||d)}d=eL(c.ca);c=AM(d.zc.zf);c.forEach(m=>{a.J.add(m.groupId)});var e=yield BM(a,d);var f=e.Nh;const g=e.periods;var h=e.ai;const k=e.xi;d=e.alternativeVariants;const l=e.alternativeTextStreams;e=e.alternativeImageStreams;if(!a.D)throw new _.I(_.F,7,7001);CM(a,g);h=DM(a,f.delay,g,h);EM(a)||(a.G=f.Cd,
34
+ FM(a));GM(a,h,g);f=HM(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})},KM=function(a,b){return Promise.all(b.map(c=>JM(a,c)))},MM=function(a,b){b.forEach(c=>{a:{var d=a.j.get(c.verbatimUri),e=!EM(a),f=RK(c.ca,_.Ea);if(f)var g=Number(f.value);else{d?(f=d.streams[d.streams.length-1].T,f=f[f.length-1].pa):f=0;if(e&&0<f)try{{const k=
35
+ RK(c.ca,_.Ia);if(!k)throw LM.error("Failed to infer discontinuity number, because EXT-X-MEDIA-SEQUENCE tag is missing."),Error(BK);const l=Number(k.value),m=dM(d,l);if(!m)throw LM.error("Failed to infer discontinuity number, could not find the appropriate segment in the previous playlist"+` (segment position = ${l})`),Error(BK);var h=m.pa}g=h;break a}catch(k){throw new _.I(_.F,4,4024,"EXT-X-DISCONTINUITY-SEQUENCE tag is required for discontinuous HLS live streams.");}g=0}}c=c.T||[];for(const k of c)QK(k.ca,
36
+ _.Da)&&g++,k.pa=g});PL(b)},PM=function(a,b){return _.x(function*(){const {textStreams:c,thumbStreams:d,Sg:e}=yield NM(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=pL(g.audio,e),k=pL(g.video,e);g=OM(a,h,k,g.bandwidth);if(!g)throw new _.I(_.F,4,4047,{message:"Video and audio are encrypted in an incompatible way.",cj:k?lL(k).Ga:void 0,audio:h?lL(h).Ga:void 0});return g});return rM(a.D.configurationId,f,c,d,!0)})},CM=function(a,
37
+ b){EM(a)||2!==a.a.timeline.version||(a.I||(a.I=b[0].startTime),_.hF(b,-a.I))},QM=function(a,b){b=b.flatMap(d=>d.T[0].ca);b=RK(b,_.Ma);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},RM=function(a,b,c){b=b.find(d=>null!==RK(d.ca,_.Ba));if(!b)return[];if(null===c)throw new _.I(_.F,4,4024,"EXT-X-PROGRAM-DATE-TIME tag is required when EXT-X-DATERANGE tags are present");return b.ca.filter(d=>
38
+ d.name===_.Ba).map(d=>{a:{var e=a.C,f=!EM(a),g=_.J(d,"ID"),h=_.J(d,"START-DATE");if(null===g||null===h)_.ou.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);h=k.getTime()/1E3+e;g={id:g,startTime:h,startDate:k};f=MK(_.J(d,yK));void 0!==f&&0<=f&&(g.duration=f);var l=MK(_.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,
39
+ "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=_.oh(k)?k:null}}r=r||{};(k=_.J(d,"CUE"))&&(r.CUE=k.split(","));if(m===_.Fd){k=d.attributes;if(null==k)var u=null;else{m={};for(u of k)switch(u.name){case _.ac:m[_.ac]=u.value;break;case _.$b:m[_.$b]=u.value;break;case _.gc:m[_.gc]=MK(u.value);break;case _.bc:m[_.bc]=MK(u.value);break;case "X-SNAP":m["X-SNAP"]=
40
+ u.value.split(",");break;case _.cc:m[_.cc]=u.value.split(",")}m[_.ac]&&m[_.$b]||!m[_.ac]&&!m[_.$b]?(_.ou.warn("Invalid EXT-X-DATERANGE Interstitial attributes X-ASSET-URI, X-ASSET-LIST"),u=null):u=_.oh(m)?m:null}if(null===u){_.ou.warn("Invalid interstitial attributes, ignoring the EXT-X-DATERANGE tag.",d);d=null;break a}r=Object.assign(r,u)}_.oh(r)&&(g.customAttributes=r);g.endTime=n?n.getTime()/1E3+e:f?h+f:l?h+l:h;g.type=_.hi;d=g}}return d}).filter(Boolean)},HM=function(a,b){const c=new Set(b.map(d=>
41
+ 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.startTime!==d.startTime)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,endTime:d.endTime,id:d.id,type:_.hi,eventElement:null};b&&!LK(b,e)||a.B.set(d.id,e)}return Array.from(a.B.values())},SM=function(a,b,c){a.A=_.Ub;_.UD(b,!0);
42
+ b.f=c[c.length-1].endTime},yM=function(a,b,c,d){a=CL(a.R,b,c);a.verbatimUri=d;return a},AM=function(a){return a.filter(b=>b.name===zK&&_.J(b,_.Ib)===_.EB&&!_.J(b,_.Kb)).map(b=>{const c=qL(b),d=_.J(b,_.$a)||_.tg;return{groupId:IK(b,_.Ua),id:_.fK++,label:IK(b,_.gb),language:d,channelsCount:c,primary:"YES"===_.J(b,"DEFAULT")}})},BM=function(a,b){return _.x(function*(){var c=nL(b.zc.closedCaptions),d=TM(a,b.Ed),e=yield UM(a,b),f=Object.values(e).flat().map(h=>h.playlist);MM(a,f);f=f[0];var g=YK(f.ca);
43
+ a.A=g;a.K=cL(f.ca);f=kL(f.ca,g,a.a.lowLatencyMode||!1,a.a.suggestedPresentationDelay,a.a.liveRefreshPeriod);g=yield VM(a,e.Af,d);c=yield WM(a,e.Ed,g,c);d=yield XM(a,e.si,d);g=yield YM(a,e.Ae);d=rM(a.D.configurationId,c,d,g,!EM(a));a.D.filterAllPeriods(d);c=[...e.Ed,...e.Af].map(h=>h.playlist);e=QM(a,c);c=RM(a,c,e);return{periods:d,ai:e,xi:c,Nh:f}})},DM=function(a,b,c,d){let e=!0,f=null,g=0;EM(a)||(e=!1,f=0,g=b);b=a.a.timeline||{};b.type=void 0;a=new _.iK(b,f,g,!0,void 0,!!a.a.lowLatencyMode);_.UD(a,
44
+ e);vM(a,c);d&&_.TD(a,d);return a},FM=function(a){var b=0;for(var c of a.j.values())b=Math.max(b,c.streams[0].Sc);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.Sc?(a.g.debug("Offset applied to",b.type),b.segmentIndex.offset(c)):a.g.debug("Offset NOT applied to",b.type)}},GM=function(a,b,c){c=iL(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===_.Ub&&(b.f=c)},NM=function(a,b){return _.x(function*(){const c=g=>lL(g.stream).type===_.w||lL(g.stream).type===_.p;var d=b.filter(c),e=b.filter(g=>!c(g)),f=g=>{g=g.map(h=>{var k=lL(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.Ga,
46
+ Fd:{width:k.width,height:k.height,frameRate:k.frameRate}};h=Object.assign({},{playlist:h.playlist},k);return ZM(a,h)});return Promise.all(g)};d=yield f(d);f=yield f(e);$M(a,d.concat(f));e=f.filter(g=>lL(g).type===_.NC);f=f.filter(g=>lL(g).type===_.re);return{textStreams:e,thumbStreams:f,Sg:d}})},OM=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?_.nD(l.drmInfos,m.drmInfos)?_.mD(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:_.tg,primary:!!h&&h.primary||!!k&&k.primary,audio:h,video:k,bandwidth:m,drmInfos:l,allowedByApplication:!0,allowedByKeySystem:!0};f.push(h)}return new aN(f)},ZM=function(a,b){return _.x(function*(){const c=b.playlist,d=b.codecs,e=b.type,f=b.Qc,g=b.jc,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.Fd,A=_.Qi(f||_.tg);if(1!==c.type)throw new _.I(_.F,
48
+ 4,4017);const E=yield bN(a,c,e,d),G=a.a.lowLatencyMode?_.CC:_.BC;let X=m;e!==_.H||m||(X=_.NC);const dd=YK(c.ca);m=E.map(dc=>{const Mb=dc.T,Zd=dc.fh,Nb=dc.mimeType,ec=dc.pa,fc=Mb[0].startTime,Eb=Mb[Mb.length-1].endTime,ib=Eb-fc,va=new _.jK(Mb),wb=Mb[0].initSegment||null;return{id:null===g?_.fK++:g,originalId:n,createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:va.f.bind(va),getSegmentReference:va.get.bind(va),adjustSegmentDurations:va.h.bind(va),getDuration:va.getDuration.bind(va),
49
+ segmentIndex:va,segmentLookupStrategy:G,initSegmentReference:wb,mimeType:Nb,codecs:d,kind:X,Lf:Zd.type,encrypted:Zd.type===HK,aesEncrypted:dc.aesEncrypted,keyId:Zd.keyId,language:A,originalLanguage:f||_.tg,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:r,spatialAudio:u,closedCaptions:v,T:Mb,drmInfos:Zd.drmInfos,pa:ec,Ga:c.verbatimUri,le:c.a,Sc:fc,Ee:Eb,duration:ib,
50
+ groupId:h,Xi:dd,muxedAudioId:k}});return new cN(m)})},$M=function(a,b){b.forEach(c=>{a.j.a.set(lL(c).Ga,c)})},TM=function(a,b){const c=new Map;for(const f of b){var d=_.J(f,_.EB);b=_.J(f,_.Tb);var e=_.J(f,FK);const g=dN(a,f);if(e){const h=_.nk(_.H,g);c.set(`${_.H}:${e}`,h);e=g.indexOf(h);-1<e&&g.splice(e,1)}d&&(e=eN(_.p,g),c.set(`${"audio"}:${d}`,e));b&&(d=eN(_.w,g),c.set(`${"video"}:${b}`,d))}return c},UM=function(a,b){return _.x(function*(){const c=yield Promise.all([fN(a,b.zc.zf),fN(a,b.zc.vi),
51
+ fN(a,b.Ed),fN(a,b.Ae)]),[d,e,f,g]=c;return{Af:d,si:e,Ed:f,Ae:g}})},VM=function(a,b,c){return _.x(function*(){if(0===b.length)return new Map;var d=[gN(a,b[0],c)];yield d[0];d=d.concat(b.slice(1).map(e=>gN(a,e,c)));d=yield Promise.all(d);return mL(d)})},WM=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(IK(f[k].tag,_.la));l<h&&(h=l,g=k)}h=f.splice(g,1).pop();h=yield hN(a,h,c,d,e);f=f.map(k=>hN(a,k,c,d,e));f=yield Promise.all(f);
52
+ f.splice(g,0,h);return f.reduce(_.eD,[])})},XM=function(a,b,c){return Promise.all(b.map(d=>gN(a,d,c)))},YM=function(a,b){return Promise.all(b.map(c=>iN(a,c)))},jN=function(a,b){return _.x(function*(){const c=TK(a.w,b.verbatimUri),{response:d,text:e}=yield xM(a,c);return yM(a,e,d.uri,b.verbatimUri)})},kN=function(a,b,c){return _.x(function*(){const d=yield ZM(a,{playlist:c,codecs:b.codecs,type:b.type,Qc:b.originalLanguage,jc:b.id,groupId:b.groupId,primary:b.primary,kind:b.kind||null,name:b.label,channelsCount:b.channelsCount,
53
+ spatialAudio:b.spatialAudio||!1,closedCaptions:b.closedCaptions,Fd:{width:b.width,height:b.height,frameRate:b.frameRate}});b.bandwidth&&iM(d,b.bandwidth);return d})},EM=function(a){return a.A===_.Ub},fN=function(a,b){return _.x(function*(){return(yield Promise.all(b.map(c=>_.x(function*(){const d=yield lN(a,c);return d?{tag:c,playlist:d}:null})))).filter(Boolean)})},JM=function(a,b){return _.x(function*(){var c=new _.Ci(lL(b).le);if(a.a.lowLatencyMode&&a.K&&a.K.Ef){var d=b.streams[b.streams.length-
54
+ 1].segmentIndex;if(d=d.a[d.a.length-1]){var e=d.a,f=e.length-1;d={Oh:d.position,Uh:e&&0<e.length?f:null}}else d=null;if(e=d)d=e.Oh,e=e.Uh,f=_.bk(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=_.ak(f,!0),d=new _.Ji(d),_.Fi(c,d)}const {response:g,text:h}=yield xM(a,c.toString());c=lL(b).Ga;d=lL(b).le;e=g.uri;d!==e&&(d=e,eM(b,d));c=yM(a,h,d,c);return{stream:b,playlist:c}})},dN=function(a,b){var c=_.J(b,_.oa,a.a.hlsDefaultCodecs||
55
+ "avc1.42E01E,mp4a.40.2").split(/\s*,\s*/);c=oL(c);b=new Set;const d=[];for(const e of c)c=_.tD(e),b.has(c)?a.g.debug("Ignoring duplicate codec"):(d.push(e),b.add(c));return d},eN=function(a,b){if(1===b.length)return b[0];a=_.nk(a,b);if(null!=a)return a;throw new _.I(_.F,4,4025,{codecList:b});},gN=function(a,b,c){return _.x(function*(){const d=b.tag,e=b.playlist;return mN(a,e.verbatimUri,()=>_.x(function*(){const f=IK(d,_.Ua),g=ZK(IK(d,_.Ib));var h=IK(d,_.Ib).toUpperCase();if(ZK(h)!==_.H)h=null;else{var k=
56
+ d.getAttribute("FORCED");k=!(!k||!k.value||"YES"!==k.value.toUpperCase());var l=_.NC;h===wK&&(l=_.wC);k&&(l=_.le);h=l}k=c.get(`${g}:${f}`)||"";l=_.J(d,_.$a);const m=_.J(d,_.gb),n=_.J(d,"DEFAULT"),r=g===_.p?qL(d):null;var u=g===_.p?(u=_.J(d,"CHANNELS"))?u.includes("/JOC"):!1:!1;return yield ZM(a,{playlist:e,codecs:k,type:g,Qc:l,primary:"YES"===n,name:m,channelsCount:r,spatialAudio:u,groupId:f,kind:h,jc:null,closedCaptions:null,Fd:null})}))})},iN=function(a,b){return _.x(function*(){const c=b.tag,d=
57
+ b.playlist;return mN(a,d.verbatimUri,()=>_.x(function*(){var e=_.J(c,_.oa)||"jpg",f=_.J(c,_.$a);const g=_.J(c,_.gb);e=yield ZM(a,{playlist:d,codecs:e,type:_.re,Qc:f,name:g,primary:!1,kind:null,channelsCount:null,spatialAudio:!1,closedCaptions:null,jc:null,groupId:null,Fd:null});(f=_.J(c,_.la))&&iM(e,Number(f));return e}))})},hN=function(a,b,c,d,e){return _.x(function*(){var f=b.tag,g=Number(IK(f,_.la));if(f.hasAttribute("FRAME-RATE")||f.hasAttribute(_.Ab)){var h=_.J(f,"FRAME-RATE");f=_.J(f,_.Ab);
58
+ var [k,l]=f?f.split("x"):[null,null];h={frameRate:MK(h),width:MK(k),height:MK(l)}}else h=null;if(f=yield nN(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?lL(r).Ga:"")+" - "+(n?lL(n).Ga:"");if(e.has(m)){a.g.debug("Skipping variant which only differs in text streams.");continue}const u=OM(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})},oN=function(a,
59
+ b,c,d,e,f){let g=dN(a,b);a.g.debug("Guessing stream type for",b.toString());b=!1;const h=_.nk(_.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(CK),c=_.p,b=!0):e?(a.g.debug(CK),c=_.p):(a.g.debug("Guessing video-only"),c=_.w):(c=_.p,a.g.debug(CK));return{type:c,Qg:g,Eh:b}},mN=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},nN=
60
+ function(a,b,c,d,e){return _.x(function*(){var f=b.tag,g=b.playlist,h=_.J(f,_.EB),k=_.J(f,_.Tb);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=>lL(u).Ga===l);const {type:m,Qg:n,Eh:r}=oN(a,f,c,k.audio.length,k.video.length,g);f=null;r||(f=yield pN(a,b,n,m,e,c));if(null==f)return null;k[m]=[f];m===_.p&&c&&k.video.forEach(u=>{fM(u,c.width);gM(u,c.height);hM(u,c.frameRate)});return k})},pN=function(a,b,c,d,e,f){return _.x(function*(){const g=
61
+ b.tag,h=b.playlist;return mN(a,h.verbatimUri,()=>_.x(function*(){var k=_.J(g,wK);let l=null;d===_.w&&k&&"NONE"!==k&&(l=e.get(k));k=(k=_.J(g,_.EB)||void 0)&&a.J.has(k)?k:void 0;var m=eN(d,c);if(k){const n=eN(_.p,c);m+=`,${n}`}return yield ZM(a,{playlist:h,codecs:m,type:d,closedCaptions:l,primary:!1,kind:null,Qc:null,name:null,channelsCount:null,spatialAudio:!1,jc:null,groupId:null,muxedAudioId:k,Fd:f})}))})},bN=function(a,b,c,d){return _.x(function*(){var e=b.verbatimUri,f=b.T;var g=void 0===g?0:g;
62
+ var h=(h=RK(b.ca,_.Ia))?Number(h.value):g;g=[];e=yield qN(a,b.a,e,f,h,c,d);if(0===f.length)f=[];else{var k=[],l=[];for(var m of f)QK(m.ca,_.Da)&&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 rN(a,b.a,k,h,e,c,d,g[g.length-1]||null),g.push(l),h+=k.length;sN(g);return g})},lN=function(a,b){return _.x(function*(){var c=b.name!==zK?!0:_.J(b,_.Ib)===FK;c=_.J(b,_.Kb,void 0,{required:c});if(!c)return null;const d=TK(a.w,c),{response:e,text:f}=yield xM(a,d);return yM(a,
63
+ f,e.uri,c)})},sN=function(a){if(1<(new Set(a.map(b=>b.mimeType))).size)throw new _.I(_.F,4,4045,"Media playlist contains discontinuities with different MIME types. This is valid, but not yet supported.");},tN=function(a){a=a.map(b=>b.a?b.a:b.f.map(c=>_.J(c,_.Kb))||null).map(b=>_.nu(b));if(1<(new Set(a)).size)throw new _.I(_.F,4,4044,"Unexpected change in file format.");},uN=function(a,b,c){a=NK(a.ca,_.Ha);if(1<a.length)throw new _.I(_.F,4,4020);a=a[0];if(!a)return null;const d=IK(a,_.Kb),e=TK(b,d);
64
+ b=dL(a,null,!0);return new _.eK(()=>[e],b.za,b.qa,c)},vN=function(a,b,c,d,e,f,g){const h=[];for(const r of FL(b.f)){b=r.Yf;const u=r.item;{var k=0===b,l=k?a:h[h.length-1],m=k?d:l.endTime,n=Number(_.J(u,yK));n=m+n;k=dL(u,k?null:l.qa,k);l=_.J(u,_.Kb);const v=(l=TK(g,l))?[l]:[];m=new fL(c,m,n,()=>v,k.za,k.qa,e,f,!1,null,null,null,null);if("YES"===_.J(u,"INDEPENDENT")||0===b)m.h=!0;h.push(m)}}return h},wN=function(a,b,c,d,e,f,g,h,k,l,m){const n=c.ca;var r=c.a;0<NK(n,_.Ha).length&&(m=uN(c,k,g));const u=
65
+ null!=r,v=r?[r]:[];if(!u&&!a.a.lowLatencyMode)return null;a=0;r={za:0,qa:null};let y=null;u?({duration:c}=bL(n),a=e+c,r=aL(n,b?b.qa:null)):(b=vN(b,c,d,e,f,g,k),a=b[b.length-1].endTime,y=b);h=h===_.re?SK(n):null;d=new fL(d,e,a,()=>v,r.za,r.qa,f,g,!1,null,h?h.hd:null,h?h.Dd:null,h?h.durationPerTile:null,y,m);d.pa=l;return d},qN=function(a,b,c,d,e,f,g){return _.x(function*(){var h=d[0];if(null!=a.C)return a.C;if(!EM(a)&&a.f)try{var k=a.j.get(c);var l=k?dM(k,e)||null:null;if(!l)throw new _.I(_.F,4,4030,
66
+ "Segment not found in pervious playlist update.");var m=l.startTime+l.Fa;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].T,m=m[m.length-1],a.g.warn(`Last #EXT-X-MEDIA-SEQUENCE values ${h.streams[0].T[0].position} - ${m.position}`+`, new values ${e} - ${e+d.length-1}.`,b,h);throw new _.I(_.F,4,4047,{message:"The updated playlist does not share any segments with the previous one.",uri:c});}m=yield xN(a,f,g,h);l=$L(h.ca,a.w,e);k=
67
+ uN(h,b,l);h=yield yN(a,k,h,l,m,g);a.g.debug(`Setting playlist start time to ${h}.`);return a.C=h})},rN=function(a,b,c,d,e,f,g,h){return _.x(function*(){var k=c[0],l=null==h;tN(c);const m=yield xN(a,f,g,k);var n=h?h.Lh:null;if(QK(c[0].ca,_.Ga)||null===n)n=XL(c,m),n=0===n.length?[TL()]:n;else{var r=XL(c,m);n=[n,...r]}r=n;n=r[r.length-1];r=UL(r);let u=h?h.Mh:null;var v=zN(u,k.ca,a.w,d);let y=uN(k,b,v)||(h?h.Fh:null);const A=k.pa;k=l?e:yield AN(a,A,y,k,d,v,m,g);l=[];v=!1;for(let G=0;G<c.length;G++){var E=
68
+ c[G];const X=l[l.length-1]||null,dd=0===G?0:X.endTime,dc=d+G,Mb=zN(u,E.ca,a.w,dc);(u=Mb)&&(v=!0);if(E=wN(a,X,E,dc,dd,k,Mb,f,b,A,y))y=E.initSegment,l.push(E)}return{T:l,fh:r,Lh:n,aesEncrypted:v,mimeType:m,endTime:l[l.length-1].endTime,pa:A,Fh:y,Mh:u}})},xN=function(a,b,c,d){return _.x(function*(){const e=d.a;var f=RK(d.ca,_.Ha);f=f?IK(f,_.Kb):null;return BN(a,b,c,e,f)})},yN=function(a,b,c,d,e,f){return _.x(function*(){if(null==c.a)return 0;const g=gL(c,d);return bM(a.S,b,g,e,f,null!=d)})},zN=function(a,
69
+ b,c,d){return b.some(e=>e.name===_.Ga&&"NONE"===_.J(e,DK))?null:(b=$L(b,c,d))?b:a&&a.generatedIv?Object.assign({},a,{iv:_.bm(new Uint8Array(12),HL(d))}):a},AN=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 yN(a,c,d,f,g,h);a.g.debug(`Segment #${e} has raw media timestamp `+`${k} s.`);a.L.set(b,k);return k})},BN=function(a,b,c,d,e){return _.x(function*(){const f=[d,e].filter(Boolean);var g=_.qk(f,b,c);if(g)return g;g=_.Bj([d],a.a.attemptParameters);g.method=
70
+ "HEAD";g.type=2;g=(yield a.H(g)).headers["content-type"];if(!g)throw new _.I(_.F,4,4021,"Unknown MIME type of: "+f.join(", "));return g.toLowerCase().split(";")[0]})},zM=a=>{a=_.nu(a)||"";return null!=_.mu.video[a]?_.w:null!=_.mu.audio[a]?_.p:null},xL=class{constructor(a,b,c,d){if(1===b){if(!d||0===d.length)throw new _.I(_.F,4,4043,"Media playlist must have at least one segment!");if(null==d[0].a)throw new _.I(_.F,4,4043,"Media playlist must have at least one full segment!");}this.a=a;this.verbatimUri=
71
+ "";this.type=b;this.ca=c;this.T=1===b?d:null}},DL=class{constructor(a,b,c){c=void 0===c?[]:c;this.ca=b;this.a=a;this.f=c;this.pa=-1}},fL=class extends _.jE{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:n,void 0===r?null:r,u,void 0===v?null:v);this.pa=0}},CN=class{constructor(){this.h=0;this.a=new Map}},DN=class{constructor(){this.a=new Map;this.f=new Map}set(a,b){this.f.set(a,b);
72
+ 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()}},LM=new _.S("clpp.hls.DiscontinuityUtils");var ZL={"com.apple.streamingkeydelivery":function(a,b){if(b===_.Hg)throw new _.I(_.F,4,4041);if(IK(a,DK)===EK)throw new _.I(_.F,4,4044,"EXT-X-KEY:METHOD SAMPLE-AES-CTR is not supported in FairPlay.");return _.hD(_.Ed,[{initDataType:_.Wf,initData:new Uint8Array(0)}],"")},"com.microsoft.playready":SL,"urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":SL,"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":function(a){var b=IK(a,DK);if(!QL.includes(b))return RL.error("Widevine in HLS is only supported with [",
73
+ QL.join(", "),"], not",b),null;b=IK(a,_.Kb);b=_.At(b);b=_.K(b.data);b=_.hD(_.Jd,[{initDataType:_.kd,initData:b}],"");if(a=_.J(a,"KEYID"))b.keyIds=[a.substr(2).toLowerCase()];return b}},QL=["SAMPLE-AES",EK],RL=new _.S("clpp.hls.DrmParser");var YL=new _.S("clpp.hls.EncryptionUtils");var EN=class{constructor(a){this.g=new _.S("clpp.hls.MediaReader");this.f=a;this.a={attemptParameters:_.xj()}}};var cN=class{constructor(a){this.streams=a}length(){return this.streams.length}};var aN=class{constructor(a){this.a=a}length(){return this.a.length}};var FN=class{constructor(){this.a=this.D=null;this.h=1;this.j=new DN;this.w="";this.R=new CN;this.G=0;this.o=null;this.l=new _.Gk(()=>{this.Xb()});this.A=_.Ub;this.f=null;this.F=new _.vu;this.K=this.C=null;this.g=new _.S("clpp.hls.HlsParser");this.L=new Map;this.S=new EN(this.H.bind(this));this.O=!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.O)throw Error("start() may be called only once!");
74
+ c.O=!0;c.D=b;const {response:d,text:e}=yield xM(c,a);c.w=d.uri;const f=yield IM(c,e);c.f=f;const g=c.G;c.l&&0<g&&c.l.ia(g);return f})}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(!EM(a)&&b){var c=b.presentationTimeline;"LIVE"===a.A&&(a.C=null);var d=Array.from(a.j.values());
75
+ if(a.a.lowLatencyMode&&null!==a.o){const g=wM(a);d=d.filter(h=>g.includes(lL(h).Ga))}var e=yield KM(a,d);d=e.map(g=>g.playlist);MM(a,d);e=yield PM(a,e);kM(b.periods,e).forEach(g=>{a.D.filterNewPeriod(g)});CM(a,e);var f=QM(a,d);f=RM(a,d,f);b.cues=HM(a,f);mM(b.periods,e);vM(c,e);if(d=WK(d))!0!==a.a.keepTimelineLive&&SM(a,c,e),a.l.stop(),a.l=null;if(a.D.onUpdate)a.D.onUpdate(b);if(d&&a.D.onTurnedStatic)a.D.onTurnedStatic();a.M&&(yield a.stop());return b}})}loadVariant(a,b){const c=this;return _.x(function*(){const d=
76
+ 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 _.zi(`No alternative variant with id: ${d}`);var f=null,g=null;if(e.audio){const k=e.audio;f=mN(c,k.verbatimUri,()=>_.x(function*(){const l=yield jN(c,k);return kN(c,k,l)}))}if(e.video){const k=e.video;g=mN(c,k.verbatimUri,()=>_.x(function*(){const l=yield jN(c,k);return kN(c,k,l)}))}f=yield f;g=yield g;e=OM(c,f,g,e.bandwidth,e.id);let h;e&&(e=rM(c.D.configurationId,
77
+ [e],[],[],!EM(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 _.zi(`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=c.f.alternativeTextStreams.find(h=>h.id===a)||null;if(!f)throw new _.zi(`Could not load text stream with id: ${a}`);
78
+ const g=yield mN(c,f.verbatimUri,()=>_.x(function*(){const h=yield jN(c,f);return kN(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 _.zi(`Could not load text stream with id: ${a}`);return d})}Xb(){const a=this;return _.x(function*(){a.g.debug(_.qC);if(a.D)try{yield a.update(),a.l&&0<a.G&&a.l.ia(a.G)}catch(b){if(!(b instanceof _.I))throw b;a.D&&(a.D.onError(b),1===b.severity&&a.l&&a.l.ia(.1))}})}H(a){if(!this.F)throw new _.I(_.F,
79
+ 7,7001);a=this.D.networkingEngine.fetch(a);_.Mj(this.F,a);return a.V}};_.z("clpp.hls.HlsComponent",class extends _.Kv{f(){_.et.m3u8=FN;_.ct[_.zl]=FN;_.ct[GK]=FN}a(){_.IE("m3u8");_.JE(_.zl);_.JE(GK)}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 rU=function(a){a.a.one(a.m,_.we,()=>qU(a))},qU=function(a){const b=a.m.getSurface().getMedia();if(b)if(a.h){a.a.on(b.textTracks,_.zc,d=>sU(a,d));var c=Array.from(b.textTracks);c.filter(d=>d.kind===_.De).forEach(d=>{sU(a,{track:d})});!tU(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."),uU(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.")},sU=function(a,b){b=b.track;b.kind===_.De&&(a.g.info("The metadata track has been added."),b.mode=_.he,a.a.on(b,_.Hd,c=>vU(a,c)))},tU=function(a){return a.some(b=>b.kind===_.De)},uU=function(a,b){const c=a.m.getTrackManager(),d=c.oa(),e=c.getAudioTracks().find(g=>g!==d);if(e){var f=()=>c.xa(d);a.a.on(b.textTracks,_.zc,g=>{g.track.kind===_.De&&(a.a.off(b.textTracks,_.zc,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
- vU=function(a,b){const c=wU(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 xU(d);if(e.f===c&&null!==e.a){a.f=d;d=a.h.parseMedia(_.Vi(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)}}})},wU=function(a){return(a=a.m.getTrackManager().wa())&&a.language&&a.language.toLowerCase()},
4
- xU=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(_.fh(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=_.fh(a)?a:null}}};var yU=class{constructor(a,b,c){this.m=a;this.l=b;this.j=c;this.a=new _.xt;this.h=(a=_.lt(_.Jc))?new a(this.m.getConfiguration()):null;this.g=new _.S("clpp.hlssmpte.ImageCueHandler");this.f=null;rU(this)}destroy(){this.a.release();this.f=null;return Promise.resolve()}};var zU=class extends _.Fv{constructor(){super();this.a=null;this.f=!1}onPlayerCreated(){}onContentWillLoad(a){if(this.f=_.Qk()){var b=a.getConfiguration();b=_.$g(b.hlssmpte||{});typeof b.patchMetadataTrack!==_.Uc&&(b.patchMetadataTrack=!1);_.gh(b.timestampOffset)||(b.timestampOffset=0);this.a=new yU(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",zU);
5
- zU.Id="hlssmpte";_.ur(new class{create(){return new zU}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var oV=function(a){a.a.one(a.m,_.Ee,()=>nV(a))},nV=function(a){const b=a.m.getSurface().getMedia();if(b)if(a.h){a.a.on(b.textTracks,_.Ec,d=>pV(a,d));var c=Array.from(b.textTracks);c.filter(d=>d.kind===_.Le).forEach(d=>{pV(a,{track:d})});!qV(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."),rV(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.")},pV=function(a,b){b=b.track;b.kind===_.Le&&(a.g.info("The metadata track has been added."),b.mode=_.pe,a.a.on(b,_.Od,c=>sV(a,c)))},qV=function(a){return a.some(b=>b.kind===_.Le)},rV=function(a,b){const c=a.m.getTrackManager(),d=c.ra(),e=c.getAudioTracks().find(g=>g!==d);if(e){var f=()=>c.ya(d);a.a.on(b.textTracks,_.Ec,g=>{g.track.kind===_.Le&&(a.a.off(b.textTracks,_.Ec,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
+ sV=function(a,b){const c=tV(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 uV(d);if(e.f===c&&null!==e.a){a.f=d;d=a.h.parseMedia(_.mj(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)}}})},tV=function(a){return(a=a.m.getTrackManager().xa())&&a.language&&a.language.toLowerCase()},
4
+ uV=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(_.sh(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=_.sh(a)?a:null}}};var vV=class{constructor(a,b,c){this.m=a;this.l=b;this.j=c;this.a=new _.St;this.h=(a=_.Et(_.Oc))?new a(this.m.getConfiguration()):null;this.g=new _.S("clpp.hlssmpte.ImageCueHandler");this.f=null;oV(this)}destroy(){this.a.release();this.f=null;return Promise.resolve()}};var wV=class extends _.Zv{constructor(){super();this.a=null;this.f=!1}onPlayerCreated(){}onContentWillLoad(a){if(this.f=_.Uk()){var b=a.getConfiguration();b=_.mh(b.hlssmpte||{});typeof b.patchMetadataTrack!==_.$c&&(b.patchMetadataTrack=!1);_.th(b.timestampOffset)||(b.timestampOffset=0);this.a=new vV(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",wV);
5
+ wV.Id="hlssmpte";_.Nr(new class{create(){return new wV}});};f.call(g, window);