@castlabs/prestoplay 6.2.8 → 6.3.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 +34 -1
  2. package/cjs/cl.adobe.js +3 -3
  3. package/cjs/cl.airplay.js +3 -3
  4. package/cjs/cl.broadpeak.js +6 -6
  5. package/cjs/cl.cast.js +110 -106
  6. package/cjs/cl.conviva.js +32 -31
  7. package/cjs/cl.core.js +371 -360
  8. package/cjs/cl.crypto.js +9 -9
  9. package/cjs/cl.dash.js +69 -69
  10. package/cjs/cl.externs.js +68 -17
  11. package/cjs/cl.freewheel.js +24 -24
  12. package/cjs/cl.hls.js +44 -44
  13. package/cjs/cl.hlssmpte.js +6 -6
  14. package/cjs/cl.htmlcue.js +32 -30
  15. package/cjs/cl.ima.js +23 -23
  16. package/cjs/cl.mse.js +250 -255
  17. package/cjs/cl.muxdata.js +12 -11
  18. package/cjs/cl.onboard.js +3 -3
  19. package/cjs/cl.persistent.js +14 -14
  20. package/cjs/cl.playlist.js +6 -5
  21. package/cjs/cl.smooth.js +70 -70
  22. package/cjs/cl.thumbnails.js +22 -22
  23. package/cjs/cl.tizen.js +71 -71
  24. package/cjs/cl.ttml.js +26 -26
  25. package/cjs/cl.verimatrix.js +5 -5
  26. package/cjs/cl.vimond.js +13 -13
  27. package/cjs/cl.vr.js +18 -18
  28. package/cjs/cl.vtt.js +14 -14
  29. package/cjs/cl.youbora.js +19 -18
  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 +85 -81
  34. package/cl.conviva.js +27 -27
  35. package/cl.core.js +346 -337
  36. package/cl.crypto.js +8 -8
  37. package/cl.dash.js +62 -63
  38. package/cl.externs.js +68 -17
  39. package/cl.freewheel.js +19 -19
  40. package/cl.hls.js +37 -37
  41. package/cl.hlssmpte.js +5 -5
  42. package/cl.htmlcue.js +25 -24
  43. package/cl.ima.js +16 -16
  44. package/cl.mse.js +220 -224
  45. package/cl.muxdata.js +8 -9
  46. package/cl.onboard.js +4 -4
  47. package/cl.persistent.js +9 -9
  48. package/cl.playlist.js +5 -4
  49. package/cl.smooth.js +57 -57
  50. package/cl.thumbnails.js +17 -17
  51. package/cl.tizen.js +57 -57
  52. package/cl.ttml.js +21 -21
  53. package/cl.verimatrix.js +4 -4
  54. package/cl.vimond.js +8 -8
  55. package/cl.vr.js +14 -14
  56. package/cl.vtt.js +12 -12
  57. package/cl.youbora.js +15 -15
  58. package/package.json +1 -1
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 eH="clpp-freewheel",fH="clpp.freewheel.AdsManagerFactory",gH="freewheel",hH=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""}},iH=function(a){const b=[];typeof a.networkId!==_.p&&b.push("networkId");typeof a.serverUrl!==_.he&&b.push("serverUrl");typeof a.profileId!==_.he&&b.push("profileId");typeof a.videoAssetId!==_.he&&typeof a.videoAssetId!==_.p&&b.push("videoAssetId");
2
- if(b.length)throw new _.H(1,9,12001,{missingKeys:b.join(", ")});},jH=function(){return _.v(function*(){var a=new _.To;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})},kH=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,_.pe,a.D.bind(a));a.g.on(a.l,_.ee,a.C.bind(a))},nH=function(a){return _.v(function*(){a.A.length?(lH(a),a.f=a.A.shift(),a.f.play()):(mH(a),yield a.l.a.play())})},mH=function(a){const b=a.l.Pb(gH).ic();b&&a.l.getSurface().hide(b);a.l.getSurface().showMediaElement()},lH=function(a){const b=a.l.Pb(gH).ic();b&&(a.l.getSurface().show(b),a.l.getSurface().hideMediaElement(),a.a.registerVideoDisplayBase(eH),
4
- a.l.isMuted()?a.setVolume(0):a.setVolume(a.l.getVolume()||1))},oH=function(a){a.w.length?(lH(a),a.f=a.w.shift(),a.f.play()):mH(a)},pH=function(a,b,c){var d=null;a.a&&c&&(c.adInstance||c.slot)&&(c=(d=c.adInstance||null)?d.getSlot():c.slot,d={ad:new W(a.a,c,d)});a.l.trigger(new _.F(b,d))},qH=class extends _.bp{constructor(){super();this.f=this.a=null}onPlayerCreated(a){if(window.tv&&tv.freewheel&&tv.freewheel.SDK)this.a=_.el(_.Gc,{id:eH}),this.f=_.el(_.u,{"class":_.pc}),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 gH}ic(){return this.a}$e(){return this.f}};_.x("clpp.freewheel.FreeWheelPlugin",qH);qH.prototype.getAdVideo=qH.prototype.$e;qH.prototype.getAdContainer=qH.prototype.ic;qH.Id=gH;qH.AD_CONTAINER_ID=eH;_.Ll(new class{create(){return new qH}});var W=class{constructor(a,b,c){this.g=a;this.f=b;this.a=c}gb(){return"FreeWheel AdManager SDK"}hb(){return tv.freewheel.SDK.version}mb(){return 0}ba(){return this.a?this.a.getAdId():""}getCreativeId(){const a=(this.a||{})._creativeId;return typeof a===_.he?a:""}getApiFramework(){return this.a?this.a.getActiveCreativeRendition().getCreativeApi():""}getAdSystem(){return""}getAdvertiserName(){return""}getTitle(){return""}getDuration(){return this.a?this.a.getActiveCreativeRendition().getDuration():0}getSkipTimeOffset(){return 0}Tb(){return!1}zb(){return this.a&&
6
- 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():""}jb(){return this.a?this.a.getActiveCreativeRendition().getWidth():0}ib(){return this.a?this.a.getActiveCreativeRendition().getHeight():0}Xa(){return 0}Ja(){switch(this.f.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:return 0;case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:return 2;
7
- default:return 1}}getPodIndex(){switch(this.Ja()){case 0:return 0;case 2:return-1}return this.g.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL).indexOf(this.f)+1}Ab(){switch(this.Ja()){case 0:return 0;case 2:return-1;default:return this.f.getTimePosition()}}Bb(){return this.a?this.f.getAdInstances().indexOf(this.a)+1:1}lb(){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.lb;W.prototype.getPositionInSequence=W.prototype.Bb;W.prototype.getPodTimeOffset=W.prototype.Ab;W.prototype.getPodIndex=W.prototype.getPodIndex;W.prototype.getPodType=W.prototype.Ja;W.prototype.getMediaBitrate=W.prototype.Xa;W.prototype.getMediaHeight=W.prototype.ib;
9
- W.prototype.getMediaWidth=W.prototype.jb;W.prototype.getMediaUrl=W.prototype.getMediaUrl;W.prototype.getClickThroughUrl=W.prototype.zb;W.prototype.isBumper=W.prototype.Tb;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.ba;W.prototype.getTechnology=W.prototype.mb;W.prototype.getAdManagerVersion=W.prototype.hb;W.prototype.getAdManagerName=W.prototype.gb;var rH=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()}})}Cb(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL).length}Ya(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL).length}};
11
- rH.prototype.hasPostroll=rH.prototype.Ya;rH.prototype.hasPreroll=rH.prototype.Cb;rH.prototype.getCuePoints=rH.prototype.getCuePoints;var sH=class{constructor(a){this.B=new _.O("clpp.freewheel.AdsManager");this.l=a;this.g=new _.mn;this.o=new tv.freewheel.SDK.AdManager;this.f=this.a=null;this.A=[];this.m=[];this.w=[];this.j=new _.Pj;this.h=null}load(){const a=this;return _.v(function*(){const b=a.l.getConfiguration().freewheel||{};try{iH(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!==_.he&&typeof b.siteSectionId!==
12
- _.p||a.a.setSiteSection(b.siteSectionId);const c=yield jH();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,hH(d.type),d.position,d.slotProfile,d.cuepointSequence,d.maxDuration,d.minDuration,d.acceptContentType);b.keyValues&&typeof b.keyValues===_.td&&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);kH(a);a.a.submitRequest();return a.j})}start(){const a=this;return _.v(function*(){yield nH(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 _.v(function*(){a.g.release();
14
- a.h&&(a.h.stop(),a.h=null);mH(a);a.a&&(a.a.dispose(),a.a=null)})}H(a){if(a.success)this.A=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL),this.m=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL),this.w=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL),this.l.trigger(new _.F(_.Fb,{adsTimeline:new rH(this.a)})),this.h=new _.Ro(this.l.getSurface(),(b,c)=>this.a.resize(b,c),this.l.Pb(gH).f);else this.l.onError(new _.H(1,
15
- 9,10003,{errorType:0},void 0));this.j.resolve()}J(a){pH(this,_.ob,a);this.h.start()}I(a){this.f=null;a=a.slot;pH(this,_.pb);this.h.stop();if(a)switch(a.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:nH(this);break;case tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL:mH(this);this.l.play();break;case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:oH(this)}}F(a){const b=a.subType;this.B.debug("ad event",b);switch(b){case tv.freewheel.SDK.EVENT_AD_IMPRESSION:pH(this,_.Bb,a);pH(this,
16
- _.ub,a);break;case tv.freewheel.SDK.EVENT_AD_IMPRESSION_END:pH(this,_.Cb,a);break;case tv.freewheel.SDK.EVENT_AD_FIRST_QUARTILE:pH(this,_.tb,a);break;case tv.freewheel.SDK.EVENT_AD_MIDPOINT:pH(this,_.wb,a);break;case tv.freewheel.SDK.EVENT_AD_THIRD_QUARTILE:pH(this,_.Db,a);break;case tv.freewheel.SDK.EVENT_AD_COMPLETE:pH(this,_.sb,a);break;case tv.freewheel.SDK.EVENT_AD_CLICK:pH(this,_.rb,a);break;case tv.freewheel.SDK.EVENT_AD_PAUSE:pH(this,_.xb,a);break;case tv.freewheel.SDK.EVENT_AD_RESUME:pH(this,
17
- _.zb,a);break;case tv.freewheel.SDK.EVENT_AD_SKIPPED:pH(this,_.Ab,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_START:pH(this,_.qb,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_END:pH(this,_.yb,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();lH(this);this.f.play()}}}C(a){if((a=a.detail)&&this.a)switch(a.currentState){case _.Lk:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PLAYING);break;case _.Kk:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PAUSED);break;case _.Ak:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_COMPLETED);oH(this);break;case _.Ik:case _.Hk:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_STOPPED)}}};
19
- sH.prototype.getPosition=sH.prototype.getPosition;sH.prototype.setVolume=sH.prototype.setVolume;sH.prototype.getVolume=sH.prototype.getVolume;sH.prototype.skip=sH.prototype.skip;sH.prototype.pause=sH.prototype.pause;sH.prototype.resume=sH.prototype.resume;sH.prototype.start=sH.prototype.start;var tH=class{constructor(){this.a=new _.O(fH)}name(){return fH}Y(a,b){return a.namespace()===_.rc?!1:window.tv&&tv.freewheel&&tv.freewheel.SDK?!(!b||!b.freewheel):(this.a.warn("FreeWheel SDK is not loaded."),!1)}create(a){return new sH(a)}};tH.prototype.create=tH.prototype.create;tH.prototype.isSupported=tH.prototype.Y;tH.prototype.name=tH.prototype.name;_.al(new tH);};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var kH="clpp-freewheel",lH="clpp.freewheel.AdsManagerFactory",mH="freewheel",nH=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""}},oH=function(a){const b=[];typeof a.networkId!==_.p&&b.push("networkId");typeof a.serverUrl!==_.je&&b.push("serverUrl");typeof a.profileId!==_.je&&b.push("profileId");typeof a.videoAssetId!==_.je&&typeof a.videoAssetId!==_.p&&b.push("videoAssetId");
2
+ if(b.length)throw new _.G(1,9,12001,{missingKeys:b.join(", ")});},pH=function(){return _.v(function*(){var a=new _.np;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})},qH=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,_.re,a.D.bind(a));a.g.on(a.l,_.ge,a.C.bind(a))},tH=function(a){return _.v(function*(){a.A.length?(rH(a),a.f=a.A.shift(),a.f.play()):(sH(a),yield a.l.a.play())})},sH=function(a){const b=a.l.Qb(mH).kc();b&&a.l.getSurface().hide(b);a.l.getSurface().showMediaElement()},rH=function(a){const b=a.l.Qb(mH).kc();b&&(a.l.getSurface().show(b),a.l.getSurface().hideMediaElement(),a.a.registerVideoDisplayBase(kH),
4
+ a.l.isMuted()?a.setVolume(0):a.setVolume(a.l.getVolume()||1))},uH=function(a){a.w.length?(rH(a),a.f=a.w.shift(),a.f.play()):sH(a)},vH=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 _.B(b,d))},wH=class extends _.up{constructor(){super();this.f=this.a=null}onPlayerCreated(a){if(window.tv&&tv.freewheel&&tv.freewheel.SDK)this.a=_.wl(_.Jc,{id:kH}),this.f=_.wl(_.u,{"class":_.rc}),this.a.appendChild(this.f),a.getSurface().addElementToContainer(this.a,
5
+ !0),a.getSurface().hide(this.a);else a.onError(new _.G(1,9,12E3))}onPlayerWillDestroy(a){this.a&&(a.getSurface().removeElementFromContainer(this.a),this.f=this.a=null)}id(){return mH}kc(){return this.a}bf(){return this.f}};_.x("clpp.freewheel.FreeWheelPlugin",wH);wH.prototype.getAdVideo=wH.prototype.bf;wH.prototype.getAdContainer=wH.prototype.kc;wH.Id=mH;wH.AD_CONTAINER_ID=kH;_.cm(new class{create(){return new wH}});var W=class{constructor(a,b,c){this.g=a;this.f=b;this.a=c}hb(){return"FreeWheel AdManager SDK"}ib(){return tv.freewheel.SDK.version}nb(){return 0}ba(){return this.a?this.a.getAdId():""}getCreativeId(){const a=(this.a||{})._creativeId;return typeof a===_.je?a:""}getApiFramework(){return this.a?this.a.getActiveCreativeRendition().getCreativeApi():""}getAdSystem(){return""}getAdvertiserName(){return""}getTitle(){return""}getDuration(){return this.a?this.a.getActiveCreativeRendition().getDuration():0}getSkipTimeOffset(){return 0}Ub(){return!1}Ab(){return this.a&&
6
+ 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():""}kb(){return this.a?this.a.getActiveCreativeRendition().getWidth():0}jb(){return this.a?this.a.getActiveCreativeRendition().getHeight():0}Ya(){return 0}Ka(){switch(this.f.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:return 0;case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:return 2;
7
+ default:return 1}}getPodIndex(){switch(this.Ka()){case 0:return 0;case 2:return-1}return this.g.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL).indexOf(this.f)+1}Bb(){switch(this.Ka()){case 0:return 0;case 2:return-1;default:return this.f.getTimePosition()}}Cb(){return this.a?this.f.getAdInstances().indexOf(this.a)+1:1}mb(){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.mb;W.prototype.getPositionInSequence=W.prototype.Cb;W.prototype.getPodTimeOffset=W.prototype.Bb;W.prototype.getPodIndex=W.prototype.getPodIndex;W.prototype.getPodType=W.prototype.Ka;W.prototype.getMediaBitrate=W.prototype.Ya;W.prototype.getMediaHeight=W.prototype.jb;
9
+ W.prototype.getMediaWidth=W.prototype.kb;W.prototype.getMediaUrl=W.prototype.getMediaUrl;W.prototype.getClickThroughUrl=W.prototype.Ab;W.prototype.isBumper=W.prototype.Ub;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.ba;W.prototype.getTechnology=W.prototype.nb;W.prototype.getAdManagerVersion=W.prototype.ib;W.prototype.getAdManagerName=W.prototype.hb;var xH=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()}})}Db(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL).length}Za(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL).length}};
11
+ xH.prototype.hasPostroll=xH.prototype.Za;xH.prototype.hasPreroll=xH.prototype.Db;xH.prototype.getCuePoints=xH.prototype.getCuePoints;var yH=class{constructor(a){this.B=new _.O("clpp.freewheel.AdsManager");this.l=a;this.g=new _.Fn;this.o=new tv.freewheel.SDK.AdManager;this.f=this.a=null;this.A=[];this.m=[];this.w=[];this.j=new _.fk;this.h=null}load(){const a=this;return _.v(function*(){const b=a.l.getConfiguration().freewheel||{};try{oH(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!==_.je&&typeof b.siteSectionId!==
12
+ _.p||a.a.setSiteSection(b.siteSectionId);const c=yield pH();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,nH(d.type),d.position,d.slotProfile,d.cuepointSequence,d.maxDuration,d.minDuration,d.acceptContentType);b.keyValues&&typeof b.keyValues===_.wd&&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);qH(a);a.a.submitRequest();return a.j})}start(){const a=this;return _.v(function*(){yield tH(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 _.v(function*(){a.g.release();
14
+ a.h&&(a.h.stop(),a.h=null);sH(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 _.B(_.Hb,{adsTimeline:new xH(this.a)})),this.h=new _.lp(this.l.getSurface(),(b,c)=>this.a.resize(b,c),this.l.Qb(mH).f);else this.l.onError(new _.G(1,
15
+ 9,10003,{errorType:0},void 0));this.j.resolve()}J(a){vH(this,_.qb,a);this.h.start()}I(a){this.f=null;a=a.slot;vH(this,_.rb);this.h.stop();if(a)switch(a.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:tH(this);break;case tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL:sH(this);this.l.play();break;case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:uH(this)}}F(a){const b=a.subType;this.B.debug("ad event",b);switch(b){case tv.freewheel.SDK.EVENT_AD_IMPRESSION:vH(this,_.Db,a);vH(this,
16
+ _.wb,a);break;case tv.freewheel.SDK.EVENT_AD_IMPRESSION_END:vH(this,_.Eb,a);break;case tv.freewheel.SDK.EVENT_AD_FIRST_QUARTILE:vH(this,_.vb,a);break;case tv.freewheel.SDK.EVENT_AD_MIDPOINT:vH(this,_.yb,a);break;case tv.freewheel.SDK.EVENT_AD_THIRD_QUARTILE:vH(this,_.Fb,a);break;case tv.freewheel.SDK.EVENT_AD_COMPLETE:vH(this,_.ub,a);break;case tv.freewheel.SDK.EVENT_AD_CLICK:vH(this,_.tb,a);break;case tv.freewheel.SDK.EVENT_AD_PAUSE:vH(this,_.zb,a);break;case tv.freewheel.SDK.EVENT_AD_RESUME:vH(this,
17
+ _.Bb,a);break;case tv.freewheel.SDK.EVENT_AD_SKIPPED:vH(this,_.Cb,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_START:vH(this,_.sb,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_END:vH(this,_.Ab,a);break;case tv.freewheel.SDK.EVENT_ERROR:this.l.onError(new _.G(1,9,10003,{errorType:1},{fwCode:a[tv.freewheel.SDK.INFO_KEY_ERROR_CODE],fwInfo:a[tv.freewheel.SDK.INFO_KEY_ERROR_INFO],fwModule:a[tv.freewheel.SDK.INFO_KEY_ERROR_MODULE]}))}}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();rH(this);this.f.play()}}}C(a){if((a=a.detail)&&this.a)switch(a.currentState){case _.dl:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PLAYING);break;case _.bl:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PAUSED);break;case _.Sk:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_COMPLETED);uH(this);break;case _.$k:case _.Zk:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_STOPPED)}}};
19
+ yH.prototype.getPosition=yH.prototype.getPosition;yH.prototype.setVolume=yH.prototype.setVolume;yH.prototype.getVolume=yH.prototype.getVolume;yH.prototype.skip=yH.prototype.skip;yH.prototype.pause=yH.prototype.pause;yH.prototype.resume=yH.prototype.resume;yH.prototype.start=yH.prototype.start;var zH=class{constructor(){this.a=new _.O(lH)}name(){return lH}Y(a,b){return a.namespace()===_.tc?!1:window.tv&&tv.freewheel&&tv.freewheel.SDK?!(!b||!b.freewheel):(this.a.warn("FreeWheel SDK is not loaded."),!1)}create(a){return new yH(a)}};zH.prototype.create=zH.prototype.create;zH.prototype.isSupported=zH.prototype.Y;zH.prototype.name=zH.prototype.name;_.tl(new zH);};f.call(g, window);
package/cl.hls.js CHANGED
@@ -1,37 +1,37 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var wy="BANDWIDTH",xy="CLOSED-CAPTIONS",yy="EXT-X-BYTERANGE",zy="EXT-X-DISCONTINUITY",Ay="EXT-X-DISCONTINUITY-SEQUENCE",By="EXT-X-ENDLIST",Cy="EXT-X-MEDIA-SEQUENCE",Dy="EXT-X-PLAYLIST-TYPE",Ey="EXT-X-STREAM-INF",Fy="EXT-X-TARGETDURATION",Gy="GROUP-ID",Hy="Guessing audio-only",Iy="SAMPLE-AES-CTR",Jy="SUBTITLES",Ky="URI",Ly="application/vnd.apple.mpegurl",My=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+
2
- 8]&&128>a[b+9]?!0:!1},Ny=function(a,b,c){return(a=a.getAttribute(b))?a.value:c||null},Oy=function(a,b){a=a.getAttribute(b);if(!a)throw new _.H(_.G,4,4023,b);return a.value},Py=function(a,b){return a.filter(c=>c.name==b)},Qy=function(a,b){return a.filter(c=>Oy(c,"TYPE")===b)},Ry=function(a,b){a=Py(a,b);return a.length?a[0]:null},Sy=function(a,b){return _.lt([a],[b])[0]},Vy=function(a,b){var c;a=a.a++;var d=b.match(/^#(EXT[^:]*)(?::(.*))?$/);if(!d)throw new _.H(_.G,4,4016,{invalidTag:b});b=d[1];var e=
3
- d[2];d=[];if(e){e=new _.Po(e);var f;(f=_.wm(e,/^([^,=]+)(?:,|$)/g))&&(c=f[1]);const g=/([^=]+)=(?:"([^"]*)"|([^",]*))(?:,|$)/g;for(;f=_.wm(e,g);)d.push(new Ty(f[1],f[2]||f[3]))}return c=new Uy(a,b,d,c)},Yy=function(a,b,c,d){const e=[];let f=[];c.forEach(g=>{/^(#EXT)/.test(g)?(g=Vy(a,g),Wy.includes(g.name)?d.push(g):f.push(g)):/^#(?!EXT)/m.test(g)||(g=Sy(b,g.trim()),e.push(new Xy(g,f)),f=[])});return e},az=function(a,b,c){b=_.jg(b);b=b.replace(/\r\n|\r(?=[^\n]|$)/gm,"\n").trim();const d=b.split(/\n+/m);
4
- if(!/^#EXTM3U($|[ \t\n])/m.test(d[0]))throw new _.H(_.G,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=Vy(a,f);--a.a;if(Wy.includes(g.name)){b=1;break}else g.name==Ey&&(e=!0)}f=[];e=!0;for(var h of _.Zs(d)){let {ld:k,item:l,next:m}=h;l=l.trim();if(!l.length||/^#(?!EXT)/m.test(l)||e)e=!1;else{g=Vy(a,l);if(Zy.includes(g.name)){if(1!=b)throw new _.H(_.G,4,4017);h=d.splice(k,d.length-k);a=Yy(a,c,h,f);return new $y(c,b,f,a)}f.push(g);g.name==Ey&&(g.a.push(new Ty(Ky,
5
- m)),e=!0)}}return new $y(c,b,f)},bz=function(a){var b=Oy(a,"METHOD");const c=["SAMPLE-AES",Iy];if(!c.includes(b))return _.Bf("PlayReady in HLS is only supported with [",c.join(", "),"], not",b),null;a=Oy(a,Ky);b=_.Ym(a);a=null;b=_.L(b.data);try{a=_.xt(_.Gt(b))}catch(d){a=b}return _.mt(_.zc,[{initDataType:_.lc,initData:a}],"")},cz=function(a){_.v(function*(){a.a.debug(_.Is);if(a.j)try{yield a.update(),a.A.$(a.T)}catch(b){a.j&&(a.j.onError(b),1===b.severity&&a.A.$(.1))}})},ez=function(a,b){b=_.zg([b],
6
- a.h.attemptParameters);b.type=1;return dz(a,b)},kz=function(a,b){return _.v(function*(){var c=az(a.K,b,a.B);if(1===c.type){a.D.set(a.B,c);c=(new _.gh(c.a[0].a)).ma.split(".").pop();var d=fz.audio[c],e="";fz.video[c]?e="avc1.42E01E":d&&(e="mp4a.40.2");{c=a.K;d=a.B;e=a.h.hlsDefaultCodecs||e;var f=[];const h=[];h.push(new Ty(wy,"0"));h.push(new Ty(Ky,d));e.length&&h.push(new Ty(_.ja,e));f.push(new Uy(c.a++,Ey,h));c=new $y(d,0,f)}}c=yield gz(a,c.Ga);if(!a.j)throw new _.H(_.G,7,7001);a.j.filterAllPeriods([c]);
7
- e=Infinity;d=0;f=Infinity;for(var g of a.f.values())e=Math.min(e,g.ud),d=Math.max(d,g.ud),g.stream.type!=_.r&&(f=Math.min(f,g.duration));a.m!=hz?(a.g=new _.ky(0,3*a.N,!0),a.g.f=!1):(a.g=new _.ky(null,0,!0),a.g.f=!0);iz(a);if(a.m!=hz){a.T=a.R;a.m===jz&&(g=Math.max(f,a.g.Ed),isNaN(a.h.availabilityWindowOverride)||(g=a.h.availabilityWindowOverride),a.g.Xb=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");
8
- for(const h of a.f.values())95443.7176888889>h.ud?(a.a.debug("Offset applied to",h.stream.type),h.ab.offset(g)):a.a.debug("Offset NOT applied to",h.stream.type)}}else{a.g.Hb(f);a.g.offset(-e);for(const h of a.f.values())h.ab.offset(-e),_.Wt(h.ab,f)}a.H={presentationTimeline:a.g,periods:[c],offlineSessionIds:[],minBufferTime:0}})},nz=function(a,b){return _.v(function*(){var c=yield ez(a,b.Le);c=az(a.K,c.data,c.uri);if(1!=c.type)throw new _.H(_.G,4,4017);var d=b.stream;d=yield lz(a,b.Tc,c,d.type,d.mimeType,
9
- d.codecs,d.keyInfo||null,b.Re);b.ab.replace(d);d=d[d.length-1];Ry(c.Ga,By)&&(mz(a,hz),a.g.Hb(d.endTime))})},lz=function(a,b,c,d,e,f,g,h){return _.v(function*(){var k=c.a;const l=oz(c,g);var m=(m=Ry(c.Ga,Cy))?Number(m.value):0;null===a.L&&(a.L=yield pz(a,b,l,k[0],m,g,e,f,d));const n=a.L;a.a.debug("First segment",k[0].a.split("/").pop(),"starts at",n);var q=Ry(c.Ga,Ay);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.I.get(t)||0;const w=[];for(const A of _.Zs(k)){var B=
10
- A.ld;k=A.item;{const E=w[w.length-1],C=0==B?n:E.endTime;B=m+B;Ry(k.Ga,zy)&&(t++,h.set(t,B),q=yield qz(a,t,b,l,k,B,g,e,f,C,d));k=rz(E,k,B,C,q,g,d);w.push(k)}}a.S.push(w);iz(a);return w})},mz=function(a,b){a.m=b;a.g&&(a.g.f=a.m==hz);a.m!=hz||a.A.stop()},gz=function(a,b){return _.v(function*(){var c=Py(b,"EXT-X-MEDIA"),d=Py(b,Ey),e=Py(b,"EXT-X-IMAGE-STREAM-INF");for(var f of d){var g=Ny(f,"AUDIO"),h=Ny(f,"VIDEO"),k=Ny(f,Jy);const l=sz(a,f);if(k){const m=tz(_.r,l);a.o.set(k,m);k=l.indexOf(m);-1<k&&l.splice(k,
11
- 1)}g&&(k=uz(_.Tb,l),a.o.set(g,k));h&&(g=uz(_.u,l),a.o.set(h,g))}yield vz(a,c);f=Qy(c,xy);for(const l of f)f=wz(l),h=Oy(l,Gy),g=Oy(l,"INSTREAM-ID"),a.J.get(h)||a.J.set(h,new Map),a.J.get(h).set(g,f);d=yield xz(a,d);c=yield yz(a,c);e=yield zz(a,e);return{startTime:0,variants:d,textStreams:c,thumbStreams:e}})},vz=function(a,b){return _.v(function*(){b=b.filter(d=>{const e=Ny(d,Ky)||"";return Ny(d,"TYPE")!==Jy&&""!==e});b.length&&(yield Az(a,b[0]));const c=b.slice(1).map(d=>Az(a,d));yield Promise.all(c)})},
12
- xz=function(a,b){return _.v(function*(){var c=f=>_.v(function*(){const g=Ny(f,"FRAME-RATE"),h=Number(Oy(f,wy));var k=Ny(f,"RESOLUTION");const [l,m]=k?k.split("x"):[null,null];return(k=yield Bz(a,f,k,g))?Cz(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(Oy(b[f],wy));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(_.jt,[]).filter(_.nk)})},yz=function(a,b){return _.v(function*(){var c=
13
- Qy(b,Jy),d=c.map(f=>_.v(function*(){try{return(yield Az(a,f)).stream}catch(g){throw g;}}));d=yield Promise.all(d);for(const f of c){var e=Oy(f,Gy);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)})},zz=function(a,b){return _.v(function*(){const c=b.map(d=>_.v(function*(){return(yield Dz(a,d)).stream}));return(yield Promise.all(c)).filter(d=>d)})},sz=function(a,b){var c=Ny(b,_.ja,a.h.hlsDefaultCodecs||"avc1.42E01E,mp4a.40.2").split(/\s*,\s*/);b=new Set;const d=
14
- [];for(const e of c)c=_.et(e)[0],b.has(c)?a.a.debug("Ignoring duplicate codec"):(d.push(e),b.add(c));return d},tz=function(a,b){const c=Ez[a];for(let d=0;d<c.length;d++)for(let e=0;e<b.length;e++)if(c[d].test(b[e].trim()))return b[e].trim();return a==_.r?"":null},uz=function(a,b){if(1==b.length)return b[0];a=tz(a,b);if(null!=a)return a;throw new _.H(_.G,4,4025,{codecList:b});},Az=function(a,b){return _.v(function*(){const c=Oy(b,Gy);var d="";let e=Oy(b,"TYPE").toLowerCase();e==_.Ts&&(e=_.r);e!==_.r&&
15
- c&&a.o.has(c)&&(d=a.o.get(c));const f=Oy(b,Ky);if(a.f.has(f))return a.f.get(f);const g=wz(b),h=Ny(b,"NAME"),k=b.getAttribute("DEFAULT"),l=b.getAttribute("AUTOSELECT"),m=Ny(b,"CHANNELS");d=yield Fz(a,f,d,e,g,!!k&&!!l,h,e==_.Tb?m?parseInt(m.split("/")[0],10):null:null,null);if(null==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})},Dz=function(a,b){return _.v(function*(){const c=Oy(b,Ky);if(a.f.has(c))return a.f.get(c);var d=Ny(b,_.ja)||
16
- "jpg",e=wz(b);const f=Ny(b,"NAME");d=yield Fz(a,c,d,_.Xc,e,!1,f,null,null);if(null===d)return null;if(a.f.has(c))return a.f.get(c);if(e=Ny(b,wy))d.stream.bandwidth=Number(e);a.f.set(c,d);return d})},Bz=function(a,b,c,d){return _.v(function*(){let e=sz(a,b);var f=Ny(b,"AUDIO"),g=Ny(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=Oy(b,Ky),l=f.audio.find(q=>q.Tc===k);var m=tz(_.u,e);m=c||d||m;1!==e.length||
17
- m?!h.length&&1<e.length?(a.a.debug("Guessing multiplexed audio+video"),h=_.u,e=[e.join(",")]):f.audio.length&&l?(a.a.debug(Hy),h=_.Tb,g=!0):f.video.length?(a.a.debug(Hy),h=_.Tb):(a.a.debug("Guessing video-only"),h=_.u):(h=_.Tb,a.a.debug(Hy));let n;g||(n=yield Gz(a,b,e,h));if(n)f[n.stream.type]=[n];else if(null===n)return a.a.debug("streamInfo is null"),null;Hz(f);return f})},Cz=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)||
18
- 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.Tc:"")+" - "+(l?l.Tc:"");let w;if(k&&n)if(q.length&&t.length?0<_.it(q,t).length:1)w=_.it(q,t);else{a.a.warn("Incompatible DRM info in HLS variant. Skipping.");continue}else k?w=q:n&&(w=t);a.V.has(b)?a.a.debug("Skipping variant which only differs in text streams."):(k=Iz(a,k,n,d,w),h.push(k),a.V.add(b))}return h},
19
- Gz=function(a,b,c,d){return _.v(function*(){const e=Oy(b,Ky);if(a.f.has(e))return a.f.get(e);var f=Ny(b,xy),g=null;d==_.u&&f&&"NONE"!=f&&(g=a.J.get(f));f=uz(d,c);g=yield Fz(a,e,f,d,_.se,!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})},Hz=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(",")},Iz=function(a,b,c,d,e){return{id:a.W++,language:b?b.language:_.se,primary:!!b&&
20
- b.primary||!!c&&c.primary,audio:b,video:c,bandwidth:d,drmInfos:e,allowedByApplication:!0,allowedByKeySystem:!0}},wz=function(a){a=Ny(a,"LANGUAGE")||_.se;return _.Jg(a)},Fz=function(a,b,c,d,e,f,g,h,k){return _.v(function*(){let l=Sy(a.B,b);var m=null;if(a.m==hz&&a.D.has(l)){var n=a.D.get(l);a.D.delete(l)}else{var q=yield ez(a,l);l=q.uri;n=az(a.K,q.data,l)}if(1!=n.type)throw new _.H(_.G,4,4017);Jz(a,n);q=yield Kz(a,d,c,n);const t=[];n.a.forEach(Bd=>{Bd=Py(Bd.Ga,"EXT-X-KEY");t.push.apply(t,Bd)});let w=
21
- !1;const B=[];let A=null;for(var E of t){var C=Oy(E,"METHOD"),oa=Ny(E,"KEYFORMAT","identity");"NONE"!=C&&("AES-128"==C?(m=Ny(E,"IV",""),m={method:"AES-128",url:Sy(a.B,Oy(E,Ky)),iv:m?_.oi((m||"0x").slice(2)):null},a.F=!0):(w=!0,(C=(C=Lz[oa])?C(E,q):null)?(C.keyIds.length&&(A=C.keyIds[0]),B.push(C)):a.a.warn("Unsupported HLS KEYFORMAT",oa)))}if(w&&!B.length&&!a.F)throw new _.H(_.G,4,4026);E=new Map;var $a=yield lz(a,b,n,d,q,c,m,E);oa=$a[0].startTime;C=$a[$a.length-1].endTime;const rf=C-oa;$a=new _.ly($a);
22
- n=oz(n,m);let we=void 0;d==_.r&&(we=_.Ss);return{stream:{id:a.W++,originalId:g,createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:$a.h.bind($a),getSegmentReference:$a.get.bind($a),adjustSegmentDurations:$a.f.bind($a),getDuration:$a.getDuration.bind($a),initSegmentReference:n,mimeType:q,codecs:c,kind:we,encrypted:w,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,
23
- closedCaptions:k,keyInfo:m},ab:$a,drmInfos:B,Tc:b,Le:l,ud:oa,Yf:C,duration:rf,Re:E}})},Jz=function(a,b){var c=Ry(b.Ga,Dy),d=Ry(b.Ga,By);d=c&&"VOD"==c.value||d;c=c&&"EVENT"==c.value&&!d;c=!d&&!c;d?mz(a,hz):(c?mz(a,jz):mz(a,Mz),b=Nz(b.Ga,Fy),b=Number(b.value),a.N=Math.max(b,a.N),a.R=Math.min(b,a.R))},Kz=function(a,b,c,d){return _.v(function*(){var e=d.a[0].a;const f=(new _.gh(e)).ma.split(".").pop(),g=fz[b][f];if(g)return g;if(b==_.r)return c&&"vtt"!=c?_.Mb:_.ne;e=_.zg([e],a.h.attemptParameters);e.method=
24
- "HEAD";e.type=2;e=(yield dz(a,e)).headers["content-type"];if(!e)throw new _.H(_.G,4,4021,f);return e.split(";")[0]})},oz=function(a,b){var c=Py(a.Ga,"EXT-X-MAP");if(!c.length)return null;if(1<c.length)throw new _.H(_.G,4,4020);c=c[0];var d=Oy(c,Ky);const e=Sy(a.f,d);a=0;d=null;if(c=Ny(c,"BYTERANGE"))a=c.split("@"),c=Number(a[0]),a=Number(a[1]),d=a+c-1;return new _.jy(()=>[e],a,d,b)},Nz=function(a,b){a=Ry(a,b);if(!a)throw new _.H(_.G,4,4024,{missingTag:b});return a},iz=function(a){a.g&&(a.S.forEach(b=>
25
- {_.Mt(a.g,b,0)}),a.S=[])},rz=function(a,b,c,d,e,f,g){var h=b.Ga;const k=b.a;b=Nz(h,"EXTINF").value.split(",");b=d+Number(b[0]);var l=0,m=null,n=Ry(h,yy);n&&(l=n.value.split("@"),m=Number(l[0]),l=l[1]?Number(l[1]):a.wa+1,m=l+m-1);(a=f?Object.assign({},f):null)&&!a.iv&&(a.iv=_.ri(new Uint8Array(12),new Uint8Array([c>>24&255,c>>16&255,c>>8&255,c&255])));let q=n=null;f=null;g===_.Xc&&(h=Ry(h,"EXT-X-TILES"),g="1x1",h&&(g=Ny(h,"LAYOUT")||"1x1",f=(h=Ny(h,"DURATION"))?Number(h):null),[n,q]=g.split("x").map(t=>
26
- parseInt(t,10)));return new _.Tt(c,d,b,()=>[k],l,m,e,a,!1,null,n,q,f)},pz=function(a,b,c,d,e,f,g,h,k,l){return _.v(function*(){var m=rz(null,d,e,0,0,f,k);if(a.H&&!l){var n=a.f.get(b).ab.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==_.Ub)return m=yield Oz(a,m),n=_.L(m.data),My(n)?Pz(n):Qz(m.data);
27
- if(g==_.Ee||g==_.Xb)return m=[Oz(a,m)],c&&m.push(Oz(a,c)),m=yield Promise.all(m),Rz(a,m[0].data,(m[1]||m[0]).data);if(g==_.De)return m=yield Oz(a,m),Qz(m.data);if(g===_.Wb||g===_.Vb||!MediaSource.isTypeSupported(`${g.split("/")[0]||""}/mp4;codecs="${h}"`))return 0;throw new _.H(_.G,4,4030);})},qz=function(a,b,c,d,e,f,g,h,k,l,m){return _.v(function*(){let n;a.I.has(b)?n=a.I.get(b):(n=(yield pz(a,c,d,e,f,g,h,k,m,!0))-l,a.a.debug("Discontinuity segment offset",n),a.I.set(b,n));return n})},dz=function(a,
28
- b){if(!a.C)throw new _.H(_.G,7,7001);b=a.j.networkingEngine.fetch(b);_.fh(a.C,b);return b.O},Oz=function(a,b){return _.v(function*(){const c=b.a(),d=_.Kt(b.Ka(),b.Fa,b.Fa+2048-1,a.h.attemptParameters);d.type=2;const e=_.Kt(b.Ka(),b.Fa,b.wa,a.h.attemptParameters);e.type=2;c&&(e.keyInfo=c);try{return yield dz(a,a.F?e:d)}catch(f){if(7001==f.code||a.F)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.",
29
- d.uris[0]);return yield dz(a,e)}})},Pz=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(_.G,4,4030);}My(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"===
30
- 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}}My(a,e)||d();e+=10;e+=f}while(e<a.byteLength);return d()},Qz=function(a){function b(){d.seek(e+188);f=_.Gi(d);71!=f&&(d.seek(e+192),f=_.Gi(d));71!=f&&(d.seek(e+204),f=_.Gi(d));71!=f&&c();_.Vs(d)}function c(){throw new _.H(_.G,4,4030);}const d=new _.Xn(new DataView(a),!1);let e=0,f=0;for(;;){e=d.getPosition();f=_.Gi(d);71!=f&&c();a=_.Hi(d);if(8191===(a&8191)){b();continue}if(!(a&
31
- 16384)){b();continue}a=(_.Gi(d)&48)>>4;0!=a&&2!=a||c();3==a&&(a=_.Gi(d),d.skip(a));if(1!=_.N(d)>>8){b();continue}d.skip(3);a=_.Gi(d)>>6;0!=a&&1!=a||c();0==_.Gi(d)&&c();a=_.Gi(d);const g=_.Hi(d),h=_.Hi(d);return(1073741824*((a&14)>>1)+((g&65534)<<14|(h&65534)>>1))/9E4}},Rz=function(a,b,c){let d=0;(new _.Xi).M(_.nd,_.Ni).M(_.qe,_.Ni).M(_.id,_.Ni).X("mdhd",g=>{g.G.skip(0==g.version?8:16);d=_.N(g.G);g.La.stop()}).parse(c,!0);if(!d)throw a.a.error("Unable to find timescale in init segment!"),new _.H(_.G,
32
- 4,4030);let e=0,f=!1;(new _.Xi).M("moof",_.Ni).M("traf",_.Ni).X("tfdt",g=>{e=(0==g.version?_.N(g.G):_.Ji(g.G))/d;f=!0;g.La.stop()}).parse(b,!0);if(!f)throw new _.H(_.G,4,4030);return e},$y=class{constructor(a,b,c,d){this.f=a;this.type=b;this.Ga=c;this.a=d||null}},Uy=class{constructor(a,b,c,d=null){this.id=a;this.name=b;this.a=c;this.value=d}toString(){function a(d){return d.name+"\x3d"+(isNaN(Number(d.value))?'"'+d.value+'"':d.value)}let b="#"+this.name;const c=this.a?this.a.map(a):[];this.value&&
33
- c.unshift(this.value);0<c.length&&(b+=":"+c.join(","));return b}getAttribute(a){const b=this.a.filter(c=>c.name==a);return b.length?b[0]:null}},Ty=class{constructor(a,b){this.name=a;this.value=b}},Xy=class{constructor(a,b){this.Ga=b;this.a=a}};var Sz=class{constructor(){this.a=0}},Wy=[Fy,Cy,Ay,Dy,"EXT-X-MAP","EXT-X-I-FRAMES-ONLY",By],Zy=["EXTINF",yy,zy,"EXT-X-PROGRAM-DATE-TIME","EXT-X-KEY","EXT-X-DATERANGE"];var Tz=class{constructor(){this.h=this.j=null;this.W=1;this.w=new Map;this.V=new Set;this.f=new Map;this.g=null;this.B="";this.K=new Sz;this.T=0;this.A=new _.wh(()=>{cz(this)});this.m=hz;this.H=null;this.N=0;this.R=Infinity;this.C=new _.Jn;this.S=[];this.J=new Map;this.F=!1;this.o=new Map;this.L=null;this.a=new _.O("clpp.hls.HlsParser");this.D=new Map;this.I=new Map}configure(a){this.h=a}start(a,b){const c=this;return _.v(function*(){c.j=b;var d=yield ez(c,a);c.B=d.uri;yield kz(c,d.data);d=c.T;0<
34
- d&&c.A.$(d);return c.H})}stop(){this.A&&(this.A.stop(),this.A=null);const a=[];this.C&&(a.push(this.C.destroy()),this.C=null);this.h=this.j=null;this.V.clear();this.f.clear();this.D.clear();this.H=null;this.w.clear();this.o.clear();return Promise.all(a)}update(){const a=this;return _.v(function*(){if(a.m!=hz){var b=[];a.L=null;var c=Array.from(a.f.values());c.length&&(yield nz(a,c[0]));for(let d=1;d<c.length;++d)b.push(nz(a,c[d]));yield Promise.all(b)}})}onExpirationUpdated(){}},Ez={audio:[/^vorbis$/,
35
- /^opus$/,/^flac$/,/^mp4a/,/^[ae]c-3$/],video:[/^avc/,/^hev/,/^hvc/,/^vp0?[89]/,/^av1$/],text:[/^vtt$/,/^wvtt/,/^stpp/]},fz={audio:{mp4:_.Xb,m4s:_.Xb,m4i:_.Xb,m4a:_.Xb,cmfa:_.Xb,ts:_.De,aac:_.Ub,ec3:_.Wb,ac3:_.Vb},video:{mp4:_.Ee,m4s:_.Ee,m4i:_.Ee,m4v:_.Ee,cmfv:_.Ee,ts:_.De},text:{mp4:_.Mb,m4s:_.Mb,m4i:_.Mb,cmft:_.Mb,vtt:_.ne,ttml:_.Pb},image:{jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",svg:"image/svg+xml",webp:"image/webp",avif:"image/avif"}},Lz={"com.apple.streamingkeydelivery":function(a,
36
- b){if(b===_.De)throw new _.H(_.G,4,4041);return _.mt(_.yc,[{initDataType:_.ae,initData:new Uint8Array(0)}],"")},"com.microsoft.playready":bz,"urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":bz,"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":function(a){var b=Oy(a,"METHOD");const c=["SAMPLE-AES",Iy];if(!c.includes(b))return _.Bf("Widevine in HLS is only supported with [",c.join(", "),"], not",b),null;b=Oy(a,Ky);b=_.Ym(b);b=_.L(b.data);b=_.mt(_.Ac,[{initDataType:_.lc,initData:b}],"");if(a=Ny(a,"KEYID"))b.keyIds=
37
- [a.substr(2).toLowerCase()];return b}},hz="VOD",Mz="EVENT",jz="LIVE";_.x("clpp.hls.HlsComponent",class extends _.zo{constructor(){super()}f(){_.Cm.m3u8=Tz;_.Am[_.Rb]=Tz;_.Am[Ly]=Tz}a(){_.Zt("m3u8");_.$t(_.Rb);_.$t(Ly)}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 Ay="BANDWIDTH",By="CLOSED-CAPTIONS",Cy="EXT-X-BYTERANGE",Dy="EXT-X-DISCONTINUITY",Ey="EXT-X-DISCONTINUITY-SEQUENCE",Fy="EXT-X-ENDLIST",Gy="EXT-X-MEDIA-SEQUENCE",Hy="EXT-X-PLAYLIST-TYPE",Iy="EXT-X-STREAM-INF",Jy="EXT-X-TARGETDURATION",Ky="GROUP-ID",Ly="Guessing audio-only",My="SAMPLE-AES-CTR",Ny="SUBTITLES",Oy="URI",Py="application/vnd.apple.mpegurl",Qy=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+
2
+ 8]&&128>a[b+9]?!0:!1},Ry=function(a,b,c){return(a=a.getAttribute(b))?a.value:c||null},Sy=function(a,b){a=a.getAttribute(b);if(!a)throw new _.G(_.F,4,4023,b);return a.value},Ty=function(a,b){return a.filter(c=>c.name==b)},Uy=function(a,b){return a.filter(c=>Sy(c,"TYPE")===b)},Vy=function(a,b){a=Ty(a,b);return a.length?a[0]:null},Wy=function(a,b){return _.Ft([a],[b])[0]},Zy=function(a,b){var c;a=a.a++;var d=b.match(/^#(EXT[^:]*)(?::(.*))?$/);if(!d)throw new _.G(_.F,4,4016,{invalidTag:b});b=d[1];var e=
3
+ d[2];d=[];if(e){e=new _.jp(e);var f;(f=_.Pm(e,/^([^,=]+)(?:,|$)/g))&&(c=f[1]);const g=/([^=]+)=(?:"([^"]*)"|([^",]*))(?:,|$)/g;for(;f=_.Pm(e,g);)d.push(new Xy(f[1],f[2]||f[3]))}return c=new Yy(a,b,d,c)},bz=function(a,b,c,d){const e=[];let f=[];c.forEach(g=>{/^(#EXT)/.test(g)?(g=Zy(a,g),$y.includes(g.name)?d.push(g):f.push(g)):/^#(?!EXT)/m.test(g)||(g=Wy(b,g.trim()),e.push(new az(g,f)),f=[])});return e},ez=function(a,b,c){b=_.mg(b);b=b.replace(/\r\n|\r(?=[^\n]|$)/gm,"\n").trim();const d=b.split(/\n+/m);
4
+ if(!/^#EXTM3U($|[ \t\n])/m.test(d[0]))throw new _.G(_.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=Zy(a,f);--a.a;if($y.includes(g.name)){b=1;break}else g.name==Iy&&(e=!0)}f=[];e=!0;for(var h of _.st(d)){let {md:k,item:l,next:m}=h;l=l.trim();if(!l.length||/^#(?!EXT)/m.test(l)||e)e=!1;else{g=Zy(a,l);if(cz.includes(g.name)){if(1!=b)throw new _.G(_.F,4,4017);h=d.splice(k,d.length-k);a=bz(a,c,h,f);return new dz(c,b,f,a)}f.push(g);g.name==Iy&&(g.a.push(new Xy(Oy,
5
+ m)),e=!0)}}return new dz(c,b,f)},fz=function(a){var b=Sy(a,"METHOD");const c=["SAMPLE-AES",My];if(!c.includes(b))return _.Ef("PlayReady in HLS is only supported with [",c.join(", "),"], not",b),null;a=Sy(a,Oy);b=_.rn(a);a=null;b=_.K(b.data);try{a=_.nt(_.Nj(b))}catch(d){a=b}return _.Gt(_.Cc,[{initDataType:_.nc,initData:a}],"")},gz=function(a){_.v(function*(){a.a.debug(_.Zs);if(a.j)try{yield a.update(),a.A.$(a.T)}catch(b){a.j&&(a.j.onError(b),1===b.severity&&a.A.$(.1))}})},iz=function(a,b){b=_.Cg([b],
6
+ a.h.attemptParameters);b.type=1;return hz(a,b)},oz=function(a,b){return _.v(function*(){var c=ez(a.K,b,a.B);if(1===c.type){a.D.set(a.B,c);c=(new _.jh(c.a[0].a)).ma.split(".").pop();var d=jz.audio[c],e="";jz.video[c]?e="avc1.42E01E":d&&(e="mp4a.40.2");{c=a.K;d=a.B;e=a.h.hlsDefaultCodecs||e;var f=[];const h=[];h.push(new Xy(Ay,"0"));h.push(new Xy(Oy,d));e.length&&h.push(new Xy(_.ja,e));f.push(new Yy(c.a++,Iy,h));c=new dz(d,0,f)}}c=yield kz(a,c.Ha);if(!a.j)throw new _.G(_.F,7,7001);a.j.filterAllPeriods([c]);
7
+ e=Infinity;d=0;f=Infinity;for(var g of a.f.values())e=Math.min(e,g.vd),d=Math.max(d,g.vd),g.stream.type!=_.t&&(f=Math.min(f,g.duration));a.m!=lz?(a.g=new _.oy(0,3*a.N,!0),a.g.f=!1):(a.g=new _.oy(null,0,!0),a.g.f=!0);mz(a);if(a.m!=lz){a.T=a.R;a.m===nz&&(g=Math.max(f,a.g.Fd),isNaN(a.h.availabilityWindowOverride)||(g=a.h.availabilityWindowOverride),a.g.Yb=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");
8
+ for(const h of a.f.values())95443.7176888889>h.vd?(a.a.debug("Offset applied to",h.stream.type),h.bb.offset(g)):a.a.debug("Offset NOT applied to",h.stream.type)}}else{a.g.Ib(f);a.g.offset(-e);for(const h of a.f.values())h.bb.offset(-e),_.au(h.bb,f)}a.H={presentationTimeline:a.g,periods:[c],offlineSessionIds:[],minBufferTime:0}})},rz=function(a,b){return _.v(function*(){var c=yield iz(a,b.Ne);c=ez(a.K,c.data,c.uri);if(1!=c.type)throw new _.G(_.F,4,4017);var d=b.stream;d=yield pz(a,b.Uc,c,d.type,d.mimeType,
9
+ d.codecs,d.keyInfo||null,b.Te);b.bb.replace(d);d=d[d.length-1];Vy(c.Ha,Fy)&&(qz(a,lz),a.g.Ib(d.endTime))})},pz=function(a,b,c,d,e,f,g,h){return _.v(function*(){var k=c.a;const l=sz(c,g);var m=(m=Vy(c.Ha,Gy))?Number(m.value):0;null===a.L&&(a.L=yield tz(a,b,l,k[0],m,g,e,f,d));const n=a.L;a.a.debug("First segment",k[0].a.split("/").pop(),"starts at",n);var q=Vy(c.Ha,Ey);let r=q?Number(q.value):0;h.has(r)||h.set(r,m);if(!q)for(;h.has(r+1)&&h.get(r+1)<m;)r++;q=a.I.get(r)||0;const w=[];for(const A of _.st(k)){var C=
10
+ A.md;k=A.item;{const E=w[w.length-1],D=0==C?n:E.endTime;C=m+C;Vy(k.Ha,Dy)&&(r++,h.set(r,C),q=yield uz(a,r,b,l,k,C,g,e,f,D,d));k=vz(E,k,C,D,q,g,d);w.push(k)}}a.S.push(w);mz(a);return w})},qz=function(a,b){a.m=b;a.g&&(a.g.f=a.m==lz);a.m!=lz||a.A.stop()},kz=function(a,b){return _.v(function*(){var c=Ty(b,"EXT-X-MEDIA"),d=Ty(b,Iy),e=Ty(b,"EXT-X-IMAGE-STREAM-INF");for(var f of d){var g=Ry(f,"AUDIO"),h=Ry(f,"VIDEO"),k=Ry(f,Ny);const l=wz(a,f);if(k){const m=xz(_.t,l);a.o.set(k,m);k=l.indexOf(m);-1<k&&l.splice(k,
11
+ 1)}g&&(k=yz(_.Vb,l),a.o.set(g,k));h&&(g=yz(_.u,l),a.o.set(h,g))}yield zz(a,c);f=Uy(c,By);for(const l of f)f=Az(l),h=Sy(l,Ky),g=Sy(l,"INSTREAM-ID"),a.J.get(h)||a.J.set(h,new Map),a.J.get(h).set(g,f);d=yield Bz(a,d);c=yield Cz(a,c);e=yield Dz(a,e);return{startTime:0,variants:d,textStreams:c,thumbStreams:e}})},zz=function(a,b){return _.v(function*(){b=b.filter(d=>{const e=Ry(d,Oy)||"";return Ry(d,"TYPE")!==Ny&&""!==e});b.length&&(yield Ez(a,b[0]));const c=b.slice(1).map(d=>Ez(a,d));yield Promise.all(c)})},
12
+ Bz=function(a,b){return _.v(function*(){var c=f=>_.v(function*(){const g=Ry(f,"FRAME-RATE"),h=Number(Sy(f,Ay));var k=Ry(f,"RESOLUTION");const [l,m]=k?k.split("x"):[null,null];return(k=yield Fz(a,f,k,g))?Gz(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(Sy(b[f],Ay));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(_.Dt,[]).filter(_.Ik)})},Cz=function(a,b){return _.v(function*(){var c=
13
+ Uy(b,Ny),d=c.map(f=>_.v(function*(){try{return(yield Ez(a,f)).stream}catch(g){throw g;}}));d=yield Promise.all(d);for(const f of c){var e=Sy(f,Ky);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)})},Dz=function(a,b){return _.v(function*(){const c=b.map(d=>_.v(function*(){return(yield Hz(a,d)).stream}));return(yield Promise.all(c)).filter(d=>d)})},wz=function(a,b){var c=Ry(b,_.ja,a.h.hlsDefaultCodecs||"avc1.42E01E,mp4a.40.2").split(/\s*,\s*/);b=new Set;const d=
14
+ [];for(const e of c)c=_.yt(e)[0],b.has(c)?a.a.debug("Ignoring duplicate codec"):(d.push(e),b.add(c));return d},xz=function(a,b){const c=Iz[a];for(let d=0;d<c.length;d++)for(let e=0;e<b.length;e++)if(c[d].test(b[e].trim()))return b[e].trim();return a==_.t?"":null},yz=function(a,b){if(1==b.length)return b[0];a=xz(a,b);if(null!=a)return a;throw new _.G(_.F,4,4025,{codecList:b});},Ez=function(a,b){return _.v(function*(){const c=Sy(b,Ky);var d="";let e=Sy(b,"TYPE").toLowerCase();e==_.jt&&(e=_.t);e!==_.t&&
15
+ c&&a.o.has(c)&&(d=a.o.get(c));const f=Sy(b,Oy);if(a.f.has(f))return a.f.get(f);const g=Az(b),h=Ry(b,"NAME"),k=b.getAttribute("DEFAULT"),l=b.getAttribute("AUTOSELECT"),m=Ry(b,"CHANNELS");d=yield Jz(a,f,d,e,g,!!k&&!!l,h,e==_.Vb?m?parseInt(m.split("/")[0],10):null:null,null);if(null==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})},Hz=function(a,b){return _.v(function*(){const c=Sy(b,Oy);if(a.f.has(c))return a.f.get(c);var d=Ry(b,_.ja)||
16
+ "jpg",e=Az(b);const f=Ry(b,"NAME");d=yield Jz(a,c,d,_.$c,e,!1,f,null,null);if(null===d)return null;if(a.f.has(c))return a.f.get(c);if(e=Ry(b,Ay))d.stream.bandwidth=Number(e);a.f.set(c,d);return d})},Fz=function(a,b,c,d){return _.v(function*(){let e=wz(a,b);var f=Ry(b,"AUDIO"),g=Ry(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=Sy(b,Oy),l=f.audio.find(q=>q.Uc===k);var m=xz(_.u,e);m=c||d||m;1!==e.length||
17
+ m?!h.length&&1<e.length?(a.a.debug("Guessing multiplexed audio+video"),h=_.u,e=[e.join(",")]):f.audio.length&&l?(a.a.debug(Ly),h=_.Vb,g=!0):f.video.length?(a.a.debug(Ly),h=_.Vb):(a.a.debug("Guessing video-only"),h=_.u):(h=_.Vb,a.a.debug(Ly));let n;g||(n=yield Kz(a,b,e,h));if(n)f[n.stream.type]=[n];else if(null===n)return a.a.debug("streamInfo is null"),null;Lz(f);return f})},Gz=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)||
18
+ 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,r=m?m.drmInfos:null;b=(m?m.Uc:"")+" - "+(l?l.Uc:"");let w;if(k&&n)if(q.length&&r.length?0<_.Ct(q,r).length:1)w=_.Ct(q,r);else{a.a.warn("Incompatible DRM info in HLS variant. Skipping.");continue}else k?w=q:n&&(w=r);a.V.has(b)?a.a.debug("Skipping variant which only differs in text streams."):(k=Mz(a,k,n,d,w),h.push(k),a.V.add(b))}return h},
19
+ Kz=function(a,b,c,d){return _.v(function*(){const e=Sy(b,Oy);if(a.f.has(e))return a.f.get(e);var f=Ry(b,By),g=null;d==_.u&&f&&"NONE"!=f&&(g=a.J.get(f));f=yz(d,c);g=yield Jz(a,e,f,d,_.ue,!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})},Lz=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(",")},Mz=function(a,b,c,d,e){return{id:a.W++,language:b?b.language:_.ue,primary:!!b&&
20
+ b.primary||!!c&&c.primary,audio:b,video:c,bandwidth:d,drmInfos:e,allowedByApplication:!0,allowedByKeySystem:!0}},Az=function(a){a=Ry(a,"LANGUAGE")||_.ue;return _.Mg(a)},Jz=function(a,b,c,d,e,f,g,h,k){return _.v(function*(){let l=Wy(a.B,b);var m=null;if(a.m==lz&&a.D.has(l)){var n=a.D.get(l);a.D.delete(l)}else{var q=yield iz(a,l);l=q.uri;n=ez(a.K,q.data,l)}if(1!=n.type)throw new _.G(_.F,4,4017);Nz(a,n);q=yield Oz(a,d,c,n);const r=[];n.a.forEach(Cd=>{Cd=Ty(Cd.Ha,"EXT-X-KEY");r.push.apply(r,Cd)});let w=
21
+ !1;const C=[];let A=null;for(var E of r){var D=Sy(E,"METHOD"),na=Ry(E,"KEYFORMAT","identity");"NONE"!=D&&("AES-128"==D?(m=Ry(E,"IV",""),m={method:"AES-128",url:Wy(a.B,Sy(E,Oy)),iv:m?_.ri((m||"0x").slice(2)):null},a.F=!0):(w=!0,(D=(D=Pz[na])?D(E,q):null)?(D.keyIds.length&&(A=D.keyIds[0]),C.push(D)):a.a.warn("Unsupported HLS KEYFORMAT",na)))}if(w&&!C.length&&!a.F)throw new _.G(_.F,4,4026);E=new Map;var $a=yield pz(a,b,n,d,q,c,m,E);na=$a[0].startTime;D=$a[$a.length-1].endTime;const tf=D-na;$a=new _.py($a);
22
+ n=sz(n,m);let xe=void 0;d==_.t&&(xe=_.it);return{stream:{id:a.W++,originalId:g,createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:$a.h.bind($a),getSegmentReference:$a.get.bind($a),adjustSegmentDurations:$a.f.bind($a),getDuration:$a.getDuration.bind($a),initSegmentReference:n,mimeType:q,codecs:c,kind:xe,encrypted:w,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,
23
+ closedCaptions:k,keyInfo:m},bb:$a,drmInfos:C,Uc:b,Ne:l,vd:na,Yf:D,duration:tf,Te:E}})},Nz=function(a,b){var c=Vy(b.Ha,Hy),d=Vy(b.Ha,Fy);d=c&&"VOD"==c.value||d;c=c&&"EVENT"==c.value&&!d;c=!d&&!c;d?qz(a,lz):(c?qz(a,nz):qz(a,Qz),b=Rz(b.Ha,Jy),b=Number(b.value),a.N=Math.max(b,a.N),a.R=Math.min(b,a.R))},Oz=function(a,b,c,d){return _.v(function*(){var e=d.a[0].a;const f=(new _.jh(e)).ma.split(".").pop(),g=jz[b][f];if(g)return g;if(b==_.t)return c&&"vtt"!=c?_.Ob:_.pe;e=_.Cg([e],a.h.attemptParameters);e.method=
24
+ "HEAD";e.type=2;e=(yield hz(a,e)).headers["content-type"];if(!e)throw new _.G(_.F,4,4021,f);return e.split(";")[0]})},sz=function(a,b){var c=Ty(a.Ha,"EXT-X-MAP");if(!c.length)return null;if(1<c.length)throw new _.G(_.F,4,4020);c=c[0];var d=Sy(c,Oy);const e=Wy(a.f,d);a=0;d=null;if(c=Ry(c,"BYTERANGE"))a=c.split("@"),c=Number(a[0]),a=Number(a[1]),d=a+c-1;return new _.ny(()=>[e],a,d,b)},Rz=function(a,b){a=Vy(a,b);if(!a)throw new _.G(_.F,4,4024,{missingTag:b});return a},mz=function(a){a.g&&(a.S.forEach(b=>
25
+ {_.Rt(a.g,b,0)}),a.S=[])},vz=function(a,b,c,d,e,f,g){var h=b.Ha;const k=b.a;b=Rz(h,"EXTINF").value.split(",");b=d+Number(b[0]);var l=0,m=null,n=Vy(h,Cy);n&&(l=n.value.split("@"),m=Number(l[0]),l=l[1]?Number(l[1]):a.wa+1,m=l+m-1);(a=f?Object.assign({},f):null)&&!a.iv&&(a.iv=_.ui(new Uint8Array(12),new Uint8Array([c>>24&255,c>>16&255,c>>8&255,c&255])));let q=n=null;f=null;g===_.$c&&(h=Vy(h,"EXT-X-TILES"),g="1x1",h&&(g=Ry(h,"LAYOUT")||"1x1",f=(h=Ry(h,"DURATION"))?Number(h):null),[n,q]=g.split("x").map(r=>
26
+ parseInt(r,10)));return new _.Yt(c,d,b,()=>[k],l,m,e,a,!1,null,n,q,f)},tz=function(a,b,c,d,e,f,g,h,k,l){return _.v(function*(){var m=vz(null,d,e,0,0,f,k);if(a.H&&!l){var n=a.f.get(b).bb.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==_.Wb)return m=yield Sz(a,m),n=_.K(m.data),Qy(n)?Tz(n):Uz(m.data);
27
+ if(g==_.Ge||g==_.Zb)return m=[Sz(a,m)],c&&m.push(Sz(a,c)),m=yield Promise.all(m),Vz(a,m[0].data,(m[1]||m[0]).data);if(g==_.Fe)return m=yield Sz(a,m),Uz(m.data);if(g===_.Yb||g===_.Xb||!MediaSource.isTypeSupported(`${g.split("/")[0]||""}/mp4;codecs="${h}"`))return 0;throw new _.G(_.F,4,4030);})},uz=function(a,b,c,d,e,f,g,h,k,l,m){return _.v(function*(){let n;a.I.has(b)?n=a.I.get(b):(n=(yield tz(a,c,d,e,f,g,h,k,m,!0))-l,a.a.debug("Discontinuity segment offset",n),a.I.set(b,n));return n})},hz=function(a,
28
+ b){if(!a.C)throw new _.G(_.F,7,7001);b=a.j.networkingEngine.fetch(b);_.ih(a.C,b);return b.O},Sz=function(a,b){return _.v(function*(){const c=b.a(),d=_.Pt(b.La(),b.Fa,b.Fa+2048-1,a.h.attemptParameters);d.type=2;const e=_.Pt(b.La(),b.Fa,b.wa,a.h.attemptParameters);e.type=2;c&&(e.keyInfo=c);try{return yield hz(a,a.F?e:d)}catch(f){if(7001==f.code||a.F)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.",
29
+ d.uris[0]);return yield hz(a,e)}})},Tz=function(a){function b(h,k,l){let m="";for(;k<l;k++)m+="%"+("00"+h[k].toString(16)).slice(-2);return m}function c(h){return h[0]<<21|h[1]<<14|h[2]<<7|h[3]}function d(){throw new _.G(_.F,4,4030);}Qy(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"===
30
+ 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}}Qy(a,e)||d();e+=10;e+=f}while(e<a.byteLength);return d()},Uz=function(a){function b(){d.seek(e+188);f=_.Ji(d);71!=f&&(d.seek(e+192),f=_.Ji(d));71!=f&&(d.seek(e+204),f=_.Ji(d));71!=f&&c();_.Oi(d)}function c(){throw new _.G(_.F,4,4030);}const d=new _.Ij(new DataView(a),!1);let e=0,f=0;for(;;){e=d.getPosition();f=_.Ji(d);71!=f&&c();a=_.Ki(d);if(8191===(a&8191)){b();continue}if(!(a&
31
+ 16384)){b();continue}a=(_.Ji(d)&48)>>4;0!=a&&2!=a||c();3==a&&(a=_.Ji(d),d.skip(a));if(1!=_.M(d)>>8){b();continue}d.skip(3);a=_.Ji(d)>>6;0!=a&&1!=a||c();0==_.Ji(d)&&c();a=_.Ji(d);const g=_.Ki(d),h=_.Ki(d);return(1073741824*((a&14)>>1)+((g&65534)<<14|(h&65534)>>1))/9E4}},Vz=function(a,b,c){let d=0;(new _.$i).M(_.qd,_.N).M(_.se,_.N).M(_.ld,_.N).X("mdhd",g=>{g.G.skip(0==g.version?8:16);d=_.M(g.G);g.Ma.stop()}).parse(c,!0);if(!d)throw a.a.error("Unable to find timescale in init segment!"),new _.G(_.F,
32
+ 4,4030);let e=0,f=!1;(new _.$i).M("moof",_.N).M("traf",_.N).X("tfdt",g=>{e=(0==g.version?_.M(g.G):_.Mi(g.G))/d;f=!0;g.Ma.stop()}).parse(b,!0);if(!f)throw new _.G(_.F,4,4030);return e},dz=class{constructor(a,b,c,d){this.f=a;this.type=b;this.Ha=c;this.a=d||null}},Yy=class{constructor(a,b,c,d=null){this.id=a;this.name=b;this.a=c;this.value=d}toString(){function a(d){return d.name+"\x3d"+(isNaN(Number(d.value))?'"'+d.value+'"':d.value)}let b="#"+this.name;const c=this.a?this.a.map(a):[];this.value&&c.unshift(this.value);
33
+ 0<c.length&&(b+=":"+c.join(","));return b}getAttribute(a){const b=this.a.filter(c=>c.name==a);return b.length?b[0]:null}},Xy=class{constructor(a,b){this.name=a;this.value=b}},az=class{constructor(a,b){this.Ha=b;this.a=a}};var Wz=class{constructor(){this.a=0}},$y=[Jy,Gy,Ey,Hy,"EXT-X-MAP","EXT-X-I-FRAMES-ONLY",Fy],cz=["EXTINF",Cy,Dy,"EXT-X-PROGRAM-DATE-TIME","EXT-X-KEY","EXT-X-DATERANGE"];var Xz=class{constructor(){this.h=this.j=null;this.W=1;this.w=new Map;this.V=new Set;this.f=new Map;this.g=null;this.B="";this.K=new Wz;this.T=0;this.A=new _.zh(()=>{gz(this)});this.m=lz;this.H=null;this.N=0;this.R=Infinity;this.C=new _.bo;this.S=[];this.J=new Map;this.F=!1;this.o=new Map;this.L=null;this.a=new _.O("clpp.hls.HlsParser");this.D=new Map;this.I=new Map}configure(a){this.h=a}start(a,b){const c=this;return _.v(function*(){c.j=b;var d=yield iz(c,a);c.B=d.uri;yield oz(c,d.data);d=c.T;0<
34
+ d&&c.A.$(d);return c.H})}stop(){this.A&&(this.A.stop(),this.A=null);const a=[];this.C&&(a.push(this.C.destroy()),this.C=null);this.h=this.j=null;this.V.clear();this.f.clear();this.D.clear();this.H=null;this.w.clear();this.o.clear();return Promise.all(a)}update(){const a=this;return _.v(function*(){if(a.m!=lz){var b=[];a.L=null;var c=Array.from(a.f.values());c.length&&(yield rz(a,c[0]));for(let d=1;d<c.length;++d)b.push(rz(a,c[d]));yield Promise.all(b)}})}onExpirationUpdated(){}},Iz={audio:[/^vorbis$/,
35
+ /^opus$/,/^flac$/,/^mp4a/,/^[ae]c-3$/],video:[/^avc/,/^hev/,/^hvc/,/^vp0?[89]/,/^av1$/],text:[/^vtt$/,/^wvtt/,/^stpp/]},jz={audio:{mp4:_.Zb,m4s:_.Zb,m4i:_.Zb,m4a:_.Zb,cmfa:_.Zb,ts:_.Fe,aac:_.Wb,ec3:_.Yb,ac3:_.Xb},video:{mp4:_.Ge,m4s:_.Ge,m4i:_.Ge,m4v:_.Ge,cmfv:_.Ge,ts:_.Fe},text:{mp4:_.Ob,m4s:_.Ob,m4i:_.Ob,cmft:_.Ob,vtt:_.pe,ttml:_.Rb},image:{jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",svg:"image/svg+xml",webp:"image/webp",avif:"image/avif"}},Pz={"com.apple.streamingkeydelivery":function(a,
36
+ b){if(b===_.Fe)throw new _.G(_.F,4,4041);return _.Gt(_.Bc,[{initDataType:_.ce,initData:new Uint8Array(0)}],"")},"com.microsoft.playready":fz,"urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":fz,"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":function(a){var b=Sy(a,"METHOD");const c=["SAMPLE-AES",My];if(!c.includes(b))return _.Ef("Widevine in HLS is only supported with [",c.join(", "),"], not",b),null;b=Sy(a,Oy);b=_.rn(b);b=_.K(b.data);b=_.Gt(_.Dc,[{initDataType:_.nc,initData:b}],"");if(a=Ry(a,"KEYID"))b.keyIds=
37
+ [a.substr(2).toLowerCase()];return b}},lz="VOD",Qz="EVENT",nz="LIVE";_.x("clpp.hls.HlsComponent",class extends _.So{constructor(){super()}f(){_.Vm.m3u8=Xz;_.Tm[_.Tb]=Xz;_.Tm[Py]=Xz}a(){_.du("m3u8");_.eu(_.Tb);_.eu(Py)}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 WG=function(a){a.a.one(a.l,_.ed,()=>VG(a))},VG=function(a){const b=a.l.getSurface().getMedia();if(b)if(a.h){a.a.on(b.textTracks,_.Eb,d=>XG(a,d));var c=Array.from(b.textTracks);c.filter(d=>d.kind===_.kd).forEach(d=>{XG(a,{track:d})});!YG(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."),ZG(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.")},XG=function(a,b){b=b.track;b.kind===_.kd&&(a.f.info("The metadata track has been added."),b.mode=_.Uc,a.a.on(b,_.Dc,c=>$G(a,c)))},YG=function(a){return a.some(b=>b.kind===_.kd)},ZG=function(a,b){const c=a.l.getTrackManager(),d=c.ha(),e=c.getAudioTracks().find(g=>g!==d);if(e){var f=()=>c.la(d);a.a.on(b.textTracks,_.Eb,g=>{g.track.kind===_.kd&&(a.a.off(b.textTracks,_.Eb,f),c.la(d))});c.la(e)}else a.f.warn("Can't enforce the creation of the metadata track if single audio track. Skipping.")},
3
- $G=function(a,b){const c=aH(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 bH(d);if(e.f===c&&null!==e.a){a.g=d;d=a.h.parseMedia(_.ng(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)}}})},aH=function(a){return(a=a.l.getTrackManager().ia())&&a.language&&a.language.toLowerCase()},
4
- bH=class{constructor(a){this.startTime=a.startTime;this.endTime=a.endTime;this.a=this.f=null;a=a.value;if(!_.y(a)){a:{var b=a.info;if(_.jf(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=_.jf(a)?a:null}}};var cH=class{constructor(a,b,c){this.l=a;this.m=b;this.j=c;this.a=new _.mn;this.h=(a=_.$m[_.Pb]||null)?new a(this.l.getConfiguration()):null;this.f=new _.O("clpp.hlssmpte.ImageCueHandler");this.g=null;WG(this)}destroy(){this.a.release();this.g=null;return Promise.resolve()}};var dH=class extends _.bp{constructor(){super();this.a=null;this.f=!1}onPlayerCreated(){}onContentWillLoad(a){if(this.f=_.Kh()){var b=a.getConfiguration();b=_.ef(b.hlssmpte||{});typeof b.patchMetadataTrack!==_.ac&&(b.patchMetadataTrack=!1);_.kf(b.timestampOffset)||(b.timestampOffset=0);this.a=new cH(a,b.patchMetadataTrack,b.timestampOffset)}}onPlayerWillDestroy(){const a=this;return _.v(function*(){a.a&&(yield a.a.destroy(),a.a=null)})}id(){return"hlssmpte"}};_.x("clpp.hlssmpte.HlsSmptePlugin",dH);
5
- dH.Id="hlssmpte";_.Ll(new class{create(){return new dH}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var bH=function(a){a.a.one(a.l,_.hd,()=>aH(a))},aH=function(a){const b=a.l.getSurface().getMedia();if(b)if(a.h){a.a.on(b.textTracks,_.Gb,d=>cH(a,d));var c=Array.from(b.textTracks);c.filter(d=>d.kind===_.nd).forEach(d=>{cH(a,{track:d})});!dH(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."),eH(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.")},cH=function(a,b){b=b.track;b.kind===_.nd&&(a.f.info("The metadata track has been added."),b.mode=_.Zc,a.a.on(b,_.Gc,c=>fH(a,c)))},dH=function(a){return a.some(b=>b.kind===_.nd)},eH=function(a,b){const c=a.l.getTrackManager(),d=c.ha(),e=c.getAudioTracks().find(g=>g!==d);if(e){var f=()=>c.la(d);a.a.on(b.textTracks,_.Gb,g=>{g.track.kind===_.nd&&(a.a.off(b.textTracks,_.Gb,f),c.la(d))});c.la(e)}else a.f.warn("Can't enforce the creation of the metadata track if single audio track. Skipping.")},
3
+ fH=function(a,b){const c=gH(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 hH(d);if(e.f===c&&null!==e.a){a.g=d;d=a.h.parseMedia(_.qg(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)}}})},gH=function(a){return(a=a.l.getTrackManager().ia())&&a.language&&a.language.toLowerCase()},
4
+ hH=class{constructor(a){this.startTime=a.startTime;this.endTime=a.endTime;this.a=this.f=null;a=a.value;if(!_.y(a)){a:{var b=a.info;if(_.lf(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=_.lf(a)?a:null}}};var iH=class{constructor(a,b,c){this.l=a;this.m=b;this.j=c;this.a=new _.Fn;this.h=(a=_.tn[_.Rb]||null)?new a(this.l.getConfiguration()):null;this.f=new _.O("clpp.hlssmpte.ImageCueHandler");this.g=null;bH(this)}destroy(){this.a.release();this.g=null;return Promise.resolve()}};var jH=class extends _.up{constructor(){super();this.a=null;this.f=!1}onPlayerCreated(){}onContentWillLoad(a){if(this.f=_.Nh()){var b=a.getConfiguration();b=_.gf(b.hlssmpte||{});typeof b.patchMetadataTrack!==_.cc&&(b.patchMetadataTrack=!1);_.mf(b.timestampOffset)||(b.timestampOffset=0);this.a=new iH(a,b.patchMetadataTrack,b.timestampOffset)}}onPlayerWillDestroy(){const a=this;return _.v(function*(){a.a&&(yield a.a.destroy(),a.a=null)})}id(){return"hlssmpte"}};_.x("clpp.hlssmpte.HlsSmptePlugin",jH);
5
+ jH.Id="hlssmpte";_.cm(new class{create(){return new jH}});};f.call(g, window);
package/cl.htmlcue.js CHANGED
@@ -1,24 +1,25 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var QF="Unsupported unit",RF="clpp-text-plain",SF="clpp-text-ttml",TF="clpp.htmlcue.HtmlTextDisplayer",UF="initial",VF=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},WF=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},YF=function(a){let b=null;for(;b=a.match(/&(amp|lt|gt|lrm|rlm|nbsp);/);)a=a.replace(b[0],c=>XF[c]);return a},ZF=
2
- function(a,b){for(const c in a)b.style[c]=a[c]},$F=function(a,b){return 0===a?"0":a+b},aG=function(a,b){return 1>Math.abs(a-b)||a<b},bG=function(a,b){return a<b&&1<Math.abs(a-b)},cG=function(a,b){return a>b&&1<Math.abs(a-b)},dG=function(a,b){return 1>Math.abs(a-b)||a>b},fG=function(a){const b=a.getBoundingClientRect();var c=getComputedStyle(a,null);const d=parseFloat(c.getPropertyValue("border-left-width"))||0,e=parseFloat(c.getPropertyValue("border-right-width"))||0;var f=parseFloat(c.getPropertyValue("border-top-width"))||
3
- 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 eG(b.left+d,b.right+e,g,(b.bottom||g+f)+c,f,(b.width||a.offsetWidth)-d-e)},gG=function(a){return new eG(a.f,a.g,a.h,a.a,a.height,a.width)},hG=function(a,b){return b.some(c=>bG(a.f,c.g)&&cG(a.g,c.f)&&bG(a.h,c.a)&&cG(a.a,c.h))},iG=function(a,b){return dG(a.h,b.h)&&aG(a.a,b.a)&&dG(a.f,b.f)&&aG(a.g,b.g)},jG=function(a,b,c){switch(c){case "+x":return bG(a.f,b.f);case "-x":return cG(a.g,
4
- b.g);case "+y":return bG(a.h,b.h);case "-y":return cG(a.a,b.a);default:throw Error("Unknown axis");}},kG=function(a){return a.f.writingMode===_.qn},lG=function(a){switch(a.f.writingMode){case _.qn:return"horizontal-tb";case _.Be:return _.Be;case _.Ce:return _.Ce;default:throw Error("Unknown writing mode");}},mG=function(a){switch(a.f.positionAlign){case _.cd:return _.$c;case "auto":case _.mc:return _.pn;case _.dd:return _.Xd}return a.f.textAlign},nG=function(a,b){if(typeof a.f.position===_.p&&typeof a.f.size===
5
- _.p)switch(b){case _.cd:return a.f.position;case "auto":case _.mc:return a.f.position-a.f.size/2;case _.dd:return a.f.position-a.f.size}return 0},oG=function(a){if(!a.f.positionAlign)switch(a.f.textAlign){case _.$c:case _.$c:return _.cd;case _.pn:return _.mc;case _.Xd:case _.Xd:return _.dd}return a.f.positionAlign},rG=function(a,b,c){return(pG(a)||qG(a))&&_.kf(c)?$F(c,_.Qd):pG(a)&&_.y(c)?$F(0,_.Qd):kG(a)&&_.kf(b)?$F(b,"%"):UF},sG=function(a,b,c){return kG(a)&&_.kf(c)?$F(c,_.Qd):(pG(a)||qG(a))&&_.kf(b)?
6
- $F(b,"%"):UF},tG=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 kG(a)?b:c},qG=function(a){return a.f.writingMode===_.Ce},pG=function(a){return a.f.writingMode===_.Be},uG=function(a,b){if(a.h)switch(b.writingMode){case _.qn:return["-y"];case _.Be:return["+x"];case _.Ce:return["-x"]}a=[];switch(b.writingMode){case _.qn:a=["+y","-y"];break;case _.Be:a=["+x","-x"];break;case _.Ce:a=["-x","+x"]}0>b.line&&(a=a.reverse());
7
- return a},vG=function(a){for(a.g=[];0<a.f.childNodes.length;)a.f.removeChild(a.f.childNodes[0]);a.a=fG(a.j.a)},wG=function(a,b){vG(a.g);a.j.unshift(b);for(const c of a.j)a.g.append(c)},xG=function(a,b,c){a=a.f;const d=a.viewportAnchorUnits;if(d===_.xn)return a.viewportAnchorY/100*c-a.regionAnchorY/100*b;if(0===d)return a.viewportAnchorY-a.regionAnchorY;throw Error(QF);},yG=function(a,b){a=`.${a.g} .clpp-text-container`;const c=`${a} .clpp-text-cue`;return b=b.replace(/::cue\((#[^)]+)\)/g,`${a} $1`).replace(/::cue\(([^)]+)\)/g,
8
- `${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,a)},zG=function(a,b){let c=!1;try{a.f.insertRule(b,0);const d=a.f.cssRules[0];d instanceof CSSStyleRule&&(c=d.selectorText.split(",").every(e=>0===e.trim().indexOf(`.${a.g} `)))}catch(d){}0<a.f.cssRules.length&&a.f.deleteRule(0);c||a.A.warn(`Ignoring the CSS rule because it's not safe: ${b}`);return c},AG=function(a){if(a.a){for(;0<
9
- a.a.cssRules.length;)a.a.deleteRule(0);a.j=[]}},BG=function(a){a=_.ef(a.getConfiguration().htmlcue||{});_.y(a.stretchSmpteImage)&&(a.stretchSmpteImage=!1);_.y(a.enableResizeObserver)&&(a.enableResizeObserver=!0);return a},HG=function(a,b){if((b||a.j)&&a.A){var c=a.l.getPosition();if(b||a.J!==c&&a.l.getState()===_.Lk)if(a.J=c,c=CG(a,c),b||(b=a.o,b=!(null===b&&null===c||null!==b&&null!==c&&b.start===c.start&&b.end===c.end)),b&&(a.o=c,DG(a),a.h&&(b="::cue {",a.getFontColor()&&(b+=`color: ${a.getFontColor()};`),
10
- a.getBackgroundColor()&&(b+=`background-color: ${a.getBackgroundColor()};`),a.getFontFamily()&&(b+=`font-family: ${a.getFontFamily()};`),a.getEdgeType()!==_.Uo&&(b+=`text-shadow: ${_.fn(a)};`),b+="}",AG(a.h),a.h.appendRule(b)),null!==c)){c=a.f.slice(c.start,c.end+1);for(const g of c){c=a;b=g;if(c.a){var d=c.a.a,e=null;switch(b.payloadType){case _.Je:e="clpp-text-vtt";break;case _.re:e=SF;break;case _.on:e=RF}e&&!d.classList.contains(e)&&_.fl(d,e)}d=fG(c.a.a);if(0===d.width||0===d.height)c.N.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.");
11
- else{ZF({fontSize:EG(c,b.containerRows)},c.a.a);d=null;e=b.payloadType===_.Je;var f=b.payloadType===_.re;b.region&&(e||f||b.backgroundImage)&&(c.B.has(b.region.id)?d=c.B.get(b.region.id):(d=new FG(b.region,{}),c.B.set(b.region.id,d),wG(c.a,d)));b=new GG(b,c.L,{});d?wG(d,b):wG(c.a,b)}}}}},IG=function(a){DG(a);a.J=null;a.o=null;a.f=[]},JG=function(a,b){return a.startTime<=b&&a.endTime>b},CG=function(a,b){var c=VF(a.f,d=>JG(d,b)?0:b!==d.startTime?b-d.startTime:b-d.endTime);if(-1===c)return null;{let d=
12
- c;for(;0<=d-1&&JG(a.f[d-1],b);)d--;for(;c+1<a.f.length&&JG(a.f[c+1],b);)c++;return{start:d,end:c}}},DG=function(a){a.B.clear();if(a.a){const b=a.a.a;b.classList.remove("clpp-text-vtt");b.classList.remove(SF);b.classList.remove(RF);a=a.a;vG(a.g);a.j=[]}},EG=function(a,b){const c=fG(a.a.a).height;if(null!==a.I)return a.getFontSize();if(null!==a.F)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*
13
- a)}px`},NG=class{parse(a){a={input:a};const b=_.hl(_.Gc),c=[];let d=b;for(var e;null!==(e=WF(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=KG[f];h?(h=_.hl(h),(f=LG[f])&&g&&h.setAttribute(f,g.trim()),g=h):g=null;!g||MG[g.localName]&&MG[g.localName]!==d.localName||(e[2]&&(g.className=e[2].substr(1).replace(/\./g," ")),c.push(e[1]),
14
- d.appendChild(g),d=g)}}else d.appendChild(document.createTextNode(YF(e)));return b}},KG={c:"c",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"v",lang:"lang"},LG={v:"voice",lang:"lang"},MG={rt:"ruby"},XF={"\x26amp;":"\x26","\x26lt;":"\x3c","\x26gt;":"\x3e","\x26lrm;":"\u200e","\x26rlm;":"\u200f","\x26nbsp;":"\u00a0"};var eG=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 OG=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 GG=class extends OG{constructor(a,b,c){super(a.id,"clpp-text-cue",c);this.j=b;this.f=a;this.g=!!this.f.backgroundImage}w(){return!this.g&&!(this.f.region&&this.f.region.displayAlign)}init(a){super.init(a);if(this.g)_.fl(this.a,"clpp-text-cue-image"),this.a.style.backgroundImage=`url("${this.f.backgroundImage}")`,this.j.stretchSmpteImage&&(this.a.style.backgroundSize="contain");else{var b=this.f;if(b.payloadType===_.re){var c=_.hl(_.Gc);c.innerHTML=b.payload;b=c}else b.payloadType===_.Je?b=(new NG).parse(b.payload):
15
- (c=_.hl(_.Gc),c.textContent=b.payload,b=c);_.fl(b,this.o);this.id&&(b.id=this.id);for(d of this.f.cssClassList)_.fl(b,d);ZF({writingMode:lG(this)},b);var d=b;this.a.appendChild(d);_.fl(this.a,"clpp-text-wrapper");for(var e of this.f.cssClassList)_.fl(this.a,`clpp-text-wrapper__${e}`);_.y(this.f.line)&&(this.f.lineInterpretation=_.rn,this.f.line=kG(this)?-1:0);e=lG(this);ZF({writingMode:e,webkitWritingMode:e,direction:UF,textAlign:mG(this)},this.a);if(!this.f.region||!this.f.region.displayAlign){e=
16
- nG(this,oG(this));ZF({position:"absolute",left:rG(this,e,null),right:qG(this)&&_.y(null)?$F(0,_.Qd):UF,top:sG(this,e,null),width:kG(this)?$F(this.f.size,"%"):UF,height:pG(this)||qG(this)?$F(this.f.size,"%"):UF},this.a);d=this.f;a=kG(this)?a.height:a.width;b=tG(this);if(d.lineInterpretation===_.rn)c=b*Math.round(d.line),Math.abs(c)>a&&(c=b*(0>d.line?0:-1)),0>c&&(c+=a);else{c=b/a*100;let f=d.line;switch(d.lineAlign){case _.mc:f-=c/2;break;case _.Oc:f-=c}c=Math.round(f/100*a)}qG(this)&&(c=a-c-b);a=c;
17
- ZF({left:rG(this,e,a),right:qG(this)&&_.y(a)?$F(0,_.Qd):UF,top:sG(this,e,a)},this.a)}}}m(){return _.hl(_.Gc)}};var PG=class{constructor(a,b){this.j=a;this.f=a.a;this.h=void 0===b?!1:b;this.a=fG(a.a);this.g=[]}append(a){const b=a.a;b.style.visibility=_.Uc;this.f.appendChild(b);a.h||a.init(this.a);if(a.w()){a:{var c=fG(a.a);var d=uG(this,a.f),e=tG(a);const g=gG(c);let h=null,k=0;for(const l of d){for(;jG(c,this.a,l)||iG(c,this.a)&&hG(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||iG(c,this.a))break a;
18
- 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=gG(c),k=d);c=gG(g)}c=h||g}ZF({top:$F(c.h-this.a.h,_.Qd),bottom:$F(this.a.a-c.a,_.Qd),left:$F(c.f-this.a.f,_.Qd),right:$F(this.a.g-c.g,_.Qd),height:$F(c.height,_.Qd),width:$F(c.width,_.Qd)},a.a)}b.style.visibility="visible";this.g.push(fG(a.a))}};var QG=class extends OG{constructor(a,b,c){super(a,b,c);this.g=null;this.j=[]}init(){this.g=new PG(this);this.h=!0}m(){const a=_.hl(_.Gc);_.fl(a,this.o);this.id&&(a.id=this.id);return a}};var FG=class extends QG{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 _.xn:b=b.width/100*a.width;break a;default:throw Error(QF);}}var c=this.f;var d=c.viewportAnchorUnits;if(d===_.xn)c=c.viewportAnchorX/100*a.width-c.regionAnchorX/100*b;else if(0===d)c=c.viewportAnchorX-c.regionAnchorX;else throw Error(QF);d=a.height;const e=xG(this,d,a.height);ZF(this.A,this.a);ZF({left:$F(c,_.Qd),top:$F(e,_.Qd),width:$F(b,
19
- _.Qd),height:$F(d,_.Qd)},this.a);this.f.writingMode&&ZF({display:"flex","flex-direction":this.f.writingMode},this.a);this.f.displayAlign&&ZF({"justify-content":this.f.displayAlign},this.a);for(var f of this.f.cssClassList)_.fl(this.a,f);a:switch(f=this.f,f.heightUnits){case 0:f=f.height;break a;case _.xn:f=f.height/100*a.height;break a;case 2:f=f.height;c=new GG(new _.un(0,1,"Lorem ipsum",_.on),{},{});b=c.a;this.a.appendChild(b);c.init(fG(this.a));c=b.getBoundingClientRect().height;this.a.removeChild(b);
20
- b=c;f*=b;break a;default:throw Error(QF);}a=xG(this,f,a.height);ZF({top:$F(a,_.Qd),height:$F(f,_.Qd)},this.a);this.g=new PG(this,!0);this.h=!0}ba(){return this.f.id}};var SG=class{constructor(a){this.A=new _.O("clpp.htmlcue.StyleManager");this.h=a.getSurface().getContainer();this.g=`clpp-video-${RG++}`;this.m=document.createElement(_.je);this.o=document.createElement(_.je);this.j=[];this.f=this.a=null;this.w=!1;a=document.styleSheets;document.head.appendChild(this.m);this.a=a[a.length-1];document.head.appendChild(this.o);this.f=a[a.length-1];this.f.disabled=!0;this.h&&_.fl(this.h,this.g)}appendRule(a){if(this.a&&!this.j.some(b=>b===a)){const b=yG(this,a);if(zG(this,
21
- b)){try{this.a.insertRule(b,this.a.cssRules.length)}catch(c){this.A.error(`An error occurred when adding a CSS rule: ${b}`)}this.j.push(a)}}}destroy(){const a=this;return _.v(function*(){a.w||(AG(a),document.head.removeChild(a.m),a.m=null,a.a=null,document.head.removeChild(a.o),a.o=null,a.f=null,a.h&&a.h.classList.remove(a.g));a.w=!0})}},RG=0;var TG=class extends _.Wo{constructor(a){super(a);this.N=new _.O(TF);this.l=a;this.L=BG(a);this.j=!1;this.f=[];this.A=a.getSurface().getContainer();this.D=new SG(a);this.h=new SG(a);this.a=new QG(null,"clpp-text-container",{});this.m=new _.Ro(a.getSurface(),this.V.bind(this));this.J=null;this.A?(this.A.appendChild(this.a.a),this.a.init(null)):this.N.warn("No container element! Subtitles will not appear. Please check your player surface configuration or switch to NativeTextDisplayer.");this.w=new _.wh(()=>
22
- {HG(this)});this.B=new Map;this.o=null}V(){HG(this,!0)}append(a,b){if(0!==a.length){for(const c of b)this.D.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.o=null;HG(this,!1)}}g(){HG(this,!0)}destroy(){const a=this;return _.v(function*(){IG(a);
23
- a.D&&(yield a.D.destroy(),a.D=null);a.h&&(yield a.h.destroy(),a.h=null);a.a&&(a.A.removeChild(a.a.a),a.a=null);a.m&&(a.m.stop(),a.m=null);a.w&&a.w.stop();a.j=!1})}remove(a,b){if(!this.a)return!1;this.f=this.f.filter(c=>c.startTime<a||c.endTime>=b);this.o=null;HG(this,!0);return!0}isTextVisible(){return this.j}setTextVisibility(a){this.j!==a&&((this.j=a)?(this.w.Qa(.25),this.L.enableResizeObserver&&this.m.start(),HG(this,!0)):(this.w.stop(),this.m.stop(),IG(this)))}};_.x(TF,TG);
24
- TG.prototype.setTextVisibility=TG.prototype.setTextVisibility;TG.prototype.isTextVisible=TG.prototype.isTextVisible;TG.prototype.remove=TG.prototype.remove;TG.prototype.destroy=TG.prototype.destroy;TG.prototype.append=TG.prototype.append;var UG=class{Y(a){return!!a.enableHtmlCue&&!_.Mh()}create(a){return new TG(a)}};UG.prototype.create=UG.prototype.create;UG.prototype.isSupported=UG.prototype.Y;_.x("clpp.htmlcue.HtmlCueComponent",class extends _.zo{f(){_.lk("html",new UG)}a(){}id(){return _.ke}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var UF="Unsupported unit",VF="clpp-text-plain",WF="clpp-text-ttml",XF="clpp.htmlcue.HtmlTextDisplayer",YF="initial",ZF=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},$F=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},bG=function(a){let b=null;for(;b=a.match(/&(amp|lt|gt|lrm|rlm|nbsp);/);)a=a.replace(b[0],c=>aG[c]);return a},cG=
2
+ function(a,b){for(const c in a)b.style[c]=a[c]},dG=function(a,b){return 0===a?"0":a+b},eG=function(a,b){return 1>Math.abs(a-b)||a<b},fG=function(a,b){return a<b&&1<Math.abs(a-b)},gG=function(a,b){return a>b&&1<Math.abs(a-b)},hG=function(a,b){return 1>Math.abs(a-b)||a>b},jG=function(a){const b=a.getBoundingClientRect();var c=getComputedStyle(a,null);const d=parseFloat(c.getPropertyValue("border-left-width"))||0,e=parseFloat(c.getPropertyValue("border-right-width"))||0;var f=parseFloat(c.getPropertyValue("border-top-width"))||
3
+ 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 iG(b.left+d,b.right+e,g,(b.bottom||g+f)+c,f,(b.width||a.offsetWidth)-d-e)},kG=function(a){return new iG(a.f,a.g,a.h,a.a,a.height,a.width)},lG=function(a,b){return b.some(c=>fG(a.f,c.g)&&gG(a.g,c.f)&&fG(a.h,c.a)&&gG(a.a,c.h))},mG=function(a,b){return hG(a.h,b.h)&&eG(a.a,b.a)&&hG(a.f,b.f)&&eG(a.g,b.g)},nG=function(a,b,c){switch(c){case "+x":return fG(a.f,b.f);case "-x":return gG(a.g,
4
+ b.g);case "+y":return fG(a.h,b.h);case "-y":return gG(a.a,b.a);default:throw Error("Unknown axis");}},oG=function(a){return a.f.writingMode===_.Jn},pG=function(a){switch(a.f.writingMode){case _.Jn:return"horizontal-tb";case _.De:return _.De;case _.Ee:return _.Ee;default:throw Error("Unknown writing mode");}},qG=function(a){switch(a.f.positionAlign){case _.fd:return _.cd;case "auto":case _.oc:return _.In;case _.gd:return _.Zd}return a.f.textAlign},rG=function(a,b){if(typeof a.f.position===_.p&&typeof a.f.size===
5
+ _.p)switch(b){case _.fd:return a.f.position;case "auto":case _.oc:return a.f.position-a.f.size/2;case _.gd:return a.f.position-a.f.size}return 0},sG=function(a){if(!a.f.positionAlign)switch(a.f.textAlign){case _.cd:case _.cd:return _.fd;case _.In:return _.oc;case _.Zd:case _.Zd:return _.gd}return a.f.positionAlign},vG=function(a,b,c){return(tG(a)||uG(a))&&_.mf(c)?dG(c,_.Sd):tG(a)&&_.y(c)?dG(0,_.Sd):oG(a)&&_.mf(b)?dG(b,"%"):YF},wG=function(a,b,c){return oG(a)&&_.mf(c)?dG(c,_.Sd):(tG(a)||uG(a))&&_.mf(b)?
6
+ dG(b,"%"):YF},xG=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 oG(a)?b:c},uG=function(a){return a.f.writingMode===_.Ee},tG=function(a){return a.f.writingMode===_.De},yG=function(a,b){if(a.h)switch(b.writingMode){case _.Jn:return["-y"];case _.De:return["+x"];case _.Ee:return["-x"]}a=[];switch(b.writingMode){case _.Jn:a=["+y","-y"];break;case _.De:a=["+x","-x"];break;case _.Ee:a=["-x","+x"]}0>b.line&&(a=a.reverse());
7
+ return a},zG=function(a){for(a.g=[];0<a.f.childNodes.length;)a.f.removeChild(a.f.childNodes[0]);a.a=jG(a.j.a)},AG=function(a,b){zG(a.g);a.j.unshift(b);for(const c of a.j)a.g.append(c)},BG=function(a,b,c){a=a.f;const d=a.viewportAnchorUnits;if(d===_.Qn)return a.viewportAnchorY/100*c-a.regionAnchorY/100*b;if(0===d)return a.viewportAnchorY-a.regionAnchorY;throw Error(UF);},DG=function(a,b){const c=document.createElement(_.le);c.title=b;const d=document.head;d.appendChild(c);CG(a,d,b);a.f.debug(`Created HTML style element style[title="${b}"]`);
8
+ return c.sheet},EG=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,a)},FG=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===
9
+ e.trim().indexOf(`.${a.j} `)))}catch(d){}0<a.g.cssRules.length&&a.g.deleteRule(0);return c},GG=function(a){if(null!=a.a){for(;0<a.a.cssRules.length;)a.a.deleteRule(0);a.o=[]}},CG=function(a,b,c){const d=new MutationObserver(e=>{e.forEach(f=>{f.removedNodes.forEach(g=>{g.title===c&&a.f.error(`PRESTOplay HTML style element style[title="${c}"] has `+"been unexpectedly removed! Some styles will not work!")})})});d.observe(b,{subtree:!1,childList:!0});a.w.push(()=>d.disconnect())},HG=function(a){a=_.gf(a.getConfiguration().htmlcue||
10
+ {});_.y(a.stretchSmpteImage)&&(a.stretchSmpteImage=!1);_.y(a.enableResizeObserver)&&(a.enableResizeObserver=!0);return a},NG=function(a,b){if((b||a.j)&&a.A){var c=a.l.getPosition();if(b||a.J!==c&&a.l.getState()===_.dl)if(a.J=c,c=IG(a,c),b||(b=a.o,b=!(null===b&&null===c||null!==b&&null!==c&&b.start===c.start&&b.end===c.end)),b&&(a.o=c,JG(a),a.m&&(b="::cue {",a.getFontColor()&&(b+=`color: ${a.getFontColor()};`),a.getBackgroundColor()&&(b+=`background-color: ${a.getBackgroundColor()};`),a.getFontFamily()&&
11
+ (b+=`font-family: ${a.getFontFamily()};`),a.getEdgeType()!==_.op&&(b+=`text-shadow: ${_.zn(a)};`),b+="}",GG(a.m),a.m.appendRule(b)),null!==c)){c=a.f.slice(c.start,c.end+1);for(const g of c){c=a;b=g;var d=c.a.a,e=null;switch(b.payloadType){case _.Le:e="clpp-text-vtt";break;case _.te:e=WF;break;case _.Hn:e=VF}e&&!d.classList.contains(e)&&_.xl(d,e);d=jG(c.a.a);if(0===d.width||0===d.height)c.N.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{cG({fontSize:KG(c,b.containerRows)},c.a.a);d=null;e=b.payloadType===_.Le;var f=b.payloadType===_.te;b.region&&(e||f||b.backgroundImage)&&(c.B.has(b.region.id)?d=c.B.get(b.region.id):(d=new LG(b.region,{}),c.B.set(b.region.id,d),AG(c.a,d)));b=new MG(b,c.L,{});d?AG(d,b):AG(c.a,b)}}}}},OG=function(a){JG(a);a.J=null;a.o=null;a.f=[]},PG=function(a,b){return a.startTime<=b&&a.endTime>b},IG=function(a,b){var c=ZF(a.f,d=>PG(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&&PG(a.f[d-1],b);)d--;for(;c+1<a.f.length&&PG(a.f[c+1],b);)c++;return{start:d,end:c}}},JG=function(a){a.B.clear();if(a.a){const b=a.a.a;b.classList.remove("clpp-text-vtt");b.classList.remove(WF);b.classList.remove(VF);a=a.a;zG(a.g);a.j=[]}},KG=function(a,b){const c=jG(a.a.a).height;if(null!==a.I)return a.getFontSize();if(null!==a.D)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`},TG=class{parse(a){a={input:a};const b=_.zl(_.Jc),c=[];let d=b;for(var e;null!==(e=$F(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=QG[f];h?(h=_.zl(h),(f=RG[f])&&g&&h.setAttribute(f,g.trim()),g=h):g=null;!g||SG[g.localName]&&SG[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(bG(e)));return b}},QG={c:"c",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"v",lang:"lang"},RG={v:"voice",lang:"lang"},SG={rt:"ruby"},aG={"\x26amp;":"\x26","\x26lt;":"\x3c","\x26gt;":"\x3e","\x26lrm;":"\u200e","\x26rlm;":"\u200f","\x26nbsp;":"\u00a0"};var iG=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 UG=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 MG=class extends UG{constructor(a,b,c){super(a.id,"clpp-text-cue",c);this.j=b;this.f=a;this.g=!!this.f.backgroundImage}w(){return!this.g&&!(this.f.region&&this.f.region.displayAlign)}init(a){super.init(a);if(this.g)_.xl(this.a,"clpp-text-cue-image"),this.a.style.backgroundImage=`url("${this.f.backgroundImage}")`,this.j.stretchSmpteImage&&(this.a.style.backgroundSize="contain");else{var b=this.f;if(b.payloadType===_.te){var c=_.zl(_.Jc);c.innerHTML=b.payload;b=c}else b.payloadType===_.Le?b=(new TG).parse(b.payload):
16
+ (c=_.zl(_.Jc),c.textContent=b.payload,b=c);_.xl(b,this.o);this.id&&(b.id=this.id);for(d of this.f.cssClassList)_.xl(b,d);cG({writingMode:pG(this)},b);var d=b;this.a.appendChild(d);_.xl(this.a,"clpp-text-wrapper");for(var e of this.f.cssClassList)_.xl(this.a,`clpp-text-wrapper__${e}`);_.y(this.f.line)&&(this.f.lineInterpretation=_.Kn,this.f.line=oG(this)?-1:0);e=pG(this);cG({writingMode:e,webkitWritingMode:e,direction:YF,textAlign:qG(this)},this.a);if(!this.f.region||!this.f.region.displayAlign){e=
17
+ rG(this,sG(this));cG({position:"absolute",left:vG(this,e,null),right:uG(this)&&_.y(null)?dG(0,_.Sd):YF,top:wG(this,e,null),width:oG(this)?dG(this.f.size,"%"):YF,height:tG(this)||uG(this)?dG(this.f.size,"%"):YF},this.a);d=this.f;a=oG(this)?a.height:a.width;b=xG(this);if(d.lineInterpretation===_.Kn)c=b*Math.round(d.line),Math.abs(c)>a&&(c=b*(0>d.line?0:-1)),0>c&&(c+=a);else{c=b/a*100;let f=d.line;switch(d.lineAlign){case _.oc:f-=c/2;break;case _.Rc:f-=c}c=Math.round(f/100*a)}uG(this)&&(c=a-c-b);a=c;
18
+ cG({left:vG(this,e,a),right:uG(this)&&_.y(a)?dG(0,_.Sd):YF,top:wG(this,e,a)},this.a)}}}m(){return _.zl(_.Jc)}};var VG=class{constructor(a,b){this.j=a;this.f=a.a;this.h=void 0===b?!1:b;this.a=jG(a.a);this.g=[]}append(a){const b=a.a;b.style.visibility=_.Zc;this.f.appendChild(b);a.h||a.init(this.a);if(a.w()){a:{var c=jG(a.a);var d=yG(this,a.f),e=xG(a);const g=kG(c);let h=null,k=0;for(const l of d){for(;nG(c,this.a,l)||mG(c,this.a)&&lG(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||mG(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=kG(c),k=d);c=kG(g)}c=h||g}cG({top:dG(c.h-this.a.h,_.Sd),bottom:dG(this.a.a-c.a,_.Sd),left:dG(c.f-this.a.f,_.Sd),right:dG(this.a.g-c.g,_.Sd),height:dG(c.height,_.Sd),width:dG(c.width,_.Sd)},a.a)}b.style.visibility="visible";this.g.push(jG(a.a))}};var WG=class extends UG{constructor(a,b,c){super(a,b,c);this.g=null;this.j=[]}init(){this.g=new VG(this);this.h=!0}m(){const a=_.zl(_.Jc);_.xl(a,this.o);this.id&&(a.id=this.id);return a}};var LG=class extends WG{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 _.Qn:b=b.width/100*a.width;break a;default:throw Error(UF);}}var c=this.f;var d=c.viewportAnchorUnits;if(d===_.Qn)c=c.viewportAnchorX/100*a.width-c.regionAnchorX/100*b;else if(0===d)c=c.viewportAnchorX-c.regionAnchorX;else throw Error(UF);d=a.height;const e=BG(this,d,a.height);cG(this.A,this.a);cG({left:dG(c,_.Sd),top:dG(e,_.Sd),width:dG(b,
20
+ _.Sd),height:dG(d,_.Sd)},this.a);this.f.writingMode&&cG({display:"flex","flex-direction":this.f.writingMode},this.a);this.f.displayAlign&&cG({"justify-content":this.f.displayAlign},this.a);for(var f of this.f.cssClassList)_.xl(this.a,f);a:switch(f=this.f,f.heightUnits){case 0:f=f.height;break a;case _.Qn:f=f.height/100*a.height;break a;case 2:f=f.height;c=new MG(new _.Nn(0,1,"Lorem ipsum",_.Hn),{},{});b=c.a;this.a.appendChild(b);c.init(jG(this.a));c=b.getBoundingClientRect().height;this.a.removeChild(b);
21
+ b=c;f*=b;break a;default:throw Error(UF);}a=BG(this,f,a.height);cG({top:dG(a,_.Sd),height:dG(f,_.Sd)},this.a);this.g=new VG(this,!0);this.h=!0}ba(){return this.f.id}};var YG=class{constructor(a,b){this.f=new _.O("clpp.htmlcue.StyleManager");this.w=[];this.m=a.getSurface().getContainer();this.j=`clpp-video-${XG++}`;this.h=b;this.o=[];this.a=DG(this,this.h);this.g=DG(this,`${this.h}-sandbox`);this.g.disabled=!0;this.m&&_.xl(this.m,this.j);this.f.debug(`Stylesheet ${this.h} has been created.`)}appendRule(a){if(null!=this.a&&!this.o.some(b=>b===a)){const b=EG(this,a);if(FG(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.o.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 _.v(function*(){null!=a.a&&(a.w.forEach(b=>b()),a.w=[],GG(a),document.head.removeChild(a.a.ownerNode),document.head.removeChild(a.g.ownerNode),a.a=null,a.g=null,a.m&&a.m.classList.remove(a.j),a.f.debug(`Stylesheet ${a.h} has been destroyed.`))})}},XG=0;var ZG=class extends _.qp{constructor(a){super(a);this.N=new _.O(XF);this.l=a;this.L=HG(a);this.j=!1;this.f=[];this.A=a.getSurface().getContainer();this.h=new YG(a,"CLPP Subtitle Styles");this.m=new YG(a,"CLPP Custom Subtitle Styles");this.a=new WG(null,"clpp-text-container",{});this.w=new _.lp(a.getSurface(),this.V.bind(this));this.J=null;this.A?(this.A.appendChild(this.a.a),this.a.init(null)):this.N.warn("No container element! Subtitles will not appear. Please check your player surface configuration or switch to NativeTextDisplayer.");
23
+ this.F=new _.zh(()=>{NG(this)});this.B=new Map;this.o=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.o=null;NG(this,!1)}}g(){null==this.h||NG(this,!0)}destroy(){const a=
24
+ this;return _.v(function*(){null!=a.h&&(OG(a),a.F.stop(),yield a.h.destroy(),a.h=null,yield a.m.destroy(),a.m=null,a.A.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.o=null;NG(this,!0);return!0}isTextVisible(){return this.j}setTextVisibility(a){null!=this.h&&this.j!==a&&((this.j=a)?(this.F.Qa(.25),this.L.enableResizeObserver&&this.w.start(),NG(this,!0)):(this.F.stop(),this.w.stop(),OG(this)))}V(){NG(this,
25
+ !0)}};_.x(XF,ZG);ZG.prototype.setTextVisibility=ZG.prototype.setTextVisibility;ZG.prototype.isTextVisible=ZG.prototype.isTextVisible;ZG.prototype.remove=ZG.prototype.remove;ZG.prototype.destroy=ZG.prototype.destroy;ZG.prototype.append=ZG.prototype.append;var $G=class{Y(a){return!!a.enableHtmlCue&&!_.Ph()}create(a){return new ZG(a)}};$G.prototype.create=$G.prototype.create;$G.prototype.isSupported=$G.prototype.Y;_.x("clpp.htmlcue.HtmlCueComponent",class extends _.So{f(){_.Gk("html",new $G)}a(){}id(){return _.me}});};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 AF="clpp.ima.AdsManagerFactory",BF=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===_.ac?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
- _.ac&&(b.useStyledLinearAds=a.useStyledLinearAds);b.uiElements=Array.isArray(a.uiElements)?a.uiElements:[];return b},CF=function(a){const b=a.a,c=a.w,d=google.ima.AdEvent.Type;c.on(b,d.LOADED,a.T.bind(a));c.on(b,d.CONTENT_PAUSE_REQUESTED,a.ec.bind(a));c.on(b,d.STARTED,a.W.bind(a));c.on(b,d.LOG,a.ua.bind(a));c.on(b,d.AD_PROGRESS,a.Ta.bind(a));c.on(b,d.AD_BUFFERING,a.ga.bind(a));c.on(b,d.FIRST_QUARTILE,a.R.bind(a));c.on(b,d.MIDPOINT,a.Ra.bind(a));c.on(b,d.THIRD_QUARTILE,a.aa.bind(a));c.on(b,d.PAUSED,
3
- a.Sa.bind(a));c.on(b,d.RESUMED,a.Ua.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.na.bind(a));c.on(b,d.CONTENT_RESUME_REQUESTED,a.hc.bind(a));c.on(b,d.ALL_ADS_COMPLETED,a.Jb.bind(a))},DF=function(a,b){const c=b?a.ca.create(b.getErrorCode()):null;a.l.onError(new _.H(1,9,10003,{errorType:c},b))},EF=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 _.F(b,d))},FF=function(a){a.A=null;EF(a,_.Cb);
4
- a.m&&a.l.getSurface().hide(a.m)},GF=function(a){_.gl(a.j,{visibility:"visible"})},IF=function(a){return _.v(function*(){a.I.initialize();const b=!!a.l.getConfiguration().muted;(yield a.F.canPlay(b))?HF(a):(EF(a,_.Zb),a.L.warn(_.ia))})},JF=function(a,b){return _.v(function*(){a.I.initialize();yield b.play();HF(a)})},HF=function(a){a.a.init(a.j.offsetWidth,a.j.offsetHeight,google.ima.ViewMode.NORMAL);a.a.start();a.D=!0},KF=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}gb(){return"Google IMA SDK"}hb(){return google.ima.VERSION}mb(){return 0}ba(){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()}Tb(){return this.f?
6
- this.f.getIsBumper():!1}zb(){let a=null;const b=this.a,c=Object.keys(b).find(d=>typeof b[d]===_.td&&typeof b[d].clickThroughUrl===_.he);c&&(a=b[c].clickThroughUrl);return a}getMediaUrl(){return this.a.getMediaUrl()}jb(){return this.a.getVastMediaWidth()}ib(){return this.a.getVastMediaHeight()}Xa(){return this.a.getVastMediaBitrate()}Ja(){return this.g?2:this.h?1:0}getPodIndex(){return this.f?this.f.getPodIndex():0}Ab(){return this.f?this.f.getTimeOffset():0}Bb(){return this.f?this.f.getAdPosition():
7
- 1}lb(){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.lb;V.prototype.getPositionInSequence=V.prototype.Bb;
8
- V.prototype.getPodTimeOffset=V.prototype.Ab;V.prototype.getPodIndex=V.prototype.getPodIndex;V.prototype.getPodType=V.prototype.Ja;V.prototype.getMediaBitrate=V.prototype.Xa;V.prototype.getMediaHeight=V.prototype.ib;V.prototype.getMediaWidth=V.prototype.jb;V.prototype.getMediaUrl=V.prototype.getMediaUrl;V.prototype.getClickThroughUrl=V.prototype.zb;V.prototype.isBumper=V.prototype.Tb;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.ba;V.prototype.getTechnology=V.prototype.mb;V.prototype.getAdManagerVersion=V.prototype.hb;V.prototype.getAdManagerName=V.prototype.gb;var LF=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 MF=class{constructor(a){this.a=a}getCuePoints(){return this.a}Cb(){return 0<=this.a.indexOf(0)||0===this.a.length}Ya(){return 0<=this.a.indexOf(-1)}};MF.prototype.hasPostroll=MF.prototype.Ya;MF.prototype.hasPreroll=MF.prototype.Cb;MF.prototype.getCuePoints=MF.prototype.getCuePoints;var NF=class{constructor(a){this.l=a;this.j=a.getSurface().getMedia();a=this.l.getConfiguration();this.J=a=_.ef(a.ima||{});this.m=this.l.Pb("ima").ic();this.I=this.l.Pb("ima").g;this.o=this.l.Pb("ima").a;this.F=new _.To;this.L=new _.O("clpp.ima");this.h=this.a=null;this.f=new _.Pj;this.D=!1;this.w=new _.mn;this.ca=new LF;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.wb.bind(this));a.on(this.o,b,this.vb.bind(this));a.one(this.j,_.Pc,this.Kb.bind(this))}}wb(a){this.a=a.getAdsManager(this.j,BF(this));this.a.isCustomPlaybackUsed()?(this.L.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 _.Ro(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 MF(a),
11
- this.l.trigger(new _.F(_.Fb,{adsTimeline:this.g})),CF(this));this.f.resolve()}vb(a){DF(this,a.getError());this.f.resolve()}ec(a){const b=this;return _.v(function*(){b.C=!0;yield b.l.pause();_.gl(b.j,{visibility:_.Uc});EF(b,_.ob,a);b.h.start()})}T(a){a.getAd().isLinear()?EF(this,_.vb,a):(this.a.discardAdBreak(),this.B||(this.B=!0,this.l.play()))}W(a){this.A=a.getAd().getDuration();EF(this,_.Bb,a);this.l.getSurface().show(this.m)}ua(a){a=a.getAdData();DF(this,a?a.adError:null);FF(this)}Ta(a){EF(this,
12
- _.yb,a)}ga(a){EF(this,_.qb,a)}R(a){EF(this,_.tb,a)}Ra(a){EF(this,_.wb,a)}aa(a){EF(this,_.Db,a)}Sa(a){EF(this,_.xb,a)}Ua(a){EF(this,_.zb,a)}N(a){this.pause();EF(this,_.rb,a)}V(a){EF(this,_.Ab,a);FF(this)}S(a){EF(this,_.ub,a)}na(a){EF(this,_.sb,a);FF(this)}hc(){this.B=!0;if(!this.C)return this.l.play();this.C=!1;this.h.stop();this.l.isEnded()||this.l.play();EF(this,_.pb);GF(this)}Jb(){this.H=!0}Kb(){this.K=!0;this.o.contentComplete()}load(){const a=this;return _.v(function*(){var b=a.l;const c=a.J;
13
- try{if(typeof c.adTagUrl!==_.he)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 _.v(function*(){b.a&&b.g&&!b.D?b.g.Cb()?yield IF(b):yield JF(b,a):yield a.play()})}resume(){this.a&&this.a.resume()}pause(){this.a&&
14
- this.a.pause()}skip(){this.a&&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.Ya()&&!this.H?(this.w.one(this.a,google.ima.AdEvent.Type.ALL_ADS_COMPLETED,()=>{a();this.m&&this.l.getSurface().hide(this.m)}),_.Hf(this.w,this.a,[google.ima.AdEvent.Type.LOADED,google.ima.AdEvent.Type.STARTED],
15
- ()=>{this.a&&this.a.discardAdBreak()})):a();this.a.discardAdBreak();this.o.contentComplete()})).then(()=>{GF(this);this.w.release();this.h&&(this.h.stop(),this.h=null);this.a&&(this.a.destroy(),this.a=null)})}};NF.prototype.getPosition=NF.prototype.getPosition;NF.prototype.setVolume=NF.prototype.setVolume;NF.prototype.getVolume=NF.prototype.getVolume;NF.prototype.skip=NF.prototype.skip;NF.prototype.pause=NF.prototype.pause;NF.prototype.resume=NF.prototype.resume;var OF=class extends _.bp{constructor(){super();this.a=this.g=this.f=null}onPlayerCreated(a){if(KF())return a.onError(new _.H(1,9,1E4));this.f=_.el(_.Gc,{"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(_.la);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)}af(){return this.a}Ze(){return this.g}ic(){return this.f}id(){return"ima"}};_.x("clpp.ima.ImaPlugin",OF);OF.prototype.getAdContainer=OF.prototype.ic;OF.prototype.getAdDisplayContainer=OF.prototype.Ze;OF.prototype.getAdsLoader=OF.prototype.af;OF.Id="ima";OF.isSdkMissing=KF;_.Ll(new class{create(){return new OF}});var PF=class{constructor(){this.a=new _.O(AF)}name(){return AF}Y(a,b){return a.namespace()===_.rc?!1:KF()?(this.a.warn("IMA SDK is not loaded."),!1):!(!b||!b.ima)}create(a){return new NF(a)}};PF.prototype.create=PF.prototype.create;PF.prototype.isSupported=PF.prototype.Y;PF.prototype.name=PF.prototype.name;_.al(new PF);};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var EF="clpp.ima.AdsManagerFactory",FF=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===_.cc?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
+ _.cc&&(b.useStyledLinearAds=a.useStyledLinearAds);b.uiElements=Array.isArray(a.uiElements)?a.uiElements:[];return b},GF=function(a){const b=a.a,c=a.w,d=google.ima.AdEvent.Type;c.on(b,d.LOADED,a.T.bind(a));c.on(b,d.CONTENT_PAUSE_REQUESTED,a.gc.bind(a));c.on(b,d.STARTED,a.W.bind(a));c.on(b,d.LOG,a.ua.bind(a));c.on(b,d.AD_PROGRESS,a.Ta.bind(a));c.on(b,d.AD_BUFFERING,a.ga.bind(a));c.on(b,d.FIRST_QUARTILE,a.R.bind(a));c.on(b,d.MIDPOINT,a.Ra.bind(a));c.on(b,d.THIRD_QUARTILE,a.aa.bind(a));c.on(b,d.PAUSED,
3
+ a.Sa.bind(a));c.on(b,d.RESUMED,a.Ua.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.na.bind(a));c.on(b,d.CONTENT_RESUME_REQUESTED,a.jc.bind(a));c.on(b,d.ALL_ADS_COMPLETED,a.Kb.bind(a))},HF=function(a,b){const c=b?a.ca.create(b.getErrorCode()):null;a.l.onError(new _.G(1,9,10003,{errorType:c},b))},IF=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 _.B(b,d))},JF=function(a){a.A=null;IF(a,_.Eb);
4
+ a.m&&a.l.getSurface().hide(a.m)},KF=function(a){_.yl(a.j,{visibility:"visible"})},MF=function(a){return _.v(function*(){a.I.initialize();const b=!!a.l.getConfiguration().muted;(yield a.F.canPlay(b))?LF(a):(IF(a,_.ac),a.L.warn(_.ia))})},NF=function(a,b){return _.v(function*(){a.I.initialize();yield b.play();LF(a)})},LF=function(a){a.a.init(a.j.offsetWidth,a.j.offsetHeight,google.ima.ViewMode.NORMAL);a.a.start();a.D=!0},OF=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}hb(){return"Google IMA SDK"}ib(){return google.ima.VERSION}nb(){return 0}ba(){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()}Ub(){return this.f?
6
+ this.f.getIsBumper():!1}Ab(){let a=null;const b=this.a,c=Object.keys(b).find(d=>typeof b[d]===_.wd&&typeof b[d].clickThroughUrl===_.je);c&&(a=b[c].clickThroughUrl);return a}getMediaUrl(){return this.a.getMediaUrl()}kb(){return this.a.getVastMediaWidth()}jb(){return this.a.getVastMediaHeight()}Ya(){return this.a.getVastMediaBitrate()}Ka(){return this.g?2:this.h?1:0}getPodIndex(){return this.f?this.f.getPodIndex():0}Bb(){return this.f?this.f.getTimeOffset():0}Cb(){return this.f?this.f.getAdPosition():
7
+ 1}mb(){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.mb;V.prototype.getPositionInSequence=V.prototype.Cb;
8
+ V.prototype.getPodTimeOffset=V.prototype.Bb;V.prototype.getPodIndex=V.prototype.getPodIndex;V.prototype.getPodType=V.prototype.Ka;V.prototype.getMediaBitrate=V.prototype.Ya;V.prototype.getMediaHeight=V.prototype.jb;V.prototype.getMediaWidth=V.prototype.kb;V.prototype.getMediaUrl=V.prototype.getMediaUrl;V.prototype.getClickThroughUrl=V.prototype.Ab;V.prototype.isBumper=V.prototype.Ub;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.ba;V.prototype.getTechnology=V.prototype.nb;V.prototype.getAdManagerVersion=V.prototype.ib;V.prototype.getAdManagerName=V.prototype.hb;var PF=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 QF=class{constructor(a){this.a=a}getCuePoints(){return this.a}Db(){return 0<=this.a.indexOf(0)||0===this.a.length}Za(){return 0<=this.a.indexOf(-1)}};QF.prototype.hasPostroll=QF.prototype.Za;QF.prototype.hasPreroll=QF.prototype.Db;QF.prototype.getCuePoints=QF.prototype.getCuePoints;var RF=class{constructor(a){this.l=a;this.j=a.getSurface().getMedia();a=this.l.getConfiguration();this.J=a=_.gf(a.ima||{});this.m=this.l.Qb("ima").kc();this.I=this.l.Qb("ima").g;this.o=this.l.Qb("ima").a;this.F=new _.np;this.L=new _.O("clpp.ima");this.h=this.a=null;this.f=new _.fk;this.D=!1;this.w=new _.Fn;this.ca=new PF;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.xb.bind(this));a.on(this.o,b,this.wb.bind(this));a.one(this.j,_.Sc,this.Lb.bind(this))}}xb(a){this.a=a.getAdsManager(this.j,FF(this));this.a.isCustomPlaybackUsed()?(this.L.warn("IMA plugin does not work correctly right now on platforms with single video element. Disposing."),this.l.onError(new _.G(1,9,10002)),this.dispose()):(this.h=new _.lp(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 QF(a),
11
+ this.l.trigger(new _.B(_.Hb,{adsTimeline:this.g})),GF(this));this.f.resolve()}wb(a){HF(this,a.getError());this.f.resolve()}gc(a){const b=this;return _.v(function*(){b.C=!0;yield b.l.pause();_.yl(b.j,{visibility:_.Zc});IF(b,_.qb,a);b.h.start()})}T(a){a.getAd().isLinear()?IF(this,_.xb,a):(this.a.discardAdBreak(),this.B||(this.B=!0,this.l.play()))}W(a){this.A=a.getAd().getDuration();IF(this,_.Db,a);this.l.getSurface().show(this.m)}ua(a){a=a.getAdData();HF(this,a?a.adError:null);JF(this)}Ta(a){IF(this,
12
+ _.Ab,a)}ga(a){IF(this,_.sb,a)}R(a){IF(this,_.vb,a)}Ra(a){IF(this,_.yb,a)}aa(a){IF(this,_.Fb,a)}Sa(a){IF(this,_.zb,a)}Ua(a){IF(this,_.Bb,a)}N(a){this.pause();IF(this,_.tb,a)}V(a){IF(this,_.Cb,a);JF(this)}S(a){IF(this,_.wb,a)}na(a){IF(this,_.ub,a);JF(this)}jc(){this.B=!0;if(!this.C)return this.l.play();this.C=!1;this.h.stop();this.l.isEnded()||this.l.play();IF(this,_.rb);KF(this)}Kb(){this.H=!0}Lb(){this.K=!0;this.o.contentComplete()}load(){const a=this;return _.v(function*(){var b=a.l;const c=a.J;
13
+ try{if(typeof c.adTagUrl!==_.je)throw new _.G(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 _.v(function*(){b.a&&b.g&&!b.D?b.g.Db()?yield MF(b):yield NF(b,a):yield a.play()})}resume(){this.a&&this.a.resume()}pause(){this.a&&
14
+ this.a.pause()}skip(){this.a&&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.Za()&&!this.H?(this.w.one(this.a,google.ima.AdEvent.Type.ALL_ADS_COMPLETED,()=>{a();this.m&&this.l.getSurface().hide(this.m)}),_.Kf(this.w,this.a,[google.ima.AdEvent.Type.LOADED,google.ima.AdEvent.Type.STARTED],
15
+ ()=>{this.a&&this.a.discardAdBreak()})):a();this.a.discardAdBreak();this.o.contentComplete()})).then(()=>{KF(this);this.w.release();this.h&&(this.h.stop(),this.h=null);this.a&&(this.a.destroy(),this.a=null)})}};RF.prototype.getPosition=RF.prototype.getPosition;RF.prototype.setVolume=RF.prototype.setVolume;RF.prototype.getVolume=RF.prototype.getVolume;RF.prototype.skip=RF.prototype.skip;RF.prototype.pause=RF.prototype.pause;RF.prototype.resume=RF.prototype.resume;var SF=class extends _.up{constructor(){super();this.a=this.g=this.f=null}onPlayerCreated(a){if(OF())return a.onError(new _.G(1,9,1E4));this.f=_.wl(_.Jc,{"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(_.la);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)}cf(){return this.a}af(){return this.g}kc(){return this.f}id(){return"ima"}};_.x("clpp.ima.ImaPlugin",SF);SF.prototype.getAdContainer=SF.prototype.kc;SF.prototype.getAdDisplayContainer=SF.prototype.af;SF.prototype.getAdsLoader=SF.prototype.cf;SF.Id="ima";SF.isSdkMissing=OF;_.cm(new class{create(){return new SF}});var TF=class{constructor(){this.a=new _.O(EF)}name(){return EF}Y(a,b){return a.namespace()===_.tc?!1:OF()?(this.a.warn("IMA SDK is not loaded."),!1):!(!b||!b.ima)}create(a){return new RF(a)}};TF.prototype.create=TF.prototype.create;TF.prototype.isSupported=TF.prototype.Y;TF.prototype.name=TF.prototype.name;_.tl(new TF);};f.call(g, window);