@castlabs/prestoplay 6.31.0 → 6.32.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +2 -2
  3. package/cjs/cl.adobe.js +3 -3
  4. package/cjs/cl.airplay.js +3 -3
  5. package/cjs/cl.broadpeak.js +18 -18
  6. package/cjs/cl.cast.js +127 -125
  7. package/cjs/cl.cdn.js +13 -0
  8. package/cjs/cl.conviva.js +32 -32
  9. package/cjs/cl.core.js +615 -610
  10. package/cjs/cl.crypto.js +9 -9
  11. package/cjs/cl.dash.js +101 -95
  12. package/cjs/cl.externs.js +113 -44
  13. package/cjs/cl.freewheel.js +26 -26
  14. package/cjs/cl.hls.js +78 -78
  15. package/cjs/cl.hlssmpte.js +6 -6
  16. package/cjs/cl.htmlcue.js +30 -30
  17. package/cjs/cl.ima.js +26 -26
  18. package/cjs/cl.mediatailor.js +3 -3
  19. package/cjs/cl.mse.js +351 -350
  20. package/cjs/cl.muxdata.js +14 -14
  21. package/cjs/cl.onboard.js +4 -4
  22. package/cjs/cl.persistent.js +14 -14
  23. package/cjs/cl.playlist.js +6 -6
  24. package/cjs/cl.simid.js +16 -16
  25. package/cjs/cl.smooth.js +71 -71
  26. package/cjs/cl.thumbnails.js +26 -26
  27. package/cjs/cl.tizen.js +71 -71
  28. package/cjs/cl.ttml.js +29 -29
  29. package/cjs/cl.verimatrix.js +5 -5
  30. package/cjs/cl.vimond.js +11 -11
  31. package/cjs/cl.vr.js +19 -19
  32. package/cjs/cl.vtt.js +14 -14
  33. package/cjs/cl.yospace.js +4 -4
  34. package/cjs/cl.youbora.js +40 -40
  35. package/cl.adobe.js +3 -3
  36. package/cl.airplay.js +3 -3
  37. package/cl.broadpeak.js +14 -14
  38. package/cl.cast.js +102 -101
  39. package/cl.cdn.js +7 -0
  40. package/cl.conviva.js +27 -27
  41. package/cl.core.js +498 -495
  42. package/cl.crypto.js +9 -9
  43. package/cl.dash.js +91 -87
  44. package/cl.externs.js +109 -44
  45. package/cl.freewheel.js +20 -20
  46. package/cl.hls.js +82 -82
  47. package/cl.hlssmpte.js +5 -5
  48. package/cl.htmlcue.js +26 -26
  49. package/cl.ima.js +20 -20
  50. package/cl.mediatailor.js +2 -2
  51. package/cl.mse.js +301 -300
  52. package/cl.muxdata.js +13 -13
  53. package/cl.onboard.js +4 -4
  54. package/cl.persistent.js +10 -10
  55. package/cl.playlist.js +5 -5
  56. package/cl.simid.js +14 -14
  57. package/cl.smooth.js +61 -61
  58. package/cl.thumbnails.js +19 -19
  59. package/cl.tizen.js +56 -56
  60. package/cl.ttml.js +22 -22
  61. package/cl.verimatrix.js +4 -4
  62. package/cl.vimond.js +8 -8
  63. package/cl.vr.js +14 -14
  64. package/cl.vtt.js +12 -12
  65. package/cl.yospace.js +3 -3
  66. package/cl.youbora.js +31 -31
  67. package/package.json +10 -1
  68. package/typings.d.ts +328 -114
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 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);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var dU="clpp-freewheel",eU="clpp.freewheel.AdsManagerFactory",fU="freewheel",gU=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""}},hU=function(a){const b=[];typeof a.networkId!==_.r&&b.push("networkId");typeof a.serverUrl!==_.Uf&&b.push("serverUrl");typeof a.profileId!==_.Uf&&b.push("profileId");typeof a.videoAssetId!==_.Uf&&typeof a.videoAssetId!==_.r&&b.push("videoAssetId");
2
+ if(b.length)throw new _.I(1,9,12001,{missingKeys:b.join(", ")});},iU=function(){return _.w(function*(){var a=new _.Kv;let b=tv.freewheel.SDK.VIDEO_ASSET_AUTO_PLAY_TYPE_NONE;const c=yield a.canPlay(!1);a=yield a.canPlay(!0);c?b=tv.freewheel.SDK.VIDEO_ASSET_AUTO_PLAY_TYPE_ATTENDED:a&&(b=tv.freewheel.SDK.VIDEO_ASSET_AUTO_PLAY_TYPE_UNATTENDED);return b})},jU=function(a){a.l.on(a.a,tv.freewheel.SDK.EVENT_REQUEST_COMPLETE,a.U.bind(a));a.l.on(a.a,tv.freewheel.SDK.EVENT_SLOT_STARTED,a.X.bind(a));a.l.on(a.a,
3
+ tv.freewheel.SDK.EVENT_SLOT_ENDED,a.W.bind(a));a.l.on(a.a,tv.freewheel.SDK.EVENT_AD,a.S.bind(a));a.l.on(a.m,_.gg,a.R.bind(a));a.l.on(a.m,_.Rf,a.P.bind(a))},kU=function(a){const b=a.m.Gd(fU).$c();b&&a.m.getSurface().hide(b);a.m.getSurface().showMediaElement()},lU=function(a){const b=a.m.Gd(fU).$c();b&&(a.m.getSurface().show(b),a.m.getSurface().hideMediaElement(),a.a.registerVideoDisplayBase(dU),a.m.isMuted()?a.setVolume(0):a.setVolume(a.m.getVolume()||1))},mU=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))},nU=class extends _.Uv{constructor(){super();this.f=this.a=null}onPlayerCreated(a){if(window.tv&&tv.freewheel&&tv.freewheel.SDK)this.a=_.Fi(_.Fd,{id:dU}),this.f=_.Fi(_.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 fU}$c(){return this.a}ai(){return this.f}};_.x("clpp.freewheel.FreeWheelPlugin",nU);nU.prototype.getAdVideo=nU.prototype.ai;nU.prototype.getAdContainer=nU.prototype.$c;nU.Id=fU;nU.AD_CONTAINER_ID=dU;var oU=class{create(){return new nU}};var X=class{constructor(a,b,c){this.h=a;this.f=b;this.a=c}eb(){return"FreeWheel AdManager SDK"}fb(){return tv.freewheel.SDK.version}hb(){return 0}getId(){return this.a?this.a.getAdId():""}getCreativeId(){const a=(this.a||{})._creativeId;return typeof a===_.Uf?a:""}zb(){return""}getApiFramework(){return this.a?this.a.getActiveCreativeRendition().getCreativeApi():""}getAdSystem(){return""}getAdvertiserName(){return""}getTitle(){return""}getDuration(){return this.a?this.a.getActiveCreativeRendition().getDuration():
6
+ 0}getPosition(){return 0}getSkipTimeOffset(){return 0}Bb(){return!1}Ra(){return this.a&&this.a.getEventCallbackUrls(tv.freewheel.SDK.EVENT_AD_CLICK,tv.freewheel.SDK.EVENT_TYPE_CLICK)[0]||""}getMediaUrl(){return this.a?this.a.getActiveCreativeRendition().getPrimaryCreativeRenditionAsset().getUrl():""}Va(){return this.a?this.a.getActiveCreativeRendition().getWidth():0}Ua(){return this.a?this.a.getActiveCreativeRendition().getHeight():0}Ba(){return 0}Ca(){switch(this.f.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:return 0;
7
+ case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:return 2;default:return 1}}getPodIndex(){switch(this.Ca()){case 0:return 0;case 2:return-1}return this.h.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL).indexOf(this.f)+1}pb(){switch(this.Ca()){case 0:return 0;case 2:return-1;default:return this.f.getTimePosition()}}gb(){return this.a?this.f.getAdInstances().indexOf(this.a)+1:1}Wa(){return this.f.getAdCount()}getWrapperAdIds(){return[]}canSeek(){return!1}getWrapperAdSystems(){return[]}getWrapperCreativeIds(){return[]}Ab(){return null}};
8
+ X.prototype.getVideoElement=X.prototype.Ab;X.prototype.getWrapperCreativeIds=X.prototype.getWrapperCreativeIds;X.prototype.getWrapperAdSystems=X.prototype.getWrapperAdSystems;X.prototype.canSeek=X.prototype.canSeek;X.prototype.getWrapperAdIds=X.prototype.getWrapperAdIds;X.prototype.getSequenceLength=X.prototype.Wa;X.prototype.getPositionInSequence=X.prototype.gb;X.prototype.getPodTimeOffset=X.prototype.pb;X.prototype.getPodIndex=X.prototype.getPodIndex;X.prototype.getPodType=X.prototype.Ca;
9
+ X.prototype.getMediaBitrate=X.prototype.Ba;X.prototype.getMediaHeight=X.prototype.Ua;X.prototype.getMediaWidth=X.prototype.Va;X.prototype.getMediaUrl=X.prototype.getMediaUrl;X.prototype.getClickThroughUrl=X.prototype.Ra;X.prototype.isBumper=X.prototype.Bb;X.prototype.getSkipTimeOffset=X.prototype.getSkipTimeOffset;X.prototype.getPosition=X.prototype.getPosition;X.prototype.getDuration=X.prototype.getDuration;X.prototype.getTitle=X.prototype.getTitle;X.prototype.getAdvertiserName=X.prototype.getAdvertiserName;
10
+ X.prototype.getAdSystem=X.prototype.getAdSystem;X.prototype.getApiFramework=X.prototype.getApiFramework;X.prototype.getSourceId=X.prototype.zb;X.prototype.getCreativeId=X.prototype.getCreativeId;X.prototype.getId=X.prototype.getId;X.prototype.getTechnology=X.prototype.hb;X.prototype.getAdManagerVersion=X.prototype.fb;X.prototype.getAdManagerName=X.prototype.eb;var pU=class{constructor(a){this.a=a}getCuePoints(){return this.a.getTemporalSlots().map(a=>{switch(a.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:return 0;case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:return-1;default:return a.getTimePosition()}})}Qb(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL).length}Pb(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL).length}};
11
+ pU.prototype.hasPostroll=pU.prototype.Pb;pU.prototype.hasPreroll=pU.prototype.Qb;pU.prototype.getCuePoints=pU.prototype.getCuePoints;var qU=class{constructor(a){this.g=new _.T("clpp.freewheel.AdsManager");this.m=a;this.l=new _.Vt;this.K=new tv.freewheel.SDK.AdManager;this.f=this.a=null;this.M=[];this.I=[];this.L=[];this.H=new _.Kl;this.B=null;this.C=!1;this.G=1;this.J=!1;this.F=!0}load(){const a=this;return _.w(function*(){const b=a.m.getConfiguration().freewheel||{};try{hU(b)}catch(d){return a.m.onError(d),a.H.resolve(),a.H}a.K.setNetwork(b.networkId);a.K.setServer(b.serverUrl);a.a=a.K.newContext();a.a.setProfile(b.profileId);
12
+ typeof b.siteSectionId!==_.Uf&&typeof b.siteSectionId!==_.r||a.a.setSiteSection(b.siteSectionId);const c=yield iU();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,gU(d.type),d.position,d.slotProfile,d.cuepointSequence,d.maxDuration,d.minDuration,d.acceptContentType);b.keyValues&&typeof b.keyValues===_.Ie&&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);jU(a);a.a.submitRequest();return a.H})}j(){if(this.M.length){lU(this);this.f=this.M.shift();this.f.play();var a=!1}else this.f?(this.f.resume(),a=!1):(kU(this),a=!0);return a}A(){}jb(){this.f&&this.f.pause()}skip(){this.f&&this.f.skipCurrentAd()}getAdVolume(){return!this.a||this.C?this.G:this.a.getAdVolume()}h(a){this.G=a;this.C||this.a&&this.a.setAdVolume(a)}setMuted(a){this.C=
14
+ a;this.a&&(a?this.a.setAdVolume(0):this.a.setAdVolume(this.G))}isMuted(){return this.C}qb(){return this.J}isPaused(){return this.F}getPosition(){return this.f?this.f.getPlayheadTime():-1}setVolume(a){this.h(a)}getVolume(){return this.getAdVolume()}pause(){this.jb()}resume(){this.j()}w(){return!0}o(){const a=this;return _.w(function*(){a.l.release();a.B&&(a.B.stop(),a.B=null);kU(a);a.a&&(a.a.dispose(),a.a=null)})}U(a){if(a.success)this.M=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL),
15
+ this.I=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL),this.L=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL),this.m.trigger(new _.H(_.qc,{adsTimeline:new pU(this.a)})),this.B=new _.Iv(this.m.getSurface(),(b,c)=>this.a.resize(b,c),this.m.Gd(fU).f);else this.m.onError(new _.I(1,9,10003,{errorType:0},void 0));this.H.resolve()}X(a){mU(this,_.Ub,a);this.B.start()}W(a){this.f=null;a=a.slot;mU(this,_.Vb);this.B.stop();kU(this);a&&a.getTimePositionClass()===
16
+ tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL||this.m.play()}S(a){const b=a.subType;this.g.debug("ad event",b);switch(b){case tv.freewheel.SDK.EVENT_AD_IMPRESSION:this.setMuted(this.C);this.h(this.G);this.J=!0;this.F=!1;mU(this,_.mc,a);mU(this,_.cc,a);break;case tv.freewheel.SDK.EVENT_AD_IMPRESSION_END:mU(this,_.nc,a);this.F=this.J=!1;break;case tv.freewheel.SDK.EVENT_AD_FIRST_QUARTILE:mU(this,_.Zb,a);break;case tv.freewheel.SDK.EVENT_AD_MIDPOINT:mU(this,_.ec,a);break;case tv.freewheel.SDK.EVENT_AD_THIRD_QUARTILE:mU(this,
17
+ _.oc,a);break;case tv.freewheel.SDK.EVENT_AD_COMPLETE:mU(this,_.Yb,a);break;case tv.freewheel.SDK.EVENT_AD_CLICK:mU(this,_.Xb,a);break;case tv.freewheel.SDK.EVENT_AD_PAUSE:this.F=!0;mU(this,_.hc,a);break;case tv.freewheel.SDK.EVENT_AD_RESUME:this.F=!1;mU(this,_.kc,a);break;case tv.freewheel.SDK.EVENT_AD_SKIPPED:mU(this,_.lc,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_START:mU(this,_.Wb,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_END:mU(this,_.jc,a);break;case tv.freewheel.SDK.EVENT_ERROR:this.m.onError(new _.I(1,
18
+ 9,10003,{errorType:1},{fwCode:a[tv.freewheel.SDK.INFO_KEY_ERROR_CODE],fwInfo:a[tv.freewheel.SDK.INFO_KEY_ERROR_INFO],fwModule:a[tv.freewheel.SDK.INFO_KEY_ERROR_MODULE]}))}}R(){if(!this.f){var a=this.m.getPosition();if(this.f=this.I.find(b=>.5>Math.abs(a-b.getTimePosition()))||null){const b=this.I.findIndex(c=>c===this.f);this.I.splice(b,1);this.m.pause();lU(this);this.f.play()}}}P(a){if((a=a.detail)&&this.a)switch(a.currentState){case 3:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PLAYING);break;
19
+ case 4:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PAUSED);break;case 5:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_COMPLETED);this.L.length?(lU(this),this.f=this.L.shift(),this.f.play()):kU(this);break;case _.Hs:case _.As:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_STOPPED)}}};qU.prototype.resume=qU.prototype.resume;qU.prototype.pause=qU.prototype.pause;qU.prototype.getVolume=qU.prototype.getVolume;qU.prototype.setVolume=qU.prototype.setVolume;qU.prototype.getPosition=qU.prototype.getPosition;
20
+ qU.prototype.skip=qU.prototype.skip;_.Kh(new class{constructor(){this.Ya=new _.T(eU)}name(){return eU}a(a,b){return a.namespace()!==_.hd&&b&&b.freewheel?window.tv&&tv.freewheel&&tv.freewheel.SDK?!0:(this.Ya.warn("FreeWheel SDK is not loaded."),!1):!1}create(a){return new qU(a)}});_.Tn(new oU);};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 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);
1
+ import {clpp} from "./cl.core.js";import './cl.mse.js';let g={};const _ = clpp._;var f=function(window){'use strict';var JI="CLOSED-CAPTIONS",KI="Could not parse MP4 segment start time.",LI="DURATION",MI="EXT-X-DATERANGE",NI="EXT-X-DISCONTINUITY",OI="EXT-X-KEY",PI="EXT-X-MAP",QI="EXT-X-MEDIA",RI="EXT-X-MEDIA-SEQUENCE",SI="EXT-X-PROGRAM-DATE-TIME",TI="EXT-X-STREAM-INF",UI="Failed to infer discontinuity number",VI="Guessing audio-only",WI="METHOD",XI="SAMPLE-AES-CTR",YI="SUBTITLES",ZI="_HLS_part",$I="application/vnd.apple.mpegurl",aJ="manifestloaded",bJ="sample",cJ=function(a,b){return _.L(a,b,void 0,
2
+ {required:!0})},dJ=function(a){if(1>a.a)throw _.Yo();--a.a},eJ=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===_.Ie&&e&&typeof e===_.Ie){if(!eJ(d,e))return!1}else if(void 0!==d&&void 0!==e&&d!==e)return!1}return!0},fJ=function(a,b){if(!eJ(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===_.Ie&&e&&typeof e===_.Ie&&fJ(d,e))return!0}return!1},gJ=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===_.Ie&&typeof d===_.Ie){if(gJ(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},hJ=function(a){if(null!==a&&void 0!==a)return Number(a)},iJ=function(a){return 0>a?[]:Array.from({length:a},(b,c)=>c)},jJ=function(a){return new Uint8Array([a>>
4
+ 24&255,a>>16&255,a>>8&255,a&255])},kJ=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},lJ=function(a,b){return a.filter(c=>c.name===b)},mJ=function(a){const b=/^[a-zA-Z0-9_-]+$/,c=new Set;a.forEach(d=>{const e=_.L(d,"VALUE"),f=_.L(d,_.Ta),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)})},nJ=function(a,b){const c=Array.isArray(b)?b:[b];return a.filter(d=>{d=cJ(d,_.tb);return c.includes(d)})},oJ=function(a,b){return a.some(c=>c.name===b)},pJ=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},qJ=function(a){var b=pJ(a,
6
+ "EXT-X-TILES");if(!b)return{Ld:1,de:1,durationPerTile:null};a=_.L(b,"LAYOUT")||"1x1";b=_.L(b,LI);a=_.DB(a);return{Ld:a.Ld,de:a.de,durationPerTile:b?Number(b):null}},rJ=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)},sJ=function(a,b){Array.isArray(a)||(a=[a]);a.forEach(c=>{for(const d of rJ(c))b(d,c)})},tJ=function(a){return a.some(b=>oJ(b.ba,"EXT-X-ENDLIST"))},
7
+ uJ=function(a){return a.type===_.q||a.type===_.t},vJ=function(a){if(pJ(a,"EXT-X-ENDLIST"))return _.Fb;a=pJ(a,"EXT-X-PLAYLIST-TYPE");if(!a)return"LIVE";if(a.value===_.Fb)return _.Fb;if("EVENT"===a.value)return"EVENT";throw new _.I(_.D,4,4044,`Invalid EXT-X-PLAYLIST-TYPE value: ${a.value}`);},wJ=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},xJ=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}},yJ=function(a,b){a=pJ(a,"EXT-X-BYTERANGE");
9
+ return xJ(a?a.value:null,b)},zJ=function(a){a=pJ(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}},AJ=function(a,b){b=void 0===b?{}:b;const c={jg:!1,Lh:!1,Mh:null,oi:null,Ug:null};a=pJ(a,"EXT-X-SERVER-CONTROL",{required:b.bh});if(!a)return c;const d=e=>null==e?null:Number(e);c.jg="YES"===_.L(a,"CAN-BLOCK-RELOAD");c.Lh="YES"===_.L(a,"CAN-SKIP-DATERANGES");c.Mh=d(_.L(a,"CAN-SKIP-UNTIL"));
10
+ c.oi=d(_.L(a,"HOLD-BACK"));c.Ug=d(_.L(a,"PART-HOLD-BACK",void 0,{required:b.bh}));return c},BJ=function(a,b,c){c=void 0===c?!1:c;a=_.L(a,"BYTERANGE");return xJ(a,b,c)},CJ=function(a){const b=lJ(a,QI),c=lJ(a,TI);a=lJ(a,"EXT-X-IMAGE-STREAM-INF");return{Oc:{dg:nJ(b,[_.pA,_.Eb]),closedCaptions:nJ(b,JI),ij:nJ(b,YI)},ee:c,ef:a}},EJ=function(a,b){const c=yJ(a.ba,null);return new DJ(0,0,0,()=>[a.a],c.na,c.ja,0,b)},FJ=function(a){let b=Infinity,c=Infinity;rJ(a).filter(uJ).forEach(d=>{{d=d.T;var e=d[0].startTime;
11
+ const f=d[d.length-1].endTime;d=e;e=f-e}b=Math.min(b,d);c=Math.min(c,e)});return{nd:b,duration:c}},GJ=function(a){return a.map(b=>{({duration:b}=FJ(b));return b}).reduce((b,c)=>b+c,0)},HJ=function(a){return(a.video?a.video.bb:"")+" - "+(a.audio?a.audio.bb:"")},IJ=function(a,b,c,d,e){if(b===_.Fb)return{delay:0,ce:0};b=pJ(a,"EXT-X-PART-INF");if(c&&b){e=Number(cJ(b,"PART-TARGET"));if(null!=d)return{delay:d,ce:e};({Ug:d}=AJ(a,{bh:!0}));return{delay:d,ce:e}}a=pJ(a,"EXT-X-TARGETDURATION",{required:!0});
12
+ a=Number(a.value);e=e||a;return null!=d?{delay:d,ce:e}:{delay:3*a,ce:e}},JJ=function(a){const b=new Map;a.forEach(c=>{var d=`${c.Hc()}:${c.streams[0].groupId}`;b.has(d)?(d=b.get(d),d.includes(c)||d.push(c)):b.set(d,[c])});return b},KJ=function(a){const b=new Map;for(const c of a){a=_.L(c,_.La);a=_.Kn(a||_.lg);const d=cJ(c,_.Fa),e=cJ(c,"INSTREAM-ID");b.has(d)||b.set(d,new Map);b.get(d).set(e,a)}return b},LJ=function(a){return a.filter(b=>"mp4a.40.34"!==b)},MJ=function(a,b,c,d,e){var f=e&&e.ae,g=e&&
13
+ e.schemeIdUri,h=_.L(a,"ID");f=_.L(a,"START-DATE")||f;if(null===h||!f)return _.lv.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,ae:f};f=hJ(_.L(a,LI));void 0!==f&&0<=f&&(h.duration=f);f=hJ(_.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=_.kh(d)?d:null}k=k||{};(d=_.L(a,"CUE"))&&(k.CUE=d.split(","));if(_.jk(g)){f=a.attributes;if(null==f)var l=null;else{d={};for(l of f)switch(l.name){case _.Ob:d[_.Ob]=l.value;break;case _.Nb:d[_.Nb]=l.value;break;case _.Sb:d[_.Sb]=hJ(l.value);break;case _.Qb:d[_.Qb]=hJ(l.value);break;case "X-SNAP":d["X-SNAP"]=l.value.split(",");break;
15
+ case _.Rb:d[_.Rb]=l.value.split(",")}l=_.kh(d)?d:null}l&&(k=Object.assign(k,l))}_.kh(k)&&(h.customAttributes=k);if(gJ(e,h))return _.lv.warn("EXT-X-DATERANGE augmented and previous values differ.Ignoring the EXT-X-DATERANGE tag.",a),null;h=_.hh(e,h);if(_.jk(g)&&!_.kk(h.customAttributes))return _.lv.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},NJ=function(a,b){if(!a)return null;const c=a.bb;return b.find(d=>d.streams[0].bb===c)||null},OJ=function(a){return(a=_.L(a,"CHANNELS"))?parseInt(a.split("/")[0],10):null},PJ=function(a){return a.some(b=>b.startsWith("#EXT-X-TARGETDURATION"))?1:0},QJ=function(a,b){const c=new Map,d=new URL(b);a.forEach(e=>{var f=_.L(e,_.Ta),g=_.L(e,"QUERYPARAM");if(f)g=cJ(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},RJ=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})},SJ=function(a,b){a.forEach(c=>{c.attributes.forEach(d=>{d.value=RJ(d.value,b)})})},VJ=function(a,b,c){const d=[];for(let e=0;e<b.length;e++){const f=TJ(a,b[e]);d.push(f);if(f.name===TI){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 _.vr(_.wb,g));e++}}b=lJ(d,"EXT-X-DEFINE");mJ(b);b=QJ(b,c);a.a=b;SJ(d,a.a);return new UJ(c,0,d)},ZJ=function(a,b,c){const {Xi:d,ni:e,uj:f}=WJ(b),g=XJ(a,f,c);b=e.map(k=>TJ(a,k,g));const h=YJ(a,c,d,g);return new UJ(c,1,b,h)},$J=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===PJ(b)?VJ(a,b,
19
+ c):ZJ(a,b,c)},WJ=function(a){const b=[],c=[],d=[];for(const e of a)aK.test(e)?d.push(e):bK.test(e)?c.push(e):b.push(e);return{Xi:b,ni:c,uj:d}},XJ=function(a,b,c){b=b.map(e=>TJ(a,e));mJ(b);const d=QJ(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},TJ=function(a,b,c){a=_.xr(a.h++,b);c&&SJ([a],c);return a},YJ=function(a,b,c,d){const e=
20
+ [];let f=[],g=[];c.forEach(h=>{/^(#EXT)/.test(h)?(h=TJ(a,h,d),"EXT-X-PART"===h.name||"EXT-X-PRELOAD-HINT"===h.name&&"PART"===_.L(h,_.tb)?g.push(h):f.push(h)):(oJ(f,"EXT-X-GAP")||(h=RJ(h,d),h=_.Tm(h,b),e.push(new cK(h,f,g))),f=[],g=[])});0<g.length&&e.push(new cK(null,f,g));return e},dK=function(a,b,c){const d=[],e=[];e.push(new _.vr(_.ma,"0"));e.push(new _.vr(_.wb,b));c.length&&e.push(new _.vr(_.pa,c));d.push(new _.wr(a.h++,TI,e));return new UJ(b,0,d)},eK=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);}kJ(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}}kJ(a,e)||d();e+=10;e+=f}while(e<a.byteLength);return d()},fK=function(a,b){let c=null,d=0;try{(new _.np).N(_.Ee,_.gp).N(_.ig,_.gp).N(_.ze,_.gp).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 _.Sv.error("Unable to find timescale in init segment!"),new _.I(_.D,4,4030,KI,c);let e=0,f=!1;try{(new _.np).N("moof",_.gp).N("traf",_.gp).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,KI,c);return e},gK=function(a){for(;a.getPosition()<a.Ta()-1;){const b=a.getPosition();if(71===_.Zo(a))return dJ(a),b}return-1},hK=function(a){function b(){d.seek(e+188);f=_.Zo(d);
24
+ 71!==f&&(d.seek(e+192),f=_.Zo(d));71!==f&&(d.seek(e+204),f=_.Zo(d));71!==f&&c();dJ(d)}function c(){throw new _.I(_.D,4,4030);}const d=new _.kq(new DataView(a),!1);let e=0,f=0;e=gK(d);0>e&&(_.Sv.error("Unable to find sync byte in TS after scanning."),c());for(;;){e=d.getPosition();f=_.Zo(d);71!==f&&c();a=_.$o(d);if(8191===(a&8191)){b();continue}if(!(a&16384)){b();continue}a=(_.Zo(d)&48)>>4;0!==a&&2!==a||c();3===a&&(a=_.Zo(d),d.skip(a));if(1!==_.N(d)>>8){b();continue}d.skip(3);a=_.Zo(d)>>6;0!==a&&1!==
25
+ a||c();0===_.Zo(d)&&c();a=_.Zo(d);const g=_.$o(d),h=_.$o(d);return(1073741824*((a&14)>>1)+((g&65534)<<14|(h&65534)>>1))/9E4}},kK=function(a){const b=iK(a),c=jK(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)})},jK=function(a){a=a.map(b=>b.T[b.T.length-1].ma);return Math.min(...a)},iK=function(a){a=a.map(b=>b.T[0].ma);return Math.max(...a)},nK=function(a){var b=cJ(a,WI);if(!lK.includes(b))return mK.error("PlayReady in HLS is only supported with [",
26
+ lK.join(", "),"], not",b),null;a=cJ(a,_.wb);b=_.jm(a);a=null;b=_.G(b.data);try{a=_.dB(_.rq(b))}catch(c){a=b}return _.rB(_.ud,[{initDataType:_.Wc,initData:a}],"")},pK=function(a){if(0===a.length)return oK();if(a.some(c=>"whole-segment"===c.type)||a.every(c=>c.type===_.He))return a[0];a=a.filter(c=>c.type===bJ);const b=_.gi(a.flatMap(c=>c.drmInfos));return{keyId:a[a.length-1].keyId,type:bJ,drmInfos:b}},sK=function(a,b){return qK(a).map(c=>rK(c.ba,b)).filter(Boolean)},qK=function(a){return a.filter(b=>
27
+ oJ(b.ba,OI))},rK=function(a,b){a=lJ(a,OI).filter(d=>"AES-128"!==cJ(d,WI));if(0===a.length)return null;var c=cJ(a[0],WI);if(1===a.length&&"NONE"===c)return oK();c=a.map(d=>cJ(d,WI));if(!c.every(d=>"SAMPLE-AES"===d)&&!c.every(d=>d===XI))throw tK.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=uK[e]||null;d=f?f(d,b):null}d||tK.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:bJ,drmInfos:a}},oK=function(){return{type:_.He,drmInfos:[],keyId:null}},vK=function(a,b,c){a=lJ(a,OI)[0];if(!a||"AES-128"!==cJ(a,WI))return null;var d=_.L(a,"IV","");d?c={iv:_.fm((d||"0x").slice(2)),generatedIv:!1}:(d=_.L(a,"KEYFORMAT"),c=null==d||"identity"===d?{iv:_.im(new Uint8Array(12),jJ(c)),generatedIv:!0}:{iv:null,generatedIv:!1});const {iv:e,
29
+ generatedIv:f}=c;return{method:"AES-128",url:_.Tm(cJ(a,_.wb),b),iv:e,generatedIv:f}},wK=function(a,b,c){return _.w(function*(){const d=b.f(),e=_.ZB(b.Da(),b.na,b.na+2048-1,a.a.attemptParameters);e.type=2;const f=_.ZB(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.");}}})},xK=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 wK(a,c,f);g=_.G(g.data);if(!kJ(g))throw new _.I(_.D,4,4030,"AAC segment does not contain an ID3 tag.");return eK(g)}if(d===_.Ag||d===
31
+ _.Hc)return g=[wK(a,c,f)],b&&g.push(wK(a,b,!0)),g=yield Promise.all(g),fK(g[0].data,(g[1]||g[0]).data);if(d===_.zg)return g=yield wK(a,c,f),hK(g.data);if(!_.rt(`${d.split("/")[0]||""}/mp4;codecs="${e}"`))return 0;throw new _.I(_.D,4,4030);})},yK=function(a,b){a=a.map(c=>c.streams[b]);return a.some(c=>null==c)?null:a},zK=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},AK=function(a,b){a.streams.forEach(c=>
32
+ {c.Re=b})},BK=function(a,b){a.streams.forEach(c=>{c.width=b})},CK=function(a,b){a.streams.forEach(c=>{c.height=b})},DK=function(a,b){a.streams.forEach(c=>{c.frameRate=b})},EK=function(a,b){a.streams.forEach(c=>{c.bandwidth=b})},FK=function(a,b){a=a.map(c=>c.a[b]);return a.some(c=>null==c)?null:a},GK=function(a,b){const c=new Set(a.map(d=>d.ma));return b.filter(d=>!c.has(d.ma))},IK=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
+ HK(c,d);const e=a.length-1;c=a[e];d=b[e];0<e&&(c.startTime!==d.startTime||c.endTime!==d.endTime)&&HK(c,d);for(c=e+1;c<b.length;)a.push(b[c]),c++},MK=function(a,b,c,d,e){var f=b[0].length();f=iJ(f).map(g=>{var h=FK(b,g)||[];const k=yK(c,g)||[];g=yK(d,g)||[];{const l=[...JK(h),...k,...g].filter(Boolean);KK(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;LK(f);return f},
34
+ JK=function(a){a=new Set(a.flatMap(b=>[b.video,b.audio]).filter(Boolean));return Array.from(a)},LK=function(a){for(let b=0;b<a.length;b++){const c=a[b],d=a[b-1];c.startTime=d?d.endTime:c.startTime;c.endTime=c.startTime+c.duration}},HK=function(a,b){a.startTime=b.startTime;a.endTime=b.endTime;a.duration=b.duration;NK(a.variants,b.variants);OK(rJ(a),rJ(b))},NK=function(a,b){const c=new Map(a.map(d=>[HJ(d),d]));b.forEach(d=>{c.get(HJ(d)).drmInfos=d.drmInfos})},OK=function(a,b){const c=new Map(a.map(d=>
35
+ [d.bb,d]));b.forEach(d=>{const e=c.get(d.bb);e.T=d.T;d.T.forEach(f=>{f.initSegment=e.initSegmentReference});e.segmentIndex.replace(d.T);e.nd=d.nd;e.jf=d.jf;e.duration=d.duration;e.sg=d.sg;e.encrypted=d.encrypted;e.drmInfos=d.drmInfos;e.keyId=d.keyId})},KK=function(a){const b=PK(a);a.forEach(c=>{_.VB(c.segmentIndex,b);c.duration=b;c.jf=c.nd+b})},PK=function(a){let b=Infinity;a.filter(uJ).forEach(c=>{b=Math.min(b,c.duration)});return b},TK=function(a){if(!(2>a.length)&&QK(a)){a=a.map(e=>({playlist:e,
36
+ og:RK(e.T[0])}));var b=a.map(e=>e.og),c=Math.max(...b);b=Math.min(...b);if(!(1E3>c-b)){a.forEach(e=>{const f=e.playlist;for(e=e.og;0<f.T.length&&1E3<c-e;){var g=f.T.shift(),h=f.T[0];if(!h)break;SK(g,h);h=RK(h);null!=h?e=h:({duration:h}=zJ(g.ba),e+=1E3*h)}});a=a.map(e=>e.playlist);if(a.some(e=>0===e.T.length))throw new _.I(_.D,4,4048,"Media playlists are completely out of sync.");var d=Math.min(...a.map(e=>e.T.length));a.forEach(e=>{for(;e.T.length>d;)e.T.pop()})}}},QK=function(a){return a.every(b=>
37
+ !!RK(b.T[0]))},SK=function(a,b){a&&b&&[PI,OI].forEach(c=>{if(!oJ(b.ba,c)){var d=a.ba.filter(e=>e.name===c);0!==d.length&&d.forEach(e=>{b.ba.push(e)})}})},UK=function(a,b){sJ(b,(c,d)=>{_.lC(a,c.T,d.startTime)});_.dC(a.a,b[0].startTime,b[b.length-1].endTime)},VK=function(a,b){return _.w(function*(){var c=_.zk([b],a.a.attemptParameters);c.type=1;c=yield a.I(c);let d="";try{d=_.ri(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
+ fL=function(a,b){return _.w(function*(){var c=WK(a,b,a.o,"");if(1===c.type){var d=c.T[0].a;c=XK(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=dK(a.S,a.o,a.a.hlsDefaultCodecs||d)}d=CJ(c.ba);c=YK(d.Oc.dg);c.forEach(m=>{a.K.add(m.groupId)});var e=yield ZK(a,d);var f=e.Ai;const g=e.periods;var h=e.Ri;const k=e.kj;d=e.alternativeVariants;const l=e.alternativeTextStreams;e=e.alternativeImageStreams;if(!a.D)throw new _.I(_.D,7,7001);
39
+ $K(a,g);h=aL(a,f.delay,g,h);bL(a)||(a.G=f.ce,a.g.info(`Update playlist each ${a.G} s`),cL(a));dL(a,h,g);f=eL(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})},hL=function(a,b){return Promise.all(b.map(c=>gL(a,c)))},jL=function(a,b){b.forEach(c=>{a:{var d=a.j.get(c.verbatimUri),e=!bL(a),f=pJ(c.ba,"EXT-X-DISCONTINUITY-SEQUENCE");
40
+ if(f)var g=Number(f.value);else{d?(f=d.streams[d.streams.length-1].T,f=f[f.length-1].ma):f=0;if(e&&0<f)try{{const k=pJ(c.ba,RI);if(!k)throw iL.error("Failed to infer discontinuity number, because EXT-X-MEDIA-SEQUENCE tag is missing."),Error(UI);const l=Number(k.value),m=zK(d,l);if(!m)throw iL.error("Failed to infer discontinuity number, could not find the appropriate segment in the previous playlist"+` (segment position = ${l})`),Error(UI);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)oJ(k.ba,NI)&&g++,k.ma=g});kK(b)},mL=function(a,b){return _.w(function*(){"LIVE"===a.w&&(a.M=!0,a.H=!0);const {textStreams:c,thumbStreams:d,Gh:e}=yield kL(a,b),f=a.f.periods[0].variants.map(g=>{const h=NJ(g.audio,e),k=NJ(g.video,e);g=lL(a,h,k,g.bandwidth);if(!g)throw new _.I(_.D,4,4047,{message:"Video and audio are encrypted in an incompatible way.",Yj:k?k.streams[0].bb:void 0,audio:h?
42
+ h.streams[0].bb:void 0});return g});return MK(a.D.configurationId,f,c,d,a.B)})},$K=function(a,b){bL(a)||2!==a.a.timeline.version||(a.J||(a.J=b[0].startTime),_.hD(b,-a.J))},nL=function(a,b){b=b.flatMap(d=>d.T[0].ba);b=pJ(b,SI);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},oL=function(a,b,c){b=b.find(e=>null!==pJ(e.ba,MI));if(!b)return[];if(null===c)throw new _.I(_.D,4,4024,
43
+ "EXT-X-PROGRAM-DATE-TIME tag is required when EXT-X-DATERANGE tags are present");var d=b.ba.filter(e=>e.name===MI);b=new Map;for(const e of d)d=(d=_.L(e,"ID"))?b.get(d):void 0,(d=MJ(e,c,a.B,!bL(a),d))&&b.set(d.id,d);return Array.from(b.values())},eL=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.ae!==d.ae)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,ae:d.ae,endTime:d.endTime,id:d.id,type:_.de,eventElement:null};b&&!fJ(b,e)||a.A.set(d.id,e)}return Array.from(a.A.values())},pL=function(a,b,c){a.w=_.Fb;_.hC(b,!0);b.f=c[c.length-1].endTime},WK=function(a,b,c,d){a=$J(a.S,b,c);a.verbatimUri=d;return a},YK=function(a){return a.filter(b=>b.name===QI&&_.L(b,_.tb)===_.pA&&!_.L(b,_.wb)).map(b=>{const c=OJ(b),d=_.L(b,_.La)||_.lg;return{groupId:cJ(b,_.Fa),id:_.pI++,
45
+ label:cJ(b,_.Ta),language:d,channelsCount:c,primary:"YES"===_.L(b,"DEFAULT")}})},ZK=function(a,b){return _.w(function*(){var c=KJ(b.Oc.closedCaptions),d=qL(a,b.ee),e=yield rL(a,b),f=Object.values(e).flat().map(k=>k.playlist),g=f[0];const h=vJ(g.ba);a.w=h;h!==_.Fb&&(a.H=!0);jL(a,f);!bL(a)&&TK(f);a.L=AJ(g.ba);f=IJ(g.ba,h,a.a.lowLatencyMode||!1,a.a.suggestedPresentationDelay,a.a.liveRefreshPeriod);g=yield sL(a,e.eg,d);c=yield tL(a,e.ee,g,c);d=yield uL(a,e.hj,d);g=yield vL(a,e.ef);d=MK(a.D.configurationId,
46
+ c,d,g,a.B);a.D.filterAllPeriods(d);c=[...e.ee,...e.eg].map(k=>k.playlist);e=nL(a,c);c=oL(a,c,e);return{periods:d,Ri:e,kj:c,Ai:f}})},aL=function(a,b,c,d){let e=!0,f=null,g=0;bL(a)||(e=!1,f=0,g=b);b=a.a.timeline||{};b.type=void 0;a=new _.uI(b,f,g,!0,void 0,!!a.a.lowLatencyMode);_.hC(a,e);UK(a,c);d&&_.gC(a,d);return a},cL=function(a){var b=0;for(var c of a.j.values())b=Math.max(b,c.streams[0].nd);for(c=0;95443.7176888889<=b;)c+=95443.7176888889,b-=95443.7176888889;if(c){a.g.debug("Offsetting live streams by",
47
+ c,"to compensate for rollover");for(const d of a.j.values())b=d.streams[0],95443.7176888889>b.nd?(a.g.debug("Offset applied to",b.type),b.segmentIndex.offset(c)):a.g.debug("Offset NOT applied to",b.type)}},dL=function(a,b,c){c=GJ(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===_.Fb&&(b.f=c)},kL=function(a,b){return _.w(function*(){const c=h=>h.stream.Hc()===_.t||h.stream.Hc()===_.q;var d=b.filter(c),e=b.filter(h=>
48
+ !c(h)),f=h=>{var k=h.stream.streams[0];k={language:k.language,channelsCount:k.channelsCount,spatialAudio:k.spatialAudio,closedCaptions:k.closedCaptions,primary:k.primary,kind:k.kind||null,groupId:k.groupId,type:k.type,codecs:k.codecs,name:k.originalId,uri:k.bb,fe:{width:k.width,height:k.height,frameRate:k.frameRate}};h=Object.assign({},{playlist:h.playlist,hc:null},k);return wL(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));xL(a,g.concat(d));e=d.filter(h=>
49
+ h.Hc()===_.VA);f=d.filter(h=>h.Hc()===_.he);return{textStreams:e,thumbStreams:f,Gh:g}})},lL=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?_.KB(l.drmInfos,m.drmInfos)?_.JB(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:_.lg,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 yL(f)},wL=function(a,b){return _.w(function*(){const c=b.playlist,d=b.codecs,e=b.type,f=b.kd,g=b.hc,h=b.groupId,k=b.muxedAudioId,l=b.primary;var m=b.kind;const n=b.name,p=b.channelsCount,u=b.spatialAudio,v=b.closedCaptions,y=b.fe,A=_.Kn(f||_.lg);if(1!==c.type)throw new _.I(_.D,4,4017);const E=yield zL(a,c,e,d),F=a.a.lowLatencyMode?_.MA:_.LA;let C=m;e!==_.K||m||(C=_.VA);const ja=vJ(c.ba);m=E.map(Ca=>{const Xa=Ca.T,Jb=Ca.Rh,vb=Ca.mimeType,fc=Ca.ma,gc=Xa[0].startTime,Kb=Xa[Xa.length-
51
+ 1].endTime,kb=Kb-gc,ya=new _.vI(Xa),yb=Xa[0].initSegment||null;return{id:null==g?_.pI++:g,originalId:n,createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:ya.f.bind(ya),getSegmentReference:ya.get.bind(ya),adjustSegmentDurations:ya.h.bind(ya),getDuration:ya.getDuration.bind(ya),segmentIndex:ya,segmentLookupStrategy:F,initSegmentReference:yb,mimeType:vb,codecs:d,kind:C,sg:Jb.type,encrypted:Jb.type===bJ,aesEncrypted:Ca.aesEncrypted,keyId:Jb.keyId,language:A,originalLanguage:f||_.lg,
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:Xa,drmInfos:Jb.drmInfos,ma:fc,bb:c.verbatimUri,Re:c.a,nd:gc,jf:Kb,duration:kb,groupId:h,Nj:ja,muxedAudioId:k}});return new AL(m)})},xL=function(a,b){b.forEach(c=>{a.j.a.set(c.streams[0].bb,c)})},qL=function(a,b){const c=new Map;for(const f of b){var d=_.L(f,_.pA);b=_.L(f,_.Eb);var e=
53
+ _.L(f,YI);const g=BL(a,f);if(e){const h=_.Or(_.K,g);c.set(`${_.K}:${e}`,h);e=g.indexOf(h);-1<e&&g.splice(e,1)}d&&(e=CL(_.q,g),c.set(`${"audio"}:${d}`,e));b&&(d=CL(_.t,g),c.set(`${"video"}:${b}`,d))}return c},rL=function(a,b){return _.w(function*(){const c=yield Promise.all([DL(a,b.Oc.dg),DL(a,b.Oc.ij),DL(a,b.ee),DL(a,b.ef)]),[d,e,f,g]=c;return{eg:d,hj:e,ee:f,ef:g}})},sL=function(a,b,c){return _.w(function*(){if(0===b.length)return new Map;var d=[EL(a,b[0],c)];yield d[0];d=d.concat(b.slice(1).map(e=>
54
+ EL(a,e,c)));d=yield Promise.all(d);return JJ(d)})},tL=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(cJ(f[k].tag,_.ma));l<h&&(h=l,g=k)}h=f.splice(g,1).pop();h=yield FL(a,h,c,d,e);f=f.map(k=>FL(a,k,c,d,e));f=yield Promise.all(f);f.splice(g,0,h);return f.reduce(_.oB,[])})},uL=function(a,b,c){return Promise.all(b.map(d=>EL(a,d,c)))},vL=function(a,b){return Promise.all(b.map(c=>GL(a,c)))},HL=function(a,b){return _.w(function*(){const c=
55
+ _.Tm(b.verbatimUri,a.o),{response:d,text:e}=yield VK(a,c);return WK(a,e,d.uri,b.verbatimUri)})},IL=function(a,b,c){return _.w(function*(){const d=yield wL(a,{playlist:c,codecs:b.codecs,type:b.type,kd:b.originalLanguage,hc:b.id,groupId:b.groupId,primary:b.primary,kind:b.kind||null,name:b.label,channelsCount:b.channelsCount,spatialAudio:b.spatialAudio||!1,closedCaptions:b.closedCaptions,fe:{width:b.width,height:b.height,frameRate:b.frameRate}});b.bandwidth&&EK(d,b.bandwidth);return d})},bL=function(a){return a.w===
56
+ _.Fb},DL=function(a,b){return _.w(function*(){return(yield Promise.all(b.map(c=>_.w(function*(){const d=yield JL(a,c);return d?{tag:c,playlist:d}:null})))).filter(Boolean)})},gL=function(a,b){return _.w(function*(){var c=new URL(b.streams[0].Re);if(a.a.lowLatencyMode&&a.L&&a.L.jg){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={Bi:d.position,Mi:e&&0<e.length?f:null}}else d=null;if(e=d)d=c.searchParams,f=e.Mi,d.set("_HLS_msn",e.Bi.toString()),null===
57
+ f&&d.get(ZI)&&d.delete(ZI),null!==f&&d.set(ZI,f.toString())}const {response:g,text:h}=yield VK(a,c.toString());c=b.streams[0].bb;d=b.streams[0].Re;e=g.uri;d!==e&&(d=e,AK(b,d));c=WK(a,h,d,c);return{stream:b,playlist:c}})},BL=function(a,b){var c=_.L(b,_.pa,a.a.hlsDefaultCodecs||"avc1.42E01E,mp4a.40.2").split(/\s*,\s*/);c=LJ(c);b=new Set;const d=[];for(const e of c)c=_.uB(e),b.has(c)?a.g.debug("Ignoring duplicate codec"):(d.push(e),b.add(c));return d},CL=function(a,b){if(1===b.length)return b[0];a=_.Or(a,
58
+ b);if(null!=a)return a;throw new _.I(_.D,4,4025,{codecList:b});},EL=function(a,b,c){return _.w(function*(){const d=b.tag,e=b.playlist;return KL(a,e.verbatimUri,()=>_.w(function*(){const f=cJ(d,_.Fa),g=wJ(cJ(d,_.tb));var h=cJ(d,_.tb).toUpperCase();if(wJ(h)!==_.K)h=null;else{var k=d.getAttribute("FORCED");k=!(!k||!k.value||"YES"!==k.value.toUpperCase());var l=_.VA;h===JI&&(l=_.GA);k&&(l=_.Zd);h=l}k=c.get(`${g}:${f}`)||"";l=_.L(d,_.La);const m=_.L(d,_.Ta),n=_.L(d,"DEFAULT"),p=g===_.q?OJ(d):null;var u=
59
+ g===_.q?(u=_.L(d,"CHANNELS"))?u.includes("/JOC"):!1:!1;return yield wL(a,{playlist:e,codecs:k,type:g,kd:l,primary:"YES"===n,name:m,channelsCount:p,spatialAudio:u,groupId:f,kind:h,hc:null,closedCaptions:null,fe:null})}))})},GL=function(a,b){return _.w(function*(){const c=b.tag,d=b.playlist;return KL(a,d.verbatimUri,()=>_.w(function*(){var e=_.L(c,_.pa)||"jpg",f=_.L(c,_.La);const g=_.L(c,_.Ta);e=yield wL(a,{playlist:d,codecs:e,type:_.he,kd:f,name:g,primary:!1,kind:null,channelsCount:null,spatialAudio:!1,
60
+ closedCaptions:null,hc:null,groupId:null,fe:null});(f=_.L(c,_.ma))&&EK(e,Number(f));return e}))})},FL=function(a,b,c,d,e){return _.w(function*(){var f=b.tag,g=Number(cJ(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:hJ(h),width:hJ(k),height:hJ(l)}}else h=null;if(f=yield LL(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].bb:"")+" - "+(n?n.streams[0].bb:"");if(e.has(m)){a.g.debug("Skipping variant which only differs in text streams.");continue}const u=lL(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})},ML=function(a,b,c,d,e,f){let g=BL(a,b);a.g.debug("Guessing stream type for",b.toString());b=!1;const h=_.Or(_.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(VI),c=_.q,b=!0):e?(a.g.debug(VI),c=_.q):(a.g.debug("Guessing video-only"),c=_.t):(c=_.q,a.g.debug(VI));return{type:c,Dh:g,pi:b}},KL=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},LL=function(a,b,c,d,e){return _.w(function*(){var f=b.tag,g=b.playlist,h=_.L(f,_.pA),k=_.L(f,_.Eb);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].bb===l);const {type:m,Dh:n,pi:p}=ML(a,f,c,k.audio.length,k.video.length,g);f=null;p||(f=yield NL(a,b,n,m,e,c));if(null==f)return null;k[m]=[f];m===_.q&&c&&k.video.forEach(u=>{BK(u,c.width);CK(u,c.height);DK(u,c.frameRate)});return k})},NL=function(a,b,c,d,e,f){return _.w(function*(){const g=b.tag,h=b.playlist;return KL(a,h.verbatimUri,()=>_.w(function*(){var k=_.L(g,JI);let l=null;d===_.t&&k&&"NONE"!==k&&(l=e.get(k));k=(k=_.L(g,_.pA)||void 0)&&a.K.has(k)?k:void 0;var m=CL(d,c);if(k){const n=
64
+ CL(_.q,c);m+=`,${n}`}return yield wL(a,{playlist:h,codecs:m,type:d,closedCaptions:l,primary:!1,kind:null,kd:null,name:null,channelsCount:null,spatialAudio:!1,hc:null,groupId:null,muxedAudioId:k,fe:f})}))})},zL=function(a,b,c,d){return _.w(function*(){var e=b.verbatimUri,f=b.T;var g=void 0===g?0:g;var h=pJ(b.ba,RI);var k=h?Number(h.value):g;g=[];h=null;if(a.H){a.H=!1;var l=a.B;a.B=yield OL(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)oJ(m.ba,NI)&&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 PL(a,b.a,k,e,c,d,g[g.length-1]||null,h),g.push(l),e+=k.length;QL(g);return g})},JL=function(a,b){return _.w(function*(){var c=b.name!==QI?!0:_.L(b,_.tb)===YI;c=_.L(b,_.wb,void 0,{required:c});if(!c)return null;const d=_.Tm(c,a.o),e=Date.now(),{response:f,text:g}=yield VK(a,d);a.D.onEvent(new _.H(aJ,{detail:{duration:Date.now()-e,type:"media"}}));return WK(a,g,f.uri,c)})},QL=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.");},RL=function(a,b,c){a=lJ(a.ba,PI);if(1<a.length)throw new _.I(_.D,4,4020);a=a[0];if(!a)return null;const d=cJ(a,_.wb),e=_.Tm(d,b);b=BJ(a,null,!0);return new _.qI(()=>[e],b.na,b.ja,c)},SL=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,LI));n=m+n;k=BJ(u,k?null:l.ja,k);l=String(_.L(u,_.wb));
67
+ const v=(l=_.Tm(l,g))?[l]:[];m=new DJ(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},TL=function(a,b,c,d,e,f,g,h,k,l,m){const n=c.ba;var p=c.a;0<lJ(n,PI).length&&(m=RL(c,k,g));var u=null!=p;const v=p?[p]:[];if(!u&&!a.a.lowLatencyMode)return null;let y=0,A={na:0,ja:null};p=null;u&&({duration:u}=zJ(n),y=e+u,A=yJ(n,b?b.ja:null));a.a.lowLatencyMode&&0<c.f.length&&(p=SL(b,c,d,e,f,g,k),0===y&&(y=p[p.length-1].endTime));a=h===_.he?qJ(n):
68
+ null;d=new DJ(d,e,y,()=>v,A.na,A.ja,f,g,!1,null,a?a.Ld:null,a?a.de:null,a?a.durationPerTile:null,p,m);d.ma=l;return d},OL=function(a,b,c,d,e,f,g){return _.w(function*(){var h=d[0];if(!bL(a)&&a.f)try{return UL(a,c,e)}catch(n){if(h=a.j.get(c)){var k=h.streams[h.streams.length-1].T;k=k[k.length-1];a.g.warn(`Last #EXT-X-MEDIA-SEQUENCE values ${h.streams[0].T[0].position} - ${k.position}`+`, new values ${e} - ${e+d.length-1}.`,b,h)}throw new _.I(_.D,4,4047,{message:"The updated playlist does not share any segments with the previous one.",
69
+ uri:c});}k=yield VL(a,f,g,h);const l=vK(h.ba,a.o,e),m=RL(h,b,l);h=yield WL(a,m,h,l,k,g);a.g.debug(`Setting playlist start time to ${h}.`);return h})},PL=function(a,b,c,d,e,f,g,h){return _.w(function*(){var k=c[0];const l=yield VL(a,e,f,k);var m=g?g.yi:null;if(oJ(c[0].ba,OI)||null===m)m=sK(c,l),m=0===m.length?[oK()]:m;else{var n=sK(c,l);m=[m,...n]}n=m;m=n[n.length-1];n=pK(n);let p=g?g.zi:null;var u=XL(p,k.ba,a.o,d);let v=RL(k,b,u)||(g?g.ri:null);const y=k.ma;k=yield YL(a,y,v,k,d,u,l,f,h,null==g);u=
70
+ [];let A=!1;for(let F=0;F<c.length;F++){var E=c[F];const C=u[u.length-1]||null,ja=0===F?0:C.endTime,Ca=d+F,Xa=XL(p,E.ba,a.o,Ca);(p=Xa)&&(A=!0);if(E=TL(a,C,E,Ca,ja,k,Xa,e,b,y,v))v=E.initSegment,u.push(E)}return{T:u,Rh:n,yi:m,aesEncrypted:A,mimeType:l,endTime:u[u.length-1].endTime,ma:y,ri:v,zi:p}})},UL=function(a,b,c){const d=ZL(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},VL=function(a,b,c,d){return _.w(function*(){const e=
71
+ d.a;var f=pJ(d.ba,PI);f=f?cJ(f,_.wb):null;return $L(a,b,c,e,f)})},WL=function(a,b,c,d,e,f){return _.w(function*(){if(null==c.a)return 0;const g=EJ(c,d);return xK(a.U,b,g,e,f,null!=d)})},XL=function(a,b,c,d){return b.some(e=>e.name===OI&&"NONE"===_.L(e,WI))?null:(b=vK(b,c,d))?b:a&&a.generatedIv?Object.assign({},a,{iv:_.im(new Uint8Array(12),jJ(d))}):a},YL=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 WL(a,c,d,f,g,h);a.g.debug(`Segment #${e} has raw media timestamp `+`${m} s.`);a.C.set(b,m);return m})},ZL=function(a,b,c){return(a=a.j.get(b))?zK(a,c)||null:null},$L=function(a,b,c,d,e){return _.w(function*(){const f=[d,e].filter(Boolean);var g=_.Rr(f,b,c);if(g)return g;g=_.zk([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]})},XK=a=>{a=_.Um(a)||"";return null!=_.Hu.video[a]?_.t:null!=_.Hu.audio[a]?_.q:null},UJ=class{constructor(a,b,c,d){if(1===b){if(!d||0===d.length)throw new _.I(_.D,4,4043,"Media playlist must have at least one segment!");if(null==d[0].a)throw new _.I(_.D,4,4043,"Media playlist must have at least one full segment!");}this.a=a;this.verbatimUri="";this.type=b;this.ba=c;this.T=1===b?d:null}},cK=class{constructor(a,b,c){c=void 0===c?[]:c;this.ba=b;this.a=
74
+ a;this.f=c;this.ma=-1}},DJ=class extends _.rI{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}},aK=/^#EXT-X-DEFINE/,bK=/^#(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)/,aM=class{constructor(){this.h=
75
+ 0;this.a=new Map}},bM=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()}},iL=new _.T("clpp.hls.DiscontinuityUtils");var uK={"com.apple.streamingkeydelivery":function(a,b){if(b===_.zg)throw new _.I(_.D,4,4041);if(cJ(a,WI)===XI)throw new _.I(_.D,4,4044,"EXT-X-KEY:METHOD SAMPLE-AES-CTR is not supported in FairPlay.");return _.rB(_.sd,[{initDataType:_.Nf,initData:new Uint8Array(0)}],"")},"com.microsoft.playready":nK,"urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":nK,"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":function(a){var b=cJ(a,WI);if(!lK.includes(b))return mK.error("Widevine in HLS is only supported with [",
76
+ lK.join(", "),"], not",b),null;b=cJ(a,_.wb);b=_.jm(b);b=_.G(b.data);b=_.rB(_.wd,[{initDataType:_.Wc,initData:b}],"");if(a=_.L(a,"KEYID"))b.keyIds=[a.substr(2).toLowerCase()];return b}},lK=["SAMPLE-AES",XI],mK=new _.T("clpp.hls.DrmParser");var tK=new _.T("clpp.hls.EncryptionUtils");var cM=class{constructor(a){this.g=new _.T("clpp.hls.MediaReader");this.f=a;this.a={attemptParameters:_.vk()}}};var AL=class{constructor(a){this.streams=a}length(){return this.streams.length}Hc(){return this.streams[0].type}};var yL=class{constructor(a){this.a=a}length(){return this.a.length}};var RK=a=>{if(!a)return null;a=pJ(a.ba,SI);if(!a)return null;a=Date.parse(a.value);return isNaN(a)?null:a};var dM=class{constructor(){this.a=this.D=null;this.h=1;this.j=new bM;this.o="";this.S=new aM;this.G=0;this.l=new _.Pi(()=>{this.dc()});this.w=_.Fb;this.f=null;this.F=new _.ju;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 cM(this.I.bind(this));this.P=!1;this.J=null;this.R=!1;this.A=new Map;this.K=new Set}configure(a){this.a=a;this.U.a=a}setCurrentVariant(){}start(a,b){const c=this;return _.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 VK(c,a);c.D.onEvent(new _.H(aJ,{detail:{duration:Date.now()-d,type:"master"}}));c.o=e.uri;d=yield fL(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(!bL(a)&&
78
+ b){var c=b.presentationTimeline,d=Array.from(a.j.values()),e=yield hL(a,d);d=e.map(g=>g.playlist);jL(a,d);e=yield mL(a,e);GK(b.periods,e).forEach(g=>{a.D.filterNewPeriod(g)});$K(a,e);var f=nL(a,d);f=oL(a,d,f);b.cues=eL(a,f);IK(b.periods,e);UK(c,e);if(d=tJ(d))!0!==a.a.keepTimelineLive&&pL(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 _.tl(`No alternative variant with id: ${d}`);var f=null,g=null;if(e.audio){const k=e.audio;f=KL(c,k.verbatimUri,()=>_.w(function*(){const l=yield HL(c,k);return IL(c,k,l)}))}if(e.video){const k=e.video;g=KL(c,k.verbatimUri,()=>_.w(function*(){const l=yield HL(c,k);return IL(c,k,l)}))}f=yield f;g=yield g;e=lL(c,f,g,e.bandwidth,e.id);let h;e&&(e=MK(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 _.tl(`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 _.tl(`Could not load text stream with id: ${a}`);const g=yield KL(c,
81
+ f.verbatimUri,()=>_.w(function*(){const h=yield HL(c,f);jL(c,[h]);return IL(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 _.tl(`Could not load text stream with id: ${a}`);return d})}dc(){const a=this;return _.w(function*(){a.g.debug(_.BA);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);_.Jl(this.F,a);return a.V}};_.x("clpp.hls.HlsComponent",class extends _.Ev{install(){_.Pt.m3u8=dM;_.Ot[_.xl]=dM;_.Ot[$I]=dM}uninstall(){_.QC("m3u8");_.RC(_.xl);_.RC($I)}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 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);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var VT=function(a){a.a.one(a.m,_.re,()=>UT(a))},UT=function(a){const b=a.m.getSurface().getMedia();if(b)if(a.h){a.a.on(b.textTracks,_.pc,d=>WT(a,d));var c=Array.from(b.textTracks);c.filter(d=>d.kind===_.Be).forEach(d=>{WT(a,{track:d})});!XT(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."),YT(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.")},WT=function(a,b){b=b.track;b.kind===_.Be&&(a.g.info("The metadata track has been added."),b.mode=_.ce,a.a.on(b,_.Bd,c=>ZT(a,c)))},XT=function(a){return a.some(b=>b.kind===_.Be)},YT=function(a,b){const c=a.m.getTrackManager(),d=c.ra(),e=c.getAudioTracks().find(g=>g!==d);if(e){var f=()=>c.za(d);a.a.on(b.textTracks,_.pc,g=>{g.track.kind===_.Be&&(a.a.off(b.textTracks,_.pc,f),c.za(d))});c.za(e)}else a.g.warn("Can't enforce the creation of the metadata track if single audio track. Skipping.")},
3
+ ZT=function(a,b){const c=$T(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 aU(d);if(e.f===c&&null!==e.a){a.f=d;d=a.h.parseMedia(_.vi(e.a),{periodStart:a.j,segmentStart:e.startTime,segmentEnd:e.endTime});const f=a.m.getTextDisplayer();f.remove(0,e.startTime);f.append(d.cues,d.styles)}}})},$T=function(a){return(a=a.m.getTrackManager().ua())&&a.language&&a.language.toLowerCase()},
4
+ aU=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(_.oh(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=_.oh(a)?a:null}}};var bU=class{constructor(a,b,c){this.m=a;this.l=b;this.j=c;this.a=new _.Vt;this.h=(a=_.Ft(_.Bc))?new a(this.m.getConfiguration()):null;this.g=new _.T("clpp.hlssmpte.ImageCueHandler");this.f=null;VT(this)}destroy(){this.a.release();this.f=null;return Promise.resolve()}};var cU=class extends _.Uv{constructor(){super();this.a=null;this.f=!1}onPlayerCreated(){}onContentWillLoad(a){if(this.f=_.bj()){var b=a.getConfiguration();b=_.ih(b.hlssmpte||{});typeof b.patchMetadataTrack!==_.Nc&&(b.patchMetadataTrack=!1);_.ph(b.timestampOffset)||(b.timestampOffset=0);this.a=new bU(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",cU);
5
+ cU.Id="hlssmpte";_.Tn(new class{create(){return new cU}});};f.call(g, window);