@castlabs/prestoplay 6.22.0 → 6.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/cjs/cl.adobe.js +3 -3
  3. package/cjs/cl.airplay.js +3 -3
  4. package/cjs/cl.broadpeak.js +7 -7
  5. package/cjs/cl.cast.js +112 -112
  6. package/cjs/cl.conviva.js +32 -33
  7. package/cjs/cl.core.js +591 -586
  8. package/cjs/cl.crypto.js +9 -9
  9. package/cjs/cl.dash.js +81 -80
  10. package/cjs/cl.externs.js +43 -36
  11. package/cjs/cl.freewheel.js +24 -24
  12. package/cjs/cl.hls.js +69 -69
  13. package/cjs/cl.hlssmpte.js +6 -6
  14. package/cjs/cl.htmlcue.js +30 -29
  15. package/cjs/cl.ima.js +23 -23
  16. package/cjs/cl.mse.js +330 -325
  17. package/cjs/cl.muxdata.js +15 -15
  18. package/cjs/cl.onboard.js +3 -3
  19. package/cjs/cl.persistent.js +13 -13
  20. package/cjs/cl.playlist.js +6 -6
  21. package/cjs/cl.sessions.js +16 -16
  22. package/cjs/cl.simid.js +15 -15
  23. package/cjs/cl.smooth.js +72 -72
  24. package/cjs/cl.thumbnails.js +26 -26
  25. package/cjs/cl.tizen.js +72 -72
  26. package/cjs/cl.ttml.js +29 -29
  27. package/cjs/cl.verimatrix.js +5 -5
  28. package/cjs/cl.vimond.js +12 -13
  29. package/cjs/cl.vr.js +19 -19
  30. package/cjs/cl.vtt.js +14 -14
  31. package/cjs/cl.yospace.js +4 -4
  32. package/cjs/cl.youbora.js +37 -37
  33. package/cl.adobe.js +3 -3
  34. package/cl.airplay.js +3 -3
  35. package/cl.broadpeak.js +5 -5
  36. package/cl.cast.js +88 -88
  37. package/cl.conviva.js +27 -27
  38. package/cl.core.js +477 -474
  39. package/cl.crypto.js +9 -9
  40. package/cl.dash.js +76 -75
  41. package/cl.externs.js +43 -36
  42. package/cl.freewheel.js +19 -19
  43. package/cl.hls.js +74 -74
  44. package/cl.hlssmpte.js +5 -5
  45. package/cl.htmlcue.js +26 -26
  46. package/cl.ima.js +17 -17
  47. package/cl.mse.js +295 -291
  48. package/cl.muxdata.js +13 -13
  49. package/cl.onboard.js +4 -4
  50. package/cl.persistent.js +10 -10
  51. package/cl.playlist.js +5 -5
  52. package/cl.sessions.js +10 -10
  53. package/cl.simid.js +13 -13
  54. package/cl.smooth.js +59 -59
  55. package/cl.thumbnails.js +19 -19
  56. package/cl.tizen.js +57 -57
  57. package/cl.ttml.js +22 -22
  58. package/cl.verimatrix.js +4 -4
  59. package/cl.vimond.js +8 -8
  60. package/cl.vr.js +15 -15
  61. package/cl.vtt.js +12 -12
  62. package/cl.yospace.js +3 -3
  63. package/cl.youbora.js +28 -27
  64. package/package.json +1 -1
  65. package/typings.d.ts +53 -6
