@castlabs/prestoplay 6.4.1 → 6.5.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 (58) hide show
  1. package/CHANGELOG.md +35 -0
  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 +419 -416
  8. package/cjs/cl.crypto.js +9 -9
  9. package/cjs/cl.dash.js +72 -72
  10. package/cjs/cl.externs.js +26 -26
  11. package/cjs/cl.freewheel.js +24 -24
  12. package/cjs/cl.hls.js +47 -47
  13. package/cjs/cl.hlssmpte.js +6 -6
  14. package/cjs/cl.htmlcue.js +31 -31
  15. package/cjs/cl.ima.js +22 -22
  16. package/cjs/cl.mse.js +258 -255
  17. package/cjs/cl.muxdata.js +12 -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 +69 -69
  22. package/cjs/cl.thumbnails.js +24 -24
  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 -18
  28. package/cjs/cl.vtt.js +14 -14
  29. package/cjs/cl.youbora.js +20 -20
  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 +354 -351
  36. package/cl.crypto.js +8 -8
  37. package/cl.dash.js +66 -66
  38. package/cl.externs.js +26 -26
  39. package/cl.freewheel.js +19 -19
  40. package/cl.hls.js +40 -39
  41. package/cl.hlssmpte.js +5 -5
  42. package/cl.htmlcue.js +25 -25
  43. package/cl.ima.js +16 -16
  44. package/cl.mse.js +230 -231
  45. package/cl.muxdata.js +8 -8
  46. package/cl.onboard.js +4 -4
  47. package/cl.persistent.js +9 -9
  48. package/cl.playlist.js +5 -5
  49. package/cl.smooth.js +58 -58
  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 -14
  56. package/cl.vtt.js +12 -12
  57. package/cl.youbora.js +15 -16
  58. package/package.json +6 -2
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 rI="clpp-freewheel",sI="clpp.freewheel.AdsManagerFactory",tI="freewheel",uI=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""}},vI=function(a){const b=[];typeof a.networkId!==_.p&&b.push("networkId");typeof a.serverUrl!==_.le&&b.push("serverUrl");typeof a.profileId!==_.le&&b.push("profileId");typeof a.videoAssetId!==_.le&&typeof a.videoAssetId!==_.p&&b.push("videoAssetId");
2
- if(b.length)throw new _.H(1,9,12001,{missingKeys:b.join(", ")});},wI=function(){return _.w(function*(){var a=new _.Up;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})},xI=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.F.bind(a));a.g.on(a.l,_.te,a.D.bind(a));a.g.on(a.l,_.ie,a.C.bind(a))},AI=function(a){return _.w(function*(){a.A.length?(yI(a),a.f=a.A.shift(),a.f.play()):(zI(a),yield a.l.a.play())})},zI=function(a){const b=a.l.Sb(tI).lc();b&&a.l.getSurface().hide(b);a.l.getSurface().showMediaElement()},yI=function(a){const b=a.l.Sb(tI).lc();b&&(a.l.getSurface().show(b),a.l.getSurface().hideMediaElement(),a.a.registerVideoDisplayBase(rI),
4
- a.l.isMuted()?a.setVolume(0):a.setVolume(a.l.getVolume()||1))},BI=function(a){a.w.length?(yI(a),a.f=a.w.shift(),a.f.play()):zI(a)},CI=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))},DI=class extends _.Zp{constructor(){super();this.f=this.a=null}onPlayerCreated(a){if(window.tv&&tv.freewheel&&tv.freewheel.SDK)this.a=_.dm(_.Mc,{id:rI}),this.f=_.dm(_.v,{"class":_.uc}),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 tI}lc(){return this.a}lf(){return this.f}};_.x("clpp.freewheel.FreeWheelPlugin",DI);DI.prototype.getAdVideo=DI.prototype.lf;DI.prototype.getAdContainer=DI.prototype.lc;DI.Id=tI;DI.AD_CONTAINER_ID=rI;_.Km(new class{create(){return new DI}});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===_.le?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}Wb(){return!1}Bb(){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}Cb(){switch(this.Oa()){case 0:return 0;case 2:return-1;default:return this.f.getTimePosition()}}Db(){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.Db;W.prototype.getPodTimeOffset=W.prototype.Cb;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.Bb;W.prototype.isBumper=W.prototype.Wb;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 EI=class{constructor(a){this.a=a}getCuePoints(){return this.a.getTemporalSlots().map(a=>{switch(a.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:return 0;case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:return-1;default:return a.getTimePosition()}})}Eb(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL).length}eb(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL).length}};
11
- EI.prototype.hasPostroll=EI.prototype.eb;EI.prototype.hasPreroll=EI.prototype.Eb;EI.prototype.getCuePoints=EI.prototype.getCuePoints;var FI=class{constructor(a){this.B=new _.O("clpp.freewheel.AdsManager");this.l=a;this.g=new _.mo;this.o=new tv.freewheel.SDK.AdManager;this.f=this.a=null;this.A=[];this.m=[];this.w=[];this.j=new _.Qk;this.h=null}load(){const a=this;return _.w(function*(){const b=a.l.getConfiguration().freewheel||{};try{vI(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!==_.le&&typeof b.siteSectionId!==
12
- _.p||a.a.setSiteSection(b.siteSectionId);const c=yield wI();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,uI(d.type),d.position,d.slotProfile,d.cuepointSequence,d.maxDuration,d.minDuration,d.acceptContentType);b.keyValues&&typeof b.keyValues===_.Ad&&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);xI(a);a.a.submitRequest();return a.j})}start(){const a=this;return _.w(function*(){yield AI(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);zI(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(_.Lb,{adsTimeline:new EI(this.a)})),this.h=new _.Sp(this.l.getSurface(),(b,c)=>this.a.resize(b,c),this.l.Sb(tI).f);else this.l.onError(new _.H(1,
15
- 9,10003,{errorType:0},void 0));this.j.resolve()}J(a){CI(this,_.ub,a);this.h.start()}I(a){this.f=null;a=a.slot;CI(this,_.vb);this.h.stop();if(a)switch(a.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:AI(this);break;case tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL:zI(this);this.l.play();break;case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:BI(this)}}F(a){const b=a.subType;this.B.debug("ad event",b);switch(b){case tv.freewheel.SDK.EVENT_AD_IMPRESSION:CI(this,_.Hb,a);CI(this,
16
- _.Ab,a);break;case tv.freewheel.SDK.EVENT_AD_IMPRESSION_END:CI(this,_.Ib,a);break;case tv.freewheel.SDK.EVENT_AD_FIRST_QUARTILE:CI(this,_.zb,a);break;case tv.freewheel.SDK.EVENT_AD_MIDPOINT:CI(this,_.Cb,a);break;case tv.freewheel.SDK.EVENT_AD_THIRD_QUARTILE:CI(this,_.Jb,a);break;case tv.freewheel.SDK.EVENT_AD_COMPLETE:CI(this,_.yb,a);break;case tv.freewheel.SDK.EVENT_AD_CLICK:CI(this,_.xb,a);break;case tv.freewheel.SDK.EVENT_AD_PAUSE:CI(this,_.Db,a);break;case tv.freewheel.SDK.EVENT_AD_RESUME:CI(this,
17
- _.Fb,a);break;case tv.freewheel.SDK.EVENT_AD_SKIPPED:CI(this,_.Gb,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_START:CI(this,_.wb,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_END:CI(this,_.Eb,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]}))}}D(){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();yI(this);this.f.play()}}}C(a){if((a=a.detail)&&this.a)switch(a.currentState){case _.Ll:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PLAYING);break;case _.Kl:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PAUSED);break;case _.Al:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_COMPLETED);BI(this);break;case _.Il:case _.Hl:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_STOPPED)}}};
19
- FI.prototype.getPosition=FI.prototype.getPosition;FI.prototype.setVolume=FI.prototype.setVolume;FI.prototype.getVolume=FI.prototype.getVolume;FI.prototype.skip=FI.prototype.skip;FI.prototype.pause=FI.prototype.pause;FI.prototype.resume=FI.prototype.resume;FI.prototype.start=FI.prototype.start;var GI=class{constructor(){this.a=new _.O(sI)}name(){return sI}ba(a,b){return a.namespace()===_.wc?!1:window.tv&&tv.freewheel&&tv.freewheel.SDK?!(!b||!b.freewheel):(this.a.warn("FreeWheel SDK is not loaded."),!1)}create(a){return new FI(a)}};GI.prototype.create=GI.prototype.create;GI.prototype.isSupported=GI.prototype.ba;GI.prototype.name=GI.prototype.name;_.am(new GI);};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var xI="clpp-freewheel",yI="clpp.freewheel.AdsManagerFactory",zI="freewheel",AI=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""}},BI=function(a){const b=[];typeof a.networkId!==_.p&&b.push("networkId");typeof a.serverUrl!==_.me&&b.push("serverUrl");typeof a.profileId!==_.me&&b.push("profileId");typeof a.videoAssetId!==_.me&&typeof a.videoAssetId!==_.p&&b.push("videoAssetId");
2
+ if(b.length)throw new _.H(1,9,12001,{missingKeys:b.join(", ")});},CI=function(){return _.w(function*(){var a=new _.Xp;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})},DI=function(a){a.g.on(a.a,tv.freewheel.SDK.EVENT_REQUEST_COMPLETE,a.I.bind(a));a.g.on(a.a,tv.freewheel.SDK.EVENT_SLOT_STARTED,a.K.bind(a));a.g.on(a.a,
3
+ tv.freewheel.SDK.EVENT_SLOT_ENDED,a.J.bind(a));a.g.on(a.a,tv.freewheel.SDK.EVENT_AD,a.G.bind(a));a.g.on(a.l,_.ue,a.F.bind(a));a.g.on(a.l,_.je,a.C.bind(a))},GI=function(a){return _.w(function*(){a.A.length?(EI(a),a.f=a.A.shift(),a.f.play()):(FI(a),yield a.l.a.play())})},FI=function(a){const b=a.l.Vb(zI).nc();b&&a.l.getSurface().hide(b);a.l.getSurface().showMediaElement()},EI=function(a){const b=a.l.Vb(zI).nc();b&&(a.l.getSurface().show(b),a.l.getSurface().hideMediaElement(),a.a.registerVideoDisplayBase(xI),
4
+ a.l.isMuted()?a.setVolume(0):a.setVolume(a.l.getVolume()||1))},HI=function(a){a.w.length?(EI(a),a.f=a.w.shift(),a.f.play()):FI(a)},II=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))},JI=class extends _.bq{constructor(){super();this.f=this.a=null}onPlayerCreated(a){if(window.tv&&tv.freewheel&&tv.freewheel.SDK)this.a=_.gm(_.Nc,{id:xI}),this.f=_.gm(_.v,{"class":_.vc}),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 zI}nc(){return this.a}qf(){return this.f}};_.x("clpp.freewheel.FreeWheelPlugin",JI);JI.prototype.getAdVideo=JI.prototype.qf;JI.prototype.getAdContainer=JI.prototype.nc;JI.Id=zI;JI.AD_CONTAINER_ID=xI;_.Nm(new class{create(){return new JI}});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===_.me?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}Eb(){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}Pa(){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.Pa()){case 0:return 0;case 2:return-1}return this.g.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL).indexOf(this.f)+1}Fb(){switch(this.Pa()){case 0:return 0;case 2:return-1;default:return this.f.getTimePosition()}}Gb(){return this.a?this.f.getAdInstances().indexOf(this.a)+1:1}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.Gb;W.prototype.getPodTimeOffset=W.prototype.Fb;W.prototype.getPodIndex=W.prototype.getPodIndex;W.prototype.getPodType=W.prototype.Pa;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.Eb;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 KI=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()}})}Hb(){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
+ KI.prototype.hasPostroll=KI.prototype.fb;KI.prototype.hasPreroll=KI.prototype.Hb;KI.prototype.getCuePoints=KI.prototype.getCuePoints;var LI=class{constructor(a){this.B=new _.O("clpp.freewheel.AdsManager");this.l=a;this.g=new _.po;this.o=new tv.freewheel.SDK.AdManager;this.f=this.a=null;this.A=[];this.m=[];this.w=[];this.j=new _.Sk;this.h=null}load(){const a=this;return _.w(function*(){const b=a.l.getConfiguration().freewheel||{};try{BI(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!==_.me&&typeof b.siteSectionId!==
12
+ _.p||a.a.setSiteSection(b.siteSectionId);const c=yield CI();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,AI(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);DI(a);a.a.submitRequest();return a.j})}start(){const a=this;return _.w(function*(){yield GI(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);FI(a);a.a&&(a.a.dispose(),a.a=null)})}I(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(_.Lb,{adsTimeline:new KI(this.a)})),this.h=new _.Vp(this.l.getSurface(),(b,c)=>this.a.resize(b,c),this.l.Vb(zI).f);else this.l.onError(new _.H(1,
15
+ 9,10003,{errorType:0},void 0));this.j.resolve()}K(a){II(this,_.ub,a);this.h.start()}J(a){this.f=null;a=a.slot;II(this,_.vb);this.h.stop();if(a)switch(a.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:GI(this);break;case tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL:FI(this);this.l.play();break;case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:HI(this)}}G(a){const b=a.subType;this.B.debug("ad event",b);switch(b){case tv.freewheel.SDK.EVENT_AD_IMPRESSION:II(this,_.Hb,a);II(this,
16
+ _.Ab,a);break;case tv.freewheel.SDK.EVENT_AD_IMPRESSION_END:II(this,_.Ib,a);break;case tv.freewheel.SDK.EVENT_AD_FIRST_QUARTILE:II(this,_.zb,a);break;case tv.freewheel.SDK.EVENT_AD_MIDPOINT:II(this,_.Cb,a);break;case tv.freewheel.SDK.EVENT_AD_THIRD_QUARTILE:II(this,_.Jb,a);break;case tv.freewheel.SDK.EVENT_AD_COMPLETE:II(this,_.yb,a);break;case tv.freewheel.SDK.EVENT_AD_CLICK:II(this,_.xb,a);break;case tv.freewheel.SDK.EVENT_AD_PAUSE:II(this,_.Db,a);break;case tv.freewheel.SDK.EVENT_AD_RESUME:II(this,
17
+ _.Fb,a);break;case tv.freewheel.SDK.EVENT_AD_SKIPPED:II(this,_.Gb,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_START:II(this,_.wb,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_END:II(this,_.Eb,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();EI(this);this.f.play()}}}C(a){if((a=a.detail)&&this.a)switch(a.currentState){case _.Nl:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PLAYING);break;case _.Ml:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PAUSED);break;case _.Cl:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_COMPLETED);HI(this);break;case _.Kl:case _.Jl:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_STOPPED)}}};
19
+ LI.prototype.getPosition=LI.prototype.getPosition;LI.prototype.setVolume=LI.prototype.setVolume;LI.prototype.getVolume=LI.prototype.getVolume;LI.prototype.skip=LI.prototype.skip;LI.prototype.pause=LI.prototype.pause;LI.prototype.resume=LI.prototype.resume;LI.prototype.start=LI.prototype.start;var MI=class{constructor(){this.a=new _.O(yI)}name(){return yI}ba(a,b){return a.namespace()===_.xc?!1:window.tv&&tv.freewheel&&tv.freewheel.SDK?!(!b||!b.freewheel):(this.a.warn("FreeWheel SDK is not loaded."),!1)}create(a){return new LI(a)}};MI.prototype.create=MI.prototype.create;MI.prototype.isSupported=MI.prototype.ba;MI.prototype.name=MI.prototype.name;_.dm(new MI);};f.call(g, window);
package/cl.hls.js CHANGED
@@ -1,39 +1,40 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var wz="CLOSED-CAPTIONS",xz="EXT-X-BYTERANGE",yz="EXT-X-DISCONTINUITY",zz="EXT-X-DISCONTINUITY-SEQUENCE",Az="EXT-X-ENDLIST",Bz="EXT-X-MEDIA-SEQUENCE",Cz="EXT-X-PART-INF",Dz="EXT-X-PLAYLIST-TYPE",Ez="EXT-X-PRELOAD-HINT",Fz="EXT-X-SERVER-CONTROL",Gz="EXT-X-STREAM-INF",Hz="EXT-X-TARGETDURATION",Iz="EXTINF",Jz="GROUP-ID",Kz="Guessing audio-only",Lz="SAMPLE-AES-CTR",Mz="SUBTITLES",Nz="application/vnd.apple.mpegurl",Oz=function(a,b){a=a.getAttribute(b);if(!a)throw new _.H(_.F,4,4023,b);return a.value},
2
- Pz=function(a){if(1>a.a)throw _.qj();--a.a},Qz=function(a,b){return a.filter(c=>c.name==b)},Rz=function(a,b){return a.filter(c=>Oz(c,"TYPE")===b)},Sz=function(a,b){a=Qz(a,b);return a.length?a[0]:null},Tz=function(a,b){return _.lu([a],[b])[0]},Uz=function(a,b){return _.Pg(a.a++,b)},Yz=function(a,b,c,d){const e=[];let f=[],g=[];c.forEach(h=>{/^(#EXT)/.test(h)?(h=Uz(a,h),Vz.includes(h.name)?d.push(h):Wz.includes(h.name)?"EXT-X-PART"===h.name?g.push(h):h.name===Ez&&"PART"===_.lg(h,"TYPE")&&g.push(h):
3
- f.push(h)):/^#(?!EXT)/m.test(h)||(h=Tz(b,h.trim()),e.push(new Xz(h,f,g)),f=[],g=[])});g.length&&e.push(new Xz(null,f,g));return e},aA=function(a,b,c){b=_.yg(b);b=b.replace(/\r\n|\r(?=[^\n]|$)/gm,"\n").trim();const d=b.split(/\n+/m);if(!/^#EXTM3U($|[ \t\n])/m.test(d[0]))throw new _.H(_.F,4,4015);b=0;let e=!0;for(var f of d)if(f=f.trim(),!f.length||/^#(?!EXT)/m.test(f)||e)e=!1;else{var g=Uz(a,f);--a.a;if(Vz.includes(g.name)){b=1;break}else g.name==Gz&&(e=!0)}f=[];e=!0;for(var h of _.nu(d)){let {Uc:k,
4
- item:l,next:m}=h;l=l.trim();if(!l.length||/^#(?!EXT)/m.test(l)||e)e=!1;else{g=Uz(a,l);if(Zz.includes(g.name)){if(1!=b)throw new _.H(_.F,4,4017);h=d.splice(k,d.length-k);a=Yz(a,c,h,f);return new $z(c,b,f,a)}f.push(g);g.name==Gz&&(g.attributes.push(new _.Ng(_.lb,m)),e=!0)}}return new $z(c,b,f)},bA=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},cA=function(a){var b=Oz(a,"METHOD");const c=["SAMPLE-AES",
5
- Lz];if(!c.includes(b))return _.Hf("PlayReady in HLS is only supported with [",c.join(", "),"], not",b),null;a=Oz(a,_.lb);b=_.Yn(a);a=null;b=_.G(b.data);try{a=_.cu(_.vk(b))}catch(d){a=b}return _.mu(_.Fc,[{initDataType:_.qc,initData:a}],"")},dA=function(a){_.w(function*(){a.a.debug(_.Gt);if(a.j)try{yield a.update(),a.A.aa(a.W)}catch(b){a.j&&(a.j.onError(b),1===b.severity&&a.A.aa(.1))}})},fA=function(a,b){b=_.Wg([b],a.g.attemptParameters);b.type=1;return eA(a,b)},lA=function(a,b){return _.w(function*(){var c=
6
- aA(a.N,b,a.B);if(1===c.type){a.H.set(a.B,c);c=(new _.Zf(c.a[0].a)).na.split(".").pop();var d=gA.audio[c],e="";gA.video[c]?e="avc1.42E01E":d&&(e="mp4a.40.2");{c=a.N;d=a.B;e=a.g.hlsDefaultCodecs||e;var f=[];const h=[];h.push(new _.Ng(_.ja,"0"));h.push(new _.Ng(_.lb,d));e.length&&h.push(new _.Ng(_.la,e));f.push(new _.Og(c.a++,Gz,h));c=new $z(d,0,f)}}c=yield hA(a,c.ra);if(!a.j)throw new _.H(_.F,7,7001);a.j.filterAllPeriods([c]);e=Infinity;d=0;f=Infinity;for(var g of a.f.values())e=Math.min(e,g.Dd),d=
7
- Math.max(d,g.Dd),g.stream.type!=_.r&&(f=Math.min(f,g.duration));a.m!=iA?(a.h=new _.lz(0,a.U,!1),_.Iu(a.h,1)):a.h=new _.lz(null,0,!0);jA(a);if(a.m!=iA){a.W=a.F;a.m===kA&&(g=Math.max(f,a.h.Md),isNaN(a.g.availabilityWindowOverride)||(g=a.g.availabilityWindowOverride),a.h.Zb=g);for(g=0;95443.7176888889<=d;)g+=95443.7176888889,d-=95443.7176888889;if(g){a.a.debug("Offsetting live streams by",g,"to compensate for rollover");for(const h of a.f.values())95443.7176888889>h.Dd?(a.a.debug("Offset applied to",
8
- h.stream.type),h.segmentIndex.offset(g)):a.a.debug("Offset NOT applied to",h.stream.type)}}else{a.h.Jb(f);a.h.offset(-e);for(const h of a.f.values())h.segmentIndex.offset(-e),_.Vu(h.segmentIndex,f)}a.J={presentationTimeline:a.h,periods:[c],offlineSessionIds:[],minBufferTime:0}})},oA=function(a,b){return _.w(function*(){var c=new _.Zf(b.Te);if(a.g.hlsLowLatency){var d=c.a;if(b.Xe){var e=b.segmentIndex;if(e=e.a[e.a.length-1]){const h=e.a,k=h.length-1;e={zf:e.position,Ff:h&&0<h.length?k:null}}else e=
9
- null;const {zf:f,Ff:g}=e;null!==f&&(d.add("_HLS_msn",f),null!==g&&d.add("_HLS_part",g))}e=d;_.jg(e);e.g&&_.bg(c,d)}c=yield fA(a,c.toString());c=aA(a.N,c.data,c.uri);if(1!=c.type)throw new _.H(_.F,4,4017);d=b.stream;d=yield mA(a,b.$c,c,d.type,d.mimeType,d.codecs,d.keyInfo||null,b.bf);b.segmentIndex.replace(d);d=d[d.length-1];Sz(c.ra,Az)&&(nA(a,iA),a.h.Jb(d.endTime))})},mA=function(a,b,c,d,e,f,g,h){return _.w(function*(){var k=c.a;const l=pA(c,g);var m=(m=Sz(c.ra,Bz))?Number(m.value):0;null===a.R&&
10
- (a.R=yield qA(a,b,l,k[0],m,g,e,f,d));const n=a.R;a.a.debug("First segment",k[0].a.split("/").pop(),"starts at",n);var q=Sz(c.ra,zz);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.K.get(t)||0;const u=[];for(const E of _.nu(k)){var y=E.Uc;k=E.item;{var A=u[u.length-1];const D=0==y?n:A.endTime;y=m+y;Sz(k.ra,yz)&&(t++,h.set(t,y),q=yield rA(a,t,b,l,k,y,g,e,f,D,d));A=sA(a,A,k,y,D,q,g,d,c.f);k=Sz(k.ra,Iz);A&&(a.g.hlsLowLatency||k)&&u.push(A)}}a.V.push(u);jA(a);
11
- return u})},nA=function(a,b){a.m=b;if(a.h){b=a.h;var c=a.m==iA;b.j=c;b.m=c}a.m!=iA||a.A.stop()},hA=function(a,b){return _.w(function*(){var c=Qz(b,"EXT-X-MEDIA"),d=Qz(b,Gz),e=Qz(b,"EXT-X-IMAGE-STREAM-INF");for(var f of d){var g=_.lg(f,"AUDIO"),h=_.lg(f,"VIDEO"),k=_.lg(f,Mz);const l=tA(a,f);if(k){const m=_.Ah(_.r,l);a.o.set(k,m);k=l.indexOf(m);-1<k&&l.splice(k,1)}g&&(k=uA(_.Yb,l),a.o.set(g,k));h&&(g=uA(_.v,l),a.o.set(h,g))}yield vA(a,c);f=Rz(c,wz);for(const l of f)f=wA(l),h=Oz(l,Jz),g=Oz(l,"INSTREAM-ID"),
12
- a.M.get(h)||a.M.set(h,new Map),a.M.get(h).set(g,f);d=yield xA(a,d);c=yield yA(a,c);e=yield zA(a,e);return{startTime:0,variants:d,textStreams:c,thumbStreams:e}})},vA=function(a,b){return _.w(function*(){b=b.filter(d=>{const e=_.lg(d,_.lb)||"";return _.lg(d,"TYPE")!==Mz&&""!==e});b.length&&(yield AA(a,b[0]));const c=b.slice(1).map(d=>AA(a,d));yield Promise.all(c)})},xA=function(a,b){return _.w(function*(){var c=f=>_.w(function*(){const g=_.lg(f,"FRAME-RATE"),h=Number(Oz(f,_.ja));var k=_.lg(f,_.Za);
13
- const [l,m]=k?k.split("x"):[null,null];return(k=yield BA(a,f,k,g))?CA(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(Oz(b[f],_.ja));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(_.ju,[]).filter(_.Yf)})},yA=function(a,b){return _.w(function*(){var c=Rz(b,Mz),d=c.map(f=>_.w(function*(){try{return(yield AA(a,f)).stream}catch(g){throw g;}}));d=yield Promise.all(d);for(const f of c){var e=
14
- Oz(f,Jz);if(c=a.o.get(e))if(e=a.w.get(e))for(const g of e)g.stream.codecs=c}return d.filter(f=>f)})},zA=function(a,b){return _.w(function*(){const c=b.map(d=>_.w(function*(){return(yield DA(a,d)).stream}));return(yield Promise.all(c)).filter(d=>d)})},tA=function(a,b){var c=_.lg(b,_.la,a.g.hlsDefaultCodecs||"avc1.42E01E,mp4a.40.2").split(/\s*,\s*/);b=new Set;const d=[];for(const e of c)c=_.uu(e)[0],b.has(c)?a.a.debug("Ignoring duplicate codec"):(d.push(e),b.add(c));return d},uA=function(a,b){if(1==
15
- b.length)return b[0];a=_.Ah(a,b);if(null!=a)return a;throw new _.H(_.F,4,4025,{codecList:b});},AA=function(a,b){return _.w(function*(){const c=Oz(b,Jz);var d="";let e=Oz(b,"TYPE").toLowerCase();e==_.Wt&&(e=_.r);e!==_.r&&c&&a.o.has(c)&&(d=a.o.get(c));const f=Oz(b,_.lb);if(a.f.has(f))return a.f.get(f);const g=wA(b),h=_.lg(b,"NAME"),k=b.getAttribute("DEFAULT"),l=b.getAttribute("AUTOSELECT"),m=_.lg(b,"CHANNELS");d=yield EA(a,f,d,e,g,!!k&&!!l,h,e==_.Yb?m?parseInt(m.split("/")[0],10):null:null,null);if(null==
16
- d)return null;a.w.has(c)?a.w.get(c).push(d):a.w.set(c,[d]);if(a.f.has(f))return a.f.get(f);a.f.set(f,d);return d})},DA=function(a,b){return _.w(function*(){const c=Oz(b,_.lb);if(a.f.has(c))return a.f.get(c);var d=_.lg(b,_.la)||"jpg",e=wA(b);const f=_.lg(b,"NAME");d=yield EA(a,c,d,_.ad,e,!1,f,null,null);if(null===d)return null;if(a.f.has(c))return a.f.get(c);if(e=_.lg(b,_.ja))d.stream.bandwidth=Number(e);a.f.set(c,d);return d})},BA=function(a,b,c,d){return _.w(function*(){let e=tA(a,b);var f=_.lg(b,
17
- "AUDIO"),g=_.lg(b,"VIDEO"),h=f||g;h=h&&a.w.has(h)?a.w.get(h):[];f={audio:f?h:[],video:g?h:[]};a.a.debug("Guessing stream type for",b.toString());g=!1;const k=Oz(b,_.lb),l=f.audio.find(q=>q.$c===k);var m=_.Ah(_.v,e);m=c||d||m;1!==e.length||m?!h.length&&1<e.length?(a.a.debug("Guessing multiplexed audio+video"),h=_.v,e=[e.join(",")]):f.audio.length&&l?(a.a.debug(Kz),h=_.Yb,g=!0):f.video.length?(a.a.debug(Kz),h=_.Yb):(a.a.debug("Guessing video-only"),h=_.v):(h=_.Yb,a.a.debug(Kz));let n;g||(n=yield FA(a,
18
- b,e,h));if(n)f[n.stream.type]=[n];else if(null===n)return a.a.debug("streamInfo is null"),null;GA(f);return f})},CA=function(a,b,c,d,e,f,g){c.forEach(l=>{if(l=l.stream)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.stream:null;const n=m?m.stream:null,q=l?l.drmInfos:null,t=m?m.drmInfos:null;b=(m?m.$c:"")+" - "+(l?l.$c:"");let u;if(k&&n)if(q.length&&t.length?0<_.wu(q,
19
- t).length:1)u=_.wu(q,t);else{a.a.warn("Incompatible DRM info in HLS variant. Skipping.");continue}else k?u=q:n&&(u=t);a.Z.has(b)?a.a.debug("Skipping variant which only differs in text streams."):(k=HA(a,k,n,d,u),h.push(k),a.Z.add(b))}return h},FA=function(a,b,c,d){return _.w(function*(){const e=Oz(b,_.lb);if(a.f.has(e))return a.f.get(e);var f=_.lg(b,wz),g=null;d==_.v&&f&&"NONE"!=f&&(g=a.M.get(f));f=uA(d,c);g=yield EA(a,e,f,d,_.we,!1,null,null,g);if(null==g)return null;if(a.f.has(e))return a.f.get(e);
20
- a.f.set(e,g);return g})},GA=function(a){for(const b of a.audio.concat(a.video))a=b.stream.codecs.split(","),a=a.filter(c=>"mp4a.40.34"!=c),b.stream.codecs=a.join(",")},HA=function(a,b,c,d,e){return{id:a.$++,language:b?b.language:_.we,primary:!!b&&b.primary||!!c&&c.primary,audio:b,video:c,bandwidth:d,drmInfos:e,allowedByApplication:!0,allowedByKeySystem:!0}},wA=function(a){a=_.lg(a,"LANGUAGE")||_.we;return _.Ih(a)},EA=function(a,b,c,d,e,f,g,h,k){return _.w(function*(){let l=Tz(a.B,b);var m=null;if(a.m==
21
- iA&&a.H.has(l)){var n=a.H.get(l);a.H.delete(l)}else{var q=yield fA(a,l);l=q.uri;n=aA(a.N,q.data,l)}if(1!=n.type)throw new _.H(_.F,4,4017);IA(a,n);q=yield JA(a,d,c,n);const t=[];n.a.forEach(ed=>{ed=Qz(ed.ra,"EXT-X-KEY");t.push.apply(t,ed)});let u=!1;const y=[];let A=null;for(var E of t){var D=Oz(E,"METHOD"),ma=_.lg(E,"KEYFORMAT","identity");"NONE"!=D&&("AES-128"==D?(m=_.lg(E,"IV",""),m={method:"AES-128",url:Tz(a.B,Oz(E,_.lb)),iv:m?_.$i((m||"0x").slice(2)):null},a.I=!0):(u=!0,(D=(D=KA[ma])?D(E,q):null)?
22
- (D.keyIds.length&&(A=D.keyIds[0]),y.push(D)):a.a.warn("Unsupported HLS KEYFORMAT",ma)))}if(u&&!y.length&&!a.I)throw new _.H(_.F,4,4026);E=new Map;var na=yield mA(a,b,n,d,q,c,m,E);ma=na[0].startTime;D=na[na.length-1].endTime;const uf=D-ma;na=new _.mz(na);const vf=a.g.hlsLowLatency?_.kx:_.Nt,wf=pA(n,m);let Qa=void 0;d==_.r&&(Qa=_.Vt);n=(n=Sz(n.ra,Fz))?"YES"===_.lg(n,"CAN-BLOCK-RELOAD"):!1;return{stream:{id:a.$++,originalId:g,createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:na.f.bind(na),
23
- getSegmentReference:na.get.bind(na),adjustSegmentDurations:na.g.bind(na),getDuration:na.getDuration.bind(na),segmentIndex:na,segmentLookupStrategy:vf,initSegmentReference:wf,mimeType:q,codecs:c,kind:Qa,encrypted:u,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},segmentIndex:na,drmInfos:y,$c:b,Te:l,Dd:ma,mg:D,duration:uf,bf:E,Xe:n}})},IA=function(a,
24
- b){var c=Sz(b.ra,Dz),d=Sz(b.ra,Az);d=c&&"VOD"==c.value||d;c=c&&"EVENT"==c.value&&!d;c=!d&&!c;if(d)nA(a,iA);else{c?nA(a,kA):nA(a,LA);d=Sz(b.ra,Hz);if(!d)throw new _.H(_.F,4,4024,{missingTag:Hz});d=Number(d.value);c=Sz(b.ra,Cz);a.g.hlsLowLatency&&c?(d=Number(Oz(c,"PART-TARGET")),a.F=Math.min(d,a.F),a.D=Math.max(d,a.D),b=Sz(b.ra,Fz),a.U=b?Number(Oz(b,"PART-HOLD-BACK")):0):(a.D=Math.max(d,a.D),a.F=Math.min(d,a.F),a.U=3*a.D)}},JA=function(a,b,c,d){return _.w(function*(){var e=d.a[0].a;const f=(new _.Zf(e)).na.split(".").pop(),
25
- g=gA[b][f];if(g)return g;if(b==_.r)return c&&"vtt"!=c?_.Sb:_.re;e=_.Wg([e],a.g.attemptParameters);e.method="HEAD";e.type=2;e=(yield eA(a,e)).headers["content-type"];if(!e)throw new _.H(_.F,4,4021,f);return e.split(";")[0]})},pA=function(a,b){var c=Qz(a.ra,"EXT-X-MAP");if(!c.length)return null;if(1<c.length)throw new _.H(_.F,4,4020);c=c[0];var d=Oz(c,_.lb);const e=Tz(a.f,d);a=0;d=null;if(c=_.lg(c,"BYTERANGE"))a=c.split("@"),c=Number(a[0]),a=Number(a[1]),d=a+c-1;return new _.kz(()=>[e],a,d,b)},jA=function(a){a.h&&
26
- (a.V.forEach(b=>{_.Hu(a.h,b,0)}),a.V=[])},MA=function(a,b){var c=0;let d=null;b&&(c=b.split("@"),b=Number(c[0]),c=c[1]?Number(c[1]):a.Ba+1,d=c+b-1);return[c,d]},NA=function(a,b,c,d,e,f,g){const h=[];for(const n of _.nu(b.f)){b=n.Uc;const q=n.item;{var k=0==b?a:h[h.length-1],l=0==b?d:k.endTime,m=Number(_.lg(q,"DURATION"));m=l+m;const t=_.lg(q,"BYTERANGE"),[u,y]=MA(k,t);k=_.lg(q,_.lb);const A=(k=Tz(g,k))?[k]:[];l=new _.Qu(c,l,m,()=>A,u,y,e,f,!1,null,null,null,null);if("YES"===_.lg(q,"INDEPENDENT")||
27
- 0===b)l.g=!0;h.push(l)}}return h},sA=function(a,b,c,d,e,f,g,h,k){var l=c.ra,m=c.a;const n=m?[m]:[];m=Sz(l,Iz);(g=g?Object.assign({},g):null)&&!g.iv&&(g.iv=_.cj(new Uint8Array(12),new Uint8Array([d>>24&255,d>>16&255,d>>8&255,d&255])));var q=null,t=null,u=null;h===_.ad&&(t=Sz(l,"EXT-X-TILES"),q="1x1",t&&(q=_.lg(t,"LAYOUT")||"1x1",u=(u=_.lg(t,"DURATION"))?Number(u):null),[q,t]=q.split("x").map(y=>parseInt(y,10)));if(0===c.f.length&&!m)throw new _.H(_.F,4,4024,{missingTag:Iz});h=null;if(0<c.f.length)if(a.g.hlsLowLatency)h=
28
- NA(b,c,d,e,f,g,k);else return null;c=a=0;k=null;m?(a=e+Number(m.value.split(",")[0]),l=Sz(l,xz),[c,k]=MA(b,l?l.value:null)):a=h[h.length-1].endTime;return new _.Qu(d,e,a,()=>n,c,k,f,g,!1,null,q,t,u,h)},qA=function(a,b,c,d,e,f,g,h,k,l){return _.w(function*(){var m=sA(a,null,d,e,0,0,f,k,"");if(!m)return 0;if(a.J&&!l){var n=a.f.get(b).segmentIndex.get(m.position);if(n)return a.a.debug("Found segment start time in previous manifest"),n.startTime;a.a.debug("Unable to find segment start time in previous manifest!")}a.a.debug("Fetching segment to find start time");
29
- if("audio/mpeg"==g)return 0;if(g==_.Zb)return m=yield OA(a,m),n=_.G(m.data),bA(n)?PA(n):QA(a,m.data);if(g==_.He||g==_.bc)return m=[OA(a,m)],c&&m.push(OA(a,c)),m=yield Promise.all(m),RA(a,m[0].data,(m[1]||m[0]).data);if(g==_.Ge)return m=yield OA(a,m),QA(a,m.data);if(g===_.ac||g===_.$b||!MediaSource.isTypeSupported(`${g.split("/")[0]||""}/mp4;codecs="${h}"`))return 0;throw new _.H(_.F,4,4030);})},rA=function(a,b,c,d,e,f,g,h,k,l,m){return _.w(function*(){let n;a.K.has(b)?n=a.K.get(b):(n=(yield qA(a,
30
- c,d,e,f,g,h,k,m,!0))-l,a.a.debug("Discontinuity segment offset",n),a.K.set(b,n));return n})},eA=function(a,b){if(!a.C)throw new _.H(_.F,7,7001);b=a.j.networkingEngine.fetch(b);_.ch(a.C,b);return b.P},OA=function(a,b){return _.w(function*(){const c=b.f(),d=_.Fu(b.Ea(),b.Ka,b.Ka+2048-1,a.g.attemptParameters);d.type=2;const e=_.Fu(b.Ea(),b.Ka,b.Ba,a.g.attemptParameters);e.type=2;c&&(e.keyInfo=c);try{return yield eA(a,a.I?e:d)}catch(f){if(7001==f.code||a.I)throw f;a.a.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 preflights.",
31
- d.uris[0]);return yield eA(a,e)}})},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 _.H(_.F,4,4030);}bA(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"===
32
- 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}}bA(a,e)||d();e+=10;e+=f}while(e<a.byteLength);return d()},QA=function(a,b){function c(){e.seek(f+188);g=_.rj(e);71!=g&&(e.seek(f+192),g=_.rj(e));71!=g&&(e.seek(f+204),g=_.rj(e));71!=g&&d();Pz(e)}function d(){throw new _.H(_.F,4,4030);}const e=new _.ok(new DataView(b),!1);let f=0,g=0;f=SA(e);0>f&&(a.a.error("Unable to find sync byte in TS after scanning"),d());for(;;){f=
33
- e.getPosition();g=_.rj(e);71!=g&&d();a=_.sj(e);if(8191===(a&8191)){c();continue}if(!(a&16384)){c();continue}a=(_.rj(e)&48)>>4;0!=a&&2!=a||d();3==a&&(a=_.rj(e),e.skip(a));if(1!=_.M(e)>>8){c();continue}e.skip(3);a=_.rj(e)>>6;0!=a&&1!=a||d();0==_.rj(e)&&d();a=_.rj(e);b=_.sj(e);const h=_.sj(e);return(1073741824*((a&14)>>1)+((b&65534)<<14|(h&65534)>>1))/9E4}},RA=function(a,b,c){let d=0;(new _.Fj).L(_.vd,_.N).L(_.ue,_.N).L(_.qd,_.N).X("mdhd",g=>{g.G.skip(0==g.version?8:16);d=_.M(g.G);g.Pa.stop()}).parse(c,
34
- !0);if(!d)throw a.a.error("Unable to find timescale in init segment!"),new _.H(_.F,4,4030);let e=0,f=!1;(new _.Fj).L("moof",_.N).L("traf",_.N).X("tfdt",g=>{e=(0==g.version?_.M(g.G):_.vj(g.G))/d;f=!0;g.Pa.stop()}).parse(b,!0);if(!f)throw new _.H(_.F,4,4030);return e},SA=function(a){for(;a.getPosition()<a.va()-1;){const b=a.getPosition();if(71===_.rj(a))return Pz(a),b}return-1},$z=class{constructor(a,b,c,d){this.f=a;this.type=b;this.ra=c;this.a=d||null}},Xz=class{constructor(a,b,c=[]){this.ra=b;this.a=
35
- a;this.f=c}},Vz=[Hz,Bz,zz,Dz,"EXT-X-MAP","EXT-X-I-FRAMES-ONLY",Az,Fz,Cz],Zz=[Iz,xz,yz,"EXT-X-PROGRAM-DATE-TIME","EXT-X-KEY","EXT-X-DATERANGE"],Wz=["EXT-X-PART",Ez],TA=class{constructor(){this.a=0}},UA=class{constructor(){this.g=this.j=null;this.$=1;this.U=0;this.w=new Map;this.Z=new Set;this.f=new Map;this.h=null;this.B="";this.N=new TA;this.W=0;this.S=new Map;this.A=new _.Oh(()=>{dA(this)});this.m=iA;this.J=null;this.D=0;this.F=Infinity;this.C=new _.Jo;this.V=[];this.M=new Map;this.I=!1;this.o=new Map;
36
- this.R=null;this.a=new _.O("clpp.hls.HlsParser");this.H=new Map;this.K=new Map}configure(a){this.g=a}setCurrentVariant(a){const b=a.video?a.video.id:null;a=a.audio?a.audio.id:null;this.S.clear();for(const c of this.f.keys()){const d=this.f.get(c);!d.stream||d.stream.id!==b&&d.stream.id!==a||this.S.set(c,d)}}start(a,b){const c=this;return _.w(function*(){c.j=b;var d=yield fA(c,a);c.B=d.uri;yield lA(c,d.data);d=c.W;0<d&&c.A.aa(d);return c.J})}stop(){this.A&&(this.A.stop(),this.A=null);const a=[];this.C&&
37
- (a.push(this.C.destroy()),this.C=null);this.g=this.j=null;this.Z.clear();this.f.clear();this.H.clear();this.J=null;this.w.clear();this.o.clear();return Promise.all(a)}update(){const a=this;return _.w(function*(){if(a.m!=iA){var b=[];a.R=null;var c=Array.from(a.f.values()),d=Array.from(a.S.values());c=a.g.hlsLowLatency&&0<d.length?d:c;yield oA(a,c[0]);for(d=1;d<c.length;d++)b.push(oA(a,c[d]));yield Promise.all(b)}})}onExpirationUpdated(){}},gA={audio:{mp4:_.bc,m4s:_.bc,m4i:_.bc,m4a:_.bc,cmfa:_.bc,
38
- ts:_.Ge,aac:_.Zb,ec3:_.ac,ac3:_.$b},video:{mp4:_.He,m4s:_.He,m4i:_.He,m4v:_.He,cmfv:_.He,ts:_.Ge},text:{mp4:_.Sb,m4s:_.Sb,m4i:_.Sb,cmft:_.Sb,vtt:_.re,ttml:_.Vb},image:{jpg:_.bd,jpeg:_.bd,png:"image/png",svg:"image/svg+xml",webp:"image/webp",avif:"image/avif"}},KA={"com.apple.streamingkeydelivery":function(a,b){if(b===_.Ge)throw new _.H(_.F,4,4041);return _.mu(_.Ec,[{initDataType:_.fe,initData:new Uint8Array(0)}],"")},"com.microsoft.playready":cA,"urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":cA,
39
- "urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":function(a){var b=Oz(a,"METHOD");const c=["SAMPLE-AES",Lz];if(!c.includes(b))return _.Hf("Widevine in HLS is only supported with [",c.join(", "),"], not",b),null;b=Oz(a,_.lb);b=_.Yn(b);b=_.G(b.data);b=_.mu(_.Gc,[{initDataType:_.qc,initData:b}],"");if(a=_.lg(a,"KEYID"))b.keyIds=[a.substr(2).toLowerCase()];return b}},iA="VOD",LA="EVENT",kA="LIVE";_.x("clpp.hls.HlsComponent",class extends _.Bp{constructor(){super()}f(){_.Cn.m3u8=UA;_.An[_.ui]=UA;_.An[Nz]=UA}a(){_.Yu("m3u8");_.Zu(_.ui);_.Zu(Nz)}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 Ez="CLOSED-CAPTIONS",Fz="EXT-X-BYTERANGE",Gz="EXT-X-DISCONTINUITY",Hz="EXT-X-DISCONTINUITY-SEQUENCE",Iz="EXT-X-ENDLIST",Jz="EXT-X-MEDIA-SEQUENCE",Kz="EXT-X-PART-INF",Lz="EXT-X-PLAYLIST-TYPE",Mz="EXT-X-PRELOAD-HINT",Nz="EXT-X-SERVER-CONTROL",Oz="EXT-X-STREAM-INF",Pz="EXT-X-TARGETDURATION",Qz="EXTINF",Rz="GROUP-ID",Sz="Guessing audio-only",Tz="SAMPLE-AES-CTR",Uz="SUBTITLES",Vz="application/vnd.apple.mpegurl",Wz=function(a,b){a=a.getAttribute(b);if(!a)throw new _.H(_.F,4,4023,b);return a.value},
2
+ Xz=function(a){if(1>a.a)throw _.sj();--a.a},Yz=function(a,b){return a.filter(c=>c.name==b)},Zz=function(a,b){return a.filter(c=>Wz(c,"TYPE")===b)},$z=function(a,b){a=Yz(a,b);return a.length?a[0]:null},aA=function(a,b){return _.ou([a],[b])[0]},bA=function(a,b){return _.Tg(a.a++,b)},fA=function(a,b,c,d){const e=[];let f=[],g=[];c.forEach(h=>{/^(#EXT)/.test(h)?(h=bA(a,h),cA.includes(h.name)?d.push(h):dA.includes(h.name)?"EXT-X-PART"===h.name?g.push(h):h.name===Mz&&"PART"===_.ng(h,"TYPE")&&g.push(h):
3
+ f.push(h)):/^#(?!EXT)/m.test(h)||(h=aA(b,h.trim()),e.push(new eA(h,f,g)),f=[],g=[])});g.length&&e.push(new eA(null,f,g));return e},iA=function(a,b,c){b=_.Ag(b);b=b.replace(/\r\n|\r(?=[^\n]|$)/gm,"\n").trim();const d=b.split(/\n+/m);if(!/^#EXTM3U($|[ \t\n])/m.test(d[0]))throw new _.H(_.F,4,4015);b=0;let e=!0;for(var f of d)if(f=f.trim(),!f.length||/^#(?!EXT)/m.test(f)||e)e=!1;else{var g=bA(a,f);--a.a;if(cA.includes(g.name)){b=1;break}else g.name==Oz&&(e=!0)}f=[];e=!0;for(var h of _.qu(d)){let {Wc:k,
4
+ item:l,next:m}=h;l=l.trim();if(!l.length||/^#(?!EXT)/m.test(l)||e)e=!1;else{g=bA(a,l);if(gA.includes(g.name)){if(1!=b)throw new _.H(_.F,4,4017);h=d.splice(k,d.length-k);a=fA(a,c,h,f);return new hA(c,b,f,a)}f.push(g);g.name==Oz&&(g.attributes.push(new _.Pg(_.lb,m)),e=!0)}}return new hA(c,b,f)},jA=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},kA=function(a){var b=Wz(a,"METHOD");const c=["SAMPLE-AES",
5
+ Tz];if(!c.includes(b))return _.Jf("PlayReady in HLS is only supported with [",c.join(", "),"], not",b),null;a=Wz(a,_.lb);b=_.ao(a);a=null;b=_.G(b.data);try{a=_.fu(_.xk(b))}catch(d){a=b}return _.pu(_.Gc,[{initDataType:_.qc,initData:a}],"")},mA=function(a,b){b=_.Yg([b],a.g.attemptParameters);b.type=1;return lA(a,b)},sA=function(a,b){return _.w(function*(){var c=iA(a.M,b,a.A);if(1===c.type){a.G.set(a.A,c);c=(new _.ag(c.a[0].a)).pa.split(".").pop();var d=nA.audio[c],e="";nA.video[c]?e="avc1.42E01E":d&&
6
+ (e="mp4a.40.2");{c=a.M;d=a.A;e=a.g.hlsDefaultCodecs||e;var f=[];const h=[];h.push(new _.Pg(_.ja,"0"));h.push(new _.Pg(_.lb,d));e.length&&h.push(new _.Pg(_.la,e));f.push(new _.Sg(c.a++,Oz,h));c=new hA(d,0,f)}}c=yield oA(a,c.ta);if(!a.D)throw new _.H(_.F,7,7001);a.D.filterAllPeriods([c]);e=Infinity;d=0;f=Infinity;for(var g of a.f.values())e=Math.min(e,g.Fd),d=Math.max(d,g.Fd),g.stream.type!=_.r&&(f=Math.min(f,g.duration));a.j!=pA?(a.h=new _.tz(0,a.T,!1),_.Mu(a.h,1)):a.h=new _.tz(null,0,!0);qA(a);if(a.j!=
7
+ pA){a.W=a.F;a.j===rA&&(g=Math.max(f,a.h.Od),isNaN(a.g.availabilityWindowOverride)||(g=a.g.availabilityWindowOverride),a.h.ac=g);for(g=0;95443.7176888889<=d;)g+=95443.7176888889,d-=95443.7176888889;if(g){a.a.debug("Offsetting live streams by",g,"to compensate for rollover");for(const h of a.f.values())95443.7176888889>h.Fd?(a.a.debug("Offset applied to",h.stream.type),h.segmentIndex.offset(g)):a.a.debug("Offset NOT applied to",h.stream.type)}}else{a.h.Mb(f);a.h.offset(-e);for(const h of a.f.values())h.segmentIndex.offset(-e),
8
+ _.Zu(h.segmentIndex,f)}a.J={presentationTimeline:a.h,periods:[c],offlineSessionIds:[],minBufferTime:0}})},vA=function(a,b){return _.w(function*(){var c=new _.ag(b.Ve);if(a.g.hlsLowLatency){var d=c.a;if(b.af){var e=b.segmentIndex;if(e=e.a[e.a.length-1]){const h=e.a,k=h.length-1;e={Df:e.position,Jf:h&&0<h.length?k:null}}else e=null;const {Df:f,Jf:g}=e;null!==f&&(d.add("_HLS_msn",f),null!==g&&d.add("_HLS_part",g))}e=d;_.lg(e);e.g&&_.dg(c,d)}c=yield mA(a,c.toString());c=iA(a.M,c.data,c.uri);if(1!=c.type)throw new _.H(_.F,
9
+ 4,4017);d=b.stream;d=yield tA(a,b.cd,c,d.type,d.mimeType,d.codecs,d.keyInfo||null,b.ff);b.segmentIndex.replace(d);d=d[d.length-1];$z(c.ta,Iz)&&(uA(a,pA),a.h.Mb(d.endTime))})},tA=function(a,b,c,d,e,f,g,h){return _.w(function*(){var k=c.a;const l=wA(c,g);var m=(m=$z(c.ta,Jz))?Number(m.value):0;null===a.O&&(a.O=yield xA(a,b,l,k[0],m,g,e,f,d));const n=a.O;a.a.debug("First segment",k[0].a.split("/").pop(),"starts at",n);var q=$z(c.ta,Hz);let t=q?Number(q.value):0;h.has(t)||h.set(t,m);if(!q)for(;h.has(t+
10
+ 1)&&h.get(t+1)<m;)t++;q=a.K.get(t)||0;const u=[];for(const E of _.qu(k)){var y=E.Wc;k=E.item;{var A=u[u.length-1];const D=0==y?n:A.endTime;y=m+y;$z(k.ta,Gz)&&(t++,h.set(t,y),q=yield yA(a,t,b,l,k,y,g,e,f,D,d));A=zA(a,A,k,y,D,q,g,d,c.f);k=$z(k.ta,Qz);A&&(a.g.hlsLowLatency||k)&&u.push(A)}}a.V.push(u);qA(a);return u})},uA=function(a,b){a.j=b;if(a.h){b=a.h;var c=a.j==pA;b.j=c;b.m=c}a.j!=pA||a.w.stop()},oA=function(a,b){return _.w(function*(){var c=Yz(b,"EXT-X-MEDIA"),d=Yz(b,Oz),e=Yz(b,"EXT-X-IMAGE-STREAM-INF");
11
+ for(var f of d){var g=_.ng(f,"AUDIO"),h=_.ng(f,"VIDEO"),k=_.ng(f,Uz);const l=AA(a,f);if(k){const m=_.Ch(_.r,l);a.m.set(k,m);k=l.indexOf(m);-1<k&&l.splice(k,1)}g&&(k=BA(_.Yb,l),a.m.set(g,k));h&&(g=BA(_.v,l),a.m.set(h,g))}yield CA(a,c);f=Zz(c,Ez);for(const l of f)f=DA(l),h=Wz(l,Rz),g=Wz(l,"INSTREAM-ID"),a.L.get(h)||a.L.set(h,new Map),a.L.get(h).set(g,f);d=yield EA(a,d);c=yield FA(a,c);e=yield GA(a,e);return{startTime:0,variants:d,textStreams:c,thumbStreams:e}})},CA=function(a,b){return _.w(function*(){b=
12
+ b.filter(d=>{const e=_.ng(d,_.lb)||"";return _.ng(d,"TYPE")!==Uz&&""!==e});b.length&&(yield HA(a,b[0]));const c=b.slice(1).map(d=>HA(a,d));yield Promise.all(c)})},EA=function(a,b){return _.w(function*(){var c=f=>_.w(function*(){const g=_.ng(f,"FRAME-RATE"),h=Number(Wz(f,_.ja));var k=_.ng(f,_.Za);const [l,m]=k?k.split("x"):[null,null];return(k=yield IA(a,f,k,g))?JA(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(Wz(b[f],_.ja));g<e&&(e=g,d=f)}e=b.splice(d,
13
+ 1).pop();e=yield c(e);c=b.map(c);c=yield Promise.all(c);c.splice(d,0,e);return c.reduce(_.mu,[]).filter(_.$f)})},FA=function(a,b){return _.w(function*(){var c=Zz(b,Uz),d=c.map(f=>_.w(function*(){try{return(yield HA(a,f)).stream}catch(g){throw g;}}));d=yield Promise.all(d);for(const f of c){var e=Wz(f,Rz);if(c=a.m.get(e))if(e=a.o.get(e))for(const g of e)g.stream.codecs=c}return d.filter(f=>f)})},GA=function(a,b){return _.w(function*(){const c=b.map(d=>_.w(function*(){return(yield KA(a,d)).stream}));
14
+ return(yield Promise.all(c)).filter(d=>d)})},AA=function(a,b){var c=_.ng(b,_.la,a.g.hlsDefaultCodecs||"avc1.42E01E,mp4a.40.2").split(/\s*,\s*/);b=new Set;const d=[];for(const e of c)c=_.xu(e)[0],b.has(c)?a.a.debug("Ignoring duplicate codec"):(d.push(e),b.add(c));return d},BA=function(a,b){if(1==b.length)return b[0];a=_.Ch(a,b);if(null!=a)return a;throw new _.H(_.F,4,4025,{codecList:b});},HA=function(a,b){return _.w(function*(){const c=Wz(b,Rz);var d="";let e=Wz(b,"TYPE").toLowerCase();e==_.Zt&&(e=
15
+ _.r);e!==_.r&&c&&a.m.has(c)&&(d=a.m.get(c));const f=Wz(b,_.lb);if(a.f.has(f))return a.f.get(f);const g=DA(b),h=_.ng(b,"NAME"),k=b.getAttribute("DEFAULT"),l=b.getAttribute("AUTOSELECT"),m=_.ng(b,"CHANNELS");d=yield LA(a,f,d,e,g,!!k&&!!l,h,e==_.Yb?m?parseInt(m.split("/")[0],10):null:null,null);if(null==d)return null;a.o.has(c)?a.o.get(c).push(d):a.o.set(c,[d]);if(a.f.has(f))return a.f.get(f);a.f.set(f,d);return d})},KA=function(a,b){return _.w(function*(){const c=Wz(b,_.lb);if(a.f.has(c))return a.f.get(c);
16
+ var d=_.ng(b,_.la)||"jpg",e=DA(b);const f=_.ng(b,"NAME");d=yield LA(a,c,d,_.bd,e,!1,f,null,null);if(null===d)return null;if(a.f.has(c))return a.f.get(c);if(e=_.ng(b,_.ja))d.stream.bandwidth=Number(e);a.f.set(c,d);return d})},IA=function(a,b,c,d){return _.w(function*(){let e=AA(a,b);var f=_.ng(b,"AUDIO"),g=_.ng(b,"VIDEO"),h=f||g;h=h&&a.o.has(h)?a.o.get(h):[];f={audio:f?h:[],video:g?h:[]};a.a.debug("Guessing stream type for",b.toString());g=!1;const k=Wz(b,_.lb),l=f.audio.find(q=>q.cd===k);var m=_.Ch(_.v,
17
+ e);m=c||d||m;1!==e.length||m?!h.length&&1<e.length?(a.a.debug("Guessing multiplexed audio+video"),h=_.v,e=[e.join(",")]):f.audio.length&&l?(a.a.debug(Sz),h=_.Yb,g=!0):f.video.length?(a.a.debug(Sz),h=_.Yb):(a.a.debug("Guessing video-only"),h=_.v):(h=_.Yb,a.a.debug(Sz));let n;g||(n=yield MA(a,b,e,h));if(n)f[n.stream.type]=[n];else if(null===n)return a.a.debug("streamInfo is null"),null;NA(f);return f})},JA=function(a,b,c,d,e,f,g){c.forEach(l=>{if(l=l.stream)l.width=Number(e)||void 0,l.height=Number(f)||
18
+ 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.stream:null;const n=m?m.stream:null,q=l?l.drmInfos:null,t=m?m.drmInfos:null;b=(m?m.cd:"")+" - "+(l?l.cd:"");let u;if(k&&n)if(q.length&&t.length?0<_.zu(q,t).length:1)u=_.zu(q,t);else{a.a.warn("Incompatible DRM info in HLS variant. Skipping.");continue}else k?u=q:n&&(u=t);a.X.has(b)?a.a.debug("Skipping variant which only differs in text streams."):(k=OA(a,k,n,d,u),
19
+ h.push(k),a.X.add(b))}return h},MA=function(a,b,c,d){return _.w(function*(){const e=Wz(b,_.lb);if(a.f.has(e))return a.f.get(e);var f=_.ng(b,Ez),g=null;d==_.v&&f&&"NONE"!=f&&(g=a.L.get(f));f=BA(d,c);g=yield LA(a,e,f,d,_.xe,!1,null,null,g);if(null==g)return null;if(a.f.has(e))return a.f.get(e);a.f.set(e,g);return g})},NA=function(a){for(const b of a.audio.concat(a.video))a=b.stream.codecs.split(","),a=a.filter(c=>"mp4a.40.34"!=c),b.stream.codecs=a.join(",")},OA=function(a,b,c,d,e){return{id:a.$++,language:b?
20
+ b.language:_.xe,primary:!!b&&b.primary||!!c&&c.primary,audio:b,video:c,bandwidth:d,drmInfos:e,allowedByApplication:!0,allowedByKeySystem:!0}},DA=function(a){a=_.ng(a,"LANGUAGE")||_.xe;return _.Kh(a)},LA=function(a,b,c,d,e,f,g,h,k){return _.w(function*(){let l=aA(a.A,b);var m=null;if(a.j==pA&&a.G.has(l)){var n=a.G.get(l);a.G.delete(l)}else{var q=yield mA(a,l);l=q.uri;n=iA(a.M,q.data,l)}if(1!=n.type)throw new _.H(_.F,4,4017);PA(a,n);q=yield QA(a,d,c,n);const t=[];n.a.forEach(fd=>{fd=Yz(fd.ta,"EXT-X-KEY");
21
+ t.push.apply(t,fd)});let u=!1;const y=[];let A=null;for(var E of t){var D=Wz(E,"METHOD"),ma=_.ng(E,"KEYFORMAT","identity");"NONE"!=D&&("AES-128"==D?(m=_.ng(E,"IV",""),m={method:"AES-128",url:aA(a.A,Wz(E,_.lb)),iv:m?_.bj((m||"0x").slice(2)):null},a.I=!0):(u=!0,(D=(D=RA[ma])?D(E,q):null)?(D.keyIds.length&&(A=D.keyIds[0]),y.push(D)):a.a.warn("Unsupported HLS KEYFORMAT",ma)))}if(u&&!y.length&&!a.I)throw new _.H(_.F,4,4026);E=new Map;var na=yield tA(a,b,n,d,q,c,m,E);ma=na[0].startTime;D=na[na.length-1].endTime;
22
+ const uf=D-ma;na=new _.uz(na);const vf=a.g.hlsLowLatency?_.rx:_.Qt,wf=wA(n,m);let Ra=void 0;d==_.r&&(Ra=_.Yt);n=(n=$z(n.ta,Nz))?"YES"===_.ng(n,"CAN-BLOCK-RELOAD"):!1;return{stream:{id:a.$++,originalId:g,createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:na.f.bind(na),getSegmentReference:na.get.bind(na),adjustSegmentDurations:na.g.bind(na),getDuration:na.getDuration.bind(na),segmentIndex:na,segmentLookupStrategy:vf,initSegmentReference:wf,mimeType:q,codecs:c,kind:Ra,encrypted:u,keyId:A,
23
+ 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},segmentIndex:na,drmInfos:y,cd:b,Ve:l,Fd:ma,qg:D,duration:uf,ff:E,af:n}})},PA=function(a,b){var c=$z(b.ta,Lz),d=$z(b.ta,Iz);d=c&&"VOD"==c.value||d;c=c&&"EVENT"==c.value&&!d;c=!d&&!c;if(d)uA(a,pA);else{c?uA(a,rA):uA(a,SA);d=$z(b.ta,Pz);if(!d)throw new _.H(_.F,4,4024,{missingTag:Pz});d=Number(d.value);c=$z(b.ta,
24
+ Kz);a.g.hlsLowLatency&&c?(d=Number(Wz(c,"PART-TARGET")),a.F=Math.min(d,a.F),a.C=Math.max(d,a.C),b=$z(b.ta,Nz),a.T=b?Number(Wz(b,"PART-HOLD-BACK")):0):(a.C=Math.max(d,a.C),a.F=Math.min(d,a.F),a.T=3*a.C)}},QA=function(a,b,c,d){return _.w(function*(){var e=d.a[0].a;const f=(new _.ag(e)).pa.split(".").pop(),g=nA[b][f];if(g)return g;if(b==_.r)return c&&"vtt"!=c?_.Sb:_.se;e=_.Yg([e],a.g.attemptParameters);e.method="HEAD";e.type=2;e=(yield lA(a,e)).headers["content-type"];if(!e)throw new _.H(_.F,4,4021,
25
+ f);return e.split(";")[0]})},wA=function(a,b){var c=Yz(a.ta,"EXT-X-MAP");if(!c.length)return null;if(1<c.length)throw new _.H(_.F,4,4020);c=c[0];var d=Wz(c,_.lb);const e=aA(a.f,d);a=0;d=null;if(c=_.ng(c,"BYTERANGE"))a=c.split("@"),c=Number(a[0]),a=Number(a[1]),d=a+c-1;return new _.sz(()=>[e],a,d,b)},qA=function(a){a.h&&(a.V.forEach(b=>{_.Lu(a.h,b,0)}),a.V=[])},TA=function(a,b){var c=0;let d=null;b&&(c=b.split("@"),b=Number(c[0]),c=c[1]?Number(c[1]):a.Ba+1,d=c+b-1);return[c,d]},UA=function(a,b,c,d,
26
+ e,f,g){const h=[];for(const n of _.qu(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(_.ng(q,"DURATION"));m=l+m;const t=_.ng(q,"BYTERANGE"),[u,y]=TA(k,t);k=_.ng(q,_.lb);const A=(k=aA(g,k))?[k]:[];l=new _.Uu(c,l,m,()=>A,u,y,e,f,!1,null,null,null,null);if("YES"===_.ng(q,"INDEPENDENT")||0===b)l.g=!0;h.push(l)}}return h},zA=function(a,b,c,d,e,f,g,h,k){var l=c.ta,m=c.a;const n=m?[m]:[];m=$z(l,Qz);(g=g?Object.assign({},g):null)&&!g.iv&&(g.iv=_.ej(new Uint8Array(12),new Uint8Array([d>>
27
+ 24&255,d>>16&255,d>>8&255,d&255])));var q=null,t=null,u=null;h===_.bd&&(t=$z(l,"EXT-X-TILES"),q="1x1",t&&(q=_.ng(t,"LAYOUT")||"1x1",u=(u=_.ng(t,"DURATION"))?Number(u):null),[q,t]=q.split("x").map(y=>parseInt(y,10)));if(0===c.f.length&&!m)throw new _.H(_.F,4,4024,{missingTag:Qz});h=null;if(0<c.f.length)if(a.g.hlsLowLatency)h=UA(b,c,d,e,f,g,k);else return null;c=a=0;k=null;m?(a=e+Number(m.value.split(",")[0]),l=$z(l,Fz),[c,k]=TA(b,l?l.value:null)):a=h[h.length-1].endTime;return new _.Uu(d,e,a,()=>n,
28
+ c,k,f,g,!1,null,q,t,u,h)},xA=function(a,b,c,d,e,f,g,h,k,l){return _.w(function*(){var m=zA(a,null,d,e,0,0,f,k,"");if(!m)return 0;if(a.J&&!l){var n=a.f.get(b).segmentIndex.get(m.position);if(n)return a.a.debug("Found segment start time in previous manifest"),n.startTime;a.a.debug("Unable to find segment start time in previous manifest!")}a.a.debug("Fetching segment to find start time");if("audio/mpeg"==g)return 0;if(g==_.Zb)return m=yield VA(a,m),n=_.G(m.data),jA(n)?WA(n):XA(a,m.data);if(g==_.Ie||
29
+ g==_.bc)return m=[VA(a,m)],c&&m.push(VA(a,c)),m=yield Promise.all(m),YA(a,m[0].data,(m[1]||m[0]).data);if(g==_.He)return m=yield VA(a,m),XA(a,m.data);if(g===_.ac||g===_.$b||!MediaSource.isTypeSupported(`${g.split("/")[0]||""}/mp4;codecs="${h}"`))return 0;throw new _.H(_.F,4,4030);})},yA=function(a,b,c,d,e,f,g,h,k,l,m){return _.w(function*(){let n;a.K.has(b)?n=a.K.get(b):(n=(yield xA(a,c,d,e,f,g,h,k,m,!0))-l,a.a.debug("Discontinuity segment offset",n),a.K.set(b,n));return n})},lA=function(a,b){if(!a.B)throw new _.H(_.F,
30
+ 7,7001);b=a.D.networkingEngine.fetch(b);_.eh(a.B,b);return b.R},VA=function(a,b){return _.w(function*(){const c=b.f(),d=_.Iu(b.Ea(),b.La,b.La+2048-1,a.g.attemptParameters);d.type=2;const e=_.Iu(b.Ea(),b.La,b.Ba,a.g.attemptParameters);e.type=2;c&&(e.keyInfo=c);try{return yield lA(a,a.I?e:d)}catch(f){if(7001==f.code||a.I)throw f;a.a.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 preflights.",
31
+ d.uris[0]);return yield lA(a,e)}})},WA=function(a){function b(h,k,l){let m="";for(;k<l;k++)m+="%"+("00"+h[k].toString(16)).slice(-2);return m}function c(h){return h[0]<<21|h[1]<<14|h[2]<<7|h[3]}function d(){throw new _.H(_.F,4,4030);}jA(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"===
32
+ 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}}jA(a,e)||d();e+=10;e+=f}while(e<a.byteLength);return d()},XA=function(a,b){function c(){e.seek(f+188);g=_.tj(e);71!=g&&(e.seek(f+192),g=_.tj(e));71!=g&&(e.seek(f+204),g=_.tj(e));71!=g&&d();Xz(e)}function d(){throw new _.H(_.F,4,4030);}const e=new _.qk(new DataView(b),!1);let f=0,g=0;f=ZA(e);0>f&&(a.a.error("Unable to find sync byte in TS after scanning"),d());for(;;){f=
33
+ e.getPosition();g=_.tj(e);71!=g&&d();a=_.uj(e);if(8191===(a&8191)){c();continue}if(!(a&16384)){c();continue}a=(_.tj(e)&48)>>4;0!=a&&2!=a||d();3==a&&(a=_.tj(e),e.skip(a));if(1!=_.M(e)>>8){c();continue}e.skip(3);a=_.tj(e)>>6;0!=a&&1!=a||d();0==_.tj(e)&&d();a=_.tj(e);b=_.uj(e);const h=_.uj(e);return(1073741824*((a&14)>>1)+((b&65534)<<14|(h&65534)>>1))/9E4}},YA=function(a,b,c){let d=0;(new _.Hj).N(_.wd,_.N).N(_.ve,_.N).N(_.rd,_.N).Y("mdhd",g=>{g.H.skip(0==g.version?8:16);d=_.M(g.H);g.Qa.stop()}).parse(c,
34
+ !0);if(!d)throw a.a.error("Unable to find timescale in init segment!"),new _.H(_.F,4,4030);let e=0,f=!1;(new _.Hj).N("moof",_.N).N("traf",_.N).Y("tfdt",g=>{e=(0==g.version?_.M(g.H):_.xj(g.H))/d;f=!0;g.Qa.stop()}).parse(b,!0);if(!f)throw new _.H(_.F,4,4030);return e},ZA=function(a){for(;a.getPosition()<a.wa()-1;){const b=a.getPosition();if(71===_.tj(a))return Xz(a),b}return-1},hA=class{constructor(a,b,c,d){this.f=a;this.type=b;this.ta=c;this.a=d||null}},eA=class{constructor(a,b,c=[]){this.ta=b;this.a=
35
+ a;this.f=c}},cA=[Pz,Jz,Hz,Lz,"EXT-X-MAP","EXT-X-I-FRAMES-ONLY",Iz,Nz,Kz],gA=[Qz,Fz,Gz,"EXT-X-PROGRAM-DATE-TIME","EXT-X-KEY","EXT-X-DATERANGE"],dA=["EXT-X-PART",Mz],$A=class{constructor(){this.a=0}},aB=class{constructor(){this.g=this.D=null;this.$=1;this.T=0;this.o=new Map;this.X=new Set;this.f=new Map;this.h=null;this.A="";this.M=new $A;this.W=0;this.S=new Map;this.w=new _.Qh(()=>{this.wb()});this.j=pA;this.J=null;this.C=0;this.F=Infinity;this.B=new _.Mo;this.V=[];this.L=new Map;this.I=!1;this.m=
36
+ new Map;this.O=null;this.a=new _.O("clpp.hls.HlsParser");this.G=new Map;this.K=new Map}configure(a){this.g=a}setCurrentVariant(a){const b=a.video?a.video.id:null;a=a.audio?a.audio.id:null;this.S.clear();for(const c of this.f.keys()){const d=this.f.get(c);!d.stream||d.stream.id!==b&&d.stream.id!==a||this.S.set(c,d)}}start(a,b){const c=this;return _.w(function*(){c.D=b;var d=yield mA(c,a);c.A=d.uri;yield sA(c,d.data);d=c.W;0<d&&c.w.aa(d);return c.J})}stop(){this.w&&(this.w.stop(),this.w=null);const a=
37
+ [];this.B&&(a.push(this.B.destroy()),this.B=null);this.g=this.D=null;this.X.clear();this.f.clear();this.G.clear();this.J=null;this.o.clear();this.m.clear();return Promise.all(a)}update(){const a=this;return _.w(function*(){if(a.j!=pA){var b=[];a.O=null;var c=Array.from(a.f.values()),d=Array.from(a.S.values());c=a.g.hlsLowLatency&&0<d.length?d:c;yield vA(a,c[0]);for(d=1;d<c.length;d++)b.push(vA(a,c[d]));yield Promise.all(b)}})}onExpirationUpdated(){}wb(){const a=this;return _.w(function*(){a.a.debug(_.Jt);
38
+ if(a.D)try{yield a.update(),a.w.aa(a.W)}catch(b){a.D&&(a.D.onError(b),1===b.severity&&a.w.aa(.1))}})}},nA={audio:{mp4:_.bc,m4s:_.bc,m4i:_.bc,m4a:_.bc,cmfa:_.bc,ts:_.He,aac:_.Zb,ec3:_.ac,ac3:_.$b},video:{mp4:_.Ie,m4s:_.Ie,m4i:_.Ie,m4v:_.Ie,cmfv:_.Ie,ts:_.He},text:{mp4:_.Sb,m4s:_.Sb,m4i:_.Sb,cmft:_.Sb,vtt:_.se,ttml:_.Vb},image:{jpg:_.cd,jpeg:_.cd,png:"image/png",svg:"image/svg+xml",webp:"image/webp",avif:"image/avif"}},RA={"com.apple.streamingkeydelivery":function(a,b){if(b===_.He)throw new _.H(_.F,
39
+ 4,4041);return _.pu(_.Fc,[{initDataType:_.ge,initData:new Uint8Array(0)}],"")},"com.microsoft.playready":kA,"urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":kA,"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":function(a){var b=Wz(a,"METHOD");const c=["SAMPLE-AES",Tz];if(!c.includes(b))return _.Jf("Widevine in HLS is only supported with [",c.join(", "),"], not",b),null;b=Wz(a,_.lb);b=_.ao(b);b=_.G(b.data);b=_.pu(_.Hc,[{initDataType:_.qc,initData:b}],"");if(a=_.ng(a,"KEYID"))b.keyIds=[a.substr(2).toLowerCase()];
40
+ return b}},pA="VOD",SA="EVENT",rA="LIVE";_.x("clpp.hls.HlsComponent",class extends _.Ep{constructor(){super()}f(){_.Fn.m3u8=aB;_.Dn[_.wi]=aB;_.Dn[Vz]=aB}a(){_.bv("m3u8");_.cv(_.wi);_.cv(Vz)}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 iI=function(a){a.a.one(a.l,_.md,()=>hI(a))},hI=function(a){const b=a.l.getSurface().getMedia();if(b)if(a.h){a.a.on(b.textTracks,_.Kb,d=>jI(a,d));var c=Array.from(b.textTracks);c.filter(d=>d.kind===_.sd).forEach(d=>{jI(a,{track:d})});!kI(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."),lI(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.")},jI=function(a,b){b=b.track;b.kind===_.sd&&(a.f.info("The metadata track has been added."),b.mode=_.$c,a.a.on(b,_.Jc,c=>mI(a,c)))},kI=function(a){return a.some(b=>b.kind===_.sd)},lI=function(a,b){const c=a.l.getTrackManager(),d=c.ia(),e=c.getAudioTracks().find(g=>g!==d);if(e){var f=()=>c.oa(d);a.a.on(b.textTracks,_.Kb,g=>{g.track.kind===_.sd&&(a.a.off(b.textTracks,_.Kb,f),c.oa(d))});c.oa(e)}else a.f.warn("Can't enforce the creation of the metadata track if single audio track. Skipping.")},
3
- mI=function(a,b){const c=nI(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 oI(d);if(e.f===c&&null!==e.a){a.g=d;d=a.h.parseMedia(_.Cg(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)}}})},nI=function(a){return(a=a.l.getTrackManager().ja())&&a.language&&a.language.toLowerCase()},
4
- oI=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(_.mf(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=_.mf(a)?a:null}}};var pI=class{constructor(a,b,c){this.l=a;this.m=b;this.j=c;this.a=new _.mo;this.h=(a=_.$n[_.Vb]||null)?new a(this.l.getConfiguration()):null;this.f=new _.O("clpp.hlssmpte.ImageCueHandler");this.g=null;iI(this)}destroy(){this.a.release();this.g=null;return Promise.resolve()}};var qI=class extends _.Zp{constructor(){super();this.a=null;this.f=!1}onPlayerCreated(){}onContentWillLoad(a){if(this.f=_.bi()){var b=a.getConfiguration();b=_.hf(b.hlssmpte||{});typeof b.patchMetadataTrack!==_.fc&&(b.patchMetadataTrack=!1);_.nf(b.timestampOffset)||(b.timestampOffset=0);this.a=new pI(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",qI);
5
- qI.Id="hlssmpte";_.Km(new class{create(){return new qI}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var oI=function(a){a.a.one(a.l,_.nd,()=>nI(a))},nI=function(a){const b=a.l.getSurface().getMedia();if(b)if(a.h){a.a.on(b.textTracks,_.Kb,d=>pI(a,d));var c=Array.from(b.textTracks);c.filter(d=>d.kind===_.td).forEach(d=>{pI(a,{track:d})});!qI(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."),rI(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.")},pI=function(a,b){b=b.track;b.kind===_.td&&(a.f.info("The metadata track has been added."),b.mode=_.ad,a.a.on(b,_.Kc,c=>sI(a,c)))},qI=function(a){return a.some(b=>b.kind===_.td)},rI=function(a,b){const c=a.l.getTrackManager(),d=c.ka(),e=c.getAudioTracks().find(g=>g!==d);if(e){var f=()=>c.qa(d);a.a.on(b.textTracks,_.Kb,g=>{g.track.kind===_.td&&(a.a.off(b.textTracks,_.Kb,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
+ sI=function(a,b){const c=tI(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 uI(d);if(e.f===c&&null!==e.a){a.g=d;d=a.h.parseMedia(_.Eg(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)}}})},tI=function(a){return(a=a.l.getTrackManager().la())&&a.language&&a.language.toLowerCase()},
4
+ uI=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(_.of(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=_.of(a)?a:null}}};var vI=class{constructor(a,b,c){this.l=a;this.m=b;this.j=c;this.a=new _.po;this.h=(a=_.co[_.Vb]||null)?new a(this.l.getConfiguration()):null;this.f=new _.O("clpp.hlssmpte.ImageCueHandler");this.g=null;oI(this)}destroy(){this.a.release();this.g=null;return Promise.resolve()}};var wI=class extends _.bq{constructor(){super();this.a=null;this.f=!1}onPlayerCreated(){}onContentWillLoad(a){if(this.f=_.di()){var b=a.getConfiguration();b=_.jf(b.hlssmpte||{});typeof b.patchMetadataTrack!==_.fc&&(b.patchMetadataTrack=!1);_.pf(b.timestampOffset)||(b.timestampOffset=0);this.a=new vI(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",wI);
5
+ wI.Id="hlssmpte";_.Nm(new class{create(){return new wI}});};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 aH="Unsupported unit",bH="clpp-text-plain",cH="clpp-text-ttml",dH="clpp.htmlcue.HtmlTextDisplayer",eH="initial",fH=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},gH=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},iH=function(a){let b=null;for(;b=a.match(/&(amp|lt|gt|lrm|rlm|nbsp);/);)a=a.replace(b[0],c=>hH[c]);return a},kH=
2
- function(a,b){jH(a,b);Array.from(b.getElementsByTagName("*")).forEach(c=>{jH(a,c)})},jH=function(a,b){for(const c in a)null!=a[c]&&(b.style[c]=a[c])},lH=function(a,b){return 0===a?"0":a+b},mH=function(a,b){return 1>Math.abs(a-b)||a<b},nH=function(a,b){return a<b&&1<Math.abs(a-b)},oH=function(a,b){return a>b&&1<Math.abs(a-b)},pH=function(a,b){return 1>Math.abs(a-b)||a>b},rH=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 qH(b.left+d,b.right+e,g,(b.bottom||g+f)+c,f,(b.width||a.offsetWidth)-d-e)},sH=function(a){return new qH(a.f,a.g,a.h,a.a,a.height,a.width)},tH=function(a,b){return b.some(c=>nH(a.f,c.g)&&oH(a.g,c.f)&&nH(a.h,c.a)&&oH(a.a,c.h))},uH=function(a,b){return pH(a.h,
4
- b.h)&&mH(a.a,b.a)&&pH(a.f,b.f)&&mH(a.g,b.g)},vH=function(a,b,c){switch(c){case "+x":return nH(a.f,b.f);case "-x":return oH(a.g,b.g);case "+y":return nH(a.h,b.h);case "-y":return oH(a.a,b.a);default:throw Error("Unknown axis");}},wH=function(a){return a.f.writingMode===_.qo},xH=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 wH(a)?b:c},yH=function(a){switch(a.f.writingMode){case _.qo:return"horizontal-tb";case _.De:return _.De;
5
- case _.Ee:return _.Ee;default:throw Error("Unknown writing mode");}},zH=function(a){switch(a.f.positionAlign){case _.kd:return _.fd;case "auto":case _.rc:return _.po;case _.ld:return _.be}return a.f.textAlign},AH=function(a,b){if(typeof a.f.position===_.p&&typeof a.f.size===_.p)switch(b){case _.kd:return a.f.position;case "auto":case _.rc:return a.f.position-a.f.size/2;case _.ld:return a.f.position-a.f.size}return 0},BH=function(a){if(!a.f.positionAlign)switch(a.f.textAlign){case _.fd:case _.fd:return _.kd;
6
- case _.po:return _.rc;case _.be:case _.be:return _.ld}return a.f.positionAlign},EH=function(a,b,c){return(CH(a)||DH(a))&&_.nf(c)?lH(c,_.Vd):CH(a)&&_.z(c)?lH(0,_.Vd):wH(a)&&_.nf(b)?lH(b,"%"):eH},FH=function(a,b,c){return wH(a)&&_.nf(c)?lH(c,_.Vd):(CH(a)||DH(a))&&_.nf(b)?lH(b,"%"):eH},DH=function(a){return a.f.writingMode===_.Ee},CH=function(a){return a.f.writingMode===_.De},GH=function(a,b){if(a.h)switch(b.writingMode){case _.qo:return["-y"];case _.De:return["+x"];case _.Ee:return["-x"]}a=[];switch(b.writingMode){case _.qo:a=
7
- ["+y","-y"];break;case _.De:a=["+x","-x"];break;case _.Ee:a=["-x","+x"]}0>b.line&&(a=a.reverse());return a},HH=function(a){for(a.g=[];0<a.f.childNodes.length;)a.f.removeChild(a.f.childNodes[0]);a.a=rH(a.j.a)},IH=function(a,b){HH(a.g);a.j.unshift(b);for(const c of a.j)a.g.append(c)},JH=function(a,b,c){a=a.f;const d=a.viewportAnchorUnits;if(d===_.xo)return a.viewportAnchorY/100*c-a.regionAnchorY/100*b;if(0===d)return a.viewportAnchorY-a.regionAnchorY;throw Error(aH);},LH=function(a,b,c,d){const e=document.createElement(_.ne),
8
- f=e.dataset;f.name=b;f.for=c;d&&(f.name=`${b} (sandbox)`,f.sandbox=!0);c=document.head;c.appendChild(e);KH(a,c,b);a.f.debug(`Created HTML style element #${b}.`);return e.sheet},MH=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)},NH=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},OH=function(a){if(null!=a.a){for(;0<a.a.cssRules.length;)a.a.deleteRule(0);a.m=[]}},KH=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())},PH=function(a){a=_.hf(a.getConfiguration().htmlcue||{});_.z(a.stretchSmpteImage)&&(a.stretchSmpteImage=!1);_.z(a.enableResizeObserver)&&(a.enableResizeObserver=!0);return a},VH=function(a,b){if((b||a.j)&&a.C){var c=a.l.getPosition();if(b||a.I!==c&&a.l.getState()===_.Ll)if(a.I=c,c=QH(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,RH(a),c)){b={color:a.getFontColor()||void 0,
11
- backgroundColor:a.getBackgroundColor()||void 0,fontFamily:a.getFontFamily()||void 0,textShadow:_.go(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 _.Me:g="clpp-text-vtt";break;case _.ve:g=cH;break;case _.oo:g=bH}g&&!f.classList.contains(g)&&_.em(f,g);f=rH(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{jH({fontSize:SH(c,d.containerRows)},c.a.a);f=null;g=d.payloadType===_.Me;var h=d.payloadType===_.ve;d.region&&(g||h||d.backgroundImage)&&(c.A.has(d.region.id)?f=c.A.get(d.region.id):(f=new TH(d.region,{}),c.A.set(d.region.id,f),IH(c.a,f)));d=new UH(d,c.K,e);f?IH(f,d):IH(c.a,d)}}}}},WH=function(a){RH(a);a.I=null;a.m=null;a.f=[]},XH=function(a,b){return a.startTime<=b&&a.endTime>b},QH=function(a,b){var c=fH(a.f,d=>XH(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&&XH(a.f[d-1],b);)d--;for(;c+1<a.f.length&&XH(a.f[c+1],b);)c++;return{start:d,end:c}}},RH=function(a){a.A.clear();if(a.a){const b=a.a.a;b.classList.remove("clpp-text-vtt");b.classList.remove(cH);b.classList.remove(bH);a=a.a;HH(a.g);a.j=[]}},SH=function(a,b){const c=rH(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`},aI=class{parse(a){a={input:a};const b=_.gm(_.Mc),c=[];let d=b;for(var e;null!==(e=gH(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=YH[f];h?(h=_.gm(h),(f=ZH[f])&&g&&h.setAttribute(f,g.trim()),g=h):g=null;!g||$H[g.localName]&&$H[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(iH(e)));return b}},YH={c:"c",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"v",lang:"lang"},ZH={v:"voice",lang:"lang"},$H={rt:"ruby"},hH={"\x26amp;":"\x26","\x26lt;":"\x3c","\x26gt;":"\x3e","\x26lrm;":"\u200e","\x26rlm;":"\u200f","\x26nbsp;":"\u00a0"};var qH=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 bI=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 UH=class extends bI{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)_.em(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===_.ve){var c=_.gm(_.Mc);c.innerHTML=b.payload;b=c}else b.payloadType===
16
- _.Me?b=(new aI).parse(b.payload):(c=_.gm(_.Mc),c.textContent=b.payload,b=c);_.em(b,this.o);this.id&&(b.id=this.id);for(d of this.f.cssClassList)_.em(b,d);jH({writingMode:yH(this)},b);var d=b;this.a.appendChild(d);_.em(this.a,"clpp-text-wrapper");for(var e of this.f.cssClassList)_.em(this.a,`clpp-text-wrapper__${e}`);_.z(this.f.line)&&(this.f.lineInterpretation=_.ro,this.f.line=wH(this)?-1:0);e=yH(this);jH({writingMode:e,webkitWritingMode:e,direction:eH,textAlign:zH(this)},this.a);if(!this.f.region||
17
- !this.f.region.displayAlign){e=AH(this,BH(this));jH({position:"absolute",left:EH(this,e,null),right:DH(this)&&_.z(null)?lH(0,_.Vd):eH,top:FH(this,e,null),width:wH(this)?lH(this.f.size,"%"):eH,height:CH(this)||DH(this)?lH(this.f.size,"%"):eH},this.a);b=this.f;a=wH(this)?a.height:a.width;c=xH(this);if(b.lineInterpretation===_.ro){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 _.rc:g-=f/2;break;case _.Uc:g-=f}f=Math.round(g/
18
- 100*a)}DH(this)&&(f=a-f-c);a=f;jH({left:EH(this,e,a),right:DH(this)&&_.z(a)?lH(0,_.Vd):eH,top:FH(this,e,a)},this.a)}kH(this.B,d)}}m(){return _.gm(_.Mc)}};var cI=class{constructor(a,b){this.j=a;this.f=a.a;this.h=void 0===b?!1:b;this.a=rH(a.a);this.g=[]}append(a){const b=a.a;b.style.visibility=_.$c;this.f.appendChild(b);a.h||a.init(this.a);if(a.w()){a:{var c=rH(a.a);var d=GH(this,a.f),e=xH(a);const g=sH(c);let h=null,k=0;for(const l of d){for(;vH(c,this.a,l)||uH(c,this.a)&&tH(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||uH(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=sH(c),k=d);c=sH(g)}c=h||g}jH({top:lH(c.h-this.a.h,_.Vd),bottom:lH(this.a.a-c.a,_.Vd),left:lH(c.f-this.a.f,_.Vd),right:lH(this.a.g-c.g,_.Vd),height:lH(c.height,_.Vd),width:lH(c.width,_.Vd)},a.a)}b.style.visibility="visible";this.g.push(rH(a.a))}};var dI=class extends bI{constructor(a,b,c){super(a,b,c);this.g=null;this.j=[]}init(){this.g=new cI(this);this.h=!0}m(){const a=_.gm(_.Mc);_.em(a,this.o);this.id&&(a.id=this.id);return a}};var TH=class extends dI{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 _.xo:b=b.width/100*a.width;break a;default:throw Error(aH);}}var c=this.f;var d=c.viewportAnchorUnits;if(d===_.xo)c=c.viewportAnchorX/100*a.width-c.regionAnchorX/100*b;else if(0===d)c=c.viewportAnchorX-c.regionAnchorX;else throw Error(aH);d=a.height;const e=JH(this,d,a.height);jH(this.A,this.a);jH({left:lH(c,_.Vd),top:lH(e,_.Vd),width:lH(b,
20
- _.Vd),height:lH(d,_.Vd)},this.a);this.f.writingMode&&jH({display:"flex","flex-direction":this.f.writingMode},this.a);this.f.displayAlign&&jH({"justify-content":this.f.displayAlign},this.a);for(var f of this.f.cssClassList)_.em(this.a,f);a:switch(f=this.f,f.heightUnits){case 0:f=f.height;break a;case _.xo:f=f.height/100*a.height;break a;case 2:f=f.height;c=new UH(new _.uo(0,1,"Lorem ipsum",_.oo),{},{});b=c.a;this.a.appendChild(b);c.init(rH(this.a));c=b.getBoundingClientRect().height;this.a.removeChild(b);
21
- b=c;f*=b;break a;default:throw Error(aH);}a=JH(this,f,a.height);jH({top:lH(a,_.Vd),height:lH(f,_.Vd)},this.a);this.g=new cI(this,!0);this.h=!0}getId(){return this.f.id}};var eI=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=LH(this,this.h,this.j);this.g=LH(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=MH(this,a);if(NH(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=[],OH(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 fI=class extends _.Wp{constructor(a){super(a);this.M=new _.O(dH);this.l=a;this.K=PH(a);this.j=!1;this.f=[];this.C=a.getSurface().getContainer();this.h=new eI(a,"CLPP Subtitle Styles");this.a=new dI(null,"clpp-text-container",{});this.w=new _.Sp(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.D=
23
- new _.Oh(()=>{VH(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;VH(this,!1)}}g(){null==this.h||VH(this,!0)}destroy(){const a=
24
- this;return _.w(function*(){null!=a.h&&(WH(a),a.D.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;VH(this,!0);return!0}isTextVisible(){return this.j}setTextVisibility(a){null!=this.h&&this.j!==a&&((this.j=a)?(this.D.Ua(.25),this.K.enableResizeObserver&&this.w.start(),VH(this,!0)):(this.D.stop(),this.w.stop(),WH(this)))}U(){VH(this,!0)}};_.x(dH,fI);
25
- fI.prototype.setTextVisibility=fI.prototype.setTextVisibility;fI.prototype.isTextVisible=fI.prototype.isTextVisible;fI.prototype.remove=fI.prototype.remove;fI.prototype.destroy=fI.prototype.destroy;fI.prototype.append=fI.prototype.append;var gI=class{ba(a){return!!a.enableHtmlCue&&!_.di()}create(a){return new fI(a)}};_.x("clpp.htmlcue.HtmlCueComponent",class extends _.Bp{f(){_.pl("html",new gI)}a(){}id(){return _.oe}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var gH="Unsupported unit",hH="clpp-text-plain",iH="clpp-text-ttml",jH="clpp.htmlcue.HtmlTextDisplayer",kH="initial",lH=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},mH=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},oH=function(a){let b=null;for(;b=a.match(/&(amp|lt|gt|lrm|rlm|nbsp);/);)a=a.replace(b[0],c=>nH[c]);return a},qH=
2
+ function(a,b){pH(a,b);Array.from(b.getElementsByTagName("*")).forEach(c=>{pH(a,c)})},pH=function(a,b){for(const c in a)null!=a[c]&&(b.style[c]=a[c])},rH=function(a,b){return 0===a?"0":a+b},sH=function(a,b){return 1>Math.abs(a-b)||a<b},tH=function(a,b){return a<b&&1<Math.abs(a-b)},uH=function(a,b){return a>b&&1<Math.abs(a-b)},vH=function(a,b){return 1>Math.abs(a-b)||a>b},xH=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 wH(b.left+d,b.right+e,g,(b.bottom||g+f)+c,f,(b.width||a.offsetWidth)-d-e)},yH=function(a){return new wH(a.f,a.g,a.h,a.a,a.height,a.width)},zH=function(a,b){return b.some(c=>tH(a.f,c.g)&&uH(a.g,c.f)&&tH(a.h,c.a)&&uH(a.a,c.h))},AH=function(a,b){return vH(a.h,
4
+ b.h)&&sH(a.a,b.a)&&vH(a.f,b.f)&&sH(a.g,b.g)},BH=function(a,b,c){switch(c){case "+x":return tH(a.f,b.f);case "-x":return uH(a.g,b.g);case "+y":return tH(a.h,b.h);case "-y":return uH(a.a,b.a);default:throw Error("Unknown axis");}},CH=function(a){return a.f.writingMode===_.to},DH=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 CH(a)?b:c},EH=function(a){switch(a.f.writingMode){case _.to:return"horizontal-tb";case _.Ee:return _.Ee;
5
+ case _.Ge:return _.Ge;default:throw Error("Unknown writing mode");}},FH=function(a){switch(a.f.positionAlign){case _.ld:return _.gd;case "auto":case _.rc:return _.so;case _.md:return _.ce}return a.f.textAlign},GH=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 _.rc:return a.f.position-a.f.size/2;case _.md:return a.f.position-a.f.size}return 0},HH=function(a){if(!a.f.positionAlign)switch(a.f.textAlign){case _.gd:case _.gd:return _.ld;
6
+ case _.so:return _.rc;case _.ce:case _.ce:return _.md}return a.f.positionAlign},KH=function(a,b,c){return(IH(a)||JH(a))&&_.pf(c)?rH(c,_.Wd):IH(a)&&_.z(c)?rH(0,_.Wd):CH(a)&&_.pf(b)?rH(b,"%"):kH},LH=function(a,b,c){return CH(a)&&_.pf(c)?rH(c,_.Wd):(IH(a)||JH(a))&&_.pf(b)?rH(b,"%"):kH},JH=function(a){return a.f.writingMode===_.Ge},IH=function(a){return a.f.writingMode===_.Ee},MH=function(a,b){if(a.h)switch(b.writingMode){case _.to:return["-y"];case _.Ee:return["+x"];case _.Ge:return["-x"]}a=[];switch(b.writingMode){case _.to:a=
7
+ ["+y","-y"];break;case _.Ee:a=["+x","-x"];break;case _.Ge:a=["-x","+x"]}0>b.line&&(a=a.reverse());return a},NH=function(a){for(a.g=[];0<a.f.childNodes.length;)a.f.removeChild(a.f.childNodes[0]);a.a=xH(a.j.a)},OH=function(a,b){NH(a.g);a.j.unshift(b);for(const c of a.j)a.g.append(c)},PH=function(a,b,c){a=a.f;const d=a.viewportAnchorUnits;if(d===_.Ao)return a.viewportAnchorY/100*c-a.regionAnchorY/100*b;if(0===d)return a.viewportAnchorY-a.regionAnchorY;throw Error(gH);},RH=function(a,b,c,d){const e=document.createElement(_.oe),
8
+ f=e.dataset;f.name=b;f.for=c;d&&(f.name=`${b} (sandbox)`,f.sandbox=!0);c=document.head;c.appendChild(e);QH(a,c,b);a.f.debug(`Created HTML style element #${b}.`);return e.sheet},SH=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)},TH=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},UH=function(a){if(null!=a.a){for(;0<a.a.cssRules.length;)a.a.deleteRule(0);a.m=[]}},QH=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())},VH=function(a){a=_.jf(a.getConfiguration().htmlcue||{});_.z(a.stretchSmpteImage)&&(a.stretchSmpteImage=!1);_.z(a.enableResizeObserver)&&(a.enableResizeObserver=!0);return a},aI=function(a,b){if((b||a.j)&&a.C){var c=a.l.getPosition();if(b||a.J!==c&&a.l.getState()===_.Nl)if(a.J=c,c=WH(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,XH(a),c)){b={color:a.getFontColor()||void 0,
11
+ backgroundColor:a.getBackgroundColor()||void 0,fontFamily:a.getFontFamily()||void 0,textShadow:_.jo(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 _.Ne:g="clpp-text-vtt";break;case _.we:g=iH;break;case _.ro:g=hH}g&&!f.classList.contains(g)&&_.hm(f,g);f=xH(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{pH({fontSize:YH(c,d.containerRows)},c.a.a);f=null;g=d.payloadType===_.Ne;var h=d.payloadType===_.we;d.region&&(g||h||d.backgroundImage)&&(c.A.has(d.region.id)?f=c.A.get(d.region.id):(f=new ZH(d.region,{}),c.A.set(d.region.id,f),OH(c.a,f)));d=new $H(d,c.L,e);f?OH(f,d):OH(c.a,d)}}}}},bI=function(a){XH(a);a.J=null;a.m=null;a.f=[]},cI=function(a,b){return a.startTime<=b&&a.endTime>b},WH=function(a,b){var c=lH(a.f,d=>cI(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&&cI(a.f[d-1],b);)d--;for(;c+1<a.f.length&&cI(a.f[c+1],b);)c++;return{start:d,end:c}}},XH=function(a){a.A.clear();if(a.a){const b=a.a.a;b.classList.remove("clpp-text-vtt");b.classList.remove(iH);b.classList.remove(hH);a=a.a;NH(a.g);a.j=[]}},YH=function(a,b){const c=xH(a.a.a).height;if(null!==a.I)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`},gI=class{parse(a){a={input:a};const b=_.jm(_.Nc),c=[];let d=b;for(var e;null!==(e=mH(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=dI[f];h?(h=_.jm(h),(f=eI[f])&&g&&h.setAttribute(f,g.trim()),g=h):g=null;!g||fI[g.localName]&&fI[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(oH(e)));return b}},dI={c:"c",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"v",lang:"lang"},eI={v:"voice",lang:"lang"},fI={rt:"ruby"},nH={"\x26amp;":"\x26","\x26lt;":"\x3c","\x26gt;":"\x3e","\x26lrm;":"\u200e","\x26rlm;":"\u200f","\x26nbsp;":"\u00a0"};var wH=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 hI=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 $H=class extends hI{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)_.hm(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===_.we){var c=_.jm(_.Nc);c.innerHTML=b.payload;b=c}else b.payloadType===
16
+ _.Ne?b=(new gI).parse(b.payload):(c=_.jm(_.Nc),c.textContent=b.payload,b=c);_.hm(b,this.o);this.id&&(b.id=this.id);for(d of this.f.cssClassList)_.hm(b,d);pH({writingMode:EH(this)},b);var d=b;this.a.appendChild(d);_.hm(this.a,"clpp-text-wrapper");for(var e of this.f.cssClassList)_.hm(this.a,`clpp-text-wrapper__${e}`);_.z(this.f.line)&&(this.f.lineInterpretation=_.uo,this.f.line=CH(this)?-1:0);e=EH(this);pH({writingMode:e,webkitWritingMode:e,direction:kH,textAlign:FH(this)},this.a);if(!this.f.region||
17
+ !this.f.region.displayAlign){e=GH(this,HH(this));pH({position:"absolute",left:KH(this,e,null),right:JH(this)&&_.z(null)?rH(0,_.Wd):kH,top:LH(this,e,null),width:CH(this)?rH(this.f.size,"%"):kH,height:IH(this)||JH(this)?rH(this.f.size,"%"):kH},this.a);b=this.f;a=CH(this)?a.height:a.width;c=DH(this);if(b.lineInterpretation===_.uo){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 _.rc:g-=f/2;break;case _.Vc:g-=f}f=Math.round(g/
18
+ 100*a)}JH(this)&&(f=a-f-c);a=f;pH({left:KH(this,e,a),right:JH(this)&&_.z(a)?rH(0,_.Wd):kH,top:LH(this,e,a)},this.a)}qH(this.B,d)}}m(){return _.jm(_.Nc)}};var iI=class{constructor(a,b){this.j=a;this.f=a.a;this.h=void 0===b?!1:b;this.a=xH(a.a);this.g=[]}append(a){const b=a.a;b.style.visibility=_.ad;this.f.appendChild(b);a.h||a.init(this.a);if(a.w()){a:{var c=xH(a.a);var d=MH(this,a.f),e=DH(a);const g=yH(c);let h=null,k=0;for(const l of d){for(;BH(c,this.a,l)||AH(c,this.a)&&zH(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||AH(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=yH(c),k=d);c=yH(g)}c=h||g}pH({top:rH(c.h-this.a.h,_.Wd),bottom:rH(this.a.a-c.a,_.Wd),left:rH(c.f-this.a.f,_.Wd),right:rH(this.a.g-c.g,_.Wd),height:rH(c.height,_.Wd),width:rH(c.width,_.Wd)},a.a)}b.style.visibility="visible";this.g.push(xH(a.a))}};var jI=class extends hI{constructor(a,b,c){super(a,b,c);this.g=null;this.j=[]}init(){this.g=new iI(this);this.h=!0}m(){const a=_.jm(_.Nc);_.hm(a,this.o);this.id&&(a.id=this.id);return a}};var ZH=class extends jI{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 _.Ao:b=b.width/100*a.width;break a;default:throw Error(gH);}}var c=this.f;var d=c.viewportAnchorUnits;if(d===_.Ao)c=c.viewportAnchorX/100*a.width-c.regionAnchorX/100*b;else if(0===d)c=c.viewportAnchorX-c.regionAnchorX;else throw Error(gH);d=a.height;const e=PH(this,d,a.height);pH(this.A,this.a);pH({left:rH(c,_.Wd),top:rH(e,_.Wd),width:rH(b,
20
+ _.Wd),height:rH(d,_.Wd)},this.a);this.f.writingMode&&pH({display:"flex","flex-direction":this.f.writingMode},this.a);this.f.displayAlign&&pH({"justify-content":this.f.displayAlign},this.a);for(var f of this.f.cssClassList)_.hm(this.a,f);a:switch(f=this.f,f.heightUnits){case 0:f=f.height;break a;case _.Ao:f=f.height/100*a.height;break a;case 2:f=f.height;c=new $H(new _.xo(0,1,"Lorem ipsum",_.ro),{},{});b=c.a;this.a.appendChild(b);c.init(xH(this.a));c=b.getBoundingClientRect().height;this.a.removeChild(b);
21
+ b=c;f*=b;break a;default:throw Error(gH);}a=PH(this,f,a.height);pH({top:rH(a,_.Wd),height:rH(f,_.Wd)},this.a);this.g=new iI(this,!0);this.h=!0}getId(){return this.f.id}};var kI=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=RH(this,this.h,this.j);this.g=RH(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=SH(this,a);if(TH(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=[],UH(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 lI=class extends _.Zp{constructor(a){super(a);this.M=new _.O(jH);this.l=a;this.L=VH(a);this.j=!1;this.f=[];this.C=a.getSurface().getContainer();this.h=new kI(a,"CLPP Subtitle Styles");this.a=new jI(null,"clpp-text-container",{});this.w=new _.Vp(a.getSurface(),this.V.bind(this));this.J=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 _.Qh(()=>{aI(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;aI(this,!1)}}g(){null==this.h||aI(this,!0)}destroy(){const a=
24
+ this;return _.w(function*(){null!=a.h&&(bI(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;aI(this,!0);return!0}isTextVisible(){return this.j}setTextVisibility(a){null!=this.h&&this.j!==a&&((this.j=a)?(this.F.Va(.25),this.L.enableResizeObserver&&this.w.start(),aI(this,!0)):(this.F.stop(),this.w.stop(),bI(this)))}V(){aI(this,!0)}};_.x(jH,lI);
25
+ lI.prototype.setTextVisibility=lI.prototype.setTextVisibility;lI.prototype.isTextVisible=lI.prototype.isTextVisible;lI.prototype.remove=lI.prototype.remove;lI.prototype.destroy=lI.prototype.destroy;lI.prototype.append=lI.prototype.append;var mI=class{ba(a){return!!a.enableHtmlCue&&!_.fi()}create(a){return new lI(a)}};_.x("clpp.htmlcue.HtmlCueComponent",class extends _.Ep{f(){_.rl("html",new mI)}a(){}id(){return _.pe}});};f.call(g, window);
package/cl.ima.js CHANGED
@@ -1,16 +1,16 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var LG="clpp.ima.AdsManagerFactory",MG=function(a){a=a.J;const b=new google.ima.AdsRenderingSettings;b.restoreCustomPlaybackStateOnAdBreakComplete=!1;typeof a.bitrate===_.p&&(b.bitrate=a.bitrate);b.enablePreloading=typeof a.enablePreloading===_.fc?a.enablePreloading:!0;typeof a.loadVideoTimeout===_.p&&(b.loadVideoTimeout=a.loadVideoTimeout);Array.isArray(a.mimeTypes)&&(b.mimeTypes=a.mimeTypes);typeof a.playAdsAfterTime===_.p&&(b.playAdsAfterTime=a.playAdsAfterTime);typeof a.useStyledLinearAds===
2
- _.fc&&(b.useStyledLinearAds=a.useStyledLinearAds);b.uiElements=Array.isArray(a.uiElements)?a.uiElements:[];return b},NG=function(a){const b=a.a,c=a.w,d=google.ima.AdEvent.Type;c.on(b,d.LOADED,a.U.bind(a));c.on(b,d.CONTENT_PAUSE_REQUESTED,a.hc.bind(a));c.on(b,d.STARTED,a.W.bind(a));c.on(b,d.LOG,a.za.bind(a));c.on(b,d.AD_PROGRESS,a.Xa.bind(a));c.on(b,d.AD_BUFFERING,a.ha.bind(a));c.on(b,d.FIRST_QUARTILE,a.R.bind(a));c.on(b,d.MIDPOINT,a.Va.bind(a));c.on(b,d.THIRD_QUARTILE,a.Z.bind(a));c.on(b,d.PAUSED,
3
- a.Wa.bind(a));c.on(b,d.RESUMED,a.Ya.bind(a));c.on(b,d.CLICK,a.N.bind(a));c.on(b,d.SKIPPED,a.V.bind(a));c.on(b,d.IMPRESSION,a.S.bind(a));c.on(b,d.COMPLETE,a.sa.bind(a));c.on(b,d.CONTENT_RESUME_REQUESTED,a.kc.bind(a));c.on(b,d.ALL_ADS_COMPLETED,a.Mb.bind(a))},OG=function(a,b){const c=b?a.$.create(b.getErrorCode()):null;a.l.onError(new _.H(1,9,10003,{errorType:c},b))},PG=function(a,b,c){c=c&&c.getAd();let d=null;c&&(d={ad:new V(c,a.B,a.K)});a.l.trigger(new _.C(b,d))},QG=function(a){a.A=null;PG(a,_.Ib);
4
- a.m&&a.l.getSurface().hide(a.m)},RG=function(a){_.fm(a.j,{visibility:"visible"})},TG=function(a){return _.w(function*(){a.I.initialize();const b=!!a.l.getConfiguration().muted;(yield a.F.canPlay(b))?SG(a):(PG(a,_.dc),a.M.warn(_.ia))})},UG=function(a,b){return _.w(function*(){a.I.initialize();yield b.play();SG(a)})},SG=function(a){a.a.init(a.j.offsetWidth,a.j.offsetHeight,google.ima.ViewMode.NORMAL);a.a.start();a.D=!0},VG=function(){return!window.google||!google.ima||!google.ima.AdsLoader},V=class{constructor(a,
5
- b,c){this.a=a;this.f=a.getAdPodInfo();this.h=b;this.g=c}mb(){return"Google IMA SDK"}nb(){return google.ima.VERSION}sb(){return 0}getId(){return this.a.getAdId()}getCreativeId(){return this.a.getCreativeId()}getApiFramework(){return this.a.getApiFramework()}getAdSystem(){return this.a.getAdSystem()}getAdvertiserName(){return this.a.getAdvertiserName()}getTitle(){return this.a.getTitle()}getDuration(){return this.a.getDuration()}getSkipTimeOffset(){return this.a.getSkipTimeOffset()}Wb(){return this.f?
6
- this.f.getIsBumper():!1}Bb(){let a=null;const b=this.a,c=Object.keys(b).find(d=>typeof b[d]===_.Ad&&typeof b[d].clickThroughUrl===_.le);c&&(a=b[c].clickThroughUrl);return a}getMediaUrl(){return this.a.getMediaUrl()}pb(){return this.a.getVastMediaWidth()}ob(){return this.a.getVastMediaHeight()}cb(){return this.a.getVastMediaBitrate()}Oa(){return this.g?2:this.h?1:0}getPodIndex(){return this.f?this.f.getPodIndex():0}Cb(){return this.f?this.f.getTimeOffset():0}Db(){return this.f?this.f.getAdPosition():
7
- 1}rb(){return this.f?this.f.getTotalAds():1}getWrapperAdIds(){return this.a.getWrapperAdIds()}getWrapperAdSystems(){return this.a.getWrapperAdSystems()}getWrapperCreativeIds(){return this.a.getWrapperCreativeIds()}};V.prototype.getWrapperCreativeIds=V.prototype.getWrapperCreativeIds;V.prototype.getWrapperAdSystems=V.prototype.getWrapperAdSystems;V.prototype.getWrapperAdIds=V.prototype.getWrapperAdIds;V.prototype.getSequenceLength=V.prototype.rb;V.prototype.getPositionInSequence=V.prototype.Db;
8
- V.prototype.getPodTimeOffset=V.prototype.Cb;V.prototype.getPodIndex=V.prototype.getPodIndex;V.prototype.getPodType=V.prototype.Oa;V.prototype.getMediaBitrate=V.prototype.cb;V.prototype.getMediaHeight=V.prototype.ob;V.prototype.getMediaWidth=V.prototype.pb;V.prototype.getMediaUrl=V.prototype.getMediaUrl;V.prototype.getClickThroughUrl=V.prototype.Bb;V.prototype.isBumper=V.prototype.Wb;V.prototype.getSkipTimeOffset=V.prototype.getSkipTimeOffset;V.prototype.getDuration=V.prototype.getDuration;
9
- V.prototype.getTitle=V.prototype.getTitle;V.prototype.getAdvertiserName=V.prototype.getAdvertiserName;V.prototype.getAdSystem=V.prototype.getAdSystem;V.prototype.getApiFramework=V.prototype.getApiFramework;V.prototype.getCreativeId=V.prototype.getCreativeId;V.prototype.getId=V.prototype.getId;V.prototype.getTechnology=V.prototype.sb;V.prototype.getAdManagerVersion=V.prototype.nb;V.prototype.getAdManagerName=V.prototype.mb;var WG=class{create(a){const b=google.ima.AdError.ErrorCode;switch(a){case b.VAST_LOAD_TIMEOUT:case b.VAST_MEDIA_LOAD_TIMEOUT:case b.FAILED_TO_REQUEST_ADS:return 0;case b.VIDEO_PLAY_ERROR:return 1;default:return 2}}};var XG=class{constructor(a){this.a=a}getCuePoints(){return this.a}Eb(){return 0<=this.a.indexOf(0)||0===this.a.length}eb(){return 0<=this.a.indexOf(-1)}};XG.prototype.hasPostroll=XG.prototype.eb;XG.prototype.hasPreroll=XG.prototype.Eb;XG.prototype.getCuePoints=XG.prototype.getCuePoints;var YG=class{constructor(a){this.l=a;this.j=a.getSurface().getMedia();a=this.l.getConfiguration();this.J=a=_.hf(a.ima||{});this.m=this.l.Sb("ima").lc();this.I=this.l.Sb("ima").g;this.o=this.l.Sb("ima").a;this.F=new _.Up;this.M=new _.O("clpp.ima");this.h=this.a=null;this.f=new _.Qk;this.D=!1;this.w=new _.mo;this.$=new WG;this.A=null;this.H=this.C=this.K=this.B=!1;this.g=null;{a=this.w;const b=google.ima.AdErrorEvent.Type.AD_ERROR;a.one(this.o,google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,
10
- this.Lb.bind(this));a.on(this.o,b,this.yb.bind(this));a.one(this.j,_.Vc,this.Nb.bind(this))}}Lb(a){this.a=a.getAdsManager(this.j,MG(this));this.a.isCustomPlaybackUsed()?(this.M.warn("IMA plugin does not work correctly right now on platforms with single video element. Disposing."),this.l.onError(new _.H(1,9,10002)),this.dispose()):(this.h=new _.Sp(this.l.getSurface(),(b,c,d)=>{this.a.resize(b,c,d?google.ima.ViewMode.FULLSCREEN:google.ima.ViewMode.NORMAL)}),a=this.a.getCuePoints(),this.g=new XG(a),
11
- this.l.trigger(new _.C(_.Lb,{adsTimeline:this.g})),NG(this));this.f.resolve()}yb(a){OG(this,a.getError());this.f.resolve()}hc(a){const b=this;return _.w(function*(){b.C=!0;yield b.l.pause();_.fm(b.j,{visibility:_.$c});PG(b,_.ub,a);b.h.start()})}U(a){a.getAd().isLinear()?PG(this,_.Bb,a):(this.a.discardAdBreak(),this.B||(this.B=!0,this.l.play()))}W(a){this.A=a.getAd().getDuration();PG(this,_.Hb,a);this.l.getSurface().show(this.m)}za(a){a=a.getAdData();OG(this,a?a.adError:null);QG(this)}Xa(a){PG(this,
12
- _.Eb,a)}ha(a){PG(this,_.wb,a)}R(a){PG(this,_.zb,a)}Va(a){PG(this,_.Cb,a)}Z(a){PG(this,_.Jb,a)}Wa(a){PG(this,_.Db,a)}Ya(a){PG(this,_.Fb,a)}N(a){this.pause();PG(this,_.xb,a)}V(a){PG(this,_.Gb,a);QG(this)}S(a){PG(this,_.Ab,a)}sa(a){PG(this,_.yb,a);QG(this)}kc(){this.B=!0;if(!this.C)return this.l.play();this.C=!1;this.h.stop();this.l.isEnded()||this.l.play();PG(this,_.vb);RG(this)}Mb(){this.H=!0}Nb(){this.K=!0;this.o.contentComplete()}load(){const a=this;return _.w(function*(){var b=a.l;const c=a.J;try{if(typeof c.adTagUrl!==
13
- _.le)throw new _.H(1,9,10001,{missingKeys:"adTagUrl"});}catch(f){return b.onError(f),a.f.resolve(),a.f}if(!c.adTagUrl)return a.f.resolve(),a.f;b=yield a.F.canPlay(!1);const d=yield a.F.canPlay(!0),e=new google.ima.AdsRequest;e.adTagUrl=c.adTagUrl;e.setAdWillAutoPlay(b);e.setAdWillPlayMuted(d);a.o.requestAds(e);return a.f})}start(a){const b=this;return _.w(function*(){b.a&&b.g&&!b.D?b.g.Eb()?yield TG(b):yield UG(b,a):yield a.play()})}resume(){this.a&&this.a.resume()}pause(){this.a&&this.a.pause()}skip(){this.a&&
14
- this.a.skip()}getVolume(){return this.a?this.a.getVolume():1}setVolume(a){this.a&&this.a.setVolume(a)}getPosition(){if(!this.a||null===this.A)return-1;const a=this.a.getRemainingTime();return 0>a?0:this.A-a}dispose(){return(new Promise(a=>{this.D&&this.g&&this.g.eb()&&!this.H?(this.w.one(this.a,google.ima.AdEvent.Type.ALL_ADS_COMPLETED,()=>{a();this.m&&this.l.getSurface().hide(this.m)}),_.Nf(this.w,this.a,[google.ima.AdEvent.Type.LOADED,google.ima.AdEvent.Type.STARTED],()=>{this.a&&this.a.discardAdBreak()})):
15
- a();this.a.discardAdBreak();this.o.contentComplete()})).then(()=>{RG(this);this.w.release();this.h&&(this.h.stop(),this.h=null);this.a&&(this.a.destroy(),this.a=null)})}};YG.prototype.getPosition=YG.prototype.getPosition;YG.prototype.setVolume=YG.prototype.setVolume;YG.prototype.getVolume=YG.prototype.getVolume;YG.prototype.skip=YG.prototype.skip;YG.prototype.pause=YG.prototype.pause;YG.prototype.resume=YG.prototype.resume;var ZG=class extends _.Zp{constructor(){super();this.a=this.g=this.f=null}onPlayerCreated(a){if(VG())return a.onError(new _.H(1,9,1E4));this.f=_.dm(_.Mc,{"class":"clpp-ima clpp-hidden"});a.getSurface().addElementToContainer(this.f);this.g=new google.ima.AdDisplayContainer(this.f,a.getSurface().getMedia());this.a=new google.ima.AdsLoader(this.g);this.a.getSettings().setPlayerType(_.pa);this.a.getSettings().setPlayerVersion(_.da);this.a.getSettings().setAutoPlayAdBreaks(!0)}onPlayerWillDestroy(a){this.a&&
16
- (this.a.destroy(),this.a=null);this.g&&(this.g.destroy(),this.g=null);this.f&&(a.getSurface().removeElementFromContainer(this.f),this.f=null)}mf(){return this.a}kf(){return this.g}lc(){return this.f}id(){return"ima"}};_.x("clpp.ima.ImaPlugin",ZG);ZG.prototype.getAdContainer=ZG.prototype.lc;ZG.prototype.getAdDisplayContainer=ZG.prototype.kf;ZG.prototype.getAdsLoader=ZG.prototype.mf;ZG.Id="ima";ZG.isSdkMissing=VG;_.Km(new class{create(){return new ZG}});var $G=class{constructor(){this.a=new _.O(LG)}name(){return LG}ba(a,b){return a.namespace()===_.wc?!1:VG()?(this.a.warn("IMA SDK is not loaded."),!1):!(!b||!b.ima)}create(a){return new YG(a)}};$G.prototype.create=$G.prototype.create;$G.prototype.isSupported=$G.prototype.ba;$G.prototype.name=$G.prototype.name;_.am(new $G);};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var RG="clpp.ima.AdsManagerFactory",SG=function(a){a=a.K;const b=new google.ima.AdsRenderingSettings;b.restoreCustomPlaybackStateOnAdBreakComplete=!1;typeof a.bitrate===_.p&&(b.bitrate=a.bitrate);b.enablePreloading=typeof a.enablePreloading===_.fc?a.enablePreloading:!0;typeof a.loadVideoTimeout===_.p&&(b.loadVideoTimeout=a.loadVideoTimeout);Array.isArray(a.mimeTypes)&&(b.mimeTypes=a.mimeTypes);typeof a.playAdsAfterTime===_.p&&(b.playAdsAfterTime=a.playAdsAfterTime);typeof a.useStyledLinearAds===
2
+ _.fc&&(b.useStyledLinearAds=a.useStyledLinearAds);b.uiElements=Array.isArray(a.uiElements)?a.uiElements:[];return b},TG=function(a){const b=a.a,c=a.w,d=google.ima.AdEvent.Type;c.on(b,d.LOADED,a.V.bind(a));c.on(b,d.CONTENT_PAUSE_REQUESTED,a.jc.bind(a));c.on(b,d.STARTED,a.X.bind(a));c.on(b,d.LOG,a.Ia.bind(a));c.on(b,d.AD_PROGRESS,a.Ya.bind(a));c.on(b,d.AD_BUFFERING,a.ea.bind(a));c.on(b,d.FIRST_QUARTILE,a.S.bind(a));c.on(b,d.MIDPOINT,a.Wa.bind(a));c.on(b,d.THIRD_QUARTILE,a.$.bind(a));c.on(b,d.PAUSED,
3
+ a.Xa.bind(a));c.on(b,d.RESUMED,a.Za.bind(a));c.on(b,d.CLICK,a.O.bind(a));c.on(b,d.SKIPPED,a.W.bind(a));c.on(b,d.IMPRESSION,a.T.bind(a));c.on(b,d.COMPLETE,a.ja.bind(a));c.on(b,d.CONTENT_RESUME_REQUESTED,a.mc.bind(a));c.on(b,d.ALL_ADS_COMPLETED,a.Pb.bind(a))},UG=function(a,b){const c=b?a.ca.create(b.getErrorCode()):null;a.l.onError(new _.H(1,9,10003,{errorType:c},b))},VG=function(a,b,c){c=c&&c.getAd();let d=null;c&&(d={ad:new V(c,a.B,a.L)});a.l.trigger(new _.C(b,d))},WG=function(a){a.A=null;VG(a,_.Ib);
4
+ a.m&&a.l.getSurface().hide(a.m)},XG=function(a){_.im(a.j,{visibility:"visible"})},ZG=function(a){return _.w(function*(){a.J.initialize();const b=!!a.l.getConfiguration().muted;(yield a.G.canPlay(b))?YG(a):(VG(a,_.dc),a.M.warn(_.ia))})},$G=function(a,b){return _.w(function*(){a.J.initialize();yield b.play();YG(a)})},YG=function(a){a.a.init(a.j.offsetWidth,a.j.offsetHeight,google.ima.ViewMode.NORMAL);a.a.start();a.F=!0},aH=function(){return!window.google||!google.ima||!google.ima.AdsLoader},V=class{constructor(a,
5
+ b,c){this.a=a;this.f=a.getAdPodInfo();this.h=b;this.g=c}nb(){return"Google IMA SDK"}ob(){return google.ima.VERSION}tb(){return 0}getId(){return this.a.getAdId()}getCreativeId(){return this.a.getCreativeId()}getApiFramework(){return this.a.getApiFramework()}getAdSystem(){return this.a.getAdSystem()}getAdvertiserName(){return this.a.getAdvertiserName()}getTitle(){return this.a.getTitle()}getDuration(){return this.a.getDuration()}getSkipTimeOffset(){return this.a.getSkipTimeOffset()}Zb(){return this.f?
6
+ this.f.getIsBumper():!1}Eb(){let a=null;const b=this.a,c=Object.keys(b).find(d=>typeof b[d]===_.Bd&&typeof b[d].clickThroughUrl===_.me);c&&(a=b[c].clickThroughUrl);return a}getMediaUrl(){return this.a.getMediaUrl()}qb(){return this.a.getVastMediaWidth()}pb(){return this.a.getVastMediaHeight()}eb(){return this.a.getVastMediaBitrate()}Pa(){return this.g?2:this.h?1:0}getPodIndex(){return this.f?this.f.getPodIndex():0}Fb(){return this.f?this.f.getTimeOffset():0}Gb(){return this.f?this.f.getAdPosition():
7
+ 1}sb(){return this.f?this.f.getTotalAds():1}getWrapperAdIds(){return this.a.getWrapperAdIds()}getWrapperAdSystems(){return this.a.getWrapperAdSystems()}getWrapperCreativeIds(){return this.a.getWrapperCreativeIds()}};V.prototype.getWrapperCreativeIds=V.prototype.getWrapperCreativeIds;V.prototype.getWrapperAdSystems=V.prototype.getWrapperAdSystems;V.prototype.getWrapperAdIds=V.prototype.getWrapperAdIds;V.prototype.getSequenceLength=V.prototype.sb;V.prototype.getPositionInSequence=V.prototype.Gb;
8
+ V.prototype.getPodTimeOffset=V.prototype.Fb;V.prototype.getPodIndex=V.prototype.getPodIndex;V.prototype.getPodType=V.prototype.Pa;V.prototype.getMediaBitrate=V.prototype.eb;V.prototype.getMediaHeight=V.prototype.pb;V.prototype.getMediaWidth=V.prototype.qb;V.prototype.getMediaUrl=V.prototype.getMediaUrl;V.prototype.getClickThroughUrl=V.prototype.Eb;V.prototype.isBumper=V.prototype.Zb;V.prototype.getSkipTimeOffset=V.prototype.getSkipTimeOffset;V.prototype.getDuration=V.prototype.getDuration;
9
+ V.prototype.getTitle=V.prototype.getTitle;V.prototype.getAdvertiserName=V.prototype.getAdvertiserName;V.prototype.getAdSystem=V.prototype.getAdSystem;V.prototype.getApiFramework=V.prototype.getApiFramework;V.prototype.getCreativeId=V.prototype.getCreativeId;V.prototype.getId=V.prototype.getId;V.prototype.getTechnology=V.prototype.tb;V.prototype.getAdManagerVersion=V.prototype.ob;V.prototype.getAdManagerName=V.prototype.nb;var bH=class{create(a){const b=google.ima.AdError.ErrorCode;switch(a){case b.VAST_LOAD_TIMEOUT:case b.VAST_MEDIA_LOAD_TIMEOUT:case b.FAILED_TO_REQUEST_ADS:return 0;case b.VIDEO_PLAY_ERROR:return 1;default:return 2}}};var cH=class{constructor(a){this.a=a}getCuePoints(){return this.a}Hb(){return 0<=this.a.indexOf(0)||0===this.a.length}fb(){return 0<=this.a.indexOf(-1)}};cH.prototype.hasPostroll=cH.prototype.fb;cH.prototype.hasPreroll=cH.prototype.Hb;cH.prototype.getCuePoints=cH.prototype.getCuePoints;var dH=class{constructor(a){this.l=a;this.j=a.getSurface().getMedia();a=this.l.getConfiguration();this.K=a=_.jf(a.ima||{});this.m=this.l.Vb("ima").nc();this.J=this.l.Vb("ima").g;this.o=this.l.Vb("ima").a;this.G=new _.Xp;this.M=new _.O("clpp.ima");this.h=this.a=null;this.f=new _.Sk;this.F=!1;this.w=new _.po;this.ca=new bH;this.A=null;this.I=this.C=this.L=this.B=!1;this.g=null;{a=this.w;const b=google.ima.AdErrorEvent.Type.AD_ERROR;a.one(this.o,google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,
10
+ this.Ob.bind(this));a.on(this.o,b,this.Bb.bind(this));a.one(this.j,_.Wc,this.Qb.bind(this))}}Ob(a){this.a=a.getAdsManager(this.j,SG(this));this.a.isCustomPlaybackUsed()?(this.M.warn("IMA plugin does not work correctly right now on platforms with single video element. Disposing."),this.l.onError(new _.H(1,9,10002)),this.dispose()):(this.h=new _.Vp(this.l.getSurface(),(b,c,d)=>{this.a.resize(b,c,d?google.ima.ViewMode.FULLSCREEN:google.ima.ViewMode.NORMAL)}),a=this.a.getCuePoints(),this.g=new cH(a),
11
+ this.l.trigger(new _.C(_.Lb,{adsTimeline:this.g})),TG(this));this.f.resolve()}Bb(a){UG(this,a.getError());this.f.resolve()}jc(a){const b=this;return _.w(function*(){b.C=!0;yield b.l.pause();_.im(b.j,{visibility:_.ad});VG(b,_.ub,a);b.h.start()})}V(a){a.getAd().isLinear()?VG(this,_.Bb,a):(this.a.discardAdBreak(),this.B||(this.B=!0,this.l.play()))}X(a){this.A=a.getAd().getDuration();VG(this,_.Hb,a);this.l.getSurface().show(this.m)}Ia(a){a=a.getAdData();UG(this,a?a.adError:null);WG(this)}Ya(a){VG(this,
12
+ _.Eb,a)}ea(a){VG(this,_.wb,a)}S(a){VG(this,_.zb,a)}Wa(a){VG(this,_.Cb,a)}$(a){VG(this,_.Jb,a)}Xa(a){VG(this,_.Db,a)}Za(a){VG(this,_.Fb,a)}O(a){this.pause();VG(this,_.xb,a)}W(a){VG(this,_.Gb,a);WG(this)}T(a){VG(this,_.Ab,a)}ja(a){VG(this,_.yb,a);WG(this)}mc(){this.B=!0;if(!this.C)return this.l.play();this.C=!1;this.h.stop();this.l.isEnded()||this.l.play();VG(this,_.vb);XG(this)}Pb(){this.I=!0}Qb(){this.L=!0;this.o.contentComplete()}load(){const a=this;return _.w(function*(){var b=a.l;const c=a.K;try{if(typeof c.adTagUrl!==
13
+ _.me)throw new _.H(1,9,10001,{missingKeys:"adTagUrl"});}catch(f){return b.onError(f),a.f.resolve(),a.f}if(!c.adTagUrl)return a.f.resolve(),a.f;b=yield a.G.canPlay(!1);const d=yield a.G.canPlay(!0),e=new google.ima.AdsRequest;e.adTagUrl=c.adTagUrl;e.setAdWillAutoPlay(b);e.setAdWillPlayMuted(d);a.o.requestAds(e);return a.f})}start(a){const b=this;return _.w(function*(){b.a&&b.g&&!b.F?b.g.Hb()?yield ZG(b):yield $G(b,a):yield a.play()})}resume(){this.a&&this.a.resume()}pause(){this.a&&this.a.pause()}skip(){this.a&&
14
+ this.a.skip()}getVolume(){return this.a?this.a.getVolume():1}setVolume(a){this.a&&this.a.setVolume(a)}getPosition(){if(!this.a||null===this.A)return-1;const a=this.a.getRemainingTime();return 0>a?0:this.A-a}dispose(){return(new Promise(a=>{this.F&&this.g&&this.g.fb()&&!this.I?(this.w.one(this.a,google.ima.AdEvent.Type.ALL_ADS_COMPLETED,()=>{a();this.m&&this.l.getSurface().hide(this.m)}),_.Pf(this.w,this.a,[google.ima.AdEvent.Type.LOADED,google.ima.AdEvent.Type.STARTED],()=>{this.a&&this.a.discardAdBreak()})):
15
+ a();this.a.discardAdBreak();this.o.contentComplete()})).then(()=>{XG(this);this.w.release();this.h&&(this.h.stop(),this.h=null);this.a&&(this.a.destroy(),this.a=null)})}};dH.prototype.getPosition=dH.prototype.getPosition;dH.prototype.setVolume=dH.prototype.setVolume;dH.prototype.getVolume=dH.prototype.getVolume;dH.prototype.skip=dH.prototype.skip;dH.prototype.pause=dH.prototype.pause;dH.prototype.resume=dH.prototype.resume;var eH=class extends _.bq{constructor(){super();this.a=this.g=this.f=null}onPlayerCreated(a){if(aH())return a.onError(new _.H(1,9,1E4));this.f=_.gm(_.Nc,{"class":"clpp-ima clpp-hidden"});a.getSurface().addElementToContainer(this.f);this.g=new google.ima.AdDisplayContainer(this.f,a.getSurface().getMedia());this.a=new google.ima.AdsLoader(this.g);this.a.getSettings().setPlayerType(_.pa);this.a.getSettings().setPlayerVersion(_.da);this.a.getSettings().setAutoPlayAdBreaks(!0)}onPlayerWillDestroy(a){this.a&&
16
+ (this.a.destroy(),this.a=null);this.g&&(this.g.destroy(),this.g=null);this.f&&(a.getSurface().removeElementFromContainer(this.f),this.f=null)}rf(){return this.a}pf(){return this.g}nc(){return this.f}id(){return"ima"}};_.x("clpp.ima.ImaPlugin",eH);eH.prototype.getAdContainer=eH.prototype.nc;eH.prototype.getAdDisplayContainer=eH.prototype.pf;eH.prototype.getAdsLoader=eH.prototype.rf;eH.Id="ima";eH.isSdkMissing=aH;_.Nm(new class{create(){return new eH}});var fH=class{constructor(){this.a=new _.O(RG)}name(){return RG}ba(a,b){return a.namespace()===_.xc?!1:aH()?(this.a.warn("IMA SDK is not loaded."),!1):!(!b||!b.ima)}create(a){return new dH(a)}};fH.prototype.create=fH.prototype.create;fH.prototype.isSupported=fH.prototype.ba;fH.prototype.name=fH.prototype.name;_.dm(new fH);};f.call(g, window);