@castlabs/prestoplay 6.22.0 → 6.23.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 (65) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/cjs/cl.adobe.js +3 -3
  3. package/cjs/cl.airplay.js +3 -3
  4. package/cjs/cl.broadpeak.js +7 -7
  5. package/cjs/cl.cast.js +116 -116
  6. package/cjs/cl.conviva.js +32 -33
  7. package/cjs/cl.core.js +592 -590
  8. package/cjs/cl.crypto.js +9 -9
  9. package/cjs/cl.dash.js +86 -80
  10. package/cjs/cl.externs.js +43 -36
  11. package/cjs/cl.freewheel.js +24 -24
  12. package/cjs/cl.hls.js +71 -70
  13. package/cjs/cl.hlssmpte.js +6 -6
  14. package/cjs/cl.htmlcue.js +30 -29
  15. package/cjs/cl.ima.js +23 -23
  16. package/cjs/cl.mse.js +342 -328
  17. package/cjs/cl.muxdata.js +15 -15
  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.sessions.js +16 -16
  22. package/cjs/cl.simid.js +15 -15
  23. package/cjs/cl.smooth.js +72 -72
  24. package/cjs/cl.thumbnails.js +26 -26
  25. package/cjs/cl.tizen.js +72 -72
  26. package/cjs/cl.ttml.js +29 -29
  27. package/cjs/cl.verimatrix.js +5 -5
  28. package/cjs/cl.vimond.js +12 -13
  29. package/cjs/cl.vr.js +19 -19
  30. package/cjs/cl.vtt.js +14 -14
  31. package/cjs/cl.yospace.js +4 -4
  32. package/cjs/cl.youbora.js +37 -37
  33. package/cl.adobe.js +3 -3
  34. package/cl.airplay.js +3 -3
  35. package/cl.broadpeak.js +5 -5
  36. package/cl.cast.js +86 -86
  37. package/cl.conviva.js +27 -27
  38. package/cl.core.js +474 -472
  39. package/cl.crypto.js +9 -9
  40. package/cl.dash.js +80 -75
  41. package/cl.externs.js +43 -36
  42. package/cl.freewheel.js +19 -19
  43. package/cl.hls.js +74 -74
  44. package/cl.hlssmpte.js +5 -5
  45. package/cl.htmlcue.js +26 -26
  46. package/cl.ima.js +16 -16
  47. package/cl.mse.js +303 -290
  48. package/cl.muxdata.js +13 -13
  49. package/cl.onboard.js +4 -4
  50. package/cl.persistent.js +10 -10
  51. package/cl.playlist.js +5 -5
  52. package/cl.sessions.js +10 -10
  53. package/cl.simid.js +13 -13
  54. package/cl.smooth.js +59 -59
  55. package/cl.thumbnails.js +19 -19
  56. package/cl.tizen.js +57 -57
  57. package/cl.ttml.js +22 -22
  58. package/cl.verimatrix.js +4 -4
  59. package/cl.vimond.js +8 -8
  60. package/cl.vr.js +15 -15
  61. package/cl.vtt.js +12 -12
  62. package/cl.yospace.js +3 -3
  63. package/cl.youbora.js +27 -26
  64. package/package.json +1 -1
  65. package/typings.d.ts +53 -6
