@castlabs/prestoplay 6.25.2 → 6.27.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 (69) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +5 -5
  3. package/cjs/cl.adobe.js +3 -3
  4. package/cjs/cl.airplay.js +3 -3
  5. package/cjs/cl.broadpeak.js +7 -7
  6. package/cjs/cl.cast.js +115 -114
  7. package/cjs/cl.conviva.js +32 -32
  8. package/cjs/cl.core.js +620 -620
  9. package/cjs/cl.crypto.js +9 -9
  10. package/cjs/cl.dash.js +89 -88
  11. package/cjs/cl.externs.js +89 -51
  12. package/cjs/cl.freewheel.js +25 -25
  13. package/cjs/cl.hls.js +79 -77
  14. package/cjs/cl.hlssmpte.js +6 -6
  15. package/cjs/cl.htmlcue.js +30 -30
  16. package/cjs/cl.ima.js +24 -24
  17. package/cjs/cl.mediatailor.js +3 -3
  18. package/cjs/cl.mse.js +351 -336
  19. package/cjs/cl.muxdata.js +15 -15
  20. package/cjs/cl.onboard.js +3 -3
  21. package/cjs/cl.persistent.js +15 -15
  22. package/cjs/cl.playlist.js +6 -6
  23. package/cjs/cl.sessions.js +16 -16
  24. package/cjs/cl.simid.js +17 -17
  25. package/cjs/cl.smooth.js +72 -72
  26. package/cjs/cl.thumbnails.js +26 -26
  27. package/cjs/cl.tizen.js +73 -72
  28. package/cjs/cl.ttml.js +29 -29
  29. package/cjs/cl.verimatrix.js +5 -5
  30. package/cjs/cl.vimond.js +12 -12
  31. package/cjs/cl.vr.js +19 -19
  32. package/cjs/cl.vtt.js +14 -14
  33. package/cjs/cl.yospace.js +4 -4
  34. package/cjs/cl.youbora.js +39 -37
  35. package/cjs/polyfill.min.js +15 -3
  36. package/cl.adobe.js +3 -3
  37. package/cl.airplay.js +3 -3
  38. package/cl.broadpeak.js +5 -5
  39. package/cl.cast.js +92 -90
  40. package/cl.conviva.js +27 -27
  41. package/cl.core.js +496 -500
  42. package/cl.crypto.js +9 -9
  43. package/cl.dash.js +82 -82
  44. package/cl.externs.js +89 -51
  45. package/cl.freewheel.js +19 -19
  46. package/cl.hls.js +80 -80
  47. package/cl.hlssmpte.js +5 -5
  48. package/cl.htmlcue.js +26 -26
  49. package/cl.ima.js +17 -17
  50. package/cl.mediatailor.js +3 -3
  51. package/cl.mse.js +305 -294
  52. package/cl.muxdata.js +13 -13
  53. package/cl.onboard.js +4 -4
  54. package/cl.persistent.js +11 -11
  55. package/cl.playlist.js +5 -5
  56. package/cl.sessions.js +10 -10
  57. package/cl.simid.js +14 -14
  58. package/cl.smooth.js +60 -60
  59. package/cl.thumbnails.js +19 -19
  60. package/cl.tizen.js +57 -57
  61. package/cl.ttml.js +22 -22
  62. package/cl.verimatrix.js +4 -4
  63. package/cl.vimond.js +8 -8
  64. package/cl.vr.js +15 -15
  65. package/cl.vtt.js +12 -12
  66. package/cl.yospace.js +3 -3
  67. package/cl.youbora.js +29 -28
  68. package/package.json +3 -3
  69. package/typings.d.ts +124 -3
