@castlabs/prestoplay 6.3.0 → 6.4.1

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 +70 -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 +108 -107
  6. package/cjs/cl.conviva.js +33 -33
  7. package/cjs/cl.core.js +426 -398
  8. package/cjs/cl.crypto.js +10 -10
  9. package/cjs/cl.dash.js +72 -69
  10. package/cjs/cl.externs.js +79 -155
  11. package/cjs/cl.freewheel.js +24 -24
  12. package/cjs/cl.hls.js +47 -44
  13. package/cjs/cl.hlssmpte.js +6 -6
  14. package/cjs/cl.htmlcue.js +31 -32
  15. package/cjs/cl.ima.js +22 -22
  16. package/cjs/cl.mse.js +259 -254
  17. package/cjs/cl.muxdata.js +12 -12
  18. package/cjs/cl.onboard.js +3 -3
  19. package/cjs/cl.persistent.js +14 -14
  20. package/cjs/cl.playlist.js +6 -6
  21. package/cjs/cl.smooth.js +69 -69
  22. package/cjs/cl.thumbnails.js +24 -23
  23. package/cjs/cl.tizen.js +70 -70
  24. package/cjs/cl.ttml.js +27 -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 +20 -19
  30. package/cl.adobe.js +3 -3
  31. package/cl.airplay.js +3 -3
  32. package/cl.broadpeak.js +5 -5
  33. package/cl.cast.js +88 -87
  34. package/cl.conviva.js +27 -27
  35. package/cl.core.js +365 -348
  36. package/cl.crypto.js +8 -8
  37. package/cl.dash.js +67 -63
  38. package/cl.externs.js +74 -154
  39. package/cl.freewheel.js +19 -19
  40. package/cl.hls.js +39 -37
  41. package/cl.hlssmpte.js +5 -5
  42. package/cl.htmlcue.js +25 -25
  43. package/cl.ima.js +16 -16
  44. package/cl.mse.js +233 -222
  45. package/cl.muxdata.js +8 -8
  46. package/cl.onboard.js +4 -4
  47. package/cl.persistent.js +10 -10
  48. package/cl.playlist.js +5 -5
  49. package/cl.smooth.js +58 -58
  50. package/cl.thumbnails.js +17 -17
  51. package/cl.tizen.js +57 -57
  52. package/cl.ttml.js +22 -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 +16 -15
  58. package/package.json +4 -2
