@castlabs/prestoplay 6.30.1-beta.1 → 6.31.1

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