package/cl.muxdata.js CHANGED
@@ -1,13 +1,13 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var eB=function(a){switch(a.type){case 1:return bB;case 2:return cB;case 3:return dB}},gB=function(a){const b=Object.keys(a).find(c=>fB.includes(c.toLowerCase()));return void 0!==b?a[b]:void 0},iB=function(a){let b={debug:!0,data:hB(a)};a.f&&a.f.muxOptionsOverride&&_.$g(a.f.muxOptionsOverride)&&(b=_.Wg(b,a.f.muxOptionsOverride));b=_.Wg(b,{getPlayheadTime:()=>1E3*a.m.getPosition(),getStateData:()=>{{a.g.debug("getStateData()");var c=a.m.getLoadedSource(),d=a.m.getTrackManager();const f=
2
- a.m.getSurface();var e={player_is_paused:a.m.isPaused(),player_is_fullscreen:f.isFullscreen(),video_source_duration:1E3*a.m.getDuration(),player_autoplay_on:!!a.m.getConfiguration().autoplay};if(c){const k=new _.mm(c.url);e.video_source_url=_.Kj(k);e.video_source_mime_type=c.type;c.name&&(e.video_title=c.name)}if(c=f.getContainer())e.player_width=c.offsetWidth,e.player_height=c.offsetHeight;(c=a.m.getSurface().getMedia())?c={videoWidth:c.videoWidth,videoHeight:c.videoHeight}:(c=a.m.getTrackManager().na(),
3
- c={videoWidth:c.width,videoHeight:c.height});const {videoWidth:g,videoHeight:h}=c;a.g.debug(`Video dimensions: ${g}x${h}`);g&&h&&(e.video_source_height=g,e.video_source_width=h);(d=d.qa())&&d.language&&(e.player_language_code=d.language)}return e}});a.g.debug("Mux SDK options",b);return b},jB=function(a){_.Dh(a.a);a.j.xd(a.F);a.j.me(a.C)},hB=function(a){const b={env_key:a.f.envKey,video_title:a.o&&a.o.name||"",player_name:_.qa,player_software_name:_.qa,player_software_version:_.ea,player_mux_plugin_name:"CastlabsPlayer built-in Mux Plugin",
4
- player_mux_plugin_version:_.ea};(a=a.m.getConfiguration().viewerId)&&(b.viewer_user_id=a);return b},kB=function(a){a.a.on(a.m,_.Zf,()=>{const b={player_playhead_time:1E3*a.m.getPosition()};a.emit(_.Zf,b)});a.a.on(a.m,_.Re,()=>a.emit(_.Re));a.a.on(a.m,_.Kc,a.G.bind(a));a.a.on(a.m,_.Kf,a.I.bind(a));a.a.on(a.m,_.jg,()=>a.emit(_.Cf));a.a.on(a.m,_.ig,()=>a.emit(_.Bf));a.a.on(a.m,_.q,a.H.bind(a));a.a.on(a.m,_.Rb,()=>a.emit("adbreakstart"));a.a.on(a.m,_.Sb,()=>a.emit("adbreakend"));a.a.on(a.m,_.jc,()=>{a.emit("adplay");
5
- a.emit("adplaying")});a.a.on(a.m,_.cc,()=>a.emit("adpause"));a.a.on(a.m,_.ec,()=>{a.emit("adplay");a.emit("adplaying")});a.a.on(a.m,_.lc,()=>a.emit("adended"));a.a.on(a.m,_.Wb,()=>a.emit("adfirstquartile"));a.a.on(a.m,_.bc,()=>a.emit("admidpoint"));a.a.on(a.m,_.mc,()=>a.emit("adthirdquartile"));a.j.Gc(a.F);a.j.Jd(a.C);a.a.on(a.m,_.q,b=>{if((b=b.detail)&&1===b.category){var c=b.data;c=c&&c.request;if(void 0!==c&&!0===(1===c.type||2===c.type||3===c.type))if(7001===b.code){b=c;c=b.requestStartTimestamp;
6
- var d=new _.mm(b.uris[b.uriIndex]);b={request_start:c,request_type:eB(b),request_hostname:d.a};a.g.debug("onRequestCanceled()","Track event: requestcanceled",b);a.emit("requestcanceled",b)}else{{d=c.requestStartTimestamp;const f=new _.mm(c.uris[c.uriIndex]);var e=b.data;e=void 0===e?-1:void 0!==e.response?e.response.status:void 0!==e.status?e.status:-1;b={request_start:d,request_type:eB(c),request_hostname:f.a,request_error:`${eB(c)}${"LoadError"}`,request_error_code:e,request_error_text:b.toString()};
7
- a.g.debug("onRequestFailed()","Track event: requestfailed",b);a.emit("requestfailed",b)}}}})},lB=function(a,b){a.trigger(new _.F(_.q,{detail:b}))},mB=function(a){return!_.B(a)&&typeof a.init===_.Yd&&typeof a.emit===_.Yd},bB="manifest",cB="media",dB="encryption",fB=["x-request-id","cf-ray","x-amz-cf-id","x-akamai-request-id"];var nB=class{constructor(a,b){this.m=a;this.o=this.f=null;this.B=("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6);this.a=new _.Nt;this.g=b;this.A=this.l=this.h=!1;this.w=null;this.j=a.getNetworkEngine();this.F=this.K.bind(this);this.C=this.J.bind(this)}initialize(a,b,c){this.f=a;this.o=b;this.w=c;if(!this.h){try{this.h=!0,this.w.init(this.B,iB(this))}catch(d){throw this.h=!1,jB(this),new _.I(1,9,9302,null,d);}this.emit("playerready")}this.l&&!this.A&&(a=hB(this),this.emit("videochange",
8
- a),this.l=!1);kB(this)}release(){this.g.debug("release()");this.l?this.g.debug(_.ia):(jB(this),this.l=!0,this.o=this.f=null)}destroy(){this.g.debug(_.Ad);this.A?this.g.debug(_.ha):(this.A=!0,this.emit("destroy"))}emit(a,b){if(null===this.w)throw new _.I(1,9,9301);this.w.emit(this.B,a,b)}G(a){this.g.debug(_.De);var b=a.detail;a=this.m.getTrackManager();b&&b.bandwidth&&(b=b.bandwidth,(a=a.Ma())&&a.bandwidth&&(b+=a.bandwidth),this.emit("renditionchange",{video_source_bitrate:b}))}I(a){this.g.debug(_.Ie);
9
- switch(a.detail.currentState){case _.Uo:this.m.getConfiguration().autoplay&&this.emit(_.Re);break;case _.Wo:this.emit(_.bf);break;case _.Vo:this.emit(_.Ne);break;case _.Lo:this.emit(_.Sd)}}H(a){this.g.debug(_.Fe);if(this.h&&(a=a.detail||null))if(10003===a.code)this.emit("aderror");else if(a.severity===_.G){var b=a.message||"Player error";if(1===a.category||6100===a.code||6007===a.code)b="Download error",6100===a.code?b="Certificate request error":6007===a.code&&(b="License request error"),b=`${b} castlabs-error-data:${JSON.stringify(a.data)}`;
10
- this.emit(_.q,{player_error_code:a.code,player_error_message:b})}}K(a){var b=a.request;if(b=void 0!==b&&!0===(1===b.type||2===b.type||3===b.type))b=a.status,b=void 0!==b&&200<=b&&299>=b;if(b){{b=a.request;const e=a.headers,f=b.bytesLoaded,g=b.requestStartTimestamp;var c=b.startTime,d=b.endTime;const h=g+a.responseStartMs;a=g+a.timeMs;c=c&&d?d-c:void 0;d=new _.mm(b.uris[b.uriIndex]);a={request_start:g,request_type:eB(b),request_hostname:d.a,request_id:gB(e),request_bytes_loaded:f,request_response_start:h,
11
- request_response_end:a,request_response_headers:e,request_media_duration:c,request_url:_.Kj(d)};this.g.debug("onRequestCompleted()","Track event: requestcompleted",a);this.emit("requestcompleted",a)}}}J(a){a.requestStartTimestamp=Date.now()}};var oB=class extends _.Pv{constructor(){super();this.f=this.m=null;this.a=!1;this.g=new _.S("clpp.muxdata")}onPlayerCreated(a){this.m=a;this.f=new nB(a,this.g)}onContentWillLoad(a,b){var c=a.getConfiguration();c=_.Xg(c.muxdata);try{var d=[];typeof c===_.Ce&&(c.envKey||d.push("envKey"));if(0<d.length)throw new _.I(1,9,9300,{missingKeys:d});{const f=a.getConfiguration();d=null;if(this.a=!_.B(f.muxdata)&&typeof f.muxdata===_.Ce){const g=f.muxdata;d=mB(g.muxLib)?g.muxLib:window.mux;if(!mB(d)){this.g.warn("Mux SDK is not loaded. Will do nothing.");
12
- this.a=!1;const h=new _.I(1,9,9301);lB(a,h)}}else this.g.debug("Mux plugin is loaded but not configured. Will do nothing.");var e=d}null!==e&&this.f.initialize(c,b,e)}catch(f){this.a=!1,lB(a,f)}}onContentLoaded(){}onPlayerWillDestroy(){this.a&&(this.f.destroy(),this.m=this.f=null)}onPlayerWillRelease(){this.a&&this.f.release()}id(){return"mux"}emit(a,b){try{this.f.emit(a,b)}catch(c){throw null!==this.m&&lB(this.m,c),c;}}};_.z("clpp.muxdata.MuxDataPlugin",oB);oB.prototype.emit=oB.prototype.emit;
13
- oB.Id="mux";_.Ir(new class{create(){return new oB}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var YA=function(a){switch(a.type){case 1:return VA;case 2:return WA;case 3:return XA}},$A=function(a){const b=Object.keys(a).find(c=>ZA.includes(c.toLowerCase()));return void 0!==b?a[b]:void 0},bB=function(a){let b={debug:!0,data:aB(a)};a.f&&a.f.muxOptionsOverride&&_.dh(a.f.muxOptionsOverride)&&(b=_.$g(b,a.f.muxOptionsOverride));b=_.$g(b,{getPlayheadTime:()=>1E3*a.m.getPosition(),getStateData:()=>{{a.g.debug("getStateData()");var c=a.m.getLoadedSource(),d=a.m.getTrackManager();const f=
2
+ a.m.getSurface();var e={player_is_paused:a.m.isPaused(),player_is_fullscreen:f.isFullscreen(),video_source_duration:1E3*a.m.getDuration(),player_autoplay_on:!!a.m.getConfiguration().autoplay};if(c){const k=new _.Lm(c.url);e.video_source_url=_.Qi(k);e.video_source_mime_type=c.type;c.name&&(e.video_title=c.name)}if(c=f.getContainer())e.player_width=c.offsetWidth,e.player_height=c.offsetHeight;(c=a.m.getSurface().getMedia())?c={videoWidth:c.videoWidth,videoHeight:c.videoHeight}:(c=a.m.getTrackManager().qa(),
3
+ c={videoWidth:c.width,videoHeight:c.height});const {videoWidth:g,videoHeight:h}=c;a.g.debug(`Video dimensions: ${g}x${h}`);g&&h&&(e.video_source_height=g,e.video_source_width=h);(d=d.oa())&&d.language&&(e.player_language_code=d.language)}return e}});a.g.debug("Mux SDK options",b);return b},cB=function(a){_.Hh(a.a);a.j.td(a.F);a.j.Se(a.C)},aB=function(a){const b={env_key:a.f.envKey,video_title:a.o&&a.o.name||"",player_name:_.ra,player_software_name:_.ra,player_software_version:_.ea,player_mux_plugin_name:"CastlabsPlayer built-in Mux Plugin",
4
+ player_mux_plugin_version:_.ea};(a=a.m.getConfiguration().viewerId)&&(b.viewer_user_id=a);return b},dB=function(a){a.a.on(a.m,_.cg,()=>{const b={player_playhead_time:1E3*a.m.getPosition()};a.emit(_.cg,b)});a.a.on(a.m,_.Ue,()=>a.emit(_.Ue));a.a.on(a.m,_.Lc,a.G.bind(a));a.a.on(a.m,_.Nf,a.I.bind(a));a.a.on(a.m,_.ng,()=>a.emit(_.Ff));a.a.on(a.m,_.mg,()=>a.emit(_.Ef));a.a.on(a.m,_.Ud,a.H.bind(a));a.a.on(a.m,_.Sb,()=>a.emit("adbreakstart"));a.a.on(a.m,_.Tb,()=>a.emit("adbreakend"));a.a.on(a.m,_.kc,()=>
5
+ {a.emit("adplay");a.emit("adplaying")});a.a.on(a.m,_.dc,()=>a.emit("adpause"));a.a.on(a.m,_.fc,()=>{a.emit("adplay");a.emit("adplaying")});a.a.on(a.m,_.mc,()=>a.emit("adended"));a.a.on(a.m,_.Xb,()=>a.emit("adfirstquartile"));a.a.on(a.m,_.cc,()=>a.emit("admidpoint"));a.a.on(a.m,_.nc,()=>a.emit("adthirdquartile"));a.j.Ac(a.F);a.j.me(a.C);a.a.on(a.m,_.Ud,b=>{if((b=b.detail)&&1===b.category){var c=b.data;c=c&&c.request;if(void 0!==c&&!0===(1===c.type||2===c.type||3===c.type))if(7001===b.code){b=c;c=b.requestStartTimestamp;
6
+ var d=new _.Lm(b.uris[b.uriIndex]);b={request_start:c,request_type:YA(b),request_hostname:d.a};a.g.debug("onRequestCanceled()","Track event: requestcanceled",b);a.emit("requestcanceled",b)}else{{d=c.requestStartTimestamp;const f=new _.Lm(c.uris[c.uriIndex]);var e=b.data;e=void 0===e?-1:void 0!==e.response?e.response.status:void 0!==e.status?e.status:-1;b={request_start:d,request_type:YA(c),request_hostname:f.a,request_error:`${YA(c)}${"LoadError"}`,request_error_code:e,request_error_text:b.toString()};
7
+ a.g.debug("onRequestFailed()","Track event: requestfailed",b);a.emit("requestfailed",b)}}}})},eB=function(a,b){a.trigger(new _.C(_.Ud,{detail:b}))},fB=function(a){return!_.z(a)&&typeof a.init===_.$d&&typeof a.emit===_.$d},VA="manifest",WA="media",XA="encryption",ZA=["x-request-id","cf-ray","x-amz-cf-id","x-akamai-request-id"];var gB=class{constructor(a,b){this.m=a;this.o=this.f=null;this.B=("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6);this.a=new _.Kt;this.g=b;this.A=this.l=this.h=!1;this.w=null;this.j=a.getNetworkEngine();this.F=this.K.bind(this);this.C=this.J.bind(this)}initialize(a,b,c){this.f=a;this.o=b;this.w=c;if(!this.h){try{this.h=!0,this.w.init(this.B,bB(this))}catch(d){throw this.h=!1,cB(this),new _.I(1,9,9302,null,d);}this.emit("playerready")}this.l&&!this.A&&(a=aB(this),this.emit("videochange",
8
+ a),this.l=!1);dB(this)}release(){this.g.debug("release()");this.l?this.g.debug(_.ja):(cB(this),this.l=!0,this.o=this.f=null)}destroy(){this.g.debug(_.Bd);this.A?this.g.debug(_.ia):(this.A=!0,this.emit("destroy"))}emit(a,b){if(null===this.w)throw new _.I(1,9,9301);this.w.emit(this.B,a,b)}G(a){this.g.debug(_.Ge);var b=a.detail;a=this.m.getTrackManager();b&&b.bandwidth&&(b=b.bandwidth,(a=a.La())&&a.bandwidth&&(b+=a.bandwidth),this.emit("renditionchange",{video_source_bitrate:b}))}I(a){this.g.debug(_.Le);
9
+ switch(a.detail.currentState){case _.qp:this.m.getConfiguration().autoplay&&this.emit(_.Ue);break;case _.sp:this.emit(_.ef);break;case _.rp:this.emit(_.Qe);break;case _.hp:this.emit(_.Td)}}H(a){this.g.debug(_.Ie);if(this.h&&(a=a.detail||null))if(10003===a.code)this.emit("aderror");else if(a.severity===_.F){var b=a.message||"Player error";if(1===a.category||6100===a.code||6007===a.code)b="Download error",6100===a.code?b="Certificate request error":6007===a.code&&(b="License request error"),b=`${b} castlabs-error-data:${JSON.stringify(a.data)}`;
10
+ this.emit(_.Ud,{player_error_code:a.code,player_error_message:b})}}K(a){var b=a.request;if(b=void 0!==b&&!0===(1===b.type||2===b.type||3===b.type))b=a.status,b=void 0!==b&&200<=b&&299>=b;if(b){{b=a.request;const e=a.headers,f=b.bytesLoaded,g=b.requestStartTimestamp;var c=b.startTime,d=b.endTime;const h=g+a.responseStartMs;a=g+a.timeMs;c=c&&d?d-c:void 0;d=new _.Lm(b.uris[b.uriIndex]);a={request_start:g,request_type:YA(b),request_hostname:d.a,request_id:$A(e),request_bytes_loaded:f,request_response_start:h,
11
+ request_response_end:a,request_response_headers:e,request_media_duration:c,request_url:_.Qi(d)};this.g.debug("onRequestCompleted()","Track event: requestcompleted",a);this.emit("requestcompleted",a)}}}J(a){a.requestStartTimestamp=Date.now()}};var hB=class extends _.Iv{constructor(){super();this.f=this.m=null;this.a=!1;this.g=new _.S("clpp.muxdata")}onPlayerCreated(a){this.m=a;this.f=new gB(a,this.g)}onContentWillLoad(a,b){var c=a.getConfiguration();c=_.ah(c.muxdata);try{var d=[];typeof c===_.Fe&&(c.envKey||d.push("envKey"));if(0<d.length)throw new _.I(1,9,9300,{missingKeys:d});{const f=a.getConfiguration();d=null;if(this.a=!_.z(f.muxdata)&&typeof f.muxdata===_.Fe){const g=f.muxdata;d=fB(g.muxLib)?g.muxLib:window.mux;if(!fB(d)){this.g.warn("Mux SDK is not loaded. Will do nothing.");
12
+ this.a=!1;const h=new _.I(1,9,9301);eB(a,h)}}else this.g.debug("Mux plugin is loaded but not configured. Will do nothing.");var e=d}null!==e&&this.f.initialize(c,b,e)}catch(f){this.a=!1,eB(a,f)}}onContentLoaded(){}onPlayerWillDestroy(){this.a&&(this.f.destroy(),this.m=this.f=null)}onPlayerWillRelease(){this.a&&this.f.release()}id(){return"mux"}emit(a,b){try{this.f.emit(a,b)}catch(c){throw null!==this.m&&eB(this.m,c),c;}}};_.x("clpp.muxdata.MuxDataPlugin",hB);hB.prototype.emit=hB.prototype.emit;
13
+ hB.Id="mux";_.fs(new class{create(){return new hB}});};f.call(g, window);
package/cl.onboard.js CHANGED
@@ -1,4 +1,4 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var aB=function(a,b){let c=b.baseUrl;_.bj(c,"/")||(c+="/");const d=g=>g&&(_.aj(g,"https://")||_.aj(g,"http://")||_.aj(g,"//"))?g:`${c}${g}`,e=d(b.widevineUrl||"widevine"),f=d(b.playreadyUrl||"playready");b=d(b.fairplayUrl||"fairplay");a=new _.yu(a);a.$a(_.td,{licenseUrl:e,videoRobustness:[_.nb,void 0],audioRobustness:[_.mb,void 0],persistentStateRequired:!1,distinctiveIdentifierRequired:!1,serverCertificate:null,modifiers:{licenseRequest:_.Bm,licenseResponse:_.Cm}});a.$a(_.pd,{licenseUrl:b,
2
- certificateUrl:b,modifiers:{licenseRequest:_.Em,licenseResponse:_.Fm,extractContentId:_.Gm,certificateRequest:_.Hm}});a.$a(_.rd,{licenseUrl:f,modifiers:{licenseRequest:_.Bm}});_.Rl(a)};
3
- _.z("clpp.onboard.OnboardComponent",class extends _.Av{constructor(){super();this.g=new _.S("clpp.onboard");this.j=new Set}a(){for(const a of this.j)delete _.Ql[a];this.j.clear()}h(a){a=a.getConfiguration().drm;var b;if(b=!(!a||!a.env))b=a&&a.customData,b=!(!b||!b.baseUrl);b&&(b=a.env,a=a.customData,a={baseUrl:a.baseUrl,widevineUrl:a.widevineUrl,playreadyUrl:a.playreadyUrl,fairplayUrl:a.fairplayUrl},this.g.info(`Registering the DRMtoday Onboard environment, name='${b}'`),aB(b,a),this.j.add(b))}id(){return"onboard"}});
4
- _.z("clpp.onboard.register",aB);};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var UA=function(a,b){let c=b.baseUrl;_.Ji(c,"/")||(c+="/");const d=g=>g&&(_.Ii(g,_.de)||_.Ii(g,"http://")||_.Ii(g,"//"))?g:`${c}${g}`,e=d(b.widevineUrl||"widevine"),f=d(b.playreadyUrl||"playready");b=d(b.fairplayUrl||"fairplay");a=new _.su(a);a.Xa(_.ud,{licenseUrl:e,videoRobustness:[_.ob,void 0],audioRobustness:[_.nb,void 0],persistentStateRequired:!1,distinctiveIdentifierRequired:!1,serverCertificate:null,modifiers:{licenseRequest:_.cn,licenseResponse:_.dn}});a.Xa(_.qd,{licenseUrl:b,
2
+ certificateUrl:b,modifiers:{licenseRequest:_.fn,licenseResponse:_.gn,extractContentId:_.hn,certificateRequest:_.jn}});a.Xa(_.sd,{licenseUrl:f,modifiers:{licenseRequest:_.cn}});_.pm(a)};
3
+ _.x("clpp.onboard.OnboardComponent",class extends _.uv{constructor(){super();this.g=new _.S("clpp.onboard");this.j=new Set}a(){for(const a of this.j)delete _.om[a];this.j.clear()}h(a){a=a.getConfiguration().drm;var b;if(b=!(!a||!a.env))b=a&&a.customData,b=!(!b||!b.baseUrl);b&&(b=a.env,a=a.customData,a={baseUrl:a.baseUrl,widevineUrl:a.widevineUrl,playreadyUrl:a.playreadyUrl,fairplayUrl:a.fairplayUrl},this.g.info(`Registering the DRMtoday Onboard environment, name='${b}'`),UA(b,a),this.j.add(b))}id(){return"onboard"}});
4
+ _.x("clpp.onboard.register",UA);};f.call(g, window);
package/cl.persistent.js CHANGED
@@ -1,11 +1,11 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var LA="A persistent DRM session already exists for: ",MA="No DRM configuration.",NA="clpp.persistent",OA="clpp.persistent.SimpleSessionStorage",PA=function(a,b){const c=[];for(const d of a)c.push(b(d));return c},RA=function(a,b,c,d,e,f){a.K=QA;const g=new Map,h=_.An(b);g.set(h,{audioCapabilities:e,videoCapabilities:f,distinctiveIdentifier:_.Ke,persistentState:_.uf,sessionTypes:[_.Pe],label:h,drmInfos:[{keySystem:b,licenseServerUri:c,distinctiveIdentifierRequired:!1,persistentStateRequired:!0,
2
- audioRobustness:"",videoRobustness:"",serverCertificate:d,initData:null,keyIds:null}]});return _.Sn(a,g)},TA=function(a,b){a.K=SA;a.L=[];a.G=!0;return _.Tn(a,b)},UA=function(a,b){return _.x(function*(){const c=yield _.ko(a,b);if(c){var d=[],e=a.h.get(c);e&&a.C&&(e.ic=new _.bn,d.push(e.ic));a.g.debug("Attempting to remove session",b);d.push(c.remove());return Promise.all(d)}a.g.debug("Ignoring attempt to remove missing session",b)})},VA=function(a){a=a.h.keys();a=PA(a,b=>b.sessionId);return Array.from(a)},
3
- WA=function(a,b){const c=_.Tl(a),d=_.tl({drm:a});d.drm=a;a=new _.cp({vb:b,onError:()=>{},Se:()=>{},Re:()=>{},onEvent:()=>{},getConfiguration:()=>d,Qc:()=>null});a.f=c;return a},ZA=function(a,b,c){return _.x(function*(){const d=XA;if(a){var e=a.offlineId;if(0!==e.length){var f=yield d.get(e);if(f)YA.debug(LA,e);else{var g=WA(a,c);try{yield TA(g,b);yield _.io(g);yield _.lo(g);const h=g.getDrmInfo(),k=b.map(l=>({contentType:_.mk(l.video.mimeType,l.video.codecs),robustness:h.videoRobustness}));f={sessionIds:VA(g),
4
- keySystem:h.keySystem,licenseServerUri:h.licenseServerUri,serverCertificate:h.serverCertificate,audioCapabilities:[],videoCapabilities:k,drmConfig:a};yield d.store(e,f)}catch(h){throw YA.error(`Error while persisting DRM session ${e}`),new _.I(1,6,6200,null,h);}finally{yield g.destroy()}}}}else YA.debug(MA)})},SA=1,QA=2,$A=class{constructor(){this.g=new _.S(OA)}store(a,b){return _.x(function*(){{var c=JSON.stringify(b.sessionIds);var d=b.serverCertificate?Array.from(b.serverCertificate):null;d=JSON.stringify(d);
5
- const e=JSON.stringify(b.audioCapabilities),f=JSON.stringify(b.videoCapabilities);c=JSON.stringify({sessionIds:c,keySystem:b.keySystem,licenseServerUri:encodeURIComponent(b.licenseServerUri),serverCertificate:d,audioCapabilities:e,videoCapabilities:f,drmConfig:JSON.stringify(b.drmConfig)})}window.localStorage.setItem(encodeURIComponent(a),btoa(c))})}get(a){const b=this;return _.x(function*(){const c=window.localStorage.getItem(encodeURIComponent(a));if(c)try{{const e=JSON.parse(atob(c)),f=JSON.parse(e.sessionIds),
6
- g=e.audioCapabilities||[],h=e.videoCapabilities||[],k=e.serverCertificate||[],l=e.drmConfig||{};var d={sessionIds:f,keySystem:e.keySystem,licenseServerUri:decodeURIComponent(e.licenseServerUri||""),serverCertificate:k?new Uint8Array(k):null,audioCapabilities:g,videoCapabilities:h,drmConfig:l}}return d}catch(e){b.g.warn(`Error while loading offline items for ${a} from storage: `,e)}return null})}delete(a){return _.x(function*(){window.localStorage.removeItem(encodeURIComponent(a))})}clear(){return _.x(function*(){window.localStorage.clear()})}getName(){return OA}};_.z("clpp.persistent.useStorage",function(a){{var b=["store","get","delete","clear","getName"];const c=[];_.B(a)||(_.ah(a.store)||c.push("store"),_.ah(a.get)||c.push("get"),_.ah(a.delete)||c.push("delete"),_.ah(a.clear)||c.push("clear"),_.ah(a.getName)||c.push("getName"),b=c)}if(0<b.length)throw YA.warn("Invalid session storage implementation"),new _.I(1,6,6202,{missingMethods:b});XA=a});
7
- _.z("clpp.persistent.fetchLicense",function(a,b,...c){return _.x(function*(){var d=XA,e=(l,m)=>new _.I(1,6,6200,l,m);const f=_.Zo(a).shift();if(!f)throw e("No source specified.");if(!b)throw e(MA);var g=b.offlineId;if(typeof g!==_.Nf||!g.length)throw e("Missing offline id.");if(yield d.get(g))YA.debug(LA,g);else{var h=_.tl();d=new _.zr;g=[];for(var k of c){const l=new k;_.wl(l.id())||(l.f(),_.yl(l),g.push(l))}k=null;try{k=yield _.Xs(f.url,d,h.manifest.attemptParameters,f.type||null);k.configure(h.manifest);
8
- const l=yield k.start(f.url,{configurationId:"",networkingEngine:d,onContentSteeringInfoFound:()=>null,filterAllPeriods:()=>{},filterNewPeriod:()=>{},onEvent:()=>{},onError:()=>{}});if(!l.periods.length)throw e(null,new _.I(_.G,4,4014));const m=_.Vs(l.periods);yield ZA(b,m,d)}catch(l){if(l instanceof _.I&&6200===l.code)throw l;throw e(null,l);}finally{for(;g.length;)e=g.shift(),e.a(),_.vl.delete(e.id());e=[];k&&e.push(k.stop());e.push(d.destroy());yield Promise.all(e)}}})});
9
- _.z("clpp.persistent.removeLicense",function(a){return _.x(function*(){var b=XA;if(_.ch(a)&&0!==a.length){var c=null,d=null;try{const e=yield b.get(a);e?(e.drmConfig.delayLicenseRequestUntilPlayed=!0,d=new _.zr,c=WA(e.drmConfig,d),yield RA(c,e.keySystem,e.licenseServerUri,e.serverCertificate,e.audioCapabilities,e.videoCapabilities),yield _.io(c),yield Promise.all(e.sessionIds.map(f=>_.x(function*(){yield UA(c,f);YA.debug("successfully removed session with id",f)}))),yield b.delete(a)):YA.debug("No persistent DRM session found")}catch(e){throw YA.error("Failed to remove session"),
10
- new _.I(1,6,6201,null,e);}finally{b=[],c&&b.push(c.destroy()),d&&b.push(d.destroy()),yield Promise.all(b)}}else YA.warn("Invalid offlineId")})});_.z("clpp.persistent.getSessionStorage",function(){return XA});var XA=new $A,YA=new _.S(NA);_.z("clpp.persistent.PersistentLicenseComponent",class extends _.Av{constructor(){super();this.g=new _.S(NA)}id(){return _.Oe}l(a,b){const c=this;return _.x(function*(){const d=a.getConfiguration().drm;if(d){c.g.debug(`Persisting DRM session ID: ${d.offlineId}`);var e=a.getNetworkEngine();try{yield ZA(d,b,e),a.trigger(new _.F(_.Ld,{offlineId:d.offlineId}))}catch(f){a.onError(f)}}else c.g.debug("No DRM configuration found for loaded source.")})}j(a){const b=this;return _.x(function*(){b.g.debug(`Getting EME session IDs for ${a}`);
11
- const c=XA;try{const d=yield c.get(a);if(d)return d.sessionIds||[];b.g.debug(`No offline session found for ${a}`);return[]}catch(d){return b.g.warn("Error while loading session info from storage"),[]}})}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var EA="A persistent DRM session already exists for: ",FA="No DRM configuration.",GA="clpp.persistent",HA="clpp.persistent.SimpleSessionStorage",IA=function(a,b){const c=[];for(const d of a)c.push(b(d));return c},KA=function(a,b,c,d,e,f){a.K=JA;const g=new Map,h=_.Xn(b);g.set(h,{audioCapabilities:e,videoCapabilities:f,distinctiveIdentifier:_.Ne,persistentState:_.xf,sessionTypes:[_.Se],label:h,drmInfos:[{keySystem:b,licenseServerUri:c,distinctiveIdentifierRequired:!1,persistentStateRequired:!0,
2
+ audioRobustness:"",videoRobustness:"",serverCertificate:d,initData:null,keyIds:null}]});return _.po(a,g)},MA=function(a,b){a.K=LA;a.L=[];a.G=!0;return _.qo(a,b)},NA=function(a,b){return _.w(function*(){const c=yield _.Ho(a,b);if(c){var d=[],e=a.h.get(c);e&&a.C&&(e.ec=new _.xk,d.push(e.ec));a.g.debug("Attempting to remove session",b);d.push(c.remove());return Promise.all(d)}a.g.debug("Ignoring attempt to remove missing session",b)})},OA=function(a){a=a.h.keys();a=IA(a,b=>b.sessionId);return Array.from(a)},
3
+ PA=function(a,b){const c=_.rm(a),d=_.Zl({drm:a});d.drm=a;a=new _.zp({sb:b,onError:()=>{},Je:()=>{},Ie:()=>{},onEvent:()=>{},getConfiguration:()=>d,Jc:()=>null});a.f=c;return a},SA=function(a,b,c){return _.w(function*(){const d=QA;if(a){var e=a.offlineId;if(0!==e.length){var f=yield d.get(e);if(f)RA.debug(EA,e);else{var g=PA(a,c);try{yield MA(g,b);yield _.Fo(g);yield _.Io(g);const h=g.getDrmInfo(),k=b.map(l=>({contentType:_.ul(l.video.mimeType,l.video.codecs),robustness:h.videoRobustness}));f={sessionIds:OA(g),
4
+ keySystem:h.keySystem,licenseServerUri:h.licenseServerUri,serverCertificate:h.serverCertificate,audioCapabilities:[],videoCapabilities:k,drmConfig:a};yield d.store(e,f)}catch(h){throw RA.error(`Error while persisting DRM session ${e}`),new _.I(1,6,6200,null,h);}finally{yield g.destroy()}}}}else RA.debug(FA)})},LA=1,JA=2,TA=class{constructor(){this.g=new _.S(HA)}store(a,b){return _.w(function*(){{var c=JSON.stringify(b.sessionIds);var d=b.serverCertificate?Array.from(b.serverCertificate):null;d=JSON.stringify(d);
5
+ const e=JSON.stringify(b.audioCapabilities),f=JSON.stringify(b.videoCapabilities);c=JSON.stringify({sessionIds:c,keySystem:b.keySystem,licenseServerUri:encodeURIComponent(b.licenseServerUri),serverCertificate:d,audioCapabilities:e,videoCapabilities:f,drmConfig:JSON.stringify(b.drmConfig)})}window.localStorage.setItem(encodeURIComponent(a),btoa(c))})}get(a){const b=this;return _.w(function*(){const c=window.localStorage.getItem(encodeURIComponent(a));if(c)try{{const e=JSON.parse(atob(c)),f=JSON.parse(e.sessionIds),
6
+ g=e.audioCapabilities||[],h=e.videoCapabilities||[],k=e.serverCertificate||[],l=e.drmConfig||{};var d={sessionIds:f,keySystem:e.keySystem,licenseServerUri:decodeURIComponent(e.licenseServerUri||""),serverCertificate:k?new Uint8Array(k):null,audioCapabilities:g,videoCapabilities:h,drmConfig:l}}return d}catch(e){b.g.warn(`Error while loading offline items for ${a} from storage: `,e)}return null})}delete(a){return _.w(function*(){window.localStorage.removeItem(encodeURIComponent(a))})}clear(){return _.w(function*(){window.localStorage.clear()})}getName(){return HA}};_.x("clpp.persistent.useStorage",function(a){{var b=["store","get","delete","clear","getName"];const c=[];_.z(a)||(_.eh(a.store)||c.push("store"),_.eh(a.get)||c.push("get"),_.eh(a.delete)||c.push("delete"),_.eh(a.clear)||c.push("clear"),_.eh(a.getName)||c.push("getName"),b=c)}if(0<b.length)throw RA.warn("Invalid session storage implementation"),new _.I(1,6,6202,{missingMethods:b});QA=a});
7
+ _.x("clpp.persistent.fetchLicense",function(a,b,...c){return _.w(function*(){var d=QA,e=(l,m)=>new _.I(1,6,6200,l,m);const f=_.vp(a).shift();if(!f)throw e("No source specified.");if(!b)throw e(FA);var g=b.offlineId;if(typeof g!==_.Qf||!g.length)throw e("Missing offline id.");if(yield d.get(g))RA.debug(EA,g);else{var h=_.Zl();d=new _.Xr;g=[];for(var k of c){const l=new k;_.bm(l.id())||(l.f(),_.dm(l),g.push(l))}k=null;try{k=yield _.qt(f.url,d,h.manifest.attemptParameters,f.type||null);k.configure(h.manifest);
8
+ const l=yield k.start(f.url,{configurationId:"",networkingEngine:d,onContentSteeringInfoFound:()=>null,filterAllPeriods:()=>{},filterNewPeriod:()=>{},onEvent:()=>{},onError:()=>{}});if(!l.periods.length)throw e(null,new _.I(_.F,4,4014));const m=_.ot(l.periods);yield SA(b,m,d)}catch(l){if(l instanceof _.I&&6200===l.code)throw l;throw e(null,l);}finally{for(;g.length;)e=g.shift(),e.a(),_.am.delete(e.id());e=[];k&&e.push(k.stop());e.push(d.destroy());yield Promise.all(e)}}})});
9
+ _.x("clpp.persistent.removeLicense",function(a){return _.w(function*(){var b=QA;if(_.gh(a)&&0!==a.length){var c=null,d=null;try{const e=yield b.get(a);e?(e.drmConfig.delayLicenseRequestUntilPlayed=!0,d=new _.Xr,c=PA(e.drmConfig,d),yield KA(c,e.keySystem,e.licenseServerUri,e.serverCertificate,e.audioCapabilities,e.videoCapabilities),yield _.Fo(c),yield Promise.all(e.sessionIds.map(f=>_.w(function*(){yield NA(c,f);RA.debug("successfully removed session with id",f)}))),yield b.delete(a)):RA.debug("No persistent DRM session found")}catch(e){throw RA.error("Failed to remove session"),
10
+ new _.I(1,6,6201,null,e);}finally{b=[],c&&b.push(c.destroy()),d&&b.push(d.destroy()),yield Promise.all(b)}}else RA.warn("Invalid offlineId")})});_.x("clpp.persistent.getSessionStorage",function(){return QA});var QA=new TA,RA=new _.S(GA);_.x("clpp.persistent.PersistentLicenseComponent",class extends _.uv{constructor(){super();this.g=new _.S(GA)}id(){return _.Re}l(a,b){const c=this;return _.w(function*(){const d=a.getConfiguration().drm;if(d){c.g.debug(`Persisting DRM session ID: ${d.offlineId}`);var e=a.getNetworkEngine();try{yield SA(d,b,e),a.trigger(new _.C(_.Md,{offlineId:d.offlineId}))}catch(f){a.onError(f)}}else c.g.debug("No DRM configuration found for loaded source.")})}j(a){const b=this;return _.w(function*(){b.g.debug(`Getting EME session IDs for ${a}`);
11
+ const c=QA;try{const d=yield c.get(a);if(d)return d.sessionIds||[];b.g.debug(`No offline session found for ${a}`);return[]}catch(d){return b.g.warn("Error while loading session info from storage"),[]}})}});};f.call(g, window);
package/cl.playlist.js CHANGED
@@ -1,5 +1,5 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var IA=function(a,b){return 0<=b&&b<a.a.length},JA=function(a){a.trigger(new _.F(_.df))},KA=class extends _.su{on(a,b,c){return super.on(a,b,c)}one(a,b,c){return super.one(a,b,c)}off(a,b){return super.off(a,b)}constructor(a,b){b=void 0===b?()=>Promise.resolve():b;super();this.m=a;this.l=b;this.f=0;this.a=[];this.h=!1;this.j=this.Aa.bind(this)}getPosition(){return this.f}Eh(){return this.a}hd(){return 0<this.a.length&&IA(this,this.f)?this.a[this.f]:null}Fh(){const a=this.f+1;return 0<
2
- this.a.length&&IA(this,a)?this.a[a]:null}Rh(){return this.h}start(){this.h||(this.h=!0,this.m.on(_.Sd,this.j),this.Td(this.f,!0))}stop(){this.h=!1;this.m.off(_.Sd,this.j)}Aa(){this.next()}next(){const a=this;return _.x(function*(){yield a.Td(Math.min(a.a.length-1,a.f+1))})}ji(){const a=this;return _.x(function*(){yield a.Td(Math.max(0,a.f-1))})}Td(a,b){b=void 0===b?!1:b;const c=this;return _.x(function*(){if(0<c.a.length&&IA(c,a)&&(b||c.f!==a)){c.f=a;var d=c.hd();d&&(yield c.l(d),yield c.m.load(d.configuration),
3
- c.trigger(new _.F(_.cf,{item:d})))}})}append(a){this.a.push(a);JA(this)}Ph(a,b){if(0<=b&&b<=this.a.length){const c=this.hd();this.a.splice(b,0,a);c&&(this.f=this.a.indexOf(c));JA(this)}}remove(a){if(0<this.a.length&&IA(this,a)){if(this.f===a)throw Error("Can't remove the current item");this.a.splice(a,1);JA(this)}}clear(){this.stop();this.f=0;this.a=[];this.h=!1;JA(this)}};_.z("clpp.Playlist",KA);KA.prototype.clear=KA.prototype.clear;KA.prototype.remove=KA.prototype.remove;KA.prototype.insert=KA.prototype.Ph;
4
- KA.prototype.append=KA.prototype.append;KA.prototype.goTo=KA.prototype.Td;KA.prototype.previous=KA.prototype.ji;KA.prototype.next=KA.prototype.next;KA.prototype.onEnded=KA.prototype.Aa;KA.prototype.stop=KA.prototype.stop;KA.prototype.start=KA.prototype.start;KA.prototype.isStarted=KA.prototype.Rh;KA.prototype.getUpcoming=KA.prototype.Fh;KA.prototype.getCurrent=KA.prototype.hd;KA.prototype.getQueue=KA.prototype.Eh;KA.prototype.getPosition=KA.prototype.getPosition;KA.prototype.off=KA.prototype.off;
5
- KA.prototype.one=KA.prototype.one;KA.prototype.on=KA.prototype.on;};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var BA=function(a,b){return 0<=b&&b<a.a.length},CA=function(a){a.trigger(new _.C(_.gf))},DA=class extends _.nu{on(a,b,c){return super.on(a,b,c)}one(a,b,c){return super.one(a,b,c)}off(a,b){return super.off(a,b)}constructor(a,b){b=void 0===b?()=>Promise.resolve():b;super();this.m=a;this.l=b;this.f=0;this.a=[];this.h=!1;this.j=this.za.bind(this)}getPosition(){return this.f}wh(){return this.a}bd(){return 0<this.a.length&&BA(this,this.f)?this.a[this.f]:null}xh(){const a=this.f+1;return 0<
2
+ this.a.length&&BA(this,a)?this.a[a]:null}Hh(){return this.h}start(){this.h||(this.h=!0,this.m.on(_.Td,this.j),this.Od(this.f,!0))}stop(){this.h=!1;this.m.off(_.Td,this.j)}za(){this.next()}next(){const a=this;return _.w(function*(){yield a.Od(Math.min(a.a.length-1,a.f+1))})}$h(){const a=this;return _.w(function*(){yield a.Od(Math.max(0,a.f-1))})}Od(a,b){b=void 0===b?!1:b;const c=this;return _.w(function*(){if(0<c.a.length&&BA(c,a)&&(b||c.f!==a)){c.f=a;var d=c.bd();d&&(yield c.l(d),yield c.m.load(d.configuration),
3
+ c.trigger(new _.C(_.ff,{item:d})))}})}append(a){this.a.push(a);CA(this)}Fh(a,b){if(0<=b&&b<=this.a.length){const c=this.bd();this.a.splice(b,0,a);c&&(this.f=this.a.indexOf(c));CA(this)}}remove(a){if(0<this.a.length&&BA(this,a)){if(this.f===a)throw Error("Can't remove the current item");this.a.splice(a,1);CA(this)}}clear(){this.stop();this.f=0;this.a=[];this.h=!1;CA(this)}};_.x("clpp.Playlist",DA);DA.prototype.clear=DA.prototype.clear;DA.prototype.remove=DA.prototype.remove;DA.prototype.insert=DA.prototype.Fh;
4
+ DA.prototype.append=DA.prototype.append;DA.prototype.goTo=DA.prototype.Od;DA.prototype.previous=DA.prototype.$h;DA.prototype.next=DA.prototype.next;DA.prototype.onEnded=DA.prototype.za;DA.prototype.stop=DA.prototype.stop;DA.prototype.start=DA.prototype.start;DA.prototype.isStarted=DA.prototype.Hh;DA.prototype.getUpcoming=DA.prototype.xh;DA.prototype.getCurrent=DA.prototype.bd;DA.prototype.getQueue=DA.prototype.wh;DA.prototype.getPosition=DA.prototype.getPosition;DA.prototype.off=DA.prototype.off;
5
+ DA.prototype.one=DA.prototype.one;DA.prototype.on=DA.prototype.on;};f.call(g, window);
package/cl.sessions.js CHANGED
@@ -1,10 +1,10 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Dz="apiUrl config is missing",Ez=function(a,b){a.j=a.j.filter(c=>c!==b)},Fz=function(a){let b=0>a;a=Math.abs(a);let c=a>>>0;a=Math.floor((a-c)/4294967296);a>>>=0;b&&(a=~a>>>0,c=(~c>>>0)+1,4294967295<c&&(c=0,a++,4294967295<a&&(a=0)));return[c,a]},Kz=function(a,b,c,d){if(!(null===c||void 0===c||typeof c===_.t&&0===c||typeof c===_.Nf&&0===c.length||Array.isArray(c)&&0===c.length))if(Array.isArray(c)){Gz(a,b<<3|2);b=new Hz;for(let e=0;e<c.length;e++)d(b,c[e]);Iz(a,b.length());Jz(a,b.end())}else Gz(a,
2
- b<<3|0),d(a,c)},Iz=function(a,b){if(0<=b)Gz(a,b);else{for(let c=0;9>c;c++)a.a.push(b&127|128),b>>=7;a.a.push(1)}},Lz=function(a,b,c){Kz(a,b,c,(d,e)=>{Iz(d,e)})},Gz=function(a,b){for(;127<b;)a.a.push(b&127|128),b>>>=7;a.a.push(b)},Nz=function(a,b,c){Kz(a,b,c,(d,e)=>{if(0<=e){{const [f,g]=Fz(e);Mz(d,f,g)}}else{{const [f,g]=Fz(e);Mz(d,f,g)}}})},Oz=function(a,b,c,d){if(!(null===c||void 0===c||typeof c===_.t&&0===c||typeof c===_.Nf&&0===c.length||Array.isArray(c)&&0===c.length))if(Array.isArray(c))for(let e=
3
- 0;e<c.length;e++){Gz(a,b<<3|2);const f=new Hz;d(f,c[e]);Iz(a,f.length());Jz(a,f.end())}else Gz(a,b<<3|2),b=new Hz,d(b,c),Iz(a,b.length()),Jz(a,b.end())},Pz=function(a,b,c){Oz(a,b,c,(d,e)=>{for(let f=0;f<e.length;f++){let g=e.charCodeAt(f);if(128>g)d.a.push(g);else if(2048>g)d.a.push(g>>6|192),d.a.push(g&63|128);else if(65536>g)if(55296<=g&&56319>=g&&f+1<e.length){let h=e.charCodeAt(f+1);56320<=h&&57343>=h&&(g=1024*(g-55296)+h-56320+65536,d.a.push(g>>18|240),d.a.push(g>>12&63|128),d.a.push(g>>6&63|
4
- 128),d.a.push(g&63|128),f++)}else d.a.push(g>>12|224),d.a.push(g>>6&63|128),d.a.push(g&63|128)}})},Jz=function(a,b){a.a.push.apply(a.a,b)},Qz=function(a,b,c){Oz(a,b,c,(d,e)=>{Jz(d,e.a())})},Rz=function(a,b,c){Oz(a,b,c,(d,e)=>{Jz(d,e)})},Mz=function(a,b,c){for(;0<c||127<b;)a.a.push(b&127|128),b=(b>>>7|c<<25)>>>0,c>>>=7;a.a.push(b)},Tz=function(a){const b=new Sz;b.h=Math.floor(a/1E3);b.f=a%1E3*1E6;return b},Xz=function(a){return _.x(function*(){if(!a.j&&!a.f){0===a.a.length&&Uz(a,new Vz);var b=()=>
5
- {};a.f=new Promise(c=>{b=c});try{const c=new Wz;c.f=a.o;c.events.push(...a.a);const d=[...a.a],e=yield fetch(a.l,{method:_.cb,headers:{"Content-Type":"application/proto"},body:new Uint8Array(c.a())});if(e.ok)a.a=a.a.filter(f=>!d.includes(f));else throw Error("An error occurred while sending telemetry events to the API, "+`status='${e.status}' statusText='${e.statusText}'`);}finally{b(),a.f=null}}})},$z=function(a,b,c,d,e,f,g){const h=new Yz;h.headers=[new Zz("CL-BROWSER-NAME",b),new Zz("CL-BROWSER-VERSION",
6
- c),new Zz("CL-OS-FAMILY",d),new Zz("CL-OS-VERSION",e),new Zz("CL-SDK-NAME",f),new Zz("CL-SDK-NAME",f),new Zz("CL-SDK-VERSION",g)];Uz(a,h)},Uz=function(a,b){if(!a.j){var c=new aA(a.w);c.sessionId=a.A;{var d=Date.now();const e=new bA;e.h=Math.floor(d/1E3);e.f=d%1E3*1E6;d=e}c.time=d;c.h=b.getId();c.f=new Uint8Array(b.a());a.a.push(c)}},cA=function(a){return _.x(function*(){a.h&&(clearInterval(a.h),a.h=null);a.f&&(yield a.f);0<a.a.length&&(yield Xz(a),a.a=[]);a.j=!0})},dA=function(a){_.x(function*(){a.g.info("Destroy the session and stop sending events.");
7
- _.Dh(a.a);a.Z=!1;const b=a.m.getNetworkEngine();b.me(a.l);b.xd(a.h);Ez(b,a.h);a.f&&(yield cA(a.f),a.f=null)})},lA=function(a){switch(a){case _.To:return eA;case _.Uo:return fA;case _.Po:return gA;case _.Wo:return hA;case _.Vo:return iA;case _.Lo:return jA;case _.Mo:return kA;default:return null}},mA=function(a,b){a.g.debug("Sending event",b);Uz(a.f,b)},uA=function(a,b){switch(a){case 1:return nA;case 2:return b===_.w?oA:b===_.p?pA:b===_.H?qA:b===_.be?rA:sA;case 3:return tA;default:return sA}};var Hz=class{constructor(){this.a=[]}length(){return this.a.length}end(){const a=this.a;this.a=[];return a}};var vA=class{constructor(a,b,c,d){this.downloadId=a;this.h=b;this.duration=c;this.j=d;this.f=[]}a(){const a=new Hz;Qz(a,1,this.downloadId);Lz(a,2,this.h);Qz(a,3,this.duration);Lz(a,4,this.j);Qz(a,5,this.f);return a.end()}getId(){return 4}};var wA=class{constructor(a,b){this.f=a;this.url=b;this.downloadId=null;this.headers=[];this.size=this.duration=null}a(){const a=new Hz;Lz(a,1,this.f);Qz(a,2,this.downloadId);Pz(a,3,this.url);Qz(a,4,this.headers);Pz(a,5,null);Qz(a,6,null);Qz(a,7,this.duration);Nz(a,8,this.size);return a.end()}getId(){return 2}};var xA=class{constructor(a,b){this.h=a;this.f=b}a(){const a=new Hz;Lz(a,1,this.h);Rz(a,2,this.f);return a.end()}};var yA=class{constructor(a){this.cause=a;this.f=this.message=this.severity=this.errorCode=null}a(){const a=new Hz;Lz(a,1,this.errorCode);Lz(a,2,this.severity);Pz(a,3,this.message);Pz(a,4,this.f);Qz(a,5,this.cause);return a.end()}getId(){return 7}};var Zz=class{constructor(a,b){this.key=a;this.value=b}a(){const a=new Hz;Pz(a,1,this.key);Pz(a,2,this.value);return a.end()}};var zA=class{constructor(){this.cause=this.severity=this.code=null}a(){const a=new Hz;Lz(a,1,this.code);Lz(a,2,this.severity);Qz(a,3,this.cause);return a.end()}getId(){return 12}};var AA=class{constructor(){this.data=null}a(){const a=new Hz;Rz(a,1,this.data);return a.end()}};var BA=class extends AA{constructor(){super();var a=new Uint8Array(16);crypto.getRandomValues(a);a[6]=a[6]&15|64;a[8]=a[8]&63|128;this.data=a}toString(){const a=[];for(let b=0;256>b;++b)a.push((b+256).toString(16).slice(1));return a[this.data[0]]+a[this.data[1]]+a[this.data[2]]+a[this.data[3]]+"-"+a[this.data[4]]+a[this.data[5]]+"-"+a[this.data[6]]+a[this.data[7]]+"-"+a[this.data[8]]+a[this.data[9]]+"-"+a[this.data[10]]+a[this.data[11]]+a[this.data[12]]+a[this.data[13]]+a[this.data[14]]+a[this.data[15]]}};var Yz=class{constructor(){this.headers=[]}a(){const a=new Hz;Qz(a,1,this.headers);return a.end()}getId(){return 1}};var Vz=class{constructor(){}a(){return(new Hz).end()}getId(){return 6}};var aA=class{constructor(a){this.j=a;this.f=this.h=this.time=this.sessionId=null}a(){const a=new Hz;Qz(a,1,this.j);Qz(a,2,this.sessionId);Qz(a,3,this.time);Nz(a,4,null);Pz(a,5,null);Lz(a,6,this.h);Rz(a,7,this.f);return a.end()}};var Wz=class{constructor(){this.f=null;this.events=[]}a(){const a=new Hz;Rz(a,1,this.f);Qz(a,2,this.events);return a.end()}};var bA=class{constructor(){this.f=this.h=null}a(){const a=new Hz;Nz(a,1,this.h);Lz(a,2,this.f);return a.end()}};var Sz=class{constructor(){this.f=this.h=null}a(){const a=new Hz;Nz(a,1,this.h);Lz(a,2,this.f);return a.end()}};var CA=class{constructor(a,b,c,d,e,f,g,h,k){k=void 0===k?2500:k;this.o=a;this.l=h;this.w=new BA;this.A=new BA;this.a=[];this.h=setInterval(()=>Xz(this),k);this.f=null;this.j=!1;$z(this,b,c,d,e,f,g)}};var DA=class{constructor(){this.reason=this.currentState=this.previousState=null}a(){const a=new Hz;Lz(a,1,this.previousState);Lz(a,2,this.currentState);Lz(a,3,this.reason);Qz(a,4,null);Qz(a,5,null);Qz(a,6,null);return a.end()}getId(){return 5}};var HA=class extends _.Pv{constructor(){super();this.m=null;this.Z=this.j=!1;this.a=new _.Nt;this.f=null;this.g=new _.S("clpp.sessions.SessionsPlugin");this.l=this.F.bind(this);this.h=this.C.bind(this)}onPlayerCreated(a){this.m=a}onContentWillLoad(a){var b=a.getConfiguration().sessions;(b=!(!b||typeof b!==_.Ce))||this.g.debug("Sessions plugin is loaded but not configured. Will do nothing.");if(this.j=b)b=a.getConfiguration().sessions,b.apiUrl?(this.g.debug(_.ra),this.g.info("Create a session and start sending events."),
8
- a=_.Tk(),this.f=new CA(new Uint8Array([]),a.browser,a.browserVersion.name,a.os,a.osVersion.name,"prestoplay-web",_.ea,b.apiUrl),this.a.on(this.m,_.Kf,this.B.bind(this)),this.a.on(this.m,_.Cf,this.A.bind(this)),this.a.on(this.m,_.Bf,this.w.bind(this)),this.a.on(this.m,_.q,this.o.bind(this)),a=this.m.getNetworkEngine(),a.Jd(this.l),a.Gc(this.h),a.j.push(this.h)):(this.g.warn(Dz),a.onError(new _.I(1,9,15E3,Dz)))}onPlayerWillRelease(){dA(this)}id(){return"sessions"}B(a){if(!this.Z){a=a.detail;var b=a.currentState,
9
- c=new DA;c.previousState=lA(a.previousState);c.currentState=lA(b);mA(this,c)}}A(){if(!this.Z){var a=new DA;a.previousState=lA(this.m.getState());a.currentState=EA;mA(this,a);this.Z=!0}}w(){if(this.Z){var a=new DA;a.previousState=EA;a.currentState=lA(this.m.getState());mA(this,a);this.Z=!1}}o(a){a=a.detail;var b=new zA;b=new yA(new xA(b.getId(),new Uint8Array(b.a())));b.errorCode=a.code;b.message=a.message;b.f=a.stack;b.severity=a.severity===_.G?FA:GA;mA(this,b)}F(a){const b=new BA;a.downloadId=b;
10
- const c=new wA(uA(a.type,a.contentType),a.uris[0]);c.downloadId=b;c.headers=Object.keys(a.headers).map(d=>new Zz(d,a.headers[d]));mA(this,c)}C(a){var b=a.request.downloadId;b?(b=new vA(b,a.data.byteLength,Tz(a.timeMs||0),a.status||-1),b.f=Object.keys(a.headers).map(c=>new Zz(c,a.headers[c])),mA(this,b)):this.g.warn("Download ID is missing on download completed event.")}};_.Ir(new class{create(){return new HA}});var GA=1,FA=2;var eA=0,fA=2,kA=3,EA=5,gA=6,hA=8,iA=10,jA=11;var nA=0,oA=1,pA=2,qA=3,rA=4,tA=5,sA=9;};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var wz="apiUrl config is missing",xz=function(a,b){a.l=a.l.filter(c=>c!==b)},yz=function(a){let b=0>a;a=Math.abs(a);let c=a>>>0;a=Math.floor((a-c)/4294967296);a>>>=0;b&&(a=~a>>>0,c=(~c>>>0)+1,4294967295<c&&(c=0,a++,4294967295<a&&(a=0)));return[c,a]},Dz=function(a,b,c,d){if(!(null===c||void 0===c||typeof c===_.r&&0===c||typeof c===_.Qf&&0===c.length||Array.isArray(c)&&0===c.length))if(Array.isArray(c)){zz(a,b<<3|2);b=new Az;for(let e=0;e<c.length;e++)d(b,c[e]);Bz(a,b.length());Cz(a,b.end())}else zz(a,
2
+ b<<3|0),d(a,c)},Bz=function(a,b){if(0<=b)zz(a,b);else{for(let c=0;9>c;c++)a.a.push(b&127|128),b>>=7;a.a.push(1)}},Ez=function(a,b,c){Dz(a,b,c,(d,e)=>{Bz(d,e)})},zz=function(a,b){for(;127<b;)a.a.push(b&127|128),b>>>=7;a.a.push(b)},Gz=function(a,b,c){Dz(a,b,c,(d,e)=>{if(0<=e){{const [f,g]=yz(e);Fz(d,f,g)}}else{{const [f,g]=yz(e);Fz(d,f,g)}}})},Hz=function(a,b,c,d){if(!(null===c||void 0===c||typeof c===_.r&&0===c||typeof c===_.Qf&&0===c.length||Array.isArray(c)&&0===c.length))if(Array.isArray(c))for(let e=
3
+ 0;e<c.length;e++){zz(a,b<<3|2);const f=new Az;d(f,c[e]);Bz(a,f.length());Cz(a,f.end())}else zz(a,b<<3|2),b=new Az,d(b,c),Bz(a,b.length()),Cz(a,b.end())},Iz=function(a,b,c){Hz(a,b,c,(d,e)=>{for(let f=0;f<e.length;f++){let g=e.charCodeAt(f);if(128>g)d.a.push(g);else if(2048>g)d.a.push(g>>6|192),d.a.push(g&63|128);else if(65536>g)if(55296<=g&&56319>=g&&f+1<e.length){let h=e.charCodeAt(f+1);56320<=h&&57343>=h&&(g=1024*(g-55296)+h-56320+65536,d.a.push(g>>18|240),d.a.push(g>>12&63|128),d.a.push(g>>6&63|
4
+ 128),d.a.push(g&63|128),f++)}else d.a.push(g>>12|224),d.a.push(g>>6&63|128),d.a.push(g&63|128)}})},Cz=function(a,b){a.a.push.apply(a.a,b)},Jz=function(a,b,c){Hz(a,b,c,(d,e)=>{Cz(d,e.a())})},Kz=function(a,b,c){Hz(a,b,c,(d,e)=>{Cz(d,e)})},Fz=function(a,b,c){for(;0<c||127<b;)a.a.push(b&127|128),b=(b>>>7|c<<25)>>>0,c>>>=7;a.a.push(b)},Mz=function(a){const b=new Lz;b.h=Math.floor(a/1E3);b.f=a%1E3*1E6;return b},Qz=function(a){return _.w(function*(){if(!a.j&&!a.f){0===a.a.length&&Nz(a,new Oz);var b=()=>
5
+ {};a.f=new Promise(c=>{b=c});try{const c=new Pz;c.f=a.o;c.events.push(...a.a);const d=[...a.a],e=yield fetch(a.l,{method:_.db,headers:{"Content-Type":"application/proto"},body:new Uint8Array(c.a())});if(e.ok)a.a=a.a.filter(f=>!d.includes(f));else throw Error("An error occurred while sending telemetry events to the API, "+`status='${e.status}' statusText='${e.statusText}'`);}finally{b(),a.f=null}}})},Tz=function(a,b,c,d,e,f,g){const h=new Rz;h.headers=[new Sz("CL-BROWSER-NAME",b),new Sz("CL-BROWSER-VERSION",
6
+ c),new Sz("CL-OS-FAMILY",d),new Sz("CL-OS-VERSION",e),new Sz("CL-SDK-NAME",f),new Sz("CL-SDK-NAME",f),new Sz("CL-SDK-VERSION",g)];Nz(a,h)},Nz=function(a,b){if(!a.j){var c=new Uz(a.w);c.sessionId=a.A;{var d=Date.now();const e=new Vz;e.h=Math.floor(d/1E3);e.f=d%1E3*1E6;d=e}c.time=d;c.h=b.getId();c.f=new Uint8Array(b.a());a.a.push(c)}},Wz=function(a){return _.w(function*(){a.h&&(clearInterval(a.h),a.h=null);a.f&&(yield a.f);0<a.a.length&&(yield Qz(a),a.a=[]);a.j=!0})},Xz=function(a){_.w(function*(){a.g.info("Destroy the session and stop sending events.");
7
+ _.Hh(a.a);a.Y=!1;const b=a.m.getNetworkEngine();b.Se(a.l);b.td(a.h);xz(b,a.h);a.f&&(yield Wz(a.f),a.f=null)})},eA=function(a){switch(a){case _.pp:return Yz;case _.qp:return Zz;case _.lp:return $z;case _.sp:return aA;case _.rp:return bA;case _.hp:return cA;case _.ip:return dA;default:return null}},fA=function(a,b){a.g.debug("Sending event",b);Nz(a.f,b)},nA=function(a,b){switch(a){case 1:return gA;case 2:return b===_.t?hA:b===_.q?iA:b===_.H?jA:b===_.ee?kA:lA;case 3:return mA;default:return lA}};var Az=class{constructor(){this.a=[]}length(){return this.a.length}end(){const a=this.a;this.a=[];return a}};var oA=class{constructor(a,b,c,d){this.downloadId=a;this.h=b;this.duration=c;this.j=d;this.f=[]}a(){const a=new Az;Jz(a,1,this.downloadId);Ez(a,2,this.h);Jz(a,3,this.duration);Ez(a,4,this.j);Jz(a,5,this.f);return a.end()}getId(){return 4}};var pA=class{constructor(a,b){this.f=a;this.url=b;this.downloadId=null;this.headers=[];this.size=this.duration=null}a(){const a=new Az;Ez(a,1,this.f);Jz(a,2,this.downloadId);Iz(a,3,this.url);Jz(a,4,this.headers);Iz(a,5,null);Jz(a,6,null);Jz(a,7,this.duration);Gz(a,8,this.size);return a.end()}getId(){return 2}};var qA=class{constructor(a,b){this.h=a;this.f=b}a(){const a=new Az;Ez(a,1,this.h);Kz(a,2,this.f);return a.end()}};var rA=class{constructor(a){this.cause=a;this.f=this.message=this.severity=this.errorCode=null}a(){const a=new Az;Ez(a,1,this.errorCode);Ez(a,2,this.severity);Iz(a,3,this.message);Iz(a,4,this.f);Jz(a,5,this.cause);return a.end()}getId(){return 7}};var Sz=class{constructor(a,b){this.key=a;this.value=b}a(){const a=new Az;Iz(a,1,this.key);Iz(a,2,this.value);return a.end()}};var sA=class{constructor(){this.cause=this.severity=this.code=null}a(){const a=new Az;Ez(a,1,this.code);Ez(a,2,this.severity);Jz(a,3,this.cause);return a.end()}getId(){return 12}};var tA=class{constructor(){this.data=null}a(){const a=new Az;Kz(a,1,this.data);return a.end()}};var uA=class extends tA{constructor(){super();var a=new Uint8Array(16);crypto.getRandomValues(a);a[6]=a[6]&15|64;a[8]=a[8]&63|128;this.data=a}toString(){const a=[];for(let b=0;256>b;++b)a.push((b+256).toString(16).slice(1));return a[this.data[0]]+a[this.data[1]]+a[this.data[2]]+a[this.data[3]]+"-"+a[this.data[4]]+a[this.data[5]]+"-"+a[this.data[6]]+a[this.data[7]]+"-"+a[this.data[8]]+a[this.data[9]]+"-"+a[this.data[10]]+a[this.data[11]]+a[this.data[12]]+a[this.data[13]]+a[this.data[14]]+a[this.data[15]]}};var Rz=class{constructor(){this.headers=[]}a(){const a=new Az;Jz(a,1,this.headers);return a.end()}getId(){return 1}};var Oz=class{constructor(){}a(){return(new Az).end()}getId(){return 6}};var Uz=class{constructor(a){this.j=a;this.f=this.h=this.time=this.sessionId=null}a(){const a=new Az;Jz(a,1,this.j);Jz(a,2,this.sessionId);Jz(a,3,this.time);Gz(a,4,null);Iz(a,5,null);Ez(a,6,this.h);Kz(a,7,this.f);return a.end()}};var Pz=class{constructor(){this.f=null;this.events=[]}a(){const a=new Az;Kz(a,1,this.f);Jz(a,2,this.events);return a.end()}};var Vz=class{constructor(){this.f=this.h=null}a(){const a=new Az;Gz(a,1,this.h);Ez(a,2,this.f);return a.end()}};var Lz=class{constructor(){this.f=this.h=null}a(){const a=new Az;Gz(a,1,this.h);Ez(a,2,this.f);return a.end()}};var vA=class{constructor(a,b,c,d,e,f,g,h,k){k=void 0===k?2500:k;this.o=a;this.l=h;this.w=new uA;this.A=new uA;this.a=[];this.h=setInterval(()=>Qz(this),k);this.f=null;this.j=!1;Tz(this,b,c,d,e,f,g)}};var wA=class{constructor(){this.reason=this.currentState=this.previousState=null}a(){const a=new Az;Ez(a,1,this.previousState);Ez(a,2,this.currentState);Ez(a,3,this.reason);Jz(a,4,null);Jz(a,5,null);Jz(a,6,null);return a.end()}getId(){return 5}};var AA=class extends _.Iv{constructor(){super();this.m=null;this.Y=this.j=!1;this.a=new _.Kt;this.f=null;this.g=new _.S("clpp.sessions.SessionsPlugin");this.l=this.F.bind(this);this.h=this.C.bind(this)}onPlayerCreated(a){this.m=a}onContentWillLoad(a){var b=a.getConfiguration().sessions;(b=!(!b||typeof b!==_.Fe))||this.g.debug("Sessions plugin is loaded but not configured. Will do nothing.");if(this.j=b)b=a.getConfiguration().sessions,b.apiUrl?(this.g.debug(_.sa),this.g.info("Create a session and start sending events."),
8
+ a=_.ok(),this.f=new vA(new Uint8Array([]),a.browser,a.browserVersion.name,a.os,a.osVersion.name,"prestoplay-web",_.ea,b.apiUrl),this.a.on(this.m,_.Nf,this.B.bind(this)),this.a.on(this.m,_.Ff,this.A.bind(this)),this.a.on(this.m,_.Ef,this.w.bind(this)),this.a.on(this.m,_.Ud,this.o.bind(this)),a=this.m.getNetworkEngine(),a.me(this.l),a.Ac(this.h),a.l.push(this.h)):(this.g.warn(wz),a.onError(new _.I(1,9,15E3,wz)))}onPlayerWillRelease(){Xz(this)}id(){return"sessions"}B(a){if(!this.Y){a=a.detail;var b=
9
+ a.currentState,c=new wA;c.previousState=eA(a.previousState);c.currentState=eA(b);fA(this,c)}}A(){if(!this.Y){var a=new wA;a.previousState=eA(this.m.getState());a.currentState=xA;fA(this,a);this.Y=!0}}w(){if(this.Y){var a=new wA;a.previousState=xA;a.currentState=eA(this.m.getState());fA(this,a);this.Y=!1}}o(a){a=a.detail;var b=new sA;b=new rA(new qA(b.getId(),new Uint8Array(b.a())));b.errorCode=a.code;b.message=a.message;b.f=a.stack;b.severity=a.severity===_.F?yA:zA;fA(this,b)}F(a){const b=new uA;
10
+ a.downloadId=b;const c=new pA(nA(a.type,a.contentType),a.uris[0]);c.downloadId=b;c.headers=Object.keys(a.headers).map(d=>new Sz(d,a.headers[d]));fA(this,c)}C(a){var b=a.request.downloadId;b?(b=new oA(b,a.data.byteLength,Mz(a.timeMs||0),a.status||-1),b.f=Object.keys(a.headers).map(c=>new Sz(c,a.headers[c])),fA(this,b)):this.g.warn("Download ID is missing on download completed event.")}};_.fs(new class{create(){return new AA}});var zA=1,yA=2;var Yz=0,Zz=2,dA=3,xA=5,$z=6,aA=8,bA=10,cA=11;var gA=0,hA=1,iA=2,jA=3,kA=4,mA=5,lA=9;};f.call(g, window);
package/cl.simid.js CHANGED
@@ -1,14 +1,14 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var mz="No surface found. Can not attach frame!",nz="SIMID:Media:timeupdate",oz="Starting creative",pz=function(a,b,c){return{type:b,sessionId:a.h,messageId:a.l++,timestamp:Date.now(),args:c}},sz=function(a,b){return new Promise((c,d)=>{new qz(a.j,c,d,b);rz(a,b)})},tz=function(a){const b=pz(a,"SIMID:Player:startCreative",void 0);sz(a,b).then(()=>{var c=a.f;c.g.info(oz);c.m.trigger(new _.F(_.Ef));a.a.style.opacity="1"}).catch(c=>{a.unload();a.f.g.error("Error while starting creative",
2
- c)})},vz=function(a,b){_.x(function*(){a.h=b.sessionId;uz(a,b);try{{var c=a.f;const f=c.getSurface(),g=c.getContainer();var d={environmentData:{videoDimensions:{x:0,y:0,height:g.clientHeight,width:g.clientWidth},creativeDimensions:{x:0,y:0,height:g.clientHeight,width:g.clientWidth},fullscreen:f.isFullscreen(),fullscreenAllowed:!0,variableDurationAllowed:!1,skippableState:"notSkippable",version:"1.1",skipoffset:"",siteUrl:window.location.toString(),appId:"",useragent:"",deviceId:"",muted:c.m.isMuted()||
3
- !1,volume:c.m.getVolume()||0,navigationSupport:"adHandles",closeButtonSupport:"adHandles",nonlinearDuration:c.f.duration},creativeData:{adParameters:c.f.adParameters||"",clickThruUri:"",clickThruUrl:""}}}{const f=pz(a,"SIMID:Player:init",d);var e=sz(a,f)}yield e;a.g.info("Player Init acknowledged");a.f.g.info("SIMID Player initialized")}catch(f){a.g.error("Error while initializing",f),a.f.g.error("Error while initializing SIMID player: ",f),a.unload()}})},uz=function(a,b){rz(a,pz(a,"resolve",{messageId:b.messageId,
4
- value:void 0}))},rz=function(a,b){a.h?(b.type!==nz&&a.g.info(`Posting message [${b.messageId}] '${b.type}':`,b.args),a.a.contentWindow&&a.a.contentWindow.postMessage(JSON.stringify(b),"*")):a.g.warn(`WARNING: no session available to send message '${b.type}'`)},wz=function(a,b,c){return new ResizeObserver(()=>{if(a.a.h){var d=a.a,e={videoDimensions:{x:0,y:0,height:b.clientHeight,width:b.clientWidth},creativeDimensions:{x:0,y:0,height:b.clientHeight,width:b.clientWidth},fullscreen:c.isFullscreen()};
5
- e=pz(d,"SIMID:Player:resize",e);rz(d,e)}})},xz=function(a,b){a.g.info("SIMID Session created");a.a=b},yz=function(a){a.g.info("Stopping creative");a.m.getSurface().getMedia().style.transition=".5s";setTimeout(()=>{a.m.getSurface().getMedia().style.transition=""},500);a.m.getSurface().getMedia().style.left="";a.m.getSurface().getMedia().style.top="";a.m.getSurface().getMedia().style.width="";a.m.getSurface().getMedia().style.height="";a.a.a.style.left="";a.a.a.style.top="";a.a.a.style.width="";a.a.a.style.height=
6
- "";a.h=!1;a.m.trigger(new _.F(_.Ff))},zz=function(a,b){var c=a.getContainer();a=c.clientWidth;c=c.clientHeight;return{top:`${b.y/c*100}%`,left:`${b.x/a*100}%`,width:`${b.width/a*100}%`,height:`${b.height/c*100}%`}},Az=class{constructor(a,b){this.f=a;this.w=b;this.h="";this.l=0;this.j=new Map;this.a=document.createElement("iframe");this.a.style.opacity="0";a=this.w.style;a.className?this.a.classList.add(a.className):(this.a.style.border=_.Be,this.a.style.backgroundColor="transparent",this.a.style.transition=
7
- "opacity .5s",this.a.style.transitionDelay=".5s",this.a.style.pointerEvents=_.Be,this.a.style.overflow=_.$d);this.a.classList.add(_.Yc);this.o=c=>{if(c.source===this.a.contentWindow&&(c=(c=c.data)?typeof c===_.Nf?JSON.parse(c):c:null))if(c.type)switch(this.g.info(`Received message [${c.messageId}] '${c.type}':`,c.args),c.type){case "createSession":vz(this,c);break;case "resolve":c=c.args;var d=this.j.get(c.messageId);d&&d.resolve(c);break;case "reject":c=c.args;(d=this.j.get(c.messageId))&&d.reject(c);
8
- break;case "SIMID:Creative:requestResize":d=this.f;var e=c.args;d.g.info("Creative requested resize",e);if(d.m&&d.m.getSurface()&&d.m.getSurface().getMedia()&&e.mediaDimensions){d.h?d.m.getSurface().getMedia().style.transition="":(d.m.getSurface().getMedia().style.transition="left .5s, top .5s,width .5s, height .5s",d.h=!0);const f=zz(d,e.mediaDimensions);d.m.getSurface().getMedia().style.left=f.left;d.m.getSurface().getMedia().style.top=f.top;d.m.getSurface().getMedia().style.width=f.width;d.m.getSurface().getMedia().style.height=
9
- f.height}e.creativeDimensions&&(e=zz(d,e.creativeDimensions),d.a.a.style.left=e.left,d.a.a.style.top=e.top,d.a.a.style.width=e.width,d.a.a.style.height=e.height);uz(this,c)}else this.g.warn("WARNING: received message without 'type' property")};this.g=new _.S("clpp.simid.SimidPlayer");xz(this.f,this)}load(a){window.addEventListener(_.re,this.o);this.h="";this.l=0;const b=this.f.url();this.g.info(`Loading "${b}" as src of iFrame`);this.a.src=b;this.g.info("Attaching iFrame");a.appendChild(this.a)}unload(){yz(this.f);
10
- this.h=this.a.src="";this.l=0;this.a.style.opacity="0";window.removeEventListener(_.re,this.o);this.a.parentElement&&this.a.parentElement.removeChild(this.a)}},qz=class{constructor(a,b,c,d,e){e=void 0===e?-1:e;this.f=a;this.l=b;this.j=c;this.h=d;this.a=null;this.f.set(d.messageId,this);0<=e&&(this.a=setTimeout(()=>{this.resolve()},e))}resolve(a){null!==this.a&&(clearTimeout(this.a),this.a=null);this.f.delete(this.h.messageId);this.l(a)}reject(a){null!==this.a&&(clearTimeout(this.a),this.a=null);this.f.delete(this.h.messageId);
11
- this.j(a)}};var Cz=class extends _.Pv{constructor(){super();this.g=new _.S("clpp.simid.Plugin");this.h=this.a=this.m=null;this.l=[];this.j=null;this.w=this.A.bind(this);this.f=null;this.o=!1}id(){return"simid"}onPlayerCreated(a){this.g.info("New player created");this.a&&(this.a.unload(),this.a=null);this.m=a;this.h&&this.h.release();this.h=new Bz(a)}onContentWillLoad(a){var b=a.getConfiguration();if(b.simid&&b.simid.creatives&&0!==b.simid.creatives.length){this.l=b.simid.creatives;this.g.info(`Setting up SIMID plugin for ${this.l.length} creatives`);
12
- var c=this.m.getSurface();c?(this.g.info("Creating new session"),this.a=new Az(this.h,b.simid),b=c.getContainer(),this.j=wz(this,b,c),this.j.observe(b),a.on(_.Zf,this.w)):this.g.warn(mz)}}A(){var a=this.m.getPosition();a:if(this.f&&a<this.f.startTime+this.f.duration)var b=this.f;else{for(b=0;b<this.l.length;b++){var c=this.l[b];const d=c.startTime+c.duration;if(a>=c.startTime-(c.preload||5)&&a<d){b=c;break a}}b=null}b?b===this.f?(b=b.startTime,this.a&&(c=a>=b,!this.o&&c&&(tz(this.a),this.o=!0,this.g.info(oz)),
13
- c&&(c=this.a,rz(c,pz(c,nz,{currentTime:a-b}))))):((a=this.m.getSurface())||this.g.warn(mz),a=a.getContainer(),this.f=b,this.o=!1,this.g.info("Loading session"),this.h.f=b,this.a.load(a)):this.f&&(this.a.unload(),this.f=null,this.o=!1)}onPlayerWillRelease(a){super.onPlayerWillRelease(a);this.m.getSurface()&&(this.j&&(this.j.disconnect(),this.j=null),a.off(_.Zf,this.w),this.f&&(this.a.unload(),this.f=this.h.f=null))}},Bz=class{constructor(a){this.m=a;this.a=null;this.g=new _.S("clpp.simid.Loader");
14
- this.h=!1;this.f=null}release(){this.g.info("Releasing loader")}getContainer(){const a=this.getSurface().getContainer();if(!a)throw this.g.error("No player container found. Can not create SIMID init data"),new _.I(1,10,10100,"No player container found");return a}getSurface(){const a=this.m.getSurface();if(!a)throw this.g.error("No player surface found. Can not create SIMID init data"),new _.I(1,10,10100,"No surface");return a}bg(){return this.a}url(){return this.f?this.f.url:""}};_.Ir(new class{create(){return new Cz}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var fz="No surface found. Can not attach frame!",gz="SIMID:Media:timeupdate",hz="Starting creative",iz=function(a,b,c){return{type:b,sessionId:a.h,messageId:a.l++,timestamp:Date.now(),args:c}},lz=function(a,b){return new Promise((c,d)=>{new jz(a.j,c,d,b);kz(a,b)})},mz=function(a){const b=iz(a,"SIMID:Player:startCreative",void 0);lz(a,b).then(()=>{var c=a.f;c.g.info(hz);c.m.trigger(new _.C(_.Hf));a.a.style.opacity="1"}).catch(c=>{a.unload();a.f.g.error("Error while starting creative",
2
+ c)})},oz=function(a,b){_.w(function*(){a.h=b.sessionId;nz(a,b);try{{var c=a.f;const f=c.getSurface(),g=c.getContainer();var d={environmentData:{videoDimensions:{x:0,y:0,height:g.clientHeight,width:g.clientWidth},creativeDimensions:{x:0,y:0,height:g.clientHeight,width:g.clientWidth},fullscreen:f.isFullscreen(),fullscreenAllowed:!0,variableDurationAllowed:!1,skippableState:"notSkippable",version:"1.1",skipoffset:"",siteUrl:window.location.toString(),appId:"",useragent:"",deviceId:"",muted:c.m.isMuted()||
3
+ !1,volume:c.m.getVolume()||0,navigationSupport:"adHandles",closeButtonSupport:"adHandles",nonlinearDuration:c.f.duration},creativeData:{adParameters:c.f.adParameters||"",clickThruUri:"",clickThruUrl:""}}}{const f=iz(a,"SIMID:Player:init",d);var e=lz(a,f)}yield e;a.g.info("Player Init acknowledged");a.f.g.info("SIMID Player initialized")}catch(f){a.g.error("Error while initializing",f),a.f.g.error("Error while initializing SIMID player: ",f),a.unload()}})},nz=function(a,b){kz(a,iz(a,"resolve",{messageId:b.messageId,
4
+ value:void 0}))},kz=function(a,b){a.h?(b.type!==gz&&a.g.info(`Posting message [${b.messageId}] '${b.type}':`,b.args),a.a.contentWindow&&a.a.contentWindow.postMessage(JSON.stringify(b),"*")):a.g.warn(`WARNING: no session available to send message '${b.type}'`)},pz=function(a,b,c){return new ResizeObserver(()=>{if(a.a.h){var d=a.a,e={videoDimensions:{x:0,y:0,height:b.clientHeight,width:b.clientWidth},creativeDimensions:{x:0,y:0,height:b.clientHeight,width:b.clientWidth},fullscreen:c.isFullscreen()};
5
+ e=iz(d,"SIMID:Player:resize",e);kz(d,e)}})},qz=function(a,b){a.g.info("SIMID Session created");a.a=b},rz=function(a){a.g.info("Stopping creative");a.m.getSurface().getMedia().style.transition=".5s";setTimeout(()=>{a.m.getSurface().getMedia().style.transition=""},500);a.m.getSurface().getMedia().style.left="";a.m.getSurface().getMedia().style.top="";a.m.getSurface().getMedia().style.width="";a.m.getSurface().getMedia().style.height="";a.a.a.style.left="";a.a.a.style.top="";a.a.a.style.width="";a.a.a.style.height=
6
+ "";a.h=!1;a.m.trigger(new _.C(_.If))},sz=function(a,b){var c=a.getContainer();a=c.clientWidth;c=c.clientHeight;return{top:`${b.y/c*100}%`,left:`${b.x/a*100}%`,width:`${b.width/a*100}%`,height:`${b.height/c*100}%`}},tz=class{constructor(a,b){this.f=a;this.w=b;this.h="";this.l=0;this.j=new Map;this.a=document.createElement("iframe");this.a.style.opacity="0";a=this.w.style;a.className?this.a.classList.add(a.className):(this.a.style.border=_.Ee,this.a.style.backgroundColor="transparent",this.a.style.transition=
7
+ "opacity .5s",this.a.style.transitionDelay=".5s",this.a.style.pointerEvents=_.Ee,this.a.style.overflow=_.be);this.a.classList.add(_.Zc);this.o=c=>{if(c.source===this.a.contentWindow&&(c=(c=c.data)?typeof c===_.Qf?JSON.parse(c):c:null))if(c.type)switch(this.g.info(`Received message [${c.messageId}] '${c.type}':`,c.args),c.type){case "createSession":oz(this,c);break;case "resolve":c=c.args;var d=this.j.get(c.messageId);d&&d.resolve(c);break;case "reject":c=c.args;(d=this.j.get(c.messageId))&&d.reject(c);
8
+ break;case "SIMID:Creative:requestResize":d=this.f;var e=c.args;d.g.info("Creative requested resize",e);if(d.m&&d.m.getSurface()&&d.m.getSurface().getMedia()&&e.mediaDimensions){d.h?d.m.getSurface().getMedia().style.transition="":(d.m.getSurface().getMedia().style.transition="left .5s, top .5s,width .5s, height .5s",d.h=!0);const f=sz(d,e.mediaDimensions);d.m.getSurface().getMedia().style.left=f.left;d.m.getSurface().getMedia().style.top=f.top;d.m.getSurface().getMedia().style.width=f.width;d.m.getSurface().getMedia().style.height=
9
+ f.height}e.creativeDimensions&&(e=sz(d,e.creativeDimensions),d.a.a.style.left=e.left,d.a.a.style.top=e.top,d.a.a.style.width=e.width,d.a.a.style.height=e.height);nz(this,c)}else this.g.warn("WARNING: received message without 'type' property")};this.g=new _.S("clpp.simid.SimidPlayer");qz(this.f,this)}load(a){window.addEventListener(_.ue,this.o);this.h="";this.l=0;const b=this.f.url();this.g.info(`Loading "${b}" as src of iFrame`);this.a.src=b;this.g.info("Attaching iFrame");a.appendChild(this.a)}unload(){rz(this.f);
10
+ this.h=this.a.src="";this.l=0;this.a.style.opacity="0";window.removeEventListener(_.ue,this.o);this.a.parentElement&&this.a.parentElement.removeChild(this.a)}},jz=class{constructor(a,b,c,d,e){e=void 0===e?-1:e;this.f=a;this.l=b;this.j=c;this.h=d;this.a=null;this.f.set(d.messageId,this);0<=e&&(this.a=setTimeout(()=>{this.resolve()},e))}resolve(a){null!==this.a&&(clearTimeout(this.a),this.a=null);this.f.delete(this.h.messageId);this.l(a)}reject(a){null!==this.a&&(clearTimeout(this.a),this.a=null);this.f.delete(this.h.messageId);
11
+ this.j(a)}};var vz=class extends _.Iv{constructor(){super();this.g=new _.S("clpp.simid.Plugin");this.h=this.a=this.m=null;this.l=[];this.j=null;this.w=this.A.bind(this);this.f=null;this.o=!1}id(){return"simid"}onPlayerCreated(a){this.g.info("New player created");this.a&&(this.a.unload(),this.a=null);this.m=a;this.h&&this.h.release();this.h=new uz(a)}onContentWillLoad(a){var b=a.getConfiguration();if(b.simid&&b.simid.creatives&&0!==b.simid.creatives.length){this.l=b.simid.creatives;this.g.info(`Setting up SIMID plugin for ${this.l.length} creatives`);
12
+ var c=this.m.getSurface();c?(this.g.info("Creating new session"),this.a=new tz(this.h,b.simid),b=c.getContainer(),this.j=pz(this,b,c),this.j.observe(b),a.on(_.cg,this.w)):this.g.warn(fz)}}A(){var a=this.m.getPosition();a:if(this.f&&a<this.f.startTime+this.f.duration)var b=this.f;else{for(b=0;b<this.l.length;b++){var c=this.l[b];const d=c.startTime+c.duration;if(a>=c.startTime-(c.preload||5)&&a<d){b=c;break a}}b=null}b?b===this.f?(b=b.startTime,this.a&&(c=a>=b,!this.o&&c&&(mz(this.a),this.o=!0,this.g.info(hz)),
13
+ c&&(c=this.a,kz(c,iz(c,gz,{currentTime:a-b}))))):((a=this.m.getSurface())||this.g.warn(fz),a=a.getContainer(),this.f=b,this.o=!1,this.g.info("Loading session"),this.h.f=b,this.a.load(a)):this.f&&(this.a.unload(),this.f=null,this.o=!1)}onPlayerWillRelease(a){super.onPlayerWillRelease(a);this.m.getSurface()&&(this.j&&(this.j.disconnect(),this.j=null),a.off(_.cg,this.w),this.f&&(this.a.unload(),this.f=this.h.f=null))}},uz=class{constructor(a){this.m=a;this.a=null;this.g=new _.S("clpp.simid.Loader");
14
+ this.h=!1;this.f=null}release(){this.g.info("Releasing loader")}getContainer(){const a=this.getSurface().getContainer();if(!a)throw this.g.error("No player container found. Can not create SIMID init data"),new _.I(1,10,10100,"No player container found");return a}getSurface(){const a=this.m.getSurface();if(!a)throw this.g.error("No player surface found. Can not create SIMID init data"),new _.I(1,10,10100,"No surface");return a}Tf(){return this.a}url(){return this.f?this.f.url:""}};_.fs(new class{create(){return new vz}});};f.call(g, window);