package/cl.freewheel.js CHANGED
@@ -1,19 +1,19 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var XT="clpp-freewheel",YT="clpp.freewheel.AdsManagerFactory",ZT="freewheel",$T=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""}},aU=function(a){const b=[];typeof a.networkId!==_.t&&b.push("networkId");typeof a.serverUrl!==_.Sf&&b.push("serverUrl");typeof a.profileId!==_.Sf&&b.push("profileId");typeof a.videoAssetId!==_.Sf&&typeof a.videoAssetId!==_.t&&b.push("videoAssetId");
2
- if(b.length)throw new _.I(1,9,12001,{missingKeys:b.join(", ")});},bU=function(){return _.x(function*(){var a=new _.av;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})},cU=function(a){a.j.on(a.a,tv.freewheel.SDK.EVENT_REQUEST_COMPLETE,a.K.bind(a));a.j.on(a.a,tv.freewheel.SDK.EVENT_SLOT_STARTED,a.M.bind(a));a.j.on(a.a,
3
- tv.freewheel.SDK.EVENT_SLOT_ENDED,a.L.bind(a));a.j.on(a.a,tv.freewheel.SDK.EVENT_AD,a.J.bind(a));a.j.on(a.m,_.Zf,a.I.bind(a));a.j.on(a.m,_.Pf,a.H.bind(a))},fU=function(a){return _.x(function*(){a.G.length?(dU(a),a.f=a.G.shift(),a.f.play()):(eU(a),yield a.m.a.play())})},eU=function(a){const b=a.m.Wc(ZT).Dc();b&&a.m.getSurface().hide(b);a.m.getSurface().showMediaElement()},dU=function(a){const b=a.m.Wc(ZT).Dc();b&&(a.m.getSurface().show(b),a.m.getSurface().hideMediaElement(),a.a.registerVideoDisplayBase(XT),
4
- a.m.isMuted()?a.setVolume(0):a.setVolume(a.m.getVolume()||1))},gU=function(a){a.F.length?(dU(a),a.f=a.F.shift(),a.f.play()):eU(a)},hU=function(a,b,c){var d=null;a.a&&c&&(c.adInstance||c.slot)&&(c=(d=c.adInstance||null)?d.getSlot():c.slot,d={ad:new Y(a.a,c,d)});a.m.trigger(new _.E(b,d))},iU=class extends _.iv{constructor(){super();this.f=this.a=null}onPlayerCreated(a){if(window.tv&&tv.freewheel&&tv.freewheel.SDK)this.a=_.Zo(_.Id,{id:XT}),this.f=_.Zo(_.w,{"class":_.hd}),this.a.appendChild(this.f),a.getSurface().addElementToContainer(this.a,
5
- !0),a.getSurface().hide(this.a);else a.onError(new _.I(1,9,12E3))}onPlayerWillDestroy(a){this.a&&(a.getSurface().removeElementFromContainer(this.a),this.f=this.a=null)}id(){return ZT}Dc(){return this.a}Ug(){return this.f}};_.z("clpp.freewheel.FreeWheelPlugin",iU);iU.prototype.getAdVideo=iU.prototype.Ug;iU.prototype.getAdContainer=iU.prototype.Dc;iU.Id=ZT;iU.AD_CONTAINER_ID=XT;_.Yq(new class{create(){return new iU}});var Y=class{constructor(a,b,c){this.h=a;this.f=b;this.a=c}lb(){return"FreeWheel AdManager SDK"}nb(){return tv.freewheel.SDK.version}qb(){return 0}getId(){return this.a?this.a.getAdId():""}getCreativeId(){const a=(this.a||{})._creativeId;return typeof a===_.Sf?a:""}Nb(){return""}getApiFramework(){return this.a?this.a.getActiveCreativeRendition().getCreativeApi():""}getAdSystem(){return""}getAdvertiserName(){return""}getTitle(){return""}getDuration(){return this.a?this.a.getActiveCreativeRendition().getDuration():
6
- 0}getPosition(){return 0}getSkipTimeOffset(){return 0}Qb(){return!1}ob(){return this.a&&this.a.getEventCallbackUrls(tv.freewheel.SDK.EVENT_AD_CLICK,tv.freewheel.SDK.EVENT_TYPE_CLICK)[0]||""}getMediaUrl(){return this.a?this.a.getActiveCreativeRendition().getPrimaryCreativeRenditionAsset().getUrl():""}eb(){return this.a?this.a.getActiveCreativeRendition().getWidth():0}cb(){return this.a?this.a.getActiveCreativeRendition().getHeight():0}Qa(){return 0}Ra(){switch(this.f.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:return 0;
7
- case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:return 2;default:return 1}}getPodIndex(){switch(this.Ra()){case 0:return 0;case 2:return-1}return this.h.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL).indexOf(this.f)+1}Db(){switch(this.Ra()){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}fb(){return this.f.getAdCount()}getWrapperAdIds(){return[]}getWrapperAdSystems(){return[]}getWrapperCreativeIds(){return[]}Pb(){return null}};
8
- Y.prototype.getVideoElement=Y.prototype.Pb;Y.prototype.getWrapperCreativeIds=Y.prototype.getWrapperCreativeIds;Y.prototype.getWrapperAdSystems=Y.prototype.getWrapperAdSystems;Y.prototype.getWrapperAdIds=Y.prototype.getWrapperAdIds;Y.prototype.getSequenceLength=Y.prototype.fb;Y.prototype.getPositionInSequence=Y.prototype.Eb;Y.prototype.getPodTimeOffset=Y.prototype.Db;Y.prototype.getPodIndex=Y.prototype.getPodIndex;Y.prototype.getPodType=Y.prototype.Ra;Y.prototype.getMediaBitrate=Y.prototype.Qa;
9
- Y.prototype.getMediaHeight=Y.prototype.cb;Y.prototype.getMediaWidth=Y.prototype.eb;Y.prototype.getMediaUrl=Y.prototype.getMediaUrl;Y.prototype.getClickThroughUrl=Y.prototype.ob;Y.prototype.isBumper=Y.prototype.Qb;Y.prototype.getSkipTimeOffset=Y.prototype.getSkipTimeOffset;Y.prototype.getPosition=Y.prototype.getPosition;Y.prototype.getDuration=Y.prototype.getDuration;Y.prototype.getTitle=Y.prototype.getTitle;Y.prototype.getAdvertiserName=Y.prototype.getAdvertiserName;Y.prototype.getAdSystem=Y.prototype.getAdSystem;
10
- Y.prototype.getApiFramework=Y.prototype.getApiFramework;Y.prototype.getSourceId=Y.prototype.Nb;Y.prototype.getCreativeId=Y.prototype.getCreativeId;Y.prototype.getId=Y.prototype.getId;Y.prototype.getTechnology=Y.prototype.qb;Y.prototype.getAdManagerVersion=Y.prototype.nb;Y.prototype.getAdManagerName=Y.prototype.lb;var jU=class{constructor(a){this.a=a}getCuePoints(){return this.a.getTemporalSlots().map(a=>{switch(a.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:return 0;case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:return-1;default:return a.getTimePosition()}})}Gb(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL).length}Fb(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL).length}};
11
- jU.prototype.hasPostroll=jU.prototype.Fb;jU.prototype.hasPreroll=jU.prototype.Gb;jU.prototype.getCuePoints=jU.prototype.getCuePoints;var kU=class{constructor(a){this.g=new _.S("clpp.freewheel.AdsManager");this.m=a;this.j=new _.jt;this.C=new tv.freewheel.SDK.AdManager;this.f=this.a=null;this.G=[];this.B=[];this.F=[];this.A=new _.In;this.w=null}load(){const a=this;return _.x(function*(){const b=a.m.getConfiguration().freewheel||{};try{aU(b)}catch(d){return a.m.onError(d),a.A.resolve(),a.A}a.C.setNetwork(b.networkId);a.C.setServer(b.serverUrl);a.a=a.C.newContext();a.a.setProfile(b.profileId);typeof b.siteSectionId!==_.Sf&&typeof b.siteSectionId!==
12
- _.t||a.a.setSiteSection(b.siteSectionId);const c=yield bU();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,$T(d.type),d.position,d.slotProfile,d.cuepointSequence,d.maxDuration,d.minDuration,d.acceptContentType);b.keyValues&&typeof b.keyValues===_.Ge&&Object.keys(b.keyValues).forEach(d=>a.a.addKeyValue(d,b.keyValues[d]));a.a.setParameter(tv.freewheel.SDK.PARAMETER_EXTENSION_CONTENT_VIDEO_ENABLED,!1,tv.freewheel.SDK.PARAMETER_LEVEL_GLOBAL);
13
- if(Array.isArray(b.parameters))for(const d of b.parameters)a.a.setParameter(d.name,d.value,d.level);cU(a);a.a.submitRequest();return a.A})}start(){const a=this;return _.x(function*(){yield fU(a)})}o(){}resume(){this.f&&this.f.resume()}pause(){this.f&&this.f.pause()}skip(){this.f&&this.f.skipCurrentAd()}getVolume(){return this.a?this.a.getAdVolume():1}setVolume(a){this.a&&this.a.setAdVolume(a)}getPosition(){return this.f?this.f.getPlayheadTime():-1}l(){return!0}h(){const a=this;return _.x(function*(){a.j.release();
14
- a.w&&(a.w.stop(),a.w=null);eU(a);a.a&&(a.a.dispose(),a.a=null)})}K(a){if(a.success)this.G=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL),this.B=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL),this.F=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL),this.m.trigger(new _.E(_.xc,{adsTimeline:new jU(this.a)})),this.w=new _.Zu(this.m.getSurface(),(b,c)=>this.a.resize(b,c),this.m.Wc(ZT).f);else this.m.onError(new _.I(1,
15
- 9,10003,{errorType:0},void 0));this.A.resolve()}M(a){hU(this,_.cc,a);this.w.start()}L(a){this.f=null;a=a.slot;hU(this,_.dc);this.w.stop();if(a)switch(a.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:fU(this);break;case tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL:eU(this);this.m.play();break;case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:gU(this)}}J(a){const b=a.subType;this.g.debug("ad event",b);switch(b){case tv.freewheel.SDK.EVENT_AD_IMPRESSION:hU(this,_.tc,a);hU(this,
16
- _.lc,a);break;case tv.freewheel.SDK.EVENT_AD_IMPRESSION_END:hU(this,_.uc,a);break;case tv.freewheel.SDK.EVENT_AD_FIRST_QUARTILE:hU(this,_.hc,a);break;case tv.freewheel.SDK.EVENT_AD_MIDPOINT:hU(this,_.nc,a);break;case tv.freewheel.SDK.EVENT_AD_THIRD_QUARTILE:hU(this,_.vc,a);break;case tv.freewheel.SDK.EVENT_AD_COMPLETE:hU(this,_.gc,a);break;case tv.freewheel.SDK.EVENT_AD_CLICK:hU(this,_.fc,a);break;case tv.freewheel.SDK.EVENT_AD_PAUSE:hU(this,_.oc,a);break;case tv.freewheel.SDK.EVENT_AD_RESUME:hU(this,
17
- _.rc,a);break;case tv.freewheel.SDK.EVENT_AD_SKIPPED:hU(this,_.sc,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_START:hU(this,_.ec,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_END:hU(this,_.qc,a);break;case tv.freewheel.SDK.EVENT_ERROR:this.m.onError(new _.I(1,9,10003,{errorType:1},{fwCode:a[tv.freewheel.SDK.INFO_KEY_ERROR_CODE],fwInfo:a[tv.freewheel.SDK.INFO_KEY_ERROR_INFO],fwModule:a[tv.freewheel.SDK.INFO_KEY_ERROR_MODULE]}))}}I(){if(!this.f){var a=this.m.getPosition();if(this.f=this.B.find(b=>
18
- .5>Math.abs(a-b.getTimePosition()))||null){const b=this.B.findIndex(c=>c===this.f);this.B.splice(b,1);this.m.pause();dU(this);this.f.play()}}}H(a){if((a=a.detail)&&this.a)switch(a.currentState){case _.Fo:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PLAYING);break;case _.Eo:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PAUSED);break;case _.uo:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_COMPLETED);gU(this);break;case _.Co:case _.Bo:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_STOPPED)}}};
19
- kU.prototype.getPosition=kU.prototype.getPosition;kU.prototype.setVolume=kU.prototype.setVolume;kU.prototype.getVolume=kU.prototype.getVolume;kU.prototype.skip=kU.prototype.skip;kU.prototype.pause=kU.prototype.pause;kU.prototype.resume=kU.prototype.resume;_.Xo(new class{constructor(){this.f=new _.S(YT)}name(){return YT}a(a,b){return a.namespace()!==_.ld&&b&&b.freewheel?window.tv&&tv.freewheel&&tv.freewheel.SDK?!0:(this.f.warn("FreeWheel SDK is not loaded."),!1):!1}create(a){return new kU(a)}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var oU="clpp-freewheel",pU="clpp.freewheel.AdsManagerFactory",qU="freewheel",rU=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""}},sU=function(a){const b=[];typeof a.networkId!==_.t&&b.push("networkId");typeof a.serverUrl!==_.Uf&&b.push("serverUrl");typeof a.profileId!==_.Uf&&b.push("profileId");typeof a.videoAssetId!==_.Uf&&typeof a.videoAssetId!==_.t&&b.push("videoAssetId");
2
+ if(b.length)throw new _.H(1,9,12001,{missingKeys:b.join(", ")});},tU=function(){return _.x(function*(){var a=new _.jv;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})},uU=function(a){a.j.on(a.a,tv.freewheel.SDK.EVENT_REQUEST_COMPLETE,a.K.bind(a));a.j.on(a.a,tv.freewheel.SDK.EVENT_SLOT_STARTED,a.M.bind(a));a.j.on(a.a,
3
+ tv.freewheel.SDK.EVENT_SLOT_ENDED,a.L.bind(a));a.j.on(a.a,tv.freewheel.SDK.EVENT_AD,a.J.bind(a));a.j.on(a.m,_.ag,a.I.bind(a));a.j.on(a.m,_.Rf,a.H.bind(a))},xU=function(a){return _.x(function*(){a.G.length?(vU(a),a.f=a.G.shift(),a.f.play()):(wU(a),yield a.m.a.play())})},wU=function(a){const b=a.m.Uc(qU).Bc();b&&a.m.getSurface().hide(b);a.m.getSurface().showMediaElement()},vU=function(a){const b=a.m.Uc(qU).Bc();b&&(a.m.getSurface().show(b),a.m.getSurface().hideMediaElement(),a.a.registerVideoDisplayBase(oU),
4
+ a.m.isMuted()?a.setVolume(0):a.setVolume(a.m.getVolume()||1))},yU=function(a){a.F.length?(vU(a),a.f=a.F.shift(),a.f.play()):wU(a)},zU=function(a,b,c){var d=null;a.a&&c&&(c.adInstance||c.slot)&&(c=(d=c.adInstance||null)?d.getSlot():c.slot,d={ad:new Y(a.a,c,d)});a.m.trigger(new _.D(b,d))},AU=class extends _.rv{constructor(){super();this.f=this.a=null}onPlayerCreated(a){if(window.tv&&tv.freewheel&&tv.freewheel.SDK)this.a=_.hp(_.Hd,{id:oU}),this.f=_.hp(_.w,{"class":_.gd}),this.a.appendChild(this.f),a.getSurface().addElementToContainer(this.a,
5
+ !0),a.getSurface().hide(this.a);else a.onError(new _.H(1,9,12E3))}onPlayerWillDestroy(a){this.a&&(a.getSurface().removeElementFromContainer(this.a),this.f=this.a=null)}id(){return qU}Bc(){return this.a}Sg(){return this.f}};_.y("clpp.freewheel.FreeWheelPlugin",AU);AU.prototype.getAdVideo=AU.prototype.Sg;AU.prototype.getAdContainer=AU.prototype.Bc;AU.Id=qU;AU.AD_CONTAINER_ID=oU;_.gr(new class{create(){return new AU}});var Y=class{constructor(a,b,c){this.h=a;this.f=b;this.a=c}kb(){return"FreeWheel AdManager SDK"}lb(){return tv.freewheel.SDK.version}pb(){return 0}getId(){return this.a?this.a.getAdId():""}getCreativeId(){const a=(this.a||{})._creativeId;return typeof a===_.Uf?a:""}Lb(){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}Ob(){return!1}nb(){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():""}ab(){return this.a?this.a.getActiveCreativeRendition().getWidth():0}$a(){return this.a?this.a.getActiveCreativeRendition().getHeight():0}Pa(){return 0}Qa(){switch(this.f.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:return 0;
7
+ case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:return 2;default:return 1}}getPodIndex(){switch(this.Qa()){case 0:return 0;case 2:return-1}return this.h.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL).indexOf(this.f)+1}Bb(){switch(this.Qa()){case 0:return 0;case 2:return-1;default:return this.f.getTimePosition()}}Cb(){return this.a?this.f.getAdInstances().indexOf(this.a)+1:1}bb(){return this.f.getAdCount()}getWrapperAdIds(){return[]}getWrapperAdSystems(){return[]}getWrapperCreativeIds(){return[]}Nb(){return null}};
8
+ Y.prototype.getVideoElement=Y.prototype.Nb;Y.prototype.getWrapperCreativeIds=Y.prototype.getWrapperCreativeIds;Y.prototype.getWrapperAdSystems=Y.prototype.getWrapperAdSystems;Y.prototype.getWrapperAdIds=Y.prototype.getWrapperAdIds;Y.prototype.getSequenceLength=Y.prototype.bb;Y.prototype.getPositionInSequence=Y.prototype.Cb;Y.prototype.getPodTimeOffset=Y.prototype.Bb;Y.prototype.getPodIndex=Y.prototype.getPodIndex;Y.prototype.getPodType=Y.prototype.Qa;Y.prototype.getMediaBitrate=Y.prototype.Pa;
9
+ Y.prototype.getMediaHeight=Y.prototype.$a;Y.prototype.getMediaWidth=Y.prototype.ab;Y.prototype.getMediaUrl=Y.prototype.getMediaUrl;Y.prototype.getClickThroughUrl=Y.prototype.nb;Y.prototype.isBumper=Y.prototype.Ob;Y.prototype.getSkipTimeOffset=Y.prototype.getSkipTimeOffset;Y.prototype.getPosition=Y.prototype.getPosition;Y.prototype.getDuration=Y.prototype.getDuration;Y.prototype.getTitle=Y.prototype.getTitle;Y.prototype.getAdvertiserName=Y.prototype.getAdvertiserName;Y.prototype.getAdSystem=Y.prototype.getAdSystem;
10
+ Y.prototype.getApiFramework=Y.prototype.getApiFramework;Y.prototype.getSourceId=Y.prototype.Lb;Y.prototype.getCreativeId=Y.prototype.getCreativeId;Y.prototype.getId=Y.prototype.getId;Y.prototype.getTechnology=Y.prototype.pb;Y.prototype.getAdManagerVersion=Y.prototype.lb;Y.prototype.getAdManagerName=Y.prototype.kb;var BU=class{constructor(a){this.a=a}getCuePoints(){return this.a.getTemporalSlots().map(a=>{switch(a.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:return 0;case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:return-1;default:return a.getTimePosition()}})}Eb(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL).length}Db(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL).length}};
11
+ BU.prototype.hasPostroll=BU.prototype.Db;BU.prototype.hasPreroll=BU.prototype.Eb;BU.prototype.getCuePoints=BU.prototype.getCuePoints;var CU=class{constructor(a){this.g=new _.S("clpp.freewheel.AdsManager");this.m=a;this.j=new _.st;this.C=new tv.freewheel.SDK.AdManager;this.f=this.a=null;this.G=[];this.B=[];this.F=[];this.A=new _.Mn;this.w=null}load(){const a=this;return _.x(function*(){const b=a.m.getConfiguration().freewheel||{};try{sU(b)}catch(d){return a.m.onError(d),a.A.resolve(),a.A}a.C.setNetwork(b.networkId);a.C.setServer(b.serverUrl);a.a=a.C.newContext();a.a.setProfile(b.profileId);typeof b.siteSectionId!==_.Uf&&typeof b.siteSectionId!==
12
+ _.t||a.a.setSiteSection(b.siteSectionId);const c=yield tU();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,rU(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,!1,tv.freewheel.SDK.PARAMETER_LEVEL_GLOBAL);
13
+ if(Array.isArray(b.parameters))for(const d of b.parameters)a.a.setParameter(d.name,d.value,d.level);uU(a);a.a.submitRequest();return a.A})}start(){const a=this;return _.x(function*(){yield xU(a)})}o(){}resume(){this.f&&this.f.resume()}pause(){this.f&&this.f.pause()}skip(){this.f&&this.f.skipCurrentAd()}getVolume(){return this.a?this.a.getAdVolume():1}setVolume(a){this.a&&this.a.setAdVolume(a)}getPosition(){return this.f?this.f.getPlayheadTime():-1}l(){return!0}h(){const a=this;return _.x(function*(){a.j.release();
14
+ a.w&&(a.w.stop(),a.w=null);wU(a);a.a&&(a.a.dispose(),a.a=null)})}K(a){if(a.success)this.G=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL),this.B=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL),this.F=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL),this.m.trigger(new _.D(_.wc,{adsTimeline:new BU(this.a)})),this.w=new _.hv(this.m.getSurface(),(b,c)=>this.a.resize(b,c),this.m.Uc(qU).f);else this.m.onError(new _.H(1,
15
+ 9,10003,{errorType:0},void 0));this.A.resolve()}M(a){zU(this,_.bc,a);this.w.start()}L(a){this.f=null;a=a.slot;zU(this,_.cc);this.w.stop();if(a)switch(a.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:xU(this);break;case tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL:wU(this);this.m.play();break;case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:yU(this)}}J(a){const b=a.subType;this.g.debug("ad event",b);switch(b){case tv.freewheel.SDK.EVENT_AD_IMPRESSION:zU(this,_.sc,a);zU(this,
16
+ _.kc,a);break;case tv.freewheel.SDK.EVENT_AD_IMPRESSION_END:zU(this,_.tc,a);break;case tv.freewheel.SDK.EVENT_AD_FIRST_QUARTILE:zU(this,_.gc,a);break;case tv.freewheel.SDK.EVENT_AD_MIDPOINT:zU(this,_.mc,a);break;case tv.freewheel.SDK.EVENT_AD_THIRD_QUARTILE:zU(this,_.uc,a);break;case tv.freewheel.SDK.EVENT_AD_COMPLETE:zU(this,_.fc,a);break;case tv.freewheel.SDK.EVENT_AD_CLICK:zU(this,_.ec,a);break;case tv.freewheel.SDK.EVENT_AD_PAUSE:zU(this,_.nc,a);break;case tv.freewheel.SDK.EVENT_AD_RESUME:zU(this,
17
+ _.pc,a);break;case tv.freewheel.SDK.EVENT_AD_SKIPPED:zU(this,_.rc,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_START:zU(this,_.dc,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_END:zU(this,_.oc,a);break;case tv.freewheel.SDK.EVENT_ERROR:this.m.onError(new _.H(1,9,10003,{errorType:1},{fwCode:a[tv.freewheel.SDK.INFO_KEY_ERROR_CODE],fwInfo:a[tv.freewheel.SDK.INFO_KEY_ERROR_INFO],fwModule:a[tv.freewheel.SDK.INFO_KEY_ERROR_MODULE]}))}}I(){if(!this.f){var a=this.m.getPosition();if(this.f=this.B.find(b=>
18
+ .5>Math.abs(a-b.getTimePosition()))||null){const b=this.B.findIndex(c=>c===this.f);this.B.splice(b,1);this.m.pause();vU(this);this.f.play()}}}H(a){if((a=a.detail)&&this.a)switch(a.currentState){case _.Oo:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PLAYING);break;case _.No:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PAUSED);break;case _.Do:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_COMPLETED);yU(this);break;case _.Lo:case _.Eo:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_STOPPED)}}};
19
+ CU.prototype.getPosition=CU.prototype.getPosition;CU.prototype.setVolume=CU.prototype.setVolume;CU.prototype.getVolume=CU.prototype.getVolume;CU.prototype.skip=CU.prototype.skip;CU.prototype.pause=CU.prototype.pause;CU.prototype.resume=CU.prototype.resume;_.fp(new class{constructor(){this.f=new _.S(pU)}name(){return pU}a(a,b){return a.namespace()!==_.kd&&b&&b.freewheel?window.tv&&tv.freewheel&&tv.freewheel.SDK?!0:(this.f.warn("FreeWheel SDK is not loaded."),!1):!1}create(a){return new CU(a)}});};f.call(g, window);
package/cl.hls.js CHANGED
@@ -1,74 +1,74 @@
1
- import {clpp} from "./cl.core.js";import './cl.mse.js';let g={};const _ = clpp._;var f=function(window){'use strict';var iJ="CLOSED-CAPTIONS",jJ="Could not parse MP4 segment start time.",kJ="DURATION",lJ="EXT-X-STREAM-INF",mJ="Failed to infer discontinuity number",nJ="Guessing audio-only",oJ="METHOD",pJ="SAMPLE-AES-CTR",qJ="SUBTITLES",rJ="Two EXT-X-KEY tags, one with METHOD\x3dAES-128 are applied to one ",sJ="application/vnd.apple.mpegurl",tJ="sample",uJ="whole-segment",vJ=function(a,b){return _.J(a,b,void 0,{required:!0})},wJ=function(a){if(1>a.a)throw _.Yl();--a.a},xJ=function(a,b){for(const c in a){if(!(c in
2
- b))return!1;const d=a[c],e=b[c];if(d&&typeof d===_.Ge&&e&&typeof e===_.Ge){if(!xJ(d,e))return!1}else if(void 0!==d&&void 0!==e&&d!==e)return!1}return!0},yJ=function(a,b){if(!xJ(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===_.Ge&&e&&typeof e===_.Ge&&yJ(d,e))return!0}return!1},zJ=function(a){if(null!==a&&void 0!==a)return Number(a)},AJ=function*(a){let b=-1,c=void 0,d=void 0;for(const e of a)0<=b&&(yield{Jf:b,item:d,Ah:c,next:e}),b++,c=d,d=e;-1!==
3
- b&&(yield{Jf:b,Ah:c,item:d,next:void 0})},BJ=function(a,b){return a.filter(c=>c.name===b)},CJ=function(a){const b=/^[a-zA-Z0-9_-]+$/,c=new Set;a.forEach(d=>{const e=_.J(d,"VALUE"),f=_.J(d,"NAME"),g=_.J(d,"IMPORT"),h=_.J(d,"QUERYPARAM");if(1!==[f,g,h].filter(Boolean).length||f&&null==e)throw new _.I(_.F,4,4044,{message:"Invalid tag.",text:d.toString()});d=f||g||h;if(c.has(d))throw new _.I(_.F,4,4044,`EXT-X-DEFINE redefined variable "${d}".`);if(!b.test(d))throw new _.I(_.F,4,4044,`EXT-X-DEFINE invalid variable name "${d}".`);
4
- c.add(d)})},DJ=function(a,b){const c=Array.isArray(b)?b:[b];return a.filter(d=>{d=vJ(d,_.Kb);return c.includes(d)})},EJ=function(a,b){return a.some(c=>c.name===b)},FJ=function(a,b,c){c=void 0===c?{}:c;a=a.find(d=>d.name===b)||null;if(!a&&c.required)throw new _.I(_.F,4,4024,{missingTag:b});return a},GJ=function(a){var b=FJ(a,"EXT-X-TILES");if(!b)return{Yc:1,qd:1,durationPerTile:null};a=_.J(b,"LAYOUT")||"1x1";b=_.J(b,kJ);a=_.sC(a);return{Yc:a.Yc,qd:a.qd,durationPerTile:b?Number(b):null}},HJ=function(a,
5
- b,c){c=void 0===c?!0:c;a=new _.hi(a);b=new _.hi(b);b=a.resolve(b).toString();return c?b:decodeURI(b)},IJ=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)},JJ=function(a,b){Array.isArray(a)||(a=[a]);a.forEach(c=>{for(const d of IJ(c))b(d,c)})},KJ=function(a){return a.some(b=>EJ(b.aa,_.Ea))},LJ=function(a){return a.type===_.p||a.type===_.w},MJ=function(a){if(FJ(a,
6
- _.Ea))return _.Tb;a=FJ(a,_.Ja);if(!a)return"LIVE";if(a.value===_.Tb)return _.Tb;if("EVENT"===a.value)return"EVENT";throw new _.I(_.F,4,4044,`Invalid EXT-X-PLAYLIST-TYPE value: ${a.value}`);},NJ=function(a){a={AUDIO:_.p,VIDEO:_.w,SUBTITLES:_.G,"CLOSED-CAPTIONS":_.G}[a.toUpperCase()];if(!a)throw new _.I(_.F,4,4044,"EXT-X-MEDIA tag has an invalid TYPE attribute.");return a},OJ=function(a,b,c){c=void 0===c?!1:c;var d=0;let e=null;if(a){d=a.split("@");a=Number(d[0]);if(0>=a)throw new _.I(_.F,4,4044,"Byte range length must be positive.");
7
- if(d[1]){if(d=Number(d[1]),0>d)throw new _.I(_.F,4,4044,"Byte range start byte must not be negative.");}else{if(c)throw new _.I(_.F,4,4044,"Invalid byte range, offset is required but missing.");if(null==b)throw new _.I(_.F,4,4044,"Invalid byte range, cannot calculate offset based on previous byte ranges.");d=b+1}e=d+a-1}return{za:d,na:e}},PJ=function(a,b){a=FJ(a,_.za);return OJ(a?a.value:null,b)},QJ=function(a){a=FJ(a,"EXTINF",{required:!0}).value.split(",");return{duration:Number(a[0]),title:a[1]||
8
- null}},RJ=function(a,b){b=void 0===b?{}:b;const c={nf:!1,Eg:!1,Fg:null,hh:null,Xf:null};a=FJ(a,_.Ma,{required:b.cg});if(!a)return c;const d=e=>null==e?null:Number(e);c.nf="YES"===_.J(a,"CAN-BLOCK-RELOAD");c.Eg="YES"===_.J(a,"CAN-SKIP-DATERANGES");c.Fg=d(_.J(a,"CAN-SKIP-UNTIL"));c.hh=d(_.J(a,"HOLD-BACK"));c.Xf=d(_.J(a,"PART-HOLD-BACK",void 0,{required:b.cg}));return c},SJ=function(a,b,c){c=void 0===c?!1:c;a=_.J(a,"BYTERANGE");return OJ(a,b,c)},UJ=function(a,b){const c=PJ(a.aa,null);return new TJ(0,
9
- 0,0,()=>[a.a],c.za,c.na,0,b)},VJ=function(a,b){if(null==a)return null;a=Object.assign({},a);null==a.iv&&(a.iv=_.ej(new Uint8Array(12),new Uint8Array([b>>24&255,b>>16&255,b>>8&255,b&255])));return a},WJ=function(a){let b=Infinity,c=Infinity;IJ(a).filter(LJ).forEach(d=>{{d=d.U;var e=d[0].startTime;const f=d[d.length-1].endTime;d=e;e=f-e}b=Math.min(b,d);c=Math.min(c,e)});return{Ic:b,duration:c}},XJ=function(a){return a.map(b=>{({duration:b}=WJ(b));return b}).reduce((b,c)=>b+c,0)},YJ=function(a){return(a.video?
10
- a.video.Fa:"")+" - "+(a.audio?a.audio.Fa:"")},ZJ=function(a,b,c,d){if(b===_.Tb)return{delay:0,pd:0};b=FJ(a,_.Ia);if(c&&b){c=Number(vJ(b,"PART-TARGET"));if(null!=d)return{delay:d,pd:c};({Xf:d}=RJ(a,{cg:!0}));return{delay:d,pd:c}}a=FJ(a,_.Oa,{required:!0});a=Number(a.value);return null!=d?{delay:d,pd:a}:{delay:3*a,pd:a}},aK=function(a){const b=new Map;a.forEach(c=>{var d=`${$J(c).type}:${$J(c).groupId}`;b.has(d)?(d=b.get(d),d.includes(c)||d.push(c)):b.set(d,[c])});return b},bK=function(a){const b=new Map;
11
- for(const c of a){a=_.J(c,_.ab);a=_.xi(a||_.cg);const d=vJ(c,_.Ua),e=vJ(c,"INSTREAM-ID");b.has(d)||b.set(d,new Map);b.get(d).set(e,a)}return b},dK=function(a){a=a.audio.concat(a.video);for(const b of a)a=$J(b).codecs.split(",").filter(c=>"mp4a.40.34"!==c),cK(b,a)},eK=function(a,b){if(!a)return null;const c=a.Fa;return b.find(d=>$J(d).Fa===c)||null},fK=function(a){for(const b of a)if(b.startsWith("#EXT-")&&(a=_.jj(0,b),_.Jt.has(a.name)))return 1;return 0},gK=function(a,b){return a.replace(/\{\$([a-zA-Z0-9_-]+)\}/g,
12
- (c,d)=>{c=b.get(d);if(null==c)throw new _.I(_.F,4,4044,`Undefined variable '${d}'`);return c})},hK=function(a,b){a.forEach(c=>{c.attributes.forEach(d=>{d.value=gK(d.value,b)})})},iK=function(a,b,c){hK(a,c);b.forEach(d=>{d.a&&(d.a=gK(d.a,c));hK(d.aa,c);hK(d.f,c)})},jK=function(a,b){const c=new Map,d=new URL(b);a.forEach(e=>{var f=_.J(e,"NAME"),g=_.J(e,"QUERYPARAM");if(f)g=vJ(e,"VALUE"),c.set(f,g);else if(g){f=d.searchParams.get(g);if(null==f)throw new _.I(_.F,4,4044,`Query param '${g}' missing in playlist URI.`);
13
- if(!f)throw new _.I(_.F,4,4044,`Query param '${g}' has no associated value`+" in playlist URI.");c.set(g,decodeURIComponent(f))}});return c},mK=function(a,b,c){const d=[];for(let e=1;e<b.length;e++){const f=kK(a,b[e]);d.push(f);if(f.name===lJ){const g=b[e+1];if(!g)throw new _.I(_.F,4,4044,"EXT-X-STREAM-INF is not followed by a URI.");f.attributes.push(new _.hj(_.Mb,g));e++}}b=BJ(d,"EXT-X-DEFINE");CJ(b);b=jK(b,c);a.a=b;iK(d,[],a.a);return new lK(c,0,d)},pK=function(a,b,c){let d=[];for(var e=1;e<b.length;){const f=
14
- kK(a,b[e]);if(_.Kt.has(f.name))break;d.push(f);e++}b=nK(a,c,b.slice(e));e=b.U;d=d.concat(b.aa);a=oK(a,d,c);iK(d,e,a);return new lK(c,1,d,b.U)},qK=function(a,b,c){b=b.trim().split(/\n+/m).map(d=>d.trim()).filter(d=>d.length&&!/^#(?!EXT)/m.test(d));if(!/^#EXTM3U($|[ \t\n])/m.test(b[0]))throw new _.I(_.F,4,4015);return 0===fK(b)?mK(a,b,c):pK(a,b,c)},kK=function(a,b){return _.jj(a.f++,b)},nK=function(a,b,c){const d=[],e=[];let f=[],g=[];c.forEach(h=>{/^(#EXT)/.test(h)?(h=kK(a,h),_.Jt.has(h.name)||_.Mt.has(h.name)?
15
- d.push(h):_.Lt.has(h.name)?"EXT-X-PART"===h.name?g.push(h):h.name===_.Ka&&"PART"===_.J(h,_.Kb)&&g.push(h):f.push(h)):/^#(?!EXT)/m.test(h)||(h=HJ(b,h.trim(),!1),e.push(new rK(h,f,g)),f=[],g=[])});0<g.length&&e.push(new rK(null,f,g));return{U:e,aa:d}},oK=function(a,b,c){b=BJ(b,"EXT-X-DEFINE");CJ(b);const d=jK(b,c);b.map(e=>_.J(e,"IMPORT")).filter(Boolean).forEach(e=>{const f=a.a.get(e);if(null==f)throw new _.I(_.F,4,4044,`Cannot import variable '${e}' as it is not defined `+"in the master playlist");
16
- d.set(e,f)});return d},sK=function(a){return 0>a?[]:Array.from({length:a},(b,c)=>c)},tK=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},uK=function(a){function b(h,k,l){let m="";for(;k<l;k++)m+="%"+("00"+h[k].toString(16)).slice(-2);return m}function c(h){return h[0]<<21|h[1]<<14|h[2]<<7|h[3]}function d(){throw new _.I(_.F,4,4030);}tK(a)||d();let e=10;a[5]&64&&(e=e+4+c(a.subarray(10,14)));do{var f=
17
- c(a.subarray(e+4,e+8));1>f&&d();var g=String.fromCharCode(a[e],a[e+1],a[e+2],a[e+3]);if("PRIV"===g){g=a.subarray(e+10,e+f+10);for(let h=0;h<g.byteLength;h++)if(0===g[h]){if("com.apple.streaming.transportStreamTimestamp"===unescape(b(g,0,h)))return a=g.subarray(h+1),f=(a[3]&1)<<30|a[4]<<22|a[5]<<14|a[6]<<6|a[7]>>>2,f*=4,f+=a[7]&3,Math.round(f/9E4);break}}tK(a,e)||d();e+=10;e+=f}while(e<a.byteLength);return d()},vK=function(a,b){let c=null,d=0;try{(new _.nm).N(_.Ce,_.gm).N(_.$f,_.gm).N(_.xe,_.gm).da("mdhd",
18
- g=>{g.reader.skip(0===g.version?8:16);d=_.P(g.reader);g.parser.stop()}).parse(b,!0)}catch(g){c=g}if(c||!d)throw _.cv.error("Unable to find timescale in init segment!"),new _.I(_.F,4,4030,jJ,c);let e=0,f=!1;try{(new _.nm).N("moof",_.gm).N("traf",_.gm).da("tfdt",g=>{var h=d;if(0===g.version)h=_.P(g.reader)/h;else{{const k=_.P(g.reader),l=_.P(g.reader);if(!(2097151>=k||h>=Math.pow(2,12)))throw Error("Cannot accurately parse MP4 timestamp, base time is too high and timescale is \x3c\x3d 2^12");h=k/h*
19
- Math.pow(2,32)+l/h}}e=h;f=!0;g.parser.stop()}).parse(a,!0)}catch(g){c=g}if(c||!f)throw new _.I(_.F,4,4030,jJ,c);return e},wK=function(a){for(;a.getPosition()<a.Pa()-1;){const b=a.getPosition();if(71===_.Zl(a))return wJ(a),b}return-1},xK=function(a){function b(){d.seek(e+188);f=_.Zl(d);71!==f&&(d.seek(e+192),f=_.Zl(d));71!==f&&(d.seek(e+204),f=_.Zl(d));71!==f&&c();wJ(d)}function c(){throw new _.I(_.F,4,4030);}const d=new _.$m(new DataView(a),!1);let e=0,f=0;e=wK(d);0>e&&(_.cv.error("Unable to find sync byte in TS after scanning."),
20
- c());for(;;){e=d.getPosition();f=_.Zl(d);71!==f&&c();a=_.$l(d);if(8191===(a&8191)){b();continue}if(!(a&16384)){b();continue}a=(_.Zl(d)&48)>>4;0!==a&&2!==a||c();3===a&&(a=_.Zl(d),d.skip(a));if(1!==_.P(d)>>8){b();continue}d.skip(3);a=_.Zl(d)>>6;0!==a&&1!==a||c();0===_.Zl(d)&&c();a=_.Zl(d);const g=_.$l(d),h=_.$l(d);return(1073741824*((a&14)>>1)+((g&65534)<<14|(h&65534)>>1))/9E4}},AK=function(a){const b=yK(a),c=zK(a);a.forEach(d=>{const e=d.U,f=e.findIndex(h=>h.ma===b);let g=e.findIndex(h=>h.ma===c+1);
21
- -1===g&&(g=e.length);d.U=e.slice(f,g)})},zK=function(a){a=a.map(b=>b.U[b.U.length-1].ma);return Math.min(...a)},yK=function(a){a=a.map(b=>b.U[0].ma);return Math.max(...a)},DK=function(a){var b=vJ(a,oJ);if(!BK.includes(b))return CK.error("PlayReady in HLS is only supported with [",BK.join(", "),"], not",b),null;a=vJ(a,_.Mb);b=_.Us(a);a=null;b=_.K(b.data);try{a=_.bC(_.gn(b))}catch(c){a=b}return _.oC(_.xd,[{initDataType:_.cd,initData:a}],"")},FK=function(a){if(0===a.length)return EK();if(a.some(c=>c.type===
22
- uJ)||a.every(c=>c.type===_.Fe))return a[0];a=a.filter(c=>c.type===tJ);const b=_.Zh(a.flatMap(c=>c.drmInfos));return{keyInfo:null,keyId:a[a.length-1].keyId,type:tJ,drmInfos:b}},IK=function(a){a=GK(a);if(a.some(b=>HK(b))&&1<a.length)throw new _.I(_.F,4,4046,"Two EXT-X-KEY tags, one with METHOD\x3dAES-128 are applied to one playlist.");},HK=function(a){return BJ(a.aa,_.Fa).some(b=>"AES-128"===_.J(b,oJ))},KK=function(a,b,c){return GK(a).map(d=>JK(d.aa,b,c))},LK=function(a){return a.filter(b=>EJ(b.aa,
23
- _.Fa)).length},GK=function(a){return a.filter(b=>EJ(b.aa,_.Fa))},JK=function(a,b,c){a=BJ(a,_.Fa);if(0===a.length)return null;var d=vJ(a[0],oJ);if(1===a.length){if("NONE"===d)return EK();if("AES-128"===d)return a=a[0],d=_.J(a,"IV",""),{type:uJ,keyInfo:{method:"AES-128",url:HJ(b,vJ(a,_.Mb)),iv:d?_.bj((d||"0x").slice(2)):null},drmInfos:[],keyId:null}}b=a.map(e=>vJ(e,oJ));if(!b.every(e=>"SAMPLE-AES"===e)&&!b.every(e=>e===pJ))throw MK.warn(`EXT-X-KEY methods ${b.join(", ")} are incompatible.`),new _.I(_.F,
24
- 4,4044,"Multiple EXT-X-KEY tags with incompatible METHOD values.");b=a.map(e=>{const f=_.J(e,"KEYFORMAT","identity");{const g=NK[f]||null;e=g?g(e,c):null}e||MK.warn("Unsupported HLS KEYFORMAT",f);return e}).filter(Boolean);if(0===b.length)throw new _.I(_.F,4,4026);return{keyInfo:null,keyId:b.map(e=>e.keyIds).reduce((e,f)=>e.concat(f),[]).reverse()[0]||null,type:tJ,drmInfos:b}},EK=function(){return{type:_.Fe,keyInfo:null,drmInfos:[],keyId:null}},OK=function(a,b,c){return _.x(function*(){const d=b.f(),
25
- e=_.RC(b.$a(),b.za,b.za+2048-1,a.a.attemptParameters);e.type=2;const f=_.RC(b.$a(),b.za,b.na,a.a.attemptParameters);f.type=2;d&&(f.keyInfo=d);try{return yield a.f(c?f:e)}catch(g){if(7001===g.code||c)throw g;a.g.warn("Unable to fetch a partial HLS segment! Falling back to a full segment request, which is expensive! Your server should support Range requests and CORS pre-flights.",e.uris[0]);try{return yield a.f(f)}catch(h){throw a.g.error("Failed to fetch media segment to parse its start timestamp.",
26
- f.uris[0],h),new _.I(_.F,4,4030,"Failed to fetch the media segment.");}}})},PK=function(a,b,c,d,e,f){return _.x(function*(){a.g.debug("Fetching segment to find start time");if("audio/mpeg"===d||d===_.Lc||d===_.Kc)return 0;if(d===_.Jc){var g=yield OK(a,c,f);const h=_.K(g.data);return tK(h)?uK(h):xK(g.data)}if(d===_.rg||d===_.Mc)return g=[OK(a,c,f)],b&&g.push(OK(a,b,!0)),g=yield Promise.all(g),vK(g[0].data,(g[1]||g[0]).data);if(d===_.ng)return g=yield OK(a,c,f),xK(g.data);if(!_.Tr(`${d.split("/")[0]||
27
- ""}/mp4;codecs="${e}"`))return 0;throw new _.I(_.F,4,4030);})},QK=function(a,b){a=a.map(c=>c.streams[b]);return a.some(c=>null==c)?null:a},cK=function(a,b){a.streams.forEach(c=>{c.codecs=b.join(",")})},RK=function(a,b){a=a.streams.find(c=>{c=c.U;return c[0].position<=b&&b<=c[c.length-1].position});return null==a?null:a.U.find(c=>c.position===b)||null},$J=function(a){return a.streams[0]},SK=function(a,b){a.streams.forEach(c=>{c.Wd=b})},TK=function(a,b){a.streams.forEach(c=>{c.width=b})},UK=function(a,
28
- b){a.streams.forEach(c=>{c.height=b})},VK=function(a,b){a.streams.forEach(c=>{c.frameRate=b})},WK=function(a,b){a.streams.forEach(c=>{c.bandwidth=b})},XK=function(a,b){a=a.map(c=>c.a[b]);return a.some(c=>null==c)?null:a},YK=function(a,b){const c=new Set(a.map(d=>d.ma));return b.filter(d=>!c.has(d.ma))},$K=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||ZK(c,d);const e=a.length-1;c=a[e];d=b[e];0<e&&(c.startTime!==d.startTime||
29
- c.endTime!==d.endTime)&&ZK(c,d);for(c=e+1;c<b.length;)a.push(b[c]),c++},eL=function(a,b,c,d,e){var f=b[0].length();f=sK(f).map(g=>{var h=XK(b,g)||[];const k=QK(c,g)||[];g=QK(d,g)||[];{const l=[...aL(h),...k,...g].filter(Boolean);bL(l);const {ma:m,duration:n}=l[0];h={configurationId:a,variants:h,textStreams:k,thumbStreams:g,startTime:0,id:`P${m}`,endTime:n,duration:n,ma:m}}return h});e&&cL(f[0]);dL(f);return f},aL=function(a){a=new Set(a.flatMap(b=>[b.video,b.audio]).filter(Boolean));return Array.from(a)},
30
- cL=function(a){const b=aL(a.variants)[0].U[0].Ea;a.startTime+=b;a.endTime+=b},dL=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}},ZK=function(a,b){a.startTime=b.startTime;a.endTime=b.endTime;a.duration=b.duration;fL(a.variants,b.variants);gL(IJ(a),IJ(b))},fL=function(a,b){const c=new Map(a.map(d=>[YJ(d),d]));b.forEach(d=>{c.get(YJ(d)).drmInfos=d.drmInfos})},gL=function(a,b){const c=new Map(a.map(d=>[d.Fa,d]));b.forEach(d=>
31
- {const e=c.get(d.Fa);e.U=d.U;e.segmentIndex.replace(d.U);e.Ic=d.Ic;e.oe=d.oe;e.duration=d.duration;e.wf=d.wf;e.encrypted=d.encrypted;e.drmInfos=d.drmInfos;e.keyId=d.keyId})},bL=function(a){const b=hL(a);a.forEach(c=>{_.NC(c.segmentIndex,b);c.duration=b;c.oe=c.Ic+b})},hL=function(a){let b=Infinity;a.filter(LJ).forEach(c=>{b=Math.min(b,c.duration)});return b},iL=function(a,b){JJ(b,(c,d)=>{_.$C(a,c.U,d.startTime)});_.SC(a.a,b[0].startTime,b[b.length-1].endTime)},jL=function(a){return null===a.j?[]:[a.j.audio,
32
- a.j.video].filter(b=>b).map(b=>b.Fa)},kL=function(a,b){return _.x(function*(){var c=_.pj([b],a.a.attemptParameters);c.type=1;c=yield a.G(c);let d="";try{d=_.Li(c.data)}catch(e){throw new _.I(_.F,4,4042);}d=d.replace(/\r\n|\r(?=[^\n]|$)/gm,"\n");d=d.trim();return{text:d,response:c}})},qL=function(a,b){return _.x(function*(){var c=lL(a,b,a.w,"");if(1===c.type){c=_.Ft(c.U[0].a)||"";c=null!=_.Et.video[c]?_.w:null!=_.Et.audio[c]?_.p:null;var d="";c===_.w?d="avc1.42E01E":c===_.p&&(d="mp4a.40.2");{c=a.M;
33
- var e=a.w;d=a.a.hlsDefaultCodecs||d;var f=[];const q=[];q.push(new _.hj(_.ka,"0"));q.push(new _.hj(_.Mb,e));d.length&&q.push(new _.hj(_.na,d));f.push(new _.ij(c.f++,lJ,q));c=new lK(e,0,f)}}d=c.aa;c=BJ(d,"EXT-X-MEDIA");e=BJ(d,lJ);d=BJ(d,"EXT-X-IMAGE-STREAM-INF");c={Hc:{zg:DJ(c,["AUDIO",_.Sb]),closedCaptions:DJ(c,iJ),Th:DJ(c,qJ)},sd:e,ke:d};const {oh:g,periods:h,Ch:k,Vh:l}=yield mL(a,c);if(!a.D)throw new _.I(_.F,7,7001);nL(a,h);c=!0;e=null;d=0;oL(a)||(c=!1,e=0,d=g.delay);f=a.a.timeline||{};f.type=void 0;
34
- e=new _.VI(f,e,d,!0,void 0,!!a.a.lowLatencyMode);_.WC(e,c);iL(e,h);k&&_.VC(e,k);c=e;if(!oL(a)){a.F=g.pd;e=0;for(var m of a.f.values())e=Math.max(e,m.streams[0].Ic);for(m=0;95443.7176888889<=e;)m+=95443.7176888889,e-=95443.7176888889;if(m){a.g.debug("Offsetting live streams by",m,"to compensate for rollover");for(var n of a.f.values())e=n.streams[0],95443.7176888889>e.Ic?(a.g.debug("Offset applied to",e.type),e.segmentIndex.offset(m)):a.g.debug("Offset NOT applied to",e.type)}}n=XJ(h);"LIVE"===a.l||
35
- "EVENT"===a.l?(n=Math.max(n,c.J),isNaN(a.a.availabilityWindowOverride)||(n=a.a.availabilityWindowOverride),c.A=n):a.l===_.Tb&&(c.f=n);n=pL(a,l);n={presentationTimeline:c,periods:h,minBufferTime:0,cues:n};a.g.debug("HLS playlist parsed",n);return n})},sL=function(a,b){return Promise.all(b.map(c=>rL(a,c)))},uL=function(a,b){b.forEach(c=>{a:{var d=a.f.get(c.a),e=!oL(a),f=FJ(c.aa,_.Da);if(f)var g=Number(f.value);else{d?(f=d.streams[d.streams.length-1].U,f=f[f.length-1].ma):f=0;if(e&&0<f)try{{const k=
36
- FJ(c.aa,_.Ha);if(!k)throw tL.error("Failed to infer discontinuity number, because EXT-X-MEDIA-SEQUENCE tag is missing."),Error(mJ);const l=Number(k.value),m=RK(d,l);if(!m)throw tL.error("Failed to infer discontinuity number, could not find the appropriate segment in the previous playlist"+` (segment position = ${l})`),Error(mJ);var h=m.ma}g=h;break a}catch(k){throw new _.I(_.F,4,4024,"EXT-X-DISCONTINUITY-SEQUENCE tag is required for discontinuous HLS live streams.");}g=0}}c=c.U||[];for(const k of c)EJ(k.aa,
37
- _.Ca)&&g++,k.ma=g});AK(b)},xL=function(a,b){return _.x(function*(){const {textStreams:c,thumbStreams:d,Ag:e}=yield vL(a,b);var f=a.B.periods[0].variants;a.a.lowLatencyMode&&null!==a.j&&(f=f.filter(g=>g.id===a.j.id));f=f.map(g=>{const h=eK(g.audio,e),k=eK(g.video,e);g=wL(a,h,k,g.bandwidth);if(!g)throw new _.I(_.F,4,4047,{message:"Video and audio are encrypted in an incompatible way.",Ci:k?$J(k).Fa:void 0,audio:h?$J(h).Fa:void 0});return g});return eL(a.D.configurationId,f,c,d,!0)})},nL=function(a,
38
- b){oL(a)||2!==a.a.timeline.version||(a.H||(a.H=b[0].startTime),_.jE(b,-a.H))},yL=function(a,b){b=b.flatMap(d=>d.U[0].aa);b=FJ(b,_.La);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},zL=function(a,b,c){b=b.find(d=>null!==FJ(d.aa,_.Ba));if(!b)return[];if(null===c)throw new _.I(_.F,4,4024,"EXT-X-PROGRAM-DATE-TIME tag is required when EXT-X-DATERANGE tags are present");return b.aa.filter(d=>
39
- d.name===_.Ba).map(d=>{a:{var e=a.A,f=!oL(a),g=_.J(d,"ID"),h=_.J(d,"START-DATE");if(null===g||null===h)_.It.warn("Invalid EXT-X-DATERANGE missing mandatory ID or START-DATE attribute, ignoring the EXT-X-DATERANGE tag.",d),d=null;else{e=f?e-c:-c;var k=new Date(h);h=k.getTime()/1E3+e;g={id:g,startTime:h,startDate:k};f=zJ(_.J(d,kJ));void 0!==f&&0<=f&&(g.duration=f);var l=zJ(_.J(d,"PLANNED-DURATION"));void 0!==l&&0<=l&&(g.plannedDuration=l);var m=_.J(d,"CLASS");null!==m&&(g.schemeIdUri=m);var n=_.J(d,
40
- "END-DATE");n=n?new Date(n):null;null!==n&&n.getTime()>=k.getTime()&&(g.endDate=n);{const v=d.attributes;if(null==v)var q=null;else{k={};for(q of v)q.name.trim().startsWith("X-")&&(k[q.name]=q.value);q=_.Wg(k)?k:null}}q=q||{};(k=_.J(d,"CUE"))&&(q.CUE=k.split(","));if(m===_.vd){k=d.attributes;if(null==k)var u=null;else{m={};for(u of k)switch(u.name){case _.$b:m[_.$b]=u.value;break;case _.Zb:m[_.Zb]=u.value;break;case _.bc:m[_.bc]=zJ(u.value);break;case _.ac:m[_.ac]=zJ(u.value);break;case "X-SNAP":m["X-SNAP"]=
41
- u.value.split(",");break;case "X-RESTRICT":m["X-RESTRICT"]=u.value.split(",")}m[_.$b]&&m[_.Zb]||!m[_.$b]&&!m[_.Zb]?(_.It.warn("Invalid EXT-X-DATERANGE Interstitial attributes X-ASSET-URI, X-ASSET-LIST"),u=null):u=_.Wg(m)?m:null}if(null===u){_.It.warn("Invalid interstitial attributes, ignoring the EXT-X-DATERANGE tag.",d);d=null;break a}q=Object.assign(q,u)}_.Wg(q)&&(g.customAttributes=q);g.endTime=n?n.getTime()/1E3+e:f?h+f:l?h+l:h;g.type=_.Hh;d=g}}return d}).filter(Boolean)},pL=function(a,b){const c=
42
- new Set(b.map(d=>d.id));a.o.forEach((d,e)=>{c.has(e)||a.o.delete(e)});for(const d of b){if((b=a.o.get(d.id))&&b.startTime!==d.startTime)a.D.onError(new _.I(1,4,4044,"EXT-X-DATERANGE START-DATE has changed for"+` ID=${d.id}`));const e={configurationId:a.D.configurationId,schemeIdUri:d.schemeIdUri,customAttributes:d.customAttributes,value:"",startTime:d.startTime,endTime:d.endTime,id:d.id,type:_.Hh,eventElement:null};b&&!yJ(b,e)||a.o.set(d.id,e)}return Array.from(a.o.values())},AL=function(a,b,c){a.l=
43
- _.Tb;_.WC(b,!0);b.f=c[c.length-1].endTime},lL=function(a,b,c,d){a=qK(a.M,b,c);a.a=d;return a},mL=function(a,b){return _.x(function*(){var c=bK(b.Hc.closedCaptions),d=BL(a,b.sd),e=yield CL(a,b),f=Object.values(e).flat().map(h=>h.playlist);uL(a,f);f=f[0];var g=MJ(f.aa);a.l=g;a.I=RJ(f.aa);f=ZJ(f.aa,g,a.a.lowLatencyMode||!1,a.a.suggestedPresentationDelay);g=yield DL(a,e.hf,d);c=yield EL(a,e.sd,g,c);d=yield FL(a,e.Sh,d);g=yield GL(a,e.ke);d=eL(a.D.configurationId,c,d,g,!oL(a));a.D.filterAllPeriods(d);
44
- c=[...e.sd,...e.hf].map(h=>h.playlist);e=yL(a,c);c=zL(a,c,e);return{periods:d,Ch:e,Vh:c,oh:f}})},vL=function(a,b){return _.x(function*(){const c=g=>$J(g.stream).type===_.w||$J(g.stream).type===_.p;var d=b.filter(c),e=b.filter(g=>!c(g)),f=g=>{g=g.map(h=>{var k=$J(h.stream);k={language:k.language,channelsCount:k.channelsCount,spatialAudio:k.spatialAudio,closedCaptions:k.closedCaptions,primary:k.primary,kind:k.kind||null,groupId:k.groupId,type:k.type,codecs:k.codecs,name:k.originalId,uri:k.Fa,Ud:{width:k.width,
45
- height:k.height,frameRate:k.frameRate}};h=Object.assign({},{playlist:h.playlist},k);return HL(a,h)});return Promise.all(g)};d=yield f(d);f=yield f(e);IL(a,d.concat(f));e=f.filter(g=>$J(g).type===_.VB);f=f.filter(g=>$J(g).type===_.ee);return{textStreams:e,thumbStreams:f,Ag:d}})},wL=function(a,b,c,d){const e=[],f=(c||b).length();for(let m=0;m<f;m++){var g=b?b.streams[m]||null:null,h=c?c.streams[m]||null:null,k=g,l=h;k=k&&l?_.vC(k.drmInfos,l.drmInfos)?_.uC(k.drmInfos,l.drmInfos):null:k?k.drmInfos:l?
46
- l.drmInfos:null;if(!k)return null;l=d;g={id:a.R++,language:g?g.language:_.cg,primary:!!g&&g.primary||!!h&&h.primary,audio:g,video:h,bandwidth:l,drmInfos:k,allowedByApplication:!0,allowedByKeySystem:!0};e.push(g)}return new JL(e)},HL=function(a,b){return _.x(function*(){const c=b.playlist,d=b.codecs,e=b.type,f=b.ed,g=b.groupId,h=b.primary;var k=b.kind;const l=b.name,m=b.channelsCount,n=b.spatialAudio,q=b.closedCaptions,u=b.Ud,v=_.xi(f||_.cg);if(1!==c.type)throw new _.I(_.F,4,4017);const y=yield KL(a,
47
- c,e,d),A=a.a.lowLatencyMode?_.KB:_.JB;let D=k;e!==_.G||k||(D=_.VB);k=y.map(H=>{const X=H.U,wb=H.Lg,oe=H.mimeType;H=H.ma;const lf=X[0].startTime,mf=X[X.length-1].endTime,$a=mf-lf,Db=new _.WI(X),Tc=X[0].initSegment||null;return{id:_.SI++,originalId:l,createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:Db.f.bind(Db),getSegmentReference:Db.get.bind(Db),adjustSegmentDurations:Db.h.bind(Db),getDuration:Db.getDuration.bind(Db),segmentIndex:Db,segmentLookupStrategy:A,initSegmentReference:Tc,
48
- mimeType:oe,codecs:d,kind:D,wf:wb.type,encrypted:wb.type===tJ,keyId:wb.keyId,language:v,originalLanguage:f||_.cg,label:l,type:e,primary:h,trickModeVideo:null,emsgSchemeIdUris:null,frameRate:u?u.frameRate:void 0,width:u?u.width:void 0,height:u?u.height:void 0,bandwidth:void 0,roles:[],channelsCount:m,spatialAudio:n,closedCaptions:q,keyInfo:wb.keyInfo,U:X,drmInfos:wb.drmInfos,ma:H,Fa:c.a,Wd:c.f,Ic:lf,oe:mf,duration:$a,groupId:g}});return new LL(k)})},IL=function(a,b){b.forEach(c=>{a.f.a.set($J(c).Fa,
49
- c)})},BL=function(a,b){const c=new Map;for(const f of b){var d=_.J(f,"AUDIO");b=_.J(f,_.Sb);var e=_.J(f,qJ);const g=ML(a,f);if(e){const h=_.bk(_.G,g);c.set(`${_.G}:${e}`,h);e=g.indexOf(h);-1<e&&g.splice(e,1)}d&&(e=NL(_.p,g),c.set(`${"audio"}:${d}`,e));b&&(d=NL(_.w,g),c.set(`${"video"}:${b}`,d))}return c},CL=function(a,b){return _.x(function*(){const c=yield Promise.all([OL(a,b.Hc.zg),OL(a,b.Hc.Th),OL(a,b.sd),OL(a,b.ke)]),[d,e,f,g]=c;return{hf:d,Sh:e,sd:f,ke:g}})},DL=function(a,b,c){return _.x(function*(){if(0===
50
- b.length)return new Map;var d=[PL(a,b[0],c)];yield d[0];d=d.concat(b.slice(1).map(e=>PL(a,e,c)));d=yield Promise.all(d);return aK(d)})},EL=function(a,b,c,d){return _.x(function*(){const e=new Set;var f=[...b];let g=0;var h=Infinity;for(let k=0;k<f.length;++k){const l=Number(vJ(f[k].tag,_.ka));l<h&&(h=l,g=k)}h=f.splice(g,1).pop();h=yield QL(a,h,c,d,e);f=f.map(k=>QL(a,k,c,d,e));f=yield Promise.all(f);f.splice(g,0,h);return f.reduce(_.lC,[])})},FL=function(a,b,c){return Promise.all(b.map(d=>PL(a,d,c)))},
51
- GL=function(a,b){return Promise.all(b.map(c=>RL(a,c)))},oL=function(a){return a.l===_.Tb},OL=function(a,b){return _.x(function*(){return(yield Promise.all(b.map(c=>_.x(function*(){const d=yield SL(a,c);return d?{tag:c,playlist:d}:null})))).filter(Boolean)})},rL=function(a,b){return _.x(function*(){var c=new _.hi($J(b).Wd);if(a.a.lowLatencyMode&&a.I&&a.I.nf){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={ph:d.position,vh:e&&0<e.length?f:null}}else d=
52
- null;if(e=d)d=e.ph,e=e.vh,f=_.Pj(c.a.toString()),f._HLS_msn=d.toString(),null===e&&f._HLS_part&&delete f._HLS_part,null!==e&&(f._HLS_part=e.toString()),d=_.Oj(f,!0),d=new _.pi(d),_.li(c,d)}const {response:g,text:h}=yield kL(a,c.toString());c=$J(b).Fa;d=$J(b).Wd;e=g.uri;d!==e&&(d=e,SK(b,d));c=lL(a,h,d,c);return{stream:b,playlist:c}})},ML=function(a,b){var c=_.J(b,_.na,a.a.hlsDefaultCodecs||"avc1.42E01E,mp4a.40.2").split(/\s*,\s*/);b=new Set;const d=[];for(const e of c)c=_.AC(e),b.has(c)?a.g.debug("Ignoring duplicate codec"):
53
- (d.push(e),b.add(c));return d},NL=function(a,b){if(1===b.length)return b[0];a=_.bk(a,b);if(null!=a)return a;throw new _.I(_.F,4,4025,{codecList:b});},PL=function(a,b,c){return _.x(function*(){const d=b.tag,e=b.playlist;return TL(a,e.a,()=>_.x(function*(){const f=vJ(d,_.Ua),g=NJ(vJ(d,_.Kb));var h=vJ(d,_.Kb).toUpperCase();if(NJ(h)!==_.G)h=null;else{var k=d.getAttribute("FORCED");k=!(!k||!k.value||"YES"!==k.value.toUpperCase());var l=_.VB;h===iJ&&(l=_.FB);k&&(l=_.Zd);h=l}k=c.get(`${g}:${f}`)||"";l=_.J(d,
54
- _.ab);const m=_.J(d,"NAME"),n=d.getAttribute("DEFAULT"),q=d.getAttribute("AUTOSELECT");var u=_.J(d,"CHANNELS");u=g===_.p?u?parseInt(u.split("/")[0],10):null:null;var v=g===_.p?(v=_.J(d,"CHANNELS"))?v.includes("/JOC"):!1:!1;return yield HL(a,{playlist:e,codecs:k,type:g,ed:l,primary:!!n&&!!q,name:m,channelsCount:u,spatialAudio:v,groupId:f,kind:h,closedCaptions:null,Ud:null})}))})},RL=function(a,b){return _.x(function*(){const c=b.tag,d=b.playlist;return TL(a,d.a,()=>_.x(function*(){var e=_.J(c,_.na)||
55
- "jpg",f=_.J(c,_.ab);const g=_.J(c,"NAME");e=yield HL(a,{playlist:d,codecs:e,type:_.ee,ed:f,name:g,primary:!1,kind:null,channelsCount:null,spatialAudio:!1,closedCaptions:null,groupId:null,Ud:null});(f=_.J(c,_.ka))&&WK(e,Number(f));return e}))})},QL=function(a,b,c,d,e){return _.x(function*(){var f=b.tag,g=Number(vJ(f,_.ka));if(null!=f.getAttribute("FRAME-RATE")||null!=f.getAttribute(_.Bb)){var h=_.J(f,"FRAME-RATE");f=_.J(f,_.Bb);var [k,l]=f?f.split("x"):[null,null];h={frameRate:zJ(h),width:zJ(k),height:zJ(l)}}else h=
56
- null;if(f=yield UL(a,b,h,c,d)){h=f.video;f=f.audio;var m=0<f.length?f:[null];h=0<h.length?h:[null];f=[];for(const n of m)for(const q of h){m=(q?$J(q).Fa:"")+" - "+(n?$J(n).Fa:"");if(e.has(m)){a.g.debug("Skipping variant which only differs in text streams.");continue}const u=wL(a,n,q,g);null==u?a.g.warn("Incompatible DRM info in HLS variant. Skipping."):(f.push(u),e.add(m))}g=f}else g=[];return g})},UL=function(a,b,c,d,e){return _.x(function*(){var f=b.tag,g=b.playlist;let h=ML(a,f);var k=_.J(f,"AUDIO"),
57
- l=_.J(f,_.Sb);k=k?d.get(`${"audio"}:${k}`)||[]:[];var m=l?d.get(`${"video"}:${l}`)||[]:[];l=[...k,...m];k={audio:k,video:m};a.g.debug("Guessing stream type for",f.toString());f=!1;const n=g.a;g=k.audio.find(q=>$J(q).Fa===n);m=_.bk(_.w,h);m=c||m;1!==h.length||m?!l.length&&1<h.length?(a.g.debug("Guessing multiplexed audio+video"),g=_.w,h=[h.join(",")]):k.audio.length&&g?(a.g.debug(nJ),g=_.p,f=!0):k.video.length?(a.g.debug(nJ),g=_.p):(a.g.debug("Guessing video-only"),g=_.w):(g=_.p,a.g.debug(nJ));m=null;
58
- f||(m=yield VL(a,b,h,g,e,c));if(null==m)return null;k[g]=[m];g===_.p&&c&&l.forEach(q=>{TK(q,c.width);UK(q,c.height);VK(q,c.frameRate)});dK(k);return k})},VL=function(a,b,c,d,e,f){return _.x(function*(){const g=b.tag,h=b.playlist;return TL(a,h.a,()=>_.x(function*(){var k=_.J(g,iJ);let l=null;d===_.w&&k&&"NONE"!==k&&(l=e.get(k));k=NL(d,c);return yield HL(a,{playlist:h,codecs:k,type:d,closedCaptions:l,primary:!1,kind:null,ed:null,name:null,channelsCount:null,spatialAudio:!1,groupId:null,Ud:f})}))})},
59
- TL=function(a,b,c){if(a.f.has(b))return a=a.f.get(b),Promise.resolve(a);if(a.f.f.has(b))return a.f.f.get(b)||null;c=c();a.f.set(b,c);return c},KL=function(a,b,c,d){return _.x(function*(){var e=b.a,f=b.U;var g=void 0===g?0:g;var h=(h=FJ(b.aa,_.Ha))?Number(h.value):g;g=[];!oL(a)&&IK(f);e=yield WL(a,b.f,e,f,h,c,d);if(0===f.length)f=[];else{var k=[],l=[];for(var m of f)EJ(m.aa,_.Ca)&&0<l.length&&(k.push(l),l=[]),l.push(m);k.push(l);f=k}for(m=0;m<f.length;m++)k=f[m],l=yield XL(a,b.f,k,h,e,c,d,g[g.length-
60
- 1]||null,f.length),g.push(l),h+=k.length;YL(g);return g})},SL=function(a,b){return _.x(function*(){var c="EXT-X-MEDIA"!==b.name?!0:_.J(b,_.Kb)===qJ;c=_.J(b,_.Mb,void 0,{required:c});if(!c)return null;const d=HJ(a.w,c),{response:e,text:f}=yield kL(a,d);return lL(a,f,e.uri,c)})},YL=function(a){if(1<(new Set(a.map(b=>b.mimeType))).size)throw new _.I(_.F,4,4045,"Media playlist contains discontinuities with different MIME types. This is valid, but not yet supported.");},ZL=function(a){a=a.map(b=>b.a?b.a:
61
- b.f.map(c=>_.J(c,_.Mb))||null).map(b=>_.Ft(b));if(1<(new Set(a)).size)throw new _.I(_.F,4,4044,"Unexpected change in file format.");},$L=function(a,b,c){a=BJ(a.aa,_.Ga);if(1<a.length)throw new _.I(_.F,4,4020);a=a[0];if(!a)return null;const d=vJ(a,_.Mb),e=HJ(b,d);b=SJ(a,null,!0);return new _.RI(()=>[e],b.za,b.na,c)},aM=function(a,b,c,d,e,f,g){const h=[];for(const q of AJ(b.f)){b=q.Jf;const u=q.item;{var k=0===b,l=k?a:h[h.length-1],m=k?d:l.endTime,n=Number(_.J(u,kJ));n=m+n;k=SJ(u,k?null:l.na,k);l=_.J(u,
62
- _.Mb);const v=(l=HJ(g,l))?[l]:[];m=new TJ(c,m,n,()=>v,k.za,k.na,e,f,!1,null,null,null,null);if("YES"===_.J(u,"INDEPENDENT")||0===b)m.h=!0;h.push(m)}}return h},bM=function(a,b,c,d,e,f,g,h,k,l,m){const n=c.aa;var q=c.a;0<BJ(n,_.Ga).length&&(m=$L(c,k,g));const u=null!=q,v=q?[q]:[];if(!u&&!a.a.lowLatencyMode)return null;a=0;q={za:0,na:null};let y=null;u?({duration:c}=QJ(n),a=e+c,q=PJ(n,b?b.na:null)):(b=aM(b,c,d,e,f,g,k),a=b[b.length-1].endTime,y=b);h=h===_.ee?GJ(n):null;d=new TJ(d,e,a,()=>v,q.za,q.na,
63
- f,g,!1,null,h?h.Yc:null,h?h.qd:null,h?h.durationPerTile:null,y,m);d.ma=l;return d},WL=function(a,b,c,d,e,f,g){return _.x(function*(){var h=d[0];if(null!=a.A)return a.A;if(!oL(a)&&a.B)try{var k=a.f.get(c);var l=k?RK(k,e)||null:null;if(!l)throw new _.I(_.F,4,4030,"Segment not found in pervious playlist update.");var m=l.startTime+l.Ea;a.g.debug(`Setting playlist start time to ${m}.`);return a.A=m}catch(n){if(h=a.f.get(c))m=h.streams[h.streams.length-1].U,m=m[m.length-1],a.g.warn(`Last #EXT-X-MEDIA-SEQUENCE values ${h.streams[0].U[0].position} - ${m.position}`+
64
- `, new values ${e} - ${e+d.length-1}.`,b,h);throw new _.I(_.F,4,4047,{message:"The updated playlist does not share any segments with the previous one.",uri:c});}m=yield cM(a,f,g,h);k=JK(h.aa,a.w,m)||EK();l=$L(h,b,k.keyInfo);k=VJ(k.keyInfo,e);h=yield dM(a,l,h,k,m,g);a.g.debug(`Setting playlist start time to ${h}.`);return a.A=h})},XL=function(a,b,c,d,e,f,g,h,k){return _.x(function*(){var l=c[0],m=null==h;ZL(c);const n=yield cM(a,f,g,l);var q=a.w,u=h?h.nh:null;var v=1===k;if(c.slice(1).some(HK))throw new _.I(_.F,
65
- 4,4046,v?"Media playlist contains an EXT-X-KEY tag with METHOD\x3dAES-128 which is not at the beginning of the playlist.":"Media playlist contains an EXT-X-KEY tag with METHOD\x3dAES-128 which is not marked by an EXT-X-DISCONTINUITY tag and is not at the beginning of the playlist.");if(EJ(c[0].aa,_.Fa)||null===u)if((u=JK(c[0].aa,q,n))&&u.type===uJ){if(1<LK(c))throw new _.I(_.F,4,4046,rJ+`${v?"playlist":"discontinuity"}.`);v=[u]}else v=KK(c,q,n),v=0===v.length?[EK()]:v;else if(q=KK(c,q,n),u.type===
66
- _.Fe||u.type===tJ)v=[u,...q];else{if(0<LK(c))throw new _.I(_.F,4,4046,rJ+`${v?"playlist":"discontinuity"}.`);v=[u]}q=v;v=q[q.length-1];q=FK(q);u=$L(l,b,q.keyInfo)||(h?h.ih:null);var y=VJ(q.keyInfo,d);const A=l.ma;l=m?e:yield eM(a,A,u,l,d,y,n,g);m=[];for(y=0;y<c.length;y++){var D=c[y];const H=m[m.length-1]||null,X=0===y?0:H.endTime,wb=d+y,oe=VJ(q.keyInfo,wb);if(D=bM(a,H,D,wb,X,l,oe,f,b,A,u))u=D.initSegment,m.push(D)}return{U:m,Lg:q,nh:v,mimeType:n,endTime:m[m.length-1].endTime,ma:A,ih:u}})},cM=function(a,
67
- b,c,d){return _.x(function*(){const e=d.a;var f=FJ(d.aa,_.Ga);f=f?vJ(f,_.Mb):null;return fM(a,b,c,e,f)})},dM=function(a,b,c,d,e,f){return _.x(function*(){if(null==c.a)return 0;const g=UJ(c,d);return PK(a.P,b,g,e,f,null!=d)})},eM=function(a,b,c,d,e,f,g,h){return _.x(function*(){if(a.J.has(b))return a.J.get(b);const k=yield dM(a,c,d,f,g,h);a.g.debug(`Segment #${e} has raw media timestamp `+`${k} s.`);a.J.set(b,k);return k})},fM=function(a,b,c,d,e){return _.x(function*(){const f=[d,e].filter(Boolean);
68
- var g=_.ek(f,b,c);if(g)return g;g=_.pj([d],a.a.attemptParameters);g.method="HEAD";g.type=2;g=(yield a.G(g)).headers["content-type"];if(!g)throw new _.I(_.F,4,4021,"Unknown MIME type of: "+f.join(", "));return g.split(";")[0]})},lK=class{constructor(a,b,c,d){if(1===b){if(!d||0===d.length)throw new _.I(_.F,4,4043,"Media playlist must have at least one segment!");if(null==d[0].a)throw new _.I(_.F,4,4043,"Media playlist must have at least one full segment!");}this.f=a;this.a="";this.type=b;this.aa=c;
69
- this.U=1===b?d:null}},rK=class{constructor(a,b,c){c=void 0===c?[]:c;this.aa=b;this.a=a;this.f=c;this.ma=-1}},TJ=class extends _.lD{constructor(a,b,c,d,e,f,g,h,k,l,m,n,q,u,v){u=void 0===u?[]:u;super(a,b,c,d,e,f,g,void 0===h?null:h,void 0===k?!1:k,void 0===l?null:l,void 0===m?null:m,void 0===n?null:n,void 0===q?null:q,u,void 0===v?null:v);this.ma=0}},gM=class{constructor(){this.f=0;this.a=new Map}},hM=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,
70
- 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()}},tL=new _.S("clpp.hls.DiscontinuityUtils");var NK={"com.apple.streamingkeydelivery":function(a,b){if(b===_.ng)throw new _.I(_.F,4,4041);if(vJ(a,oJ)===pJ)throw new _.I(_.F,4,4044,"EXT-X-KEY:METHOD SAMPLE-AES-CTR is not supported in FairPlay.");return _.oC(_.ud,[{initDataType:_.Lf,initData:new Uint8Array(0)}],"")},"com.microsoft.playready":DK,"urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":DK,"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":function(a){var b=vJ(a,oJ);if(!BK.includes(b))return CK.error("Widevine in HLS is only supported with [",
71
- BK.join(", "),"], not",b),null;b=vJ(a,_.Mb);b=_.Us(b);b=_.K(b.data);b=_.oC(_.zd,[{initDataType:_.cd,initData:b}],"");if(a=_.J(a,"KEYID"))b.keyIds=[a.substr(2).toLowerCase()];return b}},BK=["SAMPLE-AES",pJ],CK=new _.S("clpp.hls.DrmParser");var MK=new _.S("clpp.hls.EncryptionUtils");var iM=class{constructor(a){this.g=new _.S("clpp.hls.MediaReader");this.f=a;this.a={attemptParameters:_.lj()}}};var LL=class{constructor(a){this.streams=a}length(){return this.streams.length}};var JL=class{constructor(a){this.a=a}length(){return this.a.length}};var jM=class{constructor(){this.a=this.D=null;this.R=1;this.f=new hM;this.w="";this.M=new gM;this.F=0;this.j=null;this.h=new _.vk(()=>{this.Sb()});this.l=_.Tb;this.B=null;this.C=new _.Nt;this.I=this.A=null;this.g=new _.S("clpp.hls.HlsParser");this.J=new Map;this.P=new iM(this.G.bind(this));this.L=!1;this.H=null;this.K=!1;this.o=new Map}configure(a){this.a=a;this.P.a=a}setCurrentVariant(a){this.j=a}start(a,b){const c=this;return _.x(function*(){if(c.L)throw Error("start() may be called only once!");
72
- c.L=!0;c.D=b;const {response:d,text:e}=yield kL(c,a);c.w=d.uri;const f=yield qL(c,e);c.B=f;const g=c.F;c.h&&0<g&&c.h.fa(g);return f})}requestStop(){this.K=!0}stop(){this.h&&(this.h.stop(),this.h=null);const a=[];this.C&&(a.push(this.C.destroy()),this.C=null);this.f.clear();this.B=this.a=this.D=this.j=null;this.o.clear();return Promise.all(a)}update(){const a=this;return _.x(function*(){const b=a.B;if(!oL(a)&&b){var c=b.presentationTimeline;"LIVE"===a.l&&(a.A=null);var d=Array.from(a.f.values());if(a.a.lowLatencyMode&&
73
- null!==a.j){const g=jL(a);d=d.filter(h=>g.includes($J(h).Fa))}var e=yield sL(a,d);d=e.map(g=>g.playlist);uL(a,d);e=yield xL(a,e);YK(b.periods,e).forEach(g=>{a.D.filterNewPeriod(g)});nL(a,e);var f=yL(a,d);f=zL(a,d,f);b.cues=pL(a,f);$K(b.periods,e);iL(c,e);if(d=KJ(d))!0!==a.a.keepTimelineLive&&AL(a,c,e),a.h.stop(),a.h=null;if(a.D.onUpdate)a.D.onUpdate(b);if(d&&a.D.onTurnedStatic)a.D.onTurnedStatic();a.K&&(yield a.stop());return b}})}Sb(){const a=this;return _.x(function*(){a.g.debug(_.zB);if(a.D)try{yield a.update(),
74
- a.h&&0<a.F&&a.h.fa(a.F)}catch(b){if(!(b instanceof _.I))throw b;a.D&&(a.D.onError(b),1===b.severity&&a.h&&a.h.fa(.1))}})}G(a){if(!this.C)throw new _.I(_.F,7,7001);a=this.D.networkingEngine.fetch(a);_.Aj(this.C,a);return a.W}};_.z("clpp.hls.HlsComponent",class extends _.Iu{f(){_.ys.m3u8=jM;_.ws[_.ql]=jM;_.ws[sJ]=jM}a(){_.KD("m3u8");_.LD(_.ql);_.LD(sJ)}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 yJ="CLOSED-CAPTIONS",zJ="Could not parse MP4 segment start time.",AJ="DURATION",BJ="EXT-X-STREAM-INF",CJ="Failed to infer discontinuity number",DJ="Guessing audio-only",EJ="METHOD",FJ="SAMPLE-AES-CTR",GJ="SUBTITLES",HJ="Two EXT-X-KEY tags, one with METHOD\x3dAES-128 are applied to one ",IJ="application/vnd.apple.mpegurl",JJ="sample",KJ="whole-segment",LJ=function(a,b){return _.J(a,b,void 0,{required:!0})},MJ=function(a){if(1>a.a)throw _.$l();--a.a},NJ=function(a,b){for(const c in a){if(!(c in
2
+ b))return!1;const d=a[c],e=b[c];if(d&&typeof d===_.He&&e&&typeof e===_.He){if(!NJ(d,e))return!1}else if(void 0!==d&&void 0!==e&&d!==e)return!1}return!0},OJ=function(a,b){if(!NJ(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&&OJ(d,e))return!0}return!1},PJ=function(a){if(null!==a&&void 0!==a)return Number(a)},QJ=function*(a){let b=-1,c=void 0,d=void 0;for(const e of a)0<=b&&(yield{Hf:b,item:d,zh:c,next:e}),b++,c=d,d=e;-1!==
3
+ b&&(yield{Hf:b,zh:c,item:d,next:void 0})},RJ=function(a,b){return a.filter(c=>c.name===b)},SJ=function(a){const b=/^[a-zA-Z0-9_-]+$/,c=new Set;a.forEach(d=>{const e=_.J(d,"VALUE"),f=_.J(d,"NAME"),g=_.J(d,"IMPORT"),h=_.J(d,"QUERYPARAM");if(1!==[f,g,h].filter(Boolean).length||f&&null==e)throw new _.H(_.F,4,4044,{message:"Invalid tag.",text:d.toString()});d=f||g||h;if(c.has(d))throw new _.H(_.F,4,4044,`EXT-X-DEFINE redefined variable "${d}".`);if(!b.test(d))throw new _.H(_.F,4,4044,`EXT-X-DEFINE invalid variable name "${d}".`);
4
+ c.add(d)})},TJ=function(a,b){const c=Array.isArray(b)?b:[b];return a.filter(d=>{d=LJ(d,_.Ib);return c.includes(d)})},UJ=function(a,b){return a.some(c=>c.name===b)},VJ=function(a,b,c){c=void 0===c?{}:c;a=a.find(d=>d.name===b)||null;if(!a&&c.required)throw new _.H(_.F,4,4024,{missingTag:b});return a},WJ=function(a){var b=VJ(a,"EXT-X-TILES");if(!b)return{Wc:1,od:1,durationPerTile:null};a=_.J(b,"LAYOUT")||"1x1";b=_.J(b,AJ);a=_.EC(a);return{Wc:a.Wc,od:a.od,durationPerTile:b?Number(b):null}},XJ=function(a,
5
+ b,c){c=void 0===c?!0:c;a=new _.ji(a);b=new _.ji(b);b=a.resolve(b).toString();return c?b:decodeURI(b)},YJ=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)},ZJ=function(a,b){Array.isArray(a)||(a=[a]);a.forEach(c=>{for(const d of YJ(c))b(d,c)})},$J=function(a){return a.some(b=>UJ(b.aa,_.Da))},aK=function(a){return a.type===_.p||a.type===_.w},bK=function(a){if(VJ(a,
6
+ _.Da))return _.Sb;a=VJ(a,_.Ia);if(!a)return"LIVE";if(a.value===_.Sb)return _.Sb;if("EVENT"===a.value)return"EVENT";throw new _.H(_.F,4,4044,`Invalid EXT-X-PLAYLIST-TYPE value: ${a.value}`);},cK=function(a){a={AUDIO:_.p,VIDEO:_.w,SUBTITLES:_.G,"CLOSED-CAPTIONS":_.G}[a.toUpperCase()];if(!a)throw new _.H(_.F,4,4044,"EXT-X-MEDIA tag has an invalid TYPE attribute.");return a},dK=function(a,b,c){c=void 0===c?!1:c;var d=0;let e=null;if(a){d=a.split("@");a=Number(d[0]);if(0>=a)throw new _.H(_.F,4,4044,"Byte range length must be positive.");
7
+ if(d[1]){if(d=Number(d[1]),0>d)throw new _.H(_.F,4,4044,"Byte range start byte must not be negative.");}else{if(c)throw new _.H(_.F,4,4044,"Invalid byte range, offset is required but missing.");if(null==b)throw new _.H(_.F,4,4044,"Invalid byte range, cannot calculate offset based on previous byte ranges.");d=b+1}e=d+a-1}return{xa:d,ma:e}},eK=function(a,b){a=VJ(a,_.ya);return dK(a?a.value:null,b)},fK=function(a){a=VJ(a,"EXTINF",{required:!0}).value.split(",");return{duration:Number(a[0]),title:a[1]||
8
+ null}},gK=function(a,b){b=void 0===b?{}:b;const c={lf:!1,Cg:!1,Dg:null,gh:null,Vf:null};a=VJ(a,_.La,{required:b.ag});if(!a)return c;const d=e=>null==e?null:Number(e);c.lf="YES"===_.J(a,"CAN-BLOCK-RELOAD");c.Cg="YES"===_.J(a,"CAN-SKIP-DATERANGES");c.Dg=d(_.J(a,"CAN-SKIP-UNTIL"));c.gh=d(_.J(a,"HOLD-BACK"));c.Vf=d(_.J(a,"PART-HOLD-BACK",void 0,{required:b.ag}));return c},hK=function(a,b,c){c=void 0===c?!1:c;a=_.J(a,"BYTERANGE");return dK(a,b,c)},jK=function(a,b){const c=eK(a.aa,null);return new iK(0,
9
+ 0,0,()=>[a.a],c.xa,c.ma,0,b)},kK=function(a,b){if(null==a)return null;a=Object.assign({},a);null==a.iv&&(a.iv=_.gj(new Uint8Array(12),new Uint8Array([b>>24&255,b>>16&255,b>>8&255,b&255])));return a},lK=function(a){let b=Infinity,c=Infinity;YJ(a).filter(aK).forEach(d=>{{d=d.T;var e=d[0].startTime;const f=d[d.length-1].endTime;d=e;e=f-e}b=Math.min(b,d);c=Math.min(c,e)});return{Gc:b,duration:c}},mK=function(a){return a.map(b=>{({duration:b}=lK(b));return b}).reduce((b,c)=>b+c,0)},nK=function(a){return(a.video?
10
+ a.video.Fa:"")+" - "+(a.audio?a.audio.Fa:"")},oK=function(a,b,c,d){if(b===_.Sb)return{delay:0,nd:0};b=VJ(a,_.Ha);if(c&&b){c=Number(LJ(b,"PART-TARGET"));if(null!=d)return{delay:d,nd:c};({Vf:d}=gK(a,{ag:!0}));return{delay:d,nd:c}}a=VJ(a,_.Ma,{required:!0});a=Number(a.value);return null!=d?{delay:d,nd:a}:{delay:3*a,nd:a}},qK=function(a){const b=new Map;a.forEach(c=>{var d=`${pK(c).type}:${pK(c).groupId}`;b.has(d)?(d=b.get(d),d.includes(c)||d.push(c)):b.set(d,[c])});return b},rK=function(a){const b=new Map;
11
+ for(const c of a){a=_.J(c,_.Za);a=_.zi(a||_.eg);const d=LJ(c,_.Sa),e=LJ(c,"INSTREAM-ID");b.has(d)||b.set(d,new Map);b.get(d).set(e,a)}return b},tK=function(a){a=a.audio.concat(a.video);for(const b of a)a=pK(b).codecs.split(",").filter(c=>"mp4a.40.34"!==c),sK(b,a)},uK=function(a,b){if(!a)return null;const c=a.Fa;return b.find(d=>pK(d).Fa===c)||null},vK=function(a){for(const b of a)if(b.startsWith("#EXT-")&&(a=_.lj(0,b),_.St.has(a.name)))return 1;return 0},wK=function(a,b){return a.replace(/\{\$([a-zA-Z0-9_-]+)\}/g,
12
+ (c,d)=>{c=b.get(d);if(null==c)throw new _.H(_.F,4,4044,`Undefined variable '${d}'`);return c})},xK=function(a,b){a.forEach(c=>{c.attributes.forEach(d=>{d.value=wK(d.value,b)})})},yK=function(a,b,c){xK(a,c);b.forEach(d=>{d.a&&(d.a=wK(d.a,c));xK(d.aa,c);xK(d.f,c)})},zK=function(a,b){const c=new Map,d=new URL(b);a.forEach(e=>{var f=_.J(e,"NAME"),g=_.J(e,"QUERYPARAM");if(f)g=LJ(e,"VALUE"),c.set(f,g);else if(g){f=d.searchParams.get(g);if(null==f)throw new _.H(_.F,4,4044,`Query param '${g}' missing in playlist URI.`);
13
+ if(!f)throw new _.H(_.F,4,4044,`Query param '${g}' has no associated value`+" in playlist URI.");c.set(g,decodeURIComponent(f))}});return c},CK=function(a,b,c){const d=[];for(let e=1;e<b.length;e++){const f=AK(a,b[e]);d.push(f);if(f.name===BJ){const g=b[e+1];if(!g)throw new _.H(_.F,4,4044,"EXT-X-STREAM-INF is not followed by a URI.");f.attributes.push(new _.jj(_.Lb,g));e++}}b=RJ(d,"EXT-X-DEFINE");SJ(b);b=zK(b,c);a.a=b;yK(d,[],a.a);return new BK(c,0,d)},FK=function(a,b,c){let d=[];for(var e=1;e<b.length;){const f=
14
+ AK(a,b[e]);if(_.Tt.has(f.name))break;d.push(f);e++}b=DK(a,c,b.slice(e));e=b.T;d=d.concat(b.aa);a=EK(a,d,c);yK(d,e,a);return new BK(c,1,d,b.T)},GK=function(a,b,c){b=b.trim().split(/\n+/m).map(d=>d.trim()).filter(d=>d.length&&!/^#(?!EXT)/m.test(d));if(!/^#EXTM3U($|[ \t\n])/m.test(b[0]))throw new _.H(_.F,4,4015);return 0===vK(b)?CK(a,b,c):FK(a,b,c)},AK=function(a,b){return _.lj(a.f++,b)},DK=function(a,b,c){const d=[],e=[];let f=[],g=[];c.forEach(h=>{/^(#EXT)/.test(h)?(h=AK(a,h),_.St.has(h.name)||_.Vt.has(h.name)?
15
+ d.push(h):_.Ut.has(h.name)?"EXT-X-PART"===h.name?g.push(h):h.name===_.Ja&&"PART"===_.J(h,_.Ib)&&g.push(h):f.push(h)):/^#(?!EXT)/m.test(h)||(h=XJ(b,h.trim(),!1),e.push(new HK(h,f,g)),f=[],g=[])});0<g.length&&e.push(new HK(null,f,g));return{T:e,aa:d}},EK=function(a,b,c){b=RJ(b,"EXT-X-DEFINE");SJ(b);const d=zK(b,c);b.map(e=>_.J(e,"IMPORT")).filter(Boolean).forEach(e=>{const f=a.a.get(e);if(null==f)throw new _.H(_.F,4,4044,`Cannot import variable '${e}' as it is not defined `+"in the master playlist");
16
+ d.set(e,f)});return d},IK=function(a){return 0>a?[]:Array.from({length:a},(b,c)=>c)},JK=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},KK=function(a){function b(h,k,l){let m="";for(;k<l;k++)m+="%"+("00"+h[k].toString(16)).slice(-2);return m}function c(h){return h[0]<<21|h[1]<<14|h[2]<<7|h[3]}function d(){throw new _.H(_.F,4,4030);}JK(a)||d();let e=10;a[5]&64&&(e=e+4+c(a.subarray(10,14)));do{var f=
17
+ c(a.subarray(e+4,e+8));1>f&&d();var g=String.fromCharCode(a[e],a[e+1],a[e+2],a[e+3]);if("PRIV"===g){g=a.subarray(e+10,e+f+10);for(let h=0;h<g.byteLength;h++)if(0===g[h]){if("com.apple.streaming.transportStreamTimestamp"===unescape(b(g,0,h)))return a=g.subarray(h+1),f=(a[3]&1)<<30|a[4]<<22|a[5]<<14|a[6]<<6|a[7]>>>2,f*=4,f+=a[7]&3,Math.round(f/9E4);break}}JK(a,e)||d();e+=10;e+=f}while(e<a.byteLength);return d()},LK=function(a,b){let c=null,d=0;try{(new _.pm).N(_.De,_.im).N(_.bg,_.im).N(_.ye,_.im).ba("mdhd",
18
+ g=>{g.reader.skip(0===g.version?8:16);d=_.P(g.reader);g.parser.stop()}).parse(b,!0)}catch(g){c=g}if(c||!d)throw _.lv.error("Unable to find timescale in init segment!"),new _.H(_.F,4,4030,zJ,c);let e=0,f=!1;try{(new _.pm).N("moof",_.im).N("traf",_.im).ba("tfdt",g=>{var h=d;if(0===g.version)h=_.P(g.reader)/h;else{{const k=_.P(g.reader),l=_.P(g.reader);if(!(2097151>=k||h>=Math.pow(2,12)))throw Error("Cannot accurately parse MP4 timestamp, base time is too high and timescale is \x3c\x3d 2^12");h=k/h*
19
+ 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 _.H(_.F,4,4030,zJ,c);return e},MK=function(a){for(;a.getPosition()<a.Oa()-1;){const b=a.getPosition();if(71===_.am(a))return MJ(a),b}return-1},NK=function(a){function b(){d.seek(e+188);f=_.am(d);71!==f&&(d.seek(e+192),f=_.am(d));71!==f&&(d.seek(e+204),f=_.am(d));71!==f&&c();MJ(d)}function c(){throw new _.H(_.F,4,4030);}const d=new _.dn(new DataView(a),!1);let e=0,f=0;e=MK(d);0>e&&(_.lv.error("Unable to find sync byte in TS after scanning."),
20
+ c());for(;;){e=d.getPosition();f=_.am(d);71!==f&&c();a=_.bm(d);if(8191===(a&8191)){b();continue}if(!(a&16384)){b();continue}a=(_.am(d)&48)>>4;0!==a&&2!==a||c();3===a&&(a=_.am(d),d.skip(a));if(1!==_.P(d)>>8){b();continue}d.skip(3);a=_.am(d)>>6;0!==a&&1!==a||c();0===_.am(d)&&c();a=_.am(d);const g=_.bm(d),h=_.bm(d);return(1073741824*((a&14)>>1)+((g&65534)<<14|(h&65534)>>1))/9E4}},QK=function(a){const b=OK(a),c=PK(a);a.forEach(d=>{const e=d.T,f=e.findIndex(h=>h.la===b);let g=e.findIndex(h=>h.la===c+1);
21
+ -1===g&&(g=e.length);d.T=e.slice(f,g)})},PK=function(a){a=a.map(b=>b.T[b.T.length-1].la);return Math.min(...a)},OK=function(a){a=a.map(b=>b.T[0].la);return Math.max(...a)},TK=function(a){var b=LJ(a,EJ);if(!RK.includes(b))return SK.error("PlayReady in HLS is only supported with [",RK.join(", "),"], not",b),null;a=LJ(a,_.Lb);b=_.ct(a);a=null;b=_.K(b.data);try{a=_.nC(_.ln(b))}catch(c){a=b}return _.AC(_.wd,[{initDataType:_.bd,initData:a}],"")},VK=function(a){if(0===a.length)return UK();if(a.some(c=>c.type===
22
+ KJ)||a.every(c=>c.type===_.Ge))return a[0];a=a.filter(c=>c.type===JJ);const b=_.ai(a.flatMap(c=>c.drmInfos));return{keyInfo:null,keyId:a[a.length-1].keyId,type:JJ,drmInfos:b}},YK=function(a){a=WK(a);if(a.some(b=>XK(b))&&1<a.length)throw new _.H(_.F,4,4046,"Two EXT-X-KEY tags, one with METHOD\x3dAES-128 are applied to one playlist.");},XK=function(a){return RJ(a.aa,_.Ea).some(b=>"AES-128"===_.J(b,EJ))},$K=function(a,b,c){return WK(a).map(d=>ZK(d.aa,b,c))},aL=function(a){return a.filter(b=>UJ(b.aa,
23
+ _.Ea)).length},WK=function(a){return a.filter(b=>UJ(b.aa,_.Ea))},ZK=function(a,b,c){a=RJ(a,_.Ea);if(0===a.length)return null;var d=LJ(a[0],EJ);if(1===a.length){if("NONE"===d)return UK();if("AES-128"===d)return a=a[0],d=_.J(a,"IV",""),{type:KJ,keyInfo:{method:"AES-128",url:XJ(b,LJ(a,_.Lb)),iv:d?_.dj((d||"0x").slice(2)):null},drmInfos:[],keyId:null}}b=a.map(e=>LJ(e,EJ));if(!b.every(e=>"SAMPLE-AES"===e)&&!b.every(e=>e===FJ))throw bL.warn(`EXT-X-KEY methods ${b.join(", ")} are incompatible.`),new _.H(_.F,
24
+ 4,4044,"Multiple EXT-X-KEY tags with incompatible METHOD values.");b=a.map(e=>{const f=_.J(e,"KEYFORMAT","identity");{const g=cL[f]||null;e=g?g(e,c):null}e||bL.warn("Unsupported HLS KEYFORMAT",f);return e}).filter(Boolean);if(0===b.length)throw new _.H(_.F,4,4026);return{keyInfo:null,keyId:b.map(e=>e.keyIds).reduce((e,f)=>e.concat(f),[]).reverse()[0]||null,type:JJ,drmInfos:b}},UK=function(){return{type:_.Ge,keyInfo:null,drmInfos:[],keyId:null}},dL=function(a,b,c){return _.x(function*(){const d=b.f(),
25
+ e=_.cD(b.Xa(),b.xa,b.xa+2048-1,a.a.attemptParameters);e.type=2;const f=_.cD(b.Xa(),b.xa,b.ma,a.a.attemptParameters);f.type=2;d&&(f.keyInfo=d);try{return yield a.f(c?f:e)}catch(g){if(7001===g.code||c)throw g;a.g.warn("Unable to fetch a partial HLS segment! Falling back to a full segment request, which is expensive! Your server should support Range requests and CORS pre-flights.",e.uris[0]);try{return yield a.f(f)}catch(h){throw a.g.error("Failed to fetch media segment to parse its start timestamp.",
26
+ f.uris[0],h),new _.H(_.F,4,4030,"Failed to fetch the media segment.");}}})},eL=function(a,b,c,d,e,f){return _.x(function*(){a.g.debug("Fetching segment to find start time");if("audio/mpeg"===d||d===_.Kc||d===_.Jc)return 0;if(d===_.Ic){var g=yield dL(a,c,f);g=_.K(g.data);if(!JK(g))throw new _.H(_.F,4,4030,"AAC segment does not contain an ID3 tag.");return KK(g)}if(d===_.tg||d===_.Lc)return g=[dL(a,c,f)],b&&g.push(dL(a,b,!0)),g=yield Promise.all(g),LK(g[0].data,(g[1]||g[0]).data);if(d===_.sg)return g=
27
+ yield dL(a,c,f),NK(g.data);if(!_.bs(`${d.split("/")[0]||""}/mp4;codecs="${e}"`))return 0;throw new _.H(_.F,4,4030);})},fL=function(a,b){a=a.map(c=>c.streams[b]);return a.some(c=>null==c)?null:a},sK=function(a,b){a.streams.forEach(c=>{c.codecs=b.join(",")})},gL=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},pK=function(a){return a.streams[0]},hL=function(a,b){a.streams.forEach(c=>{c.Ud=b})},iL=function(a,
28
+ b){a.streams.forEach(c=>{c.width=b})},jL=function(a,b){a.streams.forEach(c=>{c.height=b})},kL=function(a,b){a.streams.forEach(c=>{c.frameRate=b})},lL=function(a,b){a.streams.forEach(c=>{c.bandwidth=b})},mL=function(a,b){a=a.map(c=>c.a[b]);return a.some(c=>null==c)?null:a},nL=function(a,b){const c=new Set(a.map(d=>d.la));return b.filter(d=>!c.has(d.la))},pL=function(a,b){for(;a[0].la<b[0].la;)a.splice(0,1);var c=a[0];let d=b[0];c.startTime===d.startTime&&c.endTime===d.endTime||oL(c,d);const e=a.length-
29
+ 1;c=a[e];d=b[e];0<e&&(c.startTime!==d.startTime||c.endTime!==d.endTime)&&oL(c,d);for(c=e+1;c<b.length;)a.push(b[c]),c++},uL=function(a,b,c,d,e){var f=b[0].length();f=IK(f).map(g=>{var h=mL(b,g)||[];const k=fL(c,g)||[];g=fL(d,g)||[];{const l=[...qL(h),...k,...g].filter(Boolean);rL(l);const {la:m,duration:n}=l[0];h={configurationId:a,variants:h,textStreams:k,thumbStreams:g,startTime:0,id:`P${m}`,endTime:n,duration:n,la:m}}return h});e&&sL(f[0]);tL(f);return f},qL=function(a){a=new Set(a.flatMap(b=>
30
+ [b.video,b.audio]).filter(Boolean));return Array.from(a)},sL=function(a){const b=qL(a.variants)[0].T[0].Ea;a.startTime+=b;a.endTime+=b},tL=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}},oL=function(a,b){a.startTime=b.startTime;a.endTime=b.endTime;a.duration=b.duration;vL(a.variants,b.variants);wL(YJ(a),YJ(b))},vL=function(a,b){const c=new Map(a.map(d=>[nK(d),d]));b.forEach(d=>{c.get(nK(d)).drmInfos=d.drmInfos})},
31
+ wL=function(a,b){const c=new Map(a.map(d=>[d.Fa,d]));b.forEach(d=>{const e=c.get(d.Fa);e.T=d.T;e.segmentIndex.replace(d.T);e.Gc=d.Gc;e.me=d.me;e.duration=d.duration;e.uf=d.uf;e.encrypted=d.encrypted;e.drmInfos=d.drmInfos;e.keyId=d.keyId})},rL=function(a){const b=xL(a);a.forEach(c=>{_.ZC(c.segmentIndex,b);c.duration=b;c.me=c.Gc+b})},xL=function(a){let b=Infinity;a.filter(aK).forEach(c=>{b=Math.min(b,c.duration)});return b},yL=function(a,b){ZJ(b,(c,d)=>{_.lD(a,c.T,d.startTime)});_.dD(a.a,b[0].startTime,
32
+ b[b.length-1].endTime)},zL=function(a){return null===a.j?[]:[a.j.audio,a.j.video].filter(b=>b).map(b=>b.Fa)},AL=function(a,b){return _.x(function*(){var c=_.rj([b],a.a.attemptParameters);c.type=1;c=yield a.G(c);let d="";try{d=_.Ni(c.data)}catch(e){throw new _.H(_.F,4,4042);}d=d.replace(/\r\n|\r(?=[^\n]|$)/gm,"\n");d=d.trim();return{text:d,response:c}})},GL=function(a,b){return _.x(function*(){var c=BL(a,b,a.w,"");if(1===c.type){c=_.Ot(c.T[0].a)||"";c=null!=_.Nt.video[c]?_.w:null!=_.Nt.audio[c]?_.p:
33
+ null;var d="";c===_.w?d="avc1.42E01E":c===_.p&&(d="mp4a.40.2");{c=a.M;var e=a.w;d=a.a.hlsDefaultCodecs||d;var f=[];const r=[];r.push(new _.jj(_.ka,"0"));r.push(new _.jj(_.Lb,e));d.length&&r.push(new _.jj(_.na,d));f.push(new _.kj(c.f++,BJ,r));c=new BK(e,0,f)}}d=c.aa;c=RJ(d,"EXT-X-MEDIA");e=RJ(d,BJ);d=RJ(d,"EXT-X-IMAGE-STREAM-INF");c={Fc:{xg:TJ(c,["AUDIO",_.Rb]),closedCaptions:TJ(c,yJ),Sh:TJ(c,GJ)},pd:e,he:d};const {nh:g,periods:h,Bh:k,Uh:l}=yield CL(a,c);if(!a.D)throw new _.H(_.F,7,7001);DL(a,h);c=
34
+ !0;e=null;d=0;EL(a)||(c=!1,e=0,d=g.delay);f=a.a.timeline||{};f.type=void 0;e=new _.kJ(f,e,d,!0,void 0,!!a.a.lowLatencyMode);_.hD(e,c);yL(e,h);k&&_.gD(e,k);c=e;if(!EL(a)){a.F=g.nd;e=0;for(var m of a.f.values())e=Math.max(e,m.streams[0].Gc);for(m=0;95443.7176888889<=e;)m+=95443.7176888889,e-=95443.7176888889;if(m){a.g.debug("Offsetting live streams by",m,"to compensate for rollover");for(var n of a.f.values())e=n.streams[0],95443.7176888889>e.Gc?(a.g.debug("Offset applied to",e.type),e.segmentIndex.offset(m)):
35
+ a.g.debug("Offset NOT applied to",e.type)}}n=mK(h);"LIVE"===a.l||"EVENT"===a.l?(n=Math.max(n,c.J),isNaN(a.a.availabilityWindowOverride)||(n=a.a.availabilityWindowOverride),c.A=n):a.l===_.Sb&&(c.f=n);n=FL(a,l);n={presentationTimeline:c,periods:h,minBufferTime:0,cues:n};a.g.debug("HLS playlist parsed",n);return n})},IL=function(a,b){return Promise.all(b.map(c=>HL(a,c)))},KL=function(a,b){b.forEach(c=>{a:{var d=a.f.get(c.a),e=!EL(a),f=VJ(c.aa,_.Ca);if(f)var g=Number(f.value);else{d?(f=d.streams[d.streams.length-
36
+ 1].T,f=f[f.length-1].la):f=0;if(e&&0<f)try{{const k=VJ(c.aa,_.Ga);if(!k)throw JL.error("Failed to infer discontinuity number, because EXT-X-MEDIA-SEQUENCE tag is missing."),Error(CJ);const l=Number(k.value),m=gL(d,l);if(!m)throw JL.error("Failed to infer discontinuity number, could not find the appropriate segment in the previous playlist"+` (segment position = ${l})`),Error(CJ);var h=m.la}g=h;break a}catch(k){throw new _.H(_.F,4,4024,"EXT-X-DISCONTINUITY-SEQUENCE tag is required for discontinuous HLS live streams.");
37
+ }g=0}}c=c.T||[];for(const k of c)UJ(k.aa,_.Ba)&&g++,k.la=g});QK(b)},NL=function(a,b){return _.x(function*(){const {textStreams:c,thumbStreams:d,yg:e}=yield LL(a,b);var f=a.B.periods[0].variants;a.a.lowLatencyMode&&null!==a.j&&(f=f.filter(g=>g.id===a.j.id));f=f.map(g=>{const h=uK(g.audio,e),k=uK(g.video,e);g=ML(a,h,k,g.bandwidth);if(!g)throw new _.H(_.F,4,4047,{message:"Video and audio are encrypted in an incompatible way.",Bi:k?pK(k).Fa:void 0,audio:h?pK(h).Fa:void 0});return g});return uL(a.D.configurationId,
38
+ f,c,d,!0)})},DL=function(a,b){EL(a)||2!==a.a.timeline.version||(a.H||(a.H=b[0].startTime),_.vE(b,-a.H))},OL=function(a,b){b=b.flatMap(d=>d.T[0].aa);b=VJ(b,_.Ka);if(!b)return null;const c=(new Date(b.value)).getTime();return isNaN(c)?(a.g.warn("Failed to parse EXT-X-PROGRAM-DATE-TIME tag "+`value (value: ${b.value}).`),null):c/1E3},PL=function(a,b,c){b=b.find(d=>null!==VJ(d.aa,_.za));if(!b)return[];if(null===c)throw new _.H(_.F,4,4024,"EXT-X-PROGRAM-DATE-TIME tag is required when EXT-X-DATERANGE tags are present");
39
+ return b.aa.filter(d=>d.name===_.za).map(d=>{a:{var e=a.A,f=!EL(a),g=_.J(d,"ID"),h=_.J(d,"START-DATE");if(null===g||null===h)_.Rt.warn("Invalid EXT-X-DATERANGE missing mandatory ID or START-DATE attribute, ignoring the EXT-X-DATERANGE tag.",d),d=null;else{e=f?e-c:-c;var k=new Date(h);h=k.getTime()/1E3+e;g={id:g,startTime:h,startDate:k};f=PJ(_.J(d,AJ));void 0!==f&&0<=f&&(g.duration=f);var l=PJ(_.J(d,"PLANNED-DURATION"));void 0!==l&&0<=l&&(g.plannedDuration=l);var m=_.J(d,"CLASS");null!==m&&(g.schemeIdUri=
40
+ m);var n=_.J(d,"END-DATE");n=n?new Date(n):null;null!==n&&n.getTime()>=k.getTime()&&(g.endDate=n);{const v=d.attributes;if(null==v)var r=null;else{k={};for(r of v)r.name.trim().startsWith("X-")&&(k[r.name]=r.value);r=_.Yg(k)?k:null}}r=r||{};(k=_.J(d,"CUE"))&&(r.CUE=k.split(","));if(m===_.ud){k=d.attributes;if(null==k)var u=null;else{m={};for(u of k)switch(u.name){case _.Zb:m[_.Zb]=u.value;break;case _.Yb:m[_.Yb]=u.value;break;case _.ac:m[_.ac]=PJ(u.value);break;case _.$b:m[_.$b]=PJ(u.value);break;
41
+ case "X-SNAP":m["X-SNAP"]=u.value.split(",");break;case "X-RESTRICT":m["X-RESTRICT"]=u.value.split(",")}m[_.Zb]&&m[_.Yb]||!m[_.Zb]&&!m[_.Yb]?(_.Rt.warn("Invalid EXT-X-DATERANGE Interstitial attributes X-ASSET-URI, X-ASSET-LIST"),u=null):u=_.Yg(m)?m:null}if(null===u){_.Rt.warn("Invalid interstitial attributes, ignoring the EXT-X-DATERANGE tag.",d);d=null;break a}r=Object.assign(r,u)}_.Yg(r)&&(g.customAttributes=r);g.endTime=n?n.getTime()/1E3+e:f?h+f:l?h+l:h;g.type=_.Jh;d=g}}return d}).filter(Boolean)},
42
+ FL=function(a,b){const c=new Set(b.map(d=>d.id));a.o.forEach((d,e)=>{c.has(e)||a.o.delete(e)});for(const d of b){if((b=a.o.get(d.id))&&b.startTime!==d.startTime)a.D.onError(new _.H(1,4,4044,"EXT-X-DATERANGE START-DATE has changed for"+` ID=${d.id}`));const e={configurationId:a.D.configurationId,schemeIdUri:d.schemeIdUri,customAttributes:d.customAttributes,value:"",startTime:d.startTime,endTime:d.endTime,id:d.id,type:_.Jh,eventElement:null};b&&!OJ(b,e)||a.o.set(d.id,e)}return Array.from(a.o.values())},
43
+ QL=function(a,b,c){a.l=_.Sb;_.hD(b,!0);b.f=c[c.length-1].endTime},BL=function(a,b,c,d){a=GK(a.M,b,c);a.a=d;return a},CL=function(a,b){return _.x(function*(){var c=rK(b.Fc.closedCaptions),d=RL(a,b.pd),e=yield SL(a,b),f=Object.values(e).flat().map(h=>h.playlist);KL(a,f);f=f[0];var g=bK(f.aa);a.l=g;a.I=gK(f.aa);f=oK(f.aa,g,a.a.lowLatencyMode||!1,a.a.suggestedPresentationDelay);g=yield TL(a,e.ff,d);c=yield UL(a,e.pd,g,c);d=yield VL(a,e.Rh,d);g=yield WL(a,e.he);d=uL(a.D.configurationId,c,d,g,!EL(a));a.D.filterAllPeriods(d);
44
+ c=[...e.pd,...e.ff].map(h=>h.playlist);e=OL(a,c);c=PL(a,c,e);return{periods:d,Bh:e,Uh:c,nh:f}})},LL=function(a,b){return _.x(function*(){const c=g=>pK(g.stream).type===_.w||pK(g.stream).type===_.p;var d=b.filter(c),e=b.filter(g=>!c(g)),f=g=>{g=g.map(h=>{var k=pK(h.stream);k={language:k.language,channelsCount:k.channelsCount,spatialAudio:k.spatialAudio,closedCaptions:k.closedCaptions,primary:k.primary,kind:k.kind||null,groupId:k.groupId,type:k.type,codecs:k.codecs,name:k.originalId,uri:k.Fa,Sd:{width:k.width,
45
+ height:k.height,frameRate:k.frameRate}};h=Object.assign({},{playlist:h.playlist},k);return XL(a,h)});return Promise.all(g)};d=yield f(d);f=yield f(e);YL(a,d.concat(f));e=f.filter(g=>pK(g).type===_.gC);f=f.filter(g=>pK(g).type===_.fe);return{textStreams:e,thumbStreams:f,yg:d}})},ML=function(a,b,c,d){const e=[],f=(c||b).length();for(let m=0;m<f;m++){var g=b?b.streams[m]||null:null,h=c?c.streams[m]||null:null,k=g,l=h;k=k&&l?_.HC(k.drmInfos,l.drmInfos)?_.GC(k.drmInfos,l.drmInfos):null:k?k.drmInfos:l?
46
+ l.drmInfos:null;if(!k)return null;l=d;g={id:a.R++,language:g?g.language:_.eg,primary:!!g&&g.primary||!!h&&h.primary,audio:g,video:h,bandwidth:l,drmInfos:k,allowedByApplication:!0,allowedByKeySystem:!0};e.push(g)}return new ZL(e)},XL=function(a,b){return _.x(function*(){const c=b.playlist,d=b.codecs,e=b.type,f=b.cd,g=b.groupId,h=b.primary;var k=b.kind;const l=b.name,m=b.channelsCount,n=b.spatialAudio,r=b.closedCaptions,u=b.Sd,v=_.zi(f||_.eg);if(1!==c.type)throw new _.H(_.F,4,4017);const z=yield $L(a,
47
+ c,e,d),A=a.a.lowLatencyMode?_.WB:_.VB;let E=k;e!==_.G||k||(E=_.gC);k=z.map(I=>{const X=I.T,ub=I.Jg,ne=I.mimeType;I=I.la;const lf=X[0].startTime,mf=X[X.length-1].endTime,Ya=mf-lf,Bb=new _.lJ(X),Tc=X[0].initSegment||null;return{id:_.hJ++,originalId:l,createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:Bb.f.bind(Bb),getSegmentReference:Bb.get.bind(Bb),adjustSegmentDurations:Bb.h.bind(Bb),getDuration:Bb.getDuration.bind(Bb),segmentIndex:Bb,segmentLookupStrategy:A,initSegmentReference:Tc,
48
+ mimeType:ne,codecs:d,kind:E,uf:ub.type,encrypted:ub.type===JJ,aesEncrypted:!!ub.keyInfo,keyId:ub.keyId,language:v,originalLanguage:f||_.eg,label:l,type:e,primary:h,trickModeVideo:null,emsgSchemeIdUris:null,frameRate:u?u.frameRate:void 0,width:u?u.width:void 0,height:u?u.height:void 0,bandwidth:void 0,roles:[],channelsCount:m,spatialAudio:n,closedCaptions:r,T:X,drmInfos:ub.drmInfos,la:I,Fa:c.a,Ud:c.f,Gc:lf,me:mf,duration:Ya,groupId:g}});return new aM(k)})},YL=function(a,b){b.forEach(c=>{a.f.a.set(pK(c).Fa,
49
+ c)})},RL=function(a,b){const c=new Map;for(const f of b){var d=_.J(f,"AUDIO");b=_.J(f,_.Rb);var e=_.J(f,GJ);const g=bM(a,f);if(e){const h=_.dk(_.G,g);c.set(`${_.G}:${e}`,h);e=g.indexOf(h);-1<e&&g.splice(e,1)}d&&(e=cM(_.p,g),c.set(`${"audio"}:${d}`,e));b&&(d=cM(_.w,g),c.set(`${"video"}:${b}`,d))}return c},SL=function(a,b){return _.x(function*(){const c=yield Promise.all([dM(a,b.Fc.xg),dM(a,b.Fc.Sh),dM(a,b.pd),dM(a,b.he)]),[d,e,f,g]=c;return{ff:d,Rh:e,pd:f,he:g}})},TL=function(a,b,c){return _.x(function*(){if(0===
50
+ b.length)return new Map;var d=[eM(a,b[0],c)];yield d[0];d=d.concat(b.slice(1).map(e=>eM(a,e,c)));d=yield Promise.all(d);return qK(d)})},UL=function(a,b,c,d){return _.x(function*(){const e=new Set;var f=[...b];let g=0;var h=Infinity;for(let k=0;k<f.length;++k){const l=Number(LJ(f[k].tag,_.ka));l<h&&(h=l,g=k)}h=f.splice(g,1).pop();h=yield fM(a,h,c,d,e);f=f.map(k=>fM(a,k,c,d,e));f=yield Promise.all(f);f.splice(g,0,h);return f.reduce(_.xC,[])})},VL=function(a,b,c){return Promise.all(b.map(d=>eM(a,d,c)))},
51
+ WL=function(a,b){return Promise.all(b.map(c=>gM(a,c)))},EL=function(a){return a.l===_.Sb},dM=function(a,b){return _.x(function*(){return(yield Promise.all(b.map(c=>_.x(function*(){const d=yield hM(a,c);return d?{tag:c,playlist:d}:null})))).filter(Boolean)})},HL=function(a,b){return _.x(function*(){var c=new _.ji(pK(b).Ud);if(a.a.lowLatencyMode&&a.I&&a.I.lf){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={oh:d.position,uh:e&&0<e.length?f:null}}else d=
52
+ null;if(e=d)d=e.oh,e=e.uh,f=_.Rj(c.a.toString()),f._HLS_msn=d.toString(),null===e&&f._HLS_part&&delete f._HLS_part,null!==e&&(f._HLS_part=e.toString()),d=_.Qj(f,!0),d=new _.ri(d),_.ni(c,d)}const {response:g,text:h}=yield AL(a,c.toString());c=pK(b).Fa;d=pK(b).Ud;e=g.uri;d!==e&&(d=e,hL(b,d));c=BL(a,h,d,c);return{stream:b,playlist:c}})},bM=function(a,b){var c=_.J(b,_.na,a.a.hlsDefaultCodecs||"avc1.42E01E,mp4a.40.2").split(/\s*,\s*/);b=new Set;const d=[];for(const e of c)c=_.MC(e),b.has(c)?a.g.debug("Ignoring duplicate codec"):
53
+ (d.push(e),b.add(c));return d},cM=function(a,b){if(1===b.length)return b[0];a=_.dk(a,b);if(null!=a)return a;throw new _.H(_.F,4,4025,{codecList:b});},eM=function(a,b,c){return _.x(function*(){const d=b.tag,e=b.playlist;return iM(a,e.a,()=>_.x(function*(){const f=LJ(d,_.Sa),g=cK(LJ(d,_.Ib));var h=LJ(d,_.Ib).toUpperCase();if(cK(h)!==_.G)h=null;else{var k=d.getAttribute("FORCED");k=!(!k||!k.value||"YES"!==k.value.toUpperCase());var l=_.gC;h===yJ&&(l=_.QB);k&&(l=_.$d);h=l}k=c.get(`${g}:${f}`)||"";l=_.J(d,
54
+ _.Za);const m=_.J(d,"NAME"),n=d.getAttribute("DEFAULT"),r=d.getAttribute("AUTOSELECT");var u=_.J(d,"CHANNELS");u=g===_.p?u?parseInt(u.split("/")[0],10):null:null;var v=g===_.p?(v=_.J(d,"CHANNELS"))?v.includes("/JOC"):!1:!1;return yield XL(a,{playlist:e,codecs:k,type:g,cd:l,primary:!!n&&!!r,name:m,channelsCount:u,spatialAudio:v,groupId:f,kind:h,closedCaptions:null,Sd:null})}))})},gM=function(a,b){return _.x(function*(){const c=b.tag,d=b.playlist;return iM(a,d.a,()=>_.x(function*(){var e=_.J(c,_.na)||
55
+ "jpg",f=_.J(c,_.Za);const g=_.J(c,"NAME");e=yield XL(a,{playlist:d,codecs:e,type:_.fe,cd:f,name:g,primary:!1,kind:null,channelsCount:null,spatialAudio:!1,closedCaptions:null,groupId:null,Sd:null});(f=_.J(c,_.ka))&&lL(e,Number(f));return e}))})},fM=function(a,b,c,d,e){return _.x(function*(){var f=b.tag,g=Number(LJ(f,_.ka));if(f.hasAttribute("FRAME-RATE")||f.hasAttribute(_.yb)){var h=_.J(f,"FRAME-RATE");f=_.J(f,_.yb);var [k,l]=f?f.split("x"):[null,null];h={frameRate:PJ(h),width:PJ(k),height:PJ(l)}}else h=
56
+ null;if(f=yield jM(a,b,h,c,d)){h=f.video;f=f.audio;var m=0<f.length?f:[null];h=0<h.length?h:[null];f=[];for(const n of m)for(const r of h){m=(r?pK(r).Fa:"")+" - "+(n?pK(n).Fa:"");if(e.has(m)){a.g.debug("Skipping variant which only differs in text streams.");continue}const u=ML(a,n,r,g);null==u?a.g.warn("Incompatible DRM info in HLS variant. Skipping."):(f.push(u),e.add(m))}g=f}else g=[];return g})},jM=function(a,b,c,d,e){return _.x(function*(){var f=b.tag,g=b.playlist;let h=bM(a,f);var k=_.J(f,"AUDIO"),
57
+ l=_.J(f,_.Rb);k=k?d.get(`${"audio"}:${k}`)||[]:[];var m=l?d.get(`${"video"}:${l}`)||[]:[];l=[...k,...m];k={audio:k,video:m};a.g.debug("Guessing stream type for",f.toString());f=!1;const n=g.a;g=k.audio.find(r=>pK(r).Fa===n);m=_.dk(_.w,h);m=c||m;1!==h.length||m?!l.length&&1<h.length?(a.g.debug("Guessing multiplexed audio+video"),g=_.w,h=[h.join(",")]):k.audio.length&&g?(a.g.debug(DJ),g=_.p,f=!0):k.video.length?(a.g.debug(DJ),g=_.p):(a.g.debug("Guessing video-only"),g=_.w):(g=_.p,a.g.debug(DJ));m=null;
58
+ f||(m=yield kM(a,b,h,g,e,c));if(null==m)return null;k[g]=[m];g===_.p&&c&&l.forEach(r=>{iL(r,c.width);jL(r,c.height);kL(r,c.frameRate)});tK(k);return k})},kM=function(a,b,c,d,e,f){return _.x(function*(){const g=b.tag,h=b.playlist;return iM(a,h.a,()=>_.x(function*(){var k=_.J(g,yJ);let l=null;d===_.w&&k&&"NONE"!==k&&(l=e.get(k));k=cM(d,c);return yield XL(a,{playlist:h,codecs:k,type:d,closedCaptions:l,primary:!1,kind:null,cd:null,name:null,channelsCount:null,spatialAudio:!1,groupId:null,Sd:f})}))})},
59
+ iM=function(a,b,c){if(a.f.has(b))return a=a.f.get(b),Promise.resolve(a);if(a.f.f.has(b))return a.f.f.get(b)||null;c=c();a.f.set(b,c);return c},$L=function(a,b,c,d){return _.x(function*(){var e=b.a,f=b.T;var g=void 0===g?0:g;var h=(h=VJ(b.aa,_.Ga))?Number(h.value):g;g=[];!EL(a)&&YK(f);e=yield lM(a,b.f,e,f,h,c,d);if(0===f.length)f=[];else{var k=[],l=[];for(var m of f)UJ(m.aa,_.Ba)&&0<l.length&&(k.push(l),l=[]),l.push(m);k.push(l);f=k}for(m=0;m<f.length;m++)k=f[m],l=yield mM(a,b.f,k,h,e,c,d,g[g.length-
60
+ 1]||null,f.length),g.push(l),h+=k.length;nM(g);return g})},hM=function(a,b){return _.x(function*(){var c="EXT-X-MEDIA"!==b.name?!0:_.J(b,_.Ib)===GJ;c=_.J(b,_.Lb,void 0,{required:c});if(!c)return null;const d=XJ(a.w,c),{response:e,text:f}=yield AL(a,d);return BL(a,f,e.uri,c)})},nM=function(a){if(1<(new Set(a.map(b=>b.mimeType))).size)throw new _.H(_.F,4,4045,"Media playlist contains discontinuities with different MIME types. This is valid, but not yet supported.");},oM=function(a){a=a.map(b=>b.a?b.a:
61
+ b.f.map(c=>_.J(c,_.Lb))||null).map(b=>_.Ot(b));if(1<(new Set(a)).size)throw new _.H(_.F,4,4044,"Unexpected change in file format.");},pM=function(a,b,c){a=RJ(a.aa,_.Fa);if(1<a.length)throw new _.H(_.F,4,4020);a=a[0];if(!a)return null;const d=LJ(a,_.Lb),e=XJ(b,d);b=hK(a,null,!0);return new _.gJ(()=>[e],b.xa,b.ma,c)},qM=function(a,b,c,d,e,f,g){const h=[];for(const r of QJ(b.f)){b=r.Hf;const u=r.item;{var k=0===b,l=k?a:h[h.length-1],m=k?d:l.endTime,n=Number(_.J(u,AJ));n=m+n;k=hK(u,k?null:l.ma,k);l=_.J(u,
62
+ _.Lb);const v=(l=XJ(g,l))?[l]:[];m=new iK(c,m,n,()=>v,k.xa,k.ma,e,f,!1,null,null,null,null);if("YES"===_.J(u,"INDEPENDENT")||0===b)m.h=!0;h.push(m)}}return h},rM=function(a,b,c,d,e,f,g,h,k,l,m){const n=c.aa;var r=c.a;0<RJ(n,_.Fa).length&&(m=pM(c,k,g));const u=null!=r,v=r?[r]:[];if(!u&&!a.a.lowLatencyMode)return null;a=0;r={xa:0,ma:null};let z=null;u?({duration:c}=fK(n),a=e+c,r=eK(n,b?b.ma:null)):(b=qM(b,c,d,e,f,g,k),a=b[b.length-1].endTime,z=b);h=h===_.fe?WJ(n):null;d=new iK(d,e,a,()=>v,r.xa,r.ma,
63
+ f,g,!1,null,h?h.Wc:null,h?h.od:null,h?h.durationPerTile:null,z,m);d.la=l;return d},lM=function(a,b,c,d,e,f,g){return _.x(function*(){var h=d[0];if(null!=a.A)return a.A;if(!EL(a)&&a.B)try{var k=a.f.get(c);var l=k?gL(k,e)||null:null;if(!l)throw new _.H(_.F,4,4030,"Segment not found in pervious playlist update.");var m=l.startTime+l.Ea;a.g.debug(`Setting playlist start time to ${m}.`);return a.A=m}catch(n){if(h=a.f.get(c))m=h.streams[h.streams.length-1].T,m=m[m.length-1],a.g.warn(`Last #EXT-X-MEDIA-SEQUENCE values ${h.streams[0].T[0].position} - ${m.position}`+
64
+ `, new values ${e} - ${e+d.length-1}.`,b,h);throw new _.H(_.F,4,4047,{message:"The updated playlist does not share any segments with the previous one.",uri:c});}m=yield sM(a,f,g,h);k=ZK(h.aa,a.w,m)||UK();l=pM(h,b,k.keyInfo);k=kK(k.keyInfo,e);h=yield tM(a,l,h,k,m,g);a.g.debug(`Setting playlist start time to ${h}.`);return a.A=h})},mM=function(a,b,c,d,e,f,g,h,k){return _.x(function*(){var l=c[0],m=null==h;oM(c);const n=yield sM(a,f,g,l);var r=a.w,u=h?h.mh:null;var v=1===k;if(c.slice(1).some(XK))throw new _.H(_.F,
65
+ 4,4046,v?"Media playlist contains an EXT-X-KEY tag with METHOD\x3dAES-128 which is not at the beginning of the playlist.":"Media playlist contains an EXT-X-KEY tag with METHOD\x3dAES-128 which is not marked by an EXT-X-DISCONTINUITY tag and is not at the beginning of the playlist.");if(UJ(c[0].aa,_.Ea)||null===u)if((u=ZK(c[0].aa,r,n))&&u.type===KJ){if(1<aL(c))throw new _.H(_.F,4,4046,HJ+`${v?"playlist":"discontinuity"}.`);v=[u]}else v=$K(c,r,n),v=0===v.length?[UK()]:v;else if(r=$K(c,r,n),u.type===
66
+ _.Ge||u.type===JJ)v=[u,...r];else{if(0<aL(c))throw new _.H(_.F,4,4046,HJ+`${v?"playlist":"discontinuity"}.`);v=[u]}r=v;v=r[r.length-1];r=VK(r);u=pM(l,b,r.keyInfo)||(h?h.hh:null);var z=kK(r.keyInfo,d);const A=l.la;l=m?e:yield uM(a,A,u,l,d,z,n,g);m=[];for(z=0;z<c.length;z++){var E=c[z];const I=m[m.length-1]||null,X=0===z?0:I.endTime,ub=d+z,ne=kK(r.keyInfo,ub);if(E=rM(a,I,E,ub,X,l,ne,f,b,A,u))u=E.initSegment,m.push(E)}return{T:m,Jg:r,mh:v,mimeType:n,endTime:m[m.length-1].endTime,la:A,hh:u}})},sM=function(a,
67
+ b,c,d){return _.x(function*(){const e=d.a;var f=VJ(d.aa,_.Fa);f=f?LJ(f,_.Lb):null;return vM(a,b,c,e,f)})},tM=function(a,b,c,d,e,f){return _.x(function*(){if(null==c.a)return 0;const g=jK(c,d);return eL(a.O,b,g,e,f,null!=d)})},uM=function(a,b,c,d,e,f,g,h){return _.x(function*(){if(a.J.has(b))return a.J.get(b);const k=yield tM(a,c,d,f,g,h);a.g.debug(`Segment #${e} has raw media timestamp `+`${k} s.`);a.J.set(b,k);return k})},vM=function(a,b,c,d,e){return _.x(function*(){const f=[d,e].filter(Boolean);
68
+ var g=_.gk(f,b,c);if(g)return g;g=_.rj([d],a.a.attemptParameters);g.method="HEAD";g.type=2;g=(yield a.G(g)).headers["content-type"];if(!g)throw new _.H(_.F,4,4021,"Unknown MIME type of: "+f.join(", "));return g.split(";")[0]})},BK=class{constructor(a,b,c,d){if(1===b){if(!d||0===d.length)throw new _.H(_.F,4,4043,"Media playlist must have at least one segment!");if(null==d[0].a)throw new _.H(_.F,4,4043,"Media playlist must have at least one full segment!");}this.f=a;this.a="";this.type=b;this.aa=c;
69
+ this.T=1===b?d:null}},HK=class{constructor(a,b,c){c=void 0===c?[]:c;this.aa=b;this.a=a;this.f=c;this.la=-1}},iK=class extends _.xD{constructor(a,b,c,d,e,f,g,h,k,l,m,n,r,u,v){u=void 0===u?[]:u;super(a,b,c,d,e,f,g,void 0===h?null:h,void 0===k?!1:k,void 0===l?null:l,void 0===m?null:m,void 0===n?null:n,void 0===r?null:r,u,void 0===v?null:v);this.la=0}},wM=class{constructor(){this.f=0;this.a=new Map}},xM=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,
70
+ 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()}},JL=new _.S("clpp.hls.DiscontinuityUtils");var cL={"com.apple.streamingkeydelivery":function(a,b){if(b===_.sg)throw new _.H(_.F,4,4041);if(LJ(a,EJ)===FJ)throw new _.H(_.F,4,4044,"EXT-X-KEY:METHOD SAMPLE-AES-CTR is not supported in FairPlay.");return _.AC(_.td,[{initDataType:_.Nf,initData:new Uint8Array(0)}],"")},"com.microsoft.playready":TK,"urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":TK,"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":function(a){var b=LJ(a,EJ);if(!RK.includes(b))return SK.error("Widevine in HLS is only supported with [",
71
+ RK.join(", "),"], not",b),null;b=LJ(a,_.Lb);b=_.ct(b);b=_.K(b.data);b=_.AC(_.yd,[{initDataType:_.bd,initData:b}],"");if(a=_.J(a,"KEYID"))b.keyIds=[a.substr(2).toLowerCase()];return b}},RK=["SAMPLE-AES",FJ],SK=new _.S("clpp.hls.DrmParser");var bL=new _.S("clpp.hls.EncryptionUtils");var yM=class{constructor(a){this.g=new _.S("clpp.hls.MediaReader");this.f=a;this.a={attemptParameters:_.nj()}}};var aM=class{constructor(a){this.streams=a}length(){return this.streams.length}};var ZL=class{constructor(a){this.a=a}length(){return this.a.length}};var zM=class{constructor(){this.a=this.D=null;this.R=1;this.f=new xM;this.w="";this.M=new wM;this.F=0;this.j=null;this.h=new _.yk(()=>{this.Qb()});this.l=_.Sb;this.B=null;this.C=new _.Wt;this.I=this.A=null;this.g=new _.S("clpp.hls.HlsParser");this.J=new Map;this.O=new yM(this.G.bind(this));this.L=!1;this.H=null;this.K=!1;this.o=new Map}configure(a){this.a=a;this.O.a=a}setCurrentVariant(a){this.j=a}start(a,b){const c=this;return _.x(function*(){if(c.L)throw Error("start() may be called only once!");
72
+ c.L=!0;c.D=b;const {response:d,text:e}=yield AL(c,a);c.w=d.uri;const f=yield GL(c,e);c.B=f;const g=c.F;c.h&&0<g&&c.h.fa(g);return f})}requestStop(){this.K=!0}stop(){this.h&&(this.h.stop(),this.h=null);const a=[];this.C&&(a.push(this.C.destroy()),this.C=null);this.f.clear();this.B=this.a=this.D=this.j=null;this.o.clear();return Promise.all(a)}update(){const a=this;return _.x(function*(){const b=a.B;if(!EL(a)&&b){var c=b.presentationTimeline;"LIVE"===a.l&&(a.A=null);var d=Array.from(a.f.values());if(a.a.lowLatencyMode&&
73
+ null!==a.j){const g=zL(a);d=d.filter(h=>g.includes(pK(h).Fa))}var e=yield IL(a,d);d=e.map(g=>g.playlist);KL(a,d);e=yield NL(a,e);nL(b.periods,e).forEach(g=>{a.D.filterNewPeriod(g)});DL(a,e);var f=OL(a,d);f=PL(a,d,f);b.cues=FL(a,f);pL(b.periods,e);yL(c,e);if(d=$J(d))!0!==a.a.keepTimelineLive&&QL(a,c,e),a.h.stop(),a.h=null;if(a.D.onUpdate)a.D.onUpdate(b);if(d&&a.D.onTurnedStatic)a.D.onTurnedStatic();a.K&&(yield a.stop());return b}})}Qb(){const a=this;return _.x(function*(){a.g.debug(_.KB);if(a.D)try{yield a.update(),
74
+ a.h&&0<a.F&&a.h.fa(a.F)}catch(b){if(!(b instanceof _.H))throw b;a.D&&(a.D.onError(b),1===b.severity&&a.h&&a.h.fa(.1))}})}G(a){if(!this.C)throw new _.H(_.F,7,7001);a=this.D.networkingEngine.fetch(a);_.Cj(this.C,a);return a.U}};_.y("clpp.hls.HlsComponent",class extends _.Ru{f(){_.Hs.m3u8=zM;_.Fs[_.tl]=zM;_.Fs[IJ]=zM}a(){_.WD("m3u8");_.XD(_.tl);_.XD(IJ)}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 OT=function(a){a.a.one(a.m,_.pe,()=>NT(a))},NT=function(a){const b=a.m.getSurface().getMedia();if(b)if(a.h){a.a.on(b.textTracks,_.wc,d=>PT(a,d));var c=Array.from(b.textTracks);c.filter(d=>d.kind===_.ze).forEach(d=>{PT(a,{track:d})});!QT(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."),RT(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.")},PT=function(a,b){b=b.track;b.kind===_.ze&&(a.g.info("The metadata track has been added."),b.mode=_.ce,a.a.on(b,_.Ed,c=>ST(a,c)))},QT=function(a){return a.some(b=>b.kind===_.ze)},RT=function(a,b){const c=a.m.getTrackManager(),d=c.oa(),e=c.getAudioTracks().find(g=>g!==d);if(e){var f=()=>c.ya(d);a.a.on(b.textTracks,_.wc,g=>{g.track.kind===_.ze&&(a.a.off(b.textTracks,_.wc,f),c.ya(d))});c.ya(e)}else a.g.warn("Can't enforce the creation of the metadata track if single audio track. Skipping.")},
3
- ST=function(a,b){const c=TT(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 UT(d);if(e.f===c&&null!==e.a){a.f=d;d=a.h.parseMedia(_.Pi(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)}}})},TT=function(a){return(a=a.m.getTrackManager().wa())&&a.language&&a.language.toLowerCase()},
4
- UT=class{constructor(a){this.startTime=a.startTime;this.endTime=a.endTime;this.a=this.f=null;a=a.value;if(!_.B(a)){a:{var b=a.info;if(_.$g(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=_.$g(a)?a:null}}};var VT=class{constructor(a,b,c){this.m=a;this.l=b;this.j=c;this.a=new _.jt;this.h=(a=_.Ys(_.Gc))?new a(this.m.getConfiguration()):null;this.g=new _.S("clpp.hlssmpte.ImageCueHandler");this.f=null;OT(this)}destroy(){this.a.release();this.f=null;return Promise.resolve()}};var WT=class extends _.iv{constructor(){super();this.a=null;this.f=!1}onPlayerCreated(){}onContentWillLoad(a){if(this.f=_.Jk()){var b=a.getConfiguration();b=_.Ug(b.hlssmpte||{});typeof b.patchMetadataTrack!==_.Rc&&(b.patchMetadataTrack=!1);_.ah(b.timestampOffset)||(b.timestampOffset=0);this.a=new VT(a,b.patchMetadataTrack,b.timestampOffset)}}onPlayerWillDestroy(){const a=this;return _.x(function*(){a.a&&(yield a.a.destroy(),a.a=null)})}id(){return"hlssmpte"}};_.z("clpp.hlssmpte.HlsSmptePlugin",WT);
5
- WT.Id="hlssmpte";_.Yq(new class{create(){return new WT}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var fU=function(a){a.a.one(a.m,_.te,()=>eU(a))},eU=function(a){const b=a.m.getSurface().getMedia();if(b)if(a.h){a.a.on(b.textTracks,_.vc,d=>gU(a,d));var c=Array.from(b.textTracks);c.filter(d=>d.kind===_.Ae).forEach(d=>{gU(a,{track:d})});!hU(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."),iU(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.")},gU=function(a,b){b=b.track;b.kind===_.Ae&&(a.g.info("The metadata track has been added."),b.mode=_.de,a.a.on(b,_.Dd,c=>jU(a,c)))},hU=function(a){return a.some(b=>b.kind===_.Ae)},iU=function(a,b){const c=a.m.getTrackManager(),d=c.na(),e=c.getAudioTracks().find(g=>g!==d);if(e){var f=()=>c.wa(d);a.a.on(b.textTracks,_.vc,g=>{g.track.kind===_.Ae&&(a.a.off(b.textTracks,_.vc,f),c.wa(d))});c.wa(e)}else a.g.warn("Can't enforce the creation of the metadata track if single audio track. Skipping.")},
3
+ jU=function(a,b){const c=kU(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 lU(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)}}})},kU=function(a){return(a=a.m.getTrackManager().va())&&a.language&&a.language.toLowerCase()},
4
+ lU=class{constructor(a){this.startTime=a.startTime;this.endTime=a.endTime;this.a=this.f=null;a=a.value;if(!_.B(a)){a:{var b=a.info;if(_.bh(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=_.bh(a)?a:null}}};var mU=class{constructor(a,b,c){this.m=a;this.l=b;this.j=c;this.a=new _.st;this.h=(a=_.gt(_.Fc))?new a(this.m.getConfiguration()):null;this.g=new _.S("clpp.hlssmpte.ImageCueHandler");this.f=null;fU(this)}destroy(){this.a.release();this.f=null;return Promise.resolve()}};var nU=class extends _.rv{constructor(){super();this.a=null;this.f=!1}onPlayerCreated(){}onContentWillLoad(a){if(this.f=_.Mk()){var b=a.getConfiguration();b=_.Wg(b.hlssmpte||{});typeof b.patchMetadataTrack!==_.Qc&&(b.patchMetadataTrack=!1);_.ch(b.timestampOffset)||(b.timestampOffset=0);this.a=new mU(a,b.patchMetadataTrack,b.timestampOffset)}}onPlayerWillDestroy(){const a=this;return _.x(function*(){a.a&&(yield a.a.destroy(),a.a=null)})}id(){return"hlssmpte"}};_.y("clpp.hlssmpte.HlsSmptePlugin",nU);
5
+ nU.Id="hlssmpte";_.gr(new class{create(){return new nU}});};f.call(g, window);