@castlabs/prestoplay 6.33.0 → 6.34.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 +22 -0
  2. package/cjs/cl.adobe.js +3 -3
  3. package/cjs/cl.airplay.js +3 -3
  4. package/cjs/cl.broadpeak.js +19 -19
  5. package/cjs/cl.cast.js +129 -129
  6. package/cjs/cl.conviva.js +31 -31
  7. package/cjs/cl.core.js +635 -624
  8. package/cjs/cl.crypto.js +9 -9
  9. package/cjs/cl.dash.js +101 -101
  10. package/cjs/cl.externs.js +49 -74
  11. package/cjs/cl.freewheel.js +26 -26
  12. package/cjs/cl.hls.js +76 -76
  13. package/cjs/cl.hlssmpte.js +6 -6
  14. package/cjs/cl.htmlcue.js +30 -30
  15. package/cjs/cl.ima.js +26 -26
  16. package/cjs/cl.mediatailor.js +3 -3
  17. package/cjs/cl.mse.js +356 -353
  18. package/cjs/cl.muxdata.js +14 -14
  19. package/cjs/cl.onboard.js +4 -5
  20. package/cjs/cl.persistent.js +14 -14
  21. package/cjs/cl.playlist.js +6 -6
  22. package/cjs/cl.simid.js +16 -16
  23. package/cjs/cl.smooth.js +71 -71
  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 +11 -11
  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 +39 -39
  33. package/cl.adobe.js +3 -3
  34. package/cl.airplay.js +3 -3
  35. package/cl.broadpeak.js +14 -14
  36. package/cl.cast.js +100 -100
  37. package/cl.conviva.js +27 -27
  38. package/cl.core.js +513 -502
  39. package/cl.crypto.js +9 -9
  40. package/cl.dash.js +90 -90
  41. package/cl.externs.js +52 -65
  42. package/cl.freewheel.js +20 -20
  43. package/cl.hls.js +82 -82
  44. package/cl.hlssmpte.js +5 -5
  45. package/cl.htmlcue.js +26 -26
  46. package/cl.ima.js +20 -20
  47. package/cl.mediatailor.js +2 -2
  48. package/cl.mse.js +306 -306
  49. package/cl.muxdata.js +13 -13
  50. package/cl.onboard.js +5 -5
  51. package/cl.persistent.js +10 -10
  52. package/cl.playlist.js +5 -5
  53. package/cl.simid.js +14 -14
  54. package/cl.smooth.js +61 -61
  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 +31 -31
  64. package/package.json +1 -1
  65. package/typings.d.ts +57 -171