package/cl.muxdata.js CHANGED
@@ -1,8 +1,8 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Ls=function(a){let b={debug:!0,data:Ks(a)};a.g&&a.g.muxOptionsOverride&&_.jf(a.g.muxOptionsOverride)&&(b=_.ff(b,a.g.muxOptionsOverride,{getPlayheadTime:()=>1E3*a.l.getPosition(),getStateData:()=>{{a.f.debug("getStateData()");var c=a.l.getLoadedSource(),d=a.l.getTrackManager();const f=a.l.getSurface(),g=d.fa();var e={player_is_paused:a.l.isPaused(),player_is_fullscreen:f.isFullscreen(),video_source_duration:1E3*a.l.getDuration(),player_autoplay_on:!!a.l.getConfiguration().autoplay};
2
- if(c){const h=new _.Yi(c.url);e.video_source_url=_.Ui(h);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;g&&g.height&&g.width&&(e.video_source_height=g.height,e.video_source_width=g.width);(d=d.ha())&&d.language&&(e.player_language_code=d.language)}return e}}));a.f.debug("Mux SDK options",b);return b},Ms=function(a,b,c){a.f.debug(`Event: ${b}`);mux.emit(a.A,b,c)},Ks=function(a){const b={env_key:a.g.envKey,
3
- video_title:a.m&&a.m.name||"",player_software_name:_.la,player_software_version:_.da,player_mux_plugin_name:"CastlabsPlayer built-in Mux Plugin",player_mux_plugin_version:_.da};(a=a.l.getConfiguration().viewerId)&&(b.viewer_user_id=a);return b},Ns=function(a){a.a.on(a.l,_.re,()=>{Ms(a,_.re,{player_playhead_time:1E3*a.l.getPosition()})});a.a.on(a.l,_.Nd,()=>Ms(a,_.Nd));a.a.on(a.l,_.bc,a.B.bind(a));a.a.on(a.l,_.ge,a.D.bind(a));a.a.on(a.l,_.Be,()=>Ms(a,_.ae));a.a.on(a.l,_.Ae,()=>Ms(a,_.$d));a.a.on(a.l,
4
- _.Tc,a.C.bind(a));a.a.on(a.l,_.qb,()=>Ms(a,"adbreakstart"));a.a.on(a.l,_.rb,()=>Ms(a,"adbreakend"));a.a.on(a.l,_.Db,()=>{Ms(a,"adplay");Ms(a,"adplaying")});a.a.on(a.l,_.zb,()=>Ms(a,"adpause"));a.a.on(a.l,_.Bb,()=>{Ms(a,"adplay");Ms(a,"adplaying")});a.a.on(a.l,_.Eb,()=>Ms(a,"adended"));a.a.on(a.l,_.vb,()=>Ms(a,"adfirstquartile"));a.a.on(a.l,_.yb,()=>Ms(a,"admidpoint"));a.a.on(a.l,_.Fb,()=>Ms(a,"adthirdquartile"))},Os=class{constructor(a,b){this.l=a;this.m=this.g=null;this.A=("000000"+(Math.random()*
5
- Math.pow(36,6)<<0).toString(36)).slice(-6);this.a=new _.Fn;this.f=b;this.o=this.j=this.h=this.w=!1}initialize(a,b){this.g=a;this.m=b;this.w=!1;if(!this.h){try{this.h=!0,mux.init(this.A,Ls(this))}catch(c){throw this.h=!1,_.Jf(this.a),new _.G(1,9,9302,null,c);}Ms(this,"playerready")}this.j&&!this.o&&(Ms(this,"videochange",Ks(this)),this.j=!1);Ns(this)}release(){this.f.debug("release()");this.j?this.f.debug(_.ha):(_.Jf(this.a),this.j=!0,this.m=this.g=null)}destroy(){this.f.debug(_.Hc);this.o?this.f.debug(_.fa):
6
- (this.o=!0,this.h&&this.w&&Ms(this,"viewend"),Ms(this,"destroy"))}B(a){this.f.debug(_.xd);var b=a.detail;a=this.l.getTrackManager();b&&b.bandwidth&&(b=b.bandwidth,(a=a.xa())&&a.bandwidth&&(b+=a.bandwidth),Ms(this,"renditionchange",{video_source_bitrate:b}))}D(a){this.f.debug(_.Bd);switch(a.detail.currentState){case _.al:this.l.getConfiguration().autoplay&&Ms(this,_.Nd);break;case _.dl:Ms(this,_.Od);break;case _.bl:Ms(this,_.Jd);break;case _.Sk:this.w=!0,Ms(this,_.Sc)}}C(a){this.f.debug(_.yd);if(this.h&&
7
- (a=a.detail||null))if(10003===a.code)Ms(this,"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)}`;Ms(this,_.Tc,{player_error_code:a.code,player_error_message:b})}}};var Ps=class extends _.up{constructor(){super();this.f=null;this.a=!1;this.g=new _.O("clpp.muxdata")}onPlayerCreated(a){this.f=new Os(a,this.g)}onContentWillLoad(a,b){var c=a.getConfiguration();if(this.a=!_.y(c.muxdata)&&typeof c.muxdata===_.wd){var d=c.muxdata;if(c="undefined"===typeof window.mux)c=d.muxLib,d="undefined"!==typeof c&&typeof c.init===_.Vc&&typeof c.emit===_.Vc,window.mux=c,c=d,c=!c;c&&(this.g.warn("Mux SDK is not loaded. Will do nothing."),this.a=!1,c=new _.G(1,9,9301),this.U(a,c))}else this.g.warn("Mux plugin is loaded but not configured. Will do nothing.");
8
- if(this.a){c=a.getConfiguration();c=_.gf(c.muxdata||{});try{d=[];typeof c===_.wd&&(c.envKey||d.push("envKey"));if(0<d.length)throw new _.G(1,9,9300,{missingKeys:d});this.f.initialize(c,b)}catch(e){this.a=!1,this.U(a,e)}}}onContentLoaded(){}onPlayerWillDestroy(){this.a&&(this.f.destroy(),this.f=null)}onPlayerWillRelease(){this.a&&this.f.release()}id(){return"mux"}U(a,b){a.trigger(new _.B(_.Tc,{detail:b}))}};_.x("clpp.muxdata.MuxDataPlugin",Ps);Ps.Id="mux";_.cm(new class{create(){return new Ps}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var qt=function(a){let b={debug:!0,data:pt(a)};a.g&&a.g.muxOptionsOverride&&_.kf(a.g.muxOptionsOverride)&&(b=_.gf(b,a.g.muxOptionsOverride,{getPlayheadTime:()=>1E3*a.l.getPosition(),getStateData:()=>{{a.f.debug("getStateData()");var c=a.l.getLoadedSource(),d=a.l.getTrackManager();const f=a.l.getSurface(),g=d.da();var e={player_is_paused:a.l.isPaused(),player_is_fullscreen:f.isFullscreen(),video_source_duration:1E3*a.l.getDuration(),player_autoplay_on:!!a.l.getConfiguration().autoplay};
2
+ if(c){const h=new _.Dj(c.url);e.video_source_url=_.nh(h);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;g&&g.height&&g.width&&(e.video_source_height=g.height,e.video_source_width=g.width);(d=d.ia())&&d.language&&(e.player_language_code=d.language)}return e}}));a.f.debug("Mux SDK options",b);return b},rt=function(a,b,c){a.f.debug(`Event: ${b}`);mux.emit(a.A,b,c)},pt=function(a){const b={env_key:a.g.envKey,
3
+ video_title:a.m&&a.m.name||"",player_name:_.pa,player_software_name:_.pa,player_software_version:_.da,player_mux_plugin_name:"CastlabsPlayer built-in Mux Plugin",player_mux_plugin_version:_.da};(a=a.l.getConfiguration().viewerId)&&(b.viewer_user_id=a);return b},st=function(a){a.a.on(a.l,_.te,()=>{rt(a,_.te,{player_playhead_time:1E3*a.l.getPosition()})});a.a.on(a.l,_.Qd,()=>rt(a,_.Qd));a.a.on(a.l,_.ec,a.B.bind(a));a.a.on(a.l,_.ie,a.D.bind(a));a.a.on(a.l,_.Be,()=>rt(a,_.de));a.a.on(a.l,_.Ae,()=>rt(a,
4
+ _.ce));a.a.on(a.l,_.Wc,a.C.bind(a));a.a.on(a.l,_.ub,()=>rt(a,"adbreakstart"));a.a.on(a.l,_.vb,()=>rt(a,"adbreakend"));a.a.on(a.l,_.Hb,()=>{rt(a,"adplay");rt(a,"adplaying")});a.a.on(a.l,_.Db,()=>rt(a,"adpause"));a.a.on(a.l,_.Fb,()=>{rt(a,"adplay");rt(a,"adplaying")});a.a.on(a.l,_.Ib,()=>rt(a,"adended"));a.a.on(a.l,_.zb,()=>rt(a,"adfirstquartile"));a.a.on(a.l,_.Cb,()=>rt(a,"admidpoint"));a.a.on(a.l,_.Jb,()=>rt(a,"adthirdquartile"))},tt=class{constructor(a,b){this.l=a;this.m=this.g=null;this.A=("000000"+
5
+ (Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6);this.a=new _.mo;this.f=b;this.o=this.j=this.h=this.w=!1}initialize(a,b){this.g=a;this.m=b;this.w=!1;if(!this.h){try{this.h=!0,mux.init(this.A,qt(this))}catch(c){throw this.h=!1,_.Mf(this.a),new _.H(1,9,9302,null,c);}rt(this,"playerready")}this.j&&!this.o&&(rt(this,"videochange",pt(this)),this.j=!1);st(this)}release(){this.f.debug("release()");this.j?this.f.debug(_.ha):(_.Mf(this.a),this.j=!0,this.m=this.g=null)}destroy(){this.f.debug(_.Kc);
6
+ this.o?this.f.debug(_.fa):(this.o=!0,this.h&&this.w&&rt(this,"viewend"),rt(this,"destroy"))}B(a){this.f.debug(_.Bd);var b=a.detail;a=this.l.getTrackManager();b&&b.bandwidth&&(b=b.bandwidth,(a=a.Ca())&&a.bandwidth&&(b+=a.bandwidth),rt(this,"renditionchange",{video_source_bitrate:b}))}D(a){this.f.debug(_.Fd);switch(a.detail.currentState){case _.Jl:this.l.getConfiguration().autoplay&&rt(this,_.Qd);break;case _.Ll:rt(this,_.Rd);break;case _.Kl:rt(this,_.Md);break;case _.Al:this.w=!0,rt(this,_.Vc)}}C(a){this.f.debug(_.Cd);
7
+ if(this.h&&(a=a.detail||null))if(10003===a.code)rt(this,"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)}`;rt(this,_.Wc,{player_error_code:a.code,player_error_message:b})}}};var ut=class extends _.Zp{constructor(){super();this.f=null;this.a=!1;this.g=new _.O("clpp.muxdata")}onPlayerCreated(a){this.f=new tt(a,this.g)}onContentWillLoad(a,b){var c=a.getConfiguration();if(this.a=!_.z(c.muxdata)&&typeof c.muxdata===_.Ad){var d=c.muxdata;if(c="undefined"===typeof window.mux)c=d.muxLib,d="undefined"!==typeof c&&typeof c.init===_.Yc&&typeof c.emit===_.Yc,window.mux=c,c=d,c=!c;c&&(this.g.warn("Mux SDK is not loaded. Will do nothing."),this.a=!1,c=new _.H(1,9,9301),this.T(a,c))}else this.g.warn("Mux plugin is loaded but not configured. Will do nothing.");
8
+ if(this.a){c=a.getConfiguration();c=_.hf(c.muxdata||{});try{d=[];typeof c===_.Ad&&(c.envKey||d.push("envKey"));if(0<d.length)throw new _.H(1,9,9300,{missingKeys:d});this.f.initialize(c,b)}catch(e){this.a=!1,this.T(a,e)}}}onContentLoaded(){}onPlayerWillDestroy(){this.a&&(this.f.destroy(),this.f=null)}onPlayerWillRelease(){this.a&&this.f.release()}id(){return"mux"}T(a,b){a.trigger(new _.C(_.Wc,{detail:b}))}};_.x("clpp.muxdata.MuxDataPlugin",ut);ut.Id="mux";_.Km(new class{create(){return new ut}});};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 Js=function(a,b){let c=b.baseUrl;_.ug(c,"/")||(c+="/");const d=g=>g&&(_.tg(g,"https://")||_.tg(g,"http://")||_.tg(g,"//"))?g:`${c}${g}`,e=d(b.widevineUrl||"widevine"),f=d(b.playreadyUrl||"playready");b=d(b.fairplayUrl||"fairplay");a=new _.po(a);a.Ba(_.Dc,{licenseUrl:e,videoRobustness:[_.cb,void 0],audioRobustness:[_.Za,void 0],persistentStateRequired:!1,distinctiveIdentifierRequired:!1,serverCertificate:null,modifiers:{licenseRequest:_.lj,licenseResponse:_.mj}});a.Ba(_.Bc,{licenseUrl:b,
2
- certificateUrl:b,modifiers:{licenseRequest:_.oj,licenseResponse:_.pj,extractContentId:_.qj,certificateRequest:_.rj}});a.Ba(_.Cc,{licenseUrl:f,modifiers:{licenseRequest:_.lj}});_.zi(a)};
3
- _.x("clpp.onboard.OnboardComponent",class extends _.So{constructor(){super();this.l=null;this.h=new _.O("clpp.onboard")}f(a){this.l=a}a(){this.l=null}g(){var a=this.l.getConfiguration().drm,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.h.info(`Registering the DRMtoday Onboard environment, name='${b}'`),Js(b,a))}release(){}id(){return"onboard"}});
4
- _.x("clpp.onboard.register",Js);};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var ot=function(a,b){let c=b.baseUrl;_.Gg(c,"/")||(c+="/");const d=g=>g&&(_.Fg(g,"https://")||_.Fg(g,"http://")||_.Fg(g,"//"))?g:`${c}${g}`,e=d(b.widevineUrl||"widevine"),f=d(b.playreadyUrl||"playready");b=d(b.fairplayUrl||"fairplay");a=new _.Xo(a);a.Ga(_.Gc,{licenseUrl:e,videoRobustness:[_.eb,void 0],audioRobustness:[_.db,void 0],persistentStateRequired:!1,distinctiveIdentifierRequired:!1,serverCertificate:null,modifiers:{licenseRequest:_.Rj,licenseResponse:_.Sj}});a.Ga(_.Ec,{licenseUrl:b,
2
+ certificateUrl:b,modifiers:{licenseRequest:_.Uj,licenseResponse:_.Vj,extractContentId:_.Wj,certificateRequest:_.Xj}});a.Ga(_.Fc,{licenseUrl:f,modifiers:{licenseRequest:_.Rj}});_.hj(a)};
3
+ _.x("clpp.onboard.OnboardComponent",class extends _.Bp{constructor(){super();this.l=null;this.h=new _.O("clpp.onboard")}f(a){this.l=a}a(){this.l=null}g(){var a=this.l.getConfiguration().drm,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.h.info(`Registering the DRMtoday Onboard environment, name='${b}'`),ot(b,a))}release(){}id(){return"onboard"}});
4
+ _.x("clpp.onboard.register",ot);};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 us="A persistent DRM session already exists for: ",vs="No DRM configuration.",ws="clpp.persistent",xs=function(a,b){const c=[];for(const d of a)c.push(b(d));return c},zs=function(a,b){a.I=ys;a.H=[];a.C=!0;return _.ck(a,b)},Bs=function(a,b,c,d,e,f){a.I=As;const g=new Map,h=_.Qj(b);g.set(h,{audioCapabilities:e,videoCapabilities:f,distinctiveIdentifier:_.Ed,persistentState:_.Xd,sessionTypes:[_.Ld],label:h,drmInfos:[{keySystem:b,licenseServerUri:c,distinctiveIdentifierRequired:!1,persistentStateRequired:!0,
2
- audioRobustness:"",videoRobustness:"",serverCertificate:d,initData:null,keyIds:null}]});return _.bk(a,g)},Cs=function(a,b){return _.v(function*(){const c=yield _.rk(a,b);if(c){var d=[],e=a.g.get(c);e&&a.A&&(e.fb=new _.fk,d.push(e.fb));a.a.debug("Attempting to remove session",b);d.push(c.remove());return Promise.all(d)}a.a.debug("Ignoring attempt to remove missing session",b)})},Ds=function(a){a=a.g.keys();a=xs(a,b=>b.sessionId);return Array.from(a)},Es=function(a,b){const c=_.Bi(a),d=_.fi({drm:a});
3
- d.drm=a;a=new _.ml({qb:b,onError:()=>{},Dd:()=>{},onExpirationUpdated:()=>{},onEvent:()=>{},getConfiguration:()=>d,lc:()=>null});a.h=c;return a},Hs=function(a,b,c){return _.v(function*(){const d=Fs;if(a){var e=a.offlineId;if(0!==e.length){var f=yield d.get(e);if(f)Gs.debug(us,e);else{var g=Es(a,c);try{yield zs(g,b);yield _.qk(g);yield _.vk(g);const h=g.getDrmInfo(),k=b.map(l=>({contentType:_.Og(l.video.mimeType,l.video.codecs),robustness:h.videoRobustness}));f={sessionIds:Ds(g),keySystem:h.keySystem,
4
- licenseServerUri:h.licenseServerUri,serverCertificate:h.serverCertificate,audioCapabilities:[],videoCapabilities:k,drmConfig:a};yield d.store(e,f)}catch(h){throw Gs.error("Error while persisting DRM session"),new _.G(1,6,6200,null,h);}finally{yield g.destroy()}}}}else Gs.debug(vs)})},ys=1,As=2,Is=class{store(a,b){return _.v(function*(){{var c=JSON.stringify(b.sessionIds);var d=b.serverCertificate?Array.from(b.serverCertificate):null;d=JSON.stringify(d);const e=JSON.stringify(b.audioCapabilities),
5
- 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){return _.v(function*(){var b=window.localStorage.getItem(encodeURIComponent(a));if(b){{b=JSON.parse(atob(b));const c=JSON.parse(b.sessionIds),d=JSON.parse(b.audioCapabilities),e=JSON.parse(b.videoCapabilities),
6
- f=JSON.parse(b.serverCertificate),g=JSON.parse(b.drmConfig);b={sessionIds:c,keySystem:b.keySystem,licenseServerUri:decodeURIComponent(b.licenseServerUri),serverCertificate:f?new Uint8Array(f):null,audioCapabilities:d,videoCapabilities:e,drmConfig:g}}}else b=null;return b})}delete(a){return _.v(function*(){window.localStorage.removeItem(encodeURIComponent(a))})}clear(){return _.v(function*(){window.localStorage.clear()})}getName(){return"clpp.persistent.SimpleSessionStorage"}};_.x("clpp.persistent.useStorage",function(a){{var b=["store","get","delete","clear","getName"];const c=[];_.y(a)||(_.kf(a.store)||c.push("store"),_.kf(a.get)||c.push("get"),_.kf(a.delete)||c.push("delete"),_.kf(a.clear)||c.push("clear"),_.kf(a.getName)||c.push("getName"),b=c)}if(0<b.length)throw Gs.warn("Invalid session storage implementation"),new _.G(1,6,6202,{missingMethods:b});Fs=a});
7
- _.x("clpp.persistent.fetchLicense",function(a,b,...c){return _.v(function*(){var d=Fs,e=(l,m)=>new _.G(1,6,6200,l,m);const f=_.gl(a).shift();if(!f)throw e("No source specified.");if(!b)throw e(vs);var g=b.offlineId;if(typeof g!==_.je||!g.length)throw e("Missing offline id.");if(yield d.get(g))Gs.debug(us,g);else{var h=_.fi();d=new _.$l;g=[];for(var k of c){const l=new k;_.ii(l.id())||(l.f(null),_.mi(l),g.push(l))}k=null;try{k=yield _.Sm(f.url,d,h.manifest.attemptParameters,f.type);k.configure(h.manifest);
8
- const l=yield k.start(f.url,{networkingEngine:d,filterAllPeriods:()=>{},filterNewPeriod:()=>{},onTimelineCueAdded:()=>{},onEvent:()=>{},onError:()=>{}});if(!l.periods.length)throw e(null,new _.G(_.F,4,4014));const m=_.Qm(l.periods);yield Hs(b,m,d)}catch(l){if(l instanceof _.G&&6200===l.code)throw l;throw e(null,l);}finally{for(;g.length;)e=g.shift(),e.a(),_.hi.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 _.v(function*(){var b=Fs;if(_.lf(a)&&0!==a.length){var c=null,d=null;try{const e=yield b.get(a);e?(e.drmConfig.delayLicenseRequestUntilPlayed=!0,d=new _.$l,c=Es(e.drmConfig,d),yield Bs(c,e.keySystem,e.licenseServerUri,e.serverCertificate,e.audioCapabilities,e.videoCapabilities),yield _.qk(c),yield Promise.all(e.sessionIds.map(f=>_.v(function*(){yield Cs(c,f);Gs.debug("successfully removed session with id",f)}))),yield b.delete(a)):Gs.debug("No persistent DRM session found")}catch(e){throw Gs.error("Failed to remove session"),
10
- new _.G(1,6,6201,null,e);}finally{b=[],c&&b.push(c.destroy()),d&&b.push(d.destroy()),yield Promise.all(b)}}else Gs.warn("Invalid offlineId")})});var Fs=new Is,Gs=new _.O(ws);_.x("clpp.persistent.PersistentLicenseComponent",class extends _.So{constructor(){super();this.l=null;this.j=Fs;this.h=new _.O(ws)}f(a){this.l=a}a(){this.l=null}release(){}g(){this.j=Fs}id(){return _.Kd}o(a,b,c){const d=this;return _.v(function*(){if(a)try{yield Hs(a,b,c),d.l.trigger(new _.B(_.Mc,{offlineId:a.offlineId}))}catch(e){d.l.onError(e)}else d.h.debug("No DRM configuration found for loaded source.")})}m(a){const b=this;return _.v(function*(){try{const c=yield b.j.get(a);if(c)return c.sessionIds;
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var $s="A persistent DRM session already exists for: ",at="No DRM configuration.",bt="clpp.persistent",ct=function(a,b){const c=[];for(const d of a)c.push(b(d));return c},et=function(a,b){a.I=dt;a.J=[];a.D=!0;return _.Nk(a,b)},gt=function(a,b,c,d,e,f){a.I=ft;const g=new Map,h=_.yk(b);g.set(h,{audioCapabilities:e,videoCapabilities:f,distinctiveIdentifier:_.Hd,persistentState:_.$d,sessionTypes:[_.Od],label:h,drmInfos:[{keySystem:b,licenseServerUri:c,distinctiveIdentifierRequired:!1,persistentStateRequired:!0,
2
+ audioRobustness:"",videoRobustness:"",serverCertificate:d,initData:null,keyIds:null}]});return _.Mk(a,g)},ht=function(a,b){return _.w(function*(){const c=yield _.dl(a,b);if(c){var d=[],e=a.g.get(c);e&&a.B&&(e.jb=new _.Qk,d.push(e.jb));a.a.debug("Attempting to remove session",b);d.push(c.remove());return Promise.all(d)}a.a.debug("Ignoring attempt to remove missing session",b)})},it=function(a){a=a.g.keys();a=ct(a,b=>b.sessionId);return Array.from(a)},jt=function(a,b){const c=_.jj(a),d=_.Qi({drm:a});
3
+ d.drm=a;a=new _.Ul({ub:b,onError:()=>{},Kd:()=>{},onExpirationUpdated:()=>{},onEvent:()=>{},getConfiguration:()=>d,mc:()=>null});a.h=c;return a},mt=function(a,b,c){return _.w(function*(){const d=kt;if(a){var e=a.offlineId;if(0!==e.length){var f=yield d.get(e);if(f)lt.debug($s,e);else{var g=jt(a,c);try{yield et(g,b);yield _.al(g);yield _.el(g);const h=g.getDrmInfo(),k=b.map(l=>({contentType:_.Kh(l.video.mimeType,l.video.codecs),robustness:h.videoRobustness}));f={sessionIds:it(g),keySystem:h.keySystem,
4
+ licenseServerUri:h.licenseServerUri,serverCertificate:h.serverCertificate,audioCapabilities:[],videoCapabilities:k,drmConfig:a};yield d.store(e,f)}catch(h){throw lt.error("Error while persisting DRM session"),new _.H(1,6,6200,null,h);}finally{yield g.destroy()}}}}else lt.debug(at)})},dt=1,ft=2,nt=class{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);const e=JSON.stringify(b.audioCapabilities),
5
+ 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){return _.w(function*(){var b=window.localStorage.getItem(encodeURIComponent(a));if(b){{b=JSON.parse(atob(b));const c=JSON.parse(b.sessionIds),d=JSON.parse(b.audioCapabilities),e=JSON.parse(b.videoCapabilities),
6
+ f=JSON.parse(b.serverCertificate),g=JSON.parse(b.drmConfig);b={sessionIds:c,keySystem:b.keySystem,licenseServerUri:decodeURIComponent(b.licenseServerUri),serverCertificate:f?new Uint8Array(f):null,audioCapabilities:d,videoCapabilities:e,drmConfig:g}}}else b=null;return b})}delete(a){return _.w(function*(){window.localStorage.removeItem(encodeURIComponent(a))})}clear(){return _.w(function*(){window.localStorage.clear()})}getName(){return"clpp.persistent.SimpleSessionStorage"}};_.x("clpp.persistent.useStorage",function(a){{var b=["store","get","delete","clear","getName"];const c=[];_.z(a)||(_.lf(a.store)||c.push("store"),_.lf(a.get)||c.push("get"),_.lf(a.delete)||c.push("delete"),_.lf(a.clear)||c.push("clear"),_.lf(a.getName)||c.push("getName"),b=c)}if(0<b.length)throw lt.warn("Invalid session storage implementation"),new _.H(1,6,6202,{missingMethods:b});kt=a});
7
+ _.x("clpp.persistent.fetchLicense",function(a,b,...c){return _.w(function*(){var d=kt,e=(l,m)=>new _.H(1,6,6200,l,m);const f=_.Ol(a).shift();if(!f)throw e("No source specified.");if(!b)throw e(at);var g=b.offlineId;if(typeof g!==_.le||!g.length)throw e("Missing offline id.");if(yield d.get(g))lt.debug($s,g);else{var h=_.Qi();d=new _.Hm;g=[];for(var k of c){const l=new k;_.Ti(l.id())||(l.f(null),_.Vi(l),g.push(l))}k=null;try{k=yield _.zn(f.url,d,h.manifest.attemptParameters,f.type||null);k.configure(h.manifest);
8
+ const l=yield k.start(f.url,{networkingEngine:d,filterAllPeriods:()=>{},filterNewPeriod:()=>{},onTimelineCueAdded:()=>{},onEvent:()=>{},onError:()=>{}});if(!l.periods.length)throw e(null,new _.H(_.F,4,4014));const m=_.xn(l.periods);yield mt(b,m,d)}catch(l){if(l instanceof _.H&&6200===l.code)throw l;throw e(null,l);}finally{for(;g.length;)e=g.shift(),e.a(),_.Si.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=kt;if(_.mf(a)&&0!==a.length){var c=null,d=null;try{const e=yield b.get(a);e?(e.drmConfig.delayLicenseRequestUntilPlayed=!0,d=new _.Hm,c=jt(e.drmConfig,d),yield gt(c,e.keySystem,e.licenseServerUri,e.serverCertificate,e.audioCapabilities,e.videoCapabilities),yield _.al(c),yield Promise.all(e.sessionIds.map(f=>_.w(function*(){yield ht(c,f);lt.debug("successfully removed session with id",f)}))),yield b.delete(a)):lt.debug("No persistent DRM session found")}catch(e){throw lt.error("Failed to remove session"),
10
+ new _.H(1,6,6201,null,e);}finally{b=[],c&&b.push(c.destroy()),d&&b.push(d.destroy()),yield Promise.all(b)}}else lt.warn("Invalid offlineId")})});var kt=new nt,lt=new _.O(bt);_.x("clpp.persistent.PersistentLicenseComponent",class extends _.Bp{constructor(){super();this.l=null;this.j=kt;this.h=new _.O(bt)}f(a){this.l=a}a(){this.l=null}release(){}g(){this.j=kt}id(){return _.Nd}o(a,b,c){const d=this;return _.w(function*(){if(a)try{yield mt(a,b,c),d.l.trigger(new _.C(_.Pc,{offlineId:a.offlineId}))}catch(e){d.l.onError(e)}else d.h.debug("No DRM configuration found for loaded source.")})}m(a){const b=this;return _.w(function*(){try{const c=yield b.j.get(a);if(c)return c.sessionIds;
11
11
  b.h.debug(`No offline session found for ${a}`);return[]}catch(c){return b.h.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 rs=function(a,b){return 0<=b&&b<a.a.length},ss=function(a){a.trigger(new _.B(_.Qd))},ts=class extends _.ao{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.l=a;this.j=b;this.f=0;this.a=[];this.g=!1;this.h=this.pe.bind(this)}getPosition(){return this.f}gf(){return this.a}gd(){return 0<this.a.length&&rs(this,this.f)?this.a[this.f]:null}hf(){const a=this.f+1;return 0<
2
- this.a.length&&rs(this,a)?this.a[a]:null}lf(){return this.g}start(){this.g||(this.g=!0,this.l.on(_.Sc,this.h),this.Mc(this.f,!0))}stop(){this.g=!1;this.l.off(_.Sc,this.h)}pe(){this.next()}next(){const a=this;return _.v(function*(){yield a.Mc(Math.min(a.a.length-1,a.f+1))})}tf(){const a=this;return _.v(function*(){yield a.Mc(Math.max(0,a.f-1))})}Mc(a,b){b=void 0===b?!1:b;const c=this;return _.v(function*(){if(0<c.a.length&&rs(c,a)&&(b||c.f!==a)){c.f=a;var d=c.gd();d&&(yield c.j(d),yield c.l.load(d.configuration),
3
- c.trigger(new _.B(_.Pd,{item:d})))}})}append(a){this.a.push(a);ss(this)}kf(a,b){if(0<=b&&b<=this.a.length){const c=this.gd();this.a.splice(b,0,a);c&&(this.f=this.a.indexOf(c));ss(this)}}remove(a){if(0<this.a.length&&rs(this,a)){if(this.f===a)throw Error("Can't remove the current item");this.a.splice(a,1);ss(this)}}clear(){this.stop();this.f=0;this.a=[];this.g=!1;ss(this)}};_.x("clpp.Playlist",ts);ts.prototype.clear=ts.prototype.clear;ts.prototype.remove=ts.prototype.remove;ts.prototype.insert=ts.prototype.kf;
4
- ts.prototype.append=ts.prototype.append;ts.prototype.goTo=ts.prototype.Mc;ts.prototype.previous=ts.prototype.tf;ts.prototype.next=ts.prototype.next;ts.prototype.onEnded=ts.prototype.pe;ts.prototype.stop=ts.prototype.stop;ts.prototype.start=ts.prototype.start;ts.prototype.isStarted=ts.prototype.lf;ts.prototype.getUpcoming=ts.prototype.hf;ts.prototype.getCurrent=ts.prototype.gd;ts.prototype.getQueue=ts.prototype.gf;ts.prototype.getPosition=ts.prototype.getPosition;ts.prototype.off=ts.prototype.off;
5
- ts.prototype.one=ts.prototype.one;ts.prototype.on=ts.prototype.on;};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Xs=function(a,b){return 0<=b&&b<a.a.length},Ys=function(a){a.trigger(new _.C(_.Td))},Zs=class extends _.Ro{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.l=a;this.j=b;this.f=0;this.a=[];this.g=!1;this.h=this.xe.bind(this)}getPosition(){return this.f}rf(){return this.a}pd(){return 0<this.a.length&&Xs(this,this.f)?this.a[this.f]:null}sf(){const a=this.f+1;return 0<
2
+ this.a.length&&Xs(this,a)?this.a[a]:null}xf(){return this.g}start(){this.g||(this.g=!0,this.l.on(_.Vc,this.h),this.Sc(this.f,!0))}stop(){this.g=!1;this.l.off(_.Vc,this.h)}xe(){this.next()}next(){const a=this;return _.w(function*(){yield a.Sc(Math.min(a.a.length-1,a.f+1))})}Hf(){const a=this;return _.w(function*(){yield a.Sc(Math.max(0,a.f-1))})}Sc(a,b){b=void 0===b?!1:b;const c=this;return _.w(function*(){if(0<c.a.length&&Xs(c,a)&&(b||c.f!==a)){c.f=a;var d=c.pd();d&&(yield c.j(d),yield c.l.load(d.configuration),
3
+ c.trigger(new _.C(_.Sd,{item:d})))}})}append(a){this.a.push(a);Ys(this)}wf(a,b){if(0<=b&&b<=this.a.length){const c=this.pd();this.a.splice(b,0,a);c&&(this.f=this.a.indexOf(c));Ys(this)}}remove(a){if(0<this.a.length&&Xs(this,a)){if(this.f===a)throw Error("Can't remove the current item");this.a.splice(a,1);Ys(this)}}clear(){this.stop();this.f=0;this.a=[];this.g=!1;Ys(this)}};_.x("clpp.Playlist",Zs);Zs.prototype.clear=Zs.prototype.clear;Zs.prototype.remove=Zs.prototype.remove;Zs.prototype.insert=Zs.prototype.wf;
4
+ Zs.prototype.append=Zs.prototype.append;Zs.prototype.goTo=Zs.prototype.Sc;Zs.prototype.previous=Zs.prototype.Hf;Zs.prototype.next=Zs.prototype.next;Zs.prototype.onEnded=Zs.prototype.xe;Zs.prototype.stop=Zs.prototype.stop;Zs.prototype.start=Zs.prototype.start;Zs.prototype.isStarted=Zs.prototype.xf;Zs.prototype.getUpcoming=Zs.prototype.sf;Zs.prototype.getCurrent=Zs.prototype.pd;Zs.prototype.getQueue=Zs.prototype.rf;Zs.prototype.getPosition=Zs.prototype.getPosition;Zs.prototype.off=Zs.prototype.off;
5
+ Zs.prototype.one=Zs.prototype.one;Zs.prototype.on=Zs.prototype.on;};f.call(g, window);
package/cl.smooth.js CHANGED
@@ -1,58 +1,58 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var BD="Full MP4 box must have flags defined",CD="clpp.smooth.SmoothMP4Processor",DD="codecPrivateData",ED=function(a,b){const c=Math.floor(b/Math.pow(2,32));b-=c*Math.pow(2,32);_.L(a,c);_.L(a,b)},FD=function(a,b){try{a.f.setUint8(a.a,b),a.a+=1}catch(c){_.Fi()}},GD=function(a,b){FD(a,b>>16&255);FD(a,b>>8&255);FD(a,b&255)},HD=function(a,b){try{a.f.setUint16(a.a,b,a.g),a.a+=2}catch(c){_.Fi()}},ID=function(a,b){try{a.f.setInt32(a.a,b,a.g),a.a+=4}catch(c){_.Fi()}},JD=function(a,b){try{a.f.setInt16(a.a,
2
- b,a.g),a.a+=2}catch(c){_.Fi()}},KD=function(a,b){if(void 0!=b){var c=new Uint8Array(b);const d=Math.min(a.length,b);let e=0;for(;e<d;++e)c[e]=a.charCodeAt(e);for(;e<b;e++)c[e]=0;return c}b=new Uint8Array(a.length);for(c=0;c<a.length;++c)b[c]=a.charCodeAt(c);return b},LD=function(a){const b=a.split("/");return b[b.length-1].toLowerCase().match("manifest(\\(.+\\))?")?a:`${a}/Manifest`},MD=function(a,b,c,d){c=b.ge[c];b=b.Gf;a=a.replace("Manifest","");b=b.replace("{bitrate}",String(d.bitrate)).replace("{Bitrate}",
3
- String(d.bitrate)).replace("{start time}",String(c.t)).replace("{start_time}",String(c.t));return _.Ft([a],[b])[0]},ND=function(a,b){if(a.type!==b.type)return!1;let c=[];a.type===_.u?c=["maxWidth","maxHeight","bitrate",DD,"fourCC"]:a.type===_.Vb&&(c=["bitrate",DD,"channels","bitsPerSample","samplingRate","fourCC"]);return _.nf(a,b,c,["id","segmentIndex"])},OD=function(a,b,c){const d=c.Gc.split("00000001");a={id:1,type:c.type,duration:a/b,timescale:b,Ca:null,Eb:null,width:NaN,height:NaN,yb:null,Ac:NaN,
4
- sampleSize:NaN,channelCount:NaN};switch(c.type){case _.u:a.Ca=[_.ri(d[1])];a.Eb=[_.ri(d[2])];a.width=c.maxWidth;a.height=c.maxHeight;break;case _.Vb:a.yb=_.ri(c.Gc),a.sampleSize=c.Pe||16,a.Ac=c.Ac,a.channelCount=c.be}return a},PD=function(a,b){return a.filter(c=>c.type===b)},QD=function(a,b){a=a.exec(b);return null==a||""==a[0]?null:(Number(a[4])||0)/1E3+(Number(a[3])||0)+60*(Number(a[2])||0)+3600*(Number(a[1])||0)},XD=function(a,b,c){var d=null;if(RD.test(a)){{a=RD.exec(a);d=Number(a[1]);const e=
5
- Number(a[2]);let f=Number(a[3]),g=Number(a[4]);g+=(Number(a[5])||0)/c.f;f+=g/c.frameRate;d=f+60*e+3600*d}}else SD.test(a)?d=QD(SD,a):TD.test(a)?d=QD(TD,a):UD.test(a)?(a=UD.exec(a),d=Number(a[1])/c.frameRate):VD.test(a)?(a=VD.exec(a),d=Number(a[1])/c.a):WD.test(a)&&(d=QD(WD,a));c=d;d=c+b;b=Math.floor(d/3600);c=Math.floor((d-3600*b)/60);a=Math.floor(d-3600*b-60*c);d-=a;10>b&&(b="0"+b);10>c&&(c="0"+c);10>a&&(a="0"+a);0===d?d="000":d=Math.round(1E3*d);return b+":"+c+":"+a+"."+d},YD=function(a){let b=
6
- 0;for(let c=0;c<a.a.length;c++)b+=a.a[c].a();return new _.bj(b)},ZD=function(a){const b=_.ai();a="ie"===b.browser||"edge"===b.browser?a.hd(_.Cc):a.hd(_.Dc);null===a&&(_.z(CD,"Could not get PSSH box!"),a={initData:new Uint8Array(0),initDataType:_.nc,keyId:"",periodId:null});return a},fE=function(a,b,c){const d=ZD(c);c=new $D("xxxx");a.type===_.u?c=new aE(a.width,a.height):c=new bE(a.channelCount,a.sampleSize,a.Ac);a=new cE;a.g=1;a.h=8;a.m=d.keyId||"00000000000000000000000000000000";a=(new $D("schi")).append([a]);
7
- b=(new $D(_.ce)).append([new dE(b),new eE(_.nc,65536),a]);c.append([b]);return c},IE=function(a,b){const c=b.Pc();var d=new gE(a.timescale,a.duration,a.id),e=(new hE).append([new iE(a.id)]),f=new jE(a.id,a.duration,a.timescale,a.width,a.height),g=new kE(a.timescale,a.duration);const h=new lE(a.type);var k=null,l=new mE;l.entries=[new nE];var m=new oE;switch(a.type){case _.u:k=new pE(a.Ca,a.Eb);c?(a=fE(a,"avc1",b),a.append([k]),m.entries=[a]):(a=(new qE(a.width,a.height)).append([k]),m.entries=[a]);
8
- k=new rE;break;case _.Vb:k=new sE(a.yb),c?(a=fE(a,"mp4a",b),a.append([k]),m.entries=[a]):(a=(new tE(a.channelCount,a.sampleSize,a.Ac)).append([k]),m.entries=[a]),k=new uE}m=(new vE).append([m,new wE,new xE,new yE,new zE]);l=(new AE).append([l]);l=(new BE).append([k,l,m]);g=(new CE).append([g,h,l]);f=(new DE).append([f,g]);d=(new EE).append([d,f,e]);e=new FE("dash",0,["iso6","mp41","avc1"]);c&&(b=ZD(b).initData,d.append([new GE("pssh",b,8)]));b=new HE([e,d]);return _.K(b.write())},SE=function(a,b){let c,
9
- d,e,f,g,h;(new _.$i).M("moof",_.N).X("mfhd",k=>{{const l=new JE;l.g=_.M(k.G);c=l}}).M("traf",_.N).X("tfhd",k=>{{const l=k.G.ya();if(null===k.flags)throw new _.G(_.F,3,3019,BD);const m=new KE(k.version||0,k.flags||0);m.g=_.M(k.G);0<l-k.G.getPosition()&&k.flags&1&&(m.h=_.Mi(k.G));0<l-k.G.getPosition()&&k.flags&2&&(m.A=_.M(k.G));0<l-k.G.getPosition()&&k.flags&8&&(m.j=_.M(k.G));0<l-k.G.getPosition()&&k.flags&16&&(m.o=_.M(k.G));0<l-k.G.getPosition()&&k.flags&32&&(m.m=_.M(k.G));d=m}}).X("trun",k=>{{var l=
10
- k.G.ya();if(null===k.flags)throw new _.G(_.F,3,3019,BD);const m=new LE(k.version||0,k.flags||0);m.g=_.M(k.G);0<l-k.G.getPosition()&&k.flags&1&&(m.j=_.Li(k.G));0<l-k.G.getPosition()&&k.flags&4&&(m.m=_.M(k.G));if(0<l-k.G.getPosition())for(l=0;l<m.g;l++)k.flags&256&&m.o.push(_.M(k.G)),k.flags&512&&m.sampleSize.push(_.M(k.G)),k.flags&1024&&m.A.push(_.M(k.G)),k.flags&2048&&(0===k.version?m.h.push(_.M(k.G)):m.h.push(_.Li(k.G)));e=m}}).X("sdtp",k=>{{const l=_.Ni(k.G,k.G.ya());f=new ME("sdtp",k.version||
11
- 0,k.flags||0,l,0)}}).M("uuid",k=>{var l=_.Ni(k.G,16);if(_.ti(l,NE)){l=_.M(k.G);k.version=l>>>24;k.flags=l&16777215;l=new OE(k.version,k.flags);l.h=_.M(k.G);k.flags&1&&(l.j=_.Ji(k.G));for(let m=0;m<l.h;m++){const n={ke:_.Ni(k.G,8),qc:0,Pd:[]};if(k.flags&2){n.qc=_.Ki(k.G);for(let q=0;q<n.qc;q++){const r={$d:0,ae:0};r.$d=_.Ki(k.G);r.ae=_.M(k.G);n.Pd.push(r)}}l.g.push(n)}g=l}}).M(_.kd,k=>{{const l=new PE;0<k.G.ya()?l.g=_.Ni(k.G,k.G.ya()):(_.z(CD,"mdat box is empty!"),l.g=new Uint8Array(0));h=l}}).parse(a,
12
- !1);if(!h)return null;a=(new QE).append([d,e]);f&&a.append([f]);b.Pc()&&g&&a.append([g]);b=(new RE).append([c,a]);return new HE([b,h])},XE=function(a,b,c){var d=c.Pc(),e=a.request.startTime,f=parseInt(e*b,10);b=a.data||new ArrayBuffer(0);var g=SE(b,c);if(null===g)return a.request.contentType===_.t?a.data:g;c=g.get(_.kd);if(a.request.contentType===_.t){d=c.g.buffer;if(e){d=_.pg(d);if((d=(new DOMParser).parseFromString(d,_.qe))&&"tt"===d.documentElement.tagName.toLowerCase())var h=d.documentElement;
13
- if(h&&(c=new TE(h.getAttribute("ttp:frameRate"),h.getAttribute("ttp:subFrameRate"),h.getAttribute("ttp:frameRateMultiplier"),h.getAttribute("ttp:tickRate")),h=h.getElementsByTagName("body")[0])){f=h.getElementsByTagName("p");for(let r=0,w=f.length;r<w;r++){h=f[r];a=e;b=c;g=["begin",_.Rc];for(let C=0,A=g.length;C<A;C++){b:{var k=h;var l=g[C],m=new RegExp("\\w+:"+l),n=0;if(k.hasAttribute(l)){k=k.getAttribute(l);break b}l=k.attributes;const E=l.length;for(;n<E;n++){var q=l[n].name;if(q=q.match(m)){k=
14
- k.getAttribute(q[0]);break b}}k=null}h.setAttribute(g[C],XD(k||"",a,b))}}}d=(new XMLSerializer).serializeToString(d);e=_.qg(d).buffer}else e=d;return e}h=new RE;a=g.get("mfhd");b=new QE;k=g.get("tfhd");m=new UE(1,f);f=g.get("trun");n=g.get("sdtp");e=g.get("senc");k.g=1;k.flags&=16777214;k.flags|=131072;b.append([k,m,f]);n&&b.append([n]);if(d){g=0;k=[];if(e.flags&2)for(k=[],m=0;m<e.h;m++)k.push(10+6*e.g[m].qc);else g=8;b.append([e,new VE,new WE(g,k,e.h)])}h.append([a,b]);f.flags|=1;f.j=h.a()+8;c=new HE([h,
15
- c]);h=c.write();d&&(d=c.get("saio"),c=c.f,d.offset[0]=e.start+16,c.seek(d.start),d.write(c),h=c.buffer);return h},YE=function(a,b,c){return{keySystem:a,licenseServerUri:"",distinctiveIdentifierRequired:!1,persistentStateRequired:!1,audioRobustness:"",videoRobustness:"",serverCertificate:null,initData:[b],keyIds:c,periodId:null}},ZE=function(a){return{initData:_.nt(_.Hj(a)),initDataType:_.nc,keyId:a,periodId:null}},$E=function(a,b,c){a=_.Nj(a);c&&a.version!==c&&(a=_.pt(a,c));return{initData:_.nt(a),
16
- initDataType:_.nc,keyId:b,periodId:null}},aF=function(a,b){return _.v(function*(){var c=_.Cg(b);c.timeout=a.h.attemptParameters.timeout;c.maxAttempts=Math.max(a.h.attemptParameters.maxAttempts,b.length);c.baseDelay=a.h.attemptParameters.baseDelay;c.backoffFactor=a.h.attemptParameters.backoffFactor;c.fuzzFactor=a.h.attemptParameters.fuzzFactor;c.type=1;c=yield a.g.networkingEngine.fetch(c).O;a.o=c.uri;return c})},iF=function(a,b){let c=null;try{{const ta=new DOMParser;let hb,Ja;try{const ab=_.pg(b);
17
- Ja=ta.parseFromString(ab.trim(),_.qe)}catch(ab){throw ab;}Ja&&Ja.documentElement.tagName==_.fb&&(hb=Ja.documentElement);c=hb&&0<hb.getElementsByTagName("parsererror").length?null:hb}}catch(ta){}if(!c)throw a.f.error("Unable to parse manifest"),new _.G(_.F,4,4033,a.o);const d=+bF(a,c,"MajorVersion"),e=+bF(a,c,"MinorVersion"),f=+c.getAttribute("TimeScale")||1E7;let g=+bF(a,c,"Duration");const h="TRUE"===c.getAttribute("IsLive"),k=+c.getAttribute("LookAheadCount"),l=+c.getAttribute("DVRWindowLength")||
18
- Infinity,m=_.Bj(c,"Protection")[0];if(!1===/^[2].[0-2]$/.test(""+d+"."+e))throw a.f.error("Smooth Streaming version must be 2.0, 2.1 or 2.2"),new _.G(_.F,4,4036,a.o);h?(cF(a,dF),a.C=typeof a.h.liveRefreshPeriod===_.p?1E3*a.h.liveRefreshPeriod:Math.min(1E3*a.H,1E4),g=Infinity):cF(a,eF);a.a={startTime:0,delay:0,duration:g/f,cd:l/f,wc:0};if(m){{var n=a.h.playreadyVersion;const ta=[],hb=_.Bj(m,"ProtectionHeader")[0],Ja=_.qi(_.Dj(hb)||""),ab=_.Nj(Ja).a;ta.push(YE(_.Dc,ZE(ab),[ab]));ta.push(YE(_.Cc,$E(Ja,
19
- ab,n),[ab]));var q=ta}a.A=q}{const ta=[],hb=_.Bj(c,"StreamIndex");if(!hb.length)throw a.f.error("No streams found!"),new _.G(_.F,4,4034,a.o);for(let Ja=0;Ja<hb.length;Ja++){{var r=a,w=hb[Ja];const ab=bF(r,w,"Type"),dc=+w.getAttribute("Chunks"),Qg=w.getAttribute("Subtype"),ze=_.Mg(w.getAttribute("Language")||_.ue),Gd=w.getAttribute("Name")||"",Rg=+w.getAttribute(_.Ka),xf=+w.getAttribute(_.Ia),yf=bF(r,w,"Url"),sk=+w.getAttribute("TimeScale")||null;{const ec=[],ji=_.Bj(w,_.Va);for(let Hd=0;Hd<ji.length;Hd++){{let fc,
20
- Ga,Wc;var C=r,A=ji[Hd],E=ab;const ki=+A.getAttribute("Index"),zf=+bF(C,A,"Bitrate");let Kb=NaN,Af=NaN,tk=NaN,ap=NaN,Tx=NaN,Ux=NaN,Vx=NaN;const Wx=A.getAttribute("FourCC");switch(E){case _.u:Kb=+bF(C,A,_.Ia);Af=+bF(C,A,_.Ka);break;case _.Vb:ap=+A.getAttribute("Channels")||2,tk=+bF(C,A,"SamplingRate"),Ux=+bF(C,A,"AudioTag"),Tx=+bF(C,A,"BitsPerSample"),Vx=+bF(C,A,"PacketSize")}let bp=String(A.getAttribute("CodecPrivateData"));if(E===_.Vb&&!bp){{var D=ap;const Xx={96E3:0,88200:1,64E3:2,48E3:3,44100:4,
21
- 32E3:5,24E3:6,22050:7,16E3:8,12E3:9,11025:10,8E3:11,7350:12},uk=Xx[tk];if("AACH"===Wx){Ga=new Uint8Array(4);const Yx=Xx[2*tk];Ga[0]=40|uk>>1;Ga[1]=uk<<7|D<<3|Yx>>1;Ga[2]=Yx<<7|8;Ga[3]=0;fc=new Uint16Array(2);fc[0]=(Ga[0]<<8)+Ga[1];fc[1]=(Ga[2]<<8)+Ga[3];Wc=fc[0].toString(16)+fc[1].toString(16)}else Ga=new Uint8Array(2),Ga[0]=16|uk>>1,Ga[1]=uk<<7|D<<3,fc=new Uint16Array(1),fc[0]=(Ga[0]<<8)+Ga[1],Wc=fc[0].toString(16);bp=Wc.toUpperCase()}}var na={id:C.W++,type:E,index:ki,bitrate:zf,Gc:bp,maxHeight:Kb,
22
- maxWidth:Af,Ac:tk,be:ap,Of:Ux,Pe:Tx,Zf:Vx,$e:Wx,bb:null}}ec.push(na)}var $a=ec}{const ec=[],ji=_.Bj(w,"c");for(let Hd=0;Hd<ji.length;Hd++){const fc=ji[Hd];let Ga=parseInt(fc.getAttribute("t"),10),Wc=parseInt(fc.getAttribute("d"),10),ki=parseInt(fc.getAttribute("r"),10),zf=0;if(isNaN(Ga)&&isNaN(Wc))throw r.f.error("Either one or both FragmentDuration and FragmentTime field MUST be present in StreamFragmentElement"),new _.G(_.F,4,4037,r.o);0===Hd&&isNaN(Ga)&&(zf=Ga=0);if(0<Hd){const Kb=ec[ec.length-
23
- 1];zf=Kb.n+1;Kb.d||(Kb.d=Ga-Kb.t);Ga||(Ga=Kb.t+Kb.d);Wc||(Wc=Ga-Kb.t)}ec.push({n:zf,d:Wc,t:Ga});if(ki){ki--;for(let Kb=0;Kb<ki;Kb++){const Af=ec[ec.length-1];zf=Af.n+1;Ga=Af.t+Af.d;Wc=Af.d;ec.push({n:zf,d:Wc,t:Ga})}}}r.D()||ec.length===dc||r.f.warn("Number of fragments ("+dc+") differs from number of chunks ("+ec.length+").");var tf=ec}var xe={type:ab,Qf:dc,Cf:Qg,language:ze,name:Gd,maxWidth:Rg,maxHeight:xf,Gf:yf,tracks:$a,ge:tf,timescale:sk}}ta.push(xe)}var Cd=ta}const bb={Xf:d,me:e,timescale:f,
24
- duration:g,isLive:h,Wf:k,cd:l,nd:!1,streams:Cd};if(a.j&&a.B)return fF(a,bb),Promise.resolve();{const ta=bb.timescale,hb=bb.duration,Ja=PD(bb.streams,_.Vb),ab=PD(bb.streams,_.u),dc=PD(bb.streams,_.t),Qg=[];let ze=gF(a,hb,ta,Ja),Gd=gF(a,hb,ta,ab);const Rg=gF(a,hb,ta,dc);ze.length||(ze=[null]);Gd.length||(Gd=[null]);for(let xf=0;xf<Gd.length;xf++)for(let yf=0;yf<ze.length;yf++)Qg.push(hF(a,Gd[xf],ze[yf]));var Sg={startTime:0,variants:Qg,textStreams:Rg,thumbStreams:[]}}{var Xc=bb.streams;let ta=a.a.startTime,
25
- hb=a.a.delay;const Ja=a.I;let ab=Math.min(a.a.duration||Infinity,Ja);const dc=a.D(),Qg=a.a.cd,ze=a.a.wc,Gd=a.H,Rg=isFinite(a.F)?a.F:0;if(dc)ab=Infinity,ta=Date.now()/1E3-ze,a.a.startTime=ta,hb=3*Gd;else{const xf=isFinite(Ja)?Ja:a.a.duration;for(const yf of Xc)for(const sk of yf.tracks)sk.bb.offset(-Rg),_.au(sk.bb,xf)}a.w=new _.oy(ta,hb,!0);a.w.f=!dc;a.w.Ib(ab);_.St(a.w,Gd);a.w.Yb=Qg;dc||a.w.offset(-Rg)}a.g.filterAllPeriods([Sg]);a.j={presentationTimeline:a.w,periods:[Sg],offlineSessionIds:[],minBufferTime:0};
26
- Promise.resolve();a.K||(a.g.networkingEngine.Wc(a.L),a.K=!0);a.B=bb;return Promise.resolve()},jF=function(a,b){null!=a.C&&null!=b&&(a.m=window.setTimeout(a.T.bind(a),b))},bF=function(a,b,c){if(b=b.getAttribute(c))return b;a.f.error("required attribute not provided: "+c);throw new _.G(_.F,4,4038,a.o,c);},cF=function(a,b){const c=b===eF;a.j&&a.j.presentationTimeline&&(a.j.presentationTimeline.f=c);c&&null!=a.m&&(window.clearTimeout(a.m),a.m=null,a.C=null);a.R=b},fF=function(a,b){for(let e=0;e<a.B.streams.length;e++){const f=
27
- b.streams[e];for(const g of a.B.streams[e].tracks){var c=f.tracks.find(h=>h.type===g.type&&h.bitrate===g.bitrate);if(c){ND(g,c)||a.f.warn("The current stream is updated with a stream that seems to have different base properties!");var d=kF(a,a.B.timescale,f,c);c=g.bb;_.Zt(c,d);(d=a.a.cd)&&_.$t(c,(c.a.length?c.a[c.a.length-1].endTime:0)-d)}else a.f.warn(`Cannot find satisfying update for ${g.type} `+`track with bitrate ${g.bitrate}. Skipping update.`)}}},kF=function(a,b,c,d){let e=0;const f=[],g=c.timescale||
28
- b;c.ge.forEach((h,k)=>{const l=h.d/g;0===k?(h=h.t/g,a.F=Math.min(a.F,h)):h=f[k-1].endTime;const m=h+l,n=MD(a.o,c,k,d);a.H=Math.max(a.H,l);f.push(new _.Yt(k,h,m,()=>[n],0,null,0,null,!0,g));e+=l});if(c.type===_.u||c.type===_.Vb)b=f[f.length-1],a.I=Math.min(a.I,e),0===a.a.wc?a.a.wc=b.endTime:a.a.wc=Math.min(a.a.wc,b.endTime);return f},gF=function(a,b,c,d){let e=[];for(let f=0;f<d.length;f++){const g=d[f].tracks.map(h=>{var k=d[f],l=kF(a,c,k,h),m=new _.py(l),n=null;k.type!==_.t&&(n=lF(a,b,c,k,h));h.bb=
29
- m;l=a.N++;var q=Promise.resolve.bind(Promise),r=m.h.bind(m),w=m.get.bind(m),C=m.f.bind(m);m=m.getDuration.bind(m);var A=mF[k.type];var E="";switch(k.type){case _.u:E=h.Gc;var D=/00000001[0-9]7/.exec(E);E="avc1."+(D&&D[0]?E.substr(E.indexOf(D[0])+10,6):"42c00c");a.f.debug("VIDEO CODECS: ",E);break;case _.Vb:E=h.Gc,D=2,"AACH"===h.$e?D=5:E&&(D=(parseInt(E.substr(0,2),16)&248)>>3),E="mp4a.40."+D,a.f.debug("AUDIO CODECS: ",E)}D=k.type===_.t?nF[k.Cf]:void 0;return h={id:l,originalId:null,ag:null,createSegmentIndex:q,
30
- findSegmentPosition:r,getSegmentReference:w,adjustSegmentDurations:C,getDuration:m,initSegmentReference:n,mimeType:A,codecs:E,frameRate:void 0,bandwidth:h.bitrate,width:h.maxWidth||void 0,height:h.maxHeight||void 0,kind:D,encrypted:a.J(),keyId:null,language:k.language,label:k.name,type:k.type,primary:!1,trickModeVideo:null,emsgSchemeIdUris:null,roles:[],channelsCount:h.be||null,closedCaptions:null}});e=e.concat(g)}return e},hF=function(a,b,c){const d=(c?c.bandwidth:0)+(b?b.bandwidth:0),e=c?c.language:
31
- _.ue;return c||b?{id:a.N++,language:e,primary:!1,audio:c,video:b,bandwidth:d,drmInfos:a.A,allowedByApplication:!0,allowedByKeySystem:!0}:null},lF=function(a,b,c,d,e){b=OD(b,d.timescale||c,e);c={isLive:a.D.bind(a),Pc:a.J.bind(a),ef:()=>1,hd:a.S.bind(a)};d=new Uint8Array(0);try{d=IE(b,c)}catch(g){throw a.f.error("Failed to generate initialization segment."),new _.G(_.F,3,4035,g);}const f="data:text/plain;base64,"+_.pi(d);return new _.ny(()=>[f],0,null,null,!0)},$D=class{constructor(a){this.type=a;this.size=
32
- this.start=0;this.parent=null;this.w=!1;this.entries=[];this.f=[]}append(a=[]){for(let b=0;b<a.length;b++)this.f.push(a[b]),a[b].parent=this;return this}get(a){if(this.type===a)return this;for(let b=0;b<this.f.length;b++){if(this.f[b].type===a)return this.f[b];{const c=this.f[b].get(a);if(c)return c}}return null}a(){const a=Math.pow(2,32)-1;let b;b=4+this.type.length;"uuid"===this.type&&(b+=16);if(0<this.f.length)for(let c=0;c<this.f.length;c++)b+=this.f[c].a();this.size>a&&(b+=8);return b}write(a){var b=
33
- Math.pow(2,32)-1;this.start=a.getPosition();this.size=this.a();this.size>b?_.L(a,1):_.L(a,this.size);_.Gi(a,KD(this.type));this.size>b&&ED(a,this.size);"uuid"===this.type&&_.Gi(a,null);if(0<this.f.length&&!this.w)for(b=0;b<this.f.length;b++)this.f[b].write(a),this.f[b].a(),a.getPosition()}},oF=class extends $D{constructor(a,b,c){super(a);this.version=b;this.flags=c}a(){return 4+super.a()}write(a){super.write(a);FD(a,this.version);GD(a,this.flags)}},GE=class extends $D{constructor(a,b,c){super(a);
34
- this.g=b;this.offset=c}a(){return this.g.byteLength+super.a()-this.offset}write(a){super.write(a);_.Gi(a,this.g,this.offset);a.getPosition()}},ME=class extends oF{constructor(a,b,c,d,e){super(a,b,c);this.g=d;this.offset=e}a(){return this.g.byteLength+super.a()-this.offset}write(a){super.write(a);_.Gi(a,this.g,this.offset);a.getPosition()}},FE=class extends $D{constructor(a,b,c){super("ftyp");this.h=a;this.me=b;this.g=c}a(){let a=this.h.length;a=a+4+this.g.join("").length;return a+super.a()}write(a){super.write(a);
35
- _.Gi(a,KD(this.h));_.L(a,this.me);_.Gi(a,KD(this.g.join("")));a.getPosition()}},EE=class extends $D{constructor(){super(_.qd)}},DE=class extends $D{constructor(){super(_.se)}},gE=class extends oF{constructor(a,b,c){super("mvhd",1,0);this.timescale=a;this.duration=b;this.volume=256;this.h=c+1;this.g=[0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0]}a(){let a=0;a=1===this.version?a+28:a+16;a=a+44+this.g.length;return a+=super.a()}write(a){super.write(a);1===this.version?(ED(a,
36
- 0),ED(a,0),_.L(a,this.timescale),ED(a,this.duration*this.timescale)):(_.L(a,0),_.L(a,0),_.L(a,this.timescale),_.L(a,this.duration*this.timescale));_.L(a,65536);HD(a,this.volume);HD(a,0);_.L(a,0);_.L(a,0);for(let b=0;b<this.g.length;b++)FD(a,this.g[b]);_.L(a,0);_.L(a,0);_.L(a,0);_.L(a,0);_.L(a,0);_.L(a,0);_.L(a,this.h);a.getPosition()}},hE=class extends $D{constructor(){super("mvex")}},iE=class extends oF{constructor(a){super("trex",0,0);this.g=a}a(){return 20+super.a()}write(a){super.write(a);_.L(a,
37
- this.g);_.L(a,1);_.L(a,0);_.L(a,0);_.L(a,0);a.getPosition()}},jE=class extends oF{constructor(a,b,c,d,e){super("tkhd",1,7);this.h=a;this.duration=b;this.timescale=c;this.width=d;this.height=e;this.volume=1;this.g=[0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0]}a(){let a=0;a=1===this.version?a+32:a+20;a=a+24+this.g.length;return a+super.a()}write(a){super.write(a);1===this.version?(ED(a,0),ED(a,0),_.L(a,this.h),_.L(a,0),ED(a,this.duration*this.timescale)):(_.L(a,0),_.L(a,
38
- 0),_.L(a,this.h),_.L(a,0),_.L(a,this.duration*this.timescale));_.L(a,0);_.L(a,0);HD(a,0);HD(a,0);HD(a,this.volume);HD(a,0);for(let b=0;b<this.g.length;b++)FD(a,this.g[b]);HD(a,this.width);HD(a,0);HD(a,this.height);HD(a,0);a.getPosition()}},kE=class extends oF{constructor(a,b){super("mdhd",1,0);this.timescale=a;this.duration=b;this.language=21956}a(){let a=0;a=1===this.version?a+28:a+16;return a+4+super.a()}write(a){super.write(a);1===this.version?(ED(a,0),ED(a,0),_.L(a,this.timescale),ED(a,this.duration*
39
- this.timescale)):(_.L(a,0),_.L(a,0),_.L(a,this.timescale),_.L(a,this.duration*this.timescale));HD(a,this.language);HD(a,0);a.getPosition()}},lE=class extends oF{constructor(a){super("hdlr",0,0);this.g=a}a(){return 33+super.a()}write(a){super.write(a);_.L(a,0);this.g===_.u?_.Gi(a,KD("vide")):_.Gi(a,KD("soun"));_.L(a,0);_.L(a,0);_.L(a,0);this.g===_.u?_.Gi(a,KD("VideoHandler\x00")):_.Gi(a,KD("SoundHandler\x00"));a.getPosition()}},rE=class extends oF{constructor(){super("vmhd",0,1);this.g=new Uint8Array([0,
40
- 0,0,0,0,0])}a(){return 2+this.g.byteLength+super.a()}write(a){super.write(a);HD(a,0);_.Gi(a,this.g);a.getPosition()}},pF=class extends $D{constructor(a){super(a);this.w=!0}a(){return 8+super.a()}write(a){super.write(a);_.L(a,0);HD(a,0);HD(a,1)}},qF=class extends pF{constructor(a){super(a);this.height=this.width=0;this.depth=24}a(){return 70+super.a()}write(a){super.write(a);HD(a,0);HD(a,0);_.L(a,0);_.L(a,0);_.L(a,0);HD(a,this.width);HD(a,this.height);_.L(a,4718592);_.L(a,4718592);_.L(a,0);HD(a,1);
41
- FD(a,10);_.Gi(a,KD("AVC Coding",31));HD(a,this.depth);JD(a,-1)}},rF=class extends pF{constructor(a,b,c,d){super(a);this.channelCount=b;this.sampleSize=c;this.sampleRate=d}a(){return 20+super.a()}write(a){super.write(a);_.L(a,0);_.L(a,0);HD(a,this.channelCount);HD(a,this.sampleSize);JD(a,0);HD(a,0);HD(a,this.sampleRate);HD(a,0)}},qE=class extends qF{constructor(a,b){super("avc1");this.width=a;this.height=b}write(a){super.write(a);for(let b=0;b<this.f.length;b++)this.f[b].write(a);a.getPosition()}},
42
- aE=class extends qE{constructor(a,b){super(a,b);this.type="encv"}},tE=class extends rF{constructor(a,b,c){super("mp4a",a,b,c)}write(a){super.write(a);for(let b=0;b<this.f.length;b++)this.f[b].write(a);a.getPosition()}},bE=class extends tE{constructor(a,b,c){super(a,b,c);this.type="enca"}},pE=class extends $D{constructor(a,b){super("avcC");this.Ca=a;this.Eb=b;this.version=1;this.g=this.Ca[0][1];this.h=this.Ca[0][2];this.level=this.Ca[0][3]}a(){let a=7;for(var b=0;b<this.Ca.length;b++)a+=2,a+=this.Ca[b].byteLength;
43
- for(b=0;b<this.Ca.length;b++)a+=2,a+=this.Eb[b].byteLength;return a+super.a()}write(a){super.write(a);FD(a,this.version);FD(a,this.g);FD(a,this.h);FD(a,this.level);FD(a,255);FD(a,224|this.Ca.length);for(var b=0;b<this.Ca.length;b++)HD(a,this.Ca[b].length),_.Gi(a,this.Ca[b]);FD(a,this.Eb.length);for(b=0;b<this.Eb.length;b++)HD(a,this.Eb[b].length),_.Gi(a,this.Eb[b]);a.getPosition()}},sE=class extends oF{constructor(a){super("esds",0,0);this.yb=a}a(){return 22+(this.yb.byteLength+3)+super.a()}write(a){super.write(a);
44
- FD(a,3);FD(a,23+this.yb.byteLength);HD(a,1);FD(a,0);FD(a,4);FD(a,15+this.yb.byteLength);FD(a,64);FD(a,21);GD(a,0);_.L(a,0);_.L(a,0);FD(a,5);FD(a,this.yb.byteLength);_.Gi(a,this.yb);_.Gi(a,new Uint8Array([6,1,2]));a.getPosition()}},nE=class extends oF{constructor(a=""){super("url ",0,1);this.location=a}a(){return this.location.length+super.a()}write(a){super.write(a);0<this.location.length&&_.Gi(a,KD(this.location));a.getPosition()}},mE=class extends oF{constructor(){super("dref",0,0)}a(){let a=4;
45
- for(let b=0;b<this.entries.length;b++)a+=this.entries[b].a();return a+super.a()}write(a){super.write(a);_.L(a,this.entries.length);for(let b=0;b<this.entries.length;b++)this.entries[b].write(a);a.getPosition()}},vE=class extends $D{constructor(){super(_.ie)}},oE=class extends oF{constructor(){super(_.ke,0,0)}a(){let a=4;for(let b=0;b<this.entries.length;b++)a+=this.entries[b].a();return a+super.a()}write(a){super.write(a);_.L(a,this.entries.length);for(let b=0;b<this.entries.length;b++)this.entries[b].write(a);
46
- a.getPosition()}},wE=class extends oF{constructor(){super("stts",0,0)}a(){let a=4;for(let b=0;b<this.entries.length;b++)a+=this.entries[b].a();return a+super.a()}write(a){super.write(a);_.L(a,this.entries.length);for(let b=0;b<this.entries.length;b++)this.entries[b].write(a);a.getPosition()}},xE=class extends oF{constructor(){super("stsc",0,0)}a(){let a=4;for(let b=0;b<this.entries.length;b++)a+=this.entries[b].a();return a+super.a()}write(a){super.write(a);_.L(a,this.entries.length);for(let b=0;b<
47
- this.entries.length;b++)this.entries[b].write(a);a.getPosition()}},zE=class extends oF{constructor(){super("stco",0,0)}a(){let a=4;for(let b=0;b<this.entries.length;b++)a+=this.entries[b].a();return a+super.a()}write(a){super.write(a);_.L(a,this.entries.length);for(let b=0;b<this.entries.length;b++)this.entries[b].write(a);a.getPosition()}},yE=class extends oF{constructor(){super("stsz",0,0)}a(){return 8+super.a()}write(a){super.write(a);_.L(a,0);_.L(a,0);a.getPosition()}},uE=class extends oF{constructor(){super("smhd",
48
- 0,0)}a(){return 4+super.a()}write(a){super.write(a);JD(a,0);HD(a,0);a.getPosition()}},AE=class extends $D{constructor(){super("dinf")}},BE=class extends $D{constructor(){super(_.pd)}},CE=class extends $D{constructor(){super(_.ld)}},UE=class extends oF{constructor(a,b){super("tfdt",a,0);this.g=b}a(){let a=0;a=1===this.version?a+8:a+4;return a+super.a()}write(a){super.write(a);1===this.version?ED(a,this.g):_.L(a,this.g);a.getPosition()}},JE=class extends oF{constructor(){super("mfhd",0,0);this.g=0}a(){return 4+
49
- super.a()}write(a){super.write(a);_.L(a,this.g);a.getPosition()}},LE=class extends oF{constructor(a,b){super("trun",a,b);this.m=this.j=this.g=0;this.o=[];this.sampleSize=[];this.A=[];this.h=[]}a(){let a=4;this.flags&sF&&(a+=4);this.flags&tF&&(a+=4);for(let b=0;b<this.g;b++)this.flags&uF&&(a+=4),this.flags&vF&&(a+=4),this.flags&wF&&(a+=4),this.flags&xF&&(a+=4);return a+super.a()}write(a){super.write(a);_.L(a,this.g);this.flags&sF&&(a.getPosition(),ID(a,this.j));this.flags&tF&&_.L(a,this.m);for(let b=
50
- 0;b<this.g;b++)this.flags&uF&&_.L(a,this.o[b]),this.flags&vF&&_.L(a,this.sampleSize[b]),this.flags&wF&&_.L(a,this.A[b]),this.flags&xF&&(0===this.version?_.L(a,this.h[b]):ID(a,this.h[b]));a.getPosition()}},sF=1,tF=4,uF=256,vF=512,wF=1024,xF=2048,KE=class extends oF{constructor(a,b){super("tfhd",a,b);this.g=255;this.m=this.o=this.j=this.A=this.h=0}a(){let a=4;this.flags&yF&&(a+=8);this.flags&zF&&(a+=4);this.flags&AF&&(a+=4);this.flags&BF&&(a+=4);this.flags&CF&&(a+=4);return a+super.a()}write(a){super.write(a);
51
- _.L(a,this.g);this.flags&yF&&ED(a,this.h);this.flags&zF&&_.L(a,this.A);this.flags&AF&&_.L(a,this.j);this.flags&BF&&_.L(a,this.o);this.flags&CF&&_.L(a,this.m);a.getPosition()}},yF=1,zF=2,AF=8,BF=16,CF=32,QE=class extends $D{constructor(){super("traf")}},RE=class extends $D{constructor(){super("moof")}},PE=class extends $D{constructor(){super(_.kd);this.g=new Uint8Array(0)}a(){return this.g.byteLength+super.a()}write(a){super.write(a);0<this.g.byteLength&&_.Gi(a,this.g)}},cE=class extends oF{constructor(){super("tenc",
52
- 0,0);this.g=1;this.h=8;this.m="";this.j=[]}a(){let a;a=20;1===this.g&&0===this.h&&(a=a+1+this.j.length);return a+super.a()}write(a){super.write(a);FD(a,0);0===this.version?FD(a,0):FD(a,0);FD(a,this.g);FD(a,this.h);_.Gi(a,_.ri(this.m));if(1===this.g&&0===this.h){FD(a,0);for(let b=0;b<this.j.length;b++)FD(a,this.j[b])}a.getPosition()}},eE=class extends oF{constructor(a,b){super("schm",0,0);this.g=a;this.h=b;this.sb=""}a(){let a=8;this.flags&1&&(a+=KD(this.sb).byteLength);return a+super.a()}write(a){super.write(a);
53
- _.Gi(a,KD(this.g));_.L(a,this.h);this.flags&1&&_.Gi(a,KD(this.sb));a.getPosition()}},dE=class extends $D{constructor(a){super("frma");this.g=a}a(){return KD(this.g).byteLength+super.a()}write(a){super.write(a);_.Gi(a,KD(this.g));a.getPosition()}},VE=class extends oF{constructor(){super("saio",0,0);this.offset=[0]}a(){let a=0;this.flags&1&&(a+=8);a+=4;for(let b=0;1>b;b++)a=0===this.version?a+4:a+8;return a+super.a()}write(a){super.write(a);this.flags&1&&(_.L(a,0),_.L(a,0));_.L(a,1);for(let b=0;1>b;b++)0===
54
- this.version?_.L(a,this.offset[b]):ED(a,this.offset[b]);a.getPosition()}},WE=class extends oF{constructor(a,b,c){super("saiz",0,0);this.g=a;this.j=b;this.h=c}a(){let a=0;this.flags&1&&(a+=8);a+=5;0===this.g&&(a+=this.j.length);return a+super.a()}write(a){super.write(a);this.flags&1&&(_.L(a,0),_.L(a,0));FD(a,this.g);_.L(a,this.h);if(0===this.g)for(let b=0;b<this.h;b++)FD(a,this.j[b]);a.getPosition()}},OE=class extends oF{constructor(a,b){super("senc",a,b);this.h=0;this.j=8;this.g=[]}a(){let a=4;this.flags&
55
- 1&&(a+=1);for(let b=0;b<this.h;b++)if(a+=this.g[b].ke.byteLength,this.flags&2){a+=2;for(let c=0;c<this.g[b].qc;c++)a+=2,a+=4}return a+super.a()}write(a){super.write(a);_.L(a,this.h);this.flags&1&&FD(a,this.j);for(let b=0;b<this.h;b++)if(_.Gi(a,this.g[b].ke),this.flags&2){HD(a,this.g[b].qc);for(let c=0;c<this.g[b].qc;c++)HD(a,this.g[b].Pd[c].$d),_.L(a,this.g[b].Pd[c].ae)}a.getPosition()}};var TE=class{constructor(a,b,c,d){this.frameRate=Number(a)||30;this.f=Number(b)||1;this.a=Number(d);0==this.a&&(this.a=a?this.frameRate*this.f:1);c&&(a=/^(\d+) (\d+)$/g.exec(c))&&(this.frameRate*=parseInt(a[1],10)/parseInt(a[2],10))}},RD=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,SD=/^(?:(\d{2,}):)?(\d{2}):(\d{2})$/,TD=/^(?:(\d{2,}):)?(\d{2}):(\d{2}\.\d{2,})$/,UD=/^(\d*\.?\d*)f$/,VD=/^(\d*\.?\d*)t$/,WD=/^(?:(\d*\.?\d*)h)?(?:(\d*\.?\d*)m)?(?:(\d*\.?\d*)s)?(?:(\d*\.?\d*)ms)?$/;var HE=class{constructor(a){this.a=a;this.f=YD(this)}get(a){for(let b=0;b<this.a.length;b++){const c=this.a[b].get(a);if(c)return c}return null}write(){this.f=YD(this);for(let a=0;a<this.a.length;a++)this.a[a].write(this.f);return this.f.buffer}};var NE=new Uint8Array([162,57,79,82,90,155,79,20,162,68,108,66,124,100,141,244]);var DF=class{constructor(){this.B=this.j=this.h=this.g=null;this.N=1;this.W=0;this.o="";this.w=this.a=null;this.f=new _.O("clpp.smooth.SmoothParser");this.K=!1;this.m=this.C=null;this.R=eF;this.H=0;this.F=this.I=Infinity;this.A=[];this.L=this.V.bind(this)}configure(a){this.h=a}start(a,b){this.g=b;a=[...new Set([a,LD(a)])];return aF(this,a).then(c=>iF(this,c.data).then(()=>{jF(this,this.C);return this.j}))}stop(){this.g&&this.g.networkingEngine.Jd(this.L);this.C=this.B=this.j=this.h=this.g=null;this.m&&
56
- (clearTimeout(this.m),this.m=null);this.K=!1;this.I=this.F=Infinity;return Promise.resolve()}update(){if(this.D())return aF(this,[this.o]).then(a=>iF(this,a.data).then(()=>this.j)).catch(a=>{if(this.g)this.g.onError(a)})}onExpirationUpdated(){}T(){this.f.debug(_.Zs);this.g&&(this.m=null,this.update().then(()=>{jF(this,this.C)}).catch(a=>{this.g&&(this.g.onError(a),1===a.severity&&jF(this,100))}))}D(){return this.R===dF}J(){return 0<this.A.length}S(a){let b=null;if(this.A.length)for(let c=0;c<this.A.length;c++)if(this.A[c].keySystem===
57
- a){b=this.A[c].initData[0];break}return b}V(a){if(2!==a.request.type||a.uri.startsWith("data:"))return Promise.resolve(a);const b=a.request.timescale||this.B.timescale,c={isLive:this.D.bind(this),Pc:this.J.bind(this),ef:()=>1,hd:this.S.bind(this)};let d=!1;const e=new _.G(_.F,3,4035,null);let f=null;try{f=XE(a,b,c)}catch(g){d=!0,e.data=g,3E3===g.code&&(e.code=4039)}if(d||!f)return Promise.reject(e);a.data=f;return Promise.resolve(a)}},mF={video:_.Ge,audio:_.Zb,text:_.Rb},eF="VOD",dF="LIVE",nF={Kf:"caption",
58
- Lf:_.it};_.x("clpp.smooth.SmoothComponent",class extends _.So{constructor(){super()}f(){_.Vm.ism=DF;_.Tm[_.Sb]=DF}a(){_.du("ism");_.eu(_.Sb)}id(){return"smooth"}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var JE="Full MP4 box must have flags defined",KE="clpp.smooth.SmoothMP4Processor",LE="codecPrivateData",ME=function(a,b){const c=Math.floor(b/Math.pow(2,32));b-=c*Math.pow(2,32);_.L(a,c);_.L(a,b)},NE=function(a,b){try{a.f.setUint8(a.a,b),a.a+=1}catch(c){_.nj()}},OE=function(a,b){NE(a,b>>16&255);NE(a,b>>8&255);NE(a,b&255)},PE=function(a,b){try{a.f.setUint16(a.a,b,a.g),a.a+=2}catch(c){_.nj()}},QE=function(a,b){try{a.f.setInt32(a.a,b,a.g),a.a+=4}catch(c){_.nj()}},RE=function(a,b){try{a.f.setInt16(a.a,
2
+ b,a.g),a.a+=2}catch(c){_.nj()}},SE=function(a,b){if(void 0!=b){var c=new Uint8Array(b);const d=Math.min(a.length,b);let e=0;for(;e<d;++e)c[e]=a.charCodeAt(e);for(;e<b;e++)c[e]=0;return c}b=new Uint8Array(a.length);for(c=0;c<a.length;++c)b[c]=a.charCodeAt(c);return b},TE=function(a){const b=a.split("/");return b[b.length-1].toLowerCase().match("manifest(\\(.+\\))?")?a:`${a}/Manifest`},UE=function(a,b,c,d){c=b.ne[c];b=b.Vf;a=a.replace("Manifest","");b=b.replace("{bitrate}",String(d.bitrate)).replace("{Bitrate}",
3
+ String(d.bitrate)).replace("{start time}",String(c.t)).replace("{start_time}",String(c.t));return _.lu([a],[b])[0]},VE=function(a,b){if(a.type!==b.type)return!1;let c=[];a.type===_.v?c=["maxWidth","maxHeight","bitrate",LE,"fourCC"]:a.type===_.Yb&&(c=["bitrate",LE,"channels","bitsPerSample","samplingRate","fourCC"]);return _.of(a,b,c,["id","segmentIndex"])},WE=function(a,b,c){const d=c.Lc.split("00000001");a={id:1,type:c.type,duration:a/b,timescale:b,Ha:null,Gb:null,width:NaN,height:NaN,zb:null,Fc:NaN,
4
+ sampleSize:NaN,channelCount:NaN};switch(c.type){case _.v:a.Ha=[_.$i(d[1])];a.Gb=[_.$i(d[2])];a.width=c.maxWidth;a.height=c.maxHeight;break;case _.Yb:a.zb=_.$i(c.Lc),a.sampleSize=c.We||16,a.Fc=c.Fc,a.channelCount=c.je}return a},XE=function(a,b){return a.filter(c=>c.type===b)},YE=function(a,b){a=a.exec(b);return null==a||""==a[0]?null:(Number(a[4])||0)/1E3+(Number(a[3])||0)+60*(Number(a[2])||0)+3600*(Number(a[1])||0)},eF=function(a,b,c){var d=null;if(ZE.test(a)){{a=ZE.exec(a);d=Number(a[1]);const e=
5
+ Number(a[2]);let f=Number(a[3]),g=Number(a[4]);g+=(Number(a[5])||0)/c.f;f+=g/c.frameRate;d=f+60*e+3600*d}}else $E.test(a)?d=YE($E,a):aF.test(a)?d=YE(aF,a):bF.test(a)?(a=bF.exec(a),d=Number(a[1])/c.frameRate):cF.test(a)?(a=cF.exec(a),d=Number(a[1])/c.a):dF.test(a)&&(d=YE(dF,a));c=d;d=c+b;b=Math.floor(d/3600);c=Math.floor((d-3600*b)/60);a=Math.floor(d-3600*b-60*c);d-=a;10>b&&(b="0"+b);10>c&&(c="0"+c);10>a&&(a="0"+a);0===d?d="000":d=Math.round(1E3*d);return b+":"+c+":"+a+"."+d},fF=function(a){let b=
6
+ 0;for(let c=0;c<a.a.length;c++)b+=a.a[c].a();return new _.Hj(b)},mF=function(a,b,c){a:{var d=[_.Gc,_.Fc];for(e of d)if((d=c.Qc(e))&&d.keyId){var e=d.keyId;break a}_.B(KE,"Could not get default Key ID for DRM init data!");e=null}c=new gF("xxxx");a.type===_.v?c=new hF(a.width,a.height):c=new iF(a.channelCount,a.sampleSize,a.Fc);a=new jF;a.g=1;a.h=8;a.m=e||"00000000000000000000000000000000";a=(new gF("schi")).append([a]);b=(new gF(_.fe)).append([new kF(b),new lF(_.qc,65536),a]);c.append([b]);return c},
7
+ PF=function(a,b){var c=b.Vc(),d=new nF(a.timescale,a.duration,a.id),e=(new oF).append([new pF(a.id)]),f=new qF(a.id,a.duration,a.timescale,a.width,a.height),g=new rF(a.timescale,a.duration);const h=new sF(a.type);var k=null,l=new tF;l.entries=[new uF];var m=new vF;switch(a.type){case _.v:k=new wF(a.Ha,a.Gb);c?(a=mF(a,"avc1",b),a.append([k]),m.entries=[a]):(a=(new xF(a.width,a.height)).append([k]),m.entries=[a]);k=new yF;break;case _.Yb:k=new zF(a.zb),c?(a=mF(a,"mp4a",b),a.append([k]),m.entries=[a]):
8
+ (a=(new AF(a.channelCount,a.sampleSize,a.Fc)).append([k]),m.entries=[a]),k=new BF}m=(new CF).append([m,new DF,new EF,new FF,new GF]);l=(new HF).append([l]);l=(new IF).append([k,l,m]);g=(new JF).append([g,h,l]);f=(new KF).append([f,g]);d=(new LF).append([d,f,e]);e=new MF("dash",0,["iso6","mp41","avc1"]);c&&(c=b.Qc(_.Fc),b=b.Qc(_.Gc),c&&d.append([new NF("pssh",c.initData,8)]),b&&d.append([new NF("pssh",b.initData,8)]),c||b||_.B(KE,"Could not get PSSH init data!"));b=new OF([e,d]);return _.G(b.write())},
9
+ ZF=function(a,b){let c,d,e,f,g,h;(new _.Fj).L("moof",_.N).X("mfhd",k=>{{const l=new QF;l.g=_.M(k.G);c=l}}).L("traf",_.N).X("tfhd",k=>{{const l=k.G.va();if(null===k.flags)throw new _.H(_.F,3,3019,JE);const m=new RF(k.version||0,k.flags||0);m.g=_.M(k.G);0<l-k.G.getPosition()&&k.flags&1&&(m.h=_.vj(k.G));0<l-k.G.getPosition()&&k.flags&2&&(m.A=_.M(k.G));0<l-k.G.getPosition()&&k.flags&8&&(m.j=_.M(k.G));0<l-k.G.getPosition()&&k.flags&16&&(m.o=_.M(k.G));0<l-k.G.getPosition()&&k.flags&32&&(m.m=_.M(k.G));d=
10
+ m}}).X("trun",k=>{{var l=k.G.va();if(null===k.flags)throw new _.H(_.F,3,3019,JE);const m=new SF(k.version||0,k.flags||0);m.g=_.M(k.G);0<l-k.G.getPosition()&&k.flags&1&&(m.j=_.tj(k.G));0<l-k.G.getPosition()&&k.flags&4&&(m.m=_.M(k.G));if(0<l-k.G.getPosition())for(l=0;l<m.g;l++)k.flags&256&&m.o.push(_.M(k.G)),k.flags&512&&m.sampleSize.push(_.M(k.G)),k.flags&1024&&m.A.push(_.M(k.G)),k.flags&2048&&(0===k.version?m.h.push(_.M(k.G)):m.h.push(_.tj(k.G)));e=m}}).X("sdtp",k=>{{const l=_.wj(k.G,k.G.va());f=
11
+ new TF("sdtp",k.version||0,k.flags||0,l,0)}}).L("uuid",k=>{var l=_.wj(k.G,16);if(_.bj(l,UF)){l=_.M(k.G);k.version=l>>>24;k.flags=l&16777215;l=new VF(k.version,k.flags);l.h=_.M(k.G);k.flags&1&&(l.j=_.rj(k.G));for(let m=0;m<l.h;m++){const n={qe:_.wj(k.G,8),rc:0,Wd:[]};if(k.flags&2){n.rc=_.sj(k.G);for(let q=0;q<n.rc;q++){const t={ge:0,he:0};t.ge=_.sj(k.G);t.he=_.M(k.G);n.Wd.push(t)}}l.g.push(n)}g=l}}).L(_.pd,k=>{{const l=new WF;0<k.G.va()?l.g=_.wj(k.G,k.G.va()):(_.B(KE,"mdat box is empty!"),l.g=new Uint8Array(0));
12
+ h=l}}).parse(a,!1);if(!h)return null;a=(new XF).append([d,e]);f&&a.append([f]);b.Vc()&&g&&a.append([g]);b=(new YF).append([c,a]);return new OF([b,h])},dG=function(a,b,c){var d=c.Vc(),e=a.request.startTime,f=parseInt(e*b,10);b=a.data||new ArrayBuffer(0);var g=ZF(b,c);if(null===g)return a.request.contentType===_.r?a.data:g;c=g.get(_.pd);if(a.request.contentType===_.r){d=c.g.buffer;if(e){d=_.Bg(d);if((d=(new DOMParser).parseFromString(d,_.se))&&"tt"===d.documentElement.tagName.toLowerCase())var h=d.documentElement;
13
+ if(h&&(c=new $F(h.getAttribute("ttp:frameRate"),h.getAttribute("ttp:subFrameRate"),h.getAttribute("ttp:frameRateMultiplier"),h.getAttribute("ttp:tickRate")),h=h.getElementsByTagName("body")[0])){f=h.getElementsByTagName("p");for(let t=0,u=f.length;t<u;t++){h=f[t];a=e;b=c;g=["begin",_.Uc];for(let y=0,A=g.length;y<A;y++){b:{var k=h;var l=g[y],m=new RegExp("\\w+:"+l),n=0;if(k.hasAttribute(l)){k=k.getAttribute(l);break b}l=k.attributes;const E=l.length;for(;n<E;n++){var q=l[n].name;if(q=q.match(m)){k=
14
+ k.getAttribute(q[0]);break b}}k=null}h.setAttribute(g[y],eF(k||"",a,b))}}}d=(new XMLSerializer).serializeToString(d);e=_.Cg(d).buffer}else e=d;return e}h=new YF;a=g.get("mfhd");b=new XF;k=g.get("tfhd");m=new aG(1,f);f=g.get("trun");n=g.get("sdtp");e=g.get("senc");k.g=1;k.flags&=16777214;k.flags|=131072;b.append([k,m,f]);n&&b.append([n]);if(d){g=0;k=[];if(e.flags&2)for(k=[],m=0;m<e.h;m++)k.push(10+6*e.g[m].rc);else g=8;b.append([e,new bG,new cG(g,k,e.h)])}h.append([a,b]);f.flags|=1;f.j=h.a()+8;c=new OF([h,
15
+ c]);h=c.write();d&&(d=c.get("saio"),c=c.f,d.offset[0]=e.start+16,c.seek(d.start),d.write(c),h=c.buffer);return h},eG=function(a,b,c){return{keySystem:a,licenseServerUri:"",distinctiveIdentifierRequired:!1,persistentStateRequired:!1,audioRobustness:"",videoRobustness:"",serverCertificate:null,initData:[b],keyIds:c,periodId:null}},fG=function(a){return{initData:_.cu(_.nk(a)),initDataType:_.qc,keyId:a,periodId:null}},gG=function(a,b,c){a=_.vk(a);c&&a.version!==c&&(a=_.eu(a,c));return{initData:_.cu(a),
16
+ initDataType:_.qc,keyId:b,periodId:null}},hG=function(a,b){return _.w(function*(){var c=_.Wg(b);c.timeout=a.h.attemptParameters.timeout;c.maxAttempts=Math.max(a.h.attemptParameters.maxAttempts,b.length);c.baseDelay=a.h.attemptParameters.baseDelay;c.backoffFactor=a.h.attemptParameters.backoffFactor;c.fuzzFactor=a.h.attemptParameters.fuzzFactor;c.type=1;c=yield a.g.networkingEngine.fetch(c).P;a.o=c.uri;return c})},pG=function(a,b){let c=null;try{{const xa=new DOMParser;let ib,Na;try{const cb=_.Bg(b);
17
+ Na=xa.parseFromString(cb.trim(),_.se)}catch(cb){throw cb;}Na&&Na.documentElement.tagName==_.jb&&(ib=Na.documentElement);c=ib&&0<ib.getElementsByTagName("parsererror").length?null:ib}}catch(xa){}if(!c)throw a.f.error("Unable to parse manifest"),new _.H(_.F,4,4033,a.o);const d=+iG(a,c,"MajorVersion"),e=+iG(a,c,"MinorVersion"),f=+c.getAttribute("TimeScale")||1E7;let g=+iG(a,c,"Duration");const h="TRUE"===c.getAttribute("IsLive"),k=+c.getAttribute("LookAheadCount"),l=+c.getAttribute("DVRWindowLength")||
18
+ Infinity,m=_.hk(c,"Protection")[0];if(!1===/^[2].[0-2]$/.test(""+d+"."+e))throw a.f.error("Smooth Streaming version must be 2.0, 2.1 or 2.2"),new _.H(_.F,4,4036,a.o);h?(jG(a,kG),a.C=typeof a.h.liveRefreshPeriod===_.p?1E3*a.h.liveRefreshPeriod:Math.min(1E3*a.H,1E4),g=Infinity):jG(a,lG);a.a={startTime:0,delay:0,duration:g/f,ld:l/f,Ac:0};if(m){{var n=a.h.playreadyVersion;const xa=[],ib=_.hk(m,"ProtectionHeader")[0],Na=_.Zi(_.jk(ib)||""),cb=_.vk(Na).a;xa.push(eG(_.Gc,fG(cb),[cb]));xa.push(eG(_.Fc,gG(Na,
19
+ cb,n),[cb]));var q=xa}a.w=q}{const xa=[],ib=_.hk(c,"StreamIndex");if(!ib.length)throw a.f.error("No streams found!"),new _.H(_.F,4,4034,a.o);for(let Na=0;Na<ib.length;Na++){{var t=a,u=ib[Na];const cb=iG(t,u,"Type"),ic=+u.getAttribute("Chunks"),Qg=u.getAttribute("Subtype"),Fe=_.Ih(u.getAttribute("Language")||_.we),Kd=u.getAttribute("Name")||"",Rg=+u.getAttribute(_.La),Af=+u.getAttribute(_.Ka),Bf=iG(t,u,"Url"),Bk=+u.getAttribute("TimeScale")||null;{const jc=[],li=_.hk(u,_.Ya);for(let Ld=0;Ld<li.length;Ld++){{let kc,
20
+ Ia,gd;var y=t,A=li[Ld],E=cb;const mi=+A.getAttribute("Index"),Cf=+iG(y,A,"Bitrate");let Ob=NaN,Df=NaN,Ck=NaN,lp=NaN,sy=NaN,ty=NaN,uy=NaN;const vy=A.getAttribute("FourCC");switch(E){case _.v:Ob=+iG(y,A,_.Ka);Df=+iG(y,A,_.La);break;case _.Yb:lp=+A.getAttribute("Channels")||2,Ck=+iG(y,A,"SamplingRate"),ty=+iG(y,A,"AudioTag"),sy=+iG(y,A,"BitsPerSample"),uy=+iG(y,A,"PacketSize")}let mp=String(A.getAttribute("CodecPrivateData"));if(E===_.Yb&&!mp){{var D=lp;const wy={96E3:0,88200:1,64E3:2,48E3:3,44100:4,
21
+ 32E3:5,24E3:6,22050:7,16E3:8,12E3:9,11025:10,8E3:11,7350:12},Dk=wy[Ck];if("AACH"===vy){Ia=new Uint8Array(4);const xy=wy[2*Ck];Ia[0]=40|Dk>>1;Ia[1]=Dk<<7|D<<3|xy>>1;Ia[2]=xy<<7|8;Ia[3]=0;kc=new Uint16Array(2);kc[0]=(Ia[0]<<8)+Ia[1];kc[1]=(Ia[2]<<8)+Ia[3];gd=kc[0].toString(16)+kc[1].toString(16)}else Ia=new Uint8Array(2),Ia[0]=16|Dk>>1,Ia[1]=Dk<<7|D<<3,kc=new Uint16Array(1),kc[0]=(Ia[0]<<8)+Ia[1],gd=kc[0].toString(16);mp=gd.toUpperCase()}}var ma={id:y.W++,type:E,index:mi,bitrate:Cf,Lc:mp,maxHeight:Ob,
22
+ maxWidth:Df,Fc:Ck,je:lp,dg:ty,We:sy,ng:uy,jf:vy,segmentIndex:null}}jc.push(ma)}var na=jc}{const jc=[],li=_.hk(u,"c");for(let Ld=0;Ld<li.length;Ld++){const kc=li[Ld];let Ia=parseInt(kc.getAttribute("t"),10),gd=parseInt(kc.getAttribute("d"),10),mi=parseInt(kc.getAttribute("r"),10),Cf=0;if(isNaN(Ia)&&isNaN(gd))throw t.f.error("Either one or both FragmentDuration and FragmentTime field MUST be present in StreamFragmentElement"),new _.H(_.F,4,4037,t.o);0===Ld&&isNaN(Ia)&&(Cf=Ia=0);if(0<Ld){const Ob=jc[jc.length-
23
+ 1];Cf=Ob.n+1;Ob.d||(Ob.d=Ia-Ob.t);Ia||(Ia=Ob.t+Ob.d);gd||(gd=Ia-Ob.t)}jc.push({n:Cf,d:gd,t:Ia});if(mi){mi--;for(let Ob=0;Ob<mi;Ob++){const Df=jc[jc.length-1];Cf=Df.n+1;Ia=Df.t+Df.d;gd=Df.d;jc.push({n:Cf,d:gd,t:Ia})}}}t.D()||jc.length===ic||t.f.warn("Number of fragments ("+ic+") differs from number of chunks ("+jc.length+").");var uf=jc}var vf={type:cb,fg:ic,Rf:Qg,language:Fe,name:Kd,maxWidth:Rg,maxHeight:Af,Vf:Bf,tracks:na,ne:uf,timescale:Bk}}xa.push(vf)}var wf=xa}const Qa={lg:d,te:e,timescale:f,
24
+ duration:g,isLive:h,kg:k,ld:l,ud:!1,streams:wf};if(a.j&&a.A)return mG(a,Qa),Promise.resolve();{const xa=Qa.timescale,ib=Qa.duration,Na=XE(Qa.streams,_.Yb),cb=XE(Qa.streams,_.v),ic=XE(Qa.streams,_.r),Qg=[];let Fe=nG(a,ib,xa,Na),Kd=nG(a,ib,xa,cb);const Rg=nG(a,ib,xa,ic);Fe.length||(Fe=[null]);Kd.length||(Kd=[null]);for(let Af=0;Af<Kd.length;Af++)for(let Bf=0;Bf<Fe.length;Bf++)Qg.push(oG(a,Kd[Af],Fe[Bf]));var ed={startTime:0,variants:Qg,textStreams:Rg,thumbStreams:[]}}{var hd=Qa.streams;let xa=a.a.startTime,
25
+ ib=a.a.delay;const Na=a.I;let cb=Math.min(a.a.duration||Infinity,Na);const ic=a.D(),Qg=a.a.ld,Fe=a.a.Ac,Kd=a.H,Rg=isFinite(a.F)?a.F:0;if(ic)cb=Infinity,xa=Date.now()/1E3-Fe,a.a.startTime=xa,ib=3*Kd;else{const Af=isFinite(Na)?Na:a.a.duration;for(const Bf of hd)for(const Bk of Bf.tracks)Bk.segmentIndex.offset(-Rg),_.Vu(Bk.segmentIndex,Af)}a.B=new _.lz(xa,ib,!ic,!0);a.B.Jb(cb);_.Iu(a.B,Kd);a.B.Zb=Qg;ic||a.B.offset(-Rg)}a.g.filterAllPeriods([ed]);a.j={presentationTimeline:a.B,periods:[ed],offlineSessionIds:[],
26
+ minBufferTime:0};Promise.resolve();a.K||(a.g.networkingEngine.cd(a.M),a.K=!0);a.A=Qa;return Promise.resolve()},qG=function(a,b){null!=a.C&&null!=b&&(a.m=window.setTimeout(a.U.bind(a),b))},iG=function(a,b,c){if(b=b.getAttribute(c))return b;a.f.error("required attribute not provided: "+c);throw new _.H(_.F,4,4038,a.o,c);},jG=function(a,b){const c=b===lG;if(a.j&&a.j.presentationTimeline){var d=a.j.presentationTimeline;d.j=c;d.m=c}c&&null!=a.m&&(window.clearTimeout(a.m),a.m=null,a.C=null);a.R=b},mG=function(a,
27
+ b){for(let e=0;e<a.A.streams.length;e++){const f=b.streams[e];for(const g of a.A.streams[e].tracks){var c=f.tracks.find(h=>h.type===g.type&&h.bitrate===g.bitrate);if(c){VE(g,c)||a.f.warn("The current stream is updated with a stream that seems to have different base properties!");var d=rG(a,a.A.timescale,f,c);c=g.segmentIndex;_.Ru(c,d);(d=a.a.ld)&&_.Su(c,_.Pu(c)-d)}else a.f.warn(`Cannot find satisfying update for ${g.type} `+`track with bitrate ${g.bitrate}. Skipping update.`)}}},rG=function(a,b,c,
28
+ d){let e=0;const f=[],g=c.timescale||b;c.ne.forEach((h,k)=>{const l=h.d/g;0===k?(h=h.t/g,a.F=Math.min(a.F,h)):h=f[k-1].endTime;const m=h+l,n=UE(a.o,c,k,d);a.H=Math.max(a.H,l);f.push(new _.Qu(k,h,m,()=>[n],0,null,0,null,!0,g));e+=l});if(c.type===_.v||c.type===_.Yb)b=f[f.length-1],a.I=Math.min(a.I,e),0===a.a.Ac?a.a.Ac=b.endTime:a.a.Ac=Math.min(a.a.Ac,b.endTime);return f},nG=function(a,b,c,d){let e=[];for(let f=0;f<d.length;f++){const g=d[f].tracks.map(h=>{var k=d[f],l=rG(a,c,k,h),m=new _.mz(l),n=null;
29
+ k.type!==_.r&&(n=sG(a,b,c,k,h));h.segmentIndex=m;l=a.N++;var q=Promise.resolve.bind(Promise),t=m.f.bind(m),u=m.get.bind(m),y=m.g.bind(m);m=m.getDuration.bind(m);var A=tG[k.type];var E="";switch(k.type){case _.v:E=h.Lc;var D=/00000001[0-9]7/.exec(E);E="avc1."+(D&&D[0]?E.substr(E.indexOf(D[0])+10,6):"42c00c");a.f.debug("VIDEO CODECS: ",E);break;case _.Yb:E=h.Lc,D=2,"AACH"===h.jf?D=5:E&&(D=(parseInt(E.substr(0,2),16)&248)>>3),E="mp4a.40."+D,a.f.debug("AUDIO CODECS: ",E)}D=k.type===_.r?uG[k.Rf]:void 0;
30
+ return h={id:l,originalId:null,pg:null,createSegmentIndex:q,findSegmentPosition:t,getSegmentReference:u,adjustSegmentDurations:y,getDuration:m,segmentIndex:null,segmentLookupStrategy:_.Nt,initSegmentReference:n,mimeType:A,codecs:E,frameRate:void 0,bandwidth:h.bitrate,width:h.maxWidth||void 0,height:h.maxHeight||void 0,kind:D,encrypted:a.J(),keyId:null,language:k.language,label:k.name,type:k.type,primary:!1,trickModeVideo:null,emsgSchemeIdUris:null,roles:[],channelsCount:h.je||null,closedCaptions:null}});
31
+ e=e.concat(g)}return e},oG=function(a,b,c){const d=(c?c.bandwidth:0)+(b?b.bandwidth:0),e=c?c.language:_.we;return c||b?{id:a.N++,language:e,primary:!1,audio:c,video:b,bandwidth:d,drmInfos:a.w,allowedByApplication:!0,allowedByKeySystem:!0}:null},sG=function(a,b,c,d,e){b=WE(b,d.timescale||c,e);c={isLive:a.D.bind(a),Vc:a.J.bind(a),pf:()=>1,Qc:a.S.bind(a)};d=new Uint8Array(0);try{d=PF(b,c)}catch(g){throw a.f.error("Failed to generate initialization segment."),new _.H(_.F,3,4035,g);}const f="data:text/plain;base64,"+
32
+ _.Yi(d);return new _.kz(()=>[f],0,null,null,!0)},gF=class{constructor(a){this.type=a;this.size=this.start=0;this.parent=null;this.w=!1;this.entries=[];this.f=[]}append(a=[]){for(let b=0;b<a.length;b++)this.f.push(a[b]),a[b].parent=this;return this}get(a){if(this.type===a)return this;for(let b=0;b<this.f.length;b++){if(this.f[b].type===a)return this.f[b];{const c=this.f[b].get(a);if(c)return c}}return null}a(){const a=Math.pow(2,32)-1;let b;b=4+this.type.length;"uuid"===this.type&&(b+=16);if(0<this.f.length)for(let c=
33
+ 0;c<this.f.length;c++)b+=this.f[c].a();this.size>a&&(b+=8);return b}write(a){var b=Math.pow(2,32)-1;this.start=a.getPosition();this.size=this.a();this.size>b?_.L(a,1):_.L(a,this.size);_.oj(a,SE(this.type));this.size>b&&ME(a,this.size);"uuid"===this.type&&_.oj(a,null);if(0<this.f.length&&!this.w)for(b=0;b<this.f.length;b++)this.f[b].write(a),this.f[b].a(),a.getPosition()}},vG=class extends gF{constructor(a,b,c){super(a);this.version=b;this.flags=c}a(){return 4+super.a()}write(a){super.write(a);NE(a,
34
+ this.version);OE(a,this.flags)}},NF=class extends gF{constructor(a,b,c){super(a);this.g=b;this.offset=c}a(){return this.g.byteLength+super.a()-this.offset}write(a){super.write(a);_.oj(a,this.g,this.offset);a.getPosition()}},TF=class extends vG{constructor(a,b,c,d,e){super(a,b,c);this.g=d;this.offset=e}a(){return this.g.byteLength+super.a()-this.offset}write(a){super.write(a);_.oj(a,this.g,this.offset);a.getPosition()}},MF=class extends gF{constructor(a,b,c){super("ftyp");this.h=a;this.te=b;this.g=
35
+ c}a(){let a=this.h.length;a=a+4+this.g.join("").length;return a+super.a()}write(a){super.write(a);_.oj(a,SE(this.h));_.L(a,this.te);_.oj(a,SE(this.g.join("")));a.getPosition()}},LF=class extends gF{constructor(){super(_.vd)}},KF=class extends gF{constructor(){super(_.ue)}},nF=class extends vG{constructor(a,b,c){super("mvhd",1,0);this.timescale=a;this.duration=b;this.volume=256;this.h=c+1;this.g=[0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0]}a(){let a=0;a=1===this.version?
36
+ a+28:a+16;a=a+44+this.g.length;return a+=super.a()}write(a){super.write(a);1===this.version?(ME(a,0),ME(a,0),_.L(a,this.timescale),ME(a,this.duration*this.timescale)):(_.L(a,0),_.L(a,0),_.L(a,this.timescale),_.L(a,this.duration*this.timescale));_.L(a,65536);PE(a,this.volume);PE(a,0);_.L(a,0);_.L(a,0);for(let b=0;b<this.g.length;b++)NE(a,this.g[b]);_.L(a,0);_.L(a,0);_.L(a,0);_.L(a,0);_.L(a,0);_.L(a,0);_.L(a,this.h);a.getPosition()}},oF=class extends gF{constructor(){super("mvex")}},pF=class extends vG{constructor(a){super("trex",
37
+ 0,0);this.g=a}a(){return 20+super.a()}write(a){super.write(a);_.L(a,this.g);_.L(a,1);_.L(a,0);_.L(a,0);_.L(a,0);a.getPosition()}},qF=class extends vG{constructor(a,b,c,d,e){super("tkhd",1,7);this.h=a;this.duration=b;this.timescale=c;this.width=d;this.height=e;this.volume=1;this.g=[0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0]}a(){let a=0;a=1===this.version?a+32:a+20;a=a+24+this.g.length;return a+super.a()}write(a){super.write(a);1===this.version?(ME(a,0),ME(a,0),_.L(a,
38
+ this.h),_.L(a,0),ME(a,this.duration*this.timescale)):(_.L(a,0),_.L(a,0),_.L(a,this.h),_.L(a,0),_.L(a,this.duration*this.timescale));_.L(a,0);_.L(a,0);PE(a,0);PE(a,0);PE(a,this.volume);PE(a,0);for(let b=0;b<this.g.length;b++)NE(a,this.g[b]);PE(a,this.width);PE(a,0);PE(a,this.height);PE(a,0);a.getPosition()}},rF=class extends vG{constructor(a,b){super("mdhd",1,0);this.timescale=a;this.duration=b;this.language=21956}a(){let a=0;a=1===this.version?a+28:a+16;return a+4+super.a()}write(a){super.write(a);
39
+ 1===this.version?(ME(a,0),ME(a,0),_.L(a,this.timescale),ME(a,this.duration*this.timescale)):(_.L(a,0),_.L(a,0),_.L(a,this.timescale),_.L(a,this.duration*this.timescale));PE(a,this.language);PE(a,0);a.getPosition()}},sF=class extends vG{constructor(a){super("hdlr",0,0);this.g=a}a(){return 33+super.a()}write(a){super.write(a);_.L(a,0);this.g===_.v?_.oj(a,SE("vide")):_.oj(a,SE("soun"));_.L(a,0);_.L(a,0);_.L(a,0);this.g===_.v?_.oj(a,SE("VideoHandler\x00")):_.oj(a,SE("SoundHandler\x00"));a.getPosition()}},
40
+ yF=class extends vG{constructor(){super("vmhd",0,1);this.g=new Uint8Array([0,0,0,0,0,0])}a(){return 2+this.g.byteLength+super.a()}write(a){super.write(a);PE(a,0);_.oj(a,this.g);a.getPosition()}},wG=class extends gF{constructor(a){super(a);this.w=!0}a(){return 8+super.a()}write(a){super.write(a);_.L(a,0);PE(a,0);PE(a,1)}},xG=class extends wG{constructor(a){super(a);this.height=this.width=0;this.depth=24}a(){return 70+super.a()}write(a){super.write(a);PE(a,0);PE(a,0);_.L(a,0);_.L(a,0);_.L(a,0);PE(a,
41
+ this.width);PE(a,this.height);_.L(a,4718592);_.L(a,4718592);_.L(a,0);PE(a,1);NE(a,10);_.oj(a,SE("AVC Coding",31));PE(a,this.depth);RE(a,-1)}},yG=class extends wG{constructor(a,b,c,d){super(a);this.channelCount=b;this.sampleSize=c;this.sampleRate=d}a(){return 20+super.a()}write(a){super.write(a);_.L(a,0);_.L(a,0);PE(a,this.channelCount);PE(a,this.sampleSize);RE(a,0);PE(a,0);PE(a,this.sampleRate);PE(a,0)}},xF=class extends xG{constructor(a,b){super("avc1");this.width=a;this.height=b}write(a){super.write(a);
42
+ for(let b=0;b<this.f.length;b++)this.f[b].write(a);a.getPosition()}},hF=class extends xF{constructor(a,b){super(a,b);this.type="encv"}},AF=class extends yG{constructor(a,b,c){super("mp4a",a,b,c)}write(a){super.write(a);for(let b=0;b<this.f.length;b++)this.f[b].write(a);a.getPosition()}},iF=class extends AF{constructor(a,b,c){super(a,b,c);this.type="enca"}},wF=class extends gF{constructor(a,b){super("avcC");this.Ha=a;this.Gb=b;this.version=1;this.g=this.Ha[0][1];this.h=this.Ha[0][2];this.level=this.Ha[0][3]}a(){let a=
43
+ 7;for(var b=0;b<this.Ha.length;b++)a+=2,a+=this.Ha[b].byteLength;for(b=0;b<this.Ha.length;b++)a+=2,a+=this.Gb[b].byteLength;return a+super.a()}write(a){super.write(a);NE(a,this.version);NE(a,this.g);NE(a,this.h);NE(a,this.level);NE(a,255);NE(a,224|this.Ha.length);for(var b=0;b<this.Ha.length;b++)PE(a,this.Ha[b].length),_.oj(a,this.Ha[b]);NE(a,this.Gb.length);for(b=0;b<this.Gb.length;b++)PE(a,this.Gb[b].length),_.oj(a,this.Gb[b]);a.getPosition()}},zF=class extends vG{constructor(a){super("esds",0,
44
+ 0);this.zb=a}a(){return 22+(this.zb.byteLength+3)+super.a()}write(a){super.write(a);NE(a,3);NE(a,23+this.zb.byteLength);PE(a,1);NE(a,0);NE(a,4);NE(a,15+this.zb.byteLength);NE(a,64);NE(a,21);OE(a,0);_.L(a,0);_.L(a,0);NE(a,5);NE(a,this.zb.byteLength);_.oj(a,this.zb);_.oj(a,new Uint8Array([6,1,2]));a.getPosition()}},uF=class extends vG{constructor(a=""){super("url ",0,1);this.location=a}a(){return this.location.length+super.a()}write(a){super.write(a);0<this.location.length&&_.oj(a,SE(this.location));
45
+ a.getPosition()}},tF=class extends vG{constructor(){super("dref",0,0)}a(){let a=4;for(let b=0;b<this.entries.length;b++)a+=this.entries[b].a();return a+super.a()}write(a){super.write(a);_.L(a,this.entries.length);for(let b=0;b<this.entries.length;b++)this.entries[b].write(a);a.getPosition()}},CF=class extends gF{constructor(){super(_.ke)}},vF=class extends vG{constructor(){super(_.me,0,0)}a(){let a=4;for(let b=0;b<this.entries.length;b++)a+=this.entries[b].a();return a+super.a()}write(a){super.write(a);
46
+ _.L(a,this.entries.length);for(let b=0;b<this.entries.length;b++)this.entries[b].write(a);a.getPosition()}},DF=class extends vG{constructor(){super("stts",0,0)}a(){let a=4;for(let b=0;b<this.entries.length;b++)a+=this.entries[b].a();return a+super.a()}write(a){super.write(a);_.L(a,this.entries.length);for(let b=0;b<this.entries.length;b++)this.entries[b].write(a);a.getPosition()}},EF=class extends vG{constructor(){super("stsc",0,0)}a(){let a=4;for(let b=0;b<this.entries.length;b++)a+=this.entries[b].a();
47
+ return a+super.a()}write(a){super.write(a);_.L(a,this.entries.length);for(let b=0;b<this.entries.length;b++)this.entries[b].write(a);a.getPosition()}},GF=class extends vG{constructor(){super("stco",0,0)}a(){let a=4;for(let b=0;b<this.entries.length;b++)a+=this.entries[b].a();return a+super.a()}write(a){super.write(a);_.L(a,this.entries.length);for(let b=0;b<this.entries.length;b++)this.entries[b].write(a);a.getPosition()}},FF=class extends vG{constructor(){super("stsz",0,0)}a(){return 8+super.a()}write(a){super.write(a);
48
+ _.L(a,0);_.L(a,0);a.getPosition()}},BF=class extends vG{constructor(){super("smhd",0,0)}a(){return 4+super.a()}write(a){super.write(a);RE(a,0);PE(a,0);a.getPosition()}},HF=class extends gF{constructor(){super("dinf")}},IF=class extends gF{constructor(){super(_.ud)}},JF=class extends gF{constructor(){super(_.qd)}},aG=class extends vG{constructor(a,b){super("tfdt",a,0);this.g=b}a(){let a=0;a=1===this.version?a+8:a+4;return a+super.a()}write(a){super.write(a);1===this.version?ME(a,this.g):_.L(a,this.g);
49
+ a.getPosition()}},QF=class extends vG{constructor(){super("mfhd",0,0);this.g=0}a(){return 4+super.a()}write(a){super.write(a);_.L(a,this.g);a.getPosition()}},SF=class extends vG{constructor(a,b){super("trun",a,b);this.m=this.j=this.g=0;this.o=[];this.sampleSize=[];this.A=[];this.h=[]}a(){let a=4;this.flags&zG&&(a+=4);this.flags&AG&&(a+=4);for(let b=0;b<this.g;b++)this.flags&BG&&(a+=4),this.flags&CG&&(a+=4),this.flags&DG&&(a+=4),this.flags&EG&&(a+=4);return a+super.a()}write(a){super.write(a);_.L(a,
50
+ this.g);this.flags&zG&&(a.getPosition(),QE(a,this.j));this.flags&AG&&_.L(a,this.m);for(let b=0;b<this.g;b++)this.flags&BG&&_.L(a,this.o[b]),this.flags&CG&&_.L(a,this.sampleSize[b]),this.flags&DG&&_.L(a,this.A[b]),this.flags&EG&&(0===this.version?_.L(a,this.h[b]):QE(a,this.h[b]));a.getPosition()}},zG=1,AG=4,BG=256,CG=512,DG=1024,EG=2048,RF=class extends vG{constructor(a,b){super("tfhd",a,b);this.g=255;this.m=this.o=this.j=this.A=this.h=0}a(){let a=4;this.flags&FG&&(a+=8);this.flags&GG&&(a+=4);this.flags&
51
+ HG&&(a+=4);this.flags&IG&&(a+=4);this.flags&JG&&(a+=4);return a+super.a()}write(a){super.write(a);_.L(a,this.g);this.flags&FG&&ME(a,this.h);this.flags&GG&&_.L(a,this.A);this.flags&HG&&_.L(a,this.j);this.flags&IG&&_.L(a,this.o);this.flags&JG&&_.L(a,this.m);a.getPosition()}},FG=1,GG=2,HG=8,IG=16,JG=32,XF=class extends gF{constructor(){super("traf")}},YF=class extends gF{constructor(){super("moof")}},WF=class extends gF{constructor(){super(_.pd);this.g=new Uint8Array(0)}a(){return this.g.byteLength+
52
+ super.a()}write(a){super.write(a);0<this.g.byteLength&&_.oj(a,this.g)}},jF=class extends vG{constructor(){super("tenc",0,0);this.g=1;this.h=8;this.m="";this.j=[]}a(){let a;a=20;1===this.g&&0===this.h&&(a=a+1+this.j.length);return a+super.a()}write(a){super.write(a);NE(a,0);0===this.version?NE(a,0):NE(a,0);NE(a,this.g);NE(a,this.h);_.oj(a,_.$i(this.m));if(1===this.g&&0===this.h){NE(a,0);for(let b=0;b<this.j.length;b++)NE(a,this.j[b])}a.getPosition()}},lF=class extends vG{constructor(a,b){super("schm",
53
+ 0,0);this.g=a;this.h=b;this.vb=""}a(){let a=8;this.flags&1&&(a+=SE(this.vb).byteLength);return a+super.a()}write(a){super.write(a);_.oj(a,SE(this.g));_.L(a,this.h);this.flags&1&&_.oj(a,SE(this.vb));a.getPosition()}},kF=class extends gF{constructor(a){super("frma");this.g=a}a(){return SE(this.g).byteLength+super.a()}write(a){super.write(a);_.oj(a,SE(this.g));a.getPosition()}},bG=class extends vG{constructor(){super("saio",0,0);this.offset=[0]}a(){let a=0;this.flags&1&&(a+=8);a+=4;for(let b=0;1>b;b++)a=
54
+ 0===this.version?a+4:a+8;return a+super.a()}write(a){super.write(a);this.flags&1&&(_.L(a,0),_.L(a,0));_.L(a,1);for(let b=0;1>b;b++)0===this.version?_.L(a,this.offset[b]):ME(a,this.offset[b]);a.getPosition()}},cG=class extends vG{constructor(a,b,c){super("saiz",0,0);this.g=a;this.j=b;this.h=c}a(){let a=0;this.flags&1&&(a+=8);a+=5;0===this.g&&(a+=this.j.length);return a+super.a()}write(a){super.write(a);this.flags&1&&(_.L(a,0),_.L(a,0));NE(a,this.g);_.L(a,this.h);if(0===this.g)for(let b=0;b<this.h;b++)NE(a,
55
+ this.j[b]);a.getPosition()}},VF=class extends vG{constructor(a,b){super("senc",a,b);this.h=0;this.j=8;this.g=[]}a(){let a=4;this.flags&1&&(a+=1);for(let b=0;b<this.h;b++)if(a+=this.g[b].qe.byteLength,this.flags&2){a+=2;for(let c=0;c<this.g[b].rc;c++)a+=2,a+=4}return a+super.a()}write(a){super.write(a);_.L(a,this.h);this.flags&1&&NE(a,this.j);for(let b=0;b<this.h;b++)if(_.oj(a,this.g[b].qe),this.flags&2){PE(a,this.g[b].rc);for(let c=0;c<this.g[b].rc;c++)PE(a,this.g[b].Wd[c].ge),_.L(a,this.g[b].Wd[c].he)}a.getPosition()}};var $F=class{constructor(a,b,c,d){this.frameRate=Number(a)||30;this.f=Number(b)||1;this.a=Number(d);0==this.a&&(this.a=a?this.frameRate*this.f:1);c&&(a=/^(\d+) (\d+)$/g.exec(c))&&(this.frameRate*=parseInt(a[1],10)/parseInt(a[2],10))}},ZE=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,$E=/^(?:(\d{2,}):)?(\d{2}):(\d{2})$/,aF=/^(?:(\d{2,}):)?(\d{2}):(\d{2}\.\d{2,})$/,bF=/^(\d*\.?\d*)f$/,cF=/^(\d*\.?\d*)t$/,dF=/^(?:(\d*\.?\d*)h)?(?:(\d*\.?\d*)m)?(?:(\d*\.?\d*)s)?(?:(\d*\.?\d*)ms)?$/;var OF=class{constructor(a){this.a=a;this.f=fF(this)}get(a){for(let b=0;b<this.a.length;b++){const c=this.a[b].get(a);if(c)return c}return null}write(){this.f=fF(this);for(let a=0;a<this.a.length;a++)this.a[a].write(this.f);return this.f.buffer}};var UF=new Uint8Array([162,57,79,82,90,155,79,20,162,68,108,66,124,100,141,244]);var KG=class{constructor(){this.A=this.j=this.h=this.g=null;this.N=1;this.W=0;this.o="";this.B=this.a=null;this.f=new _.O("clpp.smooth.SmoothParser");this.K=!1;this.m=this.C=null;this.R=lG;this.H=0;this.F=this.I=Infinity;this.w=[];this.M=this.V.bind(this)}configure(a){this.h=a}start(a,b){this.g=b;a=[...new Set([a,TE(a)])];return hG(this,a).then(c=>pG(this,c.data).then(()=>{qG(this,this.C);return this.j}))}stop(){this.g&&this.g.networkingEngine.Pd(this.M);this.C=this.A=this.j=this.h=this.g=null;this.m&&
56
+ (clearTimeout(this.m),this.m=null);this.K=!1;this.I=this.F=Infinity;return Promise.resolve()}update(){if(this.D())return hG(this,[this.o]).then(a=>pG(this,a.data).then(()=>this.j)).catch(a=>{if(this.g)this.g.onError(a)})}onExpirationUpdated(){}setCurrentVariant(){}U(){this.f.debug(_.Gt);this.g&&(this.m=null,this.update().then(()=>{qG(this,this.C)}).catch(a=>{this.g&&(this.g.onError(a),1===a.severity&&qG(this,100))}))}D(){return this.R===kG}J(){return 0<this.w.length}S(a){let b=null;if(this.w.length)for(let c=
57
+ 0;c<this.w.length;c++)if(this.w[c].keySystem===a){b=this.w[c].initData[0];break}return b}V(a){if(2!==a.request.type||a.uri.startsWith("data:"))return Promise.resolve(a);const b=a.request.timescale||this.A.timescale,c={isLive:this.D.bind(this),Vc:this.J.bind(this),pf:()=>1,Qc:this.S.bind(this)};let d=!1;const e=new _.H(_.F,3,4035,null);let f=null;try{f=dG(a,b,c)}catch(g){d=!0,e.data=g,3E3===g.code&&(e.code=4039)}if(d||!f)return Promise.reject(e);a.data=f;return Promise.resolve(a)}},tG={video:_.He,
58
+ audio:_.bc,text:_.Vb},lG="VOD",kG="LIVE",uG={$f:"caption",ag:_.Vt};_.x("clpp.smooth.SmoothComponent",class extends _.Bp{constructor(){super()}f(){_.Cn.ism=KG;_.An[_.Wb]=KG}a(){_.Yu("ism");_.Zu(_.Wb)}id(){return"smooth"}});};f.call(g, window);
package/cl.thumbnails.js CHANGED
@@ -1,17 +1,17 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Sr="No thumbnail duration or URL specified",Tr="No thumbnail found for position ",Ur="Position is out of range: ",Vr="Thumbnail URL is mandatory",Wr="Wrong gridSize format",Xr="clpp.thumbnails",Zr=function(a,b){b.reduce((c,d)=>{let e=d,f=!1;typeof d===_.wd&&(e=d.step,f=d.preloadWhileBuffering);return c.then(()=>Yr(a,0,e,!!f))},Promise.resolve())},Yr=function(a,b,c,d){if(a.w||b>=a.a.length)return Promise.resolve();const e=b+c;return $r(a,d).then(()=>a.a[b].load()).then(()=>Yr(a,e,
2
- c,d))},$r=function(a,b){return new Promise(c=>{if(b||a.g.getState()!==_.Vk)c();else a.g.one(_.gc,()=>{c()})})},as=function(a){const b=a.f.byteLength;a.a.forEach(c=>{c.offset+c.length<b&&c.a.resolve()})},ds=function(a,b){return bs(a,b).then(c=>new cs(c,b.time,b.duration))},bs=function(a,b){return b.load().then(()=>{const c=_.K(a.f,b.offset,b.length);return"data:image/jpeg;base64,"+_.oi(c)})},es=function(a){a=a.split(/\.|:/).map(parseFloat);let b=0,c;const d={3:.001,2:1,1:60,0:3600};for(c=a.length-
3
- 1;0<=c;c--)b+=a[c]*d[c];return b},fs=function(a,b){let c=null;for(const d of a)d.startTime<=b&&(c=d);return c},gs=function(a,b){const c=a.horizontalTiles||b.horizontalTiles||1,d=a.verticalTiles||b.verticalTiles||1,e=c*d;return{uc:c,Vd:d,je:e,durationPerTile:a.durationPerTile||b.durationPerTile||(a.endTime-a.startTime)/e}},hs=function(a){return a.some(b=>0<b.thumbStreams.length)},is=function(a){if(!a)return null;a=new _.Yi(a);return a.path.match(/.*\.vtt$/i)?"WEBVTT":a.path.match(/.*\.bif$/i)?"BIF":
4
- a.path.match(/.*\.(png|jpg|jpeg)$/i)?"SINGLE":null};var js=class{constructor(){this.log=new _.O(Xr);this.g=null;this.a=[];this.w=!1}init(a,b){this.g=a;a.one(_.Vd,()=>{this.w=!0});a.isLive()||this.m().then(()=>{b&&b.preload&&Zr(this,b.preload)})}};var cs=class{constructor(a,b,c,d=0,e=0,f=0,g=0,h=1,k=1,l=0,m=0,n=new Image){this.time=b;this.src=a;this.duration=c;this.x=d;this.y=e;this.width=f;this.height=g;this.a=n;this.g=h;this.m=k;this.h=l;this.j=m;this.f=null}raw(){return this.a.cloneNode(!1)}element(a,b){let c=this.width,d=this.height;const e=this.width/this.height;void 0!==a&&void 0===b&&(b=0);null!==a&&void 0!==a&&(c=a);null!==b&&void 0!==b&&(d=b);c||(c=Math.ceil(d*e));d||(d=Math.ceil(c/e));a=document.createElement(_.Jc);a.style.width=
5
- c+_.Sd;a.style.height=d+_.Sd;a.style.backgroundColor="#000";a.style.backgroundRepeat="no-repeat";a.style.backgroundImage=`url("${this.src}")`;a.style.backgroundSize=`${Math.ceil(c/this.width*(this.a.naturalWidth||this.a.width))}px ${Math.ceil(d/this.height*(this.a.naturalHeight||this.a.height))}px`;b=this.y/this.height;a.style.backgroundPositionX="-"+this.x/this.width*c+_.Sd;a.style.backgroundPositionY="-"+b*d+_.Sd;return a}load(){this.f||(this.f=new Promise((a,b)=>{const c=()=>{this.width||(this.width=
6
- (this.a.naturalWidth||this.a.width)/this.g);this.height||(this.height=(this.a.naturalHeight||this.a.height)/this.m);this.x||(this.x=this.width*this.h);this.y||(this.y=this.height*this.j)};if(this.a.src&&this.a.complete)c(),a(this);else{var d=null,e=()=>{c();this.a.removeEventListener("load",e);this.a.removeEventListener(_.Tc,d);a(this)};d=()=>{this.a.removeEventListener("load",e);this.a.removeEventListener(_.Tc,d);b()};this.a.addEventListener("load",e);this.a.addEventListener(_.Tc,d);this.a.src=this.src}}));
7
- return this.f}};_.x("clpp.thumbnails.Thumbnail",cs);cs.prototype.load=cs.prototype.load;cs.prototype.element=cs.prototype.element;cs.prototype.raw=cs.prototype.raw;var ks=class extends js{constructor(){super();this.f=null;this.o=this.h=1;this.j=0}init(a,b){if(!b||!b.url)throw new _.G(_.F,7,7100,Vr);if("GRID"===b.mode&&!b.gridSize)throw new _.G(_.F,7,7100,"Grid size is mandatory for GRID mode");if(!b.duration)throw new _.G(_.F,7,7100,"Duration is mandatory");this.f=b;const c=this.f.duration,d=this.f.url;if(!c||!d)throw this.log.error(Sr,c,d),new _.G(_.F,7,7100,Sr);this.j=c;if(this.f.gridSize)try{const e=this.f.gridSize.split(/x/).map(f=>parseInt(f,10)).filter(f=>
8
- 0<f);if(2===e.length)this.h=e[0],this.o=e[1];else throw new _.G(_.F,7,7100,Wr);}catch(e){throw this.log.error("Error during parsing gridSize",e),new _.G(_.F,7,7100,Wr);}super.init(a,b)}get(a){const b=this.g.getDuration();if(void 0===this.f.duration)return Promise.reject("Duration configuration not defined");const c=Math.floor(a/this.f.duration);if(0>a||a>b)return Promise.reject(Ur+a);const d=this.a[c];return d?d.load().then(()=>d):Promise.reject(Tr+a+" at index "+c)}m(){if(0<this.a.length)return Promise.resolve();
9
- var a=this.g.getDuration();const b=this.h*this.o;a=Math.ceil(Math.ceil(a/this.j)/b);const c=this.f.templateKey||"$index$";for(let d=0;d<a;d++){const e=this.f.url.replace(c,String(d+1)),f=new Image;for(let g=0;g<b;g++)this.a.push(new cs(e,this.j*(d*b+g),this.j,0,0,0,0,this.h,this.o,g%this.h,Math.floor(g/this.h),f))}return Promise.resolve()}};var ls=class{constructor(a,b){this.time=a;this.duration=0;this.offset=b;this.length=0;this.a=new _.fk}load(){return this.a}},ns=class{constructor(){this.g=new _.O(Xr);this.f=new ArrayBuffer(0);this.a=[];this.h=new _.fk}init(a,b){if(!b||!b.url)throw new _.G(_.F,7,7100,Vr);b=_.Cg(b.url);b.type=_.Bg;a.getNetworkEngine().fetch(b).O.then(c=>{{var d=c.data;c=_.K(this.f);d=_.K(d);const e=c.byteLength+d.byteLength,f=new ArrayBuffer(e),g=new DataView(f);let h=0;for(let k=0,l=c.byteLength;k<l;k++)g.setUint8(h,
10
- c[k]),h+=1;for(let k=0,l=d.byteLength;k<l;k++)g.setUint8(h,d[k]),h+=1;this.f=f;this.g.info(`Appended ${d.byteLength} bytes.`+`Total data now ${e} bytes.`)}}).then(()=>{{var c=this.f,d=_.K(c),e=String.fromCharCode.apply(null,ms),f=Array.prototype.slice.call(d,0,8);d=64;let h=0;var g=!1;if(e===String.fromCharCode.apply(null,f))for(c=new DataView(c,16,20),c=c.getUint32(0,!0),0===c&&(c=1E3);!g;){h+=1;f=c;e=new DataView(this.f,d);g=e.getUint32(0,!0);f=g*f/1E3;e=e.getUint32(4,!0);e=new ls(f,e);if(f=this.a.length)f=
11
- this.a[f-1],f.length=e.offset-f.offset,f.duration=e.time-f.time;this.a.push(e);d+=8;(g=4294967295===g)&&this.h.resolve();if(1E5<h)throw Error("There was a problem during reading BIF entries");}else throw Error("The file is not a valid BIF format");}}).then(()=>{as(this)}).catch(c=>{this.g.error("Error while loading thumbnail index",c)})}get(a){return 0>a?Promise.reject(Ur+a):this.h.then(()=>{for(let b=0;b<this.a.length;b++){const c=this.a[b];if(a>=c.time&&a<c.time+c.duration)return ds(this,c).then(d=>
12
- d.load().then(()=>d))}return Promise.reject(Tr+a)})}},ms=[137,66,73,70,13,10,26,10];var os=class extends js{constructor(){super();this.f=null}init(a,b){if(!b||!b.url)throw new _.G(_.F,7,7100,Vr);const c=b.url,d=_.Cg(c);d.type=_.Bg;this.f=a.getNetworkEngine().fetch(d).O.then(e=>{if(e=e.data){e=_.mg(e).split(/\n/);for(let m=0;m<e.length;m++){var f=e[m],g=f.split(" --\x3e ");if(2===g.length){f=e[++m];var h=f.indexOf("\x3d");var k=h=0>h?[]:f.substr(h+1).split(/,/).map(parseFloat);h=k[0];const n=k[1],q=k[2];k=k[3];var l=f.indexOf("#");f=0>l?f:f.substr(0,l);f.match(/^http|^\/\//)||(f=
13
- c.substr(0,c.lastIndexOf("/"))+"/"+f);l=es(g[0]);g=es(g[1])-l;this.a.push(new cs(f,l,g,h,n,q,k,0,0))}}}}).catch(e=>{this.log.error("[VTT] Error while loading thumbnail",e)});super.init(a,b)}get(a){return 0>a?Promise.reject(Ur+a):this.f.then(()=>{for(let b=0;b<this.a.length;b++){const c=this.a[b];if(a>=c.time&&a<c.time+c.duration)return c.load().then(()=>c)}return Promise.reject(Tr+a)})}m(){return this.f}};var ps=class extends js{get(a){if(0>a)return this.log.error("Position must be greater than 0 but is "+a),Promise.reject();var b=this.g.getPeriods();b=fs(b,a);if(!b)return this.log.error("Could not find period for specified position",a),Promise.reject();var c=b.thumbStreams.sort(this.f)[0];if(!c)return this.log.error("Could not find thumb stream for specified position",a),Promise.reject();b=c.findSegmentPosition(a-b.startTime);if(null===b||void 0===b)return this.log.error("Could not find segment index for specified position",
14
- a),Promise.reject();var d=c.getSegmentReference(b);if(d){const e=gs(d,c);a=Math.floor((a-d.startTime)/e.durationPerTile);let f;if(0<this.a.length)d=c.findSegmentPosition(0),null!==d&&(f=this.a[(b-d)*e.je+a]);else if((c=d.La())&&0<c.length){let g=0,h=0;d=d.startTime;1<e.je&&(g=a%e.uc,h=Math.floor(a/e.uc),d+=a*e.durationPerTile);f=new cs(c[0],d,e.durationPerTile,void 0,void 0,void 0,void 0,e.uc,e.Vd,g,h)}if(f)return f.load().then(()=>f)}this.log.error("segment reference for specified segment index does not exist",
15
- b);return Promise.reject()}f(a,b){return void 0!==a.bandwidth&&void 0!==b.bandwidth?a.bandwidth-b.bandwidth:0}m(){if(0<this.a.length)return Promise.resolve();var a=this.g.getPeriods();for(const b of a)if(a=b.thumbStreams.sort(this.f)[0]){let c=a.findSegmentPosition(0),d;for(;null!==c&&!_.y(d=a.getSegmentReference(c++));){const e=gs(d,a),f=d.La()[0],g=new Image;let h=d.startTime;for(let k=0;k<e.Vd;++k)for(let l=0;l<e.uc;++l)this.a.push(new cs(f,h,e.durationPerTile,void 0,void 0,void 0,void 0,e.uc,
16
- e.Vd,l,k,g)),h+=e.durationPerTile}}return Promise.resolve()}};var qs=class{constructor(){this.f=new _.O(Xr);this.a=this.l=null}onPlayerCreated(a){this.l=a}onPlayerWillDestroy(){this.l=null}onPlayerWillRelease(){this.a=null}onContentWillLoad(a){var b=a.getConfiguration();if(b.thumbnails){var c=b.thumbnails;c&&(void 0===c.enabled||c.enabled)&&((b=c.mode)||(b=is(c.url||null)),b&&("SINGLE"===b||"GRID"===b?this.a=new ks:"WEBVTT"===b?this.a=new os:"BIF"===b&&(this.a=new ns)),this.a&&(this.f.info("Loading thumbs configuration",c),this.l.one(_.id,()=>{this.f.info("Initialize thumbnails provider");
17
- this.a.init(a,c)})))}else this.a=null}onContentLoaded(a){if(!this.a){var b=a.getConfiguration();b=b&&b.thumbnails;if(!b||void 0===b.enabled||b.enabled){var c=a.getPeriods();hs(c)&&(this.a=new ps,this.a.init(a,b))}}}get(a){return this.a?this.a.get(a):Promise.reject()}id(){return"thumbnails"}};_.x("clpp.thumbnails.ThumbnailsPlugin",qs);qs.prototype.get=qs.prototype.get;qs.Id="thumbnails";_.cm(new class{create(){return new qs}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var xs="No thumbnail duration or URL specified",ys="No thumbnail found for position ",zs="Position is out of range: ",As="Thumbnail URL is mandatory",Bs="Wrong gridSize format",Cs="clpp.thumbnails",Es=function(a,b){b.reduce((c,d)=>{let e=d,f=!1;typeof d===_.Ad&&(e=d.step,f=d.preloadWhileBuffering);return c.then(()=>Ds(a,0,e,!!f))},Promise.resolve())},Ds=function(a,b,c,d){if(a.w||b>=a.a.length)return Promise.resolve();const e=b+c;return Fs(a,d).then(()=>a.a[b].load()).then(()=>Ds(a,e,
2
+ c,d))},Fs=function(a,b){return new Promise(c=>{if(b||a.g.getState()!==_.Dl)c();else a.g.one(_.gc,()=>{c()})})},Gs=function(a){const b=a.f.byteLength;a.a.forEach(c=>{c.offset+c.length<b&&c.se.resolve()})},Js=function(a,b){return Hs(a,b).then(c=>new Is(c,b.time,b.duration))},Hs=function(a,b){return b.load().then(()=>{const c=_.G(a.f,b.offset,b.length);return"data:image/jpeg;base64,"+_.Xi(c)})},Ks=function(a){a=a.split(/\.|:/).map(parseFloat);let b=0,c;const d={3:.001,2:1,1:60,0:3600};for(c=a.length-
3
+ 1;0<=c;c--)b+=a[c]*d[c];return b},Ls=function(a,b){let c=null;for(const d of a)d.startTime<=b&&(c=d);return c},Ms=function(a,b){const c=a.horizontalTiles||b.horizontalTiles||1,d=a.verticalTiles||b.verticalTiles||1,e=c*d;return{yc:c,be:d,pe:e,durationPerTile:a.durationPerTile||b.durationPerTile||(a.endTime-a.startTime)/e}},Ns=function(a){return a.some(b=>0<b.thumbStreams.length)},Os=function(a){if(!a)return null;a=new _.Dj(a);return a.path.match(/.*\.vtt$/i)?"WEBVTT":a.path.match(/.*\.bif$/i)?"BIF":
4
+ a.path.match(/.*\.(png|jpg|jpeg)$/i)?"SINGLE":null};var Ps=class{constructor(){this.log=new _.O(Cs);this.g=null;this.a=[];this.w=!1}init(a,b){this.g=a;a.one(_.Yd,()=>{this.w=!0});a.isLive()||this.m().then(()=>{b&&b.preload&&Es(this,b.preload)})}};var Is=class{constructor(a,b,c,d=0,e=0,f=0,g=0,h=1,k=1,l=0,m=0,n=new Image){this.time=b;this.src=a;this.duration=c;this.x=d;this.y=e;this.width=f;this.height=g;this.fa=n;this.Ze=h;this.Mf=k;this.tf=l;this.uf=m;this.ma=null}raw(){return this.fa.cloneNode(!1)}element(a,b){let c=this.width,d=this.height;const e=this.width/this.height;void 0!==a&&void 0===b&&(b=0);null!==a&&void 0!==a&&(c=a);null!==b&&void 0!==b&&(d=b);c||(c=Math.ceil(d*e));d||(d=Math.ceil(c/e));a=document.createElement(_.Mc);a.style.width=
5
+ c+_.Vd;a.style.height=d+_.Vd;a.style.backgroundColor="#000";a.style.backgroundRepeat="no-repeat";a.style.backgroundImage=`url("${this.src}")`;a.style.backgroundSize=`${Math.ceil(c/this.width*(this.fa.naturalWidth||this.fa.width))}px ${Math.ceil(d/this.height*(this.fa.naturalHeight||this.fa.height))}px`;b=this.y/this.height;a.style.backgroundPositionX="-"+this.x/this.width*c+_.Vd;a.style.backgroundPositionY="-"+b*d+_.Vd;return a}load(){this.ma||(this.ma=new Promise((a,b)=>{const c=()=>{this.width||
6
+ (this.width=(this.fa.naturalWidth||this.fa.width)/this.Ze);this.height||(this.height=(this.fa.naturalHeight||this.fa.height)/this.Mf);this.x||(this.x=this.width*this.tf);this.y||(this.y=this.height*this.uf)};if(this.fa.src&&this.fa.complete)c(),a(this);else{var d=null,e=()=>{c();this.fa.removeEventListener("load",e);this.fa.removeEventListener(_.Wc,d);a(this)};d=()=>{this.fa.removeEventListener("load",e);this.fa.removeEventListener(_.Wc,d);b()};this.fa.addEventListener("load",e);this.fa.addEventListener(_.Wc,
7
+ d);this.fa.src=this.src}}));return this.ma}};_.x("clpp.thumbnails.Thumbnail",Is);Is.prototype.load=Is.prototype.load;Is.prototype.element=Is.prototype.element;Is.prototype.raw=Is.prototype.raw;var Qs=class extends Ps{constructor(){super();this.f=null;this.o=this.h=1;this.j=0}init(a,b){if(!b||!b.url)throw new _.H(_.F,7,7100,As);if("GRID"===b.mode&&!b.gridSize)throw new _.H(_.F,7,7100,"Grid size is mandatory for GRID mode");if(!b.duration)throw new _.H(_.F,7,7100,"Duration is mandatory");this.f=b;const c=this.f.duration,d=this.f.url;if(!c||!d)throw this.log.error(xs,c,d),new _.H(_.F,7,7100,xs);this.j=c;if(this.f.gridSize)try{const e=this.f.gridSize.split(/x/).map(f=>parseInt(f,10)).filter(f=>
8
+ 0<f);if(2===e.length)this.h=e[0],this.o=e[1];else throw new _.H(_.F,7,7100,Bs);}catch(e){throw this.log.error("Error during parsing gridSize",e),new _.H(_.F,7,7100,Bs);}super.init(a,b)}get(a){const b=this.g.getDuration();if(void 0===this.f.duration)return Promise.reject("Duration configuration not defined");const c=Math.floor(a/this.f.duration);if(0>a||a>b)return Promise.reject(zs+a);const d=this.a[c];return d?d.load().then(()=>d):Promise.reject(ys+a+" at index "+c)}m(){if(0<this.a.length)return Promise.resolve();
9
+ var a=this.g.getDuration();const b=this.h*this.o;a=Math.ceil(Math.ceil(a/this.j)/b);const c=this.f.templateKey||"$index$";for(let d=0;d<a;d++){const e=this.f.url.replace(c,String(d+1)),f=new Image;for(let g=0;g<b;g++)this.a.push(new Is(e,this.j*(d*b+g),this.j,0,0,0,0,this.h,this.o,g%this.h,Math.floor(g/this.h),f))}return Promise.resolve()}};var Rs=class{constructor(a,b){this.time=a;this.duration=0;this.offset=b;this.length=0;this.se=new _.Qk}load(){return this.se}},Ts=class{constructor(){this.g=new _.O(Cs);this.f=new ArrayBuffer(0);this.a=[];this.h=new _.Qk}init(a,b){if(!b||!b.url)throw new _.H(_.F,7,7100,As);const c=b.url;b=_.Wg(c);b.type=_.Vg;a.getNetworkEngine().fetch(b).P.then(d=>{{var e=d.data;d=_.G(this.f);e=_.G(e);const f=d.byteLength+e.byteLength,g=new ArrayBuffer(f),h=new DataView(g);let k=0;for(let l=0,m=d.byteLength;l<m;l++)h.setUint8(k,
10
+ d[l]),k+=1;for(let l=0,m=e.byteLength;l<m;l++)h.setUint8(k,e[l]),k+=1;this.f=g;this.g.info(`Appended ${e.byteLength} bytes.`+`Total data now ${f} bytes.`)}}).then(()=>{{var d=this.f,e=_.G(d),f=String.fromCharCode.apply(null,Ss),g=Array.prototype.slice.call(e,0,8);e=64;let k=0;var h=!1;if(f===String.fromCharCode.apply(null,g))for(d=new DataView(d,16,20),d=d.getUint32(0,!0),0===d&&(d=1E3);!h;){k+=1;g=d;f=new DataView(this.f,e);h=f.getUint32(0,!0);g=h*g/1E3;f=f.getUint32(4,!0);f=new Rs(g,f);if(g=this.a.length)g=
11
+ this.a[g-1],g.length=f.offset-g.offset,g.duration=f.time-g.time;this.a.push(f);e+=8;(h=4294967295===h)&&this.h.resolve();if(1E5<k)throw Error("There was a problem during reading BIF entries");}else throw Error("The file is not a valid BIF format");}}).then(()=>{Gs(this)}).catch(d=>{this.g.error(`[BIF] Error while loading thumbnails '
12
+ + 'URL: ${c}`,d);a.onError(new _.H(1,7,2013,"Error while loading and parsing BIF thumbnails.",d))})}get(a){return 0>a?Promise.reject(zs+a):this.h.then(()=>{for(let b=0;b<this.a.length;b++){const c=this.a[b];if(a>=c.time&&a<c.time+c.duration)return Js(this,c).then(d=>d.load().then(()=>d))}return Promise.reject(ys+a)})}},Ss=[137,66,73,70,13,10,26,10];var Us=class extends Ps{constructor(){super();this.f=null}init(a,b){if(!b||!b.url)throw new _.H(_.F,7,7100,As);const c=b.url,d=_.Wg(c);d.type=_.Vg;this.f=a.getNetworkEngine().fetch(d).P.then(e=>{if(e=e.data){e=_.yg(e).split(/\n/);for(let m=0;m<e.length;m++){var f=e[m],g=f.split(" --\x3e ");if(2===g.length){f=e[++m];var h=f.indexOf("\x3d");var k=h=0>h?[]:f.substr(h+1).split(/,/).map(parseFloat);h=k[0];const n=k[1],q=k[2];k=k[3];var l=f.indexOf("#");f=0>l?f:f.substr(0,l);f.match(/^http|^\/\//)||(f=
13
+ c.substr(0,c.lastIndexOf("/"))+"/"+f);l=Ks(g[0]);g=Ks(g[1])-l;this.a.push(new Is(f,l,g,h,n,q,k,0,0))}}}}).catch(e=>{this.log.error("[VTT] Error while loading thumbnails "+`URL: ${c}`,e);a.onError(new _.H(1,7,2013,"Error while loading VTT thumbnails.",e))});super.init(a,b)}get(a){return 0>a?Promise.reject(zs+a):this.f.then(()=>{for(let b=0;b<this.a.length;b++){const c=this.a[b];if(a>=c.time&&a<c.time+c.duration)return c.load().then(()=>c)}return Promise.reject(ys+a)})}m(){return this.f}};var Vs=class extends Ps{get(a){if(0>a)return this.log.error("Position must be greater than 0 but is "+a),Promise.reject();var b=this.g.getPeriods();b=Ls(b,a);if(!b)return this.log.error("Could not find period for specified position",a),Promise.reject();var c=b.thumbStreams.sort(this.f)[0];if(!c)return this.log.error("Could not find thumb stream for specified position",a),Promise.reject();b=c.findSegmentPosition(a-b.startTime);if(null===b||void 0===b)return this.log.error("Could not find segment index for specified position",
14
+ a),Promise.reject();var d=c.getSegmentReference(b);if(d){const e=Ms(d,c);a=Math.floor((a-d.startTime)/e.durationPerTile);let f;if(0<this.a.length)d=c.findSegmentPosition(0),null!==d&&(f=this.a[(b-d)*e.pe+a]);else if((c=d.Ea())&&0<c.length){let g=0,h=0;d=d.startTime;1<e.pe&&(g=a%e.yc,h=Math.floor(a/e.yc),d+=a*e.durationPerTile);f=new Is(c[0],d,e.durationPerTile,void 0,void 0,void 0,void 0,e.yc,e.be,g,h)}if(f)return f.load().then(()=>f)}this.log.error("segment reference for specified segment index does not exist",
15
+ b);return Promise.reject()}f(a,b){return void 0!==a.bandwidth&&void 0!==b.bandwidth?a.bandwidth-b.bandwidth:0}m(){if(0<this.a.length)return Promise.resolve();var a=this.g.getPeriods();for(const b of a)if(a=b.thumbStreams.sort(this.f)[0]){let c=a.findSegmentPosition(0),d;for(;null!==c&&!_.z(d=a.getSegmentReference(c++));){const e=Ms(d,a),f=d.Ea()[0],g=new Image;let h=d.startTime;for(let k=0;k<e.be;++k)for(let l=0;l<e.yc;++l)this.a.push(new Is(f,h,e.durationPerTile,void 0,void 0,void 0,void 0,e.yc,
16
+ e.be,l,k,g)),h+=e.durationPerTile}}return Promise.resolve()}};var Ws=class{constructor(){this.f=new _.O(Cs);this.a=this.l=null}onPlayerCreated(a){this.l=a}onPlayerWillDestroy(){this.l=null}onPlayerWillRelease(){this.a=null}onContentWillLoad(a){var b=a.getConfiguration();if(b.thumbnails){var c=b.thumbnails;c&&(void 0===c.enabled||c.enabled)&&((b=c.mode)||(b=Os(c.url||null)),b&&("SINGLE"===b||"GRID"===b?this.a=new Qs:"WEBVTT"===b?this.a=new Us:"BIF"===b&&(this.a=new Ts)),this.a&&(this.f.info("Loading thumbs configuration",c),this.l.one(_.nd,()=>{this.f.info("Initialize thumbnails provider");
17
+ this.a.init(a,c)})))}else this.a=null}onContentLoaded(a){if(!this.a){var b=a.getConfiguration();b=b&&b.thumbnails;if(!b||void 0===b.enabled||b.enabled){var c=a.getPeriods();Ns(c)&&(this.a=new Vs,this.a.init(a,b))}}}get(a){return this.a?this.a.get(a):Promise.reject()}id(){return"thumbnails"}};_.x("clpp.thumbnails.ThumbnailsPlugin",Ws);Ws.prototype.get=Ws.prototype.get;Ws.Id="thumbnails";_.Km(new class{create(){return new Ws}});};f.call(g, window);