@castlabs/prestoplay 6.6.1 → 6.7.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 (59) hide show
  1. package/CHANGELOG.md +13 -1
  2. package/cjs/cl.adobe.js +3 -3
  3. package/cjs/cl.airplay.js +3 -3
  4. package/cjs/cl.broadpeak.js +6 -6
  5. package/cjs/cl.cast.js +110 -110
  6. package/cjs/cl.conviva.js +33 -33
  7. package/cjs/cl.core.js +423 -423
  8. package/cjs/cl.crypto.js +10 -10
  9. package/cjs/cl.dash.js +71 -71
  10. package/cjs/cl.externs.js +47 -41
  11. package/cjs/cl.freewheel.js +24 -24
  12. package/cjs/cl.hls.js +68 -49
  13. package/cjs/cl.hlssmpte.js +6 -6
  14. package/cjs/cl.htmlcue.js +31 -31
  15. package/cjs/cl.ima.js +24 -23
  16. package/cjs/cl.mse.js +263 -260
  17. package/cjs/cl.muxdata.js +11 -12
  18. package/cjs/cl.onboard.js +3 -3
  19. package/cjs/cl.persistent.js +14 -14
  20. package/cjs/cl.playlist.js +6 -6
  21. package/cjs/cl.smooth.js +71 -71
  22. package/cjs/cl.thumbnails.js +23 -23
  23. package/cjs/cl.tizen.js +71 -71
  24. package/cjs/cl.ttml.js +27 -27
  25. package/cjs/cl.verimatrix.js +5 -5
  26. package/cjs/cl.vimond.js +13 -13
  27. package/cjs/cl.vr.js +19 -19
  28. package/cjs/cl.vtt.js +14 -14
  29. package/cjs/cl.youbora.js +19 -19
  30. package/cl.adobe.js +3 -3
  31. package/cl.airplay.js +3 -3
  32. package/cl.broadpeak.js +5 -5
  33. package/cl.cast.js +88 -88
  34. package/cl.conviva.js +27 -27
  35. package/cl.core.js +346 -344
  36. package/cl.crypto.js +8 -8
  37. package/cl.dash.js +67 -67
  38. package/cl.externs.js +47 -41
  39. package/cl.freewheel.js +19 -19
  40. package/cl.hls.js +57 -40
  41. package/cl.hlssmpte.js +5 -5
  42. package/cl.htmlcue.js +25 -25
  43. package/cl.ima.js +17 -16
  44. package/cl.mse.js +228 -228
  45. package/cl.muxdata.js +9 -8
  46. package/cl.onboard.js +4 -4
  47. package/cl.persistent.js +10 -10
  48. package/cl.playlist.js +5 -5
  49. package/cl.smooth.js +58 -59
  50. package/cl.thumbnails.js +17 -17
  51. package/cl.tizen.js +57 -57
  52. package/cl.ttml.js +22 -22
  53. package/cl.verimatrix.js +4 -4
  54. package/cl.vimond.js +8 -8
  55. package/cl.vr.js +15 -15
  56. package/cl.vtt.js +12 -12
  57. package/cl.youbora.js +14 -14
  58. package/package.json +1 -1
  59. package/typings.d.ts +108 -7
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 HI="clpp-freewheel",II="clpp.freewheel.AdsManagerFactory",JI="freewheel",KI=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""}},LI=function(a){const b=[];typeof a.networkId!==_.p&&b.push("networkId");typeof a.serverUrl!==_.ne&&b.push("serverUrl");typeof a.profileId!==_.ne&&b.push("profileId");typeof a.videoAssetId!==_.ne&&typeof a.videoAssetId!==_.p&&b.push("videoAssetId");
2
- if(b.length)throw new _.G(1,9,12001,{missingKeys:b.join(", ")});},MI=function(){return _.w(function*(){var a=new _.dq;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})},NI=function(a){a.g.on(a.a,tv.freewheel.SDK.EVENT_REQUEST_COMPLETE,a.H.bind(a));a.g.on(a.a,tv.freewheel.SDK.EVENT_SLOT_STARTED,a.J.bind(a));a.g.on(a.a,
3
- tv.freewheel.SDK.EVENT_SLOT_ENDED,a.I.bind(a));a.g.on(a.a,tv.freewheel.SDK.EVENT_AD,a.G.bind(a));a.g.on(a.l,_.ve,a.F.bind(a));a.g.on(a.l,_.ke,a.C.bind(a))},QI=function(a){return _.w(function*(){a.A.length?(OI(a),a.f=a.A.shift(),a.f.play()):(PI(a),yield a.l.a.play())})},PI=function(a){const b=a.l.Tb(JI).mc();b&&a.l.getSurface().hide(b);a.l.getSurface().showMediaElement()},OI=function(a){const b=a.l.Tb(JI).mc();b&&(a.l.getSurface().show(b),a.l.getSurface().hideMediaElement(),a.a.registerVideoDisplayBase(HI),
4
- a.l.isMuted()?a.setVolume(0):a.setVolume(a.l.getVolume()||1))},RI=function(a){a.w.length?(OI(a),a.f=a.w.shift(),a.f.play()):PI(a)},SI=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 W(a.a,c,d)});a.l.trigger(new _.C(b,d))},TI=class extends _.jq{constructor(){super();this.f=this.a=null}onPlayerCreated(a){if(window.tv&&tv.freewheel&&tv.freewheel.SDK)this.a=_.lm(_.Qc,{id:HI}),this.f=_.lm(_.u,{"class":_.yc}),this.a.appendChild(this.f),a.getSurface().addElementToContainer(this.a,
5
- !0),a.getSurface().hide(this.a);else a.onError(new _.G(1,9,12E3))}onPlayerWillDestroy(a){this.a&&(a.getSurface().removeElementFromContainer(this.a),this.f=this.a=null)}id(){return JI}mc(){return this.a}pf(){return this.f}};_.x("clpp.freewheel.FreeWheelPlugin",TI);TI.prototype.getAdVideo=TI.prototype.pf;TI.prototype.getAdContainer=TI.prototype.mc;TI.Id=JI;TI.AD_CONTAINER_ID=HI;_.Sm(new class{create(){return new TI}});var W=class{constructor(a,b,c){this.g=a;this.f=b;this.a=c}mb(){return"FreeWheel AdManager SDK"}nb(){return tv.freewheel.SDK.version}sb(){return 0}getId(){return this.a?this.a.getAdId():""}getCreativeId(){const a=(this.a||{})._creativeId;return typeof a===_.ne?a:""}getApiFramework(){return this.a?this.a.getActiveCreativeRendition().getCreativeApi():""}getAdSystem(){return""}getAdvertiserName(){return""}getTitle(){return""}getDuration(){return this.a?this.a.getActiveCreativeRendition().getDuration():
6
- 0}getSkipTimeOffset(){return 0}Xb(){return!1}Db(){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():""}pb(){return this.a?this.a.getActiveCreativeRendition().getWidth():0}ob(){return this.a?this.a.getActiveCreativeRendition().getHeight():0}cb(){return 0}Oa(){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.Oa()){case 0:return 0;case 2:return-1}return this.g.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL).indexOf(this.f)+1}Eb(){switch(this.Oa()){case 0:return 0;case 2:return-1;default:return this.f.getTimePosition()}}Fb(){return this.a?this.f.getAdInstances().indexOf(this.a)+1:1}rb(){return this.f.getAdCount()}getWrapperAdIds(){return[]}getWrapperAdSystems(){return[]}getWrapperCreativeIds(){return[]}};
8
- W.prototype.getWrapperCreativeIds=W.prototype.getWrapperCreativeIds;W.prototype.getWrapperAdSystems=W.prototype.getWrapperAdSystems;W.prototype.getWrapperAdIds=W.prototype.getWrapperAdIds;W.prototype.getSequenceLength=W.prototype.rb;W.prototype.getPositionInSequence=W.prototype.Fb;W.prototype.getPodTimeOffset=W.prototype.Eb;W.prototype.getPodIndex=W.prototype.getPodIndex;W.prototype.getPodType=W.prototype.Oa;W.prototype.getMediaBitrate=W.prototype.cb;W.prototype.getMediaHeight=W.prototype.ob;
9
- W.prototype.getMediaWidth=W.prototype.pb;W.prototype.getMediaUrl=W.prototype.getMediaUrl;W.prototype.getClickThroughUrl=W.prototype.Db;W.prototype.isBumper=W.prototype.Xb;W.prototype.getSkipTimeOffset=W.prototype.getSkipTimeOffset;W.prototype.getDuration=W.prototype.getDuration;W.prototype.getTitle=W.prototype.getTitle;W.prototype.getAdvertiserName=W.prototype.getAdvertiserName;W.prototype.getAdSystem=W.prototype.getAdSystem;W.prototype.getApiFramework=W.prototype.getApiFramework;
10
- W.prototype.getCreativeId=W.prototype.getCreativeId;W.prototype.getId=W.prototype.getId;W.prototype.getTechnology=W.prototype.sb;W.prototype.getAdManagerVersion=W.prototype.nb;W.prototype.getAdManagerName=W.prototype.mb;var UI=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}eb(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL).length}};
11
- UI.prototype.hasPostroll=UI.prototype.eb;UI.prototype.hasPreroll=UI.prototype.Gb;UI.prototype.getCuePoints=UI.prototype.getCuePoints;var VI=class{constructor(a){this.B=new _.O("clpp.freewheel.AdsManager");this.l=a;this.g=new _.uo;this.o=new tv.freewheel.SDK.AdManager;this.f=this.a=null;this.A=[];this.m=[];this.w=[];this.j=new _.Xk;this.h=null}load(){const a=this;return _.w(function*(){const b=a.l.getConfiguration().freewheel||{};try{LI(b)}catch(d){return a.l.onError(d),a.j.resolve(),a.j}a.o.setNetwork(b.networkId);a.o.setServer(b.serverUrl);a.a=a.o.newContext();a.a.setProfile(b.profileId);typeof b.siteSectionId!==_.ne&&typeof b.siteSectionId!==
12
- _.p||a.a.setSiteSection(b.siteSectionId);const c=yield MI();a.a.setVideoAsset(b.videoAssetId,a.l.getDuration(),void 0,void 0,c);if(Array.isArray(b.pods))for(const d of b.pods)a.a.addTemporalSlot(d.id,KI(d.type),d.position,d.slotProfile,d.cuepointSequence,d.maxDuration,d.minDuration,d.acceptContentType);b.keyValues&&typeof b.keyValues===_.Bd&&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);NI(a);a.a.submitRequest();return a.j})}start(){const a=this;return _.w(function*(){yield QI(a)})}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}dispose(){const a=this;return _.w(function*(){a.g.release();
14
- a.h&&(a.h.stop(),a.h=null);PI(a);a.a&&(a.a.dispose(),a.a=null)})}H(a){if(a.success)this.A=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL),this.m=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL),this.w=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL),this.l.trigger(new _.C(_.Ob,{adsTimeline:new UI(this.a)})),this.h=new _.bq(this.l.getSurface(),(b,c)=>this.a.resize(b,c),this.l.Tb(JI).f);else this.l.onError(new _.G(1,
15
- 9,10003,{errorType:0},void 0));this.j.resolve()}J(a){SI(this,_.wb,a);this.h.start()}I(a){this.f=null;a=a.slot;SI(this,_.xb);this.h.stop();if(a)switch(a.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:QI(this);break;case tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL:PI(this);this.l.play();break;case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:RI(this)}}G(a){const b=a.subType;this.B.debug("ad event",b);switch(b){case tv.freewheel.SDK.EVENT_AD_IMPRESSION:SI(this,_.Kb,a);SI(this,
16
- _.Db,a);break;case tv.freewheel.SDK.EVENT_AD_IMPRESSION_END:SI(this,_.Lb,a);break;case tv.freewheel.SDK.EVENT_AD_FIRST_QUARTILE:SI(this,_.Cb,a);break;case tv.freewheel.SDK.EVENT_AD_MIDPOINT:SI(this,_.Fb,a);break;case tv.freewheel.SDK.EVENT_AD_THIRD_QUARTILE:SI(this,_.Mb,a);break;case tv.freewheel.SDK.EVENT_AD_COMPLETE:SI(this,_.Bb,a);break;case tv.freewheel.SDK.EVENT_AD_CLICK:SI(this,_.Ab,a);break;case tv.freewheel.SDK.EVENT_AD_PAUSE:SI(this,_.Gb,a);break;case tv.freewheel.SDK.EVENT_AD_RESUME:SI(this,
17
- _.Ib,a);break;case tv.freewheel.SDK.EVENT_AD_SKIPPED:SI(this,_.Jb,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_START:SI(this,_.zb,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_END:SI(this,_.Hb,a);break;case tv.freewheel.SDK.EVENT_ERROR:this.l.onError(new _.G(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]}))}}F(){if(!this.f){var a=this.l.getPosition();if(this.f=this.m.find(b=>
18
- .5>Math.abs(a-b.getTimePosition()))||null){const b=this.m.findIndex(c=>c===this.f);this.m.splice(b,1);this.l.pause();OI(this);this.f.play()}}}C(a){if((a=a.detail)&&this.a)switch(a.currentState){case _.Sl:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PLAYING);break;case _.Rl:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PAUSED);break;case _.Hl:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_COMPLETED);RI(this);break;case _.Pl:case _.Ol:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_STOPPED)}}};
19
- VI.prototype.getPosition=VI.prototype.getPosition;VI.prototype.setVolume=VI.prototype.setVolume;VI.prototype.getVolume=VI.prototype.getVolume;VI.prototype.skip=VI.prototype.skip;VI.prototype.pause=VI.prototype.pause;VI.prototype.resume=VI.prototype.resume;VI.prototype.start=VI.prototype.start;var WI=class{constructor(){this.a=new _.O(II)}name(){return II}da(a,b){return a.namespace()===_.Ac?!1:window.tv&&tv.freewheel&&tv.freewheel.SDK?!(!b||!b.freewheel):(this.a.warn("FreeWheel SDK is not loaded."),!1)}create(a){return new VI(a)}};WI.prototype.create=WI.prototype.create;WI.prototype.isSupported=WI.prototype.da;WI.prototype.name=WI.prototype.name;_.im(new WI);};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var RJ="clpp-freewheel",SJ="clpp.freewheel.AdsManagerFactory",TJ="freewheel",UJ=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""}},VJ=function(a){const b=[];typeof a.networkId!==_.r&&b.push("networkId");typeof a.serverUrl!==_.ne&&b.push("serverUrl");typeof a.profileId!==_.ne&&b.push("profileId");typeof a.videoAssetId!==_.ne&&typeof a.videoAssetId!==_.r&&b.push("videoAssetId");
2
+ if(b.length)throw new _.H(1,9,12001,{missingKeys:b.join(", ")});},WJ=function(){return _.y(function*(){var a=new _.eq;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})},XJ=function(a){a.g.on(a.a,tv.freewheel.SDK.EVENT_REQUEST_COMPLETE,a.H.bind(a));a.g.on(a.a,tv.freewheel.SDK.EVENT_SLOT_STARTED,a.J.bind(a));a.g.on(a.a,
3
+ tv.freewheel.SDK.EVENT_SLOT_ENDED,a.I.bind(a));a.g.on(a.a,tv.freewheel.SDK.EVENT_AD,a.G.bind(a));a.g.on(a.l,_.ve,a.F.bind(a));a.g.on(a.l,_.ke,a.C.bind(a))},$J=function(a){return _.y(function*(){a.A.length?(YJ(a),a.f=a.A.shift(),a.f.play()):(ZJ(a),yield a.l.a.play())})},ZJ=function(a){const b=a.l.Vb(TJ).qc();b&&a.l.getSurface().hide(b);a.l.getSurface().showMediaElement()},YJ=function(a){const b=a.l.Vb(TJ).qc();b&&(a.l.getSurface().show(b),a.l.getSurface().hideMediaElement(),a.a.registerVideoDisplayBase(RJ),
4
+ a.l.isMuted()?a.setVolume(0):a.setVolume(a.l.getVolume()||1))},aK=function(a){a.w.length?(YJ(a),a.f=a.w.shift(),a.f.play()):ZJ(a)},bK=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 W(a.a,c,d)});a.l.trigger(new _.F(b,d))},cK=class extends _.kq{constructor(){super();this.f=this.a=null}onPlayerCreated(a){if(window.tv&&tv.freewheel&&tv.freewheel.SDK)this.a=_.lm(_.Qc,{id:RJ}),this.f=_.lm(_.w,{"class":_.yc}),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 TJ}qc(){return this.a}Af(){return this.f}};_.z("clpp.freewheel.FreeWheelPlugin",cK);cK.prototype.getAdVideo=cK.prototype.Af;cK.prototype.getAdContainer=cK.prototype.qc;cK.Id=TJ;cK.AD_CONTAINER_ID=RJ;_.Sm(new class{create(){return new cK}});var W=class{constructor(a,b,c){this.g=a;this.f=b;this.a=c}nb(){return"FreeWheel AdManager SDK"}ob(){return tv.freewheel.SDK.version}tb(){return 0}getId(){return this.a?this.a.getAdId():""}getCreativeId(){const a=(this.a||{})._creativeId;return typeof a===_.ne?a:""}getApiFramework(){return this.a?this.a.getActiveCreativeRendition().getCreativeApi():""}getAdSystem(){return""}getAdvertiserName(){return""}getTitle(){return""}getDuration(){return this.a?this.a.getActiveCreativeRendition().getDuration():
6
+ 0}getSkipTimeOffset(){return 0}Zb(){return!1}Gb(){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():""}qb(){return this.a?this.a.getActiveCreativeRendition().getWidth():0}pb(){return this.a?this.a.getActiveCreativeRendition().getHeight():0}eb(){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.g.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL).indexOf(this.f)+1}Hb(){switch(this.Qa()){case 0:return 0;case 2:return-1;default:return this.f.getTimePosition()}}Ib(){return this.a?this.f.getAdInstances().indexOf(this.a)+1:1}sb(){return this.f.getAdCount()}getWrapperAdIds(){return[]}getWrapperAdSystems(){return[]}getWrapperCreativeIds(){return[]}};
8
+ W.prototype.getWrapperCreativeIds=W.prototype.getWrapperCreativeIds;W.prototype.getWrapperAdSystems=W.prototype.getWrapperAdSystems;W.prototype.getWrapperAdIds=W.prototype.getWrapperAdIds;W.prototype.getSequenceLength=W.prototype.sb;W.prototype.getPositionInSequence=W.prototype.Ib;W.prototype.getPodTimeOffset=W.prototype.Hb;W.prototype.getPodIndex=W.prototype.getPodIndex;W.prototype.getPodType=W.prototype.Qa;W.prototype.getMediaBitrate=W.prototype.eb;W.prototype.getMediaHeight=W.prototype.pb;
9
+ W.prototype.getMediaWidth=W.prototype.qb;W.prototype.getMediaUrl=W.prototype.getMediaUrl;W.prototype.getClickThroughUrl=W.prototype.Gb;W.prototype.isBumper=W.prototype.Zb;W.prototype.getSkipTimeOffset=W.prototype.getSkipTimeOffset;W.prototype.getDuration=W.prototype.getDuration;W.prototype.getTitle=W.prototype.getTitle;W.prototype.getAdvertiserName=W.prototype.getAdvertiserName;W.prototype.getAdSystem=W.prototype.getAdSystem;W.prototype.getApiFramework=W.prototype.getApiFramework;
10
+ W.prototype.getCreativeId=W.prototype.getCreativeId;W.prototype.getId=W.prototype.getId;W.prototype.getTechnology=W.prototype.tb;W.prototype.getAdManagerVersion=W.prototype.ob;W.prototype.getAdManagerName=W.prototype.nb;var dK=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()}})}Jb(){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
+ dK.prototype.hasPostroll=dK.prototype.fb;dK.prototype.hasPreroll=dK.prototype.Jb;dK.prototype.getCuePoints=dK.prototype.getCuePoints;var eK=class{constructor(a){this.B=new _.O("clpp.freewheel.AdsManager");this.l=a;this.g=new _.uo;this.o=new tv.freewheel.SDK.AdManager;this.f=this.a=null;this.A=[];this.m=[];this.w=[];this.j=new _.Xk;this.h=null}load(){const a=this;return _.y(function*(){const b=a.l.getConfiguration().freewheel||{};try{VJ(b)}catch(d){return a.l.onError(d),a.j.resolve(),a.j}a.o.setNetwork(b.networkId);a.o.setServer(b.serverUrl);a.a=a.o.newContext();a.a.setProfile(b.profileId);typeof b.siteSectionId!==_.ne&&typeof b.siteSectionId!==
12
+ _.r||a.a.setSiteSection(b.siteSectionId);const c=yield WJ();a.a.setVideoAsset(b.videoAssetId,a.l.getDuration(),void 0,void 0,c);if(Array.isArray(b.pods))for(const d of b.pods)a.a.addTemporalSlot(d.id,UJ(d.type),d.position,d.slotProfile,d.cuepointSequence,d.maxDuration,d.minDuration,d.acceptContentType);b.keyValues&&typeof b.keyValues===_.Bd&&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);XJ(a);a.a.submitRequest();return a.j})}start(){const a=this;return _.y(function*(){yield $J(a)})}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}dispose(){const a=this;return _.y(function*(){a.g.release();
14
+ a.h&&(a.h.stop(),a.h=null);ZJ(a);a.a&&(a.a.dispose(),a.a=null)})}H(a){if(a.success)this.A=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL),this.m=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL),this.w=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL),this.l.trigger(new _.F(_.Ob,{adsTimeline:new dK(this.a)})),this.h=new _.cq(this.l.getSurface(),(b,c)=>this.a.resize(b,c),this.l.Vb(TJ).f);else this.l.onError(new _.H(1,
15
+ 9,10003,{errorType:0},void 0));this.j.resolve()}J(a){bK(this,_.xb,a);this.h.start()}I(a){this.f=null;a=a.slot;bK(this,_.yb);this.h.stop();if(a)switch(a.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:$J(this);break;case tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL:ZJ(this);this.l.play();break;case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:aK(this)}}G(a){const b=a.subType;this.B.debug("ad event",b);switch(b){case tv.freewheel.SDK.EVENT_AD_IMPRESSION:bK(this,_.Kb,a);bK(this,
16
+ _.Db,a);break;case tv.freewheel.SDK.EVENT_AD_IMPRESSION_END:bK(this,_.Lb,a);break;case tv.freewheel.SDK.EVENT_AD_FIRST_QUARTILE:bK(this,_.Cb,a);break;case tv.freewheel.SDK.EVENT_AD_MIDPOINT:bK(this,_.Fb,a);break;case tv.freewheel.SDK.EVENT_AD_THIRD_QUARTILE:bK(this,_.Mb,a);break;case tv.freewheel.SDK.EVENT_AD_COMPLETE:bK(this,_.Bb,a);break;case tv.freewheel.SDK.EVENT_AD_CLICK:bK(this,_.Ab,a);break;case tv.freewheel.SDK.EVENT_AD_PAUSE:bK(this,_.Gb,a);break;case tv.freewheel.SDK.EVENT_AD_RESUME:bK(this,
17
+ _.Ib,a);break;case tv.freewheel.SDK.EVENT_AD_SKIPPED:bK(this,_.Jb,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_START:bK(this,_.zb,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_END:bK(this,_.Hb,a);break;case tv.freewheel.SDK.EVENT_ERROR:this.l.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]}))}}F(){if(!this.f){var a=this.l.getPosition();if(this.f=this.m.find(b=>
18
+ .5>Math.abs(a-b.getTimePosition()))||null){const b=this.m.findIndex(c=>c===this.f);this.m.splice(b,1);this.l.pause();YJ(this);this.f.play()}}}C(a){if((a=a.detail)&&this.a)switch(a.currentState){case _.Sl:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PLAYING);break;case _.Rl:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PAUSED);break;case _.Hl:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_COMPLETED);aK(this);break;case _.Pl:case _.Ol:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_STOPPED)}}};
19
+ eK.prototype.getPosition=eK.prototype.getPosition;eK.prototype.setVolume=eK.prototype.setVolume;eK.prototype.getVolume=eK.prototype.getVolume;eK.prototype.skip=eK.prototype.skip;eK.prototype.pause=eK.prototype.pause;eK.prototype.resume=eK.prototype.resume;eK.prototype.start=eK.prototype.start;var fK=class{constructor(){this.a=new _.O(SJ)}name(){return SJ}ba(a,b){return a.namespace()===_.Ac?!1:window.tv&&tv.freewheel&&tv.freewheel.SDK?!(!b||!b.freewheel):(this.a.warn("FreeWheel SDK is not loaded."),!1)}create(a){return new eK(a)}};fK.prototype.create=fK.prototype.create;fK.prototype.isSupported=fK.prototype.ba;fK.prototype.name=fK.prototype.name;_.im(new fK);};f.call(g, window);
package/cl.hls.js CHANGED
@@ -1,40 +1,57 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Mz="CLOSED-CAPTIONS",Nz="Could not parse MP4 segment start time.",Oz="EXT-X-BYTERANGE",Pz="EXT-X-DISCONTINUITY",Qz="EXT-X-DISCONTINUITY-SEQUENCE",Rz="EXT-X-ENDLIST",Sz="EXT-X-MAP",Tz="EXT-X-MEDIA-SEQUENCE",Uz="EXT-X-PART-INF",Vz="EXT-X-PLAYLIST-TYPE",Wz="EXT-X-PRELOAD-HINT",Xz="EXT-X-SERVER-CONTROL",Yz="EXT-X-STREAM-INF",Zz="EXT-X-TARGETDURATION",$z="EXTINF",aA="Guessing audio-only",bA="SAMPLE-AES-CTR",cA="SUBTITLES",dA="application/vnd.apple.mpegurl",eA=function(a,b){a=a.getAttribute(b);
2
- if(!a)throw new _.G(_.F,4,4023,b);return a.value},fA=function(a){if(1>a.a)throw _.xj();--a.a},gA=function(a,b){return a.filter(c=>c.name==b)},hA=function(a,b){return a.filter(c=>eA(c,"TYPE")===b)},iA=function(a,b){a=gA(a,b);return a.length?a[0]:null},jA=function(a,b){return _.wu([a],[b])[0]},nA=function(a,b,c){const d=[],e=[];let f=[],g=[];c.forEach(h=>{/^(#EXT)/.test(h)?(h=_.yg(a.a++,h),kA.includes(h.name)?d.push(h):lA.includes(h.name)?"EXT-X-PART"===h.name?g.push(h):h.name===Wz&&"PART"===_.rg(h,
3
- "TYPE")&&g.push(h):f.push(h)):/^#(?!EXT)/m.test(h)||(h=jA(b,h.trim()),e.push(new mA(h,f,g)),f=[],g=[])});0<g.length&&e.push(new mA(null,f,g));return{$:e,fa:d}},oA=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},pA=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 _.G(_.F,
4
- 4,4030);}oA(a)||d();let e=10;a[5]&64&&(e=e+4+c(a.subarray(10,14)));do{var f=c(a.subarray(e+4,e+8));1>f&&d();var g=String.fromCharCode(a[e],a[e+1],a[e+2],a[e+3]);if("PRIV"===g){g=a.subarray(e+10,e+f+10);for(let h=0;h<g.byteLength;h++)if(0===g[h]){if("com.apple.streaming.transportStreamTimestamp"===unescape(b(g,0,h)))return a=g.subarray(h+1),f=(a[3]&1)<<30|a[4]<<22|a[5]<<14|a[6]<<6|a[7]>>>2,f*=4,f+=a[7]&3,Math.round(f/9E4);break}}oA(a,e)||d();e+=10;e+=f}while(e<a.byteLength);return d()},qA=function(a,
5
- b){let c=null,d=0;try{(new _.Mj).M(_.wd,_.N).M(_.we,_.N).M(_.rd,_.N).X("mdhd",g=>{g.reader.skip(0==g.version?8:16);d=_.M(g.reader);g.parser.stop()}).parse(b,!0)}catch(g){c=g}if(c||!d)throw _.eq.error("Unable to find timescale in init segment!"),new _.G(_.F,4,4030,Nz,c);let e=0,f=!1;try{(new _.Mj).M("moof",_.N).M("traf",_.N).X("tfdt",g=>{e=(0==g.version?_.M(g.reader):_.Cj(g.reader))/d;f=!0;g.parser.stop()}).parse(a,!0)}catch(g){c=g}if(c||!f)throw new _.G(_.F,4,4030,Nz,c);return e},rA=function(a){for(;a.getPosition()<
6
- a.wa()-1;){const b=a.getPosition();if(71===_.yj(a))return fA(a),b}return-1},sA=function(a){function b(){d.seek(e+188);f=_.yj(d);71!=f&&(d.seek(e+192),f=_.yj(d));71!=f&&(d.seek(e+204),f=_.yj(d));71!=f&&c();fA(d)}function c(){throw new _.G(_.F,4,4030);}const d=new _.vk(new DataView(a),!1);let e=0,f=0;e=rA(d);0>e&&(_.eq.error("Unable to find sync byte in TS after scanning."),c());for(;;){e=d.getPosition();f=_.yj(d);71!=f&&c();a=_.zj(d);if(8191===(a&8191)){b();continue}if(!(a&16384)){b();continue}a=(_.yj(d)&
7
- 48)>>4;0!=a&&2!=a||c();3==a&&(a=_.yj(d),d.skip(a));if(1!=_.M(d)>>8){b();continue}d.skip(3);a=_.yj(d)>>6;0!=a&&1!=a||c();0==_.yj(d)&&c();a=_.yj(d);const g=_.zj(d),h=_.zj(d);return(1073741824*((a&14)>>1)+((g&65534)<<14|(h&65534)>>1))/9E4}},tA=function(a,b,c){return _.w(function*(){const d=b.f(),e=_.Qu(b.Ca(),b.Ta,b.Ta+2048-1,a.a.attemptParameters);e.type=2;const f=_.Qu(b.Ca(),b.Ta,b.Ja,a.a.attemptParameters);f.type=2;d&&(f.keyInfo=d);try{return yield a.g(c?f:e)}catch(g){if(7001===g.code||c)throw g;
8
- a.f.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.g(f)}catch(h){throw a.f.error("Failed to fetch media segment to parse its start timestamp.",f.uris[0],h),new _.G(_.F,4,4030,"Failed to fetch the media segment.");}}})},uA=function(a,b,c,d,e,f){return _.w(function*(){a.f.debug("Fetching segment to find start time");if("audio/mpeg"===d||d===_.dc||d===
9
- _.cc)return 0;if(d===_.bc){var g=yield tA(a,c,f);const h=_.H(g.data);return oA(h)?pA(h):sA(g.data)}if(d===_.Je||d===_.ec)return g=[tA(a,c,f)],b&&g.push(tA(a,b,!0)),g=yield Promise.all(g),qA(g[0].data,(g[1]||g[0]).data);if(d===_.Ie)return g=yield tA(a,c,f),sA(g.data);if(!MediaSource.isTypeSupported(`${d.split("/")[0]||""}/mp4;codecs="${e}"`))return 0;throw new _.G(_.F,4,4030);})},vA=function(a){var b=eA(a,"METHOD");const c=["SAMPLE-AES",bA];if(!c.includes(b))return _.Jf("PlayReady in HLS is only supported with [",
10
- c.join(", "),"], not",b),null;a=eA(a,_.mb);b=_.go(a);a=null;b=_.H(b.data);try{a=_.nu(_.Fk(b))}catch(d){a=b}return _.xu(_.Jc,[{initDataType:_.tc,initData:a}],"")},wA=function(a,b){return _.w(function*(){var c=_.bh([b],a.g.attemptParameters);c.type=1;c=yield a.R(c);let d="";try{d=_.Ig(c.data)}catch(e){throw new _.G(_.F,4,4042);}d=d.replace(/\r\n|\r(?=[^\n]|$)/gm,"\n");d=d.trim();return{text:d,response:c}})},DA=function(a,b){return _.w(function*(){var c=xA(a,b,a.w,"");if(1===c.type){a.G.set(a.w,c);c=
11
- _.Qo(c.$[0].a)||"";c=null!=_.Po.video[c]?_.u:null!=_.Po.audio[c]?_.ac:null;var d="";c===_.u?d="avc1.42E01E":c===_.ac&&(d="mp4a.40.2");{c=a.aa;var e=a.w;d=a.g.hlsDefaultCodecs||d;const h=[],k=[];k.push(new _.wg(_.ka,"0"));k.push(new _.wg(_.mb,e));d.length&&k.push(new _.wg(_.ma,d));h.push(new _.xg(c.a++,Yz,k));c=new yA(e,0,h)}}c=yield zA(a,c.fa);if(!a.D)throw new _.G(_.F,7,7001);a.D.filterAllPeriods([c]);d=e=Infinity;for(var f of a.a.values())e=Math.min(e,f.Dd),f.type!==_.r&&(d=Math.min(d,f.duration));
12
- a.j===AA?a.h=new _.Bz(null,0,!0):(a.h=new _.Bz(0,a.S,!1),_.Uu(a.h,1));BA(a);if(a.j===AA){a.h.Lb(d);a.h.offset(-e);for(const h of a.a.values())h.segmentIndex.offset(-e),_.gv(h.segmentIndex,d)}else{a.V=a.F;a.j===CA&&(f=Math.max(d,a.h.Md),isNaN(a.g.availabilityWindowOverride)||(f=a.g.availabilityWindowOverride),a.h.Zb=f);f=0;for(var g of a.a.values())f=Math.max(f,g.Dd);for(g=0;95443.7176888889<=f;)g+=95443.7176888889,f-=95443.7176888889;if(g){a.f.debug("Offsetting live streams by",g,"to compensate for rollover");
13
- for(const h of a.a.values())95443.7176888889>h.Dd?(a.f.debug("Offset applied to",h.type),h.segmentIndex.offset(g)):a.f.debug("Offset NOT applied to",h.type)}}return{presentationTimeline:a.h,periods:[c],offlineSessionIds:[],minBufferTime:0}})},GA=function(a,b){return _.w(function*(){var c=new _.eg(b.Ue);if(a.g.hlsLowLatency){var d=c.a;if(b.$e){var e=b.segmentIndex;if(e=e.a[e.a.length-1]){var f=e.a,g=f.length-1;e={Bf:e.position,Hf:f&&0<f.length?g:null}}else e=null;const {Bf:l,Hf:m}=e;null!==l&&(d.add("_HLS_msn",
14
- l),null!==m&&d.add("_HLS_part",m))}e=d;_.pg(e);e.g&&_.hg(c,d)}const {response:h,text:k}=yield wA(a,c.toString());c=xA(a,k,h.uri,b.Jc);if(1!==c.type)throw new _.G(_.F,4,4017);d=yield EA(a,b.Jc,c,b.type,b.mimeType,b.codecs,b.keyInfo||null,b.ef);b.$=d;b.segmentIndex.replace(d);d=d[d.length-1];iA(c.fa,Rz)&&(FA(a,AA),a.h.Lb(d.endTime))})},xA=function(a,b,c,d){a:{a=a.aa;b=b.trim().split(/\n+/m);if(!/^#EXTM3U($|[ \t\n])/m.test(b[0]))throw new _.G(_.F,4,4015);var e=b,f=0,g=!0;for(h of e){var h=h.trim();if(!h.length||
15
- /^#(?!EXT)/m.test(h)||g)g=!1;else if(e=_.yg(0,h),kA.includes(e.name)){f=1;break}else e.name===Yz&&(g=!0)}h=f;f=[];g=!0;for(var k of _.yu(b)){let {Wc:l,item:m,next:n}=k;m=m.trim();if(!m.length||/^#(?!EXT)/m.test(m)||g)g=!1;else{e=m;e=_.yg(a.a++,e);if(HA.includes(e.name)){if(1!==h)throw new _.G(_.F,4,4017);k=b.splice(l,b.length-l);a=nA(a,c,k);c=new yA(c,h,f.concat(a.fa),a.$);break a}f.push(e);e.name===Yz&&(e.attributes.push(new _.wg(_.mb,n)),g=!0)}}c=new yA(c,h,f)}c.f=d;return c},EA=function(a,b,c,
16
- d,e,f,g,h){return _.w(function*(){var k=c.$;const l=IA(c,g);var m=(m=iA(c.fa,Tz))?Number(m.value):0;null===a.J&&(a.J=yield JA(a,b,l,k[0],m,g,e,f,d));const n=a.J;a.f.debug("First segment",k[0].a.split("/").pop(),"starts at",n);var q=iA(c.fa,Qz);let t=q?Number(q.value):0;h.has(t)||h.set(t,m);if(!q)for(;h.has(t+1)&&h.get(t+1)<m;)t++;q=a.H.get(t)||0;const v=[];for(const E of _.yu(k)){var y=E.Wc;k=E.item;{var A=v[v.length-1];const D=0==y?n:A.endTime;y=m+y;iA(k.fa,Pz)&&(t++,h.set(t,y),q=yield KA(a,t,b,
17
- l,k,y,g,e,f,D,d));A=LA(a,A,k,y,D,q,g,d,c.a);k=iA(k.fa,$z);A&&(a.g.hlsLowLatency||k)&&v.push(A)}}a.U.push(v);BA(a);return v})},FA=function(a,b){a.j=b;if(a.h){b=a.h;var c=a.j===AA;b.j=c;b.m=c}a.j===AA&&a.o.stop()},zA=function(a,b){return _.w(function*(){var c=gA(b,"EXT-X-MEDIA"),d=gA(b,Yz),e=gA(b,"EXT-X-IMAGE-STREAM-INF");var f=new Map;for(var g of d){var h=_.rg(g,"AUDIO"),k=_.rg(g,"VIDEO"),l=_.rg(g,cA);const m=MA(a,g);if(l){const n=_.Fh(_.r,m);f.set(l,n);l=m.indexOf(n);-1<l&&m.splice(l,1)}h&&(l=NA(_.ac,
18
- m),f.set(h,l));k&&(h=NA(_.u,m),f.set(k,h))}a.B=f;yield OA(a,c);f=hA(c,Mz);for(const m of f)f=PA(m),g=eA(m,_.Ca),k=eA(m,"INSTREAM-ID"),a.I.get(g)||a.I.set(g,new Map),a.I.get(g).set(k,f);d=yield QA(a,d);c=yield RA(a,c);e=yield SA(a,e);return{startTime:0,variants:d,textStreams:c,thumbStreams:e}})},OA=function(a,b){return _.w(function*(){b=b.filter(d=>{const e=_.rg(d,_.mb)||"";return _.rg(d,"TYPE")!==cA&&""!==e});b.length&&(yield TA(a,b[0]));const c=b.slice(1).map(d=>TA(a,d));yield Promise.all(c)})},
19
- QA=function(a,b){return _.w(function*(){var c=f=>_.w(function*(){const g=_.rg(f,"FRAME-RATE"),h=Number(eA(f,_.ka));var k=_.rg(f,_.Za);const [l,m]=k?k.split("x"):[null,null];return(k=yield UA(a,f,k,g))?VA(a,k.audio,k.video,h,l,m,g):[]});let d=0;var e=Infinity;for(let f=0;f<b.length;++f){const g=Number(eA(b[f],_.ka));g<e&&(e=g,d=f)}e=b.splice(d,1).pop();e=yield c(e);c=b.map(c);c=yield Promise.all(c);c.splice(d,0,e);return c.reduce(_.uu,[]).filter(_.dg)})},RA=function(a,b){return _.w(function*(){var c=
20
- hA(b,cA),d=c.map(f=>_.w(function*(){try{return yield TA(a,f)}catch(g){throw g;}}));d=yield Promise.all(d);for(const f of c){var e=eA(f,_.Ca);if(c=a.B.get(e))if(e=a.m.get(e))for(const g of e)g.codecs=c}return d.filter(f=>f)})},SA=function(a,b){return _.w(function*(){const c=b.map(d=>_.w(function*(){return WA(a,d)}));return(yield Promise.all(c)).filter(d=>d)})},MA=function(a,b){var c=_.rg(b,_.ma,a.g.hlsDefaultCodecs||"avc1.42E01E,mp4a.40.2").split(/\s*,\s*/);b=new Set;const d=[];for(const e of c)c=
21
- _.Fu(e)[0],b.has(c)?a.f.debug("Ignoring duplicate codec"):(d.push(e),b.add(c));return d},NA=function(a,b){if(1===b.length)return b[0];a=_.Fh(a,b);if(null!=a)return a;throw new _.G(_.F,4,4025,{codecList:b});},TA=function(a,b){return _.w(function*(){const c=eA(b,_.Ca);var d="";let e=eA(b,"TYPE").toLowerCase();e===_.gu&&(e=_.r);e!==_.r&&c&&a.B.has(c)&&(d=a.B.get(c));const f=eA(b,_.mb);if(a.a.has(f))return a.a.get(f);const g=PA(b),h=_.rg(b,"NAME"),k=b.getAttribute("DEFAULT"),l=b.getAttribute("AUTOSELECT"),
22
- m=_.rg(b,"CHANNELS");d=yield XA(a,f,d,e,g,!!k&&!!l,h,e==_.ac?m?parseInt(m.split("/")[0],10):null:null,null);a.m.has(c)?a.m.get(c).push(d):a.m.set(c,[d]);if(a.a.has(f))return a.a.get(f);a.a.set(f,d);return d})},WA=function(a,b){return _.w(function*(){const c=eA(b,_.mb);if(a.a.has(c))return a.a.get(c);var d=_.rg(b,_.ma)||"jpg",e=PA(b);const f=_.rg(b,"NAME");d=yield XA(a,c,d,_.ed,e,!1,f,null,null);if(a.a.has(c))return a.a.get(c);if(e=_.rg(b,_.ka))d.bandwidth=Number(e);a.a.set(c,d);return d})},UA=function(a,
23
- b,c,d){return _.w(function*(){let e=MA(a,b);var f=_.rg(b,"AUDIO"),g=_.rg(b,"VIDEO"),h=f||g;h=h&&a.m.has(h)?a.m.get(h):[];f={audio:f?h:[],video:g?h:[]};a.f.debug("Guessing stream type for",b.toString());g=!1;const k=eA(b,_.mb);var l=f.audio.find(n=>n.Jc===k),m=_.Fh(_.u,e);m=c||d||m;1!==e.length||m?!h.length&&1<e.length?(a.f.debug("Guessing multiplexed audio+video"),h=_.u,e=[e.join(",")]):f.audio.length&&l?(a.f.debug(aA),h=_.ac,g=!0):f.video.length?(a.f.debug(aA),h=_.ac):(a.f.debug("Guessing video-only"),
24
- h=_.u):(h=_.ac,a.f.debug(aA));l=null;g||(l=yield YA(a,b,e,h));if(l)f[l.type]=[l];else if(null===l)return a.f.debug("stream is null"),null;ZA(f);return f})},VA=function(a,b,c,d,e,f,g){c.forEach(l=>{l&&(l.width=Number(e)||void 0,l.height=Number(f)||void 0,l.frameRate=Number(g)||void 0)});b.length||(b=[null]);c.length||(c=[null]);const h=[];for(const l of b)for(const m of c){var k=l?l.drmInfos:null;const n=m?m.drmInfos:null;b=(m?m.Jc:"")+" - "+(l?l.Jc:"");let q;if(l&&m)if(k.length&&n.length?0<_.Hu(k,
25
- n).length:1)q=_.Hu(k,n);else{a.f.warn("Incompatible DRM info in HLS variant. Skipping.");continue}else l?q=k:m&&(q=n);a.W.has(b)?a.f.debug("Skipping variant which only differs in text streams."):(k=$A(a,l,m,d,q),h.push(k),a.W.add(b))}return h},YA=function(a,b,c,d){return _.w(function*(){const e=eA(b,_.mb);if(a.a.has(e))return a.a.get(e);var f=_.rg(b,Mz),g=null;d==_.u&&f&&"NONE"!==f&&(g=a.I.get(f));f=NA(d,c);g=yield XA(a,e,f,d,_.ye,!1,null,null,g);if(a.a.has(e))return a.a.get(e);a.a.set(e,g);return g})},
26
- ZA=function(a){for(const b of a.audio.concat(a.video))a=b.codecs.split(","),a=a.filter(c=>"mp4a.40.34"!==c),b.codecs=a.join(",")},$A=function(a,b,c,d,e){return{id:a.Z++,language:b?b.language:_.ye,primary:!!b&&b.primary||!!c&&c.primary,audio:b,video:c,bandwidth:d,drmInfos:e,allowedByApplication:!0,allowedByKeySystem:!0}},PA=function(a){a=_.rg(a,"LANGUAGE")||_.ye;return _.Nh(a)},XA=function(a,b,c,d,e,f,g,h,k){return _.w(function*(){let l=jA(a.w,b);var m=null;if(a.j===AA&&a.G.has(l)){var n=a.G.get(l);
27
- a.G.delete(l)}else{const {response:rb,text:pa}=yield wA(a,l);l=rb.uri;n=xA(a,pa,l,b)}if(1!==n.type)throw new _.G(_.F,4,4017);aB(a,n);const q=yield bB(a,d,c,n),t=[];n.$.forEach(rb=>{rb=gA(rb.fa,"EXT-X-KEY");t.push.apply(t,rb)});let v=!1;const y=[];let A=null;for(var E of t){var D=eA(E,"METHOD"),ha=_.rg(E,"KEYFORMAT","identity");"NONE"!==D&&("AES-128"===D?(m=_.rg(E,"IV",""),m={method:"AES-128",url:jA(a.w,eA(E,_.mb)),iv:m?_.gj((m||"0x").slice(2)):null},a.L=!0):(v=!0,(D=(D=cB[ha])?D(E,q):null)?(D.keyIds.length&&
28
- (A=D.keyIds[0]),y.push(D)):a.f.warn("Unsupported HLS KEYFORMAT",ha)))}if(v&&!y.length&&!a.L)throw new _.G(_.F,4,4026);E=new Map;ha=yield EA(a,b,n,d,q,c,m,E);D=ha[0].startTime;const gb=ha[ha.length-1].endTime,vf=gb-D,yb=new _.Cz(ha),wf=a.g.hlsLowLatency?_.zx:_.Yt,Ta=IA(n,m);let Hd=void 0;d==_.r&&(Hd=_.fu);n=(n=iA(n.fa,Xz))?"YES"===_.rg(n,"CAN-BLOCK-RELOAD"):!1;return{id:a.Z++,originalId:g,createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:yb.f.bind(yb),getSegmentReference:yb.get.bind(yb),
29
- adjustSegmentDurations:yb.g.bind(yb),getDuration:yb.getDuration.bind(yb),segmentIndex:yb,segmentLookupStrategy:wf,initSegmentReference:Ta,mimeType:q,codecs:c,kind:Hd,encrypted:v,keyId:A,language:e,label:g,type:d,primary:f,trickModeVideo:null,emsgSchemeIdUris:null,frameRate:void 0,width:void 0,height:void 0,bandwidth:void 0,roles:[],channelsCount:h,closedCaptions:k,keyInfo:m,$:ha,drmInfos:y,Jc:b,Ue:l,Dd:D,qg:gb,duration:vf,ef:E,$e:n}})},aB=function(a,b){var c=iA(b.fa,Vz),d=iA(b.fa,Rz);d=c&&"VOD"===
30
- c.value||d;c=c&&"EVENT"===c.value&&!d;c=!d&&!c;if(d)FA(a,AA);else{c?FA(a,CA):FA(a,dB);d=iA(b.fa,Zz);if(!d)throw new _.G(_.F,4,4024,{missingTag:Zz});d=Number(d.value);c=iA(b.fa,Uz);a.g.hlsLowLatency&&c?(d=Number(eA(c,"PART-TARGET")),a.F=Math.min(d,a.F),a.C=Math.max(d,a.C),b=iA(b.fa,Xz),a.S=b?Number(eA(b,"PART-HOLD-BACK")):0):(a.C=Math.max(d,a.C),a.F=Math.min(d,a.F),a.S=3*a.C)}},bB=function(a,b,c,d){return _.w(function*(){var e=d.$[0];const f=e.a;e=(e=iA(e.fa,Sz))?eA(e,_.mb):null;return eB(a,b,c,f,
31
- e)})},IA=function(a,b){var c=gA(a.$[0].fa,Sz);if(!c.length)return null;if(1<a.$.map(f=>gA(f.fa,Sz)).reduce((f,g)=>f.concat(g),[]).length)throw new _.G(_.F,4,4020);c=c[0];var d=eA(c,_.mb);const e=jA(a.a,d);a=0;d=null;if(c=_.rg(c,"BYTERANGE"))a=c.split("@"),c=Number(a[0]),a=Number(a[1]),d=a+c-1;return new _.Az(()=>[e],a,d,b)},BA=function(a){a.h&&(a.U.forEach(b=>{_.Tu(a.h,b,0)}),a.U=[])},fB=function(a,b){var c=0;let d=null;b&&(c=b.split("@"),b=Number(c[0]),c=c[1]?Number(c[1]):a.Ja+1,d=c+b-1);return[c,
32
- d]},hB=function(a,b,c,d,e,f,g){const h=[];for(const n of _.yu(b.f)){b=n.Wc;const q=n.item;{var k=0==b?a:h[h.length-1],l=0==b?d:k.endTime,m=Number(_.rg(q,"DURATION"));m=l+m;const t=_.rg(q,"BYTERANGE"),[v,y]=fB(k,t);k=_.rg(q,_.mb);const A=(k=jA(g,k))?[k]:[];l=new gB(c,l,m,()=>A,v,y,e,f,!1,null,null,null,null);if("YES"===_.rg(q,"INDEPENDENT")||0===b)l.g=!0;h.push(l)}}return h},LA=function(a,b,c,d,e,f,g,h,k){var l=c.fa,m=c.a;const n=m?[m]:[];m=iA(l,$z);(g=g?Object.assign({},g):null)&&!g.iv&&(g.iv=_.jj(new Uint8Array(12),
33
- new Uint8Array([d>>24&255,d>>16&255,d>>8&255,d&255])));var q=null,t=null,v=null;h===_.ed&&(t=iA(l,"EXT-X-TILES"),q="1x1",t&&(q=_.rg(t,"LAYOUT")||"1x1",v=(v=_.rg(t,"DURATION"))?Number(v):null),[q,t]=q.split("x").map(y=>parseInt(y,10)));if(0===c.f.length&&!m)throw new _.G(_.F,4,4024,{missingTag:$z});h=null;if(0<c.f.length)if(a.g.hlsLowLatency)h=hB(b,c,d,e,f,g,k);else return null;c=a=0;k=null;m?(a=e+Number(m.value.split(",")[0]),l=iA(l,Oz),[c,k]=fB(b,l?l.value:null)):a=h[h.length-1].endTime;return new gB(d,
34
- e,a,()=>n,c,k,f,g,!1,null,q,t,v,h)},JA=function(a,b,c,d,e,f,g,h,k,l){return _.w(function*(){const m=LA(a,null,d,e,0,0,f,k,"");if(!m)return 0;if(a.N&&!l){{var n=m.position;const q=a.a.get(b);n=q?(n=q.segmentIndex.get(n))?n.startTime:null:null}if(null!=n)return a.f.debug("Found segment start time in previous manifest"),n;a.f.debug("Unable to find segment start time in previous manifest!")}return uA(a.ca,c,m,g,h,a.L)})},KA=function(a,b,c,d,e,f,g,h,k,l,m){return _.w(function*(){let n;a.H.has(b)?n=a.H.get(b):
35
- (n=(yield JA(a,c,d,e,f,g,h,k,m,!0))-l,a.f.debug("Discontinuity segment offset",n),a.H.set(b,n));return n})},eB=function(a,b,c,d,e){return _.w(function*(){const f=[d,e].filter(Boolean);var g=_.Ih(f,b,c);if(g)return g;g=_.bh([d],a.g.attemptParameters);g.method="HEAD";g.type=2;g=(yield a.R(g)).headers["content-type"];if(!g)throw new _.G(_.F,4,4021,f.join(", "));return g.split(";")[0]})},yA=class{constructor(a,b,c,d){if(1===b){if(!d||0===d.length)throw new _.G(_.F,4,4043,"Media playlist must have at least one segment!");
36
- if(null==d[0].a)throw new _.G(_.F,4,4043,"Media playlist must have at least one full segment!");}this.a=a;this.f="";this.type=b;this.fa=c;this.$=1===b?d:null}},mA=class{constructor(a,b,c){c=void 0===c?[]:c;this.fa=b;this.a=a;this.f=c}},kA=[Qz,Rz,"EXT-X-I-FRAMES-ONLY",Tz,Uz,Vz,Xz,Zz],HA=[$z,Oz,"EXT-X-DATERANGE",Pz,"EXT-X-KEY",Sz,"EXT-X-PROGRAM-DATE-TIME"],lA=["EXT-X-PART",Wz],iB=class{constructor(){this.a=0}},jB=class{constructor(a){this.f=new _.O("clpp.hls.MediaReader");this.g=a;this.a={attemptParameters:_.Zg()}}};var gB=class extends _.bv{constructor(a,b,c,d,e,f,g,h,k,l,m,n,q,t){t=void 0===t?[]:t;super(a,b,c,d,e,f,g,h,k,void 0===l?null:l,void 0===m?null:m,void 0===n?null:n,void 0===q?null:q,t);this.initSegment=void 0}};var kB=class{constructor(){this.g=this.D=null;this.Z=1;this.S=0;this.m=new Map;this.W=new Set;this.a=new Map;this.h=null;this.w="";this.aa=new iB;this.V=0;this.K=new Map;this.o=new _.Th(()=>{this.vb()});this.j=AA;this.N=null;this.C=0;this.F=Infinity;this.A=new _.So;this.U=[];this.I=new Map;this.L=!1;this.B=new Map;this.J=null;this.f=new _.O("clpp.hls.HlsParser");this.G=new Map;this.H=new Map;this.ca=new jB(this.R.bind(this))}configure(a){this.g=a;this.ca.a=a}setCurrentVariant(a){const b=a.video?a.video.id:
37
- null;a=a.audio?a.audio.id:null;this.K.clear();for(const c of this.a.keys()){const d=this.a.get(c);d.id!==b&&d.id!==a||this.K.set(c,d)}}start(a,b){const c=this;return _.w(function*(){c.D=b;const {response:d,text:e}=yield wA(c,a);c.w=d.uri;const f=yield DA(c,e);c.N=f;const g=c.V;0<g&&c.o.ba(g);return f})}stop(){this.o&&(this.o.stop(),this.o=null);const a=[];this.A&&(a.push(this.A.destroy()),this.A=null);this.g=this.D=null;this.W.clear();this.a.clear();this.G.clear();this.N=null;this.m.clear();this.B.clear();
38
- return Promise.all(a)}update(){const a=this;return _.w(function*(){if(a.j!==AA){var b=[];a.J=null;var c=Array.from(a.a.values()),d=Array.from(a.K.values());c=a.g.hlsLowLatency&&0<d.length?d:c;yield GA(a,c[0]);for(d=1;d<c.length;d++)b.push(GA(a,c[d]));yield Promise.all(b)}})}onExpirationUpdated(){}vb(){const a=this;return _.w(function*(){a.f.debug(_.Rt);if(a.D)try{yield a.update(),a.o.ba(a.V)}catch(b){a.D&&(a.D.onError(b),1===b.severity&&a.o.ba(.1))}})}R(a){if(!this.A)throw new _.G(_.F,7,7001);a=this.D.networkingEngine.fetch(a);
39
- _.ih(this.A,a);return a.P}},cB={"com.apple.streamingkeydelivery":function(a,b){if(b===_.Ie)throw new _.G(_.F,4,4041);return _.xu(_.Ic,[{initDataType:_.he,initData:new Uint8Array(0)}],"")},"com.microsoft.playready":vA,"urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":vA,"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":function(a){var b=eA(a,"METHOD");const c=["SAMPLE-AES",bA];if(!c.includes(b))return _.Jf("Widevine in HLS is only supported with [",c.join(", "),"], not",b),null;b=eA(a,_.mb);b=_.go(b);
40
- b=_.H(b.data);b=_.xu(_.Kc,[{initDataType:_.tc,initData:b}],"");if(a=_.rg(a,"KEYID"))b.keyIds=[a.substr(2).toLowerCase()];return b}},AA="VOD",dB="EVENT",CA="LIVE";_.x("clpp.hls.HlsComponent",class extends _.Lp{constructor(){super()}f(){_.Kn.m3u8=kB;_.In[_.Pi]=kB;_.In[dA]=kB}a(){_.jv("m3u8");_.kv(_.Pi);_.kv(dA)}id(){return"hls"}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Rz="CLOSED-CAPTIONS",Sz="Could not parse MP4 segment start time.",Tz="EXT-X-BYTERANGE",Uz="EXT-X-DISCONTINUITY",Vz="EXT-X-DISCONTINUITY-SEQUENCE",Wz="EXT-X-ENDLIST",Xz="EXT-X-KEY",Yz="EXT-X-MAP",Zz="EXT-X-MEDIA-SEQUENCE",$z="EXT-X-PART-INF",aA="EXT-X-PLAYLIST-TYPE",bA="EXT-X-PRELOAD-HINT",cA="EXT-X-SERVER-CONTROL",dA="EXT-X-STREAM-INF",eA="EXT-X-TARGETDURATION",fA="Failed to infer discontinuity number",gA="Guessing audio-only",hA="METHOD",iA="Media playlist contains an EXT-X-KEY tag with METHOD\x3dAES-128 in combination with another EXT-X-KEY tag, which is not supported.",
2
+ jA="Media playlist contains an EXT-X-KEY tag with METHOD\x3dAES-128 which is not at the beginning of the playlist , which is not supported.",kA="SAMPLE-AES-CTR",lA="application/vnd.apple.mpegurl",mA="sample",nA="whole-segment",oA=function(a,b){return _.qg(a,b,void 0,{required:!0})},pA=function(a){if(1>a.a)throw _.wj();--a.a},qA=function(a){if(null!==a&&void 0!==a)return Number(a)},rA=function(a,b){return a.filter(c=>c.name===b)},sA=function(a,b){const c=Array.isArray(b)?b:[b];return a.filter(d=>{d=
3
+ oA(d,"TYPE");return c.includes(d)})},tA=function(a,b){return a.some(c=>c.name===b)},uA=function(a,b,c){c=void 0===c?{}:c;a=a.find(d=>d.name===b)||null;if(!a&&c.required)throw new _.H(_.G,4,4024,{missingTag:b});return a},vA=function(a){var b=uA(a,"EXT-X-TILES");if(!b)return{ve:1,Ve:1,durationPerTile:null};a=_.qg(b,"LAYOUT")||"1x1";b=(b=_.qg(b,"DURATION"))?Number(b):null;const [c,d]=a.split("x").map(e=>parseInt(e,10));return{ve:c,Ve:d,durationPerTile:b}},wA=function(a,b){return _.yu([a],[b])[0]},xA=
4
+ 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)},yA=function(a,b){Array.isArray(a)||(a=[a]);a.forEach(c=>{for(const d of xA(c))b(d,c)})},zA=function(a){return a.type===_.p||a.type===_.w},AA=function(a){const b=uA(a,aA);if(uA(a,Wz))return _.Tt;if(!b)return"LIVE";if(b.value===_.Tt)return _.Tt;if("EVENT"===b.value)return"EVENT";throw new _.H(_.G,4,4044,`Invalid EXT-X-PLAYLIST-TYPE value: ${b.value}`);
5
+ },BA=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(_.G,4,4044,"Byte range length must be positive.");if(d[1]){if(d=Number(d[1]),0>d)throw new _.H(_.G,4,4044,"Byte range start byte must not be negative.");}else{if(c)throw new _.H(_.G,4,4044,"Invalid byte range, offset is required but missing.");if(null==b)throw new _.H(_.G,4,4044,"Invalid byte range, cannot calculate offset based on previous byte ranges.");d=b+1}e=d+a-1}return{ta:d,ha:e}},
6
+ CA=function(a,b){a=uA(a,Tz);return BA(a?a.value:null,b)},DA=function(a){a=uA(a,"EXTINF",{required:!0}).value.split(",");return{duration:Number(a[0]),title:a[1]||null}},EA=function(a,b){b=void 0===b?{}:b;const c={Qc:!1,kf:!1,lf:null,Jf:null,Je:null};a=uA(a,cA,{required:b.Me});if(!a)return c;const d=e=>null==e?null:Number(e);c.Qc="YES"===_.qg(a,"CAN-BLOCK-RELOAD");c.kf="YES"===_.qg(a,"CAN-SKIP-DATERANGES");c.lf=d(_.qg(a,"CAN-SKIP-UNTIL"));c.Jf=d(_.qg(a,"HOLD-BACK"));c.Je=d(_.qg(a,"PART-HOLD-BACK",void 0,
7
+ {required:b.Me}));return c},FA=function(a,b,c){c=void 0===c?!1:c;a=_.qg(a,"BYTERANGE");return BA(a,b,c)},HA=function(a,b){const c=CA(a.ca,null);return new GA(0,0,0,()=>[a.a],c.ta,c.ha,0,b)},IA=function(a,b){if(null==a)return null;a=Object.assign({},a);null==a.iv&&(a.iv=_.ah(new Uint8Array(12),new Uint8Array([b>>24&255,b>>16&255,b>>8&255,b&255])));return a},JA=function(a){let b=Infinity,c=Infinity;xA(a).filter(zA).forEach(d=>{{d=d.V;var e=d[0].startTime;const f=d[d.length-1].endTime;d=e;e=f-e}b=Math.min(b,
8
+ d);c=Math.min(c,e)});return{ub:b,duration:c}},KA=function(a){return a.map(b=>{({duration:b}=JA(b));return b}).reduce((b,c)=>b+c,0)},LA=function(a,b,c){if(b===_.Tt)return{delay:0,Oc:0};b=uA(a,$z);if(c&&b)return c=Number(oA(b,"PART-TARGET")),{Je:a}=EA(a,{Me:!0}),{delay:a,Oc:c};a=uA(a,eA,{required:!0});a=Number(a.value);return{delay:3*a,Oc:a}},MA=function(a){const b=[];yA(a,c=>{b.push(c.Rf)});return{delay:Math.max(...b.map(c=>c.delay)),Oc:Math.min(...b.map(c=>c.Oc))}},NA=function(a){const b=new Map;
9
+ a.forEach(c=>{var d=c.ea[0].groupId;b.has(d)?(d=b.get(d),d.includes(c)||d.push(c)):b.set(d,[c])});return b},OA=function(a){a=_.qg(a,"LANGUAGE")||_.ye;return _.sg(a)},QA=function(a){a=a.audio.concat(a.video);for(const b of a)a=b.ea[0].codecs.split(",").filter(c=>"mp4a.40.34"!==c),PA(b,a)},UA=function(a,b,c){const d=[],e=[];let f=[],g=[];c.forEach(h=>{/^(#EXT)/.test(h)?(h=_.fh(a.a++,h),RA.includes(h.name)?d.push(h):SA.includes(h.name)?"EXT-X-PART"===h.name?g.push(h):h.name===bA&&"PART"===_.qg(h,"TYPE")&&
10
+ g.push(h):f.push(h)):/^#(?!EXT)/m.test(h)||(h=wA(b,h.trim()),e.push(new TA(h,f,g)),f=[],g=[])});0<g.length&&e.push(new TA(null,f,g));return{V:e,ca:d}},VA=function(a){return 0>a?[]:Array.from({length:a},(b,c)=>c)},WA=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},XA=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]<<
11
+ 21|h[1]<<14|h[2]<<7|h[3]}function d(){throw new _.H(_.G,4,4030);}WA(a)||d();let e=10;a[5]&64&&(e=e+4+c(a.subarray(10,14)));do{var f=c(a.subarray(e+4,e+8));1>f&&d();var g=String.fromCharCode(a[e],a[e+1],a[e+2],a[e+3]);if("PRIV"===g){g=a.subarray(e+10,e+f+10);for(let h=0;h<g.byteLength;h++)if(0===g[h]){if("com.apple.streaming.transportStreamTimestamp"===unescape(b(g,0,h)))return a=g.subarray(h+1),f=(a[3]&1)<<30|a[4]<<22|a[5]<<14|a[6]<<6|a[7]>>>2,f*=4,f+=a[7]&3,Math.round(f/9E4);break}}WA(a,e)||d();
12
+ e+=10;e+=f}while(e<a.byteLength);return d()},YA=function(a,b){let c=null,d=0;try{(new _.Mj).L(_.wd,_.Fj).L(_.we,_.Fj).L(_.rd,_.Fj).Y("mdhd",g=>{g.reader.skip(0==g.version?8:16);d=_.N(g.reader);g.parser.stop()}).parse(b,!0)}catch(g){c=g}if(c||!d)throw _.fq.error("Unable to find timescale in init segment!"),new _.H(_.G,4,4030,Sz,c);let e=0,f=!1;try{(new _.Mj).L("moof",_.Fj).L("traf",_.Fj).Y("tfdt",g=>{e=(0==g.version?_.N(g.reader):_.Bj(g.reader))/d;f=!0;g.parser.stop()}).parse(a,!0)}catch(g){c=g}if(c||
13
+ !f)throw new _.H(_.G,4,4030,Sz,c);return e},ZA=function(a){for(;a.getPosition()<a.za()-1;){const b=a.getPosition();if(71===_.xj(a))return pA(a),b}return-1},$A=function(a){function b(){d.seek(e+188);f=_.xj(d);71!=f&&(d.seek(e+192),f=_.xj(d));71!=f&&(d.seek(e+204),f=_.xj(d));71!=f&&c();pA(d)}function c(){throw new _.H(_.G,4,4030);}const d=new _.vk(new DataView(a),!1);let e=0,f=0;e=ZA(d);0>e&&(_.fq.error("Unable to find sync byte in TS after scanning."),c());for(;;){e=d.getPosition();f=_.xj(d);71!=f&&
14
+ c();a=_.yj(d);if(8191===(a&8191)){b();continue}if(!(a&16384)){b();continue}a=(_.xj(d)&48)>>4;0!=a&&2!=a||c();3==a&&(a=_.xj(d),d.skip(a));if(1!=_.N(d)>>8){b();continue}d.skip(3);a=_.xj(d)>>6;0!=a&&1!=a||c();0==_.xj(d)&&c();a=_.xj(d);const g=_.yj(d),h=_.yj(d);return(1073741824*((a&14)>>1)+((g&65534)<<14|(h&65534)>>1))/9E4}},cB=function(a){var b=oA(a,hA);if(!aB.includes(b))return bB.error("PlayReady in HLS is only supported with [",aB.join(", "),"], not",b),null;a=oA(a,_.mb);b=_.go(a);a=null;b=_.I(b.data);
15
+ try{a=_.pu(_.Ck(b))}catch(c){a=b}return _.zu(_.Jc,[{initDataType:_.tc,initData:a}],"")},hB=function(a,b,c,d){if(null===d){if(a.slice(1).some(dB))throw new _.H(_.G,4,4046,jA);if((d=eB(a[0].ca,b,c))&&d.type===nA){if(0<fB(a.slice(1)).length)throw new _.H(_.G,4,4046,iA);return[d]}a=fB(a).map(e=>eB(e.ca,b,c));return 0===a.length?[gB()]:a}if(a.some(dB))throw new _.H(_.G,4,4046,jA);if(d.type===nA){if(0<fB(a).length)throw new _.H(_.G,4,4046,iA);return[d]}d=d.type===mA?[d]:[];a=fB(a).map(e=>eB(e.ca,b,c));
16
+ return d.concat(a)},iB=function(a){if(0===a.length)return gB();if(a.some(c=>c.type===nA)||a.every(c=>c.type===_.Ad))return a[0];a=a.filter(c=>c.type===mA);const b=Array.from((new Set(a.flatMap(c=>c.drmInfos))).values());return{keyInfo:null,keyId:a[a.length-1].keyId,type:mA,drmInfos:b}},dB=function(a){return rA(a.ca,Xz).some(b=>"AES-128"===_.qg(b,hA))},fB=function(a){return a.filter(b=>tA(b.ca,Xz))},eB=function(a,b,c){a=rA(a,Xz);if(0===a.length)return null;var d=oA(a[0],hA);if(1===a.length){if("NONE"===
17
+ d)return gB();if("AES-128"===d)return a=a[0],d=_.qg(a,"IV",""),{type:nA,keyInfo:{method:"AES-128",url:wA(b,oA(a,_.mb)),iv:d?_.Yg((d||"0x").slice(2)):null},drmInfos:[],keyId:null}}b=a.map(e=>oA(e,hA));if(!b.every(e=>"SAMPLE-AES"===e)&&!b.every(e=>e===kA))throw jB.warn(`EXT-X-KEY methods ${b.join(", ")} are incompatible.`),new _.H(_.G,4,4044,"Multiple EXT-X-KEY tags with incompatible METHOD values.");b=a.map(e=>{const f=_.qg(e,"KEYFORMAT","identity");{const g=kB[f]||null;e=g?g(e,c):null}e||jB.warn("Unsupported HLS KEYFORMAT",
18
+ f);return e}).filter(Boolean);if(0===b.length)throw new _.H(_.G,4,4026);return{keyInfo:null,keyId:b.map(e=>e.keyIds).reduce((e,f)=>e.concat(f),[]).reverse()[0]||null,type:mA,drmInfos:b}},gB=function(){return{type:_.Ad,keyInfo:null,drmInfos:[],keyId:null}},lB=function(a,b,c){return _.y(function*(){const d=b.f(),e=_.Tu(b.Fa(),b.ta,b.ta+2048-1,a.a.attemptParameters);e.type=2;const f=_.Tu(b.Fa(),b.ta,b.ha,a.a.attemptParameters);f.type=2;d&&(f.keyInfo=d);try{return yield a.g(c?f:e)}catch(g){if(7001===
19
+ g.code||c)throw g;a.f.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.g(f)}catch(h){throw a.f.error("Failed to fetch media segment to parse its start timestamp.",f.uris[0],h),new _.H(_.G,4,4030,"Failed to fetch the media segment.");}}})},mB=function(a,b,c,d,e,f){return _.y(function*(){a.f.debug("Fetching segment to find start time");if("audio/mpeg"===
20
+ d||d===_.dc||d===_.cc)return 0;if(d===_.bc){var g=yield lB(a,c,f);const h=_.I(g.data);return WA(h)?XA(h):$A(g.data)}if(d===_.Ke||d===_.ec)return g=[lB(a,c,f)],b&&g.push(lB(a,b,!0)),g=yield Promise.all(g),YA(g[0].data,(g[1]||g[0]).data);if(d===_.Je)return g=yield lB(a,c,f),$A(g.data);if(!MediaSource.isTypeSupported(`${d.split("/")[0]||""}/mp4;codecs="${e}"`))return 0;throw new _.H(_.G,4,4030);})},nB=function(a,b){a=a.map(c=>c.ea[b]);return a.some(c=>null==c)?null:a},PA=function(a,b){a.ea.forEach(c=>
21
+ {c.codecs=b.join(",")})},oB=function(a,b){a=a.ea.find(c=>{c=c.V;return c[0].position<=b&&b<=c[c.length-1].position});return null==a?null:a.V.find(c=>c.position===b)||null},pB=function(a,b){a.ea.forEach(c=>{c.width=b})},qB=function(a,b){a.ea.forEach(c=>{c.height=b})},rB=function(a,b){a.ea.forEach(c=>{c.frameRate=b})},sB=function(a,b){a.ea.forEach(c=>{c.bandwidth=b})},tB=function(a,b){return a.ea.some(c=>c.id===b)},uB=function(a,b){a=a.map(c=>c.a[b]);return a.some(c=>null==c)?null:a},xB=function(a,
22
+ b,c,d){var e=a[0].length();e=VA(e).map(f=>{const g=uB(a,f)||[],h=nB(b,f)||[],k=nB(c,f)||[];return vB({variants:g,textStreams:h,thumbStreams:k,Pf:d&&0===f})});wB(e);return e},zB=function(a){if(1===a.length)return a[0];const b=a[0],c=a.reduce((e,f)=>e+f.duration,0),d=new Map;a.forEach((e,f)=>{const g=xA(e);0<f&&yB(g,e.startTime);g.forEach(h=>{const k=h.ec;d.has(k)?d.get(k).push(h):d.set(k,[h])})});yA(b,e=>{var f=d.get(e.ec);const g=f.flatMap(h=>h.V);f=f.map(h=>({keyInfo:h.keyInfo,type:h.qe,drmInfos:h.drmInfos,
23
+ keyId:h.keyId}));f=iB(f);e.keyInfo=f.keyInfo;e.qe=f.type;e.encrypted=f.type===mA;e.drmInfos=f.drmInfos;e.keyId=f.keyId;e.V=g;e.segmentIndex.replace(g)});return Object.assign({},b,{duration:c,endTime:a[0].startTime+c})},vB=function(a){const b=a.variants,c=a.textStreams,d=a.thumbStreams;var e=a.Pf;a=[...b.flatMap(l=>[l.video,l.audio]),...c,...d].filter(Boolean);const f=a[0].ub;e=e?f:0;AB(a,e);const {Eb:g,bd:h,duration:k}=a[0];return{variants:b,textStreams:c,thumbStreams:d,startTime:0,id:`P${g}`,endTime:h,
24
+ duration:k+e,Eb:g}},wB=function(a){for(let b=0;b<a.length;b++){const c=a[b],d=a[b-1];c.startTime=d?d.endTime:0;c.endTime=c.startTime+c.duration}},AB=function(a,b){yB(a,0);BB(a);0<b&&yB(a,b)},yB=function(a,b){a.forEach(c=>{const d=-c.ub+b;c.segmentIndex.offset(d);c.bd+=d;c.ub=b})},BB=function(a){const b=CB(a);a.forEach(c=>{_.kv(c.segmentIndex,b);c.duration=b;c.bd=c.ub+b})},CB=function(a){let b=Infinity;a.filter(zA).forEach(c=>{b=Math.min(b,c.duration)});return b},DB=function(a,b){return _.y(function*(){var c=
25
+ _.kh([b],a.f.attemptParameters);c.type=1;c=yield a.F(c);let d="";try{d=_.Fg(c.data)}catch(e){throw new _.H(_.G,4,4042);}d=d.replace(/\r\n|\r(?=[^\n]|$)/gm,"\n");d=d.trim();return{text:d,response:c}})},KB=function(a,b){return _.y(function*(){var c=EB(a,b,a.h,"");if(1===c.type){a.w.set(a.h,c);c=_.Qo(c.V[0].a)||"";c=null!=_.Po.video[c]?_.w:null!=_.Po.audio[c]?_.p:null;var d="";c===_.w?d="avc1.42E01E":c===_.p&&(d="mp4a.40.2");{c=a.K;var e=a.h;d=a.f.hlsDefaultCodecs||d;const h=[],k=[];k.push(new _.dh(_.ja,
26
+ "0"));k.push(new _.dh(_.mb,e));d.length&&k.push(new _.dh(_.la,d));h.push(new _.eh(c.a++,dA,k));c=new FB(e,0,h)}}d=c.ca;c=rA(d,"EXT-X-MEDIA");e=rA(d,dA);d=rA(d,"EXT-X-IMAGE-STREAM-INF");c={tc:{ff:sA(c,["AUDIO",_.sb]),closedCaptions:sA(c,Rz),kg:sA(c,"SUBTITLES")},Xe:e,Kf:d};c=yield GB(a,c);if(!a.D)throw new _.H(_.G,7,7001);d=MA(c[0]);e=HB(a,d.delay,c);if(!IB(a)){a.H=d.Oc;d=0;for(var f of a.g.values())d=Math.max(d,f.ea[0].ub);for(f=0;95443.7176888889<=d;)f+=95443.7176888889,d-=95443.7176888889;if(f){a.a.debug("Offsetting live streams by",
27
+ f,"to compensate for rollover");for(var g of a.g.values())d=g.ea[0],95443.7176888889>d.ub?(a.a.debug("Offset applied to",d.type),d.segmentIndex.offset(f)):a.a.debug("Offset NOT applied to",d.type)}}g=KA(c);"LIVE"===a.m||"EVENT"===a.m?(g=Math.max(g,e.F),isNaN(a.f.availabilityWindowOverride)||(g=a.f.availabilityWindowOverride),e.j=g):a.m===_.Tt&&JB(e,g,c);g={presentationTimeline:e,periods:c,offlineSessionIds:[],minBufferTime:0};a.a.debug("HLS playlist parsed",g);return g})},PB=function(a,b,c,d){return _.y(function*(){var e=
28
+ b.ea[0],f=LB(a,e);const {response:g,text:h}=yield DB(a,f.toString());f=EB(a,h,g.uri,e.ec);MB(f,e.codecs,e.type);if(1!==f.type)throw new _.H(_.G,4,4017);const k=(yield NB(a,f,e.type,e.codecs)).flatMap(l=>l.V);e.V=k;e.segmentIndex.replace(k);_.Xu(c,k,d);e=k[k.length-1];uA(f.ca,Wz)&&(OB(a,_.Tt),_.Uu(c,!0),c.f=e.endTime)})},LB=function(a,b){const c=new _.dg(b.cf);if(a.f.hlsLowLatency){a=c.a;if(b.Qc){b=b.segmentIndex;if(b=b.a[b.a.length-1]){var d=b.a,e=d.length-1;b={Sf:b.position,Yf:d&&0<d.length?e:null}}else b=
29
+ null;const {Sf:f,Yf:g}=b;null!==f&&(a.add("_HLS_msn",f),null!==g&&a.add("_HLS_part",g))}b=a;_.og(b);b.g&&_.gg(c,a)}return c},EB=function(a,b,c,d){a:{a=a.K;b=b.trim().split(/\n+/m);if(!/^#EXTM3U($|[ \t\n])/m.test(b[0]))throw new _.H(_.G,4,4015);var e=b,f=0,g=!0;for(h of e){var h=h.trim();if(!h.length||/^#(?!EXT)/m.test(h)||g)g=!1;else if(e=_.fh(0,h),RA.includes(e.name)){f=1;break}else e.name===dA&&(g=!0)}h=f;f=[];g=!0;for(var k of _.Du(b)){let {xd:l,item:m,next:n}=k;m=m.trim();if(!m.length||/^#(?!EXT)/m.test(m)||
30
+ g)g=!1;else{e=m;e=_.fh(a.a++,e);if(QB.includes(e.name)){if(1!==h)throw new _.H(_.G,4,4017);k=b.splice(l,b.length-l);a=UA(a,c,k);c=new FB(c,h,f.concat(a.ca),a.V);break a}f.push(e);e.name===dA&&(e.attributes.push(new _.dh(_.mb,n)),g=!0)}}c=new FB(c,h,f)}c.a=d;RB(c);return c},MB=function(a,b,c){if(1===a.type&&(a=a.V.map(d=>d.a?d.a:d.f.map(e=>_.qg(e,_.mb))||null).map(d=>_.Ro(d,c,b)),1<(new Set(a)).size))throw new _.H(_.G,4,4045,"Media playlist contains discontinuities with different MIME types. This is valid, but not yet supported.");
31
+ },NB=function(a,b,c,d){return _.y(function*(){const e=b.a;var f=b.V;var g=void 0===g?0:g;var h=(h=uA(b.ca,Zz))?Number(h.value):g;g=[];a:{var k=a.g.get(b.a),l=!IB(a),m=uA(b.ca,Vz);if(m)var n=Number(m.value);else{k?(m=k.ea[k.ea.length-1].V,m=m[m.length-1].Eb):m=0;if(l&&0<m)try{var q=uA(b.ca,Zz);if(!q)throw SB.error("Failed to infer discontinuity number, because EXT-X-MEDIA-SEQUENCE tag is missing."),Error(fA);var t=Number(q.value),u=oB(k,t);if(!u)throw SB.error("Failed to infer discontinuity number, could not find the appropriate segment in the previous playlist"+
32
+ ` (segment position = ${t})`),Error(fA);n=u.Eb;break a}catch(A){throw new _.H(_.G,4,4024,"EXT-X-DISCONTINUITY-SEQUENCE tag is required for discontinuous HLS live streams.");}n=0}}q=yield TB(a,b.f,e,f,h,c,d);t=h;if(0===f.length)f=[];else{u=[];h=[];for(var x of f)tA(x.ca,Uz)&&0<h.length&&(u.push(h),h=[]),h.push(x);u.push(h);f=u}for(x=0;x<f.length;x++)u=f[x],q=yield UB(a,e,b.f,u,n+x,t,q,c,d,g[g.length-1]||null),g.push(q),q=q.endTime,t+=u.length;return g})},OB=function(a,b){a.m=b;IB(a)&&a.j.stop()},GB=
33
+ function(a,b){return _.y(function*(){var c=b.tc.closedCaptions;var d=new Map;for(var e of c){c=OA(e);var f=oA(e,_.Ca),g=oA(e,"INSTREAM-ID");d.has(f)||d.set(f,new Map);d.get(f).set(g,c)}c=b.Xe;e=new Map;for(k of c){f=_.qg(k,"AUDIO");c=_.qg(k,_.sb);var h=_.qg(k,"SUBTITLES");g=VB(a,k);if(h){const l=_.Oh(_.v,g);e.set(h,l);h=g.indexOf(l);-1<h&&g.splice(h,1)}f&&(h=WB(_.p,g),e.set(f,h));c&&(f=WB(_.w,g),e.set(c,f))}var k=e;e=yield XB(a,b.tc.ff,k);d=yield YB(a,b.Xe,e,d);k=yield ZB(a,b.tc.kg,k);e=yield $B(a,
34
+ b.Kf);k=xB(d,k,e,!IB(a));k=[zB(k)];a.D.filterAllPeriods(k);return k})},HB=function(a,b,c){let d=!0,e=null,f=0;IB(a)||(d=!1,e=0,f=b);const g=new _.Gz(e,f,!0);_.Uu(g,d);yA(c,(h,k)=>{_.Xu(g,h.V,k.startTime)});return g},XB=function(a,b,c){return _.y(function*(){var d=b.filter(f=>""!==(_.qg(f,_.mb)||""));if(0===d.length)return new Map;let e=[aC(a,d[0],c)];yield e[0];e=e.concat(d.slice(1).map(f=>aC(a,f,c)));d=yield Promise.all(e);return NA(d)})},YB=function(a,b,c,d){return _.y(function*(){const e=new Set;
35
+ var f=[...b];let g=0;var h=Infinity;for(let k=0;k<f.length;++k){const l=Number(oA(f[k],_.ja));l<h&&(h=l,g=k)}h=f.splice(g,1).pop();h=yield bC(a,h,c,d,e);f=f.map(k=>bC(a,k,c,d,e));f=yield Promise.all(f);f.splice(g,0,h);return f.reduce(_.wu,[])})},ZB=function(a,b,c){return Promise.all(b.map(d=>aC(a,d,c)))},$B=function(a,b){return Promise.all(b.map(c=>cC(a,c)))},VB=function(a,b){var c=_.qg(b,_.la,a.f.hlsDefaultCodecs||"avc1.42E01E,mp4a.40.2").split(/\s*,\s*/);b=new Set;const d=[];for(const e of c)c=
36
+ _.Ju(e)[0],b.has(c)?a.a.debug("Ignoring duplicate codec"):(d.push(e),b.add(c));return d},WB=function(a,b){if(1===b.length)return b[0];a=_.Oh(a,b);if(null!=a)return a;throw new _.H(_.G,4,4025,{codecList:b});},aC=function(a,b,c){return _.y(function*(){const d=oA(b,_.mb);return dC(a,d,()=>_.y(function*(){const e=oA(b,_.Ca);var f={AUDIO:_.p,VIDEO:_.w,SUBTITLES:_.v,"CLOSED-CAPTIONS":_.v}[oA(b,"TYPE").toUpperCase()];if(!f)throw new _.H(_.G,4,4044,"EXT-X-MEDIA tag has an invalid TYPE attribute.");const g=
37
+ c.get(e)||"",h=OA(b),k=_.qg(b,"NAME"),l=b.getAttribute("DEFAULT"),m=b.getAttribute("AUTOSELECT"),n=_.qg(b,"CHANNELS");return yield eC(a,{uri:d,codecs:g,type:f,language:h,primary:!!l&&!!m,name:k,channelsCount:f===_.p?n?parseInt(n.split("/")[0],10):null:null,groupId:e,closedCaptions:null,ee:null})}))})},cC=function(a,b){return _.y(function*(){const c=oA(b,_.mb);return dC(a,c,()=>_.y(function*(){var d=_.qg(b,_.la)||"jpg",e=OA(b);const f=_.qg(b,"NAME");d=yield eC(a,{uri:c,codecs:d,type:_.ed,language:e,
38
+ name:f,primary:!1,channelsCount:null,closedCaptions:null,groupId:null,ee:null});(e=_.qg(b,_.ja))&&sB(d,Number(e));return d}))})},bC=function(a,b,c,d,e){return _.y(function*(){var f=Number(oA(b,_.ja));if(null!=b.getAttribute("FRAME-RATE")||null!=b.getAttribute(_.Za)){var g=_.qg(b,"FRAME-RATE");var h=_.qg(b,_.Za),[k,l]=h?h.split("x"):[null,null];g={frameRate:qA(g),width:qA(k),height:qA(l)}}else g=null;if(h=yield fC(a,b,g,c,d)){g=h.video;h=h.audio;var m=0<h.length?h:[null];g=0<g.length?g:[null];h=[];
39
+ for(const X of m)for(const na of g)if(m=(na?na.ea[0].ec:"")+" - "+(X?X.ea[0].ec:""),e.has(m))a.a.debug("Skipping variant which only differs in text streams.");else{a:{var n=a;var q=X,t=na,u=f;const tb=[],Jd=(t||q).length();for(let Pb=0;Pb<Jd;Pb++){var x=q?q.ea[Pb]||null:null,A=t?t.ea[Pb]||null:null,E=x,D=A;E=E&&D?_.Gu(E.drmInfos,D.drmInfos)?_.Fu(E.drmInfos,D.drmInfos):null:E?E.drmInfos:D?D.drmInfos:null;if(!E){n=null;break a}D=u;x={id:n.I++,language:x?x.language:_.ye,primary:!!x&&x.primary||!!A&&
40
+ A.primary,audio:x,video:A,bandwidth:D,drmInfos:E,allowedByApplication:!0,allowedByKeySystem:!0};tb.push(x)}n=new gC(tb)}null==n?a.a.warn("Incompatible DRM info in HLS variant. Skipping."):(h.push(n),e.add(m))}f=h}else f=[];return f})},fC=function(a,b,c,d,e){return _.y(function*(){let f=VB(a,b);var g=_.qg(b,"AUDIO"),h=_.qg(b,_.sb),k=g||h;k=k&&d.has(k)?d.get(k):[];g={audio:g?k:[],video:h?k:[]};a.a.debug("Guessing stream type for",b.toString());h=!1;const l=oA(b,_.mb);var m=g.audio.find(q=>q.ec===l);
41
+ var n=_.Oh(_.w,f);n=c||n;1!==f.length||n?!k.length&&1<f.length?(a.a.debug("Guessing multiplexed audio+video"),m=_.w,f=[f.join(",")]):g.audio.length&&m?(a.a.debug(gA),m=_.p,h=!0):g.video.length?(a.a.debug(gA),m=_.p):(a.a.debug("Guessing video-only"),m=_.w):(m=_.p,a.a.debug(gA));n=null;h||(n=yield hC(a,b,f,m,e,c));if(null==n)return null;g[m]=[n];m===_.p&&c&&k.forEach(q=>{pB(q,c.width);qB(q,c.height);rB(q,c.frameRate)});QA(g);return g})},hC=function(a,b,c,d,e,f){return _.y(function*(){const g=oA(b,_.mb);
42
+ return dC(a,g,()=>_.y(function*(){var h=_.qg(b,Rz);let k=null;d===_.w&&h&&"NONE"!==h&&(k=e.get(h));h=WB(d,c);return yield eC(a,{uri:g,codecs:h,type:d,closedCaptions:k,primary:!1,language:null,name:null,channelsCount:null,groupId:null,ee:f})}))})},dC=function(a,b,c){if(a.g.has(b))return a=a.g.get(b),Promise.resolve(a);if(a.g.a.has(b))return a.g.a.get(b)||null;c=c();a.g.set(b,c);return c},eC=function(a,b){return _.y(function*(){const c=b.uri,d=b.codecs,e=b.type,f=b.language,g=b.groupId,h=b.primary,
43
+ k=b.name,l=b.channelsCount,m=b.closedCaptions,n=b.ee;let q=wA(a.h,c);if(IB(a)&&a.w.has(q)){var t=a.w.get(q);a.w.delete(q)}else{const {response:X,text:na}=yield DB(a,q);q=X.uri;t=EB(a,na,q,c);MB(t,d,e)}if(1!==t.type)throw new _.H(_.G,4,4017);var u=AA(t.ca);OB(a,u);const x=LA(t.ca,u,a.f.hlsLowLatency||!1);u=yield NB(a,t,e,d);const A=a.f.hlsLowLatency?_.Ex:_.$t;let E=void 0;e===_.v&&(E=_.hu);const {Qc:D}=EA(t.ca);t=u.map(X=>{const na=X.V,tb=X.rf,Jd=X.mimeType;X=X.Eb;const Pb=na[0].startTime,Qa=na[na.length-
44
+ 1].endTime,Fe=Qa-Pb,bb=new _.Hz(na),qa=na[0].initSegment||null;return{id:a.I++,originalId:k,createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:bb.f.bind(bb),getSegmentReference:bb.get.bind(bb),adjustSegmentDurations:bb.g.bind(bb),getDuration:bb.getDuration.bind(bb),segmentIndex:bb,segmentLookupStrategy:A,initSegmentReference:qa,mimeType:Jd,codecs:d,kind:E,qe:tb.type,encrypted:tb.type===mA,keyId:tb.keyId,language:f||_.ye,label:k,type:e,primary:h,trickModeVideo:null,emsgSchemeIdUris:null,
45
+ frameRate:n?n.frameRate:void 0,width:n?n.width:void 0,height:n?n.height:void 0,bandwidth:void 0,roles:[],channelsCount:l,closedCaptions:m,keyInfo:tb.keyInfo,V:na,drmInfos:tb.drmInfos,Eb:X,ec:c,cf:q,ub:Pb,bd:Qa,duration:Fe,Qc:D,groupId:g,Rf:x}});return new iC(t)})},RB=function(a){1===a.type&&a.V.slice(1).forEach(b=>{if(tA(b.ca,Yz))throw new _.H(_.G,4,4045,"Media playlist contains one or more EXT-X-MAP tags that are not located at the beginning of the playlist. This is valid, but not yet supported.");
46
+ })},jC=function(a,b,c){a=rA(a.ca,Yz);if(1<a.length)throw new _.H(_.G,4,4020);a=a[0];if(!a)return null;const d=oA(a,_.mb),e=wA(b,d);b=FA(a,null,!0);return new _.Ez(()=>[e],b.ta,b.ha,c)},kC=function(a,b,c,d,e,f,g){const h=[];for(const q of _.Du(b.f)){b=q.xd;const t=q.item;{var k=0===b,l=k?a:h[h.length-1],m=k?d:l.endTime,n=Number(_.qg(t,"DURATION"));n=m+n;k=FA(t,k?null:l.ha,k);l=_.qg(t,_.mb);const u=(l=wA(g,l))?[l]:[];m=new GA(c,m,n,()=>u,k.ta,k.ha,e,f,!1,null,null,null,null);if("YES"===_.qg(t,"INDEPENDENT")||
47
+ 0===b)m.g=!0;h.push(m)}}return h},lC=function(a,b,c,d,e,f,g,h,k,l,m){const n=c.ca;var q=c.a;const t=null!=q,u=q?[q]:[];if(!t&&!a.f.hlsLowLatency)return null;a=0;q={ta:0,ha:null};let x=null;t?({duration:c}=DA(n),a=e+c,q=CA(n,b?b.ha:null)):(b=kC(b,c,d,e,f,g,k),a=b[b.length-1].endTime,x=b);h=h===_.ed?vA(n):null;d=new GA(d,e,a,()=>u,q.ta,q.ha,f,g,!1,null,h?h.ve:null,h?h.Ve:null,h?h.durationPerTile:null,x);d.Eb=l;d.initSegment=m||void 0;return d},TB=function(a,b,c,d,e,f,g){return _.y(function*(){var h=
48
+ d[0];if(null!=a.B)return a.B;const k=yield mC(a,f,g,h);var l=hB([h],a.h,k,null)[0];const m=jC(h,b,l.keyInfo);l=IA(l.keyInfo,e);h=yield nC(a,c,m,h,e,l,k,g);a.a.debug(`Setting playlist start time to ${h}.`);return a.B=h})},UB=function(a,b,c,d,e,f,g,h,k,l){return _.y(function*(){var m=d[0],n=null==l;const q=yield mC(a,h,k,m);var t=hB(d,a.h,q,l?l.Qf:null);const u=t[t.length-1];t=iB(t);const x=jC(m,c,t.keyInfo)||(l?l.Lf:null);var A=IA(t.keyInfo,f);m=n&&IB(a)?0:yield oC(a,e,b,x,m,f,A,q,k,g);n=[];for(A=
49
+ 0;A<d.length;A++){var E=d[A];const D=n[n.length-1]||null,X=0===A?g:D.endTime,na=f+A,tb=IA(t.keyInfo,na);(E=lC(a,D,E,na,X,m,tb,h,c,e,x))&&n.push(E)}return{V:n,rf:t,Qf:u,mimeType:q,endTime:n[n.length-1].endTime,Eb:e,Lf:x}})},mC=function(a,b,c,d){return _.y(function*(){const e=d.a;var f=uA(d.ca,Yz);f=f?oA(f,_.mb):null;return pC(a,b,c,e,f)})},nC=function(a,b,c,d,e,f,g,h){return _.y(function*(){if(null==d.a)return 0;var k;k=(k=a.g.get(b))?(k=oB(k,e))?k.startTime:null:null;if(null!=k)return a.a.debug("Found segment start time in previous manifest"),
50
+ k;a.a.debug("Unable to find segment start time in previous manifest!");k=HA(d,f);return mB(a.M,c,k,g,h,null!=f)})},IB=function(a){return a.m===_.Tt},oC=function(a,b,c,d,e,f,g,h,k,l){return _.y(function*(){let m;a.G.has(b)?m=a.G.get(b):(m=(yield nC(a,c,d,e,f,g,h,k))-l,a.a.debug(`Segment #${f} has `+`timestamp offset ${m} s`),a.G.set(b,m));return m})},pC=function(a,b,c,d,e){return _.y(function*(){const f=[d,e].filter(Boolean);var g=_.Rh(f,b,c);if(g)return g;g=_.kh([d],a.f.attemptParameters);g.method=
51
+ "HEAD";g.type=2;g=(yield a.F(g)).headers["content-type"];if(!g)throw new _.H(_.G,4,4021,f.join(", "));return g.split(";")[0]})},JB=function(a,b,c){a.f=b;b=c[0];const d=JA(b);a.offset(-d.ub);yA(b,e=>{e.segmentIndex.offset(-d.ub);_.kv(e.segmentIndex,d.duration)})},FB=class{constructor(a,b,c,d){if(1===b){if(!d||0===d.length)throw new _.H(_.G,4,4043,"Media playlist must have at least one segment!");if(null==d[0].a)throw new _.H(_.G,4,4043,"Media playlist must have at least one full segment!");}this.f=
52
+ a;this.a="";this.type=b;this.ca=c;this.V=1===b?d:null}},TA=class{constructor(a,b,c){c=void 0===c?[]:c;this.ca=b;this.a=a;this.f=c}},GA=class extends _.fv{constructor(a,b,c,d,e,f,g,h,k,l,m,n,q,t){t=void 0===t?[]:t;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,t);this.initSegment=void 0;this.Eb=0}},RA=[Vz,Wz,"EXT-X-I-FRAMES-ONLY",Zz,$z,aA,cA,eA],QB=["EXTINF",Tz,"EXT-X-DATERANGE",Uz,Xz,Yz,"EXT-X-PROGRAM-DATE-TIME"],SA=["EXT-X-PART",
53
+ bA],qC=class{constructor(){this.a=0}},rC=class{constructor(){this.f=new Map;this.a=new Map}set(a,b){this.a.set(a,b);return b.then(c=>this.f.set(a,c)).catch(()=>{}).then(()=>this.a.delete(a))}has(a){return this.f.has(a)}get(a){return this.f.get(a)||null}values(){return Array.from(this.f.values())}clear(){this.a.clear();this.f.clear()}},SB=new _.O("clpp.hls.DiscontinuityUtils");var kB={"com.apple.streamingkeydelivery":function(a,b){if(b===_.Je)throw new _.H(_.G,4,4041);if(oA(a,hA)===kA)throw new _.H(_.G,4,4044,"EXT-X-KEY:METHOD SAMPLE-AES-CTR is not supported in FairPlay.");return _.zu(_.Ic,[{initDataType:_.he,initData:new Uint8Array(0)}],"")},"com.microsoft.playready":cB,"urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":cB,"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":function(a){var b=oA(a,hA);if(!aB.includes(b))return bB.error("Widevine in HLS is only supported with [",
54
+ aB.join(", "),"], not",b),null;b=oA(a,_.mb);b=_.go(b);b=_.I(b.data);b=_.zu(_.Kc,[{initDataType:_.tc,initData:b}],"");if(a=_.qg(a,"KEYID"))b.keyIds=[a.substr(2).toLowerCase()];return b}},aB=["SAMPLE-AES",kA],bB=new _.O("clpp.hls.DrmParser");var jB=new _.O("clpp.hls.EncryptionUtils");var sC=class{constructor(a){this.f=new _.O("clpp.hls.MediaReader");this.g=a;this.a={attemptParameters:_.hh()}}};var iC=class{constructor(a){this.ea=a}length(){return this.ea.length}};var gC=class{constructor(a){this.a=a}length(){return this.a.length}};var tC=class{constructor(){this.f=this.D=null;this.I=1;this.g=new rC;this.h="";this.K=new qC;this.H=0;this.A=new Map;this.j=new _.Zh(()=>{this.xb()});this.m=_.Tt;this.C=null;this.o=new _.Uo;this.B=null;this.a=new _.O("clpp.hls.HlsParser");this.w=new Map;this.G=new Map;this.M=new sC(this.F.bind(this));this.J=!1}configure(a){this.f=a;this.M.a=a}setCurrentVariant(a){const b=a.video?a.video.id:null;a=a.audio?a.audio.id:null;this.A.clear();for(const c of this.g.values())(null!=b&&tB(c,b)||null!=a&&tB(c,
55
+ a))&&this.A.set(c.ea[0].ec,c)}start(a,b){const c=this;return _.y(function*(){if(c.J)throw Error("start() may be called only once!");c.J=!0;c.D=b;const {response:d,text:e}=yield DB(c,a);c.h=d.uri;const f=yield KB(c,e);c.C=f;const g=c.H;0<g&&c.j.$(g);return f})}stop(){this.j&&(this.j.stop(),this.j=null);const a=[];this.o&&(a.push(this.o.destroy()),this.o=null);this.g.clear();this.A.clear();this.f=this.D=null;this.w.clear();this.C=null;return Promise.all(a)}onExpirationUpdated(){}update(){const a=this;
56
+ return _.y(function*(){var b=a.C;if(!IB(a)&&b){var c=b.presentationTimeline;b=b.periods[0].startTime;var d=[];"LIVE"===a.m&&(a.B=null);var e=Array.from(a.g.values()),f=Array.from(a.A.values());e=a.f.hlsLowLatency&&0<f.length?f:e;yield PB(a,e[0],c,b);for(f=1;f<e.length;f++)d.push(PB(a,e[f],c,b));yield Promise.all(d)}})}xb(){const a=this;return _.y(function*(){a.a.debug(_.St);if(a.D)try{yield a.update(),a.j.$(a.H)}catch(b){a.D&&(a.D.onError(b),1===b.severity&&a.j.$(.1))}})}F(a){if(!this.o)throw new _.H(_.G,
57
+ 7,7001);a=this.D.networkingEngine.fetch(a);_.rh(this.o,a);return a.P}};_.z("clpp.hls.HlsComponent",class extends _.Mp{constructor(){super()}f(){_.Kn.m3u8=tC;_.In[_.Vi]=tC;_.In[lA]=tC}a(){_.nv("m3u8");_.ov(_.Vi);_.ov(lA)}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 yI=function(a){a.a.one(a.l,_.nd,()=>xI(a))},xI=function(a){const b=a.l.getSurface().getMedia();if(b)if(a.h){a.a.on(b.textTracks,_.Nb,d=>zI(a,d));var c=Array.from(b.textTracks);c.filter(d=>d.kind===_.td).forEach(d=>{zI(a,{track:d})});!AI(c)&&a.m&&(a.f.warn("The metadata track is not present. Changing an audio track in order to enforce the creation of the metadata track."),BI(a,b))}else a.f.warn("The clpp.ttml.TextParser class is not available. Please register the ttml component first.");
2
- else a.f.warn("A video element is not available. Skipping.")},zI=function(a,b){b=b.track;b.kind===_.td&&(a.f.info("The metadata track has been added."),b.mode=_.dd,a.a.on(b,_.Nc,c=>CI(a,c)))},AI=function(a){return a.some(b=>b.kind===_.td)},BI=function(a,b){const c=a.l.getTrackManager(),d=c.la(),e=c.getAudioTracks().find(g=>g!==d);if(e){var f=()=>c.qa(d);a.a.on(b.textTracks,_.Nb,g=>{g.track.kind===_.td&&(a.a.off(b.textTracks,_.Nb,f),c.qa(d))});c.qa(e)}else a.f.warn("Can't enforce the creation of the metadata track if single audio track. Skipping.")},
3
- CI=function(a,b){const c=DI(a);c&&Array.from(b.target.activeCues||[]).forEach(d=>{if(d!==a.g&&Number.isFinite(d.startTime)&&Number.isFinite(d.endTime)&&"org.id3"===d.type&&d.value&&"TXXX"===d.value.key){var e=new EI(d);if(e.f===c&&null!==e.a){a.g=d;d=a.h.parseMedia(_.Mg(e.a),{periodStart:a.j,segmentStart:e.startTime,segmentEnd:e.endTime});const f=a.l.getTextDisplayer();f.remove(0,e.startTime);f.append(d.cues,d.styles)}}})},DI=function(a){return(a=a.l.getTrackManager().ma())&&a.language&&a.language.toLowerCase()},
4
- EI=class{constructor(a){this.startTime=a.startTime;this.endTime=a.endTime;this.a=this.f=null;a=a.value;if(!_.z(a)){a:{var b=a.info;if(_.pf(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=_.pf(a)?a:null}}};var FI=class{constructor(a,b,c){this.l=a;this.m=b;this.j=c;this.a=new _.uo;this.h=(a=_.io[_.Yb]||null)?new a(this.l.getConfiguration()):null;this.f=new _.O("clpp.hlssmpte.ImageCueHandler");this.g=null;yI(this)}destroy(){this.a.release();this.g=null;return Promise.resolve()}};var GI=class extends _.jq{constructor(){super();this.a=null;this.f=!1}onPlayerCreated(){}onContentWillLoad(a){if(this.f=_.gi()){var b=a.getConfiguration();b=_.kf(b.hlssmpte||{});typeof b.patchMetadataTrack!==_.lc&&(b.patchMetadataTrack=!1);_.qf(b.timestampOffset)||(b.timestampOffset=0);this.a=new FI(a,b.patchMetadataTrack,b.timestampOffset)}}onPlayerWillDestroy(){const a=this;return _.w(function*(){a.a&&(yield a.a.destroy(),a.a=null)})}id(){return"hlssmpte"}};_.x("clpp.hlssmpte.HlsSmptePlugin",GI);
5
- GI.Id="hlssmpte";_.Sm(new class{create(){return new GI}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var IJ=function(a){a.a.one(a.l,_.nd,()=>HJ(a))},HJ=function(a){const b=a.l.getSurface().getMedia();if(b)if(a.h){a.a.on(b.textTracks,_.Nb,d=>JJ(a,d));var c=Array.from(b.textTracks);c.filter(d=>d.kind===_.td).forEach(d=>{JJ(a,{track:d})});!KJ(c)&&a.m&&(a.f.warn("The metadata track is not present. Changing an audio track in order to enforce the creation of the metadata track."),LJ(a,b))}else a.f.warn("The clpp.ttml.TextParser class is not available. Please register the ttml component first.");
2
+ else a.f.warn("A video element is not available. Skipping.")},JJ=function(a,b){b=b.track;b.kind===_.td&&(a.f.info("The metadata track has been added."),b.mode=_.dd,a.a.on(b,_.Nc,c=>MJ(a,c)))},KJ=function(a){return a.some(b=>b.kind===_.td)},LJ=function(a,b){const c=a.l.getTrackManager(),d=c.na(),e=c.getAudioTracks().find(g=>g!==d);if(e){var f=()=>c.sa(d);a.a.on(b.textTracks,_.Nb,g=>{g.track.kind===_.td&&(a.a.off(b.textTracks,_.Nb,f),c.sa(d))});c.sa(e)}else a.f.warn("Can't enforce the creation of the metadata track if single audio track. Skipping.")},
3
+ MJ=function(a,b){const c=NJ(a);c&&Array.from(b.target.activeCues||[]).forEach(d=>{if(d!==a.g&&Number.isFinite(d.startTime)&&Number.isFinite(d.endTime)&&"org.id3"===d.type&&d.value&&"TXXX"===d.value.key){var e=new OJ(d);if(e.f===c&&null!==e.a){a.g=d;d=a.h.parseMedia(_.Jg(e.a),{periodStart:a.j,segmentStart:e.startTime,segmentEnd:e.endTime});const f=a.l.getTextDisplayer();f.remove(0,e.startTime);f.append(d.cues,d.styles)}}})},NJ=function(a){return(a=a.l.getTrackManager().oa())&&a.language&&a.language.toLowerCase()},
4
+ OJ=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(_.qf(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=_.qf(a)?a:null}}};var PJ=class{constructor(a,b,c){this.l=a;this.m=b;this.j=c;this.a=new _.uo;this.h=(a=_.io[_.Zb]||null)?new a(this.l.getConfiguration()):null;this.f=new _.O("clpp.hlssmpte.ImageCueHandler");this.g=null;IJ(this)}destroy(){this.a.release();this.g=null;return Promise.resolve()}};var QJ=class extends _.kq{constructor(){super();this.a=null;this.f=!1}onPlayerCreated(){}onContentWillLoad(a){if(this.f=_.mi()){var b=a.getConfiguration();b=_.lf(b.hlssmpte||{});typeof b.patchMetadataTrack!==_.ic&&(b.patchMetadataTrack=!1);_.rf(b.timestampOffset)||(b.timestampOffset=0);this.a=new PJ(a,b.patchMetadataTrack,b.timestampOffset)}}onPlayerWillDestroy(){const a=this;return _.y(function*(){a.a&&(yield a.a.destroy(),a.a=null)})}id(){return"hlssmpte"}};_.z("clpp.hlssmpte.HlsSmptePlugin",QJ);
5
+ QJ.Id="hlssmpte";_.Sm(new class{create(){return new QJ}});};f.call(g, window);
package/cl.htmlcue.js CHANGED
@@ -1,25 +1,25 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var qH="Unsupported unit",rH="clpp-text-plain",sH="clpp-text-ttml",tH="clpp.htmlcue.HtmlTextDisplayer",uH="initial",vH=function(a,b){let c=0,d=a.length-1;for(;c<=d;){const e=c+d>>1,f=b(a[e]);if(0===f)return e;0<f?c=e+1:d=e-1}return-1},wH=function(a){if(!a.input)return null;var b=a.input.match(/^([^<]*)(<[^>]+>?)?/);b=b[1]?b[1]:b[2];a.input=a.input.substr(b.length);return b},yH=function(a){let b=null;for(;b=a.match(/&(amp|lt|gt|lrm|rlm|nbsp);/);)a=a.replace(b[0],c=>xH[c]);return a},AH=
2
- function(a,b){zH(a,b);Array.from(b.getElementsByTagName("*")).forEach(c=>{zH(a,c)})},zH=function(a,b){for(const c in a)null!=a[c]&&(b.style[c]=a[c])},BH=function(a,b){return 0===a?"0":a+b},CH=function(a,b){return 1>Math.abs(a-b)||a<b},DH=function(a,b){return a<b&&1<Math.abs(a-b)},EH=function(a,b){return a>b&&1<Math.abs(a-b)},FH=function(a,b){return 1>Math.abs(a-b)||a>b},HH=function(a){const b=a.getBoundingClientRect();var c=getComputedStyle(a,null);const d=parseFloat(c.getPropertyValue("border-left-width"))||
3
- 0,e=parseFloat(c.getPropertyValue("border-right-width"))||0;var f=parseFloat(c.getPropertyValue("border-top-width"))||0;c=parseFloat(c.getPropertyValue("border-bottom-width"))||0;const g=(b.top||a.offsetTop)+f;f=(b.height||a.offsetHeight)-f-c;return new GH(b.left+d,b.right+e,g,(b.bottom||g+f)+c,f,(b.width||a.offsetWidth)-d-e)},IH=function(a){return new GH(a.f,a.g,a.h,a.a,a.height,a.width)},JH=function(a,b){return b.some(c=>DH(a.f,c.g)&&EH(a.g,c.f)&&DH(a.h,c.a)&&EH(a.a,c.h))},KH=function(a,b){return FH(a.h,
4
- b.h)&&CH(a.a,b.a)&&FH(a.f,b.f)&&CH(a.g,b.g)},LH=function(a,b,c){switch(c){case "+x":return DH(a.f,b.f);case "-x":return EH(a.g,b.g);case "+y":return DH(a.h,b.h);case "-y":return EH(a.a,b.a);default:throw Error("Unknown axis");}},MH=function(a){return a.f.writingMode===_.yo},NH=function(a){var b=a.a.childNodes[0],c=a.a.getBoundingClientRect();const d=b.getClientRects();b=c.height/d.length;c=c.width/d.length;return MH(a)?b:c},OH=function(a){switch(a.f.writingMode){case _.yo:return"horizontal-tb";case _.Ge:return _.Ge;
5
- case _.He:return _.He;default:throw Error("Unknown writing mode");}},PH=function(a){switch(a.f.positionAlign){case _.ld:return _.id;case "auto":case _.uc:return _.xo;case _.md:return _.de}return a.f.textAlign},QH=function(a,b){if(typeof a.f.position===_.p&&typeof a.f.size===_.p)switch(b){case _.ld:return a.f.position;case "auto":case _.uc:return a.f.position-a.f.size/2;case _.md:return a.f.position-a.f.size}return 0},RH=function(a){if(!a.f.positionAlign)switch(a.f.textAlign){case _.id:case _.id:return _.ld;
6
- case _.xo:return _.uc;case _.de:case _.de:return _.md}return a.f.positionAlign},UH=function(a,b,c){return(SH(a)||TH(a))&&_.qf(c)?BH(c,_.Xd):SH(a)&&_.z(c)?BH(0,_.Xd):MH(a)&&_.qf(b)?BH(b,"%"):uH},VH=function(a,b,c){return MH(a)&&_.qf(c)?BH(c,_.Xd):(SH(a)||TH(a))&&_.qf(b)?BH(b,"%"):uH},TH=function(a){return a.f.writingMode===_.He},SH=function(a){return a.f.writingMode===_.Ge},WH=function(a,b){if(a.h)switch(b.writingMode){case _.yo:return["-y"];case _.Ge:return["+x"];case _.He:return["-x"]}a=[];switch(b.writingMode){case _.yo:a=
7
- ["+y","-y"];break;case _.Ge:a=["+x","-x"];break;case _.He:a=["-x","+x"]}0>b.line&&(a=a.reverse());return a},XH=function(a){for(a.g=[];0<a.f.childNodes.length;)a.f.removeChild(a.f.childNodes[0]);a.a=HH(a.j.a)},YH=function(a,b){XH(a.g);a.j.unshift(b);for(const c of a.j)a.g.append(c)},ZH=function(a,b,c){a=a.f;const d=a.viewportAnchorUnits;if(d===_.Fo)return a.viewportAnchorY/100*c-a.regionAnchorY/100*b;if(0===d)return a.viewportAnchorY-a.regionAnchorY;throw Error(qH);},aI=function(a,b,c,d){const e=document.createElement(_.pe),
8
- f=e.dataset;f.name=b;f.for=c;d&&(f.name=`${b} (sandbox)`,f.sandbox=!0);c=document.head;c.appendChild(e);$H(a,c,b);a.f.debug(`Created HTML style element #${b}.`);return e.sheet},bI=function(a,b){a=`.${a.j} .clpp-text-container`;const c=`${a} .clpp-text-cue`;return b=b.replace(/::cue\((#[^)]+)\)/g,`${a} $1`).replace(/::cue\(([^)]+)\)/g,`${c} $1`).replace(/::cue-region\(([^)]+)\)/g,`${a} $1 .clpp-text-cue`).replace(/::cue/g,c).replace(/::cue-region/g,`${a} .clpp-text-cue-region .clpp-text-cue`).replace(/::ttml/g,
9
- a)},cI=function(a,b){let c=!1;try{a.g.insertRule(b,0);const d=a.g.cssRules[0];d instanceof CSSStyleRule&&(c=d.selectorText.split(",").every(e=>0===e.trim().indexOf(`.${a.j} `)))}catch(d){}0<a.g.cssRules.length&&a.g.deleteRule(0);return c},dI=function(a){if(null!=a.a){for(;0<a.a.cssRules.length;)a.a.deleteRule(0);a.m=[]}},$H=function(a,b,c){const d=new MutationObserver(e=>{e.forEach(f=>{f.removedNodes.forEach(g=>{g.id===c&&a.f.error(`PRESTOplay HTML style element #${c} has `+"been unexpectedly removed! Some styles will not work!")})})});
10
- d.observe(b,{subtree:!1,childList:!0});a.o.push(()=>d.disconnect())},eI=function(a){a=_.kf(a.getConfiguration().htmlcue||{});_.z(a.stretchSmpteImage)&&(a.stretchSmpteImage=!1);_.z(a.enableResizeObserver)&&(a.enableResizeObserver=!0);return a},kI=function(a,b){if((b||a.j)&&a.C){var c=a.l.getPosition();if(b||a.I!==c&&a.l.getState()===_.Sl)if(a.I=c,c=fI(a,c),b||(b=a.m,b=!(null===b&&null===c||null!==b&&null!==c&&b.start===c.start&&b.end===c.end)),b&&(a.m=c,gI(a),c)){b={color:a.getFontColor()||void 0,
11
- backgroundColor:a.getBackgroundColor()||void 0,fontFamily:a.getFontFamily()||void 0,textShadow:_.oo(a)||void 0};c=a.f.slice(c.start,c.end+1);for(const k of c){c=a;var d=k,e=b,f=c.a.a,g=null;switch(d.payloadType){case _.Oe:g="clpp-text-vtt";break;case _.xe:g=sH;break;case _.wo:g=rH}g&&!f.classList.contains(g)&&_.mm(f,g);f=HH(c.a.a);if(0===f.width||0===f.height)c.L.warn("The height or width of the `.clpp-text-container` element is zero. Captions will not be displayed. Please check if the `clpp.styles.css` file has been included.");
12
- else{zH({fontSize:hI(c,d.containerRows)},c.a.a);f=null;g=d.payloadType===_.Oe;var h=d.payloadType===_.xe;d.region&&(g||h||d.backgroundImage)&&(c.A.has(d.region.id)?f=c.A.get(d.region.id):(f=new iI(d.region,{}),c.A.set(d.region.id,f),YH(c.a,f)));d=new jI(d,c.K,e);f?YH(f,d):YH(c.a,d)}}}}},lI=function(a){gI(a);a.I=null;a.m=null;a.f=[]},mI=function(a,b){return a.startTime<=b&&a.endTime>b},fI=function(a,b){var c=vH(a.f,d=>mI(d,b)?0:b!==d.startTime?b-d.startTime:b-d.endTime);if(-1===c)return null;{let d=
13
- c;for(;0<=d-1&&mI(a.f[d-1],b);)d--;for(;c+1<a.f.length&&mI(a.f[c+1],b);)c++;return{start:d,end:c}}},gI=function(a){a.A.clear();if(a.a){const b=a.a.a;b.classList.remove("clpp-text-vtt");b.classList.remove(sH);b.classList.remove(rH);a=a.a;XH(a.g);a.j=[]}},hI=function(a,b){const c=HH(a.a.a).height;if(null!==a.H)return a.getFontSize();if(null!==a.B)return a=a.getFontSizePercent(),`${Math.round(c*a)}px`;if(typeof b===_.p&&0<b)return`${Math.round(c/b)}px`;a=a.getFontSizePercent();return`${Math.round(c*
14
- a)}px`},qI=class{parse(a){a={input:a};const b=_.om(_.Qc),c=[];let d=b;for(var e;null!==(e=wH(a));)if("\x3c"===e[0])if("/"===e[1])c.length&&c[c.length-1]===e.substr(2).replace("\x3e","")&&(c.pop(),d=d.parentNode);else{if(e=e.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/)){var f=e[1];var g=e[3];var h=nI[f];h?(h=_.om(h),(f=oI[f])&&g&&h.setAttribute(f,g.trim()),g=h):g=null;!g||pI[g.localName]&&pI[g.localName]!==d.localName||(e[2]&&(g.className=e[2].substr(1).replace(/\./g," ")),c.push(e[1]),
15
- d.appendChild(g),d=g)}}else d.appendChild(document.createTextNode(yH(e)));return b}},nI={c:"c",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"v",lang:"lang"},oI={v:"voice",lang:"lang"},pI={rt:"ruby"},xH={"\x26amp;":"\x26","\x26lt;":"\x3c","\x26gt;":"\x3e","\x26lrm;":"\u200e","\x26rlm;":"\u200f","\x26nbsp;":"\u00a0"};var GH=class{constructor(a,b,c,d,e,f){this.f=a;this.g=b;this.h=c;this.a=d;this.height=e;this.width=f}};var rI=class{constructor(a,b,c){this.id=a;this.o=b;this.A=c;this.a=this.m();this.h=!1}init(){this.h=!0}w(){return!1}};var jI=class extends rI{constructor(a,b,c){super(a.id,"clpp-text-cue",{});this.j=b;this.f=a;this.g=!!this.f.backgroundImage;this.B=c}w(){return!this.g&&!(this.f.region&&this.f.region.displayAlign)}init(a){super.init(a);if(this.g)_.mm(this.a,"clpp-text-cue-image"),this.a.style.backgroundImage=`url("${this.f.backgroundImage}")`,this.j.stretchSmpteImage&&(this.a.style.backgroundSize="contain");else if(a){var b=this.f;if(b.payloadType===_.xe){var c=_.om(_.Qc);c.innerHTML=b.payload;b=c}else b.payloadType===
16
- _.Oe?b=(new qI).parse(b.payload):(c=_.om(_.Qc),c.textContent=b.payload,b=c);_.mm(b,this.o);this.id&&(b.id=this.id);for(d of this.f.cssClassList)_.mm(b,d);zH({writingMode:OH(this)},b);var d=b;this.a.appendChild(d);_.mm(this.a,"clpp-text-wrapper");for(var e of this.f.cssClassList)_.mm(this.a,`clpp-text-wrapper__${e}`);_.z(this.f.line)&&(this.f.lineInterpretation=_.zo,this.f.line=MH(this)?-1:0);e=OH(this);zH({writingMode:e,webkitWritingMode:e,direction:uH,textAlign:PH(this)},this.a);if(!this.f.region||
17
- !this.f.region.displayAlign){e=QH(this,RH(this));zH({position:"absolute",left:UH(this,e,null),right:TH(this)&&_.z(null)?BH(0,_.Xd):uH,top:VH(this,e,null),width:MH(this)?BH(this.f.size,"%"):uH,height:SH(this)||TH(this)?BH(this.f.size,"%"):uH},this.a);b=this.f;a=MH(this)?a.height:a.width;c=NH(this);if(b.lineInterpretation===_.zo){var f=c*Math.round(b.line);Math.abs(f)>a&&(f=c*(0>b.line?0:-1));0>f&&(f+=a)}else{f=c/a*100;let g=b.line;switch(b.lineAlign){case _.uc:g-=f/2;break;case _.Yc:g-=f}f=Math.round(g/
18
- 100*a)}TH(this)&&(f=a-f-c);a=f;zH({left:UH(this,e,a),right:TH(this)&&_.z(a)?BH(0,_.Xd):uH,top:VH(this,e,a)},this.a)}AH(this.B,d)}}m(){return _.om(_.Qc)}};var sI=class{constructor(a,b){this.j=a;this.f=a.a;this.h=void 0===b?!1:b;this.a=HH(a.a);this.g=[]}append(a){const b=a.a;b.style.visibility=_.dd;this.f.appendChild(b);a.h||a.init(this.a);if(a.w()){a:{var c=HH(a.a);var d=WH(this,a.f),e=NH(a);const g=IH(c);let h=null,k=0;for(const l of d){for(;LH(c,this.a,l)||KH(c,this.a)&&JH(c,this.g);){d=c;var f=e;switch(l){case "+x":d.f+=f;d.g+=f;break;case "-x":d.f-=f;d.g-=f;break;case "+y":d.h+=f;d.a+=f;break;case "-y":d.h-=f,d.a-=f}}if(this.h||KH(c,this.a))break a;
19
- d=this.a;d=Math.max(0,Math.min(c.g,d.g)-Math.max(c.f,d.f))*Math.max(0,Math.min(c.a,d.a)-Math.max(c.h,d.h))/(c.height*c.width);d>k&&(h=IH(c),k=d);c=IH(g)}c=h||g}zH({top:BH(c.h-this.a.h,_.Xd),bottom:BH(this.a.a-c.a,_.Xd),left:BH(c.f-this.a.f,_.Xd),right:BH(this.a.g-c.g,_.Xd),height:BH(c.height,_.Xd),width:BH(c.width,_.Xd)},a.a)}b.style.visibility="visible";this.g.push(HH(a.a))}};var tI=class extends rI{constructor(a,b,c){super(a,b,c);this.g=null;this.j=[]}init(){this.g=new sI(this);this.h=!0}m(){const a=_.om(_.Qc);_.mm(a,this.o);this.id&&(a.id=this.id);return a}};var iI=class extends tI{constructor(a,b){super(a.id,"clpp-text-cue-region",b);this.f=a}init(a){a:{var b=this.f;switch(b.widthUnits){case 0:b=b.width;break a;case _.Fo:b=b.width/100*a.width;break a;default:throw Error(qH);}}var c=this.f;var d=c.viewportAnchorUnits;if(d===_.Fo)c=c.viewportAnchorX/100*a.width-c.regionAnchorX/100*b;else if(0===d)c=c.viewportAnchorX-c.regionAnchorX;else throw Error(qH);d=a.height;const e=ZH(this,d,a.height);zH(this.A,this.a);zH({left:BH(c,_.Xd),top:BH(e,_.Xd),width:BH(b,
20
- _.Xd),height:BH(d,_.Xd)},this.a);this.f.writingMode&&zH({display:"flex","flex-direction":this.f.writingMode},this.a);this.f.displayAlign&&zH({"justify-content":this.f.displayAlign},this.a);for(var f of this.f.cssClassList)_.mm(this.a,f);a:switch(f=this.f,f.heightUnits){case 0:f=f.height;break a;case _.Fo:f=f.height/100*a.height;break a;case 2:f=f.height;c=new jI(new _.Co(0,1,"Lorem ipsum",_.wo),{},{});b=c.a;this.a.appendChild(b);c.init(HH(this.a));c=b.getBoundingClientRect().height;this.a.removeChild(b);
21
- b=c;f*=b;break a;default:throw Error(qH);}a=ZH(this,f,a.height);zH({top:BH(a,_.Xd),height:BH(f,_.Xd)},this.a);this.g=new sI(this,!0);this.h=!0}getId(){return this.f.id}};var uI=class{constructor(a,b){this.f=new _.O("clpp.htmlcue.StyleManager");this.o=[];this.j=a.getSurface().getUniqueCssClass();this.h=b;this.m=[];this.a=aI(this,this.h,this.j);this.g=aI(this,this.h,this.j,!0);this.g.disabled=!0;this.f.debug(`Stylesheet ${this.h} has been created.`)}appendRule(a){if(null!=this.a&&!this.m.some(b=>b===a)){const b=bI(this,a);if(cI(this,b)){try{this.a.insertRule(b,this.a.cssRules.length),this.f.debug(`Added CSS rule ${b}`)}catch(c){this.f.error(`An error occurred when adding a CSS rule: ${b}`)}this.m.push(a)}else this.f.warn(`Stylesheet ${this.h} ignoring the CSS rule `+
22
- `because it's not safe: ${b}`)}}destroy(){const a=this;return _.w(function*(){null!=a.a&&(a.o.forEach(b=>b()),a.o=[],dI(a),document.head.removeChild(a.a.ownerNode),document.head.removeChild(a.g.ownerNode),a.a=null,a.g=null,a.f.debug(`Stylesheet ${a.h} has been destroyed.`))})}};var vI=class extends _.gq{constructor(a){super(a);this.L=new _.O(tH);this.l=a;this.K=eI(a);this.j=!1;this.f=[];this.C=a.getSurface().getContainer();this.h=new uI(a,"CLPP Subtitle Styles");this.a=new tI(null,"clpp-text-container",{});this.w=new _.bq(a.getSurface(),this.U.bind(this));this.I=null;this.C?(this.C.appendChild(this.a.a),this.a.init(null)):this.L.warn("No container element! Subtitles will not appear. Please check your player surface configuration or switch to NativeTextDisplayer.");this.F=
23
- new _.Th(()=>{kI(this)});this.A=new Map;this.m=null}append(a,b){if(null!=this.h&&0!==a.length){for(const c of b)this.h.appendRule(c);a.sort((c,d)=>c.startTime!==d.startTime?c.startTime-d.startTime:c.endTime-d.endTime);b=this.f.findIndex(c=>c.startTime>=a[0].startTime);0===b?this.f=[]:0<b&&this.f.splice(0,b);for(const c of a)this.f.some(d=>d.payload!==c.payload?!1:d.startTime!==c.startTime?!1:d.endTime!==c.endTime?!1:!0)||this.f.push(c);this.m=null;kI(this,!1)}}g(){null==this.h||kI(this,!0)}destroy(){const a=
24
- this;return _.w(function*(){null!=a.h&&(lI(a),a.F.stop(),yield a.h.destroy(),a.h=null,a.C.removeChild(a.a.a),a.a=null,a.w.stop(),a.w=null,a.j=!1)})}remove(a,b){if(null==this.h)return!1;this.f=this.f.filter(c=>c.startTime<a||c.endTime>=b);this.m=null;kI(this,!0);return!0}isTextVisible(){return this.j}setTextVisibility(a){null!=this.h&&this.j!==a&&((this.j=a)?(this.F.Ua(.25),this.K.enableResizeObserver&&this.w.start(),kI(this,!0)):(this.F.stop(),this.w.stop(),lI(this)))}U(){kI(this,!0)}};_.x(tH,vI);
25
- vI.prototype.setTextVisibility=vI.prototype.setTextVisibility;vI.prototype.isTextVisible=vI.prototype.isTextVisible;vI.prototype.remove=vI.prototype.remove;vI.prototype.destroy=vI.prototype.destroy;vI.prototype.append=vI.prototype.append;var wI=class{da(a){return!!a.enableHtmlCue&&!_.ii()}create(a){return new vI(a)}};_.x("clpp.htmlcue.HtmlCueComponent",class extends _.Lp{f(){_.wl("html",new wI)}a(){}id(){return _.qe}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var AI="Unsupported unit",BI="clpp-text-plain",CI="clpp-text-ttml",DI="clpp.htmlcue.HtmlTextDisplayer",EI="initial",FI=function(a,b){let c=0,d=a.length-1;for(;c<=d;){const e=c+d>>1,f=b(a[e]);if(0===f)return e;0<f?c=e+1:d=e-1}return-1},GI=function(a){if(!a.input)return null;var b=a.input.match(/^([^<]*)(<[^>]+>?)?/);b=b[1]?b[1]:b[2];a.input=a.input.substr(b.length);return b},II=function(a){let b=null;for(;b=a.match(/&(amp|lt|gt|lrm|rlm|nbsp);/);)a=a.replace(b[0],c=>HI[c]);return a},KI=
2
+ function(a,b){JI(a,b);Array.from(b.getElementsByTagName("*")).forEach(c=>{JI(a,c)})},JI=function(a,b){for(const c in a)null!=a[c]&&(b.style[c]=a[c])},LI=function(a,b){return 0===a?"0":a+b},MI=function(a,b){return 1>Math.abs(a-b)||a<b},NI=function(a,b){return a<b&&1<Math.abs(a-b)},OI=function(a,b){return a>b&&1<Math.abs(a-b)},PI=function(a,b){return 1>Math.abs(a-b)||a>b},RI=function(a){const b=a.getBoundingClientRect();var c=getComputedStyle(a,null);const d=parseFloat(c.getPropertyValue("border-left-width"))||
3
+ 0,e=parseFloat(c.getPropertyValue("border-right-width"))||0;var f=parseFloat(c.getPropertyValue("border-top-width"))||0;c=parseFloat(c.getPropertyValue("border-bottom-width"))||0;const g=(b.top||a.offsetTop)+f;f=(b.height||a.offsetHeight)-f-c;return new QI(b.left+d,b.right+e,g,(b.bottom||g+f)+c,f,(b.width||a.offsetWidth)-d-e)},SI=function(a){return new QI(a.f,a.g,a.h,a.a,a.height,a.width)},TI=function(a,b){return b.some(c=>NI(a.f,c.g)&&OI(a.g,c.f)&&NI(a.h,c.a)&&OI(a.a,c.h))},UI=function(a,b){return PI(a.h,
4
+ b.h)&&MI(a.a,b.a)&&PI(a.f,b.f)&&MI(a.g,b.g)},VI=function(a,b,c){switch(c){case "+x":return NI(a.f,b.f);case "-x":return OI(a.g,b.g);case "+y":return NI(a.h,b.h);case "-y":return OI(a.a,b.a);default:throw Error("Unknown axis");}},WI=function(a){return a.f.writingMode===_.yo},XI=function(a){var b=a.a.childNodes[0],c=a.a.getBoundingClientRect();const d=b.getClientRects();b=c.height/d.length;c=c.width/d.length;return WI(a)?b:c},YI=function(a){switch(a.f.writingMode){case _.yo:return"horizontal-tb";case _.Ge:return _.Ge;
5
+ case _.Ie:return _.Ie;default:throw Error("Unknown writing mode");}},ZI=function(a){switch(a.f.positionAlign){case _.ld:return _.id;case "auto":case _.uc:return _.xo;case _.md:return _.de}return a.f.textAlign},$I=function(a,b){if(typeof a.f.position===_.r&&typeof a.f.size===_.r)switch(b){case _.ld:return a.f.position;case "auto":case _.uc:return a.f.position-a.f.size/2;case _.md:return a.f.position-a.f.size}return 0},aJ=function(a){if(!a.f.positionAlign)switch(a.f.textAlign){case _.id:case _.id:return _.ld;
6
+ case _.xo:return _.uc;case _.de:case _.de:return _.md}return a.f.positionAlign},dJ=function(a,b,c){return(bJ(a)||cJ(a))&&_.rf(c)?LI(c,_.Xd):bJ(a)&&_.B(c)?LI(0,_.Xd):WI(a)&&_.rf(b)?LI(b,"%"):EI},eJ=function(a,b,c){return WI(a)&&_.rf(c)?LI(c,_.Xd):(bJ(a)||cJ(a))&&_.rf(b)?LI(b,"%"):EI},cJ=function(a){return a.f.writingMode===_.Ie},bJ=function(a){return a.f.writingMode===_.Ge},fJ=function(a,b){if(a.h)switch(b.writingMode){case _.yo:return["-y"];case _.Ge:return["+x"];case _.Ie:return["-x"]}a=[];switch(b.writingMode){case _.yo:a=
7
+ ["+y","-y"];break;case _.Ge:a=["+x","-x"];break;case _.Ie:a=["-x","+x"]}0>b.line&&(a=a.reverse());return a},gJ=function(a){for(a.g=[];0<a.f.childNodes.length;)a.f.removeChild(a.f.childNodes[0]);a.a=RI(a.j.a)},hJ=function(a,b){gJ(a.g);a.j.unshift(b);for(const c of a.j)a.g.append(c)},iJ=function(a,b,c){a=a.f;const d=a.viewportAnchorUnits;if(d===_.Fo)return a.viewportAnchorY/100*c-a.regionAnchorY/100*b;if(0===d)return a.viewportAnchorY-a.regionAnchorY;throw Error(AI);},kJ=function(a,b,c,d){const e=document.createElement(_.pe),
8
+ f=e.dataset;f.name=b;f.for=c;d&&(f.name=`${b} (sandbox)`,f.sandbox=!0);c=document.head;c.appendChild(e);jJ(a,c,b);a.f.debug(`Created HTML style element #${b}.`);return e.sheet},lJ=function(a,b){a=`.${a.j} .clpp-text-container`;const c=`${a} .clpp-text-cue`;return b=b.replace(/::cue\((#[^)]+)\)/g,`${a} $1`).replace(/::cue\(([^)]+)\)/g,`${c} $1`).replace(/::cue-region\(([^)]+)\)/g,`${a} $1 .clpp-text-cue`).replace(/::cue/g,c).replace(/::cue-region/g,`${a} .clpp-text-cue-region .clpp-text-cue`).replace(/::ttml/g,
9
+ a)},mJ=function(a,b){let c=!1;try{a.g.insertRule(b,0);const d=a.g.cssRules[0];d instanceof CSSStyleRule&&(c=d.selectorText.split(",").every(e=>0===e.trim().indexOf(`.${a.j} `)))}catch(d){}0<a.g.cssRules.length&&a.g.deleteRule(0);return c},nJ=function(a){if(null!=a.a){for(;0<a.a.cssRules.length;)a.a.deleteRule(0);a.m=[]}},jJ=function(a,b,c){const d=new MutationObserver(e=>{e.forEach(f=>{f.removedNodes.forEach(g=>{g.id===c&&a.f.error(`PRESTOplay HTML style element #${c} has `+"been unexpectedly removed! Some styles will not work!")})})});
10
+ d.observe(b,{subtree:!1,childList:!0});a.o.push(()=>d.disconnect())},oJ=function(a){a=_.lf(a.getConfiguration().htmlcue||{});_.B(a.stretchSmpteImage)&&(a.stretchSmpteImage=!1);_.B(a.enableResizeObserver)&&(a.enableResizeObserver=!0);return a},uJ=function(a,b){if((b||a.j)&&a.C){var c=a.l.getPosition();if(b||a.I!==c&&a.l.getState()===_.Sl)if(a.I=c,c=pJ(a,c),b||(b=a.m,b=!(null===b&&null===c||null!==b&&null!==c&&b.start===c.start&&b.end===c.end)),b&&(a.m=c,qJ(a),c)){b={color:a.getFontColor()||void 0,
11
+ backgroundColor:a.getBackgroundColor()||void 0,fontFamily:a.getFontFamily()||void 0,textShadow:_.oo(a)||void 0};c=a.f.slice(c.start,c.end+1);for(const k of c){c=a;var d=k,e=b,f=c.a.a,g=null;switch(d.payloadType){case _.Pe:g="clpp-text-vtt";break;case _.xe:g=CI;break;case _.wo:g=BI}g&&!f.classList.contains(g)&&_.mm(f,g);f=RI(c.a.a);if(0===f.width||0===f.height)c.M.warn("The height or width of the `.clpp-text-container` element is zero. Captions will not be displayed. Please check if the `clpp.styles.css` file has been included.");
12
+ else{JI({fontSize:rJ(c,d.containerRows)},c.a.a);f=null;g=d.payloadType===_.Pe;var h=d.payloadType===_.xe;d.region&&(g||h||d.backgroundImage)&&(c.A.has(d.region.id)?f=c.A.get(d.region.id):(f=new sJ(d.region,{}),c.A.set(d.region.id,f),hJ(c.a,f)));d=new tJ(d,c.K,e);f?hJ(f,d):hJ(c.a,d)}}}}},vJ=function(a){qJ(a);a.I=null;a.m=null;a.f=[]},wJ=function(a,b){return a.startTime<=b&&a.endTime>b},pJ=function(a,b){var c=FI(a.f,d=>wJ(d,b)?0:b!==d.startTime?b-d.startTime:b-d.endTime);if(-1===c)return null;{let d=
13
+ c;for(;0<=d-1&&wJ(a.f[d-1],b);)d--;for(;c+1<a.f.length&&wJ(a.f[c+1],b);)c++;return{start:d,end:c}}},qJ=function(a){a.A.clear();if(a.a){const b=a.a.a;b.classList.remove("clpp-text-vtt");b.classList.remove(CI);b.classList.remove(BI);a=a.a;gJ(a.g);a.j=[]}},rJ=function(a,b){const c=RI(a.a.a).height;if(null!==a.H)return a.getFontSize();if(null!==a.B)return a=a.getFontSizePercent(),`${Math.round(c*a)}px`;if(typeof b===_.r&&0<b)return`${Math.round(c/b)}px`;a=a.getFontSizePercent();return`${Math.round(c*
14
+ a)}px`},AJ=class{parse(a){a={input:a};const b=_.om(_.Qc),c=[];let d=b;for(var e;null!==(e=GI(a));)if("\x3c"===e[0])if("/"===e[1])c.length&&c[c.length-1]===e.substr(2).replace("\x3e","")&&(c.pop(),d=d.parentNode);else{if(e=e.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/)){var f=e[1];var g=e[3];var h=xJ[f];h?(h=_.om(h),(f=yJ[f])&&g&&h.setAttribute(f,g.trim()),g=h):g=null;!g||zJ[g.localName]&&zJ[g.localName]!==d.localName||(e[2]&&(g.className=e[2].substr(1).replace(/\./g," ")),c.push(e[1]),
15
+ d.appendChild(g),d=g)}}else d.appendChild(document.createTextNode(II(e)));return b}},xJ={c:"c",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"v",lang:"lang"},yJ={v:"voice",lang:"lang"},zJ={rt:"ruby"},HI={"\x26amp;":"\x26","\x26lt;":"\x3c","\x26gt;":"\x3e","\x26lrm;":"\u200e","\x26rlm;":"\u200f","\x26nbsp;":"\u00a0"};var QI=class{constructor(a,b,c,d,e,f){this.f=a;this.g=b;this.h=c;this.a=d;this.height=e;this.width=f}};var BJ=class{constructor(a,b,c){this.id=a;this.o=b;this.A=c;this.a=this.m();this.h=!1}init(){this.h=!0}w(){return!1}};var tJ=class extends BJ{constructor(a,b,c){super(a.id,"clpp-text-cue",{});this.j=b;this.f=a;this.g=!!this.f.backgroundImage;this.B=c}w(){return!this.g&&!(this.f.region&&this.f.region.displayAlign)}init(a){super.init(a);if(this.g)_.mm(this.a,"clpp-text-cue-image"),this.a.style.backgroundImage=`url("${this.f.backgroundImage}")`,this.j.stretchSmpteImage&&(this.a.style.backgroundSize="contain");else if(a){var b=this.f;if(b.payloadType===_.xe){var c=_.om(_.Qc);c.innerHTML=b.payload;b=c}else b.payloadType===
16
+ _.Pe?b=(new AJ).parse(b.payload):(c=_.om(_.Qc),c.textContent=b.payload,b=c);_.mm(b,this.o);this.id&&(b.id=this.id);for(d of this.f.cssClassList)_.mm(b,d);JI({writingMode:YI(this)},b);var d=b;this.a.appendChild(d);_.mm(this.a,"clpp-text-wrapper");for(var e of this.f.cssClassList)_.mm(this.a,`clpp-text-wrapper__${e}`);_.B(this.f.line)&&(this.f.lineInterpretation=_.zo,this.f.line=WI(this)?-1:0);e=YI(this);JI({writingMode:e,webkitWritingMode:e,direction:EI,textAlign:ZI(this)},this.a);if(!this.f.region||
17
+ !this.f.region.displayAlign){e=$I(this,aJ(this));JI({position:"absolute",left:dJ(this,e,null),right:cJ(this)&&_.B(null)?LI(0,_.Xd):EI,top:eJ(this,e,null),width:WI(this)?LI(this.f.size,"%"):EI,height:bJ(this)||cJ(this)?LI(this.f.size,"%"):EI},this.a);b=this.f;a=WI(this)?a.height:a.width;c=XI(this);if(b.lineInterpretation===_.zo){var f=c*Math.round(b.line);Math.abs(f)>a&&(f=c*(0>b.line?0:-1));0>f&&(f+=a)}else{f=c/a*100;let g=b.line;switch(b.lineAlign){case _.uc:g-=f/2;break;case _.Yc:g-=f}f=Math.round(g/
18
+ 100*a)}cJ(this)&&(f=a-f-c);a=f;JI({left:dJ(this,e,a),right:cJ(this)&&_.B(a)?LI(0,_.Xd):EI,top:eJ(this,e,a)},this.a)}KI(this.B,d)}}m(){return _.om(_.Qc)}};var CJ=class{constructor(a,b){this.j=a;this.f=a.a;this.h=void 0===b?!1:b;this.a=RI(a.a);this.g=[]}append(a){const b=a.a;b.style.visibility=_.dd;this.f.appendChild(b);a.h||a.init(this.a);if(a.w()){a:{var c=RI(a.a);var d=fJ(this,a.f),e=XI(a);const g=SI(c);let h=null,k=0;for(const l of d){for(;VI(c,this.a,l)||UI(c,this.a)&&TI(c,this.g);){d=c;var f=e;switch(l){case "+x":d.f+=f;d.g+=f;break;case "-x":d.f-=f;d.g-=f;break;case "+y":d.h+=f;d.a+=f;break;case "-y":d.h-=f,d.a-=f}}if(this.h||UI(c,this.a))break a;
19
+ d=this.a;d=Math.max(0,Math.min(c.g,d.g)-Math.max(c.f,d.f))*Math.max(0,Math.min(c.a,d.a)-Math.max(c.h,d.h))/(c.height*c.width);d>k&&(h=SI(c),k=d);c=SI(g)}c=h||g}JI({top:LI(c.h-this.a.h,_.Xd),bottom:LI(this.a.a-c.a,_.Xd),left:LI(c.f-this.a.f,_.Xd),right:LI(this.a.g-c.g,_.Xd),height:LI(c.height,_.Xd),width:LI(c.width,_.Xd)},a.a)}b.style.visibility="visible";this.g.push(RI(a.a))}};var DJ=class extends BJ{constructor(a,b,c){super(a,b,c);this.g=null;this.j=[]}init(){this.g=new CJ(this);this.h=!0}m(){const a=_.om(_.Qc);_.mm(a,this.o);this.id&&(a.id=this.id);return a}};var sJ=class extends DJ{constructor(a,b){super(a.id,"clpp-text-cue-region",b);this.f=a}init(a){a:{var b=this.f;switch(b.widthUnits){case 0:b=b.width;break a;case _.Fo:b=b.width/100*a.width;break a;default:throw Error(AI);}}var c=this.f;var d=c.viewportAnchorUnits;if(d===_.Fo)c=c.viewportAnchorX/100*a.width-c.regionAnchorX/100*b;else if(0===d)c=c.viewportAnchorX-c.regionAnchorX;else throw Error(AI);d=a.height;const e=iJ(this,d,a.height);JI(this.A,this.a);JI({left:LI(c,_.Xd),top:LI(e,_.Xd),width:LI(b,
20
+ _.Xd),height:LI(d,_.Xd)},this.a);this.f.writingMode&&JI({display:"flex","flex-direction":this.f.writingMode},this.a);this.f.displayAlign&&JI({"justify-content":this.f.displayAlign},this.a);for(var f of this.f.cssClassList)_.mm(this.a,f);a:switch(f=this.f,f.heightUnits){case 0:f=f.height;break a;case _.Fo:f=f.height/100*a.height;break a;case 2:f=f.height;c=new tJ(new _.Co(0,1,"Lorem ipsum",_.wo),{},{});b=c.a;this.a.appendChild(b);c.init(RI(this.a));c=b.getBoundingClientRect().height;this.a.removeChild(b);
21
+ b=c;f*=b;break a;default:throw Error(AI);}a=iJ(this,f,a.height);JI({top:LI(a,_.Xd),height:LI(f,_.Xd)},this.a);this.g=new CJ(this,!0);this.h=!0}getId(){return this.f.id}};var EJ=class{constructor(a,b){this.f=new _.O("clpp.htmlcue.StyleManager");this.o=[];this.j=a.getSurface().getUniqueCssClass();this.h=b;this.m=[];this.a=kJ(this,this.h,this.j);this.g=kJ(this,this.h,this.j,!0);this.g.disabled=!0;this.f.debug(`Stylesheet ${this.h} has been created.`)}appendRule(a){if(null!=this.a&&!this.m.some(b=>b===a)){const b=lJ(this,a);if(mJ(this,b)){try{this.a.insertRule(b,this.a.cssRules.length),this.f.debug(`Added CSS rule ${b}`)}catch(c){this.f.error(`An error occurred when adding a CSS rule: ${b}`)}this.m.push(a)}else this.f.warn(`Stylesheet ${this.h} ignoring the CSS rule `+
22
+ `because it's not safe: ${b}`)}}destroy(){const a=this;return _.y(function*(){null!=a.a&&(a.o.forEach(b=>b()),a.o=[],nJ(a),document.head.removeChild(a.a.ownerNode),document.head.removeChild(a.g.ownerNode),a.a=null,a.g=null,a.f.debug(`Stylesheet ${a.h} has been destroyed.`))})}};var FJ=class extends _.hq{constructor(a){super(a);this.M=new _.O(DI);this.l=a;this.K=oJ(a);this.j=!1;this.f=[];this.C=a.getSurface().getContainer();this.h=new EJ(a,"CLPP Subtitle Styles");this.a=new DJ(null,"clpp-text-container",{});this.w=new _.cq(a.getSurface(),this.U.bind(this));this.I=null;this.C?(this.C.appendChild(this.a.a),this.a.init(null)):this.M.warn("No container element! Subtitles will not appear. Please check your player surface configuration or switch to NativeTextDisplayer.");this.F=
23
+ new _.Zh(()=>{uJ(this)});this.A=new Map;this.m=null}append(a,b){if(null!=this.h&&0!==a.length){for(const c of b)this.h.appendRule(c);a.sort((c,d)=>c.startTime!==d.startTime?c.startTime-d.startTime:c.endTime-d.endTime);b=this.f.findIndex(c=>c.startTime>=a[0].startTime);0===b?this.f=[]:0<b&&this.f.splice(0,b);for(const c of a)this.f.some(d=>d.payload!==c.payload?!1:d.startTime!==c.startTime?!1:d.endTime!==c.endTime?!1:!0)||this.f.push(c);this.m=null;uJ(this,!1)}}g(){null==this.h||uJ(this,!0)}destroy(){const a=
24
+ this;return _.y(function*(){null!=a.h&&(vJ(a),a.F.stop(),yield a.h.destroy(),a.h=null,a.C.removeChild(a.a.a),a.a=null,a.w.stop(),a.w=null,a.j=!1)})}remove(a,b){if(null==this.h)return!1;this.f=this.f.filter(c=>c.startTime<a||c.endTime>=b);this.m=null;uJ(this,!0);return!0}isTextVisible(){return this.j}setTextVisibility(a){null!=this.h&&this.j!==a&&((this.j=a)?(this.F.Va(.25),this.K.enableResizeObserver&&this.w.start(),uJ(this,!0)):(this.F.stop(),this.w.stop(),vJ(this)))}U(){uJ(this,!0)}};_.z(DI,FJ);
25
+ FJ.prototype.setTextVisibility=FJ.prototype.setTextVisibility;FJ.prototype.isTextVisible=FJ.prototype.isTextVisible;FJ.prototype.remove=FJ.prototype.remove;FJ.prototype.destroy=FJ.prototype.destroy;FJ.prototype.append=FJ.prototype.append;var GJ=class{ba(a){return!!a.enableHtmlCue&&!_.oi()}create(a){return new FJ(a)}};_.z("clpp.htmlcue.HtmlCueComponent",class extends _.Mp{f(){_.wl("html",new GJ)}a(){}id(){return _.qe}});};f.call(g, window);