package/cl.freewheel.js CHANGED
@@ -1,20 +1,20 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var YT="clpp-freewheel",ZT="clpp.freewheel.AdsManagerFactory",$T="freewheel",aU=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""}},bU=function(a){const b=[];typeof a.networkId!==_.r&&b.push("networkId");typeof a.serverUrl!==_.Pf&&b.push("serverUrl");typeof a.profileId!==_.Pf&&b.push("profileId");typeof a.videoAssetId!==_.Pf&&typeof a.videoAssetId!==_.r&&b.push("videoAssetId");
2
- if(b.length)throw new _.I(1,9,12001,{missingKeys:b.join(", ")});},cU=function(){return _.v(function*(){var a=new _.Cv;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})},dU=function(a){a.l.on(a.a,tv.freewheel.SDK.EVENT_REQUEST_COMPLETE,a.U.bind(a));a.l.on(a.a,tv.freewheel.SDK.EVENT_SLOT_STARTED,a.Z.bind(a));a.l.on(a.a,
3
- tv.freewheel.SDK.EVENT_SLOT_ENDED,a.W.bind(a));a.l.on(a.a,tv.freewheel.SDK.EVENT_AD,a.S.bind(a));a.l.on(a.m,_.bg,a.R.bind(a));a.l.on(a.m,_.Mf,a.P.bind(a))},eU=function(a){const b=a.m.Gd($T).$c();b&&a.m.getSurface().hide(b);a.m.getSurface().showMediaElement()},fU=function(a){const b=a.m.Gd($T).$c();b&&(a.m.getSurface().show(b),a.m.getSurface().hideMediaElement(),a.a.registerVideoDisplayBase(YT),a.m.isMuted()?a.setVolume(0):a.setVolume(a.m.getVolume()||1))},gU=function(a,b,c){var d=null;a.a&&c&&(c.adInstance||
4
- c.slot)&&(c=(d=c.adInstance||null)?d.getSlot():c.slot,d={ad:new X(a.a,c,d)});a.m.trigger(new _.H(b,d))},hU=class extends _.Mv{constructor(){super();this.f=this.a=null}onPlayerCreated(a){if(window.tv&&tv.freewheel&&tv.freewheel.SDK)this.a=_.xi(_.Bd,{id:YT}),this.f=_.xi(_.t,{"class":_.Yc}),this.a.appendChild(this.f),a.getSurface().addElementToContainer(this.a,!0),a.getSurface().hide(this.a);else a.onError(new _.I(1,9,12E3))}onPlayerWillDestroy(a){this.a&&(a.getSurface().removeElementFromContainer(this.a),
5
- this.f=this.a=null)}id(){return $T}$c(){return this.a}Uh(){return this.f}};_.w("clpp.freewheel.FreeWheelPlugin",hU);hU.prototype.getAdVideo=hU.prototype.Uh;hU.prototype.getAdContainer=hU.prototype.$c;hU.Id=$T;hU.AD_CONTAINER_ID=YT;var iU=class{create(){return new hU}};var X=class{constructor(a,b,c){this.h=a;this.f=b;this.a=c}cb(){return"FreeWheel AdManager SDK"}eb(){return tv.freewheel.SDK.version}gb(){return 0}getId(){return this.a?this.a.getAdId():""}getCreativeId(){const a=(this.a||{})._creativeId;return typeof a===_.Pf?a:""}zb(){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}Bb(){return!1}Pa(){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():""}Ta(){return this.a?this.a.getActiveCreativeRendition().getWidth():0}Sa(){return this.a?this.a.getActiveCreativeRendition().getHeight():0}Ba(){return 0}Ca(){switch(this.f.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:return 0;
7
- case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:return 2;default:return 1}}getPodIndex(){switch(this.Ca()){case 0:return 0;case 2:return-1}return this.h.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL).indexOf(this.f)+1}pb(){switch(this.Ca()){case 0:return 0;case 2:return-1;default:return this.f.getTimePosition()}}fb(){return this.a?this.f.getAdInstances().indexOf(this.a)+1:1}Ua(){return this.f.getAdCount()}getWrapperAdIds(){return[]}canSeek(){return!1}getWrapperAdSystems(){return[]}getWrapperCreativeIds(){return[]}Ab(){return null}};
8
- X.prototype.getVideoElement=X.prototype.Ab;X.prototype.getWrapperCreativeIds=X.prototype.getWrapperCreativeIds;X.prototype.getWrapperAdSystems=X.prototype.getWrapperAdSystems;X.prototype.canSeek=X.prototype.canSeek;X.prototype.getWrapperAdIds=X.prototype.getWrapperAdIds;X.prototype.getSequenceLength=X.prototype.Ua;X.prototype.getPositionInSequence=X.prototype.fb;X.prototype.getPodTimeOffset=X.prototype.pb;X.prototype.getPodIndex=X.prototype.getPodIndex;X.prototype.getPodType=X.prototype.Ca;
9
- X.prototype.getMediaBitrate=X.prototype.Ba;X.prototype.getMediaHeight=X.prototype.Sa;X.prototype.getMediaWidth=X.prototype.Ta;X.prototype.getMediaUrl=X.prototype.getMediaUrl;X.prototype.getClickThroughUrl=X.prototype.Pa;X.prototype.isBumper=X.prototype.Bb;X.prototype.getSkipTimeOffset=X.prototype.getSkipTimeOffset;X.prototype.getPosition=X.prototype.getPosition;X.prototype.getDuration=X.prototype.getDuration;X.prototype.getTitle=X.prototype.getTitle;X.prototype.getAdvertiserName=X.prototype.getAdvertiserName;
10
- X.prototype.getAdSystem=X.prototype.getAdSystem;X.prototype.getApiFramework=X.prototype.getApiFramework;X.prototype.getSourceId=X.prototype.zb;X.prototype.getCreativeId=X.prototype.getCreativeId;X.prototype.getId=X.prototype.getId;X.prototype.getTechnology=X.prototype.gb;X.prototype.getAdManagerVersion=X.prototype.eb;X.prototype.getAdManagerName=X.prototype.cb;var jU=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()}})}Rb(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL).length}Qb(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL).length}};
11
- jU.prototype.hasPostroll=jU.prototype.Qb;jU.prototype.hasPreroll=jU.prototype.Rb;jU.prototype.getCuePoints=jU.prototype.getCuePoints;var kU=class{constructor(a){this.g=new _.T("clpp.freewheel.AdsManager");this.m=a;this.l=new _.It;this.K=new tv.freewheel.SDK.AdManager;this.f=this.a=null;this.M=[];this.I=[];this.L=[];this.H=new _.Cl;this.B=null;this.C=!1;this.G=1;this.J=!1;this.F=!0}load(){const a=this;return _.v(function*(){const b=a.m.getConfiguration().freewheel||{};try{bU(b)}catch(d){return a.m.onError(d),a.H.resolve(),a.H}a.K.setNetwork(b.networkId);a.K.setServer(b.serverUrl);a.a=a.K.newContext();a.a.setProfile(b.profileId);
12
- typeof b.siteSectionId!==_.Pf&&typeof b.siteSectionId!==_.r||a.a.setSiteSection(b.siteSectionId);const c=yield cU();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,aU(d.type),d.position,d.slotProfile,d.cuepointSequence,d.maxDuration,d.minDuration,d.acceptContentType);b.keyValues&&typeof b.keyValues===_.De&&Object.keys(b.keyValues).forEach(d=>a.a.addKeyValue(d,b.keyValues[d]));a.a.setParameter(tv.freewheel.SDK.PARAMETER_EXTENSION_CONTENT_VIDEO_ENABLED,
13
- !1,tv.freewheel.SDK.PARAMETER_LEVEL_GLOBAL);if(Array.isArray(b.parameters))for(const d of b.parameters)a.a.setParameter(d.name,d.value,d.level);dU(a);a.a.submitRequest();return a.H})}j(){if(this.M.length){fU(this);this.f=this.M.shift();this.f.play();var a=!1}else this.f?(this.f.resume(),a=!1):(eU(this),a=!0);return a}A(){}ib(){this.f&&this.f.pause()}skip(){this.f&&this.f.skipCurrentAd()}getAdVolume(){return!this.a||this.C?this.G:this.a.getAdVolume()}h(a){this.G=a;this.C||this.a&&this.a.setAdVolume(a)}setMuted(a){this.C=
14
- a;this.a&&(a?this.a.setAdVolume(0):this.a.setAdVolume(this.G))}isMuted(){return this.C}qb(){return this.J}isPaused(){return this.F}getPosition(){return this.f?this.f.getPlayheadTime():-1}setVolume(a){this.h(a)}getVolume(){return this.getAdVolume()}pause(){this.ib()}resume(){this.j()}w(){return!0}o(){const a=this;return _.v(function*(){a.l.release();a.B&&(a.B.stop(),a.B=null);eU(a);a.a&&(a.a.dispose(),a.a=null)})}U(a){if(a.success)this.M=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL),
15
- this.I=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL),this.L=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL),this.m.trigger(new _.H(_.mc,{adsTimeline:new jU(this.a)})),this.B=new _.Av(this.m.getSurface(),(b,c)=>this.a.resize(b,c),this.m.Gd($T).f);else this.m.onError(new _.I(1,9,10003,{errorType:0},void 0));this.H.resolve()}Z(a){gU(this,_.Qb,a);this.B.start()}W(a){this.f=null;a=a.slot;gU(this,_.Rb);this.B.stop();eU(this);a&&a.getTimePositionClass()===
16
- tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL||this.m.play()}S(a){const b=a.subType;this.g.debug("ad event",b);switch(b){case tv.freewheel.SDK.EVENT_AD_IMPRESSION:this.setMuted(this.C);this.h(this.G);this.J=!0;this.F=!1;gU(this,_.hc,a);gU(this,_.Zb,a);break;case tv.freewheel.SDK.EVENT_AD_IMPRESSION_END:gU(this,_.jc,a);this.F=this.J=!1;break;case tv.freewheel.SDK.EVENT_AD_FIRST_QUARTILE:gU(this,_.Vb,a);break;case tv.freewheel.SDK.EVENT_AD_MIDPOINT:gU(this,_.ac,a);break;case tv.freewheel.SDK.EVENT_AD_THIRD_QUARTILE:gU(this,
17
- _.kc,a);break;case tv.freewheel.SDK.EVENT_AD_COMPLETE:gU(this,_.Ub,a);break;case tv.freewheel.SDK.EVENT_AD_CLICK:gU(this,_.Tb,a);break;case tv.freewheel.SDK.EVENT_AD_PAUSE:this.F=!0;gU(this,_.bc,a);break;case tv.freewheel.SDK.EVENT_AD_RESUME:this.F=!1;gU(this,_.dc,a);break;case tv.freewheel.SDK.EVENT_AD_SKIPPED:gU(this,_.ec,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_START:gU(this,_.Sb,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_END:gU(this,_.cc,a);break;case tv.freewheel.SDK.EVENT_ERROR:this.m.onError(new _.I(1,
18
- 9,10003,{errorType:1},{fwCode:a[tv.freewheel.SDK.INFO_KEY_ERROR_CODE],fwInfo:a[tv.freewheel.SDK.INFO_KEY_ERROR_INFO],fwModule:a[tv.freewheel.SDK.INFO_KEY_ERROR_MODULE]}))}}R(){if(!this.f){var a=this.m.getPosition();if(this.f=this.I.find(b=>.5>Math.abs(a-b.getTimePosition()))||null){const b=this.I.findIndex(c=>c===this.f);this.I.splice(b,1);this.m.pause();fU(this);this.f.play()}}}P(a){if((a=a.detail)&&this.a)switch(a.currentState){case 3:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PLAYING);break;
19
- case 4:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PAUSED);break;case 5:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_COMPLETED);this.L.length?(fU(this),this.f=this.L.shift(),this.f.play()):eU(this);break;case _.zo:case _.qo:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_STOPPED)}}};kU.prototype.resume=kU.prototype.resume;kU.prototype.pause=kU.prototype.pause;kU.prototype.getVolume=kU.prototype.getVolume;kU.prototype.setVolume=kU.prototype.setVolume;kU.prototype.getPosition=kU.prototype.getPosition;
20
- kU.prototype.skip=kU.prototype.skip;_.Bh(new class{constructor(){this.Wa=new _.T(ZT)}name(){return ZT}a(a,b){return a.namespace()!==_.ed&&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 kU(a)}});_.Kn(new iU);};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var mU="clpp-freewheel",nU="clpp.freewheel.AdsManagerFactory",oU="freewheel",pU=function(a){switch(a){case 0:return tv.freewheel.SDK.ADUNIT_PREROLL;case _.Pj:return tv.freewheel.SDK.ADUNIT_MIDROLL;case _.Mj:return tv.freewheel.SDK.ADUNIT_POSTROLL;default:return""}},qU=function(a){const b=[];typeof a.networkId!==_.r&&b.push("networkId");typeof a.serverUrl!==_.Of&&b.push("serverUrl");typeof a.profileId!==_.Of&&b.push("profileId");typeof a.videoAssetId!==_.Of&&typeof a.videoAssetId!==_.r&&
2
+ b.push("videoAssetId");if(b.length)throw new _.J(1,9,12001,{missingKeys:b.join(", ")});},rU=function(){return _.v(function*(){var a=new _.Pv;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})},sU=function(a){a.l.on(a.a,tv.freewheel.SDK.EVENT_REQUEST_COMPLETE,a.U.bind(a));a.l.on(a.a,tv.freewheel.SDK.EVENT_SLOT_STARTED,
3
+ a.Z.bind(a));a.l.on(a.a,tv.freewheel.SDK.EVENT_SLOT_ENDED,a.W.bind(a));a.l.on(a.a,tv.freewheel.SDK.EVENT_AD,a.S.bind(a));a.l.on(a.m,_.$f,a.R.bind(a));a.l.on(a.m,_.bf,a.P.bind(a))},tU=function(a){const b=a.m.Ed(oU).Yc();b&&a.m.getSurface().hide(b);a.m.getSurface().showMediaElement()},uU=function(a){const b=a.m.Ed(oU).Yc();b&&(a.m.getSurface().show(b),a.m.getSurface().hideMediaElement(),a.a.registerVideoDisplayBase(mU),a.m.isMuted()?a.setVolume(0):a.setVolume(a.m.getVolume()||1))},vU=function(a,b,c){var d=
4
+ null;a.a&&c&&(c.adInstance||c.slot)&&(c=(d=c.adInstance||null)?d.getSlot():c.slot,d={ad:new X(a.a,c,d)});a.m.trigger(new _.H(b,d))},wU=class extends _.Zv{constructor(){super();this.f=this.a=null}onPlayerCreated(a){if(window.tv&&tv.freewheel&&tv.freewheel.SDK)this.a=_.Dp(_.Ad,{id:mU}),this.f=_.Dp(_.t,{"class":_.bd}),this.a.appendChild(this.f),a.getSurface().addElementToContainer(this.a,!0),a.getSurface().hide(this.a);else a.onError(new _.J(1,9,12E3))}onPlayerWillDestroy(a){this.a&&(a.getSurface().removeElementFromContainer(this.a),
5
+ this.f=this.a=null)}id(){return oU}Yc(){return this.a}Sh(){return this.f}};_.w("clpp.freewheel.FreeWheelPlugin",wU);wU.prototype.getAdVideo=wU.prototype.Sh;wU.prototype.getAdContainer=wU.prototype.Yc;wU.Id=oU;wU.AD_CONTAINER_ID=mU;var xU=class{create(){return new wU}};var X=class{constructor(a,b,c){this.h=a;this.f=b;this.a=c}fb(){return"FreeWheel AdManager SDK"}gb(){return tv.freewheel.SDK.version}ib(){return 0}getId(){return this.a?this.a.getAdId():""}getCreativeId(){const a=(this.a||{})._creativeId;return typeof a===_.Of?a:""}yb(){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}Ab(){return!1}Ra(){return this.a&&this.a.getEventCallbackUrls(tv.freewheel.SDK.EVENT_AD_CLICK,tv.freewheel.SDK.EVENT_TYPE_CLICK)[0]||""}getMediaUrl(){return this.a?this.a.getActiveCreativeRendition().getPrimaryCreativeRenditionAsset().getUrl():""}Va(){return this.a?this.a.getActiveCreativeRendition().getWidth():0}Ua(){return this.a?this.a.getActiveCreativeRendition().getHeight():0}Ba(){return 0}Ca(){switch(this.f.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:return 0;
7
+ case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:return _.Mj;default:return _.Pj}}getPodIndex(){switch(this.Ca()){case 0:return 0;case _.Mj:return-1}return this.h.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL).indexOf(this.f)+1}ob(){switch(this.Ca()){case 0:return 0;case _.Mj:return-1;default:return this.f.getTimePosition()}}hb(){return this.a?this.f.getAdInstances().indexOf(this.a)+1:1}Wa(){return this.f.getAdCount()}getWrapperAdIds(){return[]}canSeek(){return!1}getWrapperAdSystems(){return[]}getWrapperCreativeIds(){return[]}zb(){return null}};
8
+ X.prototype.getVideoElement=X.prototype.zb;X.prototype.getWrapperCreativeIds=X.prototype.getWrapperCreativeIds;X.prototype.getWrapperAdSystems=X.prototype.getWrapperAdSystems;X.prototype.canSeek=X.prototype.canSeek;X.prototype.getWrapperAdIds=X.prototype.getWrapperAdIds;X.prototype.getSequenceLength=X.prototype.Wa;X.prototype.getPositionInSequence=X.prototype.hb;X.prototype.getPodTimeOffset=X.prototype.ob;X.prototype.getPodIndex=X.prototype.getPodIndex;X.prototype.getPodType=X.prototype.Ca;
9
+ X.prototype.getMediaBitrate=X.prototype.Ba;X.prototype.getMediaHeight=X.prototype.Ua;X.prototype.getMediaWidth=X.prototype.Va;X.prototype.getMediaUrl=X.prototype.getMediaUrl;X.prototype.getClickThroughUrl=X.prototype.Ra;X.prototype.isBumper=X.prototype.Ab;X.prototype.getSkipTimeOffset=X.prototype.getSkipTimeOffset;X.prototype.getPosition=X.prototype.getPosition;X.prototype.getDuration=X.prototype.getDuration;X.prototype.getTitle=X.prototype.getTitle;X.prototype.getAdvertiserName=X.prototype.getAdvertiserName;
10
+ X.prototype.getAdSystem=X.prototype.getAdSystem;X.prototype.getApiFramework=X.prototype.getApiFramework;X.prototype.getSourceId=X.prototype.yb;X.prototype.getCreativeId=X.prototype.getCreativeId;X.prototype.getId=X.prototype.getId;X.prototype.getTechnology=X.prototype.ib;X.prototype.getAdManagerVersion=X.prototype.gb;X.prototype.getAdManagerName=X.prototype.fb;var yU=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()}})}Qb(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL).length}Pb(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL).length}};
11
+ yU.prototype.hasPostroll=yU.prototype.Pb;yU.prototype.hasPreroll=yU.prototype.Qb;yU.prototype.getCuePoints=yU.prototype.getCuePoints;var zU=class{constructor(a){this.g=new _.S("clpp.freewheel.AdsManager");this.m=a;this.l=new _.Ut;this.K=new tv.freewheel.SDK.AdManager;this.f=this.a=null;this.M=[];this.I=[];this.L=[];this.H=new _.wk;this.B=null;this.C=!1;this.G=1;this.J=!1;this.F=!0}load(){const a=this;return _.v(function*(){const b=a.m.getConfiguration().freewheel||{};try{qU(b)}catch(d){return a.m.onError(d),a.H.resolve(),a.H}a.K.setNetwork(b.networkId);a.K.setServer(b.serverUrl);a.a=a.K.newContext();a.a.setProfile(b.profileId);
12
+ typeof b.siteSectionId!==_.Of&&typeof b.siteSectionId!==_.r||a.a.setSiteSection(b.siteSectionId);const c=yield rU();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,pU(d.type),d.position,d.slotProfile,d.cuepointSequence,d.maxDuration,d.minDuration,d.acceptContentType);b.keyValues&&typeof b.keyValues===_.Ce&&Object.keys(b.keyValues).forEach(d=>a.a.addKeyValue(d,b.keyValues[d]));a.a.setParameter(tv.freewheel.SDK.PARAMETER_EXTENSION_CONTENT_VIDEO_ENABLED,
13
+ !1,tv.freewheel.SDK.PARAMETER_LEVEL_GLOBAL);if(Array.isArray(b.parameters))for(const d of b.parameters)a.a.setParameter(d.name,d.value,d.level);sU(a);a.a.submitRequest();return a.H})}j(){if(this.M.length){uU(this);this.f=this.M.shift();this.f.play();var a=!1}else this.f?(this.f.resume(),a=!1):(tU(this),a=!0);return a}A(){}Ja(){this.f&&this.f.pause()}skip(){this.f&&this.f.skipCurrentAd()}getAdVolume(){return!this.a||this.C?this.G:this.a.getAdVolume()}h(a){this.G=a;this.C||this.a&&this.a.setAdVolume(a)}setMuted(a){this.C=
14
+ a;this.a&&(a?this.a.setAdVolume(0):this.a.setAdVolume(this.G))}isMuted(){return this.C}pb(){return this.J}isPaused(){return this.F}getPosition(){return this.f?this.f.getPlayheadTime():-1}setVolume(a){this.h(a)}getVolume(){return this.getAdVolume()}pause(){this.Ja()}resume(){this.j()}w(){return!0}o(){const a=this;return _.v(function*(){a.l.release();a.B&&(a.B.stop(),a.B=null);tU(a);a.a&&(a.a.dispose(),a.a=null)})}U(a){if(a.success)this.M=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL),
15
+ this.I=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL),this.L=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL),this.m.trigger(new _.H(_.oc,{adsTimeline:new yU(this.a)})),this.B=new _.Nv(this.m.getSurface(),(b,c)=>this.a.resize(b,c),this.m.Ed(oU).f);else this.m.onError(new _.J(1,9,10003,{errorType:0},void 0));this.H.resolve()}Z(a){vU(this,_.Sb,a);this.B.start()}W(a){this.f=null;a=a.slot;vU(this,_.Tb);this.B.stop();tU(this);a&&a.getTimePositionClass()===
16
+ tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL||this.m.play()}S(a){const b=a.subType;this.g.debug("ad event",b);switch(b){case tv.freewheel.SDK.EVENT_AD_IMPRESSION:this.setMuted(this.C);this.h(this.G);this.J=!0;this.F=!1;vU(this,_.kc,a);vU(this,_.ac,a);break;case tv.freewheel.SDK.EVENT_AD_IMPRESSION_END:vU(this,_.lc,a);this.F=this.J=!1;break;case tv.freewheel.SDK.EVENT_AD_FIRST_QUARTILE:vU(this,_.Xb,a);break;case tv.freewheel.SDK.EVENT_AD_MIDPOINT:vU(this,_.cc,a);break;case tv.freewheel.SDK.EVENT_AD_THIRD_QUARTILE:vU(this,
17
+ _.mc,a);break;case tv.freewheel.SDK.EVENT_AD_COMPLETE:vU(this,_.Wb,a);break;case tv.freewheel.SDK.EVENT_AD_CLICK:vU(this,_.Vb,a);break;case tv.freewheel.SDK.EVENT_AD_PAUSE:this.F=!0;vU(this,_.dc,a);break;case tv.freewheel.SDK.EVENT_AD_RESUME:this.F=!1;vU(this,_.fc,a);break;case tv.freewheel.SDK.EVENT_AD_SKIPPED:vU(this,_.ic,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_START:vU(this,_.Ub,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_END:vU(this,_.ec,a);break;case tv.freewheel.SDK.EVENT_ERROR:this.m.onError(new _.J(1,
18
+ 9,10003,{errorType:1},{fwCode:a[tv.freewheel.SDK.INFO_KEY_ERROR_CODE],fwInfo:a[tv.freewheel.SDK.INFO_KEY_ERROR_INFO],fwModule:a[tv.freewheel.SDK.INFO_KEY_ERROR_MODULE]}))}}R(){if(!this.f){var a=this.m.getPosition();if(this.f=this.I.find(b=>.5>Math.abs(a-b.getTimePosition()))||null){const b=this.I.findIndex(c=>c===this.f);this.I.splice(b,1);this.m.pause();uU(this);this.f.play()}}}P(a){if((a=a.detail)&&this.a)switch(a.currentState){case 8:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PLAYING);break;
19
+ case 10:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PAUSED);break;case 11:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_COMPLETED);this.L.length?(uU(this),this.f=this.L.shift(),this.f.play()):tU(this);break;case 0:case 3:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_STOPPED)}}};zU.prototype.resume=zU.prototype.resume;zU.prototype.pause=zU.prototype.pause;zU.prototype.getVolume=zU.prototype.getVolume;zU.prototype.setVolume=zU.prototype.setVolume;zU.prototype.getPosition=zU.prototype.getPosition;
20
+ zU.prototype.skip=zU.prototype.skip;_.pp(new class{constructor(){this.Ya=new _.S(nU)}name(){return nU}a(a,b){return a.namespace()!==_.gd&&b&&b.freewheel?window.tv&&tv.freewheel&&tv.freewheel.SDK?!0:(this.Ya.warn("FreeWheel SDK is not loaded."),!1):!1}create(a){return new zU(a)}});_.Sr(new xU);};f.call(g, window);
package/cl.hls.js CHANGED
@@ -1,82 +1,82 @@
1
- import {clpp} from "./cl.core.js";import './cl.mse.js';let g={};const _ = clpp._;var f=function(window){'use strict';var EI="CLOSED-CAPTIONS",FI="Could not parse MP4 segment start time.",GI="DURATION",HI="EXT-X-DATERANGE",II="EXT-X-DISCONTINUITY",JI="EXT-X-KEY",KI="EXT-X-MAP",LI="EXT-X-MEDIA",MI="EXT-X-MEDIA-SEQUENCE",NI="EXT-X-PROGRAM-DATE-TIME",OI="EXT-X-STREAM-INF",PI="Failed to infer discontinuity number",QI="Guessing audio-only",RI="METHOD",SI="SAMPLE-AES-CTR",TI="SUBTITLES",UI="_HLS_part",VI="application/vnd.apple.mpegurl",WI="manifestloaded",XI="sample",YI=function(a,b){return _.L(a,b,void 0,
2
- {required:!0})},ZI=function(a){if(1>a.a)throw _.Xo();--a.a},$I=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===_.De&&e&&typeof e===_.De){if(!$I(d,e))return!1}else if(void 0!==d&&void 0!==e&&d!==e)return!1}return!0},aJ=function(a,b){if(!$I(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===_.De&&e&&typeof e===_.De&&aJ(d,e))return!0}return!1},bJ=function(a,b){if(a===b||_.z(a)||_.z(b))return!1;const c=Object.keys(a);
3
- for(let e=0;e<c.length;e++){var d=c[e];if(!(d in b))continue;const f=a[d];d=b[d];if(f instanceof Date&&d instanceof Date&&f.getTime()!==d.getTime())return!0;if(typeof f===_.De&&typeof d===_.De){if(bJ(f,d))return!0}else{if(f instanceof Array&&d instanceof Array){if(f.length!==d.length)return!0;for(let g=0;g<f.length;g++)if(f[g]!==d[g])return!0}if(f!==d)return!0}}return!1},cJ=function(a){if(null!==a&&void 0!==a)return Number(a)},dJ=function(a){return 0>a?[]:Array.from({length:a},(b,c)=>c)},eJ=function(a){return new Uint8Array([a>>
4
- 24&255,a>>16&255,a>>8&255,a&255])},fJ=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},gJ=function(a,b){return a.filter(c=>c.name===b)},hJ=function(a){const b=/^[a-zA-Z0-9_-]+$/,c=new Set;a.forEach(d=>{const e=_.L(d,"VALUE"),f=_.L(d,_.Ra),g=_.L(d,"IMPORT"),h=_.L(d,"QUERYPARAM");if(1!==[f,g,h].filter(Boolean).length||f&&null==e)throw new _.I(_.D,4,4044,{message:"Invalid tag.",text:d.toString()});
5
- d=f||g||h;if(c.has(d))throw new _.I(_.D,4,4044,`EXT-X-DEFINE redefined variable "${d}".`);if(!b.test(d))throw new _.I(_.D,4,4044,`EXT-X-DEFINE invalid variable name "${d}".`);c.add(d)})},iJ=function(a,b){const c=Array.isArray(b)?b:[b];return a.filter(d=>{d=YI(d,_.pb);return c.includes(d)})},jJ=function(a,b){return a.some(c=>c.name===b)},kJ=function(a,b,c){c=void 0===c?{}:c;a=a.find(d=>d.name===b)||null;if(!a&&c.required)throw new _.I(_.D,4,4024,{missingTag:b});return a},lJ=function(a){var b=kJ(a,
6
- "EXT-X-TILES");if(!b)return{Ld:1,ce:1,durationPerTile:null};a=_.L(b,"LAYOUT")||"1x1";b=_.L(b,GI);a=_.wB(a);return{Ld:a.Ld,ce:a.ce,durationPerTile:b?Number(b):null}},mJ=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)},nJ=function(a,b){Array.isArray(a)||(a=[a]);a.forEach(c=>{for(const d of mJ(c))b(d,c)})},oJ=function(a){return a.some(b=>jJ(b.ba,"EXT-X-ENDLIST"))},
7
- pJ=function(a){return a.type===_.q||a.type===_.t},qJ=function(a){if(kJ(a,"EXT-X-ENDLIST"))return _.Bb;a=kJ(a,"EXT-X-PLAYLIST-TYPE");if(!a)return"LIVE";if(a.value===_.Bb)return _.Bb;if("EVENT"===a.value)return"EVENT";throw new _.I(_.D,4,4044,`Invalid EXT-X-PLAYLIST-TYPE value: ${a.value}`);},rJ=function(a){a={AUDIO:_.q,VIDEO:_.t,SUBTITLES:_.K,"CLOSED-CAPTIONS":_.K}[a.toUpperCase()];if(!a)throw new _.I(_.D,4,4044,"EXT-X-MEDIA tag has an invalid TYPE attribute.");return a},sJ=function(a,b,c){c=void 0===
8
- c?!1:c;var d=0;let e=null;if(a){d=a.split("@");a=Number(d[0]);if(0>=a)throw new _.I(_.D,4,4044,"Byte range length must be positive.");if(d[1]){if(d=Number(d[1]),0>d)throw new _.I(_.D,4,4044,"Byte range start byte must not be negative.");}else{if(c)throw new _.I(_.D,4,4044,"Invalid byte range, offset is required but missing.");if(null==b)throw new _.I(_.D,4,4044,"Invalid byte range, cannot calculate offset based on previous byte ranges.");d=b+1}e=d+a-1}return{na:d,ja:e}},tJ=function(a,b){a=kJ(a,"EXT-X-BYTERANGE");
9
- return sJ(a?a.value:null,b)},uJ=function(a){a=kJ(a,"EXTINF",{required:!0}).value.split(",");const b=Number(a[0]);if(isNaN(b))throw new _.I(_.D,4,4044,"#EXTINF must be a number.");return{duration:b,title:a[1]||null}},vJ=function(a,b){b=void 0===b?{}:b;const c={bg:!1,Eh:!1,Fh:null,hi:null,Mg:null};a=kJ(a,"EXT-X-SERVER-CONTROL",{required:b.Vg});if(!a)return c;const d=e=>null==e?null:Number(e);c.bg="YES"===_.L(a,"CAN-BLOCK-RELOAD");c.Eh="YES"===_.L(a,"CAN-SKIP-DATERANGES");c.Fh=d(_.L(a,"CAN-SKIP-UNTIL"));
10
- c.hi=d(_.L(a,"HOLD-BACK"));c.Mg=d(_.L(a,"PART-HOLD-BACK",void 0,{required:b.Vg}));return c},wJ=function(a,b,c){c=void 0===c?!1:c;a=_.L(a,"BYTERANGE");return sJ(a,b,c)},xJ=function(a){const b=gJ(a,LI),c=gJ(a,OI);a=gJ(a,"EXT-X-IMAGE-STREAM-INF");return{Oc:{Wf:iJ(b,[_.iA,_.Ab]),closedCaptions:iJ(b,EI),dj:iJ(b,TI)},de:c,$e:a}},zJ=function(a,b){const c=tJ(a.ba,null);return new yJ(0,0,0,()=>[a.a],c.na,c.ja,0,b)},AJ=function(a){let b=Infinity,c=Infinity;mJ(a).filter(pJ).forEach(d=>{{d=d.T;var e=d[0].startTime;
11
- const f=d[d.length-1].endTime;d=e;e=f-e}b=Math.min(b,d);c=Math.min(c,e)});return{nd:b,duration:c}},BJ=function(a){return a.map(b=>{({duration:b}=AJ(b));return b}).reduce((b,c)=>b+c,0)},CJ=function(a){return(a.video?a.video.$a:"")+" - "+(a.audio?a.audio.$a:"")},DJ=function(a,b,c,d,e){if(b===_.Bb)return{delay:0,be:0};b=kJ(a,"EXT-X-PART-INF");if(c&&b){e=Number(YI(b,"PART-TARGET"));if(null!=d)return{delay:d,be:e};({Mg:d}=vJ(a,{Vg:!0}));return{delay:d,be:e}}a=kJ(a,"EXT-X-TARGETDURATION",{required:!0});
12
- a=Number(a.value);e=e||a;return null!=d?{delay:d,be:e}:{delay:3*a,be:e}},EJ=function(a){const b=new Map;a.forEach(c=>{var d=`${c.Hc()}:${c.streams[0].groupId}`;b.has(d)?(d=b.get(d),d.includes(c)||d.push(c)):b.set(d,[c])});return b},FJ=function(a){const b=new Map;for(const c of a){a=_.L(c,_.Ja);a=_.Bn(a||_.gg);const d=YI(c,_.Da),e=YI(c,"INSTREAM-ID");b.has(d)||b.set(d,new Map);b.get(d).set(e,a)}return b},GJ=function(a){return a.filter(b=>"mp4a.40.34"!==b)},HJ=function(a,b,c,d,e){var f=e&&e.$d,g=e&&
13
- e.schemeIdUri,h=_.L(a,"ID");f=_.L(a,"START-DATE")||f;if(null===h||!f)return _.cv.warn("Invalid EXT-X-DATERANGE missing mandatory ID or required START-DATE attribute, ignoring the EXT-X-DATERANGE tag.",a),null;b=d?c-b:-b;d=new Date(f);c=d.getTime()/1E3+b;h={id:h,startTime:c,startDate:d,$d:f};f=cJ(_.L(a,GI));void 0!==f&&0<=f&&(h.duration=f);f=cJ(_.L(a,"PLANNED-DURATION"));void 0!==f&&0<=f&&(h.plannedDuration=f);g=_.L(a,"CLASS")||g||null;null!==g&&(h.schemeIdUri=g);f=(f=_.L(a,"END-DATE"))?new Date(f):
14
- null;null!==f&&f.getTime()>=d.getTime()&&(h.endDate=f);f=a.attributes;if(null==f)var k=null;else{d={};for(k of f)k.name.trim().startsWith("X-")&&(d[k.name]=k.value);k=_.bh(d)?d:null}k=k||{};(d=_.L(a,"CUE"))&&(k.CUE=d.split(","));if(_.bk(g)){f=a.attributes;if(null==f)var l=null;else{d={};for(l of f)switch(l.name){case _.Kb:d[_.Kb]=l.value;break;case _.Jb:d[_.Jb]=l.value;break;case _.Ob:d[_.Ob]=cJ(l.value);break;case _.Mb:d[_.Mb]=cJ(l.value);break;case "X-SNAP":d["X-SNAP"]=l.value.split(",");break;
15
- case _.Nb:d[_.Nb]=l.value.split(",")}l=_.bh(d)?d:null}l&&(k=Object.assign(k,l))}_.bh(k)&&(h.customAttributes=k);if(bJ(e,h))return _.cv.warn("EXT-X-DATERANGE augmented and previous values differ.Ignoring the EXT-X-DATERANGE tag.",a),null;h=_.Zg(e,h);if(_.bk(g)&&!_.ck(h.customAttributes))return _.cv.warn("Invalid EXT-X-DATERANGE Interstitial attributes X-ASSET-URI, X-ASSET-LIST"),null;let m;h.endDate?m=h.endDate.getTime()/1E3+b:h.duration?m=c+h.duration:h.plannedDuration?m=c+h.plannedDuration:m=c;h.endTime=
16
- m;h.type=_.$d;return h},IJ=function(a,b){if(!a)return null;const c=a.$a;return b.find(d=>d.streams[0].$a===c)||null},JJ=function(a){return(a=_.L(a,"CHANNELS"))?parseInt(a.split("/")[0],10):null},KJ=function(a){return a.some(b=>b.startsWith("#EXT-X-TARGETDURATION"))?1:0},LJ=function(a,b){const c=new Map,d=new URL(b);a.forEach(e=>{var f=_.L(e,_.Ra),g=_.L(e,"QUERYPARAM");if(f)g=YI(e,"VALUE"),c.set(f,g);else if(g){f=d.searchParams.get(g);if(null==f)throw new _.I(_.D,4,4044,`Query param '${g}' missing in playlist URI.`);
17
- if(!f)throw new _.I(_.D,4,4044,`Query param '${g}' has no associated value`+" in playlist URI.");c.set(g,decodeURIComponent(f))}});return c},MJ=function(a,b){return a.replace(/\{\$([a-zA-Z0-9_-]+)\}/g,(c,d)=>{c=b.get(d);if(null==c)throw new _.I(_.D,4,4044,`Undefined variable '${d}'`);return c})},NJ=function(a,b){a.forEach(c=>{c.attributes.forEach(d=>{d.value=MJ(d.value,b)})})},QJ=function(a,b,c){const d=[];for(let e=0;e<b.length;e++){const f=OJ(a,b[e]);d.push(f);if(f.name===OI){const g=b[e+1];if(!g)throw new _.I(_.D,
18
- 4,4044,"EXT-X-STREAM-INF is not followed by a URI.");f.attributes.push(new _.hr(_.rb,g));e++}}b=gJ(d,"EXT-X-DEFINE");hJ(b);b=LJ(b,c);a.a=b;NJ(d,a.a);return new PJ(c,0,d)},UJ=function(a,b,c){const {Si:d,gi:e,pj:f}=RJ(b),g=SJ(a,f,c);b=e.map(k=>OJ(a,k,g));const h=TJ(a,c,d,g);return new PJ(c,1,b,h)},VJ=function(a,b,c){b=b.trim().split(/\n+/m).map(d=>d.trim()).filter(d=>d.length&&!/^#(?!EXT)/m.test(d));if(!/^#EXTM3U($|[ \t\n])/m.test(b[0]))throw new _.I(_.D,4,4015);b=b.slice(1);return 0===KJ(b)?QJ(a,b,
19
- c):UJ(a,b,c)},RJ=function(a){const b=[],c=[],d=[];for(const e of a)WJ.test(e)?d.push(e):XJ.test(e)?c.push(e):b.push(e);return{Si:b,gi:c,pj:d}},SJ=function(a,b,c){b=b.map(e=>OJ(a,e));hJ(b);const d=LJ(b,c);b.map(e=>_.L(e,"IMPORT")).filter(Boolean).forEach(e=>{const f=a.a.get(e);if(null==f)throw new _.I(_.D,4,4044,`Cannot import variable '${e}' as it is not defined `+"in the master playlist");d.set(e,f)});return d},OJ=function(a,b,c){a=_.jr(a.h++,b);c&&NJ([a],c);return a},TJ=function(a,b,c,d){const e=
20
- [];let f=[],g=[];c.forEach(h=>{/^(#EXT)/.test(h)?(h=OJ(a,h,d),"EXT-X-PART"===h.name||"EXT-X-PRELOAD-HINT"===h.name&&"PART"===_.L(h,_.pb)?g.push(h):f.push(h)):(jJ(f,"EXT-X-GAP")||(h=MJ(h,d),h=_.Km(h,b),e.push(new YJ(h,f,g))),f=[],g=[])});0<g.length&&e.push(new YJ(null,f,g));return e},ZJ=function(a,b,c){const d=[],e=[];e.push(new _.hr(_.ma,"0"));e.push(new _.hr(_.rb,b));c.length&&e.push(new _.hr(_.pa,c));d.push(new _.ir(a.h++,OI,e));return new PJ(b,0,d)},$J=function(a){function b(h,k,l){let m="";for(;k<
21
- l;k++)m+="%"+("00"+h[k].toString(16)).slice(-2);return m}function c(h){return h[0]<<21|h[1]<<14|h[2]<<7|h[3]}function d(){throw new _.I(_.D,4,4030);}fJ(a)||d();let e=10;a[5]&64&&(e=e+4+c(a.subarray(10,14)));do{var f=c(a.subarray(e+4,e+8));1>f&&d();var g=String.fromCharCode(a[e],a[e+1],a[e+2],a[e+3]);if("PRIV"===g){g=a.subarray(e+10,e+f+10);for(let h=0;h<g.byteLength;h++)if(0===g[h]){if("com.apple.streaming.transportStreamTimestamp"===unescape(b(g,0,h)))return a=g.subarray(h+1),f=(a[3]&1)<<30|a[4]<<
22
- 22|a[5]<<14|a[6]<<6|a[7]>>>2,f*=4,f+=a[7]&3,Math.round(f/9E4);break}}fJ(a,e)||d();e+=10;e+=f}while(e<a.byteLength);return d()},aK=function(a,b){let c=null,d=0;try{(new _.mp).N(_.we,_.fp).N(_.dg,_.fp).N(_.re,_.fp).fa("mdhd",g=>{g.reader.skip(0===g.version?8:16);d=_.N(g.reader);g.parser.stop()}).parse(b,!0)}catch(g){c=g}if(c||!d)throw _.Kv.error("Unable to find timescale in init segment!"),new _.I(_.D,4,4030,FI,c);let e=0,f=!1;try{(new _.mp).N("moof",_.fp).N("traf",_.fp).fa("tfdt",g=>{var h=d;if(0===
23
- g.version)h=_.N(g.reader)/h;else{{const k=_.N(g.reader),l=_.N(g.reader);if(!(2097151>=k||h>=Math.pow(2,12)))throw Error("Cannot accurately parse MP4 timestamp, base time is too high and timescale is \x3c\x3d 2^12");h=k/h*Math.pow(2,32)+l/h}}e=h;f=!0;g.parser.stop()}).parse(a,!0)}catch(g){c=g}if(c||!f)throw new _.I(_.D,4,4030,FI,c);return e},bK=function(a){for(;a.getPosition()<a.Ra()-1;){const b=a.getPosition();if(71===_.Yo(a))return ZI(a),b}return-1},cK=function(a){function b(){d.seek(e+188);f=_.Yo(d);
24
- 71!==f&&(d.seek(e+192),f=_.Yo(d));71!==f&&(d.seek(e+204),f=_.Yo(d));71!==f&&c();ZI(d)}function c(){throw new _.I(_.D,4,4030);}const d=new _.Wp(new DataView(a),!1);let e=0,f=0;e=bK(d);0>e&&(_.Kv.error("Unable to find sync byte in TS after scanning."),c());for(;;){e=d.getPosition();f=_.Yo(d);71!==f&&c();a=_.Zo(d);if(8191===(a&8191)){b();continue}if(!(a&16384)){b();continue}a=(_.Yo(d)&48)>>4;0!==a&&2!==a||c();3===a&&(a=_.Yo(d),d.skip(a));if(1!==_.N(d)>>8){b();continue}d.skip(3);a=_.Yo(d)>>6;0!==a&&1!==
25
- a||c();0===_.Yo(d)&&c();a=_.Yo(d);const g=_.Zo(d),h=_.Zo(d);return(1073741824*((a&14)>>1)+((g&65534)<<14|(h&65534)>>1))/9E4}},fK=function(a){const b=dK(a),c=eK(a);a.forEach(d=>{const e=d.T,f=e.findIndex(h=>h.ma===b);let g=e.findIndex(h=>h.ma===c+1);-1===g&&(g=e.length);d.T=e.slice(f,g)})},eK=function(a){a=a.map(b=>b.T[b.T.length-1].ma);return Math.min(...a)},dK=function(a){a=a.map(b=>b.T[0].ma);return Math.max(...a)},iK=function(a){var b=YI(a,RI);if(!gK.includes(b))return hK.error("PlayReady in HLS is only supported with [",
26
- gK.join(", "),"], not",b),null;a=YI(a,_.rb);b=_.Zl(a);a=null;b=_.G(b.data);try{a=_.XA(_.cq(b))}catch(c){a=b}return _.kB(_.qd,[{initDataType:_.Tc,initData:a}],"")},kK=function(a){if(0===a.length)return jK();if(a.some(c=>"whole-segment"===c.type)||a.every(c=>c.type===_.Ce))return a[0];a=a.filter(c=>c.type===XI);const b=_.Yh(a.flatMap(c=>c.drmInfos));return{keyId:a[a.length-1].keyId,type:XI,drmInfos:b}},nK=function(a,b){return lK(a).map(c=>mK(c.ba,b)).filter(Boolean)},lK=function(a){return a.filter(b=>
27
- jJ(b.ba,JI))},mK=function(a,b){a=gJ(a,JI).filter(d=>"AES-128"!==YI(d,RI));if(0===a.length)return null;var c=YI(a[0],RI);if(1===a.length&&"NONE"===c)return jK();c=a.map(d=>YI(d,RI));if(!c.every(d=>"SAMPLE-AES"===d)&&!c.every(d=>d===SI))throw oK.warn(`EXT-X-KEY methods ${c.join(", ")} are incompatible.`),new _.I(_.D,4,4044,"Multiple EXT-X-KEY tags with incompatible METHOD values.");a=a.map(d=>{const e=_.L(d,"KEYFORMAT","identity");{const f=pK[e]||null;d=f?f(d,b):null}d||oK.warn("Unsupported HLS KEYFORMAT",
28
- e);return d}).filter(Boolean);if(0===a.length)throw new _.I(_.D,4,4026);return{keyId:a.map(d=>d.keyIds).reduce((d,e)=>d.concat(e),[]).reverse()[0]||null,type:XI,drmInfos:a}},jK=function(){return{type:_.Ce,drmInfos:[],keyId:null}},qK=function(a,b,c){a=gJ(a,JI)[0];if(!a||"AES-128"!==YI(a,RI))return null;var d=_.L(a,"IV","");d?c={iv:_.Vl((d||"0x").slice(2)),generatedIv:!1}:(d=_.L(a,"KEYFORMAT"),c=null==d||"identity"===d?{iv:_.Yl(new Uint8Array(12),eJ(c)),generatedIv:!0}:{iv:null,generatedIv:!1});const {iv:e,
29
- generatedIv:f}=c;return{method:"AES-128",url:_.Km(YI(a,_.rb),b),iv:e,generatedIv:f}},rK=function(a,b,c){return _.v(function*(){const d=b.f(),e=_.SB(b.Da(),b.na,b.na+2048-1,a.a.attemptParameters);e.type=2;const f=_.SB(b.Da(),b.na,b.ja,a.a.attemptParameters);f.type=2;d&&(f.keyInfo=d);try{return yield a.f(c?f:e)}catch(g){if(7001===g.code||c)throw g;a.g.warn("Unable to fetch a partial HLS segment! Falling back to a full segment request, which is expensive! Your server should support Range requests and CORS pre-flights.",
30
- e.uris[0]);try{return yield a.f(f)}catch(h){throw a.g.error("Failed to fetch media segment to parse its start timestamp.",f.uris[0],h),new _.I(_.D,4,4030,"Failed to fetch the media segment.");}}})},sK=function(a,b,c,d,e,f){return _.v(function*(){a.g.debug("Fetching segment to find start time");if("audio/mpeg"===d||d===_.Dc||d===_.Cc)return 0;if(d===_.Bc){var g=yield rK(a,c,f);g=_.G(g.data);if(!fJ(g))throw new _.I(_.D,4,4030,"AAC segment does not contain an ID3 tag.");return $J(g)}if(d===_.sg||d===
31
- _.Ec)return g=[rK(a,c,f)],b&&g.push(rK(a,b,!0)),g=yield Promise.all(g),aK(g[0].data,(g[1]||g[0]).data);if(d===_.rg)return g=yield rK(a,c,f),cK(g.data);if(!_.Vs(`${d.split("/")[0]||""}/mp4;codecs="${e}"`))return 0;throw new _.I(_.D,4,4030);})},tK=function(a,b){a=a.map(c=>c.streams[b]);return a.some(c=>null==c)?null:a},uK=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},vK=function(a,b){a.streams.forEach(c=>
32
- {c.Ne=b})},wK=function(a,b){a.streams.forEach(c=>{c.width=b})},xK=function(a,b){a.streams.forEach(c=>{c.height=b})},yK=function(a,b){a.streams.forEach(c=>{c.frameRate=b})},zK=function(a,b){a.streams.forEach(c=>{c.bandwidth=b})},AK=function(a,b){a=a.map(c=>c.a[b]);return a.some(c=>null==c)?null:a},BK=function(a,b){const c=new Set(a.map(d=>d.ma));return b.filter(d=>!c.has(d.ma))},DK=function(a,b){for(;a[0].ma<b[0].ma;)a.splice(0,1);var c=a[0];let d=b[0];c.startTime===d.startTime&&c.endTime===d.endTime||
33
- CK(c,d);const e=a.length-1;c=a[e];d=b[e];0<e&&(c.startTime!==d.startTime||c.endTime!==d.endTime)&&CK(c,d);for(c=e+1;c<b.length;)a.push(b[c]),c++},HK=function(a,b,c,d,e){var f=b[0].length();f=dJ(f).map(g=>{var h=AK(b,g)||[];const k=tK(c,g)||[];g=tK(d,g)||[];{const l=[...EK(h),...k,...g].filter(Boolean);FK(l);const {ma:m,duration:n}=l[0];h={configurationId:a,variants:h,textStreams:k,thumbStreams:g,startTime:0,id:`P${m}`,endTime:n,duration:n,ma:m}}return h});f[0].startTime+=e;f[0].endTime+=e;GK(f);return f},
34
- EK=function(a){a=new Set(a.flatMap(b=>[b.video,b.audio]).filter(Boolean));return Array.from(a)},GK=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}},CK=function(a,b){a.startTime=b.startTime;a.endTime=b.endTime;a.duration=b.duration;IK(a.variants,b.variants);JK(mJ(a),mJ(b))},IK=function(a,b){const c=new Map(a.map(d=>[CJ(d),d]));b.forEach(d=>{c.get(CJ(d)).drmInfos=d.drmInfos})},JK=function(a,b){const c=new Map(a.map(d=>
35
- [d.$a,d]));b.forEach(d=>{const e=c.get(d.$a);e.T=d.T;d.T.forEach(f=>{f.initSegment=e.initSegmentReference});e.segmentIndex.replace(d.T);e.nd=d.nd;e.df=d.df;e.duration=d.duration;e.kg=d.kg;e.encrypted=d.encrypted;e.drmInfos=d.drmInfos;e.keyId=d.keyId})},FK=function(a){const b=KK(a);a.forEach(c=>{_.OB(c.segmentIndex,b);c.duration=b;c.df=c.nd+b})},KK=function(a){let b=Infinity;a.filter(pJ).forEach(c=>{b=Math.min(b,c.duration)});return b},OK=function(a){if(!(2>a.length)&&LK(a)){a=a.map(e=>({playlist:e,
36
- gg:MK(e.T[0])}));var b=a.map(e=>e.gg),c=Math.max(...b);b=Math.min(...b);if(!(1E3>c-b)){a.forEach(e=>{const f=e.playlist;for(e=e.gg;0<f.T.length&&1E3<c-e;){var g=f.T.shift(),h=f.T[0];if(!h)break;NK(g,h);h=MK(h);null!=h?e=h:({duration:h}=uJ(g.ba),e+=1E3*h)}});a=a.map(e=>e.playlist);if(a.some(e=>0===e.T.length))throw new _.I(_.D,4,4048,"Media playlists are completely out of sync.");var d=Math.min(...a.map(e=>e.T.length));a.forEach(e=>{for(;e.T.length>d;)e.T.pop()})}}},LK=function(a){return a.every(b=>
37
- !!MK(b.T[0]))},NK=function(a,b){a&&b&&[KI,JI].forEach(c=>{if(!jJ(b.ba,c)){var d=a.ba.filter(e=>e.name===c);0!==d.length&&d.forEach(e=>{b.ba.push(e)})}})},PK=function(a,b){nJ(b,(c,d)=>{_.eC(a,c.T,d.startTime)});_.XB(a.a,b[0].startTime,b[b.length-1].endTime)},QK=function(a,b){return _.v(function*(){var c=_.sk([b],a.a.attemptParameters);c.type=1;c=yield a.I(c);let d="";try{d=_.ii(c.data)}catch(e){throw new _.I(_.D,4,4042);}d=d.replace(/\r\n|\r(?=[^\n]|$)/gm,"\n");d=d.trim();return{text:d,response:c}})},
38
- aL=function(a,b){return _.v(function*(){var c=RK(a,b,a.o,"");if(1===c.type){var d=c.T[0].a;c=SK(d);if(!c)throw new _.I(_.D,4,4021,`Unknown file extension ${d}`);d="";c===_.t?d="avc1.42E01E":c===_.q&&(d="mp4a.40.2");c=ZJ(a.S,a.o,a.a.hlsDefaultCodecs||d)}d=xJ(c.ba);c=TK(d.Oc.Wf);c.forEach(m=>{a.K.add(m.groupId)});var e=yield UK(a,d);var f=e.ri;const g=e.periods;var h=e.Mi;const k=e.fj;d=e.alternativeVariants;const l=e.alternativeTextStreams;e=e.alternativeImageStreams;if(!a.D)throw new _.I(_.D,7,7001);
39
- VK(a,g);h=WK(a,f.delay,g,h);XK(a)||(a.G=f.be,a.g.info(`Update playlist each ${a.G} s`),YK(a));ZK(a,h,g);f=$K(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})},cL=function(a,b){return Promise.all(b.map(c=>bL(a,c)))},eL=function(a,b){b.forEach(c=>{a:{var d=a.j.get(c.verbatimUri),e=!XK(a),f=kJ(c.ba,"EXT-X-DISCONTINUITY-SEQUENCE");
40
- if(f)var g=Number(f.value);else{d?(f=d.streams[d.streams.length-1].T,f=f[f.length-1].ma):f=0;if(e&&0<f)try{{const k=kJ(c.ba,MI);if(!k)throw dL.error("Failed to infer discontinuity number, because EXT-X-MEDIA-SEQUENCE tag is missing."),Error(PI);const l=Number(k.value),m=uK(d,l);if(!m)throw dL.error("Failed to infer discontinuity number, could not find the appropriate segment in the previous playlist"+` (segment position = ${l})`),Error(PI);var h=m.ma}g=h;break a}catch(k){throw new _.I(_.D,4,4024,
41
- "EXT-X-DISCONTINUITY-SEQUENCE tag is required for discontinuous HLS live streams.");}g=0}}c=c.T||[];for(const k of c)jJ(k.ba,II)&&g++,k.ma=g});fK(b)},hL=function(a,b){return _.v(function*(){"LIVE"===a.w&&(a.M=!0,a.H=!0);const {textStreams:c,thumbStreams:d,zh:e}=yield fL(a,b),f=a.f.periods[0].variants.map(g=>{const h=IJ(g.audio,e),k=IJ(g.video,e);g=gL(a,h,k,g.bandwidth);if(!g)throw new _.I(_.D,4,4047,{message:"Video and audio are encrypted in an incompatible way.",Sj:k?k.streams[0].$a:void 0,audio:h?
42
- h.streams[0].$a:void 0});return g});return HK(a.D.configurationId,f,c,d,a.B)})},VK=function(a,b){XK(a)||2!==a.a.timeline.version||(a.J||(a.J=b[0].startTime),_.cD(b,-a.J))},iL=function(a,b){b=b.flatMap(d=>d.T[0].ba);b=kJ(b,NI);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},jL=function(a,b,c){b=b.find(e=>null!==kJ(e.ba,HI));if(!b)return[];if(null===c)throw new _.I(_.D,4,4024,
43
- "EXT-X-PROGRAM-DATE-TIME tag is required when EXT-X-DATERANGE tags are present");var d=b.ba.filter(e=>e.name===HI);b=new Map;for(const e of d)d=(d=_.L(e,"ID"))?b.get(d):void 0,(d=HJ(e,c,a.B,!XK(a),d))&&b.set(d.id,d);return Array.from(b.values())},$K=function(a,b){const c=new Set(b.map(d=>d.id));a.A.forEach((d,e)=>{c.has(e)||a.A.delete(e)});for(const d of b){if((b=a.A.get(d.id))&&b.$d!==d.$d)a.D.onError(new _.I(1,4,4044,"EXT-X-DATERANGE START-DATE has changed for"+` ID=${d.id}`));const e={configurationId:a.D.configurationId,
44
- schemeIdUri:d.schemeIdUri,customAttributes:d.customAttributes,value:"",startTime:d.startTime,$d:d.$d,endTime:d.endTime,id:d.id,type:_.$d,eventElement:null};b&&!aJ(b,e)||a.A.set(d.id,e)}return Array.from(a.A.values())},kL=function(a,b,c){a.w=_.Bb;_.aC(b,!0);b.f=c[c.length-1].endTime},RK=function(a,b,c,d){a=VJ(a.S,b,c);a.verbatimUri=d;return a},TK=function(a){return a.filter(b=>b.name===LI&&_.L(b,_.pb)===_.iA&&!_.L(b,_.rb)).map(b=>{const c=JJ(b),d=_.L(b,_.Ja)||_.gg;return{groupId:YI(b,_.Da),id:_.jI++,
45
- label:YI(b,_.Ra),language:d,channelsCount:c,primary:"YES"===_.L(b,"DEFAULT")}})},UK=function(a,b){return _.v(function*(){var c=FJ(b.Oc.closedCaptions),d=lL(a,b.de),e=yield mL(a,b),f=Object.values(e).flat().map(k=>k.playlist),g=f[0];const h=qJ(g.ba);a.w=h;h!==_.Bb&&(a.H=!0);eL(a,f);!XK(a)&&OK(f);a.L=vJ(g.ba);f=DJ(g.ba,h,a.a.lowLatencyMode||!1,a.a.suggestedPresentationDelay,a.a.liveRefreshPeriod);g=yield nL(a,e.Xf,d);c=yield oL(a,e.de,g,c);d=yield pL(a,e.cj,d);g=yield qL(a,e.$e);d=HK(a.D.configurationId,
46
- c,d,g,a.B);a.D.filterAllPeriods(d);c=[...e.de,...e.Xf].map(k=>k.playlist);e=iL(a,c);c=jL(a,c,e);return{periods:d,Mi:e,fj:c,ri:f}})},WK=function(a,b,c,d){let e=!0,f=null,g=0;XK(a)||(e=!1,f=0,g=b);b=a.a.timeline||{};b.type=void 0;a=new _.oI(b,f,g,!0,void 0,!!a.a.lowLatencyMode);_.aC(a,e);PK(a,c);d&&_.$B(a,d);return a},YK=function(a){var b=0;for(var c of a.j.values())b=Math.max(b,c.streams[0].nd);for(c=0;95443.7176888889<=b;)c+=95443.7176888889,b-=95443.7176888889;if(c){a.g.debug("Offsetting live streams by",
47
- c,"to compensate for rollover");for(const d of a.j.values())b=d.streams[0],95443.7176888889>b.nd?(a.g.debug("Offset applied to",b.type),b.segmentIndex.offset(c)):a.g.debug("Offset NOT applied to",b.type)}},ZK=function(a,b,c){c=BJ(c);"LIVE"===a.w||"EVENT"===a.w?(c=Math.max(c,b.J),isNaN(a.a.availabilityWindowOverride)||(c=a.a.availabilityWindowOverride),b.A=c):a.w===_.Bb&&(b.f=c)},fL=function(a,b){return _.v(function*(){const c=h=>h.stream.Hc()===_.t||h.stream.Hc()===_.q;var d=b.filter(c),e=b.filter(h=>
48
- !c(h)),f=h=>{var k=h.stream.streams[0];k={language:k.language,channelsCount:k.channelsCount,spatialAudio:k.spatialAudio,closedCaptions:k.closedCaptions,primary:k.primary,kind:k.kind||null,groupId:k.groupId,type:k.type,codecs:k.codecs,name:k.originalId,uri:k.$a,ee:{width:k.width,height:k.height,frameRate:k.frameRate}};h=Object.assign({},{playlist:h.playlist,hc:null},k);return rL(a,h)};const g=[];for(const h of d)g.push(yield f(h));d=[];for(const h of e)d.push(yield f(h));sL(a,g.concat(d));e=d.filter(h=>
49
- h.Hc()===_.OA);f=d.filter(h=>h.Hc()===_.ce);return{textStreams:e,thumbStreams:f,zh:g}})},gL=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?_.DB(l.drmInfos,m.drmInfos)?_.CB(l.drmInfos,m.drmInfos):null:l?l.drmInfos:m?m.drmInfos:null;if(!l)return null;m=d;h={id:e?e:a.h++,language:h?h.language:_.gg,primary:!!h&&h.primary||!!k&&k.primary,audio:h,video:k,bandwidth:m,drmInfos:l,allowedByApplication:!0,allowedByKeySystem:!0};
50
- f.push(h)}return new tL(f)},rL=function(a,b){return _.v(function*(){const c=b.playlist,d=b.codecs,e=b.type,f=b.kd,g=b.hc,h=b.groupId,k=b.muxedAudioId,l=b.primary;var m=b.kind;const n=b.name,p=b.channelsCount,u=b.spatialAudio,x=b.closedCaptions,y=b.ee,A=_.Bn(f||_.gg);if(1!==c.type)throw new _.I(_.D,4,4017);const E=yield uL(a,c,e,d),F=a.a.lowLatencyMode?_.FA:_.EA;let C=m;e!==_.K||m||(C=_.OA);const ja=qJ(c.ba);m=E.map(Ca=>{const Xa=Ca.T,Hb=Ca.Kh,tb=Ca.mimeType,fc=Ca.ma,gc=Xa[0].startTime,Ib=Xa[Xa.length-
51
- 1].endTime,kb=Ib-gc,xa=new _.pI(Xa),wb=Xa[0].initSegment||null;return{id:null==g?_.jI++:g,originalId:n,createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:xa.f.bind(xa),getSegmentReference:xa.get.bind(xa),adjustSegmentDurations:xa.h.bind(xa),getDuration:xa.getDuration.bind(xa),segmentIndex:xa,segmentLookupStrategy:F,initSegmentReference:wb,mimeType:tb,codecs:d,kind:C,kg:Hb.type,encrypted:Hb.type===XI,aesEncrypted:Ca.aesEncrypted,keyId:Hb.keyId,language:A,originalLanguage:f||_.gg,
52
- label:n,type:e,primary:l,trickModeVideo:null,emsgSchemeIdUris:null,frameRate:y?y.frameRate:void 0,width:y?y.width:void 0,height:y?y.height:void 0,bandwidth:void 0,roles:[],channelsCount:p,spatialAudio:u,closedCaptions:x,T:Xa,drmInfos:Hb.drmInfos,ma:fc,$a:c.verbatimUri,Ne:c.a,nd:gc,df:Ib,duration:kb,groupId:h,Jj:ja,muxedAudioId:k}});return new vL(m)})},sL=function(a,b){b.forEach(c=>{a.j.a.set(c.streams[0].$a,c)})},lL=function(a,b){const c=new Map;for(const f of b){var d=_.L(f,_.iA);b=_.L(f,_.Ab);var e=
53
- _.L(f,TI);const g=wL(a,f);if(e){const h=_.Ar(_.K,g);c.set(`${_.K}:${e}`,h);e=g.indexOf(h);-1<e&&g.splice(e,1)}d&&(e=xL(_.q,g),c.set(`${"audio"}:${d}`,e));b&&(d=xL(_.t,g),c.set(`${"video"}:${b}`,d))}return c},mL=function(a,b){return _.v(function*(){const c=yield Promise.all([yL(a,b.Oc.Wf),yL(a,b.Oc.dj),yL(a,b.de),yL(a,b.$e)]),[d,e,f,g]=c;return{Xf:d,cj:e,de:f,$e:g}})},nL=function(a,b,c){return _.v(function*(){if(0===b.length)return new Map;var d=[zL(a,b[0],c)];yield d[0];d=d.concat(b.slice(1).map(e=>
54
- zL(a,e,c)));d=yield Promise.all(d);return EJ(d)})},oL=function(a,b,c,d){return _.v(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(YI(f[k].tag,_.ma));l<h&&(h=l,g=k)}h=f.splice(g,1).pop();h=yield AL(a,h,c,d,e);f=f.map(k=>AL(a,k,c,d,e));f=yield Promise.all(f);f.splice(g,0,h);return f.reduce(_.hB,[])})},pL=function(a,b,c){return Promise.all(b.map(d=>zL(a,d,c)))},qL=function(a,b){return Promise.all(b.map(c=>BL(a,c)))},CL=function(a,b){return _.v(function*(){const c=
55
- _.Km(b.verbatimUri,a.o),{response:d,text:e}=yield QK(a,c);return RK(a,e,d.uri,b.verbatimUri)})},DL=function(a,b,c){return _.v(function*(){const d=yield rL(a,{playlist:c,codecs:b.codecs,type:b.type,kd:b.originalLanguage,hc:b.id,groupId:b.groupId,primary:b.primary,kind:b.kind||null,name:b.label,channelsCount:b.channelsCount,spatialAudio:b.spatialAudio||!1,closedCaptions:b.closedCaptions,ee:{width:b.width,height:b.height,frameRate:b.frameRate}});b.bandwidth&&zK(d,b.bandwidth);return d})},XK=function(a){return a.w===
56
- _.Bb},yL=function(a,b){return _.v(function*(){return(yield Promise.all(b.map(c=>_.v(function*(){const d=yield EL(a,c);return d?{tag:c,playlist:d}:null})))).filter(Boolean)})},bL=function(a,b){return _.v(function*(){var c=new URL(b.streams[0].Ne);if(a.a.lowLatencyMode&&a.L&&a.L.bg){var d=b.streams[b.streams.length-1].segmentIndex;if(d=d.a[d.a.length-1]){var e=d.a,f=e.length-1;d={si:d.position,Hi:e&&0<e.length?f:null}}else d=null;if(e=d)d=c.searchParams,f=e.Hi,d.set("_HLS_msn",e.si.toString()),null===
57
- f&&d.get(UI)&&d.delete(UI),null!==f&&d.set(UI,f.toString())}const {response:g,text:h}=yield QK(a,c.toString());c=b.streams[0].$a;d=b.streams[0].Ne;e=g.uri;d!==e&&(d=e,vK(b,d));c=RK(a,h,d,c);return{stream:b,playlist:c}})},wL=function(a,b){var c=_.L(b,_.pa,a.a.hlsDefaultCodecs||"avc1.42E01E,mp4a.40.2").split(/\s*,\s*/);c=GJ(c);b=new Set;const d=[];for(const e of c)c=_.nB(e),b.has(c)?a.g.debug("Ignoring duplicate codec"):(d.push(e),b.add(c));return d},xL=function(a,b){if(1===b.length)return b[0];a=_.Ar(a,
58
- b);if(null!=a)return a;throw new _.I(_.D,4,4025,{codecList:b});},zL=function(a,b,c){return _.v(function*(){const d=b.tag,e=b.playlist;return FL(a,e.verbatimUri,()=>_.v(function*(){const f=YI(d,_.Da),g=rJ(YI(d,_.pb));var h=YI(d,_.pb).toUpperCase();if(rJ(h)!==_.K)h=null;else{var k=d.getAttribute("FORCED");k=!(!k||!k.value||"YES"!==k.value.toUpperCase());var l=_.OA;h===EI&&(l=_.zA);k&&(l=_.Vd);h=l}k=c.get(`${g}:${f}`)||"";l=_.L(d,_.Ja);const m=_.L(d,_.Ra),n=_.L(d,"DEFAULT"),p=g===_.q?JJ(d):null;var u=
59
- g===_.q?(u=_.L(d,"CHANNELS"))?u.includes("/JOC"):!1:!1;return yield rL(a,{playlist:e,codecs:k,type:g,kd:l,primary:"YES"===n,name:m,channelsCount:p,spatialAudio:u,groupId:f,kind:h,hc:null,closedCaptions:null,ee:null})}))})},BL=function(a,b){return _.v(function*(){const c=b.tag,d=b.playlist;return FL(a,d.verbatimUri,()=>_.v(function*(){var e=_.L(c,_.pa)||"jpg",f=_.L(c,_.Ja);const g=_.L(c,_.Ra);e=yield rL(a,{playlist:d,codecs:e,type:_.ce,kd:f,name:g,primary:!1,kind:null,channelsCount:null,spatialAudio:!1,
60
- closedCaptions:null,hc:null,groupId:null,ee:null});(f=_.L(c,_.ma))&&zK(e,Number(f));return e}))})},AL=function(a,b,c,d,e){return _.v(function*(){var f=b.tag,g=Number(YI(f,_.ma));if(f.hasAttribute("FRAME-RATE")||f.hasAttribute(_.hb)){var h=_.L(f,"FRAME-RATE");f=_.L(f,_.hb);var [k,l]=f?f.split("x"):[null,null];h={frameRate:cJ(h),width:cJ(k),height:cJ(l)}}else h=null;if(f=yield GL(a,b,h,c,d)){h=f.video;f=f.audio;var m=0<f.length?f:[null];h=0<h.length?h:[null];f=[];for(const n of m)for(const p of h){m=
61
- (p?p.streams[0].$a:"")+" - "+(n?n.streams[0].$a:"");if(e.has(m)){a.g.debug("Skipping variant which only differs in text streams.");continue}const u=gL(a,n,p,g);null==u?a.g.warn("Incompatible DRM info in HLS variant. Skipping."):(f.push(u),e.add(m))}g=f}else g=[];return g})},HL=function(a,b,c,d,e,f){let g=wL(a,b);a.g.debug("Guessing stream type for",b.toString());b=!1;const h=_.Ar(_.t,g),k=d+e;1!==g.length||c||h?!k&&1<g.length?(a.g.debug("Guessing multiplexed audio+video"),c=_.t,g=[g.join(",")]):d&&
62
- f?(a.g.debug(QI),c=_.q,b=!0):e?(a.g.debug(QI),c=_.q):(a.g.debug("Guessing video-only"),c=_.t):(c=_.q,a.g.debug(QI));return{type:c,xh:g,ii:b}},FL=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},GL=function(a,b,c,d,e){return _.v(function*(){var f=b.tag,g=b.playlist,h=_.L(f,_.iA),k=_.L(f,_.Ab);h=h?d.get(`${"audio"}:${h}`)||[]:[];k=k?d.get(`${"video"}:${k}`)||[]:[];k={audio:h,video:k};const l=g.verbatimUri;g=k.audio.find(u=>
63
- u.streams[0].$a===l);const {type:m,xh:n,ii:p}=HL(a,f,c,k.audio.length,k.video.length,g);f=null;p||(f=yield IL(a,b,n,m,e,c));if(null==f)return null;k[m]=[f];m===_.q&&c&&k.video.forEach(u=>{wK(u,c.width);xK(u,c.height);yK(u,c.frameRate)});return k})},IL=function(a,b,c,d,e,f){return _.v(function*(){const g=b.tag,h=b.playlist;return FL(a,h.verbatimUri,()=>_.v(function*(){var k=_.L(g,EI);let l=null;d===_.t&&k&&"NONE"!==k&&(l=e.get(k));k=(k=_.L(g,_.iA)||void 0)&&a.K.has(k)?k:void 0;var m=xL(d,c);if(k){const n=
64
- xL(_.q,c);m+=`,${n}`}return yield rL(a,{playlist:h,codecs:m,type:d,closedCaptions:l,primary:!1,kind:null,kd:null,name:null,channelsCount:null,spatialAudio:!1,hc:null,groupId:null,muxedAudioId:k,ee:f})}))})},uL=function(a,b,c,d){return _.v(function*(){var e=b.verbatimUri,f=b.T;var g=void 0===g?0:g;var h=kJ(b.ba,MI);var k=h?Number(h.value):g;g=[];h=null;if(a.H){a.H=!1;var l=a.B;a.B=yield JL(a,b.a,e,f,k,c,d);null!=l&&(h=a.B-l)}e=k;if(0===f.length)f=[];else{k=[];l=[];for(var m of f)jJ(m.ba,II)&&0<l.length&&
65
- (k.push(l),l=[]),l.push(m);k.push(l);f=k}for(m=0;m<f.length;m++)k=f[m],l=yield KL(a,b.a,k,e,c,d,g[g.length-1]||null,h),g.push(l),e+=k.length;LL(g);return g})},EL=function(a,b){return _.v(function*(){var c=b.name!==LI?!0:_.L(b,_.pb)===TI;c=_.L(b,_.rb,void 0,{required:c});if(!c)return null;const d=_.Km(c,a.o),e=Date.now(),{response:f,text:g}=yield QK(a,d);a.D.onEvent(new _.H(WI,{detail:{duration:Date.now()-e,type:"media"}}));return RK(a,g,f.uri,c)})},LL=function(a){if(1<(new Set(a.map(b=>b.mimeType))).size)throw new _.I(_.D,
66
- 4,4045,"Media playlist contains discontinuities with different MIME types. This is valid, but not yet supported.");},ML=function(a,b,c){a=gJ(a.ba,KI);if(1<a.length)throw new _.I(_.D,4,4020);a=a[0];if(!a)return null;const d=YI(a,_.rb),e=_.Km(d,b);b=wJ(a,null,!0);return new _.kI(()=>[e],b.na,b.ja,c)},NL=function(a,b,c,d,e,f,g){const h=[];for(let p=0;p<b.f.length;p++){const u=b.f[p];var k=0===p,l=k?a:h[h.length-1],m=k?d:l.endTime,n=Number(_.L(u,GI));n=m+n;k=wJ(u,k?null:l.ja,k);l=String(_.L(u,_.rb));
67
- const x=(l=_.Km(l,g))?[l]:[];m=new yJ(c,m,n,()=>x,k.na,k.ja,e,f,!1,null,null,null,null);if("YES"===_.L(u,"INDEPENDENT")||0===p)m.h=!0;h.push(m)}return h},OL=function(a,b,c,d,e,f,g,h,k,l,m){const n=c.ba;var p=c.a;0<gJ(n,KI).length&&(m=ML(c,k,g));var u=null!=p;const x=p?[p]:[];if(!u&&!a.a.lowLatencyMode)return null;let y=0,A={na:0,ja:null};p=null;u&&({duration:u}=uJ(n),y=e+u,A=tJ(n,b?b.ja:null));a.a.lowLatencyMode&&0<c.f.length&&(p=NL(b,c,d,e,f,g,k),0===y&&(y=p[p.length-1].endTime));a=h===_.ce?lJ(n):
68
- null;d=new yJ(d,e,y,()=>x,A.na,A.ja,f,g,!1,null,a?a.Ld:null,a?a.ce:null,a?a.durationPerTile:null,p,m);d.ma=l;return d},JL=function(a,b,c,d,e,f,g){return _.v(function*(){var h=d[0];if(!XK(a)&&a.f)try{return PL(a,c,e)}catch(n){if(h=a.j.get(c)){var k=h.streams[h.streams.length-1].T;k=k[k.length-1];a.g.warn(`Last #EXT-X-MEDIA-SEQUENCE values ${h.streams[0].T[0].position} - ${k.position}`+`, new values ${e} - ${e+d.length-1}.`,b,h)}throw new _.I(_.D,4,4047,{message:"The updated playlist does not share any segments with the previous one.",
69
- uri:c});}k=yield QL(a,f,g,h);const l=qK(h.ba,a.o,e),m=ML(h,b,l);h=yield RL(a,m,h,l,k,g);a.g.debug(`Setting playlist start time to ${h}.`);return h})},KL=function(a,b,c,d,e,f,g,h){return _.v(function*(){var k=c[0];const l=yield QL(a,e,f,k);var m=g?g.oi:null;if(jJ(c[0].ba,JI)||null===m)m=nK(c,l),m=0===m.length?[jK()]:m;else{var n=nK(c,l);m=[m,...n]}n=m;m=n[n.length-1];n=kK(n);let p=g?g.pi:null;var u=SL(p,k.ba,a.o,d);let x=ML(k,b,u)||(g?g.ji:null);const y=k.ma;k=yield TL(a,y,x,k,d,u,l,f,h,null==g);u=
70
- [];let A=!1;for(let F=0;F<c.length;F++){var E=c[F];const C=u[u.length-1]||null,ja=0===F?0:C.endTime,Ca=d+F,Xa=SL(p,E.ba,a.o,Ca);(p=Xa)&&(A=!0);if(E=OL(a,C,E,Ca,ja,k,Xa,e,b,y,x))x=E.initSegment,u.push(E)}return{T:u,Kh:n,oi:m,aesEncrypted:A,mimeType:l,endTime:u[u.length-1].endTime,ma:y,ji:x,pi:p}})},PL=function(a,b,c){const d=UL(a,b,c);if(!d)throw new _.I(_.D,4,4030,"Segment not found in previous playlist update.");return a.f.periods.find(e=>e.ma===d.ma).startTime+d.startTime},QL=function(a,b,c,d){return _.v(function*(){const e=
71
- d.a;var f=kJ(d.ba,KI);f=f?YI(f,_.rb):null;return VL(a,b,c,e,f)})},RL=function(a,b,c,d,e,f){return _.v(function*(){if(null==c.a)return 0;const g=zJ(c,d);return sK(a.U,b,g,e,f,null!=d)})},SL=function(a,b,c,d){return b.some(e=>e.name===JI&&"NONE"===_.L(e,RI))?null:(b=qK(b,c,d))?b:a&&a.generatedIv?Object.assign({},a,{iv:_.Yl(new Uint8Array(12),eJ(d))}):a},TL=function(a,b,c,d,e,f,g,h,k,l){return _.v(function*(){if(a.C.has(b)&&l&&a.M&&null!=k){var m=a.f.periods.filter(p=>p.ma<b).map(p=>p.duration).reduce((p,
72
- u)=>p+u,0);m=k-m;const n=a.C.get(b);a.C.set(b,n+m);a.M=!1}if(a.C.has(b))return a.C.get(b);m=yield RL(a,c,d,f,g,h);a.g.debug(`Segment #${e} has raw media timestamp `+`${m} s.`);a.C.set(b,m);return m})},UL=function(a,b,c){return(a=a.j.get(b))?uK(a,c)||null:null},VL=function(a,b,c,d,e){return _.v(function*(){const f=[d,e].filter(Boolean);var g=_.Dr(f,b,c);if(g)return g;g=_.sk([d],a.a.attemptParameters);g.method="HEAD";g.type=2;g=(yield a.I(g)).headers["content-type"];if(!g)throw new _.I(_.D,4,4021,"Unknown MIME type of: "+
73
- f.join(", "));return g.toLowerCase().split(";")[0]})},SK=a=>{a=_.Lm(a)||"";return null!=_.wu.video[a]?_.t:null!=_.wu.audio[a]?_.q:null},PJ=class{constructor(a,b,c,d){if(1===b){if(!d||0===d.length)throw new _.I(_.D,4,4043,"Media playlist must have at least one segment!");if(null==d[0].a)throw new _.I(_.D,4,4043,"Media playlist must have at least one full segment!");}this.a=a;this.verbatimUri="";this.type=b;this.ba=c;this.T=1===b?d:null}},YJ=class{constructor(a,b,c){c=void 0===c?[]:c;this.ba=b;this.a=
74
- a;this.f=c;this.ma=-1}},yJ=class extends _.lI{constructor(a,b,c,d,e,f,g,h,k,l,m,n,p,u,x){u=void 0===u?[]:u;super(a,b,c,d,e,f,g,void 0===h?null:h,void 0===k?!1:k,void 0===l?null:l,void 0===m?null:m,void 0===n?null:n,void 0===p?null:p,u,void 0===x?null:x);this.ma=0}},WJ=/^#EXT-X-DEFINE/,XJ=/^#(EXT-X-DISCONTINUITY-SEQUENCE|EXT-X-ENDLIST|EXT-X-I-FRAMES-ONLY|EXT-X-MEDIA-SEQUENCE|EXT-X-PART-INF|EXT-X-PLAYLIST-TYPE|EXT-X-SERVER-CONTROL|EXT-X-TARGETDURATION|EXT-X-DATERANGE|EXT-X-VERSION)/,WL=class{constructor(){this.h=
75
- 0;this.a=new Map}},XL=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()}},dL=new _.T("clpp.hls.DiscontinuityUtils");var pK={"com.apple.streamingkeydelivery":function(a,b){if(b===_.rg)throw new _.I(_.D,4,4041);if(YI(a,RI)===SI)throw new _.I(_.D,4,4044,"EXT-X-KEY:METHOD SAMPLE-AES-CTR is not supported in FairPlay.");return _.kB(_.od,[{initDataType:_.If,initData:new Uint8Array(0)}],"")},"com.microsoft.playready":iK,"urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":iK,"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":function(a){var b=YI(a,RI);if(!gK.includes(b))return hK.error("Widevine in HLS is only supported with [",
76
- gK.join(", "),"], not",b),null;b=YI(a,_.rb);b=_.Zl(b);b=_.G(b.data);b=_.kB(_.sd,[{initDataType:_.Tc,initData:b}],"");if(a=_.L(a,"KEYID"))b.keyIds=[a.substr(2).toLowerCase()];return b}},gK=["SAMPLE-AES",SI],hK=new _.T("clpp.hls.DrmParser");var oK=new _.T("clpp.hls.EncryptionUtils");var YL=class{constructor(a){this.g=new _.T("clpp.hls.MediaReader");this.f=a;this.a={attemptParameters:_.nk()}}};var vL=class{constructor(a){this.streams=a}length(){return this.streams.length}Hc(){return this.streams[0].type}};var tL=class{constructor(a){this.a=a}length(){return this.a.length}};var MK=a=>{if(!a)return null;a=kJ(a.ba,NI);if(!a)return null;a=Date.parse(a.value);return isNaN(a)?null:a};var ZL=class{constructor(){this.a=this.D=null;this.h=1;this.j=new XL;this.o="";this.S=new WL;this.G=0;this.l=new _.Hi(()=>{this.dc()});this.w=_.Bb;this.f=null;this.F=new _.Xt;this.B=0;this.L=null;this.g=new _.T("clpp.hls.HlsParser");this.C=new Map;this.H=this.M=!1;this.U=new YL(this.I.bind(this));this.P=!1;this.J=null;this.R=!1;this.A=new Map;this.K=new Set}configure(a){this.a=a;this.U.a=a}setCurrentVariant(){}start(a,b){const c=this;return _.v(function*(){if(c.P)throw Error("start() may be called only once!");
77
- c.P=!0;c.D=b;var d=Date.now();const {response:e,text:f}=yield QK(c,a);c.D.onEvent(new _.H(WI,{detail:{duration:Date.now()-d,type:"master"}}));c.o=e.uri;d=yield aL(c,f);c.f=d;const g=c.G;c.l&&0<g&&c.l.la(g);return d})}requestStop(){this.R=!0}stop(){this.l&&(this.l.stop(),this.l=null);const a=[];this.F&&(a.push(this.F.destroy()),this.F=null);this.j.clear();this.f=this.a=this.D=null;this.A.clear();this.K.clear();return Promise.all(a)}update(){const a=this;return _.v(function*(){const b=a.f;if(!XK(a)&&
78
- b){var c=b.presentationTimeline,d=Array.from(a.j.values()),e=yield cL(a,d);d=e.map(g=>g.playlist);eL(a,d);e=yield hL(a,e);BK(b.periods,e).forEach(g=>{a.D.filterNewPeriod(g)});VK(a,e);var f=iL(a,d);f=jL(a,d,f);b.cues=$K(a,f);DK(b.periods,e);PK(c,e);if(d=oJ(d))!0!==a.a.keepTimelineLive&&kL(a,c,e),a.l.stop(),a.l=null;if(a.D.onUpdate)a.D.onUpdate(b);if(d&&a.D.onTurnedStatic)a.D.onTurnedStatic();a.R&&(yield a.stop());return b}})}loadVariant(a,b){const c=this;return _.v(function*(){const d=a.id;var e=c.f.periods.find(k=>
79
- k.id===b);if(e&&(e=e.variants.find(k=>k.id===d)))return e;e=c.f.alternativeVariants.find(k=>k.id===d);if(!e)throw new _.ll(`No alternative variant with id: ${d}`);var f=null,g=null;if(e.audio){const k=e.audio;f=FL(c,k.verbatimUri,()=>_.v(function*(){const l=yield CL(c,k);return DL(c,k,l)}))}if(e.video){const k=e.video;g=FL(c,k.verbatimUri,()=>_.v(function*(){const l=yield CL(c,k);return DL(c,k,l)}))}f=yield f;g=yield g;e=gL(c,f,g,e.bandwidth,e.id);let h;e&&(e=HK(c.D.configurationId,[e],[],[],0),c.D.filterAllPeriods(e),
80
- e.forEach((k,l)=>{c.f.periods[l].variants.push(k.variants[0]);b===c.f.periods[l].id&&(h=k.variants[0])}));if(!h)throw new _.ll(`Could load variant with id: ${d}`);return h})}loadTextStream(a,b){const c=this;return _.v(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 _.ll(`Could not load text stream with id: ${a}`);const g=yield FL(c,
81
- f.verbatimUri,()=>_.v(function*(){const h=yield CL(c,f);eL(c,[h]);return DL(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 _.ll(`Could not load text stream with id: ${a}`);return d})}dc(){const a=this;return _.v(function*(){a.g.debug(_.uA);if(a.D)try{yield a.update(),a.l&&0<a.G&&a.l.la(a.G)}catch(b){if(!(b instanceof _.I))throw b;a.D&&(a.D.onError(b),1===b.severity&&a.l&&a.l.la(.1))}})}I(a){if(!this.F)throw new _.I(_.D,
82
- 7,7001);a=this.D.networkingEngine.fetch(a);_.Bl(this.F,a);return a.V}};_.w("clpp.hls.HlsComponent",class extends _.uv{install(){_.Ct.m3u8=ZL;_.Bt[_.pl]=ZL;_.Bt[VI]=ZL}uninstall(){_.JC("m3u8");_.KC(_.pl);_.KC(VI)}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 VI="CLOSED-CAPTIONS",WI="Could not parse MP4 segment start time.",XI="DURATION",YI="EXT-X-DATERANGE",ZI="EXT-X-DISCONTINUITY",$I="EXT-X-KEY",aJ="EXT-X-MAP",bJ="EXT-X-MEDIA",cJ="EXT-X-MEDIA-SEQUENCE",dJ="EXT-X-PROGRAM-DATE-TIME",eJ="EXT-X-STREAM-INF",fJ="Failed to infer discontinuity number",gJ="Guessing audio-only",hJ="METHOD",iJ="SAMPLE-AES-CTR",jJ="SUBTITLES",kJ="_HLS_part",lJ="application/vnd.apple.mpegurl",mJ="manifestloaded",nJ="sample",oJ=function(a,b){return _.K(a,b,void 0,
2
+ {required:!0})},pJ=function(a){if(1>a.a)throw _.Cm();--a.a},qJ=function(a,b){for(const c in a){if(!(c in b))return!1;const d=a[c],e=b[c];if(d&&typeof d===_.Ce&&e&&typeof e===_.Ce){if(!qJ(d,e))return!1}else if(void 0!==d&&void 0!==e&&d!==e)return!1}return!0},rJ=function(a,b){if(!qJ(a,b))return!1;for(const c in b){if(!(c in a))return!0;const d=a[c],e=b[c];if(!d&&e||d&&typeof d===_.Ce&&e&&typeof e===_.Ce&&rJ(d,e))return!0}return!1},sJ=function(a,b){if(a===b||_.z(a)||_.z(b))return!1;const c=Object.keys(a);
3
+ for(let e=0;e<c.length;e++){var d=c[e];if(!(d in b))continue;const f=a[d];d=b[d];if(f instanceof Date&&d instanceof Date&&f.getTime()!==d.getTime())return!0;if(typeof f===_.Ce&&typeof d===_.Ce){if(sJ(f,d))return!0}else{if(f instanceof Array&&d instanceof Array){if(f.length!==d.length)return!0;for(let g=0;g<f.length;g++)if(f[g]!==d[g])return!0}if(f!==d)return!0}}return!1},tJ=function(a){if(null!==a&&void 0!==a)return Number(a)},uJ=function(a,b){return a.filter(c=>c.name===b)},vJ=function(a){const b=
4
+ /^[a-zA-Z0-9_-]+$/,c=new Set;a.forEach(d=>{const e=_.K(d,"VALUE"),f=_.K(d,_.Sa),g=_.K(d,"IMPORT"),h=_.K(d,"QUERYPARAM");if(1!==[f,g,h].filter(Boolean).length||f&&null==e)throw new _.J(_.C,4,4044,{message:"Invalid tag.",text:d.toString()});d=f||g||h;if(c.has(d))throw new _.J(_.C,4,4044,`EXT-X-DEFINE redefined variable "${d}".`);if(!b.test(d))throw new _.J(_.C,4,4044,`EXT-X-DEFINE invalid variable name "${d}".`);c.add(d)})},wJ=function(a,b){const c=Array.isArray(b)?b:[b];return a.filter(d=>{d=oJ(d,
5
+ _.rb);return c.includes(d)})},xJ=function(a,b){return a.some(c=>c.name===b)},yJ=function(a,b,c){c=void 0===c?{}:c;a=a.find(d=>d.name===b)||null;if(!a&&c.required)throw new _.J(_.C,4,4024,{missingTag:b});return a},zJ=function(a){var b=yJ(a,"EXT-X-TILES");if(!b)return{Jd:1,ae:1,durationPerTile:null};a=_.K(b,"LAYOUT")||"1x1";b=_.K(b,XI);a=_.zB(a);return{Jd:a.Jd,ae:a.ae,durationPerTile:b?Number(b):null}},AJ=function(a){const b=new Set;a.variants.forEach(c=>{c.audio&&b.add(c.audio);c.video&&b.add(c.video)});
6
+ a.textStreams.forEach(c=>b.add(c));a.thumbStreams.forEach(c=>b.add(c));return Array.from(b)},BJ=function(a,b){Array.isArray(a)||(a=[a]);a.forEach(c=>{for(const d of AJ(c))b(d,c)})},CJ=function(a){return a.some(b=>xJ(b.ba,"EXT-X-ENDLIST"))},DJ=function(a){return a.type===_.q||a.type===_.t},EJ=function(a){if(yJ(a,"EXT-X-ENDLIST"))return _.Db;a=yJ(a,"EXT-X-PLAYLIST-TYPE");if(!a)return"LIVE";if(a.value===_.Db)return _.Db;if("EVENT"===a.value)return"EVENT";throw new _.J(_.C,4,4044,`Invalid EXT-X-PLAYLIST-TYPE value: ${a.value}`);
7
+ },FJ=function(a){a={AUDIO:_.q,VIDEO:_.t,SUBTITLES:_.I,"CLOSED-CAPTIONS":_.I}[a.toUpperCase()];if(!a)throw new _.J(_.C,4,4044,"EXT-X-MEDIA tag has an invalid TYPE attribute.");return a},GJ=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 _.J(_.C,4,4044,"Byte range length must be positive.");if(d[1]){if(d=Number(d[1]),0>d)throw new _.J(_.C,4,4044,"Byte range start byte must not be negative.");}else{if(c)throw new _.J(_.C,4,4044,"Invalid byte range, offset is required but missing.");
8
+ if(null==b)throw new _.J(_.C,4,4044,"Invalid byte range, cannot calculate offset based on previous byte ranges.");d=b+1}e=d+a-1}return{na:d,ka:e}},HJ=function(a,b){a=yJ(a,"EXT-X-BYTERANGE");return GJ(a?a.value:null,b)},IJ=function(a){a=yJ(a,"EXTINF",{required:!0}).value.split(",");const b=Number(a[0]);if(isNaN(b))throw new _.J(_.C,4,4044,"#EXTINF must be a number.");return{duration:b,title:a[1]||null}},JJ=function(a,b){b=void 0===b?{}:b;const c={$f:!1,Ch:!1,Dh:null,fi:null,Kg:null};a=yJ(a,"EXT-X-SERVER-CONTROL",
9
+ {required:b.Tg});if(!a)return c;const d=e=>null==e?null:Number(e);c.$f="YES"===_.K(a,"CAN-BLOCK-RELOAD");c.Ch="YES"===_.K(a,"CAN-SKIP-DATERANGES");c.Dh=d(_.K(a,"CAN-SKIP-UNTIL"));c.fi=d(_.K(a,"HOLD-BACK"));c.Kg=d(_.K(a,"PART-HOLD-BACK",void 0,{required:b.Tg}));return c},KJ=function(a,b,c){c=void 0===c?!1:c;a=_.K(a,"BYTERANGE");return GJ(a,b,c)},LJ=function(a){const b=uJ(a,bJ),c=uJ(a,eJ);a=uJ(a,"EXT-X-IMAGE-STREAM-INF");return{Mc:{Uf:wJ(b,[_.vA,_.Cb]),closedCaptions:wJ(b,VI),cj:wJ(b,jJ)},be:c,Xe:a}},
10
+ NJ=function(a,b){const c=HJ(a.ba,null);return new MJ(0,0,0,()=>[a.a],c.na,c.ka,0,b)},OJ=function(a){let b=Infinity,c=Infinity;AJ(a).filter(DJ).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{ld:b,duration:c}},PJ=function(a){return a.map(b=>{({duration:b}=OJ(b));return b}).reduce((b,c)=>b+c,0)},QJ=function(a){return(a.video?a.video.bb:"")+" - "+(a.audio?a.audio.bb:"")},RJ=function(a,b,c,d,e){if(b===_.Db)return{delay:0,$d:0};b=
11
+ yJ(a,"EXT-X-PART-INF");if(c&&b){e=Number(oJ(b,"PART-TARGET"));if(null!=d)return{delay:d,$d:e};({Kg:d}=JJ(a,{Tg:!0}));return{delay:d,$d:e}}a=yJ(a,"EXT-X-TARGETDURATION",{required:!0});a=Number(a.value);e=e||a;return null!=d?{delay:d,$d:e}:{delay:3*a,$d:e}},SJ=function(a){const b=new Map;a.forEach(c=>{var d=`${c.Fc()}:${c.streams[0].groupId}`;b.has(d)?(d=b.get(d),d.includes(c)||d.push(c)):b.set(d,[c])});return b},TJ=function(a){const b=new Map;for(const c of a){a=_.K(c,_.Ka);a=_.Tj(a||_.eg);const d=
12
+ oJ(c,_.Ea),e=oJ(c,"INSTREAM-ID");b.has(d)||b.set(d,new Map);b.get(d).set(e,a)}return b},UJ=function(a){return a.filter(b=>"mp4a.40.34"!==b)},VJ=function(a,b,c,d,e){var f=e&&e.Yd,g=e&&e.schemeIdUri,h=_.K(a,"ID");f=_.K(a,"START-DATE")||f;if(null===h||!f)return _.pu.warn("Invalid EXT-X-DATERANGE missing mandatory ID or required START-DATE attribute, ignoring the EXT-X-DATERANGE tag.",a),null;b=d?c-b:-b;d=new Date(f);c=d.getTime()/1E3+b;h={id:h,startTime:c,startDate:d,Yd:f};f=tJ(_.K(a,XI));void 0!==f&&
13
+ 0<=f&&(h.duration=f);f=tJ(_.K(a,"PLANNED-DURATION"));void 0!==f&&0<=f&&(h.plannedDuration=f);g=_.K(a,"CLASS")||g||null;null!==g&&(h.schemeIdUri=g);f=(f=_.K(a,"END-DATE"))?new Date(f):null;null!==f&&f.getTime()>=d.getTime()&&(h.endDate=f);f=a.attributes;if(null==f)var k=null;else{d={};for(k of f)k.name.trim().startsWith("X-")&&(d[k.name]=k.value);k=_.$g(d)?d:null}k=k||{};(d=_.K(a,"CUE"))&&(k.CUE=d.split(","));if(_.Hj(g)){f=a.attributes;if(null==f)var l=null;else{d={};for(l of f)switch(l.name){case _.Mb:d[_.Mb]=
14
+ l.value;break;case _.Lb:d[_.Lb]=l.value;break;case _.Qb:d[_.Qb]=tJ(l.value);break;case _.Ob:d[_.Ob]=tJ(l.value);break;case "X-SNAP":d["X-SNAP"]=l.value.split(",");break;case _.Pb:d[_.Pb]=l.value.split(",")}l=_.$g(d)?d:null}l&&(k=Object.assign(k,l))}_.$g(k)&&(h.customAttributes=k);if(sJ(e,h))return _.pu.warn("EXT-X-DATERANGE augmented and previous values differ.Ignoring the EXT-X-DATERANGE tag.",a),null;h=_.Xg(e,h);if(_.Hj(g)&&!_.Ij(h.customAttributes))return _.pu.warn("Invalid EXT-X-DATERANGE Interstitial attributes X-ASSET-URI, X-ASSET-LIST"),
15
+ null;let m;h.endDate?m=h.endDate.getTime()/1E3+b:h.duration?m=c+h.duration:h.plannedDuration?m=c+h.plannedDuration:m=c;h.endTime=m;h.type=_.cj;return h},WJ=function(a,b){if(!a)return null;const c=a.bb;return b.find(d=>d.streams[0].bb===c)||null},XJ=function(a){return(a=_.K(a,"CHANNELS"))?parseInt(a.split("/")[0],10):null},YJ=function(a){return a.some(b=>b.startsWith("#EXT-X-TARGETDURATION"))?1:0},ZJ=function(a,b){const c=new Map,d=new URL(b);a.forEach(e=>{var f=_.K(e,_.Sa),g=_.K(e,"QUERYPARAM");if(f)g=
16
+ oJ(e,"VALUE"),c.set(f,g);else if(g){f=d.searchParams.get(g);if(null==f)throw new _.J(_.C,4,4044,`Query param '${g}' missing in playlist URI.`);if(!f)throw new _.J(_.C,4,4044,`Query param '${g}' has no associated value`+" in playlist URI.");c.set(g,decodeURIComponent(f))}});return c},$J=function(a,b){return a.replace(/\{\$([a-zA-Z0-9_-]+)\}/g,(c,d)=>{c=b.get(d);if(null==c)throw new _.J(_.C,4,4044,`Undefined variable '${d}'`);return c})},aK=function(a,b){a.forEach(c=>{c.attributes.forEach(d=>{d.value=
17
+ $J(d.value,b)})})},dK=function(a,b,c){const d=[];for(let e=0;e<b.length;e++){const f=bK(a,b[e]);d.push(f);if(f.name===eJ){const g=b[e+1];if(!g)throw new _.J(_.C,4,4044,"EXT-X-STREAM-INF is not followed by a URI.");f.attributes.push(new _.rk(_.ub,g));e++}}b=uJ(d,"EXT-X-DEFINE");vJ(b);b=ZJ(b,c);a.a=b;aK(d,a.a);return new cK(c,0,d)},hK=function(a,b,c){const {Qi:d,ei:e,oj:f}=eK(b),g=fK(a,f,c);b=e.map(k=>bK(a,k,g));const h=gK(a,c,d,g);return new cK(c,1,b,h)},iK=function(a,b,c){b=b.trim().split(/\n+/m).map(d=>
18
+ d.trim()).filter(d=>d.length&&!/^#(?!EXT)/m.test(d));if(!/^#EXTM3U($|[ \t\n])/m.test(b[0]))throw new _.J(_.C,4,4015);b=b.slice(1);return 0===YJ(b)?dK(a,b,c):hK(a,b,c)},eK=function(a){const b=[],c=[],d=[];for(const e of a)jK.test(e)?d.push(e):kK.test(e)?c.push(e):b.push(e);return{Qi:b,ei:c,oj:d}},fK=function(a,b,c){b=b.map(e=>bK(a,e));vJ(b);const d=ZJ(b,c);b.map(e=>_.K(e,"IMPORT")).filter(Boolean).forEach(e=>{const f=a.a.get(e);if(null==f)throw new _.J(_.C,4,4044,`Cannot import variable '${e}' as it is not defined `+
19
+ "in the master playlist");d.set(e,f)});return d},bK=function(a,b,c){a=_.tk(a.h++,b);c&&aK([a],c);return a},gK=function(a,b,c,d){const e=[];let f=[],g=[];c.forEach(h=>{/^(#EXT)/.test(h)?(h=bK(a,h,d),"EXT-X-PART"===h.name||"EXT-X-PRELOAD-HINT"===h.name&&"PART"===_.K(h,_.rb)?g.push(h):f.push(h)):(xJ(f,"EXT-X-GAP")||(h=$J(h,d),h=_.Cj(h,b),e.push(new lK(h,f,g))),f=[],g=[])});0<g.length&&e.push(new lK(null,f,g));return e},mK=function(a,b,c){const d=[],e=[];e.push(new _.rk(_.na,"0"));e.push(new _.rk(_.ub,
20
+ b));c.length&&e.push(new _.rk(_.qa,c));d.push(new _.sk(a.h++,eJ,e));return new cK(b,0,d)},nK=function(a){return 0>a?[]:Array.from({length:a},(b,c)=>c)},oK=function(a){return new Uint8Array([a>>24&255,a>>16&255,a>>8&255,a&255])},pK=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},qK=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
+ 21|h[1]<<14|h[2]<<7|h[3]}function d(){throw new _.J(_.C,4,4030);}pK(a)||d();let e=10;a[5]&64&&(e=e+4+c(a.subarray(10,14)));do{var f=c(a.subarray(e+4,e+8));1>f&&d();var g=String.fromCharCode(a[e],a[e+1],a[e+2],a[e+3]);if("PRIV"===g){g=a.subarray(e+10,e+f+10);for(let h=0;h<g.byteLength;h++)if(0===g[h]){if("com.apple.streaming.transportStreamTimestamp"===unescape(b(g,0,h)))return a=g.subarray(h+1),f=(a[3]&1)<<30|a[4]<<22|a[5]<<14|a[6]<<6|a[7]>>>2,f*=4,f+=a[7]&3,Math.round(f/9E4);break}}pK(a,e)||d();
22
+ e+=10;e+=f}while(e<a.byteLength);return d()},rK=function(a,b){let c=null,d=0;try{(new _.Vm).N(_.ue,_.Om).N(_.bg,_.Om).N(_.pe,_.Om).fa("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 _.Xv.error("Unable to find timescale in init segment!"),new _.J(_.C,4,4030,WI,c);let e=0,f=!1;try{(new _.Vm).N("moof",_.Om).N("traf",_.Om).fa("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>=
23
+ 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 _.J(_.C,4,4030,WI,c);return e},sK=function(a){for(;a.getPosition()<a.Ta()-1;){const b=a.getPosition();if(71===_.Dm(a))return pJ(a),b}return-1},tK=function(a){function b(){d.seek(e+188);f=_.Dm(d);71!==f&&(d.seek(e+192),f=_.Dm(d));71!==f&&(d.seek(e+204),f=_.Dm(d));71!==f&&c();
24
+ pJ(d)}function c(){throw new _.J(_.C,4,4030);}const d=new _.Cn(new DataView(a),!1);let e=0,f=0;e=sK(d);0>e&&(_.Xv.error("Unable to find sync byte in TS after scanning."),c());for(;;){e=d.getPosition();f=_.Dm(d);71!==f&&c();a=_.Em(d);if(8191===(a&8191)){b();continue}if(!(a&16384)){b();continue}a=(_.Dm(d)&48)>>4;0!==a&&2!==a||c();3===a&&(a=_.Dm(d),d.skip(a));if(1!==_.P(d)>>8){b();continue}d.skip(3);a=_.Dm(d)>>6;0!==a&&1!==a||c();0===_.Dm(d)&&c();a=_.Dm(d);const g=_.Em(d),h=_.Em(d);return(1073741824*
25
+ ((a&14)>>1)+((g&65534)<<14|(h&65534)>>1))/9E4}},wK=function(a){const b=uK(a),c=vK(a);a.forEach(d=>{const e=d.T,f=e.findIndex(h=>h.ma===b);let g=e.findIndex(h=>h.ma===c+1);-1===g&&(g=e.length);d.T=e.slice(f,g)})},vK=function(a){a=a.map(b=>b.T[b.T.length-1].ma);return Math.min(...a)},uK=function(a){a=a.map(b=>b.T[0].ma);return Math.max(...a)},zK=function(a){var b=oJ(a,hJ);if(!xK.includes(b))return yK.error("PlayReady in HLS is only supported with [",xK.join(", "),"], not",b),null;a=oJ(a,_.ub);b=_.Tk(a);
26
+ a=null;b=_.E(b.data);try{a=_.kB(_.Kn(b))}catch(c){a=b}return _.xB(_.rd,[{initDataType:_.Vc,initData:a}],"")},BK=function(a){if(0===a.length)return AK();if(a.some(c=>"whole-segment"===c.type)||a.every(c=>c.type===_.Be))return a[0];a=a.filter(c=>c.type===nJ);const b=_.qj(a.flatMap(c=>c.drmInfos));return{keyId:a[a.length-1].keyId,type:nJ,drmInfos:b}},EK=function(a,b){return CK(a).map(c=>DK(c.ba,b)).filter(Boolean)},CK=function(a){return a.filter(b=>xJ(b.ba,$I))},DK=function(a,b){a=uJ(a,$I).filter(d=>
27
+ "AES-128"!==oJ(d,hJ));if(0===a.length)return null;var c=oJ(a[0],hJ);if(1===a.length&&"NONE"===c)return AK();c=a.map(d=>oJ(d,hJ));if(!c.every(d=>"SAMPLE-AES"===d)&&!c.every(d=>d===iJ))throw FK.warn(`EXT-X-KEY methods ${c.join(", ")} are incompatible.`),new _.J(_.C,4,4044,"Multiple EXT-X-KEY tags with incompatible METHOD values.");a=a.map(d=>{const e=_.K(d,"KEYFORMAT","identity");{const f=GK[e]||null;d=f?f(d,b):null}d||FK.warn("Unsupported HLS KEYFORMAT",e);return d}).filter(Boolean);if(0===a.length)throw new _.J(_.C,
28
+ 4,4026);return{keyId:a.map(d=>d.keyIds).reduce((d,e)=>d.concat(e),[]).reverse()[0]||null,type:nJ,drmInfos:a}},AK=function(){return{type:_.Be,drmInfos:[],keyId:null}},HK=function(a,b,c){a=uJ(a,$I)[0];if(!a||"AES-128"!==oJ(a,hJ))return null;var d=_.K(a,"IV","");d?c={iv:_.Pk((d||"0x").slice(2)),generatedIv:!1}:(d=_.K(a,"KEYFORMAT"),c=null==d||"identity"===d?{iv:_.Sk(new Uint8Array(12),oK(c)),generatedIv:!0}:{iv:null,generatedIv:!1});const {iv:e,generatedIv:f}=c;return{method:"AES-128",url:_.Cj(oJ(a,
29
+ _.ub),b),iv:e,generatedIv:f}},IK=function(a,b,c){return _.v(function*(){const d=b.f(),e=_.fC(b.Da(),b.na,b.na+2048-1,a.a.attemptParameters);e.type=2;const f=_.fC(b.Da(),b.na,b.ka,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.",
30
+ f.uris[0],h),new _.J(_.C,4,4030,"Failed to fetch the media segment.");}}})},JK=function(a,b,c,d,e,f){return _.v(function*(){a.g.debug("Fetching segment to find start time");if("audio/mpeg"===d||d===_.Fc||d===_.Ec)return 0;if(d===_.Dc){var g=yield IK(a,c,f);g=_.E(g.data);if(!pK(g))throw new _.J(_.C,4,4030,"AAC segment does not contain an ID3 tag.");return qK(g)}if(d===_.qg||d===_.Gc)return g=[IK(a,c,f)],b&&g.push(IK(a,b,!0)),g=yield Promise.all(g),rK(g[0].data,(g[1]||g[0]).data);if(d===_.pg)return g=
31
+ yield IK(a,c,f),tK(g.data);if(!_.Qs(`${d.split("/")[0]||""}/mp4;codecs="${e}"`))return 0;throw new _.J(_.C,4,4030);})},KK=function(a,b){a=a.map(c=>c.streams[b]);return a.some(c=>null==c)?null:a},LK=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},MK=function(a,b){a.streams.forEach(c=>{c.Ke=b})},NK=function(a,b){a.streams.forEach(c=>{c.width=b})},OK=function(a,b){a.streams.forEach(c=>{c.height=b})},
32
+ PK=function(a,b){a.streams.forEach(c=>{c.frameRate=b})},QK=function(a,b){a.streams.forEach(c=>{c.bandwidth=b})},RK=function(a,b){a=a.map(c=>c.a[b]);return a.some(c=>null==c)?null:a},SK=function(a,b){const c=new Set(a.map(d=>d.ma));return b.filter(d=>!c.has(d.ma))},UK=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||TK(c,d);const e=a.length-1;c=a[e];d=b[e];0<e&&(c.startTime!==d.startTime||c.endTime!==d.endTime)&&TK(c,d);for(c=
33
+ e+1;c<b.length;)a.push(b[c]),c++},YK=function(a,b,c,d,e){var f=b[0].length();f=nK(f).map(g=>{var h=RK(b,g)||[];const k=KK(c,g)||[];g=KK(d,g)||[];{const l=[...VK(h),...k,...g].filter(Boolean);WK(l);const {ma:m,duration:n}=l[0];h={configurationId:a,variants:h,textStreams:k,thumbStreams:g,startTime:0,id:`P${m}`,endTime:n,duration:n,ma:m}}return h});f[0].startTime+=e;f[0].endTime+=e;XK(f);return f},VK=function(a){a=new Set(a.flatMap(b=>[b.video,b.audio]).filter(Boolean));return Array.from(a)},XK=function(a){for(let b=
34
+ 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}},TK=function(a,b){a.startTime=b.startTime;a.endTime=b.endTime;a.duration=b.duration;ZK(a.variants,b.variants);$K(AJ(a),AJ(b))},ZK=function(a,b){const c=new Map(a.map(d=>[QJ(d),d]));b.forEach(d=>{c.get(QJ(d)).drmInfos=d.drmInfos})},$K=function(a,b){const c=new Map(a.map(d=>[d.bb,d]));b.forEach(d=>{const e=c.get(d.bb);e.T=d.T;d.T.forEach(f=>{f.initSegment=e.initSegmentReference});e.segmentIndex.replace(d.T);
35
+ e.ld=d.ld;e.af=d.af;e.duration=d.duration;e.ig=d.ig;e.encrypted=d.encrypted;e.drmInfos=d.drmInfos;e.keyId=d.keyId})},WK=function(a){const b=aL(a);a.forEach(c=>{_.bC(c.segmentIndex,b);c.duration=b;c.af=c.ld+b})},aL=function(a){let b=Infinity;a.filter(DJ).forEach(c=>{b=Math.min(b,c.duration)});return b},eL=function(a){if(!(2>a.length)&&bL(a)){a=a.map(e=>({playlist:e,eg:cL(e.T[0])}));var b=a.map(e=>e.eg),c=Math.max(...b);b=Math.min(...b);if(!(1E3>c-b)){a.forEach(e=>{const f=e.playlist;for(e=e.eg;0<f.T.length&&
36
+ 1E3<c-e;){var g=f.T.shift(),h=f.T[0];if(!h)break;dL(g,h);h=cL(h);null!=h?e=h:({duration:h}=IJ(g.ba),e+=1E3*h)}});a=a.map(e=>e.playlist);if(a.some(e=>0===e.T.length))throw new _.J(_.C,4,4048,"Media playlists are completely out of sync.");var d=Math.min(...a.map(e=>e.T.length));a.forEach(e=>{for(;e.T.length>d;)e.T.pop()})}}},bL=function(a){return a.every(b=>!!cL(b.T[0]))},dL=function(a,b){a&&b&&[aJ,$I].forEach(c=>{if(!xJ(b.ba,c)){var d=a.ba.filter(e=>e.name===c);0!==d.length&&d.forEach(e=>{b.ba.push(e)})}})},
37
+ fL=function(a,b){BJ(b,(c,d)=>{_.sC(a,c.T,d.startTime)});_.kC(a.a,b[0].startTime,b[b.length-1].endTime)},gL=function(a,b){return _.v(function*(){var c=_.ek([b],a.a.attemptParameters);c.type=1;c=yield a.I(c);let d="";try{d=_.vi(c.data)}catch(e){throw new _.J(_.C,4,4042);}d=d.replace(/\r\n|\r(?=[^\n]|$)/gm,"\n");d=d.trim();return{text:d,response:c}})},rL=function(a,b){return _.v(function*(){var c=hL(a,b,a.o,"");if(1===c.type){var d=c.T[0].a;c=iL(d);if(!c)throw new _.J(_.C,4,4021,`Unknown file extension ${d}`);
38
+ d="";c===_.t?d="avc1.42E01E":c===_.q&&(d="mp4a.40.2");c=mK(a.S,a.o,a.a.hlsDefaultCodecs||d)}d=LJ(c.ba);c=jL(d.Mc.Uf);c.forEach(m=>{a.K.add(m.groupId)});var e=yield kL(a,d);var f=e.oi;const g=e.periods;var h=e.Ki;const k=e.ej;d=e.alternativeVariants;const l=e.alternativeTextStreams;e=e.alternativeImageStreams;if(!a.D)throw new _.J(_.C,7,7001);lL(a,g);h=mL(a,f.delay,g,h);nL(a)||(a.G=f.$d,a.g.info(`Update playlist each ${a.G} s`),oL(a));pL(a,h,g);f=qL(a,k);c={presentationTimeline:h,periods:g,minBufferTime:0,
39
+ 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})},tL=function(a,b){return Promise.all(b.map(c=>sL(a,c)))},vL=function(a,b){b.forEach(c=>{a:{var d=a.j.get(c.verbatimUri),e=!nL(a),f=yJ(c.ba,"EXT-X-DISCONTINUITY-SEQUENCE");if(f)var g=Number(f.value);else{d?(f=d.streams[d.streams.length-1].T,f=f[f.length-1].ma):f=0;if(e&&0<f)try{{const k=yJ(c.ba,cJ);if(!k)throw uL.error("Failed to infer discontinuity number, because EXT-X-MEDIA-SEQUENCE tag is missing."),
40
+ Error(fJ);const l=Number(k.value),m=LK(d,l);if(!m)throw uL.error("Failed to infer discontinuity number, could not find the appropriate segment in the previous playlist"+` (segment position = ${l})`),Error(fJ);var h=m.ma}g=h;break a}catch(k){throw new _.J(_.C,4,4024,"EXT-X-DISCONTINUITY-SEQUENCE tag is required for discontinuous HLS live streams.");}g=0}}c=c.T||[];for(const k of c)xJ(k.ba,ZI)&&g++,k.ma=g});wK(b)},yL=function(a,b){return _.v(function*(){"LIVE"===a.w&&(a.M=!0,a.H=!0);const {textStreams:c,
41
+ thumbStreams:d,xh:e}=yield wL(a,b),f=a.f.periods[0].variants.map(g=>{const h=WJ(g.audio,e),k=WJ(g.video,e);g=xL(a,h,k,g.bandwidth);if(!g)throw new _.J(_.C,4,4047,{message:"Video and audio are encrypted in an incompatible way.",Tj:k?k.streams[0].bb:void 0,audio:h?h.streams[0].bb:void 0});return g});return YK(a.D.configurationId,f,c,d,a.B)})},lL=function(a,b){nL(a)||2!==a.a.timeline.version||(a.J||(a.J=b[0].startTime),_.pD(b,-a.J))},zL=function(a,b){b=b.flatMap(d=>d.T[0].ba);b=yJ(b,dJ);if(!b)return null;
42
+ 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},AL=function(a,b,c){b=b.find(e=>null!==yJ(e.ba,YI));if(!b)return[];if(null===c)throw new _.J(_.C,4,4024,"EXT-X-PROGRAM-DATE-TIME tag is required when EXT-X-DATERANGE tags are present");var d=b.ba.filter(e=>e.name===YI);b=new Map;for(const e of d)d=(d=_.K(e,"ID"))?b.get(d):void 0,(d=VJ(e,c,a.B,!nL(a),d))&&b.set(d.id,d);return Array.from(b.values())},
43
+ qL=function(a,b){const c=new Set(b.map(d=>d.id));a.A.forEach((d,e)=>{c.has(e)||a.A.delete(e)});for(const d of b){if((b=a.A.get(d.id))&&b.Yd!==d.Yd)a.D.onError(new _.J(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,Yd:d.Yd,endTime:d.endTime,id:d.id,type:_.cj,eventElement:null};b&&!rJ(b,e)||a.A.set(d.id,e)}return Array.from(a.A.values())},BL=
44
+ function(a,b,c){a.w=_.Db;_.oC(b,!0);b.f=c[c.length-1].endTime},hL=function(a,b,c,d){a=iK(a.S,b,c);a.verbatimUri=d;return a},jL=function(a){return a.filter(b=>b.name===bJ&&_.K(b,_.rb)===_.vA&&!_.K(b,_.ub)).map(b=>{const c=XJ(b),d=_.K(b,_.Ka)||_.eg;return{groupId:oJ(b,_.Ea),id:_.CI++,label:oJ(b,_.Sa),language:d,channelsCount:c,primary:"YES"===_.K(b,"DEFAULT")}})},kL=function(a,b){return _.v(function*(){var c=TJ(b.Mc.closedCaptions),d=CL(a,b.be),e=yield DL(a,b),f=Object.values(e).flat().map(k=>k.playlist),
45
+ g=f[0];const h=EJ(g.ba);a.w=h;h!==_.Db&&(a.H=!0);vL(a,f);!nL(a)&&eL(f);a.L=JJ(g.ba);f=RJ(g.ba,h,a.a.lowLatencyMode||!1,a.a.suggestedPresentationDelay,a.a.liveRefreshPeriod);g=yield EL(a,e.Vf,d);c=yield FL(a,e.be,g,c);d=yield GL(a,e.bj,d);g=yield HL(a,e.Xe);d=YK(a.D.configurationId,c,d,g,a.B);a.D.filterAllPeriods(d);c=[...e.be,...e.Vf].map(k=>k.playlist);e=zL(a,c);c=AL(a,c,e);return{periods:d,Ki:e,ej:c,oi:f}})},mL=function(a,b,c,d){let e=!0,f=null,g=0;nL(a)||(e=!1,f=0,g=b);b=a.a.timeline||{};b.type=
46
+ void 0;a=new _.FI(b,f,g,!0,void 0,!!a.a.lowLatencyMode);_.oC(a,e);fL(a,c);d&&_.nC(a,d);return a},oL=function(a){var b=0;for(var c of a.j.values())b=Math.max(b,c.streams[0].ld);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.ld?(a.g.debug("Offset applied to",b.type),b.segmentIndex.offset(c)):a.g.debug("Offset NOT applied to",b.type)}},pL=function(a,
47
+ b,c){c=PJ(c);"LIVE"===a.w||"EVENT"===a.w?(c=Math.max(c,b.J),isNaN(a.a.availabilityWindowOverride)||(c=a.a.availabilityWindowOverride),b.A=c):a.w===_.Db&&(b.f=c)},wL=function(a,b){return _.v(function*(){const c=h=>h.stream.Fc()===_.t||h.stream.Fc()===_.q;var d=b.filter(c),e=b.filter(h=>!c(h)),f=h=>{var k=h.stream.streams[0];k={language:k.language,channelsCount:k.channelsCount,spatialAudio:k.spatialAudio,closedCaptions:k.closedCaptions,primary:k.primary,kind:k.kind||null,groupId:k.groupId,type:k.type,
48
+ codecs:k.codecs,name:k.originalId,uri:k.bb,ce:{width:k.width,height:k.height,frameRate:k.frameRate}};h=Object.assign({},{playlist:h.playlist,gc:null},k);return IL(a,h)};const g=[];for(const h of d)g.push(yield f(h));d=[];for(const h of e)d.push(yield f(h));JL(a,g.concat(d));e=d.filter(h=>h.Fc()===_.dB);f=d.filter(h=>h.Fc()===_.ae);return{textStreams:e,thumbStreams:f,xh:g}})},xL=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]||
49
+ null:null,l=h,m=k;l=l&&m?_.BB(l.drmInfos,m.drmInfos)?_.AB(l.drmInfos,m.drmInfos):null:l?l.drmInfos:m?m.drmInfos:null;if(!l)return null;m=d;h={id:e?e:a.h++,language:h?h.language:_.eg,primary:!!h&&h.primary||!!k&&k.primary,audio:h,video:k,bandwidth:m,drmInfos:l,allowedByApplication:!0,allowedByKeySystem:!0};f.push(h)}return new KL(f)},IL=function(a,b){return _.v(function*(){const c=b.playlist,d=b.codecs,e=b.type,f=b.hd,g=b.gc,h=b.groupId,k=b.muxedAudioId,l=b.primary;var m=b.kind;const n=b.name,p=b.channelsCount,
50
+ u=b.spatialAudio,x=b.closedCaptions,y=b.ce,B=_.Tj(f||_.eg);if(1!==c.type)throw new _.J(_.C,4,4017);const F=yield LL(a,c,e,d),G=a.a.lowLatencyMode?_.UA:_.TA;let D=m;e!==_.I||m||(D=_.dB);const ka=EJ(c.ba);m=F.map(Da=>{const Xa=Da.T,Hb=Da.Ih,tb=Da.mimeType,gc=Da.ma,hc=Xa[0].startTime,Ib=Xa[Xa.length-1].endTime,jb=Ib-hc,za=new _.GI(Xa),wb=Xa[0].initSegment||null;return{id:null==g?_.CI++:g,originalId:n,createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:za.f.bind(za),getSegmentReference:za.get.bind(za),
51
+ adjustSegmentDurations:za.h.bind(za),getDuration:za.getDuration.bind(za),segmentIndex:za,segmentLookupStrategy:G,initSegmentReference:wb,mimeType:tb,codecs:d,kind:D,ig:Hb.type,encrypted:Hb.type===nJ,aesEncrypted:Da.aesEncrypted,keyId:Hb.keyId,language:B,originalLanguage:f||_.eg,label:n,type:e,primary:l,trickModeVideo:null,emsgSchemeIdUris:null,frameRate:y?y.frameRate:void 0,width:y?y.width:void 0,height:y?y.height:void 0,bandwidth:void 0,roles:[],channelsCount:p,spatialAudio:u,closedCaptions:x,T:Xa,
52
+ drmInfos:Hb.drmInfos,ma:gc,bb:c.verbatimUri,Ke:c.a,ld:hc,af:Ib,duration:jb,groupId:h,Kj:ka,muxedAudioId:k}});return new ML(m)})},JL=function(a,b){b.forEach(c=>{a.j.a.set(c.streams[0].bb,c)})},CL=function(a,b){const c=new Map;for(const f of b){var d=_.K(f,_.vA);b=_.K(f,_.Cb);var e=_.K(f,jJ);const g=NL(a,f);if(e){const h=_.yl(_.I,g);c.set(`${_.I}:${e}`,h);e=g.indexOf(h);-1<e&&g.splice(e,1)}d&&(e=OL(_.q,g),c.set(`${"audio"}:${d}`,e));b&&(d=OL(_.t,g),c.set(`${"video"}:${b}`,d))}return c},DL=function(a,
53
+ b){return _.v(function*(){const c=yield Promise.all([PL(a,b.Mc.Uf),PL(a,b.Mc.cj),PL(a,b.be),PL(a,b.Xe)]),[d,e,f,g]=c;return{Vf:d,bj:e,be:f,Xe:g}})},EL=function(a,b,c){return _.v(function*(){if(0===b.length)return new Map;var d=[QL(a,b[0],c)];yield d[0];d=d.concat(b.slice(1).map(e=>QL(a,e,c)));d=yield Promise.all(d);return SJ(d)})},FL=function(a,b,c,d){return _.v(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(oJ(f[k].tag,_.na));l<h&&(h=l,
54
+ g=k)}h=f.splice(g,1).pop();h=yield RL(a,h,c,d,e);f=f.map(k=>RL(a,k,c,d,e));f=yield Promise.all(f);f.splice(g,0,h);return f.reduce(_.uB,[])})},GL=function(a,b,c){return Promise.all(b.map(d=>QL(a,d,c)))},HL=function(a,b){return Promise.all(b.map(c=>SL(a,c)))},TL=function(a,b){return _.v(function*(){const c=_.Cj(b.verbatimUri,a.o),{response:d,text:e}=yield gL(a,c);return hL(a,e,d.uri,b.verbatimUri)})},UL=function(a,b,c){return _.v(function*(){const d=yield IL(a,{playlist:c,codecs:b.codecs,type:b.type,
55
+ hd:b.originalLanguage,gc:b.id,groupId:b.groupId,primary:b.primary,kind:b.kind||null,name:b.label,channelsCount:b.channelsCount,spatialAudio:b.spatialAudio||!1,closedCaptions:b.closedCaptions,ce:{width:b.width,height:b.height,frameRate:b.frameRate}});b.bandwidth&&QK(d,b.bandwidth);return d})},nL=function(a){return a.w===_.Db},PL=function(a,b){return _.v(function*(){return(yield Promise.all(b.map(c=>_.v(function*(){const d=yield VL(a,c);return d?{tag:c,playlist:d}:null})))).filter(Boolean)})},sL=function(a,
56
+ b){return _.v(function*(){var c=new URL(b.streams[0].Ke);if(a.a.lowLatencyMode&&a.L&&a.L.$f){var d=b.streams[b.streams.length-1].segmentIndex;if(d=d.a[d.a.length-1]){var e=d.a,f=e.length-1;d={pi:d.position,Fi:e&&0<e.length?f:null}}else d=null;if(e=d)d=c.searchParams,f=e.Fi,d.set("_HLS_msn",e.pi.toString()),null===f&&d.get(kJ)&&d.delete(kJ),null!==f&&d.set(kJ,f.toString())}const {response:g,text:h}=yield gL(a,c.toString());c=b.streams[0].bb;d=b.streams[0].Ke;e=g.uri;d!==e&&(d=e,MK(b,d));c=hL(a,h,d,
57
+ c);return{stream:b,playlist:c}})},NL=function(a,b){var c=_.K(b,_.qa,a.a.hlsDefaultCodecs||"avc1.42E01E,mp4a.40.2").split(/\s*,\s*/);c=UJ(c);b=new Set;const d=[];for(const e of c)c=_.GB(e),b.has(c)?a.g.debug("Ignoring duplicate codec"):(d.push(e),b.add(c));return d},OL=function(a,b){if(1===b.length)return b[0];a=_.yl(a,b);if(null!=a)return a;throw new _.J(_.C,4,4025,{codecList:b});},QL=function(a,b,c){return _.v(function*(){const d=b.tag,e=b.playlist;return WL(a,e.verbatimUri,()=>_.v(function*(){const f=
58
+ oJ(d,_.Ea),g=FJ(oJ(d,_.rb));var h=oJ(d,_.rb).toUpperCase();if(FJ(h)!==_.I)h=null;else{var k=d.getAttribute("FORCED");k=!(!k||!k.value||"YES"!==k.value.toUpperCase());var l=_.dB;h===VI&&(l=_.MA);k&&(l=_.Ud);h=l}k=c.get(`${g}:${f}`)||"";l=_.K(d,_.Ka);const m=_.K(d,_.Sa),n=_.K(d,"DEFAULT"),p=g===_.q?XJ(d):null;var u=g===_.q?(u=_.K(d,"CHANNELS"))?u.includes("/JOC"):!1:!1;return yield IL(a,{playlist:e,codecs:k,type:g,hd:l,primary:"YES"===n,name:m,channelsCount:p,spatialAudio:u,groupId:f,kind:h,gc:null,
59
+ closedCaptions:null,ce:null})}))})},SL=function(a,b){return _.v(function*(){const c=b.tag,d=b.playlist;return WL(a,d.verbatimUri,()=>_.v(function*(){var e=_.K(c,_.qa)||"jpg",f=_.K(c,_.Ka);const g=_.K(c,_.Sa);e=yield IL(a,{playlist:d,codecs:e,type:_.ae,hd:f,name:g,primary:!1,kind:null,channelsCount:null,spatialAudio:!1,closedCaptions:null,gc:null,groupId:null,ce:null});(f=_.K(c,_.na))&&QK(e,Number(f));return e}))})},RL=function(a,b,c,d,e){return _.v(function*(){var f=b.tag,g=Number(oJ(f,_.na));if(f.hasAttribute("FRAME-RATE")||
60
+ f.hasAttribute(_.ib)){var h=_.K(f,"FRAME-RATE");f=_.K(f,_.ib);var [k,l]=f?f.split("x"):[null,null];h={frameRate:tJ(h),width:tJ(k),height:tJ(l)}}else h=null;if(f=yield XL(a,b,h,c,d)){h=f.video;f=f.audio;var m=0<f.length?f:[null];h=0<h.length?h:[null];f=[];for(const n of m)for(const p of h){m=(p?p.streams[0].bb:"")+" - "+(n?n.streams[0].bb:"");if(e.has(m)){a.g.debug("Skipping variant which only differs in text streams.");continue}const u=xL(a,n,p,g);null==u?a.g.warn("Incompatible DRM info in HLS variant. Skipping."):
61
+ (f.push(u),e.add(m))}g=f}else g=[];return g})},YL=function(a,b,c,d,e,f){let g=NL(a,b);a.g.debug("Guessing stream type for",b.toString());b=!1;const h=_.yl(_.t,g),k=d+e;1!==g.length||c||h?!k&&1<g.length?(a.g.debug("Guessing multiplexed audio+video"),c=_.t,g=[g.join(",")]):d&&f?(a.g.debug(gJ),c=_.q,b=!0):e?(a.g.debug(gJ),c=_.q):(a.g.debug("Guessing video-only"),c=_.t):(c=_.q,a.g.debug(gJ));return{type:c,vh:g,gi:b}},WL=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)||
62
+ null;c=c();a.j.set(b,c);return c},XL=function(a,b,c,d,e){return _.v(function*(){var f=b.tag,g=b.playlist,h=_.K(f,_.vA),k=_.K(f,_.Cb);h=h?d.get(`${"audio"}:${h}`)||[]:[];k=k?d.get(`${"video"}:${k}`)||[]:[];k={audio:h,video:k};const l=g.verbatimUri;g=k.audio.find(u=>u.streams[0].bb===l);const {type:m,vh:n,gi:p}=YL(a,f,c,k.audio.length,k.video.length,g);f=null;p||(f=yield ZL(a,b,n,m,e,c));if(null==f)return null;k[m]=[f];m===_.q&&c&&k.video.forEach(u=>{NK(u,c.width);OK(u,c.height);PK(u,c.frameRate)});
63
+ return k})},ZL=function(a,b,c,d,e,f){return _.v(function*(){const g=b.tag,h=b.playlist;return WL(a,h.verbatimUri,()=>_.v(function*(){var k=_.K(g,VI);let l=null;d===_.t&&k&&"NONE"!==k&&(l=e.get(k));k=(k=_.K(g,_.vA)||void 0)&&a.K.has(k)?k:void 0;var m=OL(d,c);if(k){const n=OL(_.q,c);m+=`,${n}`}return yield IL(a,{playlist:h,codecs:m,type:d,closedCaptions:l,primary:!1,kind:null,hd:null,name:null,channelsCount:null,spatialAudio:!1,gc:null,groupId:null,muxedAudioId:k,ce:f})}))})},LL=function(a,b,c,d){return _.v(function*(){var e=
64
+ b.verbatimUri,f=b.T;var g=void 0===g?0:g;var h=yJ(b.ba,cJ);var k=h?Number(h.value):g;g=[];h=null;if(a.H){a.H=!1;var l=a.B;a.B=yield $L(a,b.a,e,f,k,c,d);null!=l&&(h=a.B-l)}e=k;if(0===f.length)f=[];else{k=[];l=[];for(var m of f)xJ(m.ba,ZI)&&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 aM(a,b.a,k,e,c,d,g[g.length-1]||null,h),g.push(l),e+=k.length;bM(g);return g})},VL=function(a,b){return _.v(function*(){var c=b.name!==bJ?!0:_.K(b,_.rb)===jJ;c=_.K(b,_.ub,
65
+ void 0,{required:c});if(!c)return null;const d=_.Cj(c,a.o),e=Date.now(),{response:f,text:g}=yield gL(a,d);a.D.onEvent(new _.H(mJ,{detail:{duration:Date.now()-e,type:"media"}}));return hL(a,g,f.uri,c)})},bM=function(a){if(1<(new Set(a.map(b=>b.mimeType))).size)throw new _.J(_.C,4,4045,"Media playlist contains discontinuities with different MIME types. This is valid, but not yet supported.");},cM=function(a,b,c){a=uJ(a.ba,aJ);if(1<a.length)throw new _.J(_.C,4,4020);a=a[0];if(!a)return null;const d=
66
+ oJ(a,_.ub),e=_.Cj(d,b);b=KJ(a,null,!0);return new _.AI(()=>[e],b.na,b.ka,c)},dM=function(a,b,c,d,e,f,g){const h=[];for(let p=0;p<b.f.length;p++){const u=b.f[p];var k=0===p,l=k?a:h[h.length-1],m=k?d:l.endTime,n=Number(_.K(u,XI));n=m+n;k=KJ(u,k?null:l.ka,k);l=String(_.K(u,_.ub));const x=(l=_.Cj(l,g))?[l]:[];m=new MJ(c,m,n,()=>x,k.na,k.ka,e,f,!1,null,null,null,null);if("YES"===_.K(u,"INDEPENDENT")||0===p)m.h=!0;h.push(m)}return h},eM=function(a,b,c,d,e,f,g,h,k,l,m){const n=c.ba;var p=c.a;0<uJ(n,aJ).length&&
67
+ (m=cM(c,k,g));var u=null!=p;const x=p?[p]:[];if(!u&&!a.a.lowLatencyMode)return null;let y=0,B={na:0,ka:null};p=null;u&&({duration:u}=IJ(n),y=e+u,B=HJ(n,b?b.ka:null));a.a.lowLatencyMode&&0<c.f.length&&(p=dM(b,c,d,e,f,g,k),0===y&&(y=p[p.length-1].endTime));a=h===_.ae?zJ(n):null;d=new MJ(d,e,y,()=>x,B.na,B.ka,f,g,!1,null,a?a.Jd:null,a?a.ae:null,a?a.durationPerTile:null,p,m);d.ma=l;return d},$L=function(a,b,c,d,e,f,g){return _.v(function*(){var h=d[0];if(!nL(a)&&a.f)try{return fM(a,c,e)}catch(n){if(h=
68
+ a.j.get(c)){var k=h.streams[h.streams.length-1].T;k=k[k.length-1];a.g.warn(`Last #EXT-X-MEDIA-SEQUENCE values ${h.streams[0].T[0].position} - ${k.position}`+`, new values ${e} - ${e+d.length-1}.`,b,h)}throw new _.J(_.C,4,4047,{message:"The updated playlist does not share any segments with the previous one.",uri:c});}k=yield gM(a,f,g,h);const l=HK(h.ba,a.o,e),m=cM(h,b,l);h=yield hM(a,m,h,l,k,g);a.g.debug(`Setting playlist start time to ${h}.`);return h})},aM=function(a,b,c,d,e,f,g,h){return _.v(function*(){var k=
69
+ c[0];const l=yield gM(a,e,f,k);var m=g?g.mi:null;if(xJ(c[0].ba,$I)||null===m)m=EK(c,l),m=0===m.length?[AK()]:m;else{var n=EK(c,l);m=[m,...n]}n=m;m=n[n.length-1];n=BK(n);let p=g?g.ni:null;var u=iM(p,k.ba,a.o,d);let x=cM(k,b,u)||(g?g.hi:null);const y=k.ma;k=yield jM(a,y,x,k,d,u,l,f,h,null==g);u=[];let B=!1;for(let G=0;G<c.length;G++){var F=c[G];const D=u[u.length-1]||null,ka=0===G?0:D.endTime,Da=d+G,Xa=iM(p,F.ba,a.o,Da);(p=Xa)&&(B=!0);if(F=eM(a,D,F,Da,ka,k,Xa,e,b,y,x))x=F.initSegment,u.push(F)}return{T:u,
70
+ Ih:n,mi:m,aesEncrypted:B,mimeType:l,endTime:u[u.length-1].endTime,ma:y,hi:x,ni:p}})},fM=function(a,b,c){const d=kM(a,b,c);if(!d)throw new _.J(_.C,4,4030,"Segment not found in previous playlist update.");return a.f.periods.find(e=>e.ma===d.ma).startTime+d.startTime},gM=function(a,b,c,d){return _.v(function*(){const e=d.a;var f=yJ(d.ba,aJ);f=f?oJ(f,_.ub):null;return lM(a,b,c,e,f)})},hM=function(a,b,c,d,e,f){return _.v(function*(){if(null==c.a)return 0;const g=NJ(c,d);return JK(a.U,b,g,e,f,null!=d)})},
71
+ iM=function(a,b,c,d){return b.some(e=>e.name===$I&&"NONE"===_.K(e,hJ))?null:(b=HK(b,c,d))?b:a&&a.generatedIv?Object.assign({},a,{iv:_.Sk(new Uint8Array(12),oK(d))}):a},jM=function(a,b,c,d,e,f,g,h,k,l){return _.v(function*(){if(a.C.has(b)&&l&&a.M&&null!=k){var m=a.f.periods.filter(p=>p.ma<b).map(p=>p.duration).reduce((p,u)=>p+u,0);m=k-m;const n=a.C.get(b);a.C.set(b,n+m);a.M=!1}if(a.C.has(b))return a.C.get(b);m=yield hM(a,c,d,f,g,h);a.g.debug(`Segment #${e} has raw media timestamp `+`${m} s.`);a.C.set(b,
72
+ m);return m})},kM=function(a,b,c){return(a=a.j.get(b))?LK(a,c)||null:null},lM=function(a,b,c,d,e){return _.v(function*(){const f=[d,e].filter(Boolean);var g=_.Bl(f,b,c);if(g)return g;g=_.ek([d],a.a.attemptParameters);g.method="HEAD";g.type=2;g=(yield a.I(g)).headers["content-type"];if(!g)throw new _.J(_.C,4,4021,"Unknown MIME type of: "+f.join(", "));return g.toLowerCase().split(";")[0]})},iL=a=>{a=_.Ej(a)||"";return null!=_.ou.video[a]?_.t:null!=_.ou.audio[a]?_.q:null},cK=class{constructor(a,b,c,
73
+ d){if(1===b){if(!d||0===d.length)throw new _.J(_.C,4,4043,"Media playlist must have at least one segment!");if(null==d[0].a)throw new _.J(_.C,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}},lK=class{constructor(a,b,c){c=void 0===c?[]:c;this.ba=b;this.a=a;this.f=c;this.ma=-1}},MJ=class extends _.BI{constructor(a,b,c,d,e,f,g,h,k,l,m,n,p,u,x){u=void 0===u?[]:u;super(a,b,c,d,e,f,g,void 0===h?null:h,void 0===k?!1:k,
74
+ void 0===l?null:l,void 0===m?null:m,void 0===n?null:n,void 0===p?null:p,u,void 0===x?null:x);this.ma=0}},jK=/^#EXT-X-DEFINE/,kK=/^#(EXT-X-DISCONTINUITY-SEQUENCE|EXT-X-ENDLIST|EXT-X-I-FRAMES-ONLY|EXT-X-MEDIA-SEQUENCE|EXT-X-PART-INF|EXT-X-PLAYLIST-TYPE|EXT-X-SERVER-CONTROL|EXT-X-TARGETDURATION|EXT-X-DATERANGE|EXT-X-VERSION)/,mM=class{constructor(){this.h=0;this.a=new Map}},nM=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(()=>
75
+ 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()}},uL=new _.S("clpp.hls.DiscontinuityUtils");var GK={"com.apple.streamingkeydelivery":function(a,b){if(b===_.pg)throw new _.J(_.C,4,4041);if(oJ(a,hJ)===iJ)throw new _.J(_.C,4,4044,"EXT-X-KEY:METHOD SAMPLE-AES-CTR is not supported in FairPlay.");return _.xB(_.pd,[{initDataType:_.Hf,initData:new Uint8Array(0)}],"")},"com.microsoft.playready":zK,"urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":zK,"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":function(a){var b=oJ(a,hJ);if(!xK.includes(b))return yK.error("Widevine in HLS is only supported with [",
76
+ xK.join(", "),"], not",b),null;b=oJ(a,_.ub);b=_.Tk(b);b=_.E(b.data);b=_.xB(_.td,[{initDataType:_.Vc,initData:b}],"");if(a=_.K(a,"KEYID"))b.keyIds=[a.substr(2).toLowerCase()];return b}},xK=["SAMPLE-AES",iJ],yK=new _.S("clpp.hls.DrmParser");var FK=new _.S("clpp.hls.EncryptionUtils");var oM=class{constructor(a){this.g=new _.S("clpp.hls.MediaReader");this.f=a;this.a={attemptParameters:_.Zj()}}};var ML=class{constructor(a){this.streams=a}length(){return this.streams.length}Fc(){return this.streams[0].type}};var KL=class{constructor(a){this.a=a}length(){return this.a.length}};var cL=a=>{if(!a)return null;a=yJ(a.ba,dJ);if(!a)return null;a=Date.parse(a.value);return isNaN(a)?null:a};var pM=class{constructor(){this.a=this.D=null;this.h=1;this.j=new nM;this.o="";this.S=new mM;this.G=0;this.l=new _.Jh(()=>{this.dc()});this.w=_.Db;this.f=null;this.F=new _.qu;this.B=0;this.L=null;this.g=new _.S("clpp.hls.HlsParser");this.C=new Map;this.H=this.M=!1;this.U=new oM(this.I.bind(this));this.P=!1;this.J=null;this.R=!1;this.A=new Map;this.K=new Set}configure(a){this.a=a;this.U.a=a}setCurrentVariant(){}start(a,b){const c=this;return _.v(function*(){if(c.P)throw Error("start() may be called only once!");
77
+ c.P=!0;c.D=b;var d=Date.now();const {response:e,text:f}=yield gL(c,a);c.D.onEvent(new _.H(mJ,{detail:{duration:Date.now()-d,type:"master"}}));c.o=e.uri;d=yield rL(c,f);c.f=d;const g=c.G;c.l&&0<g&&c.l.la(g);return d})}requestStop(){this.R=!0}stop(){this.l&&(this.l.stop(),this.l=null);const a=[];this.F&&(a.push(this.F.destroy()),this.F=null);this.j.clear();this.f=this.a=this.D=null;this.A.clear();this.K.clear();return Promise.all(a)}update(){const a=this;return _.v(function*(){const b=a.f;if(!nL(a)&&
78
+ b){var c=b.presentationTimeline,d=Array.from(a.j.values()),e=yield tL(a,d);d=e.map(g=>g.playlist);vL(a,d);e=yield yL(a,e);SK(b.periods,e).forEach(g=>{a.D.filterNewPeriod(g)});lL(a,e);var f=zL(a,d);f=AL(a,d,f);b.cues=qL(a,f);UK(b.periods,e);fL(c,e);if(d=CJ(d))!0!==a.a.keepTimelineLive&&BL(a,c,e),a.l.stop(),a.l=null;if(a.D.onUpdate)a.D.onUpdate(b);if(d&&a.D.onTurnedStatic)a.D.onTurnedStatic();a.R&&(yield a.stop());return b}})}loadVariant(a,b){const c=this;return _.v(function*(){const d=a.id;var e=c.f.periods.find(k=>
79
+ k.id===b);if(e&&(e=e.variants.find(k=>k.id===d)))return e;e=c.f.alternativeVariants.find(k=>k.id===d);if(!e)throw new _.vj(`No alternative variant with id: ${d}`);var f=null,g=null;if(e.audio){const k=e.audio;f=WL(c,k.verbatimUri,()=>_.v(function*(){const l=yield TL(c,k);return UL(c,k,l)}))}if(e.video){const k=e.video;g=WL(c,k.verbatimUri,()=>_.v(function*(){const l=yield TL(c,k);return UL(c,k,l)}))}f=yield f;g=yield g;e=xL(c,f,g,e.bandwidth,e.id);let h;e&&(e=YK(c.D.configurationId,[e],[],[],0),c.D.filterAllPeriods(e),
80
+ e.forEach((k,l)=>{c.f.periods[l].variants.push(k.variants[0]);b===c.f.periods[l].id&&(h=k.variants[0])}));if(!h)throw new _.vj(`Could load variant with id: ${d}`);return h})}loadTextStream(a,b){const c=this;return _.v(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 _.vj(`Could not load text stream with id: ${a}`);const g=yield WL(c,
81
+ f.verbatimUri,()=>_.v(function*(){const h=yield TL(c,f);vL(c,[h]);return UL(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 _.vj(`Could not load text stream with id: ${a}`);return d})}dc(){const a=this;return _.v(function*(){a.g.debug(_.HA);if(a.D)try{yield a.update(),a.l&&0<a.G&&a.l.la(a.G)}catch(b){if(!(b instanceof _.J))throw b;a.D&&(a.D.onError(b),1===b.severity&&a.l&&a.l.la(.1))}})}I(a){if(!this.F)throw new _.J(_.C,
82
+ 7,7001);a=this.D.networkingEngine.fetch(a);_.vk(this.F,a);return a.V}};_.w("clpp.hls.HlsComponent",class extends _.Ev{install(){_.Mt.m3u8=pM;_.Lt[_.km]=pM;_.Lt[lJ]=pM}uninstall(){_.XC("m3u8");_.YC(_.km);_.YC(lJ)}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 PT=function(a){a.a.one(a.m,_.me,()=>OT(a))},OT=function(a){const b=a.m.getSurface().getMedia();if(b)if(a.h){a.a.on(b.textTracks,_.lc,d=>QT(a,d));var c=Array.from(b.textTracks);c.filter(d=>d.kind===_.te).forEach(d=>{QT(a,{track:d})});!RT(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."),ST(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.")},QT=function(a,b){b=b.track;b.kind===_.te&&(a.g.info("The metadata track has been added."),b.mode=_.Zd,a.a.on(b,_.xd,c=>TT(a,c)))},RT=function(a){return a.some(b=>b.kind===_.te)},ST=function(a,b){const c=a.m.getTrackManager(),d=c.ra(),e=c.getAudioTracks().find(g=>g!==d);if(e){var f=()=>c.za(d);a.a.on(b.textTracks,_.lc,g=>{g.track.kind===_.te&&(a.a.off(b.textTracks,_.lc,f),c.za(d))});c.za(e)}else a.g.warn("Can't enforce the creation of the metadata track if single audio track. Skipping.")},
3
- TT=function(a,b){const c=UT(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 VT(d);if(e.f===c&&null!==e.a){a.f=d;d=a.h.parseMedia(_.mi(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)}}})},UT=function(a){return(a=a.m.getTrackManager().ua())&&a.language&&a.language.toLowerCase()},
4
- VT=class{constructor(a){this.startTime=a.startTime;this.endTime=a.endTime;this.a=this.f=null;a=a.value;if(!_.z(a)){a:{var b=a.info;if(_.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 WT=class{constructor(a,b,c){this.m=a;this.l=b;this.j=c;this.a=new _.It;this.h=(a=_.st(_.yc))?new a(this.m.getConfiguration()):null;this.g=new _.T("clpp.hlssmpte.ImageCueHandler");this.f=null;PT(this)}destroy(){this.a.release();this.f=null;return Promise.resolve()}};var XT=class extends _.Mv{constructor(){super();this.a=null;this.f=!1}onPlayerCreated(){}onContentWillLoad(a){if(this.f=_.Ui()){var b=a.getConfiguration();b=_.$g(b.hlssmpte||{});typeof b.patchMetadataTrack!==_.Kc&&(b.patchMetadataTrack=!1);_.gh(b.timestampOffset)||(b.timestampOffset=0);this.a=new WT(a,b.patchMetadataTrack,b.timestampOffset)}}onPlayerWillDestroy(){const a=this;return _.v(function*(){a.a&&(yield a.a.destroy(),a.a=null)})}id(){return"hlssmpte"}};_.w("clpp.hlssmpte.HlsSmptePlugin",XT);
5
- XT.Id="hlssmpte";_.Kn(new class{create(){return new XT}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var dU=function(a){a.a.one(a.m,_.ke,()=>cU(a))},cU=function(a){const b=a.m.getSurface().getMedia();if(b)if(a.h){a.a.on(b.textTracks,_.nc,d=>eU(a,d));var c=Array.from(b.textTracks);c.filter(d=>d.kind===_.re).forEach(d=>{eU(a,{track:d})});!fU(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."),gU(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.")},eU=function(a,b){b=b.track;b.kind===_.re&&(a.g.info("The metadata track has been added."),b.mode=_.Yd,a.a.on(b,_.wd,c=>hU(a,c)))},fU=function(a){return a.some(b=>b.kind===_.re)},gU=function(a,b){const c=a.m.getTrackManager(),d=c.ra(),e=c.getAudioTracks().find(g=>g!==d);if(e){var f=()=>c.za(d);a.a.on(b.textTracks,_.nc,g=>{g.track.kind===_.re&&(a.a.off(b.textTracks,_.nc,f),c.za(d))});c.za(e)}else a.g.warn("Can't enforce the creation of the metadata track if single audio track. Skipping.")},
3
+ hU=function(a,b){const c=iU(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 jU(d);if(e.f===c&&null!==e.a){a.f=d;d=a.h.parseMedia(_.zi(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)}}})},iU=function(a){return(a=a.m.getTrackManager().ua())&&a.language&&a.language.toLowerCase()},
4
+ jU=class{constructor(a){this.startTime=a.startTime;this.endTime=a.endTime;this.a=this.f=null;a=a.value;if(!_.z(a)){a:{var b=a.info;if(_.dh(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=_.dh(a)?a:null}}};var kU=class{constructor(a,b,c){this.m=a;this.l=b;this.j=c;this.a=new _.Ut;this.h=(a=_.Ct(_.Ac))?new a(this.m.getConfiguration()):null;this.g=new _.S("clpp.hlssmpte.ImageCueHandler");this.f=null;dU(this)}destroy(){this.a.release();this.f=null;return Promise.resolve()}};var lU=class extends _.Zv{constructor(){super();this.a=null;this.f=!1}onPlayerCreated(){}onContentWillLoad(a){if(this.f=_.Yh()){var b=a.getConfiguration();b=_.Yg(b.hlssmpte||{});typeof b.patchMetadataTrack!==_.Mc&&(b.patchMetadataTrack=!1);_.eh(b.timestampOffset)||(b.timestampOffset=0);this.a=new kU(a,b.patchMetadataTrack,b.timestampOffset)}}onPlayerWillDestroy(){const a=this;return _.v(function*(){a.a&&(yield a.a.destroy(),a.a=null)})}id(){return"hlssmpte"}};_.w("clpp.hlssmpte.HlsSmptePlugin",lU);
5
+ lU.Id="hlssmpte";_.Sr(new class{create(){return new lU}});};f.call(g, window);