package/cl.tizen.js CHANGED
@@ -1,57 +1,57 @@
1
- import {clpp} from "./cl.core.js";import './cl.mse.js';let g={};const _ = clpp._;var f=function(window){'use strict';var FO="An unknown error occurred while trying to get volume",GO="Cannot get loading rendition due to platform limitations",HO="SecurityError",IO="The require privilege is: http://tizen.org/privilege/tv.audio",JO="|STARTBITRATE\x3d",KO=function(a,b,c){const d=e=>{c.call(a,e);a.removeEventListener(b,d)};a.addEventListener(b,d)},NO=function(a){return _.x(function*(){if(a.a!==_.zd&&a.a!==_.xd)throw new _.I(_.F,6,6001,`The key system ${a.a} is not supported by `+"the player or the platform");
2
- const b=a.f.get(a.a);if(!b.hd)throw new _.I(_.F,6,6012,`No license server given for ${a.a}`);try{a.a===_.zd?yield LO(a):yield MO(a,b),a.o={keySystem:a.a,licenseServerUri:b.hd,distinctiveIdentifierRequired:!1,persistentStateRequired:b.Ae,audioRobustness:"",videoRobustness:"",serverCertificate:null,initData:[],keyIds:[],periodId:null}}catch(c){throw a.g.error(`Error while configuring CDM for ${a.a}`,c),new _.I(_.F,6,6005,{message:JSON.stringify(c)});}})},PO=function(a,b){_.x(function*(){var c=a.f.get(a.a);
3
- a.g.debug("DRM Challenge data: ",b.challenge);const d=atob(b.challenge);var e=new Uint8Array(d.length);for(let h=0;h<d.length;++h)e[h]=d.charCodeAt(h);c=_.pj([b.serverurl&&""!==b.serverurl?b.serverurl:c.hd],_.lj());c.type=3;c.body=e.buffer;c.method=_.tb;try{var f=yield a.D.Jb.fetch(c).W;if(a.j){var g=_.K(f.data);const h=g.byteLength;e="";for(f=0;f<h;f++)e+=String.fromCharCode(g[f]);const k=`${b.session_id}PARAM_START_POSITION`+`${btoa(e)}PARAM_START_POSITION`;a.g.debug("Widevine license params",k);
4
- try{webapis.avplay.setDrm(OO,"widevine_license_data",k)}catch(l){a.g.error("License response rejected by CDM");const m=new _.I(_.F,6,6008,{browserError:JSON.stringify(l)});a.D.onError(m)}}}catch(h){a.g.error("License request failed.",JSON.stringify(h)),g=new _.I(_.F,6,6007,{message:_.Ra,url:h.data.url,status:h.data.status||NaN,response:h.data.response||"",headers:h.data.headers||{}},h),a.D.onError(g)}})},LO=function(a){return _.x(function*(){try{webapis.avplay.setDrm(OO,"Initialize",""),webapis.avplay.setDrm(OO,
5
- "widevine_app_session",a.l.id),webapis.avplay.setDrm(OO,"widevine_data_type",a.l.type)}catch(b){throw b;}})},MO=function(a,b){return _.x(function*(){var c={};c[QO]=!b.Ae;c[RO]=b.hd;""!==b.customData&&(c[SO]=b.customData);c=JSON.stringify(c);a.g.debug("PlayReady properties: ",c);try{webapis.avplay.setDrm(TO,"SetProperties",c)}catch(d){throw d;}})},VO=function(a,b){if(a.f!==b)if(a.f===_.Bo&&b!==_.Co)a.g.debug(_.mB+`${UO(b)}`);else{var c=(new Date).getTime();a.j=a.f;a.f=b;a.f===_.xo?(a.o=(new Date).getTime(),
6
- a.m.trigger(new _.E(_.Uc,{detail:{bufferedTimeMS:-1,reason:a.h}}))):a.j===_.xo&&a.m.trigger(new _.E(_.Sc,{detail:{bufferedTimeMS:c-a.o,reason:a.h}}));b={currentState:a.f,previousState:a.j,timeSinceLastStateChangeMS:c-a.w};a.w=c;a.m.trigger(new _.E(_.Pf,{detail:b}));a.g.debug("State changed:",UO(a.j),"-\x3e",UO(a.f))}},UO=function(a){return Object.keys(_.Ao)[a]},YO=function(a){if(a.l){var b=a.a.getState(),c=a.f;switch(b){case WO:c=_.Fo;break;case XO:c=_.Eo;break;default:a.m.isEnded()?c=_.uo:a.g.debug("Inconsistent AVPlay playback state:",
7
- b)}VO(a,c)}},ZO=function(a){return _.x(function*(){const b=a.m.getConfiguration();let c;(c=yield _.vs(a.B.url,a.m.getNetworkEngine(),b.manifest.attemptParameters,a.B.type||null))&&c.configure(b.manifest);return c})},$O=function(a){if(!a)return!1;a=a.periods;let b=!1;for(let c=0;c<a.length;c++)b=b||0<a[c].textStreams.length;return b},aP=function(a){const b=document.createElement(_.w),c=new _.gI,d=new _.nH,e=a.m.getTextDisplayer();return new _.iI(b,c,e,d,a.m.getConfiguration())},bP=function(a){const b=
8
- {configuration:{},Mb:()=>a.m.getPosition(),$:a.h,Jb:a.m.getNetworkEngine(),yc:null,ue:a.G.bind(a),te:a.F.bind(a),onError:a.T.bind(a),Sf:()=>{},onEvent:()=>{},Wf:a.H.bind(a),Od:()=>{},Uc:()=>new _.bJ,Zd:()=>!1,Sc:null};return new _.CI(a.a,b)},cP=function(a){const b=a.m.getPosition();let c=null;for(const d of a.a.periods)d.startTime<=b&&(c=d);return c},dP=function(a){a.g.debug("getTextStreams()",a.a);if(a.a){var b=[],c=a.a.periods;a.g.debug("getting text streams");for(var d=0;d<c.length;d++)if(a.g.debug(c[d].startTime,
9
- a.m.getPosition()),c[d].startTime<=a.m.getPosition()){b=c[d].textStreams;break}a=b}else a=[];b=[];c=0;for(d=0;d<a.length;d++){const e=new _.Lj(String(c++),_.L);e.mimeType=a[d].mimeType;e.language=a[d].language;e.roles=a[d].roles;e.kind=a[d].kind||_.WB;const f=new _.Tj(String(a[d].id),e);f.bandwidth=a[d].bandwidth||null;e.renditions.push(f);b.push(e)}return b},eP=function(a){if(a.h&&!a.h.getTextDisplayer().isTextVisible())return null;if(a.f){const b=_.iG(a.f,_.G);let c=null;if(b){a=dP(a);for(let d=
10
- 0;d<a.length;d++)if(a[d].renditions[0].id===String(b.id)){c=a[d].renditions[0];break}}return c}return null},fP=function(a,b){a.g.debug("Set active track",b);if(b&&(a.o=b.language,a.A=b.roles[0]||"",a.C=b.kind===_.Zd,a.a&&a.f)){a.setTextVisibility(!0);const c=cP(a),d=b.renditions[0];(b=c.textStreams.find(e=>String(e.id)===d.id))?(a.w?(a.g.debug("Switching period defer text selection"),a.l=b):(_.uG(a.f,b,!0,0),a.m.trigger(new _.E(_.ml))),a.o=b.language):a.g.error(_.lB,d.id)}},gP=function(a){const b=
11
- a.la();b&&a.m.trigger(new _.E(_.Qc,{detail:{width:b.width,height:b.height,bandwidth:b.bandwidth,rendition:b}}))},hP=function(a,b){a.m.trigger(new _.E(_.tg,{details:{width:b.width,height:b.height,bandwidth:b.bandwidth,track:b.track,abrSelection:a.a.o}}))},iP=function(a,b){let c=null;try{c=JSON.parse(b)}catch(d){a.g.warn("Couldn't retrieve extra infos from stream."),c=null}return c},jP=function(a,b){a=a.f[_.N]||[];const c=[];for(let d=0;d<a.length;d++)for(let e=0;e<a[d].renditions.length;e++)_.bh(a[d].renditions[e],
12
- b,Object.keys(b))&&c.push(a[d].renditions[e]);return c[0]||null},kP=function(a){const b=a.m.getConfiguration();var c=_.Vh(b.preferredAudioLanguage||[]);const d=a.f[_.M]||[];if(d.length){var e=null;c.some(g=>{e=_.rC(g,d.map(h=>h.language));return!!e});if(e){var f=d.filter(g=>g.language===e);c=f[0];1<f.length&&b.preferredAudioRole&&(f=f.filter(g=>0<=g.roles.indexOf(b.preferredAudioRole)),0<f.length&&(c=f[0]));a.g.debug("Setting audio track with preferred language:",e);a.ya(c)}else a.g.debug("Preferred language(s) not available")}else a.g.debug("Could not set preferred audio language")},
13
- qP=function(a,b){var c=(l,m)=>{for(let n=0;n<l.length;n++)if(l[n].language===m)return l[n];return null};const d={};if(0>=b.length)return d;var e=b.filter(l=>l.type===lP),f=b.filter(l=>l.type===mP);const g=[];for(var h=0;h<f.length;h++){const l=iP(a,f[h].extra_info);if(l){var k=_.xi(l.language||_.cg);k=_.Hj(k);k=c(g,k);k||(k=new _.Lj(String(a.o++),_.M),g.push(k));k.renditions.push(nP(f[h].index,l,k))}else a.g.warn("Skipping audio stream with no extra info")}c=new _.Lj(String(a.o++),_.N);for(f=0;f<
14
- e.length;f++)(h=iP(a,e[f].extra_info))?c.renditions.push(oP(e[f].index,h,c)):a.g.warn("Skipping video stream with no extra info");e=[];e=a.h?dP(a.h):pP(a,b);d[_.N]=[c];d[_.M]=g;d[_.L]=e;return d},tP=function(a,b){if(b===_.L&&a.h)return eP(a.h);var c=rP(a.a)||[];if(0===c.length)return null;c=c.filter(e=>e.type===b.toUpperCase())[0];var d=null;b===_.N&&(d=iP(a,c.extra_info),d=jP(a,{width:d.Width,height:d.Height}));b===_.M&&(c?(d=sP(a,c,_.M),a.j=d):d=a.j);b===_.L&&(c?(d=sP(a,c,_.L),a.l=d):d=a.l);return d},
15
- wP=function(a,b){if(b){const c=b.track.type.toUpperCase();uP(a.a,c,Number(b.id)).then(()=>{c===mP&&(a.j=b,a.m.trigger(new _.E(_.ll)));c===vP&&(a.l=b,a.m.trigger(new _.E(_.ml)))}).catch(()=>{a.g.error("Could not select "+c+" track.")})}else a.g.debug("Must provide valid rendition")},nP=function(a,b,c){const d=_.xi(b.language||_.cg);c.language=_.Hj(d);c.originalLanguage=d;c.channelsCount=b.channels?Number(b.channels):null;c.mimeType=_.Mc;a=new _.Tj(String(a),c);a.track=c;a.codec=b.fourCC||null;a.bandwidth=
16
- b.bit_rate||null;return a},oP=function(a,b,c){c.mimeType=_.rg;a=new _.Tj(String(a),c);a.track=c;a.width=b.Width||null;a.height=b.Height||null;a.bandwidth=b.Bit_rate?Number(b.Bit_rate):null;a.codec=b.fourCC||null;return a},xP=function(a,b,c){b=_.xi(b.track_lang||_.cg);c.mimeType="text/ttml";c.language=_.Hj(b);c.originalLanguage=b;c.kind=_.WB;return new _.Tj(String(a),c)},pP=function(a,b){b=b.filter(d=>d.type===vP);const c=[];for(let d=0;d<b.length;d++){const e=iP(a,b[d].extra_info);if(!e){a.g.warn("Skipping text stream with no extra info");
17
- continue}const f=new _.Lj(String(a.o++),_.L);f.renditions.push(xP(b[d].index,e,f));c.push(f)}return c},sP=function(a,b,c){a=a.f[c]||[];b=String(b.index);c=null;for(let d=0;d<a.length;d++)for(let e=0;e<a[d].renditions.length;e++)if(a[d].renditions[e].id===b){c=a[d].renditions[e];break}return c},yP=function(a){return a.f&&a.a?a.a.Wh:webapis.avplay.getTotalTrackInfo()},AP=function(a,b,c){a.g.debug("switchVideoTrack()");try{const d={estimatedBandwidth:parseInt(webapis.avplay.getStreamingProperty("CURRENT_BANDWITH"),
18
- 10),currentBandwidth:b,nextBandwidth:c,currentPosition:a.getPosition()};a.a=zP(a);a.f=!0;webapis.avplay.stop();webapis.avplay.close();return a.load(a.m.getConfiguration(),d).then(()=>{const e=a.a.jf;a.f=!1;a.a=null;return e===XO?a.pause():a.play()})}catch(d){return Promise.reject(d)}},BP=function(a,b){var c=a.m.getTextDisplayer();c&&c.setTextVisibility(b);c=a.m.h;try{c||webapis.avplay.setSilentSubtitle(!b)}catch(d){a.g.debug("Could not set text track visibility",d)}},uP=function(a,b,c){b=b.toUpperCase();
19
- b===vP&&BP(a,!0);const d=a.j[b];d&&(d.Td.stop(),a.j[b]=null,a.g.debug(`Cancelled pending track switch for ${b}`));return new Promise((e,f)=>{const g=(h,k,l)=>{l=void 0===l?!1:l;try{webapis.avplay.setSelectTrack(h,k),a.j[h]=null,e()}catch(m){a.g.debug(`Could not set ${h} track. Trying again...`+`AVPlay state: ${a.getState()}, `+`buffering: ${a.w}`,m),!1===l&&(a.j[h]={type:h,index:k,ff:0,Td:new _.vk(()=>g(h,c,!0))}),(k=a.j[h])&&3>k.ff?(!a.w&&++k.ff,k.Td.fa(a.w?.5:.25)):(a.g.debug("Could not set track after multiple attempts.Giving up..."),
20
- k&&k.Td.stop(),a.j[h]=null,f())}};g(b,c)})},rP=function(a){return a.f&&a.a?a.a.Jg:webapis.avplay.getCurrentStreamInfo()},CP=function(a){return _.x(function*(){tizen.systeminfo.getPropertyValue("DISPLAY",b=>{a.A=b.resolutionWidth/1920;a.g.debug("Display resolution ratio: ",a.A)},b=>{a.g.debug("Could not load DISPLAY property");throw b;})})},EP=function(a){try{webapis.avplay.setListener({onbufferingstart:a.I.bind(a),onbufferingprogress:a.H.bind(a),onbufferingcomplete:a.G.bind(a),onstreamcompleted:a.L.bind(a),
21
- oncurrentplaytime:b=>{a.trigger(new _.E(DP,{currentTime:b}))},onevent:a.K.bind(a),onsubtitlechange:a.M.bind(a),ondrmevent:a.J.bind(a),onerror:a.T.bind(a)})}catch(b){a.g.error(b)}},FP=function(a){const b=!!a.m.getTrackManager().Sa();try{webapis.avplay.setSilentSubtitle(!b)}catch(c){a.g.debug("Could not set AVPlay subtitle config",c)}},GP=function(a,b){try{const c=b.estimatedBandwidth||0,d=b.currentBandwidth||0;a.g.debug({estimatedBandwidth:c,ki:d});0!==c&&0!==d&&c>=1.15*d&&webapis.avplay.setStreamingProperty("ADAPTIVE_INFO",
22
- JO+d)}catch(c){a.g.debug(c)}},HP=function(a,b){try{webapis.avplay.setStreamingProperty("ADAPTIVE_INFO","|BITRATES\x3d"+b+JO+b)}catch(c){throw a.g.debug("Could not set fixed bandwidth",c),c;}},IP=function(a){let b=null;try{b=tizen.tvaudiocontrol.isMute()}catch(c){switch(c.name){case HO:a.g.warn("The application doesn't have the privilege to get the mute state.",IO);break;default:a.g.warn(FO,c)}}return!!b},zP=function(a){return{position:a.getPosition(),state:a.m.getState(),jf:a.getState(),playbackRate:a.getPlaybackRate(),
23
- isLive:a.isLive(),duration:a.getDuration(),isMuted:IP(a),volume:a.getVolume(),Wh:yP(a),Jg:rP(a)}},JP=function(){return new Promise((a,b)=>{if(window.webapis)a();else{const c=document.createElement("script");KO(c,_.ne,d=>a(d));KO(c,_.r,d=>b(d));c.src="$WEBAPIS/webapis/webapis.js";document.querySelector("head").appendChild(c)}})},KP=function(a){return _.x(function*(){yield JP();const b=new Promise(c=>{(new _.vk(c)).fa(5)});if(!(yield Promise.race([CP(a).then(()=>!0),b.then(()=>!1)])))return a.g.debug("Took to long for the SDK to be ready"),
24
- Promise.reject("SDK Timeout")})},LP=function(a){return _.x(function*(){a.g.debug("avplay.prepare()");return new Promise((b,c)=>{try{webapis.avplay.prepareAsync(()=>{a.g.debug("AVPlay is ready!");FP(a);b()},d=>{a.g.debug("prepareAsync failed",d);c(d)})}catch(d){a.g.debug("Failed to prepare media player for playback"),c(d)}})})},MP=function(a,b){try{tizen.tvaudiocontrol.setMute(b)}catch(c){switch(c.name){case HO:a.g.warn("The application does not have the privilege to set mute.",IO);break;default:a.g.warn(FO,
25
- c)}}},RP=function(a,b,c){return _.x(function*(){a.l=_.Io(b);const d=a.F,e=c||{estimatedBandwidth:0,currentBandwidth:0,nextBandwidth:null,currentPosition:0};a.g.debug(`Loading manifest URL: ${a.l[d].url}`);let f=b.startTime||void 0;a.f&&(a.trigger(new _.E(NP)),f=c.currentPosition);try{let g=a.l[d].url;if(a.l[d].type===_.Cc&&!g.includes(".mpd")){const h=new URL(g);h.searchParams.append("cl-ext",".mpd");g=h.toString()}webapis.avplay.open(g);e.nextBandwidth?(HP(a,e.nextBandwidth),a.o=!1):(a.o||GP(a,e),
26
- a.o=!0);EP(a);if(b.drm&&b.drm.env){const h={onError:k=>a.m.onError(k),Jb:a.m.getNetworkEngine()};a.h=new OP(b.drm,h);yield a.h.init()}else a.g.debug("No DRM configuration was provided. Assuming clear content");a.f||a.trigger(new _.E(PP));yield LP(a);a.f||a.trigger(new _.E(QP));f&&typeof f===_.t&&0<f&&a.seek(f).catch(h=>{a.g.debug("Couldn't set start position",h)});a.f||(b.volume&&a.setVolume(b.volume),b.muted&&MP(a,b.muted),b.autoplay&&a.m.play().catch(h=>{a.g.debug("Autoplay failed",h)}))}catch(g){throw a.g.debug("Error while attempting to load source."),
27
- g;}})},SP=function(a){if("NONE"!==a.a.getState()){var b=a.j.getBoundingClientRect();{a=a.a;const c=Math.floor(b.left*a.A),d=Math.floor(b.top*a.A),e=Math.floor(b.width*a.A);b=Math.floor(b.height*a.A);a.g.debug("Setting display area to","x:",c,"y:",d,"width:",e,"height:",b);webapis.avplay.setDisplayRect(c,d,e,b);0===c&&0===d&&1920===e&&1080===b&&webapis.avplay.setDisplayMethod("PLAYER_DISPLAY_MODE_LETTER_BOX")}}else a.g.debug("Could not apply dimension. Player state "+a.a.getState())},OP=class{constructor(a,
28
- b){this.h=a;this.o=null;this.a=_.Fe;this.l=null;this.j=!1;this.f=new Map;this.D=b;this.g=new _.S("clpp.tizen.DrmEngine")}init(){const a=this;return _.x(function*(){var b=_.Pl[a.h.env]||null;if(!b)throw a.g.debug(_.ta,_.yb+a.h.env+_.aa),new _.I(_.F,6,6015,`DRM environment '${a.h.env}' is missing.`);a.l={id:String(Math.floor(1E4*Math.random())),type:"MPEG-DASH"};var c=Object.keys(a.h.customData||{}).length?btoa(JSON.stringify(a.h.customData)):"";b=_.Rl(b,a.h.customData);const d=b[_.xd];d&&a.f.set(_.xd,
29
- {hd:d.licenseUrl||"",customData:c,Ae:!1});(b=b[_.zd])&&a.f.set(_.zd,{hd:b.licenseUrl||"",customData:c,Ae:!1});if(0===a.f.size)throw new _.I(_.F,6,6E3);if((c=a.h.preferredDrmSystem)&&a.f.get(c))a.a=c;else if(a.f.get(_.xd))a.a=_.xd;else if(a.f.get(_.zd))a.a=_.zd;else throw new _.I(_.F,6,6001,"Configuration for the target system is missing.");yield NO(a);a.j=!0})}release(){const a=this;return _.x(function*(){a.j=!1;a.o=null;a.a=_.Fe;a.l=null;a.f=new Map})}getDrmInfo(){return this.o}},QO="DeleteLicenseAfterUse",
30
- RO="LicenseServer",SO="CustomData";var YP=class{constructor(a){this.m=a;this.a=this.m.a;this.f=_.Co;this.j=_.qu;this.w=(new Date).getTime();this.l=!1;this.o=-1;this.h=2;this.g=new _.S("clpp.tizen.StateManager")}initialize(){this.a.on(NP,this.C,this);this.a.on(TP,this.B,this);this.a.on(UP,this.A,this);this.a.on(PP,this.H,this);this.a.on(QP,this.G,this);this.a.on(VP,this.F,this)}release(){VO(this,_.Co);this.l=!1;this.o=-1;this.h=2}destroy(){this.release();this.a.off(NP,this.C);this.a.off(TP,this.B);this.a.off(UP,this.A);this.a.off(PP,
31
- this.H);this.a.off(QP,this.G);this.a.off(VP,this.F);this.m=this.a=null}C(){this.g.debug("Buffering start. Player state: ",this.a.getState());this.h=this.a.B?1:2;VO(this,_.xo)}B(a){this.g.debug("Buffering progress: "+a.percent+" %. Player state: ",UO(this.f))}A(){this.g.debug("Buffering complete. Player state: ",this.a.getState());if(!this.l){this.l=!0;var a=this.m.getConfiguration().autoplay;const b=this.a.getState()===WP;if(!a&&b){VO(this,_.Eo);return}}if(a=this.f!==_.Do)a=this.a.getState(),a=a===
32
- WO||a===XO;a&&YO(this)}H(){this.g.debug("Preparing starts. AVPlay State: ",this.a.getState());this.a.getState()===XP?VO(this,_.Do):this.g.error("AVPlay prepares while state is not IDLE")}G(){this.g.debug("Preparing ends: AVPlay state:",this.a.getState())}F(){VO(this,_.uo)}getState(){return this.f}};var ZP=class{constructor(){this.o=this.A=this.f=this.h=this.B=this.m=this.j=this.a=null;this.C=!1;this.w=!0;this.l=null;this.g=new _.S("clpp.tizen.TextStreamer")}initialize(a){this.m=a}load(a){const b=this;return _.x(function*(){if(b.m)if(b.B=a,b.j=yield ZO(b),b.j){var c={configurationId:"",networkingEngine:b.m.getNetworkEngine(),filterNewPeriod:()=>{},filterAllPeriods:()=>{},onEvent:()=>{},onError:()=>{}};try{b.a=yield b.j.start(a.url,c)}catch(d){b.g.warn(d);try{b.a=yield b.j.start(a.url.replace("https://",
33
- "http://"),c)}catch(e){b.g.error(e),b.a=null}}if(b.a&&$O(b.a)){b.h=aP(b);try{yield b.h.open();b.f=bP(b);const d=b.m.getConfiguration();b.f.h=d.streaming;b.o=d.preferredTextLanguage;b.A=d.preferredTextRole;b.C=d.preferForcedSubtitles}catch(d){b.g.debug("Could not setup media source..."),b.h=null,b.f=null,b.j=null,b.a=null}}}else b.g.debug("Could not find manifest parser for source. Make sure parsers are registered.");else b.g.debug("Text streamer is not initialized. Will not load()")})}G(a){this.g.debug(_.NB,
34
- a);this.w=!0;let b=_.gF(a.textStreams,this.o||"",this.A||"",this.C)[0]||null;this.l&&(a.textStreams.includes(this.l)&&(b=this.l),this.l=null);return{variant:null,text:b}}F(){this.g.debug("canSwitch_");this.w=!1;this.l&&(_.uG(this.f,this.l,!0,0),this.l=null)}T(){this.g.debug("onError_")}H(){this.j&&this.j.update&&this.j.update()}start(){const a=this;return _.x(function*(){if(a.f)try{a.f.start()}catch(b){a.g.error("Error while starting streaming engine",b)}})}setTextVisibility(a){this.g.debug("Set text visibility",
35
- a);this.h&&this.h.getTextDisplayer().setTextVisibility(a)}release(){const a=this;return _.x(function*(){a.m=null;a.a=null;a.B=null;a.A=null;a.o=null;a.w=!0;a.l=null})}destroy(){const a=this;return _.x(function*(){a.j&&(yield a.j.stop(),a.j=null);a.f&&(yield a.f.destroy(),a.f=null,a.w=!0);a.h&&(yield a.h.destroy(),a.h=null)})}};var cQ=class extends _.T{constructor(){super();this.h=this.a=this.m=null;this.f={};this.g=new _.S("clpp.tizen.TrackManager");this.w=this.l=this.j=null;this.B=!1;this.o=1}C(a){var b=a.eventid;a=a.data;switch(b){case $P:0<Object.keys(this.f).length||(this.g.debug("Loading track manager!"),this.load());b=webapis.avplay.getCurrentStreamInfo();0<b.length&&(b=+iP(this,b[0].extra_info).Bit_rate,b=jP(this,{bandwidth:b}))&&(this.w=b,hP(this,b));break;case aQ:gP(this);break;default:this.g.debug("Event type: "+
36
- b+" data: "+a)}}A(a){a.detail.currentState===_.Fo&&this.m.off(_.Pf,this.A)}initialize(a){this.m=a;this.a=this.m.a;this.m.on(_.Pf,b=>{this.B||(b=b.detail,b.currentState===_.Fo&&(this.g.debug("Current state",b.currentState),this.B=!0,kP(this)))});this.a.on(bQ,this.C,this)}release(){this.f={};this.h=this.w=this.l=this.j=null;this.B=!1;this.o=1}load(){if(this.a&&!(0<Object.keys(this.f).length)){this.h=this.m.h;this.m.off(_.Pf,this.A);this.m.on(_.Pf,this.A,this);try{const a=yP(this.a);this.f=qP(this,a);
37
- const b=this.f[_.M]||[];b.length&&(this.j=b[0].renditions[0]||null);gP(this)}catch(a){this.g.debug("Could not load track manager")}}}destroy(){this.a.off(bQ,this.C);this.a=this.m=null}getVideoTracks(){return this.f[_.N]||[]}getAudioTracks(){return this.f[_.M]||[]}ka(){return this.f[_.L]||[]}la(){return tP(this,_.N)}Za(){return tP(this,_.M)}Sa(){return tP(this,_.L)}pb(){return this.w}Bb(){this.g.info(GO);return null}Cb(){this.g.info(GO);return null}Ga(){const a=this.la();return a?a.track:null}oa(){const a=
38
- this.Za();return a?a.track:null}wa(){const a=this.Sa();return a?a.track:null}wb(a){null===a?(a=this.la(),AP(this.a,a.bandwidth,null).then(()=>{gP(this)})):0<a.renditions.length&&this.hb(a.renditions[0])}ya(a){a?wP(this,a.renditions[0]):this.g.warn("Cannot disable audio tracks on this platform.","Consider muting audio instead...")}Ua(a){a?(a=a.renditions[0],this.h?fP(this.h,a.track):wP(this,a)):(this.g.debug("Disabling text tracks"),this.l=null,BP(this.a,!1),this.m.trigger(new _.E(_.ml)))}hb(a){const b=
39
- this.la();this.a.o||a.width!==b.width||a.height!==b.height||a.bandwidth!==b.bandwidth?(this.w=a,hP(this,a),AP(this.a,b.bandwidth,a.bandwidth).then(()=>{gP(this)}).catch(c=>{const d=new _.I(_.F,7,7200,{tizenerror:c});this.g.debug("Error while switching video track",c);this.m.onError(d)})):this.g.debug("Trying to switch to already active rendition. Doing nothing...")}ub(a){wP(this,a)}vb(a){this.h?fP(this.h,a.track):wP(this,a)}addTextTrack(){}ta(){return this.a.o}};cQ.prototype.isAbrEnabled=cQ.prototype.ta;
40
- cQ.prototype.addTextTrack=cQ.prototype.addTextTrack;cQ.prototype.setTextRendition=cQ.prototype.vb;cQ.prototype.setAudioRendition=cQ.prototype.ub;cQ.prototype.setVideoRendition=cQ.prototype.hb;cQ.prototype.setTextTrack=cQ.prototype.Ua;cQ.prototype.setAudioTrack=cQ.prototype.ya;cQ.prototype.setVideoTrack=cQ.prototype.wb;cQ.prototype.getTextTrack=cQ.prototype.wa;cQ.prototype.getAudioTrack=cQ.prototype.oa;cQ.prototype.getVideoTrack=cQ.prototype.Ga;cQ.prototype.getLoadingTextRendition=cQ.prototype.Cb;
41
- cQ.prototype.getLoadingAudioRendition=cQ.prototype.Bb;cQ.prototype.getLoadingVideoRendition=cQ.prototype.pb;cQ.prototype.getTextRendition=cQ.prototype.Sa;cQ.prototype.getAudioRendition=cQ.prototype.Za;cQ.prototype.getVideoRendition=cQ.prototype.la;cQ.prototype.getTextTracks=cQ.prototype.ka;cQ.prototype.getAudioTracks=cQ.prototype.getAudioTracks;cQ.prototype.getVideoTracks=cQ.prototype.getVideoTracks;var gQ=class extends _.Wt{constructor(a){super();this.m=a;this.h=null;this.g=new _.S("clpp.tizen.Middleware");this.C=1;this.B=!1;this.l=null;this.F=0;this.o=!0;this.f=!1;this.a=null;this.A=1;this.w=!1;this.j={}}I(){this.w=!0;this.f||this.trigger(new _.E(NP))}H(a){this.w=!0;this.trigger(new _.E(TP,{percent:a}))}G(){this.w=!1;this.trigger(new _.E(UP))}L(){this.trigger(new _.E(VP))}K(a,b){this.trigger(new _.E(bQ,{eventid:a,data:b}))}M(a,b,c,d,e){this.trigger(new _.E(dQ,{duration:a,text:b,subtitleType:c,
42
- attriCount:d,attributes:e}))}J(a,b){this.trigger(new _.E(eQ,{drmType:a,drmData:b}));this.h&&(a=this.h,a.j&&(a.a===_.zd&&"Challenge"===b.name?PO(a,b):"DrmError"===b.name&&(a.g.debug("DrmError event",b),b=new _.I(_.F,6,6005,{message:JSON.stringify(b)}),a.D.onError(b))))}T(a){this.trigger(new _.E(fQ,{eventType:a}))}play(){const a=this.getState(),b=()=>new Promise((c,d)=>{let e=null;const f=()=>{c();clearTimeout(e)};this.one(DP,f,this);e=setTimeout(()=>{this.off(DP,f);d("Timeout")},3E4)});if(a===XP)return(new Promise((c,
43
- d)=>{webapis.avplay.prepareAsync(()=>{FP(this);c(webapis.avplay.play())},e=>{this.trigger(new _.E(fQ));d(e)})})).then(()=>b());if(a===XO||a===WP)try{return webapis.avplay.play(),b()}catch(c){return Promise.reject(c)}return a===WO?Promise.resolve():Promise.reject("Player is in invalid state")}pause(){try{webapis.avplay.pause()}catch(a){Promise.reject(a)}return this.getState()===XO?Promise.resolve():Promise.reject()}setPlaybackRate(a){const b=this.getState();if(b===WP||b===WO||b===XO){try{webapis.avplay.setSpeed(a),
44
- this.C=a}catch(c){return this.g.debug("Error while trying to set playback rate",c),this.setPlaybackRate(this.C)}return!0}this.g.debug("Cannot set playback rate; AVPlay is in inconsistent state: "+b);return!1}getPlaybackRate(){return this.C}load(a,b){const c=this;return _.x(function*(){c.g.debug("configure()",b||"");try{yield KP(c),yield RP(c,a,b)}catch(d){throw new _.I(_.F,7,7003,null,d);}})}getState(){if(this.f&&this.a)return this.a.jf;try{return webapis.avplay.getState()}catch(a){this.T(JSON.stringify(a))}}seek(a){const b=
45
- 1E3*a;return new Promise((c,d)=>{this.B=!0;this.m.trigger(new _.E(_.ig));webapis.avplay.seekTo(b,()=>{this.B=!1;this.m.trigger(new _.E(_.hg));c()},()=>{this.B=!1;d()})})}getPosition(){if(this.f&&this.a)return this.a.position;try{return webapis.avplay.getCurrentTime()/1E3}catch(a){this.T(JSON.stringify(a))}}getDuration(){if(this.f&&this.a)return this.a.duration;try{return webapis.avplay.getDuration()/1E3}catch(a){this.T(JSON.stringify(a))}}release(){return new Promise((a,b)=>{try{this.h&&(this.h.release(),
46
- this.h=null);webapis.avplay.stop();webapis.avplay.close();for(const c in this.j){const d=this.j[c];d&&d.Td.stop()}this.j={};this.C=1;this.B=!1;this.a=this.l=null;return a()}catch(c){return b(c)}})}getVolume(){let a=null;try{a=tizen.tvaudiocontrol.getVolume()}catch(b){switch(b.name){case HO:this.g.debug("The application does not have the privilege to get the volume.",IO);break;default:this.g.debug(FO,b)}}return a}setVolume(a){try{tizen.tvaudiocontrol.setVolume(Math.max(0,Math.min(100*a,100)))}catch(b){switch(b.name){case "InvalidValueError":this.g.warn("Invalid value passed for setVolume.",
47
- "The passed value value should be in the range of 0 to 1.");break;case HO:this.g.warn("The application does not have the privilege to set the volume.",IO);break;default:this.g.warn("An unknown error occurred while trying to set volume",b)}}}isLive(){if(this.f&&this.a)return this.a.isLive;try{return"1"===webapis.avplay.getStreamingProperty("IS_LIVE")}catch(a){this.T(JSON.stringify(a))}}stop(){try{webapis.avplay.stop()}catch(a){this.g.debug(a)}}getDrmInfo(){this.h&&this.h.getDrmInfo();return null}setSourceIndex(a){this.F=
48
- a}getSourceIndex(){return this.F}getLoadedSource(){return this.l&&this.l[this.getSourceIndex()]}},XP="IDLE",WP="READY",WO="PLAYING",XO="PAUSED",lP=_.Sb,mP="AUDIO",vP="TEXT",aQ="PLAYER_MSG_RESOLUTION_CHANGED",$P="PLAYER_MSG_BITRATE_CHANGE",TO="PLAYREADY",OO="WIDEVINE_CDM";var kQ=class extends _.Wt{constructor(){super();this.a=new gQ(this);this.f=new YP(this);this.configuration=this.B=_.wl();this.w=null;this.g=new _.S("clpp.tizen.Player");this.j=null;this.l=new cQ;this.C=new _.Pq;this.o=this.h=null;this.A=!1}H(){this.g.debug("On Stream completed. Current time: ",this.getPosition());this.trigger(new _.E(_.Xd));this.configuration.loop?this.seek(this.configuration.startTime||0).catch(()=>{this.g.debug("Could not loop playback")}):this.a.stop()}F(a){this.trigger(new _.E(_.Zf,
49
- {currentTime:a.currentTime/1E3}))}I(a){const b=this.a.getPosition(),c=b+a.duration/1E3;let d=a.text||"";this.g.debug("Got subtitles: ",d,"start:",b,"end:",c,a);(d=_.Yi(d))&&this.o.append([new _.rt(b,c,d)],[])}G(a){this.g.debug("DRM event: "+a.drmType+", data: "+a.drmData)}J(){this.A||(this.g.debug("Initial buffering completed..."),this.A=!0)}T(a){this.g.debug(`Error: TYPE: ${a.eventType}`);VO(this.f,_.Bo);a=new _.I(_.F,7,7200,{tizenerror:a.eventType});this.a.release();this.trigger(new _.E(_.r,{detail:a}))}init(a,
50
- b){this.configuration=this.B=b;this.w=a;this.a.on(VP,this.H,this);this.a.on(DP,this.F,this);this.a.on(dQ,this.I,this);this.a.on(eQ,this.G,this);this.a.on(fQ,this.T,this);this.a.on(UP,this.J,this);this.f.initialize();this.l.initialize(this);this.g.debug("Initializing player surface");this.w.hideMediaElement();a=hQ;hQ+=1;a="__clpp_tizen_player_"+a;this.j=_.Zo(_.Ge,{id:a,type:"application/avplayer"});this.w.addElementToContainer(this.j,!0);var c=this.w.getMedia();if(c){a=this.j;{b=[_.Eg,_.be,"position",
51
- _.he,"top"];const e={};c=null!==c.parentElement?window.getComputedStyle(c,null):c.style;if(!b||0===b.length)for(d in b||(b=[]),c)b.push(d);for(const f of b)e[f]=c[f];var d=e}_.ap(a,d);SP(this)}}getSurface(){return this.w}getConfiguration(){return this.configuration}getTimeline(){return null}setupPlaylist(){return Promise.reject(_.pb)}appendLoad(){return Promise.reject(_.pb)}seekWith(){return Promise.reject(_.pb)}setSeekInterceptor(){}setPlaybackSessionId(){}destroy(){const a=this;return _.x(function*(){yield a.release();
52
- a.a.off(VP,a.H);a.a.off(DP,a.F);a.a.off(dQ,a.I);a.a.off(eQ,a.G);a.a.off(fQ,a.T);a.a.off(UP,a.J);a.h&&(yield a.h.destroy(),a.h=null);a.j&&(a.j.parentElement.removeChild(a.j),a.j=null);a.l.destroy();a.f.destroy();a.l=null;a.f=null})}namespace(){return iQ}getPlaybackRate(){return this.a.getPlaybackRate()}setDrmCustomDataModifier(){}setCdnErrorCallback(){}detach(){}setPlaybackRate(a){this.a.setPlaybackRate(a)}getPosition(){return this.getMediaPosition()}getMediaPosition(){return 0<(this.configuration.startTime||
53
- 0)&&!this.A?0:this.f.getState()===_.uo?this.getDuration():this.a.getPosition()||0}seek(a){return typeof a===_.t&&0<=a?(this.isLive()||(a=Math.min(a,this.getDuration())),this.a.seek(a)):Promise.reject()}getPresentationStartTime(){return null}getSeekRange(){return{start:0,end:0}}getVolume(){const a=this.a.getVolume();return typeof a===_.t?a/100:null}setVolume(a){this.a.setVolume(a)}getDuration(){return this.getMediaDuration()}getMediaDuration(){return this.a.getDuration()}getBufferInfo(){this.g.warn(_.oa);
54
- return new _.Vt}getTrackManager(){return this.l}unload(){return this.a.release().then(()=>{this.l.release()})}release(){const a=this;return _.x(function*(){a.h&&(yield a.h.release());a.o&&(yield a.o.destroy(),a.o=null);yield a.a.release();a.l.release();a.f.release();a.A=!1})}load(a){const b=this;return _.x(function*(){b.configuration=_.yl(b.B,a);var c=_.ko(b.configuration,[_.de,"native"]);b.o=c.create(b);c=_.Io(b.configuration)[0];if(b.configuration.tizen&&b.configuration.tizen.sideStreamText){b.h=
55
- new ZP;b.h.initialize(b);try{yield b.h.load(c),b.h.start()}catch(d){b.g.error(d)}}try{yield b.a.load(b.configuration)}catch(d){throw b.onError(d),d;}b.l.load()})}play(){this.trigger(new _.E(_.Ue));SP(this);return this.a.play().then(()=>{YO(this.f)})}pause(){return this.a.pause().then(()=>{YO(this.f)})}getState(){return this.f.getState()}getPeriods(){return[]}onError(a){const b=new _.E(_.r,{detail:a});a.severity===_.F&&(VO(this.f,_.Bo),this.a.release());this.trigger(b);b.defaultPrevented&&(b.a=!0)}getDrmInfo(){return this.a.getDrmInfo()}isEnded(){return this.f.getState()===
56
- _.uo}isPaused(){return this.a.getState()===XO}isMuted(){return IP(this.a)}setMuted(a){MP(this.a,a)}getNetworkEngine(){return this.C}setNetworkEngine(a){this.C=a}setCmsdManager(){}isLive(){return this.a.isLive()}getStats(){return null}setSourceIndex(a){this.a.setSourceIndex(a)}getSourceIndex(){return this.a.getSourceIndex()}getLoadedSource(){return this.a.getLoadedSource()}canPlay(a,b){return(new jQ).canPlay(a,b)}getTimelineCues(){return[]}getCueTimeline(){return null}getTextDisplayer(){return this.o}resetAbr(){}},
57
- iQ="clpp.tizen",hQ=0,jQ=class{a(){return iQ}canPlay(a){a=a.type;const b=!!window.webapis;if((a===_.Cc||a===_.ql||a===_.Hc)&&b){if(_.zk(2))return 2;if(_.zk(3)||_.zk(4)||_.zk(5)||_.zk(6))return _.C("Use of clpp.tizen.TizenComponent is not recommended for Tizen version \x3e\x3d 3."),1}return 0}f(a){return a===_.la}create(){return new kQ}};_.z("clpp.tizen.TizenComponent",class extends _.Iu{f(){_.rh(new jQ)}a(){var a=iQ;a&&_.ph[a]&&(delete _.ph[a],_.qh.info("Removed Player factory: '"+a+"'"))}id(){return"tizen"}});var NP="onbufferingstart",TP="onbufferingprogress",UP="onbufferingcomplete",VP="onstreamcompleted",DP="oncurrentplaytime",bQ="onevent",dQ="onsubtitlechange",eQ="ondrmevent",fQ="onerror",PP="preparingstart",QP="preparingend";};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";import './cl.mse.js';let g={};const _ = clpp._;var f=function(window){'use strict';var jP="An unknown error occurred while trying to get volume",kP="Cannot get loading rendition due to platform limitations",lP="SecurityError",mP="The require privilege is: http://tizen.org/privilege/tv.audio",nP="|STARTBITRATE\x3d",oP=function(a,b,c){const d=e=>{c.call(a,e);a.removeEventListener(b,d)};a.addEventListener(b,d)},rP=function(a){return _.x(function*(){if(a.a!==_.Cd&&a.a!==_.Ad)throw new _.H(_.F,6,6001,`The key system ${a.a} is not supported by `+"the player or the platform");
2
+ const b=a.f.get(a.a);if(!b.ld)throw new _.H(_.F,6,6012,`No license server given for ${a.a}`);try{a.a===_.Cd?yield pP(a):yield qP(a,b),a.o={keySystem:a.a,licenseServerUri:b.ld,distinctiveIdentifierRequired:!1,persistentStateRequired:b.Je,audioRobustness:"",videoRobustness:"",serverCertificate:null,initData:[],keyIds:[],periodId:null}}catch(c){throw a.g.error(`Error while configuring CDM for ${a.a}`,c),new _.H(_.F,6,6005,{message:JSON.stringify(c)});}})},tP=function(a,b){_.x(function*(){var c=a.f.get(a.a);
3
+ a.g.debug("DRM Challenge data: ",b.challenge);const d=atob(b.challenge);var e=new Uint8Array(d.length);for(let h=0;h<d.length;++h)e[h]=d.charCodeAt(h);c=_.xj([b.serverurl&&""!==b.serverurl?b.serverurl:c.ld],_.rj());c.type=3;c.body=e.buffer;c.method=_.rb;try{var f=yield a.D.rb.fetch(c).U;if(a.j){var g=_.K(f.data);const h=g.byteLength;e="";for(f=0;f<h;f++)e+=String.fromCharCode(g[f]);const k=`${b.session_id}PARAM_START_POSITION`+`${btoa(e)}PARAM_START_POSITION`;a.g.debug("Widevine license params",k);
4
+ try{webapis.avplay.setDrm(sP,"widevine_license_data",k)}catch(l){a.g.error("License response rejected by CDM");const m=new _.H(_.F,6,6008,{browserError:JSON.stringify(l)});a.D.onError(m)}}}catch(h){a.g.error("License request failed.",JSON.stringify(h)),g=new _.H(_.F,6,6007,{message:"Error while fetching license!",url:h.data.url,status:h.data.status||NaN,response:h.data.response||"",headers:h.data.headers||{}},h),a.D.onError(g)}})},pP=function(a){return _.x(function*(){try{webapis.avplay.setDrm(sP,
5
+ "Initialize",""),webapis.avplay.setDrm(sP,"widevine_app_session",a.l.id),webapis.avplay.setDrm(sP,"widevine_data_type",a.l.type)}catch(b){throw b;}})},qP=function(a,b){return _.x(function*(){var c={};c[uP]=!b.Je;c[vP]=b.ld;""!==b.customData&&(c[wP]=b.customData);c=JSON.stringify(c);a.g.debug("PlayReady properties: ",c);try{webapis.avplay.setDrm(xP,"SetProperties",c)}catch(d){throw d;}})},zP=function(a,b){if(a.f!==b)if(a.f===_.Ro&&b!==_.Yo)a.g.debug(_.KB+`${yP(b)}`);else{var c=(new Date).getTime();
6
+ a.j=a.f;a.f=b;a.f===_.Uo?(a.o=(new Date).getTime(),a.m.trigger(new _.E(_.Wc,{detail:{bufferedTimeMS:-1,reason:a.h}}))):a.j===_.Uo&&a.m.trigger(new _.E(_.Vc,{detail:{bufferedTimeMS:c-a.o,reason:a.h}}));b={currentState:a.f,previousState:a.j,timeSinceLastStateChangeMS:c-a.w};a.w=c;a.m.trigger(new _.E(_.Sf,{detail:b}));a.g.debug("State changed:",yP(a.j),"-\x3e",yP(a.f))}},yP=function(a){return Object.keys(_.Xo)[a]},CP=function(a){if(a.l){var b=a.a.getState(),c=a.f;switch(b){case AP:c=_.ap;break;case BP:c=
7
+ _.$o;break;default:a.m.isEnded()?c=_.Qo:a.g.debug("Inconsistent AVPlay playback state:",b)}zP(a,c)}},DP=function(a){return _.x(function*(){const b=a.m.getConfiguration();let c;(c=yield _.Js(a.B.url,a.m.getNetworkEngine(),b.manifest.attemptParameters,a.B.type||null))&&c.configure(b.manifest);return c})},EP=function(a){if(!a)return!1;a=a.periods;let b=!1;for(let c=0;c<a.length;c++)b=b||0<a[c].textStreams.length;return b},FP=function(a){const b=document.createElement(_.w),c=new _.OI,d=new _.VH,e=a.m.getTextDisplayer();
8
+ return new _.QI(b,c,e,d,a.m.getConfiguration())},GP=function(a){const b={configuration:{},Mb:()=>a.m.getPosition(),$:a.h,rb:a.m.getNetworkEngine(),Bc:null,De:a.G.bind(a),Ce:a.F.bind(a),onError:a.H.bind(a),$f:()=>{},onEvent:()=>{},dg:a.I.bind(a),Vd:()=>{},Xc:()=>new _.JJ,he:()=>!1,Vc:null};return new _.jJ(a.a,b)},HP=function(a){const b=a.m.getPosition();let c=null;for(const d of a.a.periods)d.startTime<=b&&(c=d);return c},IP=function(a){a.g.debug("getTextStreams()",a.a);if(a.a){var b=[],c=a.a.periods;
9
+ a.g.debug("getting text streams");for(var d=0;d<c.length;d++)if(a.g.debug(c[d].startTime,a.m.getPosition()),c[d].startTime<=a.m.getPosition()){b=c[d].textStreams;break}a=b}else a=[];b=[];c=0;for(d=0;d<a.length;d++){const e=new _.Rj(String(c++),_.L);e.mimeType=a[d].mimeType;e.language=a[d].language;e.roles=a[d].roles;e.kind=a[d].kind||_.uC;const f=new _.Zj(String(a[d].id),e);f.bandwidth=a[d].bandwidth||null;e.renditions.push(f);b.push(e)}return b},JP=function(a){if(a.h&&!a.h.getTextDisplayer().isTextVisible())return null;
10
+ if(a.f){const b=_.PG(a.f,_.G);let c=null;if(b){a=IP(a);for(let d=0;d<a.length;d++)if(a[d].renditions[0].id===String(b.id)){c=a[d].renditions[0];break}}return c}return null},KP=function(a,b){a.g.debug("Set active track",b);if(b&&(a.o=b.language,a.A=b.roles[0]||"",a.C=b.kind===_.de,a.a&&a.f)){a.setTextVisibility(!0);const c=HP(a),d=b.renditions[0];(b=c.textStreams.find(e=>String(e.id)===d.id))?(a.w?(a.g.debug("Switching period defer text selection"),a.l=b):(_.aH(a.f,b,!0,0),a.m.trigger(new _.E(_.tl))),
11
+ a.o=b.language):a.g.error(_.IB,d.id)}},LP=function(a){const b=a.la();b&&a.m.trigger(new _.E(_.Tc,{detail:{width:b.width,height:b.height,bandwidth:b.bandwidth,rendition:b}}))},MP=function(a,b){a.m.trigger(new _.E(_.xg,{details:{width:b.width,height:b.height,bandwidth:b.bandwidth,track:b.track,abrSelection:a.a.o}}))},NP=function(a,b){let c=null;try{c=JSON.parse(b)}catch(d){a.g.warn("Couldn't retrieve extra infos from stream."),c=null}return c},OP=function(a,b){a=a.f[_.N]||[];const c=[];for(let d=0;d<
12
+ a.length;d++)for(let e=0;e<a[d].renditions.length;e++)_.hh(a[d].renditions[e],b,Object.keys(b))&&c.push(a[d].renditions[e]);return c[0]||null},PP=function(a){const b=a.m.getConfiguration();var c=_.ai(b.preferredAudioLanguage||[]);const d=a.f[_.M]||[];if(d.length){var e=null;c.some(g=>{e=_.QC(g,d.map(h=>h.language));return!!e});if(e){var f=d.filter(g=>g.language===e);c=f[0];1<f.length&&b.preferredAudioRole&&(f=f.filter(g=>0<=g.roles.indexOf(b.preferredAudioRole)),0<f.length&&(c=f[0]));a.g.debug("Setting audio track with preferred language:",
13
+ e);a.xa(c)}else a.g.debug("Preferred language(s) not available")}else a.g.debug("Could not set preferred audio language")},VP=function(a,b){var c=(l,m)=>{for(let n=0;n<l.length;n++)if(l[n].language===m)return l[n];return null};const d={};if(0>=b.length)return d;var e=b.filter(l=>l.type===QP),f=b.filter(l=>l.type===RP);const g=[];for(var h=0;h<f.length;h++){const l=NP(a,f[h].extra_info);if(l){var k=_.Di(l.language||_.fg);k=_.Nj(k);k=c(g,k);k||(k=new _.Rj(String(a.h++),_.M),g.push(k));k.renditions.push(SP(f[h].index,
14
+ l,k))}else a.g.warn("Skipping audio stream with no extra info")}c=new _.Rj(String(a.h++),_.N);for(f=0;f<e.length;f++)(h=NP(a,e[f].extra_info))?c.renditions.push(TP(e[f].index,h,c)):a.g.warn("Skipping video stream with no extra info");e=[];e=a.j?IP(a.j):UP(a,b);d[_.N]=[c];d[_.M]=g;d[_.L]=e;return d},YP=function(a,b){if(b===_.L&&a.j)return JP(a.j);var c=WP(a.a)||[];if(0===c.length)return null;c=c.filter(e=>e.type===b.toUpperCase())[0];var d=null;b===_.N&&(d=NP(a,c.extra_info),d=OP(a,{width:d.Width,
15
+ height:d.Height}));b===_.M&&(c?(d=XP(a,c,_.M),a.l=d):d=a.l);b===_.L&&(c?(d=XP(a,c,_.L),a.o=d):d=a.o);return d},aQ=function(a,b){if(b){const c=b.track.type.toUpperCase();ZP(a.a,c,Number(b.id)).then(()=>{c===RP&&(a.l=b,a.m.trigger(new _.E(_.sl)));c===$P&&(a.o=b,a.m.trigger(new _.E(_.tl)))}).catch(()=>{a.g.error("Could not select "+c+" track.")})}else a.g.debug("Must provide valid rendition")},SP=function(a,b,c){const d=_.Di(b.language||_.fg);c.language=_.Nj(d);c.originalLanguage=d;c.channelsCount=b.channels?
16
+ Number(b.channels):null;c.mimeType=_.Pc;a=new _.Zj(String(a),c);a.track=c;a.codec=b.fourCC||null;a.bandwidth=b.bit_rate||null;return a},TP=function(a,b,c){c.mimeType=_.vg;a=new _.Zj(String(a),c);a.track=c;a.width=b.Width||null;a.height=b.Height||null;a.bandwidth=b.Bit_rate?Number(b.Bit_rate):null;a.codec=b.fourCC||null;return a},bQ=function(a,b,c){b=_.Di(b.track_lang||_.fg);c.mimeType="text/ttml";c.language=_.Nj(b);c.originalLanguage=b;c.kind=_.uC;return new _.Zj(String(a),c)},UP=function(a,b){b=
17
+ b.filter(d=>d.type===$P);const c=[];for(let d=0;d<b.length;d++){const e=NP(a,b[d].extra_info);if(!e){a.g.warn("Skipping text stream with no extra info");continue}const f=new _.Rj(String(a.h++),_.L);f.renditions.push(bQ(b[d].index,e,f));c.push(f)}return c},XP=function(a,b,c){a=a.f[c]||[];b=String(b.index);c=null;for(let d=0;d<a.length;d++)for(let e=0;e<a[d].renditions.length;e++)if(a[d].renditions[e].id===b){c=a[d].renditions[e];break}return c},cQ=function(a){return a.f&&a.a?a.a.gi:webapis.avplay.getTotalTrackInfo()},
18
+ eQ=function(a,b,c){a.g.debug("switchVideoTrack()");try{const d={estimatedBandwidth:parseInt(webapis.avplay.getStreamingProperty("CURRENT_BANDWITH"),10),currentBandwidth:b,nextBandwidth:c,currentPosition:a.getPosition()};a.a=dQ(a);a.f=!0;webapis.avplay.stop();webapis.avplay.close();return a.load(a.m.getConfiguration(),d).then(()=>{const e=a.a.tf;a.f=!1;a.a=null;return e===BP?a.pause():a.play()})}catch(d){return Promise.reject(d)}},fQ=function(a,b){var c=a.m.getTextDisplayer();c&&c.setTextVisibility(b);
19
+ c=a.m.h;try{c||webapis.avplay.setSilentSubtitle(!b)}catch(d){a.g.debug("Could not set text track visibility",d)}},ZP=function(a,b,c){b=b.toUpperCase();b===$P&&fQ(a,!0);const d=a.j[b];d&&(d.be.stop(),a.j[b]=null,a.g.debug(`Cancelled pending track switch for ${b}`));return new Promise((e,f)=>{const g=(h,k,l)=>{l=void 0===l?!1:l;try{webapis.avplay.setSelectTrack(h,k),a.j[h]=null,e()}catch(m){a.g.debug(`Could not set ${h} track. Trying again...`+`AVPlay state: ${a.getState()}, `+`buffering: ${a.w}`,m),
20
+ !1===l&&(a.j[h]={type:h,index:k,pf:0,be:new _.Ck(()=>g(h,c,!0))}),(k=a.j[h])&&3>k.pf?(!a.w&&++k.pf,k.be.ga(a.w?.5:.25)):(a.g.debug("Could not set track after multiple attempts.Giving up..."),k&&k.be.stop(),a.j[h]=null,f())}};g(b,c)})},WP=function(a){return a.f&&a.a?a.a.Sg:webapis.avplay.getCurrentStreamInfo()},gQ=function(a){return _.x(function*(){tizen.systeminfo.getPropertyValue("DISPLAY",b=>{a.A=b.resolutionWidth/1920;a.g.debug("Display resolution ratio: ",a.A)},b=>{a.g.debug("Could not load DISPLAY property");
21
+ throw b;})})},iQ=function(a){try{webapis.avplay.setListener({onbufferingstart:a.J.bind(a),onbufferingprogress:a.I.bind(a),onbufferingcomplete:a.H.bind(a),onstreamcompleted:a.M.bind(a),oncurrentplaytime:b=>{a.trigger(new _.E(hQ,{currentTime:b}))},onevent:a.L.bind(a),onsubtitlechange:a.O.bind(a),ondrmevent:a.K.bind(a),onerror:a.B.bind(a)})}catch(b){a.g.error(b)}},jQ=function(a){const b=!!a.m.getTrackManager().Sa();try{webapis.avplay.setSilentSubtitle(!b)}catch(c){a.g.debug("Could not set AVPlay subtitle config",
22
+ c)}},kQ=function(a,b){try{const c=b.estimatedBandwidth||0,d=b.currentBandwidth||0;a.g.debug({estimatedBandwidth:c,yi:d});0!==c&&0!==d&&c>=1.15*d&&webapis.avplay.setStreamingProperty("ADAPTIVE_INFO",nP+d)}catch(c){a.g.debug(c)}},lQ=function(a,b){try{webapis.avplay.setStreamingProperty("ADAPTIVE_INFO","|BITRATES\x3d"+b+nP+b)}catch(c){throw a.g.debug("Could not set fixed bandwidth",c),c;}},mQ=function(a){let b=null;try{b=tizen.tvaudiocontrol.isMute()}catch(c){switch(c.name){case lP:a.g.warn("The application doesn't have the privilege to get the mute state.",
23
+ mP);break;default:a.g.warn(jP,c)}}return!!b},dQ=function(a){return{position:a.getPosition(),state:a.m.getState(),tf:a.getState(),playbackRate:a.getPlaybackRate(),isLive:a.isLive(),duration:a.getDuration(),isMuted:mQ(a),volume:a.getVolume(),gi:cQ(a),Sg:WP(a)}},nQ=function(){return new Promise((a,b)=>{if(window.webapis)a();else{const c=document.createElement("script");oP(c,_.se,d=>a(d));oP(c,_.r,d=>b(d));c.src="$WEBAPIS/webapis/webapis.js";document.querySelector("head").appendChild(c)}})},oQ=function(a){return _.x(function*(){yield nQ();
24
+ const b=new Promise(c=>{(new _.Ck(c)).ga(5)});if(!(yield Promise.race([gQ(a).then(()=>!0),b.then(()=>!1)])))return a.g.debug("Took to long for the SDK to be ready"),Promise.reject("SDK Timeout")})},pQ=function(a){return _.x(function*(){a.g.debug("avplay.prepare()");return new Promise((b,c)=>{try{webapis.avplay.prepareAsync(()=>{a.g.debug("AVPlay is ready!");jQ(a);b()},d=>{a.g.debug("prepareAsync failed",d);c(d)})}catch(d){a.g.debug("Failed to prepare media player for playback"),c(d)}})})},qQ=function(a,
25
+ b){try{tizen.tvaudiocontrol.setMute(b)}catch(c){switch(c.name){case lP:a.g.warn("The application does not have the privilege to set mute.",mP);break;default:a.g.warn(jP,c)}}},vQ=function(a,b,c){return _.x(function*(){a.l=_.dp(b);const d=a.G,e=c||{estimatedBandwidth:0,currentBandwidth:0,nextBandwidth:null,currentPosition:0};a.g.debug(`Loading manifest URL: ${a.l[d].url}`);let f=b.startTime||void 0;a.f&&(a.trigger(new _.E(rQ)),f=c.currentPosition);try{let g=a.l[d].url;if(a.l[d].type===_.Fc&&!g.includes(".mpd")){const h=
26
+ new URL(g);h.searchParams.append("cl-ext",".mpd");g=h.toString()}webapis.avplay.open(g);e.nextBandwidth?(lQ(a,e.nextBandwidth),a.o=!1):(a.o||kQ(a,e),a.o=!0);iQ(a);if(b.drm&&b.drm.env){const h={onError:k=>a.m.onError(k),rb:a.m.getNetworkEngine()};a.h=new sQ(b.drm,h);yield a.h.init()}else a.g.debug("No DRM configuration was provided. Assuming clear content");a.f||a.trigger(new _.E(tQ));yield pQ(a);a.f||a.trigger(new _.E(uQ));f&&typeof f===_.t&&0<f&&a.seek(f).catch(h=>{a.g.debug("Couldn't set start position",
27
+ h)});a.f||(b.volume&&a.setVolume(b.volume),b.muted&&qQ(a,b.muted),b.autoplay&&a.m.play().catch(h=>{a.g.debug("Autoplay failed",h)}))}catch(g){throw a.g.debug("Error while attempting to load source."),g;}})},wQ=function(a){if("NONE"!==a.a.getState()){var b=a.j.getBoundingClientRect();{a=a.a;const c=Math.floor(b.left*a.A),d=Math.floor(b.top*a.A),e=Math.floor(b.width*a.A);b=Math.floor(b.height*a.A);a.g.debug("Setting display area to","x:",c,"y:",d,"width:",e,"height:",b);webapis.avplay.setDisplayRect(c,
28
+ d,e,b);0===c&&0===d&&1920===e&&1080===b&&webapis.avplay.setDisplayMethod("PLAYER_DISPLAY_MODE_LETTER_BOX")}}else a.g.debug("Could not apply dimension. Player state "+a.a.getState())},sQ=class{constructor(a,b){this.h=a;this.o=null;this.a=_.Je;this.l=null;this.j=!1;this.f=new Map;this.D=b;this.g=new _.S("clpp.tizen.DrmEngine")}init(){const a=this;return _.x(function*(){var b=_.Wl[a.h.env]||null;if(!b)throw a.g.debug(_.ua,_.wb+a.h.env+_.aa),new _.H(_.F,6,6015,`DRM environment '${a.h.env}' is missing.`);
29
+ a.l={id:String(Math.floor(1E4*Math.random())),type:"MPEG-DASH"};var c=Object.keys(a.h.customData||{}).length?btoa(JSON.stringify(a.h.customData)):"";b=_.Yl(b,a.h.customData);const d=b[_.Ad];d&&a.f.set(_.Ad,{ld:d.licenseUrl||"",customData:c,Je:!1});(b=b[_.Cd])&&a.f.set(_.Cd,{ld:b.licenseUrl||"",customData:c,Je:!1});if(0===a.f.size)throw new _.H(_.F,6,6E3);if((c=a.h.preferredDrmSystem)&&a.f.get(c))a.a=c;else if(a.f.get(_.Ad))a.a=_.Ad;else if(a.f.get(_.Cd))a.a=_.Cd;else throw new _.H(_.F,6,6001,"Configuration for the target system is missing.");
30
+ yield rP(a);a.j=!0})}release(){const a=this;return _.x(function*(){a.j=!1;a.o=null;a.a=_.Je;a.l=null;a.f=new Map})}getDrmInfo(){return this.o}},uP="DeleteLicenseAfterUse",vP="LicenseServer",wP="CustomData";var CQ=class{constructor(a){this.m=a;this.a=this.m.a;this.f=_.Yo;this.j=_.Yu;this.w=(new Date).getTime();this.l=!1;this.o=-1;this.h=2;this.g=new _.S("clpp.tizen.StateManager")}initialize(){this.a.on(rQ,this.C,this);this.a.on(xQ,this.B,this);this.a.on(yQ,this.A,this);this.a.on(tQ,this.H,this);this.a.on(uQ,this.G,this);this.a.on(zQ,this.F,this)}release(){zP(this,_.Yo);this.l=!1;this.o=-1;this.h=2}destroy(){this.release();this.a.off(rQ,this.C);this.a.off(xQ,this.B);this.a.off(yQ,this.A);this.a.off(tQ,
31
+ this.H);this.a.off(uQ,this.G);this.a.off(zQ,this.F);this.m=this.a=null}C(){this.g.debug("Buffering start. Player state: ",this.a.getState());this.h=this.a.C?1:2;zP(this,_.Uo)}B(a){this.g.debug("Buffering progress: "+a.percent+" %. Player state: ",yP(this.f))}A(){this.g.debug("Buffering complete. Player state: ",this.a.getState());if(!this.l){this.l=!0;var a=this.m.getConfiguration().autoplay;const b=this.a.getState()===AQ;if(!a&&b){zP(this,_.$o);return}}if(a=this.f!==_.Zo)a=this.a.getState(),a=a===
32
+ AP||a===BP;a&&CP(this)}H(){this.g.debug("Preparing starts. AVPlay State: ",this.a.getState());this.a.getState()===BQ?zP(this,_.Zo):this.g.error("AVPlay prepares while state is not IDLE")}G(){this.g.debug("Preparing ends: AVPlay state:",this.a.getState())}F(){zP(this,_.Qo)}getState(){return this.f}};var DQ=class{constructor(){this.o=this.A=this.f=this.h=this.B=this.m=this.j=this.a=null;this.C=!1;this.w=!0;this.l=null;this.g=new _.S("clpp.tizen.TextStreamer")}initialize(a){this.m=a}load(a){const b=this;return _.x(function*(){if(b.m)if(b.B=a,b.j=yield DP(b),b.j){var c={configurationId:"",networkingEngine:b.m.getNetworkEngine(),filterNewPeriod:()=>{},filterAllPeriods:()=>{},onEvent:()=>{},onError:()=>{}};try{b.a=yield b.j.start(a.url,c)}catch(d){b.g.warn(d);try{b.a=yield b.j.start(a.url.replace("https://",
33
+ "http://"),c)}catch(e){b.g.error(e),b.a=null}}if(b.a&&EP(b.a)){b.h=FP(b);try{yield b.h.open();b.f=GP(b);const d=b.m.getConfiguration();b.f.h=d.streaming;b.o=d.preferredTextLanguage;b.A=d.preferredTextRole;b.C=d.preferForcedSubtitles}catch(d){b.g.debug("Could not setup media source..."),b.h=null,b.f=null,b.j=null,b.a=null}}}else b.g.debug("Could not find manifest parser for source. Make sure parsers are registered.");else b.g.debug("Text streamer is not initialized. Will not load()")})}G(a){this.g.debug(_.lC,
34
+ a);this.w=!0;let b=_.NF(a.textStreams,this.o||"",this.A||"",this.C)[0]||null;this.l&&(a.textStreams.includes(this.l)&&(b=this.l),this.l=null);return{variant:null,text:b}}F(){this.g.debug("canSwitch_");this.w=!1;this.l&&(_.aH(this.f,this.l,!0,0),this.l=null)}H(){this.g.debug("onError_")}I(){this.j&&this.j.update&&this.j.update()}start(){const a=this;return _.x(function*(){if(a.f)try{a.f.start()}catch(b){a.g.error("Error while starting streaming engine",b)}})}setTextVisibility(a){this.g.debug("Set text visibility",
35
+ a);this.h&&this.h.getTextDisplayer().setTextVisibility(a)}release(){const a=this;return _.x(function*(){a.m=null;a.a=null;a.B=null;a.A=null;a.o=null;a.w=!0;a.l=null})}destroy(){const a=this;return _.x(function*(){a.j&&(yield a.j.stop(),a.j=null);a.f&&(yield a.f.destroy(),a.f=null,a.w=!0);a.h&&(yield a.h.destroy(),a.h=null)})}};var HQ=class extends _.T{constructor(){super();this.j=this.a=this.m=null;this.f={};this.g=new _.S("clpp.tizen.TrackManager");this.w=this.o=this.l=null;this.B=!1;this.h=1}C(a){var b=a.eventid;a=a.data;switch(b){case EQ:0<Object.keys(this.f).length||(this.g.debug("Loading track manager!"),this.load());b=webapis.avplay.getCurrentStreamInfo();0<b.length&&(b=+NP(this,b[0].extra_info).Bit_rate,b=OP(this,{bandwidth:b}))&&(this.w=b,MP(this,b));break;case FQ:LP(this);break;default:this.g.debug("Event type: "+
36
+ b+" data: "+a)}}A(a){a.detail.currentState===_.ap&&this.m.off(_.Sf,this.A)}initialize(a){this.m=a;this.a=this.m.a;this.m.on(_.Sf,b=>{this.B||(b=b.detail,b.currentState===_.ap&&(this.g.debug("Current state",b.currentState),this.B=!0,PP(this)))});this.a.on(GQ,this.C,this)}release(){this.f={};this.j=this.w=this.o=this.l=null;this.B=!1;this.h=1}load(){if(this.a&&!(0<Object.keys(this.f).length)){this.j=this.m.h;this.m.off(_.Sf,this.A);this.m.on(_.Sf,this.A,this);try{const a=cQ(this.a);this.f=VP(this,a);
37
+ const b=this.f[_.M]||[];b.length&&(this.l=b[0].renditions[0]||null);LP(this)}catch(a){this.g.debug("Could not load track manager")}}}destroy(){this.a.off(GQ,this.C);this.a=this.m=null}getVideoTracks(){return this.f[_.N]||[]}getAudioTracks(){return this.f[_.M]||[]}ka(){return this.f[_.L]||[]}la(){return YP(this,_.N)}Wa(){return YP(this,_.M)}Sa(){return YP(this,_.L)}pb(){return this.w}Ab(){this.g.info(kP);return null}Bb(){this.g.info(kP);return null}Ha(){const a=this.la();return a?a.track:null}oa(){const a=
38
+ this.Wa();return a?a.track:null}wa(){const a=this.Sa();return a?a.track:null}xb(a){null===a?(a=this.la(),eQ(this.a,a.bandwidth,null).then(()=>{LP(this)})):0<a.renditions.length&&this.gb(a.renditions[0])}xa(a){a?aQ(this,a.renditions[0]):this.g.warn("Cannot disable audio tracks on this platform.","Consider muting audio instead...")}Ta(a){a?(a=a.renditions[0],this.j?KP(this.j,a.track):aQ(this,a)):(this.g.debug("Disabling text tracks"),this.o=null,fQ(this.a,!1),this.m.trigger(new _.E(_.tl)))}gb(a){const b=
39
+ this.la();this.a.o||a.width!==b.width||a.height!==b.height||a.bandwidth!==b.bandwidth?(this.w=a,MP(this,a),eQ(this.a,b.bandwidth,a.bandwidth).then(()=>{LP(this)}).catch(c=>{const d=new _.H(_.F,7,7200,{tizenerror:c});this.g.debug("Error while switching video track",c);this.m.onError(d)})):this.g.debug("Trying to switch to already active rendition. Doing nothing...")}vb(a){aQ(this,a)}wb(a){this.j?KP(this.j,a.track):aQ(this,a)}addTextTrack(){}ta(){return this.a.o}};HQ.prototype.isAbrEnabled=HQ.prototype.ta;
40
+ HQ.prototype.addTextTrack=HQ.prototype.addTextTrack;HQ.prototype.setTextRendition=HQ.prototype.wb;HQ.prototype.setAudioRendition=HQ.prototype.vb;HQ.prototype.setVideoRendition=HQ.prototype.gb;HQ.prototype.setTextTrack=HQ.prototype.Ta;HQ.prototype.setAudioTrack=HQ.prototype.xa;HQ.prototype.setVideoTrack=HQ.prototype.xb;HQ.prototype.getTextTrack=HQ.prototype.wa;HQ.prototype.getAudioTrack=HQ.prototype.oa;HQ.prototype.getVideoTrack=HQ.prototype.Ha;HQ.prototype.getLoadingTextRendition=HQ.prototype.Bb;
41
+ HQ.prototype.getLoadingAudioRendition=HQ.prototype.Ab;HQ.prototype.getLoadingVideoRendition=HQ.prototype.pb;HQ.prototype.getTextRendition=HQ.prototype.Sa;HQ.prototype.getAudioRendition=HQ.prototype.Wa;HQ.prototype.getVideoRendition=HQ.prototype.la;HQ.prototype.getTextTracks=HQ.prototype.ka;HQ.prototype.getAudioTracks=HQ.prototype.getAudioTracks;HQ.prototype.getVideoTracks=HQ.prototype.getVideoTracks;var LQ=class extends _.ju{constructor(a){super();this.m=a;this.h=null;this.g=new _.S("clpp.tizen.Middleware");this.F=1;this.C=!1;this.l=null;this.G=0;this.o=!0;this.f=!1;this.a=null;this.A=1;this.w=!1;this.j={}}J(){this.w=!0;this.f||this.trigger(new _.E(rQ))}I(a){this.w=!0;this.trigger(new _.E(xQ,{percent:a}))}H(){this.w=!1;this.trigger(new _.E(yQ))}M(){this.trigger(new _.E(zQ))}L(a,b){this.trigger(new _.E(GQ,{eventid:a,data:b}))}O(a,b,c,d,e){this.trigger(new _.E(IQ,{duration:a,text:b,subtitleType:c,
42
+ attriCount:d,attributes:e}))}K(a,b){this.trigger(new _.E(JQ,{drmType:a,drmData:b}));this.h&&(a=this.h,a.j&&(a.a===_.Cd&&"Challenge"===b.name?tP(a,b):"DrmError"===b.name&&(a.g.debug("DrmError event",b),b=new _.H(_.F,6,6005,{message:JSON.stringify(b)}),a.D.onError(b))))}B(a){this.trigger(new _.E(KQ,{eventType:a}))}play(){const a=this.getState(),b=()=>new Promise((c,d)=>{let e=null;const f=()=>{c();clearTimeout(e)};this.one(hQ,f,this);e=setTimeout(()=>{this.off(hQ,f);d("Timeout")},3E4)});if(a===BQ)return(new Promise((c,
43
+ d)=>{webapis.avplay.prepareAsync(()=>{jQ(this);c(webapis.avplay.play())},e=>{this.trigger(new _.E(KQ));d(e)})})).then(()=>b());if(a===BP||a===AQ)try{return webapis.avplay.play(),b()}catch(c){return Promise.reject(c)}return a===AP?Promise.resolve():Promise.reject("Player is in invalid state")}pause(){try{webapis.avplay.pause()}catch(a){Promise.reject(a)}return this.getState()===BP?Promise.resolve():Promise.reject()}setPlaybackRate(a){const b=this.getState();if(b===AQ||b===AP||b===BP){try{webapis.avplay.setSpeed(a),
44
+ this.F=a}catch(c){return this.g.debug("Error while trying to set playback rate",c),this.setPlaybackRate(this.F)}return!0}this.g.debug("Cannot set playback rate; AVPlay is in inconsistent state: "+b);return!1}getPlaybackRate(){return this.F}load(a,b){const c=this;return _.x(function*(){c.g.debug("configure()",b||"");try{yield oQ(c),yield vQ(c,a,b)}catch(d){throw new _.H(_.F,7,7003,null,d);}})}getState(){if(this.f&&this.a)return this.a.tf;try{return webapis.avplay.getState()}catch(a){this.B(JSON.stringify(a))}}seek(a){const b=
45
+ 1E3*a;return new Promise((c,d)=>{this.C=!0;this.m.trigger(new _.E(_.lg));webapis.avplay.seekTo(b,()=>{this.C=!1;this.m.trigger(new _.E(_.kg));c()},()=>{this.C=!1;d()})})}getPosition(){if(this.f&&this.a)return this.a.position;try{return webapis.avplay.getCurrentTime()/1E3}catch(a){this.B(JSON.stringify(a))}}getDuration(){if(this.f&&this.a)return this.a.duration;try{return webapis.avplay.getDuration()/1E3}catch(a){this.B(JSON.stringify(a))}}release(){return new Promise((a,b)=>{try{this.h&&(this.h.release(),
46
+ this.h=null);webapis.avplay.stop();webapis.avplay.close();for(const c in this.j){const d=this.j[c];d&&d.be.stop()}this.j={};this.F=1;this.C=!1;this.a=this.l=null;return a()}catch(c){return b(c)}})}getVolume(){let a=null;try{a=tizen.tvaudiocontrol.getVolume()}catch(b){switch(b.name){case lP:this.g.debug("The application does not have the privilege to get the volume.",mP);break;default:this.g.debug(jP,b)}}return a}setVolume(a){try{tizen.tvaudiocontrol.setVolume(Math.max(0,Math.min(100*a,100)))}catch(b){switch(b.name){case "InvalidValueError":this.g.warn("Invalid value passed for setVolume.",
47
+ "The passed value value should be in the range of 0 to 1.");break;case lP:this.g.warn("The application does not have the privilege to set the volume.",mP);break;default:this.g.warn("An unknown error occurred while trying to set volume",b)}}}isLive(){if(this.f&&this.a)return this.a.isLive;try{return"1"===webapis.avplay.getStreamingProperty("IS_LIVE")}catch(a){this.B(JSON.stringify(a))}}stop(){try{webapis.avplay.stop()}catch(a){this.g.debug(a)}}getDrmInfo(){this.h&&this.h.getDrmInfo();return null}setSourceIndex(a){this.G=
48
+ a}getSourceIndex(){return this.G}getLoadedSource(){return this.l&&this.l[this.getSourceIndex()]}},BQ="IDLE",AQ="READY",AP="PLAYING",BP="PAUSED",QP=_.Rb,RP="AUDIO",$P="TEXT",FQ="PLAYER_MSG_RESOLUTION_CHANGED",EQ="PLAYER_MSG_BITRATE_CHANGE",xP="PLAYREADY",sP="WIDEVINE_CDM";var PQ=class extends _.ju{constructor(){super();this.a=new LQ(this);this.f=new CQ(this);this.configuration=this.B=_.El();this.w=null;this.g=new _.S("clpp.tizen.Player");this.j=null;this.l=new HQ;this.C=new _.lr;this.o=this.h=null;this.A=!1}I(){this.g.debug("On Stream completed. Current time: ",this.getPosition());this.trigger(new _.E(_.be));this.configuration.loop?this.seek(this.configuration.startTime||0).catch(()=>{this.g.debug("Could not loop playback")}):this.a.stop()}F(a){this.trigger(new _.E(_.bg,
49
+ {currentTime:a.currentTime/1E3}))}J(a){const b=this.a.getPosition(),c=b+a.duration/1E3;let d=a.text||"";this.g.debug("Got subtitles: ",d,"start:",b,"end:",c,a);(d=_.dj(d))&&this.o.append([new _.Ft(b,c,d)],[])}G(a){this.g.debug("DRM event: "+a.drmType+", data: "+a.drmData)}K(){this.A||(this.g.debug("Initial buffering completed..."),this.A=!0)}H(a){this.g.debug(`Error: TYPE: ${a.eventType}`);zP(this.f,_.Ro);a=new _.H(_.F,7,7200,{tizenerror:a.eventType});this.a.release();this.trigger(new _.E(_.r,{detail:a}))}init(a,
50
+ b){this.configuration=this.B=b;this.w=a;this.a.on(zQ,this.I,this);this.a.on(hQ,this.F,this);this.a.on(IQ,this.J,this);this.a.on(JQ,this.G,this);this.a.on(KQ,this.H,this);this.a.on(yQ,this.K,this);this.f.initialize();this.l.initialize(this);this.g.debug("Initializing player surface");this.w.hideMediaElement();a=MQ;MQ+=1;a="__clpp_tizen_player_"+a;this.j=_.vp(_.Ke,{id:a,type:"application/avplayer"});this.w.addElementToContainer(this.j,!0);var c=this.w.getMedia();if(c){a=this.j;{b=[_.Ig,_.ge,"position",
51
+ _.me,"top"];const e={};c=null!==c.parentElement?window.getComputedStyle(c,null):c.style;if(!b||0===b.length)for(d in b||(b=[]),c)b.push(d);for(const f of b)e[f]=c[f];var d=e}_.xp(a,d);wQ(this)}}getSurface(){return this.w}getConfiguration(){return this.configuration}getTimeline(){return null}setupPlaylist(){return Promise.reject(_.nb)}appendLoad(){return Promise.reject(_.nb)}seekWith(){return Promise.reject(_.nb)}setSeekInterceptor(){}setPlaybackSessionId(){}destroy(){const a=this;return _.x(function*(){yield a.release();
52
+ a.a.off(zQ,a.I);a.a.off(hQ,a.F);a.a.off(IQ,a.J);a.a.off(JQ,a.G);a.a.off(KQ,a.H);a.a.off(yQ,a.K);a.h&&(yield a.h.destroy(),a.h=null);a.j&&(a.j.parentElement.removeChild(a.j),a.j=null);a.l.destroy();a.f.destroy();a.l=null;a.f=null})}namespace(){return NQ}getPlaybackRate(){return this.a.getPlaybackRate()}setDrmCustomDataModifier(){}setCdnErrorCallback(){}detach(){}setPlaybackRate(a){this.a.setPlaybackRate(a)}getPosition(){return this.getMediaPosition()}getMediaPosition(){return 0<(this.configuration.startTime||
53
+ 0)&&!this.A?0:this.f.getState()===_.Qo?this.getDuration():this.a.getPosition()||0}seek(a){return typeof a===_.t&&0<=a?(this.isLive()||(a=Math.min(a,this.getDuration())),this.a.seek(a)):Promise.reject()}getPresentationStartTime(){return null}getSeekRange(){return{start:0,end:0}}getVolume(){const a=this.a.getVolume();return typeof a===_.t?a/100:null}setVolume(a){this.a.setVolume(a)}getDuration(){return this.getMediaDuration()}getMediaDuration(){return this.a.getDuration()}getBufferInfo(){this.g.warn(_.pa);
54
+ return new _.iu}getTrackManager(){return this.l}unload(){return this.a.release().then(()=>{this.l.release()})}release(){const a=this;return _.x(function*(){a.h&&(yield a.h.release());a.o&&(yield a.o.destroy(),a.o=null);yield a.a.release();a.l.release();a.f.release();a.A=!1})}load(a){const b=this;return _.x(function*(){b.configuration=_.Gl(b.B,a);var c=_.Io(b.configuration,[_.ie,"native"]);b.o=c.create(b);c=_.dp(b.configuration)[0];if(b.configuration.tizen&&b.configuration.tizen.sideStreamText){b.h=
55
+ new DQ;b.h.initialize(b);try{yield b.h.load(c),b.h.start()}catch(d){b.g.error(d)}}try{yield b.a.load(b.configuration)}catch(d){throw b.onError(d),d;}b.l.load()})}play(){this.trigger(new _.E(_.Ze));wQ(this);return this.a.play().then(()=>{CP(this.f)})}pause(){return this.a.pause().then(()=>{CP(this.f)})}getState(){return this.f.getState()}getPeriods(){return[]}onError(a){const b=new _.E(_.r,{detail:a});a.severity===_.F&&(zP(this.f,_.Ro),this.a.release());this.trigger(b);b.defaultPrevented&&(b.a=!0)}getDrmInfo(){return this.a.getDrmInfo()}isEnded(){return this.f.getState()===
56
+ _.Qo}isPaused(){return this.a.getState()===BP}isMuted(){return mQ(this.a)}setMuted(a){qQ(this.a,a)}getNetworkEngine(){return this.C}setNetworkEngine(a){this.C=a}setCmsdManager(){}isLive(){return this.a.isLive()}getStats(){return null}setSourceIndex(a){this.a.setSourceIndex(a)}getSourceIndex(){return this.a.getSourceIndex()}getLoadedSource(){return this.a.getLoadedSource()}canPlay(a,b){return(new OQ).canPlay(a,b)}getTimelineCues(){return[]}getCueTimeline(){return null}getTextDisplayer(){return this.o}resetAbr(){}},
57
+ NQ="clpp.tizen",MQ=0,OQ=class{a(){return NQ}canPlay(a){a=a.type;const b=!!window.webapis;if((a===_.Fc||a===_.xl||a===_.Kc)&&b){if(_.Gk(2))return 2;if(_.Gk(3)||_.Gk(4)||_.Gk(5)||_.Gk(6))return _.C("Use of clpp.tizen.TizenComponent is not recommended for Tizen version \x3e\x3d 3."),1}return 0}f(a){return a===_.ma}create(){return new PQ}};_.z("clpp.tizen.TizenComponent",class extends _.pv{f(){_.xh(new OQ)}a(){var a=NQ;a&&_.vh[a]&&(delete _.vh[a],_.wh.info("Removed Player factory: '"+a+"'"))}id(){return"tizen"}});var rQ="onbufferingstart",xQ="onbufferingprogress",yQ="onbufferingcomplete",zQ="onstreamcompleted",hQ="oncurrentplaytime",GQ="onevent",IQ="onsubtitlechange",JQ="ondrmevent",KQ="onerror",tQ="preparingstart",uQ="preparingend";};f.call(g, window);
package/cl.ttml.js CHANGED
@@ -1,22 +1,22 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Vw='application/mp4; codecs\x3d"stpp.ttml"',Ww='application/mp4; codecs\x3d"stpp.ttml.im1i"',Xw='application/mp4; codecs\x3d"stpp.ttml.im1t"',Yw="backgroundColor",Zw="direction",$w="displayAlign",ax="region",bx="textAlign",cx="textDecoration",dx="writingMode",ex=function(a,b,c){a=a.f;for(let d=a.length-1;0<=d;d--){const e=b.get(a[d]);if(c in e.a)return e.getAttribute(c)}return null},mx=function(a,b){var c=null;if(fx.test(a)){{a=fx.exec(a);c=Number(a[1]);const d=Number(a[2]);let e=
2
- Number(a[3]),f=Number(a[4]);f+=(Number(a[5])||0)/b.f;e+=f/b.frameRate;c=e+60*d+3600*c}}else gx.test(a)?c=hx(gx,a):ix.test(a)?c=hx(ix,a):jx.test(a)?(a=jx.exec(a),c=Number(a[1])/b.frameRate):kx.test(a)?(a=kx.exec(a),c=Number(a[1])/b.a):lx.test(a)&&(c=hx(lx,a));return c},hx=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)},nx=function(a){return a.split(":").pop()},ox=function(a){return a.replace(/(\d*\.?\d+)c/g,
3
- "$1em")},qx=function(a,b){for(;px.test(a);){const c=px.exec(a)[0];a=a.replace(c,`${parseInt(c,10)/b}em`)}return a},rx=function(a){return a?a.replace(/(\d*\.?\d+)%/g,(b,c)=>`${c/100}em`):""},sx=function(a,b,c){a=ex(a,b,bx);if(!a&&c&&(a=ex(c,b,bx),!a&&"rltb"===ex(c,b,dx)))return _.Bf;switch(a){case _.dd:return _.mt;case _.Bf:case _.Wd:return _.Bf;default:return _.he}},tx=function(a,b,c){if(_.Ui(a.w))return document.createTextNode(_.Yi(a.w||""));if(a.A)return _.Zo("br");const d=_.Zo("span");for(const e of a.f)_.$o(d,
4
- e);for(const e of a.j)d.appendChild(tx(c.get(e),b,c));return d},wx=function(a,b,c,d){const e=ux.exec(a);a=vx.exec(a);return typeof b===_.t&&0<b&&a?100*Number(a[c])/b:e?Number(e[c]):a?Number(a[c]):d},xx=function(a,b){return typeof b===_.t&&0<b?_.ut:vx.test(a)?0:_.ut},yx=function(a,b,c){return typeof a===_.t?a:typeof b===_.t?b:c},zx=function(a,b){a=a.getAttribute("extent");return(a=vx.exec(a))?Number(a[b]):null},Bx=function(a){a=a.getAttribute("cellResolution");return(a=Ax.exec(a))?Number(a[2]):null},
5
- Dx=function(){return`${"inline-"}${Cx++}`},Fx=function(a){return Ex.some(b=>b in a.attributes)},Gx=function(a,b){if(0===b.length)return[];const c=[];for(const d of b)a.a.has(d)&&c.push(...Gx(a,a.a.get(d).f),d);return c},Hx=function(a){return a.o.map(b=>b.build(a.l,a.w,a.A,a.h,a.a,a.j,a.f)).filter(b=>null!=b)},Ix=function(a){return nx(a.h.nodeName)},Lx=function(a,b){if(a.a.has(b))return a.a.get(b);var c=null,d=null;let e=[],f=[],g={};const h=b.parentNode;if(h&&a.a.has(h)){const k=a.a.get(h);e=[...k.l];
6
- -1===["#text","span","br"].indexOf(b.nodeName)&&(c=k.a,d=k.j,f=[...k.f],g={},Jx.forEach(l=>{l in k.attributes&&(g[l]=k.attributes[l])}))}if(b.nodeType===b.ELEMENT_NODE){b.hasAttribute(ax)&&(c=b.getAttribute(ax));b.hasAttribute(_.Uf)&&f.push(...b.getAttribute(_.Uf).split(" "));d=Array.from(b.attributes).map(k=>k.name);for(const k of d)d=nx(k),g[d]=b.getAttribute(k);d=g.backgroundImage}c=new Kx(b,c,d,e,f,g);a.a.set(b,c);return c},Mx=function(a){return`${String(Math.floor(a/3600)).padStart(2,"0")}:${String(Math.floor(a/
7
- 60%60)).padStart(2,"0")}:${String(Math.floor(a%60)).padStart(2,"0")}.${String(Math.floor(1E3*a%1E3)).padStart(3,"0")}`},Nx=class{constructor(a,b,c){this.h=a;this.f=b;this.a=c}getId(){return this.h}getAttribute(a){return this.a[a]}};var Ox=class extends Nx{constructor(a,b,c){super(a,[],c);this.j=b||""}};var Px=class extends Nx{constructor(a,b,c){super(a,b,c)}};var fx=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,gx=/^(?:(\d{2,}):)?(\d{2}):(\d{2})$/,ix=/^(?:(\d{2,}):)?(\d{2}):(\d{2}\.\d+)$/,jx=/^(\d*(?:\.\d*)?)f$/,kx=/^(\d*(?:\.\d*)?)t$/,lx=/^(?:(\d*(?:\.\d*)?)h)?(?:(\d*(?:\.\d*)?)m)?(?:(\d*(?:\.\d*)?)s)?(?:(\d*(?:\.\d*)?)ms)?$/,ux=/^(\d{1,2}(?:\.\d+)?|100(?:\.0+)?)% (\d{1,2}(?:\.\d+)?|100(?:\.0+)?)%$/,vx=/^(\d+)px (\d+)px$/,Ax=/^(\d+) (\d+)$/,px=/(\d+)px/,Qx=/^(\d+px|\d+em|\d*\.?\d+c)$/,Ex=[Yw,"color",Zw,$w,"fontFamily","fontSize","fontStyle","fontWeight",
8
- "lineHeight","opacity","padding",bx,cx,"textOutline",dx,"zIndex"],Jx=["begin",_.Wd];var Rx=class extends Px{constructor(a,b,c,d,e,f,g){super(a,f,g);this.w=b;this.A=c;this.o=d;this.l=e;this.j=[]}build(a,b,c,d,e,f,g){let h=mx(this.a.begin,b);b=mx(this.a.end,b);if(null===h||null===b)return null;h+=c;b+=c;c=_.Zo(_.Id);for(const k of this.j)c.appendChild(tx(g.get(k),e,g));g=new _.rt(h,b,c.innerHTML.trim(),_.ag);g.cssClassList=[...this.f];g.textAlign=sx(this,e,null);g.writingMode=_.nt;g.line=-1;g.lineInterpretation=_.ot;g.lineAlign=_.pt;g.containerRows=yx(null,Bx(a),15);if(this.o&&(f=
9
- f.get(this.o))){g.region=f.build(a,e);g.textAlign=sx(this,e,f);a:switch(ex(f,e,dx)){case "tb":case "tblr":a=_.lg;break a;case "tbrl":a=_.mg;break a;default:a=_.nt}g.writingMode=a;a:switch(ex(f,e,$w)){case _.dd:a=50;break a;case "after":a=-1;break a;default:a=0}g.line=a;a:switch(ex(f,e,$w)){case _.dd:a=1;break a;default:a=_.ot}g.lineInterpretation=a;a:switch(ex(f,e,$w)){case _.dd:e=_.dd;break a;default:e=_.pt}g.lineAlign=e}this.l&&(d=d.get(this.l))&&(a=d,d=a.getAttribute("encoding"),e=a.getAttribute("imageType")||
10
- a.getAttribute("imagetype"),a=a.j.trim(),d="PNG"===e&&"Base64"===d&&0<a.length?`data:image/png;base64,${a}`:null,g.backgroundImage=d||"");return g}};var Sx=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*=Number(a[1])/Number(a[2]))}};var Tx=class extends Px{constructor(a,b,c){super(a,b,c)}build(a,b){const c=new _.wt;c.id=this.getId();const d=yx(a.j.containerWidth,zx(a,1),720);a=yx(a.j.containerHeight,zx(a,2),480);a:switch(ex(this,b,$w)){case "after":var e="flex-start";break a;case _.dd:e=_.dd;break a;default:e="flex-end"}c.displayAlign=e;a:switch(ex(this,b,dx)){case "tb":case "tblr":e="row-reverse";break a;case "tbrl":e="row";break a;default:e=_.sd}c.writingMode=e;e=this.getAttribute("extent")||ex(this,b,"extent");c.width=wx(e,
11
- d,1,100);c.widthUnits=xx(e,d);c.height=wx(e,a,2,100);c.heightUnits=xx(e,a);b=this.getAttribute("origin")||ex(this,b,"origin");c.viewportAnchorX=wx(b,d,1,0);c.viewportAnchorY=wx(b,a,2,0);c.viewportAnchorUnits=xx(b,d);c.cssClassList=[...this.f];return c}};var Ux=class extends Nx{constructor(a,b){super("root-container",[],b);this.j=a}};var Wx=class extends Nx{constructor(a,b,c){super(a,b,c)}build(a){var b=null;var c=Bx(a);c&&(b=yx(a.j.containerHeight,zx(a,2),480)/c);b=yx(a.j.fontSizeRadix,b,16);a=[];c=`::ttml .${this.h}, ::ttml .${this.h} * {`;for(const [g,h]of Vx.entries())g in this.a&&(c+=`${h}:${ox(this.a[g])};`);a:{if("unicodeBidi"in this.a){var d=this.a.unicodeBidi;var e="";switch(d){case "normal":case "embed":e=d;break;case "bidiOverride":e="bidi-override"}if(0<e.length){d=`unicode-bidi:${e};`;break a}}d=""}c+=d;a:{if("textOutline"in
12
- this.a){d=this.a.textOutline.split(" ");e="black";let g=".4em";const h=d[0]&&d[0].trim(),k=d[1]&&d[1].trim(),l=d[2]&&d[2].trim();3===d.length&&!Qx.test(h)&&Qx.test(k)&&Qx.test(l)?(e=h,g=k):2===d.length&&!Qx.test(h)&&Qx.test(k)?(e=h,g=k):2===d.length&&Qx.test(h)&&Qx.test(k)&&(g=h);if(""!==g){g=ox(g);d="text-shadow:"+`0 0 ${g} ${e},`+`0 0 ${g} ${e},`+`0 0 ${g} ${e};`;break a}}d=""}c+=d;"textShadow"in this.a?(d=rx(this.a.textShadow),d=ox(d),d=`text-shadow:${d};`):d="";c=c+d+("fontFamily"in this.a?`font-family:${this.a.fontFamily.replace("monospaceSansSerif",
13
- "monospace").replace("monospaceSerif","monospace").replace("proportionalSansSerif","sans-serif").replace("proportionalSerif","sans-serif").replace("sansSerif","sans-serif").replace("default","sans-serif")};`:"");a:{if(cx in this.a){d=this.a.textDecoration.split(" ");e=[];for(f of d)switch(f){case "underline":case "overline":e.push(f);break;case "lineThrough":e.push("line-through")}if(0<e.length){var f=`text-decoration:${e.join(" ")};`;break a}}f=""}"padding"in this.a?(d="border: solid transparent;border-width:"+
14
- ox(this.a.padding),d+=";"):d="";f=c=c+f+d;"lineHeight"in this.a?(c="",d=this.a.lineHeight,d=ox(d),d=qx(d,b),c+="line-height:",c+=d,c+=";"):c="";a.push(f+c+"}");a:{if("fontSize"in this.a&&(f=this.a.fontSize.split(" "),c=null,1===f.length&&(c=f[0]),2===f.length&&(c=f[1]),c)){c=c.trim();c=ox(c);c=qx(c,b);b=`font-size:${c};`;break a}b=null}b&&(f=`::ttml .${this.h} .clpp-text-wrapper {`,f+=b,f+="}",a.push(f),f=`::ttml .clpp-text-wrapper__${this.h} {`,f+=b,f+="}",a.push(f));return a}},Vx=new Map([[Yw,"background-color"],
15
- ["color","color"],[Zw,Zw],["fontStyle","font-style"],["fontWeight","font-weight"],["opacity","opacity"],["zIndex","z-index"]]);var Xx=class{constructor(a){this.B=a;this.w=this.l=null;this.A=0;this.h=new Map;this.a=new Map;this.j=new Map;this.f=new Map;this.o=[]}},Cx=0;var $x=class{constructor(a){this.a=a.firstChild;this.f=new Set}$c(){return!!this.a}next(){if(!this.a)return null;let a=this.a;do this.f.add(a),a.nodeType!==Node.TEXT_NODE&&!Yx.has(nx(a.nodeName))||Zx.has(nx(a.nodeName))||!a.firstChild||this.f.has(a.firstChild)?a.nextSibling?a=a.nextSibling:a=a.parentNode:a=a.firstChild;while(a&&(this.f.has(a)||a.nodeType!==Node.TEXT_NODE&&!Yx.has(nx(a.nodeName))));const b=this.a;this.a=a;return b}},Yx=new Set(["tt","head","layout",_.ze,_.ee,ax,"styling",_.Uf,"body",
16
- _.Id,"p","span","br"]),Zx=new Set([_.Uf,_.ee]);var Kx=class{constructor(a,b,c,d,e,f){this.h=a;this.a=b;this.j=c;this.l=d;this.f=e;this.attributes=f}getId(){return this.attributes.id}};var ay=class{constructor(){this.a=new Map}};var by=class{constructor(a){this.a=a;this.f=new DOMParser}parseInit(){}parseMedia(a,b,c){c&&c.length||(c=[a.byteLength]);var d=_.Ug(this.a.ttml||{}),e=_.K(a,0,c[0]);e=_.Li(e);if(""===e)return{cues:[],styles:[]};var f=null;try{f=this.f.parseFromString(e,_.Yf)}catch(m){throw new _.I(_.F,2,2005,"Failed to parse TTML.");}d=new Xx(d);e=new ay;f=new $x(f);b=b.periodStart;typeof b===_.t&&(d.A=b);b=c[0];for(var g=1;g<c.length;++g){var h=c[g],k=_.K(a,b,h);k=_.Zi(k);const m=`urn:mpeg:14496-30:subs:${g}`;d.h.set(m,
17
- new Ox(m,k,{imageType:"PNG",encoding:"Base64"}));b+=h}for(;f.$c();)a=f.next(),a=Lx(e,a),c=d,b=a,"tt"===Ix(b)&&(c.l=new Ux(c.B,Object.assign({},b.attributes))),c=d,b=a,"tt"===Ix(b)&&(c.w=new Sx(b.attributes.frameRate,b.attributes.subFrameRate,b.attributes.frameRateMultiplier,b.attributes.tickRate)),c=d,b=a,Ix(b)!==_.ee||b.attributes.begin||b.attributes.end||(g=`#${b.getId()}`,c.h.set(g,new Ox(g,b.h.textContent,b.attributes))),c=d,g=a,Ix(g)===_.ee&&g.attributes.begin&&g.attributes.end?(b=`#${Dx()}`,
18
- g=new Ox(b,g.h.textContent,g.attributes),c.h.set(b,g),c=g):c=null,c&&(a.j=c.getId()),c=d,b=a,Ix(b)===_.Uf&&(g=b.getId()||Dx(),h=new Wx(g,b.f,Object.assign({},b.attributes)),c.a.set(g,h),b.a&&c.j.get(b.a).f.push(g)),c=d,g=a,Ix(g)!==_.Uf&&Fx(g)?(b=Dx(),g=new Wx(b,[],Object.assign({},g.attributes)),c.a.set(b,g),c=g):c=null,c&&a.f.push(c.getId()),c=d,g=a,Ix(g)!==_.Id||!g.attributes.extent&&!g.attributes.origin?c=null:(b=Dx(),g=new Tx(b,Gx(c,g.f),Object.assign({},g.attributes)),c.j.set(b,g),c=g),c&&(a.a=
19
- c.getId()),c=d,g=a,Ix(g)!==ax?c=null:(b=g.getId(),g=new Tx(b,Gx(c,g.f),Object.assign({},g.attributes)),c.j.set(b,g),c=g),c&&(a.a=c.getId()),c=d,g=a,b=g.l,-1===["#text","span","br"].indexOf(Ix(g))||0===b.length?c=null:(h=b[b.length-1],c.f.has(h)?(b=Dx(),g=new Rx(b,"#text"===g.h.nodeName?g.h.textContent:null,"br"===Ix(g),g.a,g.j,Gx(c,g.f),g.attributes),c.f.set(b,g),(c=c.f.get(h))&&c.j.push(b),c=g):c=null),c&&a.l.push(c.getId()),c=d,g=a,"p"===Ix(g)||g.j?(b=Dx(),g=new Rx(b,null,!1,g.a,g.j,Gx(c,g.f),g.attributes),
20
- c.f.set(b,g),c.o.push(g),c=g):c=null,c&&a.l.push(c.getId());e=Hx(d);f=[];for(l of d.a.values())f.push(...l.build(d.l));var l=f;return{cues:e,styles:l}}};var cy=class{constructor(a){this.f=a}a(a){var b=new by(this.f);({cues:a}=b.parseMedia(a,{periodStart:0,segmentStart:null,segmentEnd:0}));b="WEBVTT\n\n";for(const d of a){a=b;b=Mx(d.startTime)+" --\x3e "+Mx(d.endTime);{var c=d;const e=[];switch(c.textAlign){case _.he:e.push("align:left");break;case _.Bf:e.push("align:right");break;case _.mt:e.push("align:middle");break;case _.he:e.push("align:start");break;case _.Bf:e.push("align:end")}switch(c.writingMode){case _.lg:e.push("vertical:lr");break;case _.mg:e.push("vertical:rl")}c=
21
- e.length?" "+e.join(" "):""}b=a+(b+c+"\n");b+=d.payload+"\n\n"}return _.Pi(b)}},dy=class{probe(a,b){return a===_.Gc&&b===_.Xf}create(a){return new cy(a)}};var ey=class{constructor(a){this.a=new by(a);this.g=new _.S("clpp.ttml.Mp4TtmlParser")}parseInit(a){let b=!1;(new _.nm).N(_.Ce,_.gm).N(_.$f,_.gm).N(_.xe,_.gm).N(_.Be,_.gm).N(_.Rf,_.gm).da(_.Tf,_.hm).N("stpp",c=>{b=!0;c.parser.stop()}).parse(a);if(!b)throw new _.I(_.F,2,2007);}parseMedia(a,b){let c=!1,d=[],e=[];const f=[];(new _.nm).N("moof",_.gm).N("traf",_.gm).da("subs",g=>{const h=_.P(g.reader);for(let k=0;k<h;++k){g.reader.skip(4);const l=_.$l(g.reader);for(let m=0;m<l;++m){const n=1===g.version?
22
- _.P(g.reader):_.$l(g.reader);f.push(n);g.reader.skip(6)}}}).N(_.we,_.im(g=>{c=!0;g=this.a.parseMedia(g,b,f);d=d.concat(g.cues);e=e.concat(g.styles)})).parse(a);c||this.g.warn("Couldn't find the mdat box");return{cues:d,styles:e}}};_.z("clpp.ttml.TtmlComponent",class extends _.Iu{constructor(){super();this.j=new dy}f(){_.Xs(_.Gc,by);_.Xs(_.Ec,ey);_.Xs(Vw,ey);_.Xs(Xw,ey);_.Xs(Ww,ey);_.fk.push(this.j)}a(){_.Zs(_.Gc);_.Zs(_.Ec);_.Zs(Vw);_.Zs(Xw);_.Zs(Ww);_.hk(this.j)}id(){return"subtitles-ttml"}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var qx='application/mp4; codecs\x3d"stpp.ttml"',rx='application/mp4; codecs\x3d"stpp.ttml.im1i"',sx='application/mp4; codecs\x3d"stpp.ttml.im1t"',tx="backgroundColor",ux="direction",vx="displayAlign",wx="region",xx="textAlign",yx="textDecoration",zx="writingMode",Ax=function(a,b,c){a=a.f;for(let d=a.length-1;0<=d;d--){const e=b.get(a[d]);if(e.hasAttribute(c))return e.getAttribute(c)}return null},Ix=function(a,b){var c=null;if(Bx.test(a)){{a=Bx.exec(a);c=Number(a[1]);const d=Number(a[2]);
2
+ let e=Number(a[3]),f=Number(a[4]);f+=(Number(a[5])||0)/b.f;e+=f/b.frameRate;c=e+60*d+3600*c}}else Cx.test(a)?c=Dx(Cx,a):Ex.test(a)?c=Dx(Ex,a):Fx.test(a)?(a=Fx.exec(a),c=Number(a[1])/b.frameRate):Gx.test(a)?(a=Gx.exec(a),c=Number(a[1])/b.a):Hx.test(a)&&(c=Dx(Hx,a));return c},Dx=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)},Jx=function(a){return a.split(":").pop()},Kx=function(a){return a.replace(/(\d*\.?\d+)c/g,
3
+ "$1em")},Mx=function(a,b){for(;Lx.test(a);){const c=Lx.exec(a)[0];a=a.replace(c,`${parseInt(c,10)/b}em`)}return a},Nx=function(a){return a?a.replace(/(\d*\.?\d+)%/g,(b,c)=>`${c/100}em`):""},Ox=function(a,b,c){a=Ax(a,b,xx);if(!a&&c&&(a=Ax(c,b,xx),!a&&"rltb"===Ax(c,b,zx)))return _.Ef;switch(a){case _.ed:return _.At;case _.Ef:case _.ae:return _.Ef;default:return _.me}},Px=function(a,b,c){if(_.$i(a.w))return document.createTextNode(_.dj(a.w||""));if(a.A)return _.vp("br");const d=_.vp("span");for(const e of a.f)_.wp(d,
4
+ e);for(const e of a.j)d.appendChild(Px(c.get(e),b,c));return d},Sx=function(a,b,c,d){const e=Qx.exec(a);a=Rx.exec(a);return typeof b===_.t&&0<b&&a?100*Number(a[c])/b:e?Number(e[c]):a?Number(a[c]):d},Tx=function(a,b){return typeof b===_.t&&0<b?_.It:Rx.test(a)?0:_.It},Ux=function(a,b,c){return typeof a===_.t?a:typeof b===_.t?b:c},Vx=function(a,b){a=a.getAttribute("extent");return(a=Rx.exec(a))?Number(a[b]):null},Xx=function(a){a=a.getAttribute("cellResolution");return(a=Wx.exec(a))?Number(a[2]):null},
5
+ Zx=function(){return`${"inline-"}${Yx++}`},ay=function(a){return $x.some(b=>b in a.attributes)},by=function(a,b){if(0===b.length)return[];const c=[];for(const d of b)a.a.has(d)&&c.push(...by(a,a.a.get(d).f),d);return c},cy=function(a){return a.o.map(b=>b.build(a.l,a.w,a.A,a.h,a.a,a.j,a.f)).filter(b=>null!=b)},dy=function(a){return Jx(a.h.nodeName)},gy=function(a,b){if(a.a.has(b))return a.a.get(b);var c=null,d=null;let e=[],f=[],g={};const h=b.parentNode;if(h&&a.a.has(h)){const k=a.a.get(h);e=[...k.l];
6
+ -1===[_.da,"span","br"].indexOf(b.nodeName)&&(c=k.a,d=k.j,f=[...k.f],g={},ey.forEach(l=>{l in k.attributes&&(g[l]=k.attributes[l])}))}if(b.nodeType===b.ELEMENT_NODE){b.hasAttribute(wx)&&(c=b.getAttribute(wx));b.hasAttribute(_.Xf)&&f.push(...b.getAttribute(_.Xf).split(" "));d=Array.from(b.attributes).map(k=>k.name);for(const k of d)d=Jx(k),g[d]=b.getAttribute(k);d=g.backgroundImage}c=new fy(b,c,d,e,f,g);a.a.set(b,c);return c},hy=function(a){return`${String(Math.floor(a/3600)).padStart(2,"0")}:${String(Math.floor(a/
7
+ 60%60)).padStart(2,"0")}:${String(Math.floor(a%60)).padStart(2,"0")}.${String(Math.floor(1E3*a%1E3)).padStart(3,"0")}`},iy=class{constructor(a,b,c){this.h=a;this.f=b;this.a=c}getId(){return this.h}hasAttribute(a){return a in this.a}getAttribute(a){return this.a[a]}};var jy=class extends iy{constructor(a,b,c){super(a,[],c);this.j=b||""}};var ky=class extends iy{constructor(a,b,c){super(a,b,c)}};var Bx=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Cx=/^(?:(\d{2,}):)?(\d{2}):(\d{2})$/,Ex=/^(?:(\d{2,}):)?(\d{2}):(\d{2}\.\d+)$/,Fx=/^(\d*(?:\.\d*)?)f$/,Gx=/^(\d*(?:\.\d*)?)t$/,Hx=/^(?:(\d*(?:\.\d*)?)h)?(?:(\d*(?:\.\d*)?)m)?(?:(\d*(?:\.\d*)?)s)?(?:(\d*(?:\.\d*)?)ms)?$/,Qx=/^(\d{1,2}(?:\.\d+)?|100(?:\.0+)?)% (\d{1,2}(?:\.\d+)?|100(?:\.0+)?)%$/,Rx=/^(\d+)px (\d+)px$/,Wx=/^(\d+) (\d+)$/,Lx=/(\d+)px/,ly=/^(\d+px|\d+em|\d*\.?\d+c)$/,$x=[tx,"color",ux,vx,"fontFamily","fontSize","fontStyle","fontWeight",
8
+ "lineHeight","opacity","padding",xx,yx,"textOutline",zx,"zIndex"],ey=["begin",_.ae];var my=class extends ky{constructor(a,b,c,d,e,f,g){super(a,f,g);this.w=b;this.A=c;this.o=d;this.l=e;this.j=[]}build(a,b,c,d,e,f,g){let h=Ix(this.a.begin,b);b=Ix(this.a.end,b);if(null===h||null===b)return null;h+=c;b+=c;c=_.vp(_.Ld);for(const k of this.j)c.appendChild(Px(g.get(k),e,g));g=new _.Ft(h,b,c.innerHTML.trim(),_.dg);g.cssClassList=[...this.f];g.textAlign=Ox(this,e,null);g.writingMode=_.Bt;g.line=-1;g.lineInterpretation=_.Ct;g.lineAlign=_.Dt;g.containerRows=Ux(null,Xx(a),15);if(this.o&&(f=
9
+ f.get(this.o))){g.region=f.build(a,e);g.textAlign=Ox(this,e,f);a:switch(Ax(f,e,zx)){case "tb":case "tblr":a=_.pg;break a;case "tbrl":a=_.qg;break a;default:a=_.Bt}g.writingMode=a;a:switch(Ax(f,e,vx)){case _.ed:a=50;break a;case "after":a=-1;break a;default:a=0}g.line=a;a:switch(Ax(f,e,vx)){case _.ed:a=1;break a;default:a=_.Ct}g.lineInterpretation=a;a:switch(Ax(f,e,vx)){case _.ed:e=_.ed;break a;default:e=_.Dt}g.lineAlign=e}this.l&&(d=d.get(this.l))&&(a=d,d=a.getAttribute("encoding"),e=a.getAttribute("imageType")||
10
+ a.getAttribute("imagetype"),a=a.j.trim(),d="PNG"===e&&"Base64"===d&&0<a.length?`data:image/png;base64,${a}`:null,g.backgroundImage=d||"");return g}};var ny=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*=Number(a[1])/Number(a[2]))}};var oy=class extends ky{constructor(a,b,c){super(a,b,c)}build(a,b){const c=new _.Kt;c.id=this.getId();const d=Ux(a.j.containerWidth,Vx(a,1),720);a=Ux(a.j.containerHeight,Vx(a,2),480);a:switch(Ax(this,b,vx)){case "after":var e="flex-start";break a;case _.ed:e=_.ed;break a;default:e="flex-end"}c.displayAlign=e;a:switch(Ax(this,b,zx)){case "tb":case "tblr":e="row-reverse";break a;case "tbrl":e="row";break a;default:e=_.ud}c.writingMode=e;e=this.getAttribute("extent")||Ax(this,b,"extent");c.width=Sx(e,
11
+ d,1,100);c.widthUnits=Tx(e,d);c.height=Sx(e,a,2,100);c.heightUnits=Tx(e,a);b=this.getAttribute("origin")||Ax(this,b,"origin");c.viewportAnchorX=Sx(b,d,1,0);c.viewportAnchorY=Sx(b,a,2,0);c.viewportAnchorUnits=Tx(b,d);c.cssClassList=[...this.f];return c}};var py=class extends iy{constructor(a,b){super("root-container",[],b);this.j=a}};var ry=class extends iy{constructor(a,b,c){super(a,b,c)}build(a){var b=null;var c=Xx(a);c&&(b=Ux(a.j.containerHeight,Vx(a,2),480)/c);b=Ux(a.j.fontSizeRadix,b,16);a=[];c=`::ttml .${this.h}, ::ttml .${this.h} * {`;for(const [g,h]of qy.entries())g in this.a&&(c+=`${h}:${Kx(this.a[g])};`);a:{if("unicodeBidi"in this.a){var d=this.a.unicodeBidi;var e="";switch(d){case "normal":case "embed":e=d;break;case "bidiOverride":e="bidi-override"}if(0<e.length){d=`unicode-bidi:${e};`;break a}}d=""}c+=d;a:{if("textOutline"in
12
+ this.a){d=this.a.textOutline.split(" ");e="black";let g=".4em";const h=d[0]&&d[0].trim(),k=d[1]&&d[1].trim(),l=d[2]&&d[2].trim();3===d.length&&!ly.test(h)&&ly.test(k)&&ly.test(l)?(e=h,g=k):2===d.length&&!ly.test(h)&&ly.test(k)?(e=h,g=k):2===d.length&&ly.test(h)&&ly.test(k)&&(g=h);if(""!==g){g=Kx(g);d="text-shadow:"+`0 0 ${g} ${e},`+`0 0 ${g} ${e},`+`0 0 ${g} ${e};`;break a}}d=""}c+=d;"textShadow"in this.a?(d=Nx(this.a.textShadow),d=Kx(d),d=`text-shadow:${d};`):d="";c=c+d+("fontFamily"in this.a?`font-family:${this.a.fontFamily.replace("monospaceSansSerif",
13
+ "monospace").replace("monospaceSerif","monospace").replace("proportionalSansSerif","sans-serif").replace("proportionalSerif","sans-serif").replace("sansSerif","sans-serif").replace("default","sans-serif")};`:"");a:{if(yx in this.a){d=this.a.textDecoration.split(" ");e=[];for(f of d)switch(f){case "underline":case "overline":e.push(f);break;case "lineThrough":e.push("line-through")}if(0<e.length){var f=`text-decoration:${e.join(" ")};`;break a}}f=""}"padding"in this.a?(d="border: solid transparent;border-width:"+
14
+ Kx(this.a.padding),d+=";"):d="";f=c=c+f+d;"lineHeight"in this.a?(c="",d=this.a.lineHeight,d=Kx(d),d=Mx(d,b),c+="line-height:",c+=d,c+=";"):c="";a.push(f+c+"}");a:{if("fontSize"in this.a&&(f=this.a.fontSize.split(" "),c=null,1===f.length&&(c=f[0]),2===f.length&&(c=f[1]),c)){c=c.trim();c=Kx(c);c=Mx(c,b);b=`font-size:${c};`;break a}b=null}b&&(f=`::ttml .${this.h} .clpp-text-wrapper {`,f+=b,f+="}",a.push(f),f=`::ttml .clpp-text-wrapper__${this.h} {`,f+=b,f+="}",a.push(f));return a}},qy=new Map([[tx,"background-color"],
15
+ ["color","color"],[ux,ux],["fontStyle","font-style"],["fontWeight","font-weight"],["opacity","opacity"],["zIndex","z-index"]]);var sy=class{constructor(a){this.B=a;this.w=this.l=null;this.A=0;this.h=new Map;this.a=new Map;this.j=new Map;this.f=new Map;this.o=[]}},Yx=0;var vy=class{constructor(a){this.a=a.firstChild;this.f=new Set}dd(){return!!this.a}next(){if(!this.a)return null;let a=this.a;do this.f.add(a),a.nodeType!==Node.TEXT_NODE&&!ty.has(Jx(a.nodeName))||uy.has(Jx(a.nodeName))||!a.firstChild||this.f.has(a.firstChild)?a.nextSibling?a=a.nextSibling:a=a.parentNode:a=a.firstChild;while(a&&(this.f.has(a)||a.nodeType!==Node.TEXT_NODE&&!ty.has(Jx(a.nodeName))));const b=this.a;this.a=a;return b}},ty=new Set(["tt","head","layout",_.De,_.je,wx,"styling",_.Xf,"body",
16
+ _.Ld,"p","span","br"]),uy=new Set([_.Xf,_.je]);var fy=class{constructor(a,b,c,d,e,f){this.h=a;this.a=b;this.j=c;this.l=d;this.f=e;this.attributes=f}getId(){return this.attributes.id}};var wy=class{constructor(){this.a=new Map}};var xy=class{constructor(a){this.a=a;this.f=new DOMParser}parseInit(){}parseMedia(a,b,c){c&&c.length||(c=[a.byteLength]);var d=_.$g(this.a.ttml||{}),e=_.K(a,0,c[0]);e=_.Ri(e);if(""===e)return{cues:[],styles:[]};var f=null;try{f=this.f.parseFromString(e,_.ag)}catch(m){throw new _.H(_.F,2,2005,"Failed to parse TTML.");}d=new sy(d);e=new wy;f=new vy(f);b=b.periodStart;typeof b===_.t&&(d.A=b);b=c[0];for(var g=1;g<c.length;++g){var h=c[g],k=_.K(a,b,h);k=_.ej(k);const m=`urn:mpeg:14496-30:subs:${g}`;d.h.set(m,
17
+ new jy(m,k,{imageType:"PNG",encoding:"Base64"}));b+=h}for(;f.dd();)a=f.next(),a=gy(e,a),c=d,b=a,"tt"===dy(b)&&(c.l=new py(c.B,Object.assign({},b.attributes))),c=d,b=a,"tt"===dy(b)&&(c.w=new ny(b.attributes.frameRate,b.attributes.subFrameRate,b.attributes.frameRateMultiplier,b.attributes.tickRate)),c=d,b=a,dy(b)!==_.je||b.attributes.begin||b.attributes.end||(g=`#${b.getId()}`,c.h.set(g,new jy(g,b.h.textContent,b.attributes))),c=d,g=a,dy(g)===_.je&&g.attributes.begin&&g.attributes.end?(b=`#${Zx()}`,
18
+ g=new jy(b,g.h.textContent,g.attributes),c.h.set(b,g),c=g):c=null,c&&(a.j=c.getId()),c=d,b=a,dy(b)===_.Xf&&(g=b.getId()||Zx(),h=new ry(g,b.f,Object.assign({},b.attributes)),c.a.set(g,h),b.a&&c.j.get(b.a).f.push(g)),c=d,g=a,dy(g)!==_.Xf&&ay(g)?(b=Zx(),g=new ry(b,[],Object.assign({},g.attributes)),c.a.set(b,g),c=g):c=null,c&&a.f.push(c.getId()),c=d,g=a,dy(g)!==_.Ld||!g.attributes.extent&&!g.attributes.origin?c=null:(b=Zx(),g=new oy(b,by(c,g.f),Object.assign({},g.attributes)),c.j.set(b,g),c=g),c&&(a.a=
19
+ c.getId()),c=d,g=a,dy(g)!==wx?c=null:(b=g.getId(),g=new oy(b,by(c,g.f),Object.assign({},g.attributes)),c.j.set(b,g),c=g),c&&(a.a=c.getId()),c=d,g=a,b=g.l,-1===[_.da,"span","br"].indexOf(dy(g))||0===b.length?c=null:(h=b[b.length-1],c.f.has(h)?(b=Zx(),g=new my(b,g.h.nodeName===_.da?g.h.textContent:null,"br"===dy(g),g.a,g.j,by(c,g.f),g.attributes),c.f.set(b,g),(c=c.f.get(h))&&c.j.push(b),c=g):c=null),c&&a.l.push(c.getId()),c=d,g=a,"p"===dy(g)||g.j?(b=Zx(),g=new my(b,null,!1,g.a,g.j,by(c,g.f),g.attributes),
20
+ c.f.set(b,g),c.o.push(g),c=g):c=null,c&&a.l.push(c.getId());e=cy(d);f=[];for(l of d.a.values())f.push(...l.build(d.l));var l=f;return{cues:e,styles:l}}};var yy=class{constructor(a){this.f=a}a(a){var b=new xy(this.f);({cues:a}=b.parseMedia(a,{periodStart:0,segmentStart:null,segmentEnd:0}));b="WEBVTT\n\n";for(const d of a){a=b;b=hy(d.startTime)+" --\x3e "+hy(d.endTime);{var c=d;const e=[];switch(c.textAlign){case _.me:e.push("align:left");break;case _.Ef:e.push("align:right");break;case _.At:e.push("align:middle");break;case _.me:e.push("align:start");break;case _.Ef:e.push("align:end")}switch(c.writingMode){case _.pg:e.push("vertical:lr");break;case _.qg:e.push("vertical:rl")}c=
21
+ e.length?" "+e.join(" "):""}b=a+(b+c+"\n");b+=d.payload+"\n\n"}return _.Vi(b)}},zy=class{probe(a,b){return a===_.Jc&&b===_.$f}create(a){return new yy(a)}};var Ay=class{constructor(a){this.a=new xy(a);this.g=new _.S("clpp.ttml.Mp4TtmlParser")}parseInit(a){let b=!1;(new _.um).N(_.Ge,_.nm).N(_.cg,_.nm).N(_.Be,_.nm).N(_.Fe,_.nm).N(_.Uf,_.nm).ca(_.Wf,_.om).N("stpp",c=>{b=!0;c.parser.stop()}).parse(a);if(!b)throw new _.H(_.F,2,2007);}parseMedia(a,b){let c=!1,d=[],e=[];const f=[];(new _.um).N("moof",_.nm).N("traf",_.nm).ca("subs",g=>{const h=_.P(g.reader);for(let k=0;k<h;++k){g.reader.skip(4);const l=_.gm(g.reader);for(let m=0;m<l;++m){const n=1===g.version?
22
+ _.P(g.reader):_.gm(g.reader);f.push(n);g.reader.skip(6)}}}).N(_.Ae,_.pm(g=>{c=!0;g=this.a.parseMedia(g,b,f);d=d.concat(g.cues);e=e.concat(g.styles)})).parse(a);c||this.g.warn("Couldn't find the mdat box");return{cues:d,styles:e}}};_.z("clpp.ttml.TtmlComponent",class extends _.pv{constructor(){super();this.j=new zy}f(){_.kt(_.Jc,xy);_.kt(_.Hc,Ay);_.kt(qx,Ay);_.kt(sx,Ay);_.kt(rx,Ay);_.lk.push(this.j)}a(){_.mt(_.Jc);_.mt(_.Hc);_.mt(qx);_.mt(sx);_.mt(rx);_.nk(this.j)}id(){return"subtitles-ttml"}});};f.call(g, window);
package/cl.verimatrix.js CHANGED
@@ -1,4 +1,4 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Kw="VerimatrixVCAS",Lw="clpp.verimatrix.Vcas",Mw="clpp.verimatrix.VcasComponent",Ow=function(a,b){return a.C===Nw?(a=Object.assign({},{deviceId:_.$i(_.Ri(a.A))},a.a&&{authenticator:_.$i(_.Ri(a.a))}),b+_.Oj(a)):b},Uw=class extends _.au{constructor(a){super(Kw);const b={};b[Pw]=Pw;b[Qw]=Qw;const {deviceId:c,authenticator:d,licenseRequestVuidLocation:e=Nw,httpHeaderNames:f=b,widevineLicenseUrl:g,playReadyLicenseUrl:h,fairPlayLicenseUrl:k,fairPlayCertificateUrl:l,fairPlaySiteId:m,fairPlayAssetIdStrategy:n=
2
- Rw}=a;this.A=c;this.a=d;this.C=e;this.B=f;this.w=Ow(this,g);this.o=Ow(this,h);this.l=Ow(this,k);this.j=l;this.G=m;this.F=n;this.g=new _.S(Lw);_.Vi(this.w)?this.g.warn(_.Wb):this.ab(_.zd,{licenseUrl:this.w,videoRobustness:[_.Gb,void 0],audioRobustness:[_.Fb,void 0],persistentStateRequired:!1,distinctiveIdentifierRequired:!1,serverCertificate:null,modifiers:{licenseRequest:this.h.bind(this)}});_.Vi(this.o)?this.g.warn(_.ub):this.ab(_.xd,{licenseUrl:this.o,videoRobustness:["3000"],audioRobustness:["2000"],
3
- modifiers:{licenseRequest:this.h.bind(this)}});_.Vi(this.l)?this.g.warn(_.Ta):_.Vi(this.j)?this.g.warn(_.Sa):this.ab(_.ud,{licenseUrl:this.l,certificateUrl:this.j,modifiers:{licenseRequest:this.J.bind(this),licenseResponse:this.K.bind(this),extractContentId:this.H.bind(this)}})}h(a,b){if(this.C===Sw){a=this.B[Qw];const c={};c[this.B[Pw]]=this.A;this.a&&(c[a]=this.a);Object.keys(c).forEach(d=>{b.headers[d]=c[d]})}}H(a,b){a=_.mm(b);switch(this.F){case Tw:a=_.Oj({r:a,yi:this.G},!0)}return a}J(a,b){this.h(a,
4
- b);_.rm(b)}K(a,b){_.sm(b)}};_.z(Lw,Uw);Uw.prototype.constructor=Uw.prototype.constructor;Uw.NAME=Kw;var Nw="query-string",Sw="http-header";Uw.LicenseRequestVuidLocation={QUERY_STRING:Nw,HTTP_HEADER:Sw};var Pw="DeviceId",Qw="Authenticator";Uw.LicenseRequestHttpHeader={DEVICE_ID_HEADER:Pw,AUTHENTICATOR_HEADER:Qw};var Rw="keyid",Tw="contentid-siteid";Uw.FairPlayAssetIdStrategy={KEYID:Rw,CONTENTID_SITEID:Tw};_.z(Mw,class extends _.Iu{constructor(){super();this.g=new _.S(Mw)}a(){delete _.Pl.VerimatrixVCAS}h(a){a=a.getConfiguration();if(a.drm&&a.drm.env===Kw){({customData:a}=a.drm);if(!a)throw new _.I(_.F,7,7100,_.Ad);a=new Uw(a);this.g.info("Registering the Verimatrix VCAS Ultra environment");_.Ql(a)}}id(){return"verimatrix-vcas"}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var fx="VerimatrixVCAS",gx="clpp.verimatrix.Vcas",hx="clpp.verimatrix.VcasComponent",jx=function(a,b){return a.C===ix?(a=Object.assign({},{deviceId:_.fj(_.Xi(a.A))},a.a&&{authenticator:_.fj(_.Xi(a.a))}),b+_.Uj(a)):b},px=class extends _.ou{constructor(a){super(fx);const b={};b[kx]=kx;b[lx]=lx;const {deviceId:c,authenticator:d,licenseRequestVuidLocation:e=ix,httpHeaderNames:f=b,widevineLicenseUrl:g,playReadyLicenseUrl:h,fairPlayLicenseUrl:k,fairPlayCertificateUrl:l,fairPlaySiteId:m,fairPlayAssetIdStrategy:n=
2
+ mx}=a;this.A=c;this.a=d;this.C=e;this.B=f;this.w=jx(this,g);this.o=jx(this,h);this.l=jx(this,k);this.j=l;this.G=m;this.F=n;this.g=new _.S(gx);_.aj(this.w)?this.g.warn(_.Vb):this.Ya(_.Cd,{licenseUrl:this.w,videoRobustness:[_.Cb,void 0],audioRobustness:[_.Bb,void 0],persistentStateRequired:!1,distinctiveIdentifierRequired:!1,serverCertificate:null,modifiers:{licenseRequest:this.h.bind(this)}});_.aj(this.o)?this.g.warn(_.tb):this.Ya(_.Ad,{licenseUrl:this.o,videoRobustness:["3000"],audioRobustness:["2000"],
3
+ modifiers:{licenseRequest:this.h.bind(this)}});_.aj(this.l)?this.g.warn(_.Ra):_.aj(this.j)?this.g.warn(_.Qa):this.Ya(_.wd,{licenseUrl:this.l,certificateUrl:this.j,modifiers:{licenseRequest:this.J.bind(this),licenseResponse:this.K.bind(this),extractContentId:this.H.bind(this)}})}h(a,b){if(this.C===nx){a=this.B[lx];const c={};c[this.B[kx]]=this.A;this.a&&(c[a]=this.a);Object.keys(c).forEach(d=>{b.headers[d]=c[d]})}}H(a,b){a=_.tm(b);switch(this.F){case ox:a=_.Uj({r:a,Ki:this.G},!0)}return a}J(a,b){this.h(a,
4
+ b);_.Bm(b)}K(a,b){_.Cm(b)}};_.z(gx,px);px.prototype.constructor=px.prototype.constructor;px.NAME=fx;var ix="query-string",nx="http-header";px.LicenseRequestVuidLocation={QUERY_STRING:ix,HTTP_HEADER:nx};var kx="DeviceId",lx="Authenticator";px.LicenseRequestHttpHeader={DEVICE_ID_HEADER:kx,AUTHENTICATOR_HEADER:lx};var mx="keyid",ox="contentid-siteid";px.FairPlayAssetIdStrategy={KEYID:mx,CONTENTID_SITEID:ox};_.z(hx,class extends _.pv{constructor(){super();this.g=new _.S(hx)}a(){delete _.Wl.VerimatrixVCAS}h(a){a=a.getConfiguration();if(a.drm&&a.drm.env===fx){({customData:a}=a.drm);if(!a)throw new _.H(_.F,7,7100,_.Dd);a=new px(a);this.g.info("Registering the Verimatrix VCAS Ultra environment");_.Xl(a)}}id(){return"verimatrix-vcas"}});};f.call(g, window);
package/cl.vimond.js CHANGED
@@ -1,8 +1,8 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Bw="Registering listeners",Cw="clpp.vimond.VimondPlugin",Dw=function(a,b){a.m.trigger(new _.E(_.ug,{detail:b}))},Ew=function(a,b,c){b&&(a.B=!0,a.h.stop());a.m.onError(new _.I(b?_.F:1,9,9201,c))},Fw=function(a,b){const c=a.m.getState();if(1===b)return["str-start",_.ef];if(a.h)return[_.Wd,_.Qe];if(c===_.uo)return[_.Wd,null];if(c===_.Bo)return[_.r,_.Qe];b=_.Qe;if(c===_.xo||c===_.Fo||a.f)b=_.ef;return["period",b]},Gw=class{constructor(a,b,c,d,e){this.K=a;this.L=b;this.M=c;this.m=d;this.F=
2
- e;this.a=new _.jt;this.l=!0;this.f=this.j=this.B=!1;this.C=null;this.h=new _.vk(this.A.bind(this));this.g=new _.S("clpp.vimond.VimondDispatcher");this.o=this.w=0;this.m&&this.a&&(this.g.debug(Bw),this.a.on(this.m,_.Pf,this.I.bind(this)),this.a.on(this.m,_.Zf,this.J.bind(this)),this.a.on(this.m,_.cc,this.G.bind(this)),this.a.on(this.m,_.dc,this.H.bind(this)))}J(){this.f||(this.f=1<Math.abs(this.w-this.m.getPosition()));this.w=this.m.getPosition()}G(){this.g.debug("Ad break started");this.j=!0}H(){this.g.debug("Ad break stopped");
3
- this.j=!1}I(a){const b=this;return _.x(function*(){const c=a.detail,d=c.currentState;b.g.debug(`State changed, prev: ${c.previousState} curr: ${d}`);b.B||b.j||(d!==b.C||b.f?b.l&&d!==_.Fo||(b.f&&[_.Eo,_.xo].includes(d)?b.g.debug("Seeking"):(b.f&&d===_.Fo&&(b.g.debug("Seeked"),b.f=!1),[_.Fo,_.Eo,_.Bo,_.uo].includes(d)&&(b.C=d,yield b.A(),d===_.uo&&b.h.stop()))):b.g.debug("Ignore transition"))})}A(){const a=this;return _.x(function*(){{const n=Math.floor(Date.now()/1E3);0<a.o&&a.g.debug(`Last event was ${n-
4
- a.o} seconds ago`);a.o=n}a.h.stop();a.h.fa(a.l?10:a.K);a.l=!1;try{{var b=a.F;b.f++;const q=_.Tg(b.o);q.client.buildName=_.pa;q.client.buildVersion=_.da;var c=q.client;{const A=b.a.m.getDrmInfo();var d=A?A.keySystem:""}c.drm=d;q.client.pageUrl=document.location.href;q.client.streamUrl=b.a.m.getLoadedSource().url;q.client.userAgent=navigator.userAgent;q.client.videoFormat=b.a.m.getLoadedSource().type||"";var e=q.client;{const A=b.a.m.getLoadedSource();var f=((new _.lm(A.url)).scheme||"").replace(":",
5
- "")}e.videoProtocol=f;const u=Fw(b.a,b.f);q.client.playerEvent=u[0]||"";q.client.playerState=u[1]||"";q.progress.vod&&(q.progress.vod.position=b.a.getPosition());const v=q.progress.live;if(v){{var g=b.a;const A=g.m.getPresentationStartTime()||0,D=Math.floor(A+g.m.getPosition());var h=(new Date(1E3*D)).toISOString()}v.position=h;{var k=b.a;const A=k.m.getPosition(),D=k.m.getSeekRange().end;var l=30>Math.abs(D-A)}v.onLiveEdge=l;typeof v.liveResumePossible!==_.Rc&&(v.liveResumePossible=!0)}q.progress.eventNumber=
6
- b.f;q.timestamp=(new Date).toISOString();b.g.debug("Fire an event");const y=_.pj(b.l);y.method=_.tb;y.contentType="application/json";y.headers.Authorization=`Bearer ${b.h}`;y.body=_.Ri(JSON.stringify(q));var m=b.j.fetch(y).W}const n=yield m;Dw(a,n)}catch(n){m=n.code,b=n.data,[1002,1003].includes(m)?(a.g.debug("Unreachable service"),Dw(a,b),Ew(a,a.L,b)):1001===m?(a.g.debug("Generic service error"),Dw(a,b),Ew(a,a.M,b)):a.g.error(n.toString())}})}};var Hw=class{constructor(a,b,c,d,e){this.l=a;this.o=c;this.h=b;this.a=d;this.j=e;this.g=new _.S("clpp.vimond.VimondService");this.f=0}Xe(a){this.h=a}};var Iw=class{constructor(a){this.m=a;this.a=new _.jt;this.g=new _.S("clpp.vimond.VimondAdapter");this.f=this.h=!1;this.m&&this.a&&(this.g.debug(Bw),this.a.on(this.m,_.xf,this.o.bind(this)),this.a.on(this.m,_.cc,this.j.bind(this)),this.a.on(this.m,_.dc,this.l.bind(this)))}getPosition(){return Math.floor(this.m.getPosition())}o(){this.h=!0}j(){this.f=!0}l(){this.f=!1}};var Jw=class extends _.iv{constructor(){super();this.a=!1;this.g=new _.S(Cw);this.j=this.h=this.f=null}onPlayerCreated(){}onContentWillLoad(a){var b=a.getConfiguration();(this.a=!_.B(b.vimond)&&typeof b.vimond===_.Ge)?a.namespace()===_.ld&&(this.a=!1,this.g.info("Vimond does not report when casting.")):this.g.debug("Vimond plugin is loaded but not configured. Will do nothing.");if(this.a){b=a.getConfiguration().vimond;for(var c of["authToken","playerEventRequest"])if(!b[c]){this.g.warn(`${c} key is missing`);
7
- a.onError(new _.I(1,9,9200));return}this.g.debug(_.qa);c=b.failIfUnreachable;typeof c!==_.Rc&&(c=!0);var d=b.failOnError;typeof d!==_.Rc&&(d=!0);this.f=new Iw(a);this.h=new Hw(b.playerEventRequest.uri,b.authToken,b.playerEventRequest.body,this.f,a.getNetworkEngine());this.j=new Gw(b.playerEventRequest.eventInterval,c,d,a,this.h)}}onPlayerWillRelease(){if(this.a){if(this.f){var a=this.f;a.g.debug(_.Pb);_.uh(a.a)}this.j&&(a=this.j,a.g.debug(_.Pb),_.uh(a.a),a.h.stop());this.j=this.h=this.f=null}}onPlayerWillDestroy(){}id(){return"vimond"}Xe(a){this.a&&
8
- this.h&&this.h.Xe(a)}};_.z(Cw,Jw);Jw.prototype.updateAuthToken=Jw.prototype.Xe;Jw.Id="vimond";_.Yq(new class{create(){return new Jw}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Xw="Registering listeners",Yw="clpp.vimond.VimondPlugin",Zw=function(a,b){a.m.trigger(new _.E(_.yg,{detail:b}))},$w=function(a,b,c){b&&(a.B=!0,a.h.stop());a.m.onError(new _.H(b?_.F:1,9,9201,c))},ax=function(a,b){const c=a.m.getState();if(1===b)return["str-start",_.kf];if(a.h)return[_.ae,_.Ve];if(c===_.Qo)return[_.ae,null];if(c===_.Ro)return[_.r,_.Ve];b=_.Ve;if(c===_.Uo||c===_.ap||a.f)b=_.kf;return["period",b]},bx=class{constructor(a,b,c,d,e){this.K=a;this.L=b;this.M=c;this.m=d;this.F=
2
+ e;this.a=new _.xt;this.l=!0;this.f=this.j=this.B=!1;this.C=null;this.h=new _.Ck(this.A.bind(this));this.g=new _.S("clpp.vimond.VimondDispatcher");this.o=this.w=0;this.m&&this.a&&(this.g.debug(Xw),this.a.on(this.m,_.Sf,this.I.bind(this)),this.a.on(this.m,_.bg,this.J.bind(this)),this.a.on(this.m,_.cc,this.G.bind(this)),this.a.on(this.m,_.ec,this.H.bind(this)))}J(){this.f||(this.f=1<Math.abs(this.w-this.m.getPosition()));this.w=this.m.getPosition()}G(){this.g.debug("Ad break started");this.j=!0}H(){this.g.debug("Ad break stopped");
3
+ this.j=!1}I(a){const b=this;return _.x(function*(){const c=a.detail,d=c.currentState;b.g.debug(`State changed, prev: ${c.previousState} curr: ${d}`);b.B||b.j||(d!==b.C||b.f?b.l&&d!==_.ap||(b.f&&[_.$o,_.Uo].includes(d)?b.g.debug("Seeking"):(b.f&&d===_.ap&&(b.g.debug("Seeked"),b.f=!1),[_.ap,_.$o,_.Ro,_.Qo].includes(d)&&(b.C=d,yield b.A(),d===_.Qo&&b.h.stop()))):b.g.debug("Ignore transition"))})}A(){const a=this;return _.x(function*(){var b=Math.floor(Date.now()/1E3);0<a.o&&a.g.debug(`Last event was ${b-
4
+ a.o} seconds ago`);a.o=b;a.h.stop();a.h.ga(a.l?10:a.K);a.l=!1;try{var c=yield a.F.fireEvent();Zw(a,c)}catch(d){b=d.code,c=d.data,[1002,1003].includes(b)?(a.g.debug("Unreachable service"),Zw(a,c),$w(a,a.L,c)):1001===b?(a.g.debug("Generic service error"),Zw(a,c),$w(a,a.M,c)):a.g.error(d.toString())}})}};var cx=class{constructor(a,b,c,d,e){this.l=a;this.o=c;this.h=b;this.a=d;this.j=e;this.g=new _.S("clpp.vimond.VimondService");this.f=0}fireEvent(){this.f++;const a=_.Zg(this.o);a.client.buildName=_.qa;a.client.buildVersion=_.ea;var b=a.client;var c=(c=this.a.m.getDrmInfo())?c.keySystem:"";b.drm=c;a.client.pageUrl=document.location.href;a.client.streamUrl=this.a.m.getLoadedSource().url;a.client.userAgent=navigator.userAgent;a.client.videoFormat=this.a.m.getLoadedSource().type||"";b=a.client;c=this.a.m.getLoadedSource();
5
+ c=((new _.sm(c.url)).scheme||"").replace(":","");b.videoProtocol=c;b=ax(this.a,this.f);a.client.playerEvent=b[0]||"";a.client.playerState=b[1]||"";a.progress.vod&&(a.progress.vod.position=this.a.getPosition());if(b=a.progress.live){c=this.a;var d=c.m.getPresentationStartTime()||0;c=Math.floor(d+c.m.getPosition());c=(new Date(1E3*c)).toISOString();b.position=c;d=this.a;c=d.m.getPosition();d=d.m.getSeekRange().end;c=30>Math.abs(d-c);b.onLiveEdge=c;typeof b.liveResumePossible!==_.Uc&&(b.liveResumePossible=
6
+ !0)}a.progress.eventNumber=this.f;a.timestamp=(new Date).toISOString();this.g.debug("Fire an event");b=_.xj(this.l);b.method=_.rb;b.contentType="application/json";b.headers.Authorization=`Bearer ${this.h}`;b.body=_.Xi(JSON.stringify(a));return this.j.fetch(b).U}ef(a){this.h=a}};var dx=class{constructor(a){this.m=a;this.a=new _.xt;this.g=new _.S("clpp.vimond.VimondAdapter");this.f=this.h=!1;this.m&&this.a&&(this.g.debug(Xw),this.a.on(this.m,_.Af,this.o.bind(this)),this.a.on(this.m,_.cc,this.j.bind(this)),this.a.on(this.m,_.ec,this.l.bind(this)))}getPosition(){return Math.floor(this.m.getPosition())}o(){this.h=!0}j(){this.f=!0}l(){this.f=!1}};var ex=class extends _.Fv{constructor(){super();this.a=!1;this.g=new _.S(Yw);this.j=this.h=this.f=null}onPlayerCreated(){}onContentWillLoad(a){var b=a.getConfiguration();(this.a=!_.B(b.vimond)&&typeof b.vimond===_.Ke)?a.namespace()===_.md&&(this.a=!1,this.g.info("Vimond does not report when casting.")):this.g.debug("Vimond plugin is loaded but not configured. Will do nothing.");if(this.a){b=a.getConfiguration().vimond;for(var c of["authToken","playerEventRequest"])if(!b[c]){this.g.warn(`${c} key is missing`);
7
+ a.onError(new _.H(1,9,9200));return}this.g.debug(_.ra);c=b.failIfUnreachable;typeof c!==_.Uc&&(c=!0);var d=b.failOnError;typeof d!==_.Uc&&(d=!0);this.f=new dx(a);this.h=new cx(b.playerEventRequest.uri,b.authToken,b.playerEventRequest.body,this.f,a.getNetworkEngine());this.j=new bx(b.playerEventRequest.eventInterval,c,d,a,this.h)}}onPlayerWillRelease(){if(this.a){if(this.f){var a=this.f;a.g.debug(_.Ob);_.Ah(a.a)}this.j&&(a=this.j,a.g.debug(_.Ob),_.Ah(a.a),a.h.stop());this.j=this.h=this.f=null}}onPlayerWillDestroy(){}id(){return"vimond"}ef(a){this.a&&
8
+ this.h&&this.h.ef(a)}};_.z(Yw,ex);ex.prototype.updateAuthToken=ex.prototype.ef;ex.Id="vimond";_.ur(new class{create(){return new ex}});};f.call(g, window);
package/cl.vr.js CHANGED
@@ -1,15 +1,15 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var hw="touchmove",iw="touchstart",kw=function(a,b,c){c*=.5;const d=Math.sqrt(a*a+b*b),e=Math.sin(c);return new jw(a/d*e,b/d*e,0/d*e,Math.cos(c))},lw=function(a,b){const c=a.x,d=a.y,e=a.a;a=a.f;b.set(1-2*(d*d+e*e),2*(c*d-e*a),2*(c*e+d*a),0,2*(c*d+e*a),1-2*(c*c+e*e),2*(d*e-c*a),0,2*(c*e-d*a),2*(d*e+c*a),1-2*(c*c+d*d),0,0,0,0,1)},mw=function(a,b){isFinite(b)?(a.x*=b,a.y*=b,a.a*=b):(a.x=0,a.y=0,a.a=0)},nw=function(a,b){return a.x*b.x+a.y*b.y+a.a*b.a},ow=function(a,b,c){const d=b.x,e=b.y;
2
- b=b.a;const f=c.x,g=c.y;c=c.a;a.x=e*c-b*g;a.y=b*f-d*c;a.a=d*g-e*f;return a},pw=function(a,b,c){b=b.a;c=c.a;const d=a.a;let e=0;do d[4*e]=b[4*e]*c[0]+b[4*e+1]*c[4]+b[4*e+2]*c[8]+b[4*e+3]*c[12],d[4*e+1]=b[4*e]*c[1]+b[4*e+1]*c[5]+b[4*e+2]*c[9]+b[4*e+3]*c[13],d[4*e+2]=b[4*e]*c[2]+b[4*e+1]*c[6]+b[4*e+2]*c[10]+b[4*e+3]*c[14],d[4*e+3]=b[4*e]*c[3]+b[4*e+1]*c[7]+b[4*e+2]*c[11]+b[4*e+3]*c[15];while(4>++e);return a},rw=function(a){var b=new qw(0,0,0),c=new qw(0,0,1);const d=new qw,e=new qw,f=new qw;a=a.a;var g=
3
- new qw(0,1,0);f.x=b.x-g.x;f.y=b.y-g.y;f.a=b.a-g.a;g=f.length();mw(f,1/g);c=ow(d,c,f);g=c.length();mw(c,1/g);ow(e,f,d);a[0]=d.x;a[1]=d.y;a[2]=d.a;a[3]=-nw(d,b);a[4]=e.x;a[5]=e.y;a[6]=e.a;a[7]=-nw(e,b);a[8]=f.x;a[9]=f.y;a[10]=f.a;a[11]=-nw(f,b);a[12]=0;a[13]=0;a[14]=0;a[15]=1},sw=function(a,b,c){b=a.a.createShader(b?a.a.FRAGMENT_SHADER:a.a.VERTEX_SHADER);a.a.shaderSource(b,c);a.a.compileShader(b);if(!a.a.getShaderParameter(b,a.a.COMPILE_STATUS))throw new _.I(1,9,9004,"Unable to compile GL shader: "+
4
- a.a.getShaderInfoLog(b));return b},tw=function(a){a.a&&(a.a.removeEventListener("mousemove",a.A,!1),a.a.removeEventListener(hw,a.A,!1),a.a.removeEventListener("mouseup",a.B,!1),a.a.removeEventListener("touchend",a.B,!1))},uw=function(a){const b=kw(1,0,a.l*Math.PI/180);lw(kw(0,1,a.j*Math.PI/180),a.P);lw(b,a.R);rw(a.Y);pw(a.Z,a.P,a.Y);pw(a.G,a.R,a.Z)},jw=class{constructor(a,b,c,d){this.x=a||0;this.y=b||0;this.a=c||0;this.f=d||1}};var qw=class{constructor(a,b,c){this.x=a||0;this.y=b||0;this.a=c||0}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.a*this.a)}};var vw=class{constructor(){this.a=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}set(a,b,c,d,e,f,g,h,k,l,m,n,q,u,v,y){const A=this.a;A[0]=a;A[4]=b;A[8]=c;A[12]=d;A[1]=e;A[5]=f;A[9]=g;A[13]=h;A[2]=k;A[6]=l;A[10]=m;A[14]=n;A[3]=q;A[7]=u;A[11]=v;A[15]=y;return this}};var ww=class{constructor(a){this.a=a;this.f=a.createProgram();this.l=sw(this,!1,"uniform highp mat4 Mvpm;\nattribute highp vec4 aPosition;\nattribute highp vec2 aTexCoord;\nvarying highp vec2 oTexCoord;\nvoid main()\n{\n gl_Position \x3d Mvpm * aPosition;\n oTexCoord \x3d aTexCoord;\n}\n");this.j=sw(this,!0,"precision highp float;\nuniform sampler2D Texture0;\nvarying highp vec2 oTexCoord;\nvoid main()\n{\n gl_FragColor \x3d texture2D(Texture0, oTexCoord);\n gl_FragColor.w \x3d 1.0;\n}\n");
5
- a.attachShader(this.f,this.l);a.attachShader(this.f,this.j);a.bindAttribLocation(this.f,0,"aPosition");a.bindAttribLocation(this.f,1,"aTexCoord");a.linkProgram(this.f);if(!a.getProgramParameter(this.f,a.LINK_STATUS))throw new _.I(1,9,9004,"Unable to initialize shader");a.useProgram(this.f);this.h=a.getUniformLocation(this.f,"Mvpm");a.uniform1i(a.getUniformLocation(this.f,"Texture0"),0);a.useProgram(null)}};var xw=class{constructor(a){this.a=a;var b=[];let c,d;for(d=0;70>=d;d++){var e=3>=d?d/4/64:67<=d?(63+(d-66)/4)/64:(d-3)/64;var f=(e-.5)*Math.PI;const g=Math.cos(f);for(c=0;128>=c;c++){const h=c/128,k=(.5+h)*Math.PI*2;128===c?(b.push(b[645*d]),b.push(b[645*d+1]),b.push(b[645*d+2])):(b.push(100*Math.cos(k)*g),b.push(100*Math.sin(k)*g),b.push(100*Math.sin(f)));0===d||70===d?b.push(.5):b.push(1-h);b.push(1-e)}}e=[];for(c=0;128>c;c++)for(d=0;70>d;d++)f=5*(129*d+c),e.push(b[f],b[f+1],b[f+2],b[f+3],b[f+
6
- 4]),f=5*(129*d+c+1),e.push(b[f],b[f+1],b[f+2],b[f+3],b[f+4]),f=5*(129*(d+1)+c),e.push(b[f],b[f+1],b[f+2],b[f+3],b[f+4]),f=5*(129*(d+1)+c),e.push(b[f],b[f+1],b[f+2],b[f+3],b[f+4]),f=5*(129*d+c+1),e.push(b[f],b[f+1],b[f+2],b[f+3],b[f+4]),f=5*(129*(d+1)+c+1),e.push(b[f],b[f+1],b[f+2],b[f+3],b[f+4]);this.h=e.length/5;this.f=a.createBuffer();b=new Float32Array(e);a.bindBuffer(a.ARRAY_BUFFER,this.f);a.bufferData(a.ARRAY_BUFFER,b,a.STATIC_DRAW)}};var yw=class{constructor(a,b){this.a=b;this.f=this.a.createTexture();b.activeTexture(b.TEXTURE0);b.bindTexture(b.TEXTURE_2D,this.f);b.texImage2D(b.TEXTURE_2D,0,b.RGB,b.RGB,b.UNSIGNED_BYTE,a);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.bindTexture(b.TEXTURE_2D,null)}};var zw={alpha:!1,depth:!0,stencil:!1,antialias:!0,premultipliedAlpha:!1,preserveDrawingBuffer:!1,devicePixelRatio:1},Aw=class extends _.iv{constructor(){super();this.o=this.w=this.K=this.I=this.C=this.X=this.G=this.f=this.a=this.m=null;this.g=new _.S("clpp.vr");this.H=70;this.V=1;this.M=this.L=!1;this.F=()=>{if(this.a&&this.f){this.f.viewport(0,0,this.a.width,this.a.height);{const a=this.K.a,b=Math.tan(.5*this.H*Math.PI/180);a[0]=1/(this.a.width/this.a.height*b);a[1]=0;a[2]=0;a[3]=0;a[4]=0;a[5]=1/
7
- b;a[6]=0;a[7]=0;a[8]=0;a[9]=0;a[10]=2E3/-1999.9;a[11]=200/-1999.9;a[12]=0;a[13]=0;a[14]=-1;a[15]=1}}};this.l=this.j=0;this.h={x:0,y:0};this.P=new vw;this.R=new vw;this.Y=new vw;this.Z=new vw;this.A=this.ca.bind(this);this.B=this.ha.bind(this);this.J=this.ba.bind(this)}onPlayerCreated(a){this.g.info("Player created");this.m=a}onContentWillLoad(a){const b=a.getConfiguration();if(b.vr&&b.vr.enable){{var c=b.vr,d=c.fieldOfView;const e=c.sensitivity,f=c.invertHorizontalControl;c=c.invertVerticalControl;
8
- if(void 0!==d&&_.ah(d))this.H=d;else throw new _.I(1,7,7100,"fieldOfView configuration must be a number");if(void 0!==e&&_.ah(e)&&0<e)this.V=e;else throw new _.I(1,7,7100,"sensitivity configuration must be a positive number");this.L=!!f;this.M=!!c}if(a=a.getSurface())if((d=a.getMedia())&&d.tagName.toLowerCase()===_.w){this.g.info("Initialize VR Surface");if(!this.a){this.a=document.createElement("canvas");this.a.style.width="100%";this.f=this.a.getContext("webgl",zw)||this.a.getContext("experimental-webgl",
9
- zw);if(!this.f)throw new _.I(1,9,9003,"Unable to create GL context");this.G=new vw;rw(this.G);this.X=new xw(this.f);this.C=new ww(this.f);this.I=new vw;this.K=new vw;this.o=this.w=null;this.a.addEventListener(_.Af,this.F)}a.addElementToContainer(this.a,!0,!0);a.hideMediaElement();b.vr.attachMouseListener&&(this.a.addEventListener("mousedown",this.J,!1),this.a.addEventListener(iw,this.J,!1));this.F();this.S()}else this.g.info("No video element found, can not initialize VR plugin");else this.g.info("No surface found, can not initialize VR plugin")}}onPlayerWillRelease(){this.g.info("Releasing VR plugin resources");
10
- this.w&&cancelAnimationFrame(this.w);this.h.x=0;this.l=this.j=this.h.y=0;this.f&&(delete this.f,this.f=null);this.a&&(tw(this),this.a.removeEventListener(_.Af,this.F),this.a.parentElement.removeChild(this.a),this.a.removeEventListener("mousedown",this.J,!1),delete this.a,this.a=null)}onPlayerWillDestroy(){const a=this;return _.x(function*(){a.m=null})}id(){return"vr"}S(){if(this.m&&this.f){var a=this.m.getSurface();if(a&&(a=a.getMedia())&&a.tagName.toLowerCase()===_.w){this.w=requestAnimationFrame(this.S.bind(this));
11
- var b=this.f;this.o||a.readyState!==a.HAVE_ENOUGH_DATA||(this.o=new yw(a,b));b.clearColor(0,0,0,1);b.clearDepth(1);b.clearStencil(0);b.enable(b.DEPTH_TEST);b.depthFunc(b.LEQUAL);b.frontFace(b.CCW);b.cullFace(b.BACK);b.disable(b.CULL_FACE);b.enable(b.BLEND);b.blendFunc(b.SRC_ALPHA,b.ONE_MINUS_SRC_ALPHA);b.depthMask(!0);b.clearColor(0,0,0,1);b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);if(this.o){var c=this.C;c.a.useProgram(c.f);{c=pw(this.I,this.K,this.G).a;let d;d=c[1];c[1]=c[4];c[4]=d;d=c[2];c[2]=
12
- c[8];c[8]=d;d=c[6];c[6]=c[9];c[9]=d;d=c[3];c[3]=c[12];c[12]=d;d=c[7];c[7]=c[13];c[13]=d;d=c[11];c[11]=c[14];c[14]=d}b.uniformMatrix4fv(this.C.h,!1,this.I.a);c=this.o;c.a.activeTexture(c.a.TEXTURE0);c.a.bindTexture(c.a.TEXTURE_2D,c.f);b.texImage2D(b.TEXTURE_2D,0,b.RGB,b.RGB,b.UNSIGNED_BYTE,a);a=this.X;a.a.bindBuffer(a.a.ARRAY_BUFFER,a.f);a.a.vertexAttribPointer(0,3,a.a.FLOAT,!1,20,0);a.a.vertexAttribPointer(1,2,a.a.FLOAT,!1,20,12);a.a.enableVertexAttribArray(0);a.a.enableVertexAttribArray(1);a.a.drawArrays(a.a.TRIANGLES,
13
- 0,a.h);a=this.o;a.a.bindTexture(a.a.TEXTURE_2D,null);this.C.a.useProgram(null)}}}}ba(a){this.g.debug("Mouse Down. Enable VR mouse interaction");a.preventDefault();if(0===a.button||a.type===iw)a.type===iw?a.touches[0]&&(this.h.x=a.touches[0].clientX,this.h.y=a.touches[0].clientY):(this.h.x=a.clientX,this.h.y=a.clientY),this.g.debug("Mouse Start coordinates:",this.h,a),this.a.addEventListener("mousemove",this.A,!1),this.a.addEventListener(hw,this.A,!1),this.a.addEventListener("mouseup",this.B,!1),this.a.addEventListener("touchend",
14
- this.B,!1)}ca(a){a.preventDefault();var b=a.clientX;let c=a.clientY;a.type===hw&&a.touches[0]&&(b=a.touches[0].clientX,c=a.touches[0].clientY);a=this.h.x-b;const d=this.h.y-c;this.h.x=b;this.h.y=c;b=this.V;const {Cg:e,Dg:f}={Cg:a*b*(this.L?-1:1),Dg:d*b*(this.M?-1:1)};this.j+=e;this.l+=f;uw(this)}ha(a){this.g.debug("Mouse Up. Removing mouse interaction listeners");a.preventDefault();tw(this)}qh(a,b){this.l=b;this.j=a;uw(this)}Wg(){return{x:this.j,y:this.l}}Kh(a){this.H=a;this.F()}};
15
- _.z("clpp.vr.VrPlugin",Aw);Aw.prototype.setCameraFieldOfView=Aw.prototype.Kh;Aw.prototype.getCameraCoordinates=Aw.prototype.Wg;Aw.prototype.moveCamera=Aw.prototype.qh;Aw.Id="vr";_.Yq(new class{create(){return new Aw}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Dw="touchmove",Ew="touchstart",Gw=function(a,b,c){c*=.5;const d=Math.sqrt(a*a+b*b),e=Math.sin(c);return new Fw(a/d*e,b/d*e,0/d*e,Math.cos(c))},Hw=function(a,b){const c=a.x,d=a.y,e=a.a;a=a.f;b.set(1-2*(d*d+e*e),2*(c*d-e*a),2*(c*e+d*a),0,2*(c*d+e*a),1-2*(c*c+e*e),2*(d*e-c*a),0,2*(c*e-d*a),2*(d*e+c*a),1-2*(c*c+d*d),0,0,0,0,1)},Iw=function(a,b){isFinite(b)?(a.x*=b,a.y*=b,a.a*=b):(a.x=0,a.y=0,a.a=0)},Jw=function(a,b){return a.x*b.x+a.y*b.y+a.a*b.a},Kw=function(a,b,c){const d=b.x,e=b.y;
2
+ b=b.a;const f=c.x,g=c.y;c=c.a;a.x=e*c-b*g;a.y=b*f-d*c;a.a=d*g-e*f;return a},Lw=function(a,b,c){b=b.a;c=c.a;const d=a.a;let e=0;do d[4*e]=b[4*e]*c[0]+b[4*e+1]*c[4]+b[4*e+2]*c[8]+b[4*e+3]*c[12],d[4*e+1]=b[4*e]*c[1]+b[4*e+1]*c[5]+b[4*e+2]*c[9]+b[4*e+3]*c[13],d[4*e+2]=b[4*e]*c[2]+b[4*e+1]*c[6]+b[4*e+2]*c[10]+b[4*e+3]*c[14],d[4*e+3]=b[4*e]*c[3]+b[4*e+1]*c[7]+b[4*e+2]*c[11]+b[4*e+3]*c[15];while(4>++e);return a},Nw=function(a){var b=new Mw(0,0,0),c=new Mw(0,0,1);const d=new Mw,e=new Mw,f=new Mw;a=a.a;var g=
3
+ new Mw(0,1,0);f.x=b.x-g.x;f.y=b.y-g.y;f.a=b.a-g.a;g=f.length();Iw(f,1/g);c=Kw(d,c,f);g=c.length();Iw(c,1/g);Kw(e,f,d);a[0]=d.x;a[1]=d.y;a[2]=d.a;a[3]=-Jw(d,b);a[4]=e.x;a[5]=e.y;a[6]=e.a;a[7]=-Jw(e,b);a[8]=f.x;a[9]=f.y;a[10]=f.a;a[11]=-Jw(f,b);a[12]=0;a[13]=0;a[14]=0;a[15]=1},Ow=function(a,b,c){b=a.a.createShader(b?a.a.FRAGMENT_SHADER:a.a.VERTEX_SHADER);a.a.shaderSource(b,c);a.a.compileShader(b);if(!a.a.getShaderParameter(b,a.a.COMPILE_STATUS))throw new _.H(1,9,9004,"Unable to compile GL shader: "+
4
+ a.a.getShaderInfoLog(b));return b},Pw=function(a){a.a&&(a.a.removeEventListener("mousemove",a.A,!1),a.a.removeEventListener(Dw,a.A,!1),a.a.removeEventListener("mouseup",a.B,!1),a.a.removeEventListener("touchend",a.B,!1))},Qw=function(a){const b=Gw(1,0,a.l*Math.PI/180);Hw(Gw(0,1,a.j*Math.PI/180),a.O);Hw(b,a.R);Nw(a.X);Lw(a.Z,a.O,a.X);Lw(a.G,a.R,a.Z)},Fw=class{constructor(a,b,c,d){this.x=a||0;this.y=b||0;this.a=c||0;this.f=d||1}};var Mw=class{constructor(a,b,c){this.x=a||0;this.y=b||0;this.a=c||0}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.a*this.a)}};var Rw=class{constructor(){this.a=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}set(a,b,c,d,e,f,g,h,k,l,m,n,q,u,v,y){const A=this.a;A[0]=a;A[4]=b;A[8]=c;A[12]=d;A[1]=e;A[5]=f;A[9]=g;A[13]=h;A[2]=k;A[6]=l;A[10]=m;A[14]=n;A[3]=q;A[7]=u;A[11]=v;A[15]=y;return this}};var Sw=class{constructor(a){this.a=a;this.f=a.createProgram();this.l=Ow(this,!1,"uniform highp mat4 Mvpm;\nattribute highp vec4 aPosition;\nattribute highp vec2 aTexCoord;\nvarying highp vec2 oTexCoord;\nvoid main()\n{\n gl_Position \x3d Mvpm * aPosition;\n oTexCoord \x3d aTexCoord;\n}\n");this.j=Ow(this,!0,"precision highp float;\nuniform sampler2D Texture0;\nvarying highp vec2 oTexCoord;\nvoid main()\n{\n gl_FragColor \x3d texture2D(Texture0, oTexCoord);\n gl_FragColor.w \x3d 1.0;\n}\n");
5
+ a.attachShader(this.f,this.l);a.attachShader(this.f,this.j);a.bindAttribLocation(this.f,0,"aPosition");a.bindAttribLocation(this.f,1,"aTexCoord");a.linkProgram(this.f);if(!a.getProgramParameter(this.f,a.LINK_STATUS))throw new _.H(1,9,9004,"Unable to initialize shader");a.useProgram(this.f);this.h=a.getUniformLocation(this.f,"Mvpm");a.uniform1i(a.getUniformLocation(this.f,"Texture0"),0);a.useProgram(null)}};var Tw=class{constructor(a){this.a=a;var b=[];let c,d;for(d=0;70>=d;d++){var e=3>=d?d/4/64:67<=d?(63+(d-66)/4)/64:(d-3)/64;var f=(e-.5)*Math.PI;const g=Math.cos(f);for(c=0;128>=c;c++){const h=c/128,k=(.5+h)*Math.PI*2;128===c?(b.push(b[645*d]),b.push(b[645*d+1]),b.push(b[645*d+2])):(b.push(100*Math.cos(k)*g),b.push(100*Math.sin(k)*g),b.push(100*Math.sin(f)));0===d||70===d?b.push(.5):b.push(1-h);b.push(1-e)}}e=[];for(c=0;128>c;c++)for(d=0;70>d;d++)f=5*(129*d+c),e.push(b[f],b[f+1],b[f+2],b[f+3],b[f+
6
+ 4]),f=5*(129*d+c+1),e.push(b[f],b[f+1],b[f+2],b[f+3],b[f+4]),f=5*(129*(d+1)+c),e.push(b[f],b[f+1],b[f+2],b[f+3],b[f+4]),f=5*(129*(d+1)+c),e.push(b[f],b[f+1],b[f+2],b[f+3],b[f+4]),f=5*(129*d+c+1),e.push(b[f],b[f+1],b[f+2],b[f+3],b[f+4]),f=5*(129*(d+1)+c+1),e.push(b[f],b[f+1],b[f+2],b[f+3],b[f+4]);this.h=e.length/5;this.f=a.createBuffer();b=new Float32Array(e);a.bindBuffer(a.ARRAY_BUFFER,this.f);a.bufferData(a.ARRAY_BUFFER,b,a.STATIC_DRAW)}};var Uw=class{constructor(a,b){this.a=b;this.f=this.a.createTexture();b.activeTexture(b.TEXTURE0);b.bindTexture(b.TEXTURE_2D,this.f);b.texImage2D(b.TEXTURE_2D,0,b.RGB,b.RGB,b.UNSIGNED_BYTE,a);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.bindTexture(b.TEXTURE_2D,null)}};var Vw={alpha:!1,depth:!0,stencil:!1,antialias:!0,premultipliedAlpha:!1,preserveDrawingBuffer:!1,devicePixelRatio:1},Ww=class extends _.Fv{constructor(){super();this.o=this.w=this.K=this.I=this.C=this.W=this.G=this.f=this.a=this.m=null;this.g=new _.S("clpp.vr");this.H=70;this.V=1;this.M=this.L=!1;this.F=()=>{if(this.a&&this.f){this.f.viewport(0,0,this.a.width,this.a.height);{const a=this.K.a,b=Math.tan(.5*this.H*Math.PI/180);a[0]=1/(this.a.width/this.a.height*b);a[1]=0;a[2]=0;a[3]=0;a[4]=0;a[5]=1/
7
+ b;a[6]=0;a[7]=0;a[8]=0;a[9]=0;a[10]=2E3/-1999.9;a[11]=200/-1999.9;a[12]=0;a[13]=0;a[14]=-1;a[15]=1}}};this.l=this.j=0;this.h={x:0,y:0};this.O=new Rw;this.R=new Rw;this.X=new Rw;this.Z=new Rw;this.A=this.aa.bind(this);this.B=this.fa.bind(this);this.J=this.da.bind(this)}onPlayerCreated(a){this.g.info("Player created");this.m=a}onContentWillLoad(a){const b=a.getConfiguration();if(b.vr&&b.vr.enable){{var c=b.vr,d=c.fieldOfView;const e=c.sensitivity,f=c.invertHorizontalControl;c=c.invertVerticalControl;
8
+ if(void 0!==d&&_.gh(d))this.H=d;else throw new _.H(1,7,7100,"fieldOfView configuration must be a number");if(void 0!==e&&_.gh(e)&&0<e)this.V=e;else throw new _.H(1,7,7100,"sensitivity configuration must be a positive number");this.L=!!f;this.M=!!c}if(a=a.getSurface())if((d=a.getMedia())&&d.tagName.toLowerCase()===_.w){this.g.info("Initialize VR Surface");if(!this.a){this.a=document.createElement("canvas");this.a.style.width="100%";this.f=this.a.getContext("webgl",Vw)||this.a.getContext("experimental-webgl",
9
+ Vw);if(!this.f)throw new _.H(1,9,9003,"Unable to create GL context");this.G=new Rw;Nw(this.G);this.W=new Tw(this.f);this.C=new Sw(this.f);this.I=new Rw;this.K=new Rw;this.o=this.w=null;this.a.addEventListener(_.Df,this.F)}a.addElementToContainer(this.a,!0,!0);a.hideMediaElement();b.vr.attachMouseListener&&(this.a.addEventListener("mousedown",this.J,!1),this.a.addEventListener(Ew,this.J,!1));this.F();this.S()}else this.g.info("No video element found, can not initialize VR plugin");else this.g.info("No surface found, can not initialize VR plugin")}}onPlayerWillRelease(){this.g.info("Releasing VR plugin resources");
10
+ this.w&&cancelAnimationFrame(this.w);this.h.x=0;this.l=this.j=this.h.y=0;this.f&&(delete this.f,this.f=null);this.a&&(Pw(this),this.a.removeEventListener(_.Df,this.F),this.a.parentElement.removeChild(this.a),this.a.removeEventListener("mousedown",this.J,!1),delete this.a,this.a=null)}onPlayerWillDestroy(){const a=this;return _.x(function*(){a.m=null})}id(){return"vr"}S(){if(this.m&&this.f){var a=this.m.getSurface();if(a&&(a=a.getMedia())&&a.tagName.toLowerCase()===_.w){this.w=requestAnimationFrame(this.S.bind(this));
11
+ var b=this.f;this.o||a.readyState!==a.HAVE_ENOUGH_DATA||(this.o=new Uw(a,b));b.clearColor(0,0,0,1);b.clearDepth(1);b.clearStencil(0);b.enable(b.DEPTH_TEST);b.depthFunc(b.LEQUAL);b.frontFace(b.CCW);b.cullFace(b.BACK);b.disable(b.CULL_FACE);b.enable(b.BLEND);b.blendFunc(b.SRC_ALPHA,b.ONE_MINUS_SRC_ALPHA);b.depthMask(!0);b.clearColor(0,0,0,1);b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);if(this.o){var c=this.C;c.a.useProgram(c.f);{c=Lw(this.I,this.K,this.G).a;let d;d=c[1];c[1]=c[4];c[4]=d;d=c[2];c[2]=
12
+ c[8];c[8]=d;d=c[6];c[6]=c[9];c[9]=d;d=c[3];c[3]=c[12];c[12]=d;d=c[7];c[7]=c[13];c[13]=d;d=c[11];c[11]=c[14];c[14]=d}b.uniformMatrix4fv(this.C.h,!1,this.I.a);c=this.o;c.a.activeTexture(c.a.TEXTURE0);c.a.bindTexture(c.a.TEXTURE_2D,c.f);b.texImage2D(b.TEXTURE_2D,0,b.RGB,b.RGB,b.UNSIGNED_BYTE,a);a=this.W;a.a.bindBuffer(a.a.ARRAY_BUFFER,a.f);a.a.vertexAttribPointer(0,3,a.a.FLOAT,!1,20,0);a.a.vertexAttribPointer(1,2,a.a.FLOAT,!1,20,12);a.a.enableVertexAttribArray(0);a.a.enableVertexAttribArray(1);a.a.drawArrays(a.a.TRIANGLES,
13
+ 0,a.h);a=this.o;a.a.bindTexture(a.a.TEXTURE_2D,null);this.C.a.useProgram(null)}}}}da(a){this.g.debug("Mouse Down. Enable VR mouse interaction");a.preventDefault();if(0===a.button||a.type===Ew)a.type===Ew?a.touches[0]&&(this.h.x=a.touches[0].clientX,this.h.y=a.touches[0].clientY):(this.h.x=a.clientX,this.h.y=a.clientY),this.g.debug("Mouse Start coordinates:",this.h,a),this.a.addEventListener("mousemove",this.A,!1),this.a.addEventListener(Dw,this.A,!1),this.a.addEventListener("mouseup",this.B,!1),this.a.addEventListener("touchend",
14
+ this.B,!1)}aa(a){a.preventDefault();var b=a.clientX;let c=a.clientY;a.type===Dw&&a.touches[0]&&(b=a.touches[0].clientX,c=a.touches[0].clientY);a=this.h.x-b;const d=this.h.y-c;this.h.x=b;this.h.y=c;b=this.V;const {Lg:e,Mg:f}={Lg:a*b*(this.L?-1:1),Mg:d*b*(this.M?-1:1)};this.j+=e;this.l+=f;Qw(this)}fa(a){this.g.debug("Mouse Up. Removing mouse interaction listeners");a.preventDefault();Pw(this)}Bh(a,b){this.l=b;this.j=a;Qw(this)}fh(){return{x:this.j,y:this.l}}Vh(a){this.H=a;this.F()}};
15
+ _.z("clpp.vr.VrPlugin",Ww);Ww.prototype.setCameraFieldOfView=Ww.prototype.Vh;Ww.prototype.getCameraCoordinates=Ww.prototype.fh;Ww.prototype.moveCamera=Ww.prototype.Bh;Ww.Id="vr";_.ur(new class{create(){return new Ww}});};f.call(g, window);