@castlabs/prestoplay 6.17.1 → 6.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/CHANGELOG.md +30 -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 +111 -111
  6. package/cjs/cl.conviva.js +33 -33
  7. package/cjs/cl.core.js +566 -558
  8. package/cjs/cl.crypto.js +9 -9
  9. package/cjs/cl.dash.js +75 -74
  10. package/cjs/cl.externs.js +46 -46
  11. package/cjs/cl.freewheel.js +24 -24
  12. package/cjs/cl.hls.js +71 -69
  13. package/cjs/cl.hlssmpte.js +6 -6
  14. package/cjs/cl.htmlcue.js +29 -29
  15. package/cjs/cl.ima.js +23 -23
  16. package/cjs/cl.mse.js +311 -311
  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 +15 -15
  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 +69 -69
  26. package/cjs/cl.ttml.js +28 -28
  27. package/cjs/cl.verimatrix.js +5 -5
  28. package/cjs/cl.vimond.js +13 -13
  29. package/cjs/cl.vr.js +19 -19
  30. package/cjs/cl.vtt.js +14 -14
  31. package/cjs/cl.youbora.js +18 -18
  32. package/cl.adobe.js +3 -3
  33. package/cl.airplay.js +3 -3
  34. package/cl.broadpeak.js +5 -5
  35. package/cl.cast.js +87 -87
  36. package/cl.conviva.js +27 -27
  37. package/cl.core.js +456 -450
  38. package/cl.crypto.js +8 -8
  39. package/cl.dash.js +70 -69
  40. package/cl.externs.js +46 -46
  41. package/cl.freewheel.js +19 -19
  42. package/cl.hls.js +72 -72
  43. package/cl.hlssmpte.js +5 -5
  44. package/cl.htmlcue.js +26 -26
  45. package/cl.ima.js +17 -17
  46. package/cl.mse.js +274 -273
  47. package/cl.muxdata.js +13 -13
  48. package/cl.onboard.js +4 -4
  49. package/cl.persistent.js +10 -10
  50. package/cl.playlist.js +5 -5
  51. package/cl.sessions.js +10 -10
  52. package/cl.simid.js +13 -13
  53. package/cl.smooth.js +59 -59
  54. package/cl.thumbnails.js +19 -19
  55. package/cl.tizen.js +57 -57
  56. package/cl.ttml.js +22 -22
  57. package/cl.verimatrix.js +4 -4
  58. package/cl.vimond.js +8 -8
  59. package/cl.vr.js +15 -15
  60. package/cl.vtt.js +12 -12
  61. package/cl.youbora.js +15 -15
  62. package/package.json +2 -2
  63. package/typings.d.ts +37 -3
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 DM="An unknown error occurred while trying to get volume",EM="Cannot get loading rendition due to platform limitations",FM="SecurityError",GM="The require privilege is: http://tizen.org/privilege/tv.audio",HM="|STARTBITRATE\x3d",IM=function(a,b,c){const d=e=>{c.call(a,e);a.removeEventListener(b,d)};a.addEventListener(b,d)},LM=function(a){return _.x(function*(){if(a.a!==_.yd&&a.a!==_.wd)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.$c)throw new _.H(_.F,6,6012,`No license server given for ${a.a}`);try{a.a===_.yd?yield JM(a):yield KM(a,b),a.o={keySystem:a.a,licenseServerUri:b.$c,distinctiveIdentifierRequired:!1,persistentStateRequired:b.re,audioRobustness:"",videoRobustness:"",serverCertificate:null,initData:[],keyIds:[],periodId:null}}catch(c){throw a.h.error(`Error while configuring CDM for ${a.a}`,c),new _.H(_.F,6,6005,{message:JSON.stringify(c)});}})},NM=function(a,b){_.x(function*(){var c=a.f.get(a.a);
3
- a.h.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=_.Pi([b.serverurl&&""!==b.serverurl?b.serverurl:c.$c],_.Mi());c.type=3;c.body=e.buffer;c.method="POST";try{var f=yield a.D.sb.fetch(c).P;if(a.j){var g=_.J(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.h.debug("Widevine license params",
4
- k);try{webapis.avplay.setDrm(MM,"widevine_license_data",k)}catch(l){a.h.error("License response rejected by CDM");const m=new _.H(_.F,6,6008,{browserError:JSON.stringify(l)});a.D.onError(m)}}}catch(h){a.h.error("License request failed.",JSON.stringify(h)),g=new _.H(_.F,6,6007,{message:_.Sa,url:h.data.url,status:h.data.status||NaN,response:h.data.response||"",headers:h.data.headers||{}},h),a.D.onError(g)}})},JM=function(a){return _.x(function*(){try{webapis.avplay.setDrm(MM,"Initialize",""),webapis.avplay.setDrm(MM,
5
- "widevine_app_session",a.l.id),webapis.avplay.setDrm(MM,"widevine_data_type",a.l.type)}catch(b){throw b;}})},KM=function(a,b){return _.x(function*(){var c={};c[OM]=!b.re;c[PM]=b.$c;""!==b.customData&&(c[QM]=b.customData);c=JSON.stringify(c);a.h.debug("PlayReady properties: ",c);try{webapis.avplay.setDrm(RM,"SetProperties",c)}catch(d){throw d;}})},TM=function(a,b){if(a.f!==b)if(a.f===_.Sn&&b!==_.Tn)a.h.debug(_.Xz+`${SM(b)}`);else{var c=(new Date).getTime();a.j=a.f;a.f=b;a.f===_.On?(a.o=(new Date).getTime(),
6
- a.m.trigger(new _.E(_.Qc,{detail:{bufferedTimeMS:-1,reason:a.g}}))):a.j===_.On&&a.m.trigger(new _.E(_.Pc,{detail:{bufferedTimeMS:c-a.o,reason:a.g}}));b={currentState:a.f,previousState:a.j,timeSinceLastStateChangeMS:c-a.w};a.w=c;a.m.trigger(new _.E(_.Jf,{detail:b}));a.h.debug("State changed:",SM(a.j),"-\x3e",SM(a.f))}},SM=function(a){return Object.keys(_.Rn)[a]},WM=function(a){if(a.l){var b=a.a.getState(),c=a.f;switch(b){case UM:c=_.Wn;break;case VM:c=_.Vn;break;default:a.m.isEnded()?c=_.Ln:a.h.debug("Inconsistent AVPlay playback state:",
7
- b)}TM(a,c)}},XM=function(a){return _.x(function*(){const b=a.m.getConfiguration();let c;(c=yield _.qr(a.B.url,a.m.getNetworkEngine(),b.manifest.attemptParameters,a.B.type||null))&&c.configure(b.manifest);return c})},YM=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},ZM=function(a){const b=document.createElement(_.w),c=new _.qG,d=new _.xF(()=>null),e=a.m.getTextDisplayer();return new _.sG(b,c,e,d,a.m.getConfiguration())},$M=function(a){const b=
8
- {configuration:{},Ab:()=>a.m.getPosition(),Z:a.g,sb:a.m.getNetworkEngine(),me:a.G.bind(a),le:a.F.bind(a),onError:a.U.bind(a),wf:()=>{},onEvent:()=>{},zf:a.H.bind(a),Hd:()=>{},ud:()=>new _.jH,Qd:()=>!1,Lc:null};return new _.KG(a.a,b)},aN=function(a){const b=a.m.getPosition();let c=null;for(const d of a.a.periods)d.startTime<=b&&(c=d);return c},bN=function(a){a.h.debug("getTextStreams()",a.a);if(a.a){var b=[],c=a.a.periods;a.h.debug("getting text streams");for(var d=0;d<c.length;d++)if(a.h.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 _.ej(String(c++),_.K);e.mimeType=a[d].mimeType;e.language=a[d].language;e.roles=a[d].roles;e.kind=a[d].kind||_.EA;const f=new _.mj(String(a[d].id),e);f.bandwidth=a[d].bandwidth||null;e.renditions.push(f);b.push(e)}return b},cN=function(a){if(a.g&&!a.g.getTextDisplayer().isTextVisible())return null;if(a.f){const b=_.tE(a.f,_.G);let c=null;if(b){a=bN(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},dN=function(a,b){a.h.debug("Set active track",b);if(b&&(a.o=b.language,a.A=b.roles[0]||"",a.C=b.kind===_.Vd,a.a&&a.f)){a.setTextVisibility(!0);const c=aN(a),d=b.renditions[0];(b=c.textStreams.find(e=>String(e.id)===d.id))?(a.w?(a.h.debug("Switching period defer text selection"),a.l=b):(_.IE(a.f,b,!0,0),a.m.trigger(new _.E(_.Hk))),a.o=b.language):a.h.error(_.Wz,d.id)}},eN=function(a){const b=
11
- a.ma();b&&a.m.trigger(new _.E(_.Mc,{detail:{width:b.width,height:b.height,bandwidth:b.bandwidth,rendition:b}}))},fN=function(a,b){a.m.trigger(new _.E(_.og,{details:{width:b.width,height:b.height,bandwidth:b.bandwidth,track:b.track,abrSelection:a.a.o}}))},gN=function(a,b){let c=null;try{c=JSON.parse(b)}catch(d){a.h.warn("Couldn't retrieve extra infos from stream."),c=null}return c},hN=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++)_.Vg(a[d].renditions[e],
12
- b,Object.keys(b))&&c.push(a[d].renditions[e]);return c[0]||null},iN=function(a){const b=a.m.getConfiguration();var c=_.xh(b.preferredAudioLanguage||[]);const d=a.f[_.L]||[];if(d.length){var e=null;c.some(g=>{e=_.YA(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.h.debug("Setting audio track with preferred language:",e);a.ta(c)}else a.h.debug("Preferred language(s) not available")}else a.h.debug("Could not set preferred audio language")},
13
- oN=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===jN),f=b.filter(l=>l.type===kN);const g=[];for(var h=0;h<f.length;h++){const l=gN(a,f[h].extra_info);if(l){var k=_.Zh(l.language||_.Xf);k=_.aj(k);k=c(g,k);k||(k=new _.ej(String(a.o++),_.L),g.push(k));k.renditions.push(lN(f[h].index,l,k))}else a.h.warn("Skipping audio stream with no extra info")}c=new _.ej(String(a.o++),_.N);for(f=0;f<
14
- e.length;f++)(h=gN(a,e[f].extra_info))?c.renditions.push(mN(e[f].index,h,c)):a.h.warn("Skipping video stream with no extra info");e=[];e=a.g?bN(a.g):nN(a,b);d[_.N]=[c];d[_.L]=g;d[_.K]=e;return d},rN=function(a,b){if(b===_.K&&a.g)return cN(a.g);var c=pN(a.a)||[];if(0===c.length)return null;c=c.filter(e=>e.type===b.toUpperCase())[0];var d=null;b===_.N&&(d=gN(a,c.extra_info),d=hN(a,{width:d.Width,height:d.Height}));b===_.L&&(c?(d=qN(a,c,_.L),a.j=d):d=a.j);b===_.K&&(c?(d=qN(a,c,_.K),a.l=d):d=a.l);return d},
15
- uN=function(a,b){if(b){const c=b.track.type.toUpperCase();sN(a.a,c,Number(b.id)).then(()=>{c===kN&&(a.j=b,a.m.trigger(new _.E(_.Gk)));c===tN&&(a.l=b,a.m.trigger(new _.E(_.Hk)))}).catch(()=>{a.h.error("Could not select "+c+" track.")})}else a.h.debug("Must provide valid rendition")},lN=function(a,b,c){const d=_.Zh(b.language||_.Xf);c.language=_.aj(d);c.originalLanguage=d;c.channelsCount=b.channels?Number(b.channels):null;c.mimeType=_.Ic;a=new _.mj(String(a),c);a.track=c;a.codec=b.fourCC||null;a.bandwidth=
16
- b.bit_rate||null;return a},mN=function(a,b,c){c.mimeType=_.ig;a=new _.mj(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},vN=function(a,b,c){b=_.Zh(b.track_lang||_.Xf);c.mimeType="text/ttml";c.language=_.aj(b);c.originalLanguage=b;c.kind=_.EA;return new _.mj(String(a),c)},nN=function(a,b){b=b.filter(d=>d.type===tN);const c=[];for(let d=0;d<b.length;d++){const e=gN(a,b[d].extra_info);if(!e){a.h.warn("Skipping text stream with no extra info");
17
- continue}const f=new _.ej(String(a.o++),_.K);f.renditions.push(vN(b[d].index,e,f));c.push(f)}return c},qN=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},wN=function(a){return a.f&&a.a?a.a.uh:webapis.avplay.getTotalTrackInfo()},yN=function(a,b,c){a.h.debug("switchVideoTrack()");try{const d={estimatedBandwidth:parseInt(webapis.avplay.getStreamingProperty("CURRENT_BANDWITH"),
18
- 10),currentBandwidth:b,nextBandwidth:c,currentPosition:a.getPosition()};a.a=xN(a);a.f=!0;webapis.avplay.stop();webapis.avplay.close();return a.load(a.m.getConfiguration(),d).then(()=>{const e=a.a.Ue;a.f=!1;a.a=null;return e===VM?a.pause():a.play()})}catch(d){return Promise.reject(d)}},zN=function(a,b){var c=a.m.getTextDisplayer();c&&c.setTextVisibility(b);c=a.m.g;try{c||webapis.avplay.setSilentSubtitle(!b)}catch(d){a.h.debug("Could not set text track visibility",d)}},sN=function(a,b,c){b=b.toUpperCase();
19
- b===tN&&zN(a,!0);const d=a.j[b];d&&(d.Kd.stop(),a.j[b]=null,a.h.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.h.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,Re:0,Kd:new _.Qj(()=>g(h,c,!0))}),(k=a.j[h])&&3>k.Re?(!a.w&&++k.Re,k.Kd.fa(a.w?.5:.25)):(a.h.debug("Could not set track after multiple attempts.Giving up..."),
20
- k&&k.Kd.stop(),a.j[h]=null,f())}};g(b,c)})},pN=function(a){return a.f&&a.a?a.a.lg:webapis.avplay.getCurrentStreamInfo()},AN=function(a){return _.x(function*(){tizen.systeminfo.getPropertyValue("DISPLAY",b=>{a.A=b.resolutionWidth/1920;a.h.debug("Display resolution ratio: ",a.A)},b=>{a.h.debug("Could not load DISPLAY property");throw b;})})},CN=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(BN,{currentTime:b}))},onevent:a.K.bind(a),onsubtitlechange:a.N.bind(a),ondrmevent:a.J.bind(a),onerror:a.U.bind(a)})}catch(b){a.h.error(b)}},DN=function(a){const b=!!a.m.getTrackManager().Ea();try{webapis.avplay.setSilentSubtitle(!b)}catch(c){a.h.debug("Could not set AVPlay subtitle config",c)}},EN=function(a,b){try{const c=b.estimatedBandwidth||0,d=b.currentBandwidth||0;a.h.debug({estimatedBandwidth:c,Jh:d});0!==c&&0!==d&&c>=1.15*d&&webapis.avplay.setStreamingProperty("ADAPTIVE_INFO",
22
- HM+d)}catch(c){a.h.debug(c)}},FN=function(a,b){try{webapis.avplay.setStreamingProperty("ADAPTIVE_INFO","|BITRATES\x3d"+b+HM+b)}catch(c){throw a.h.debug("Could not set fixed bandwidth",c),c;}},GN=function(a){let b=null;try{b=tizen.tvaudiocontrol.isMute()}catch(c){switch(c.name){case FM:a.h.warn("The application doesn't have the privilege to get the mute state.",GM);break;default:a.h.warn(DM,c)}}return!!b},xN=function(a){return{position:a.getPosition(),state:a.m.getState(),Ue:a.getState(),playbackRate:a.getPlaybackRate(),
23
- isLive:a.isLive(),duration:a.getDuration(),isMuted:GN(a),volume:a.getVolume(),uh:wN(a),lg:pN(a)}},HN=function(){return new Promise((a,b)=>{if(window.webapis)a();else{const c=document.createElement("script");IM(c,"load",d=>a(d));IM(c,_.r,d=>b(d));c.src="$WEBAPIS/webapis/webapis.js";document.querySelector("head").appendChild(c)}})},IN=function(a){return _.x(function*(){yield HN();const b=new Promise(c=>{(new _.Qj(c)).fa(5)});if(!(yield Promise.race([AN(a).then(()=>!0),b.then(()=>!1)])))return a.h.debug("Took to long for the SDK to be ready"),
24
- Promise.reject("SDK Timeout")})},JN=function(a){return _.x(function*(){a.h.debug("avplay.prepare()");return new Promise((b,c)=>{try{webapis.avplay.prepareAsync(()=>{a.h.debug("AVPlay is ready!");DN(a);b()},d=>{a.h.debug("prepareAsync failed",d);c(d)})}catch(d){a.h.debug("Failed to prepare media player for playback"),c(d)}})})},KN=function(a,b){try{tizen.tvaudiocontrol.setMute(b)}catch(c){switch(c.name){case FM:a.h.warn("The application does not have the privilege to set mute.",GM);break;default:a.h.warn(DM,
25
- c)}}},PN=function(a,b,c){return _.x(function*(){a.l=_.Zn(b);const d=a.F,e=c||{estimatedBandwidth:0,currentBandwidth:0,nextBandwidth:null,currentPosition:0};a.h.debug(`Loading manifest URL: ${a.l[d].url}`);let f=b.startTime||void 0;a.f&&(a.trigger(new _.E(LN)),f=c.currentPosition);try{let g=a.l[d].url;if(a.l[d].type===_.yc&&!g.includes(".mpd")){const h=new URL(g);h.searchParams.append("cl-ext",".mpd");g=h.toString()}webapis.avplay.open(g);e.nextBandwidth?(FN(a,e.nextBandwidth),a.o=!1):(a.o||EN(a,e),
26
- a.o=!0);CN(a);if(b.drm&&b.drm.env){const h={onError:k=>a.m.onError(k),sb:a.m.getNetworkEngine()};a.g=new MN(b.drm,h);yield a.g.init()}else a.h.debug("No DRM configuration was provided. Assuming clear content");a.f||a.trigger(new _.E(NN));yield JN(a);a.f||a.trigger(new _.E(ON));f&&typeof f===_.t&&0<f&&a.seek(f).catch(h=>{a.h.debug("Couldn't set start position",h)});a.f||(b.volume&&a.setVolume(b.volume),b.muted&&KN(a,b.muted),b.autoplay&&a.m.play().catch(h=>{a.h.debug("Autoplay failed",h)}))}catch(g){throw a.h.debug("Error while attempting to load source."),
27
- g;}})},QN=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.h.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.h.debug("Could not apply dimension. Player state "+a.a.getState())},MN=class{constructor(a,
28
- b){this.g=a;this.o=null;this.a=_.Be;this.l=null;this.j=!1;this.f=new Map;this.D=b;this.h=new _.R("clpp.tizen.DrmEngine")}init(){const a=this;return _.x(function*(){var b=_.kl[a.g.env]||null;if(!b)throw a.h.debug(_.va,_.yb+a.g.env+_.aa),new _.H(_.F,6,6015,`DRM environment '${a.g.env}' is missing.`);a.l={id:String(Math.floor(1E4*Math.random())),type:"MPEG-DASH"};var c=Object.keys(a.g.customData||{}).length?btoa(JSON.stringify(a.g.customData)):"";b=_.ml(b,a.g.customData);const d=b[_.wd];d&&a.f.set(_.wd,
29
- {$c:d.licenseUrl||"",customData:c,re:!1});(b=b[_.yd])&&a.f.set(_.yd,{$c:b.licenseUrl||"",customData:c,re:!1});if(0===a.f.size)throw new _.H(_.F,6,6E3);if((c=a.g.preferredDrmSystem)&&a.f.get(c))a.a=c;else if(a.f.get(_.wd))a.a=_.wd;else if(a.f.get(_.yd))a.a=_.yd;else throw new _.H(_.F,6,6001,"Configuration for the target system is missing.");yield LM(a);a.j=!0})}release(){const a=this;return _.x(function*(){a.j=!1;a.o=null;a.a=_.Be;a.l=null;a.f=new Map})}getDrmInfo(){return this.o}},OM="DeleteLicenseAfterUse",
30
- PM="LicenseServer",QM="CustomData";var WN=class{constructor(a){this.m=a;this.a=this.m.a;this.f=_.Tn;this.j=_.rt;this.w=(new Date).getTime();this.l=!1;this.o=-1;this.g=2;this.h=new _.R("clpp.tizen.StateManager")}initialize(){this.a.on(LN,this.C,this);this.a.on(RN,this.B,this);this.a.on(SN,this.A,this);this.a.on(NN,this.H,this);this.a.on(ON,this.G,this);this.a.on(TN,this.F,this)}release(){TM(this,_.Tn);this.l=!1;this.o=-1;this.g=2}destroy(){this.release();this.a.off(LN,this.C);this.a.off(RN,this.B);this.a.off(SN,this.A);this.a.off(NN,
31
- this.H);this.a.off(ON,this.G);this.a.off(TN,this.F);this.m=this.a=null}C(){this.h.debug("Buffering start. Player state: ",this.a.getState());this.g=this.a.B?1:2;TM(this,_.On)}B(a){this.h.debug("Buffering progress: "+a.percent+" %. Player state: ",SM(this.f))}A(){this.h.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()===UN;if(!a&&b){TM(this,_.Vn);return}}if(a=this.f!==_.Un)a=this.a.getState(),a=a===
32
- UM||a===VM;a&&WM(this)}H(){this.h.debug("Preparing starts. AVPlay State: ",this.a.getState());this.a.getState()===VN?TM(this,_.Un):this.h.error("AVPlay prepares while state is not IDLE")}G(){this.h.debug("Preparing ends: AVPlay state:",this.a.getState())}F(){TM(this,_.Ln)}getState(){return this.f}};var XN=class{constructor(){this.o=this.A=this.f=this.g=this.B=this.m=this.j=this.a=null;this.C=!1;this.w=!0;this.l=null;this.h=new _.R("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 XM(b),b.j){var c={configurationId:"",networkingEngine:b.m.getNetworkEngine(),filterNewPeriod:()=>{},filterAllPeriods:()=>{},onTimelineCueAdded:()=>{},onEvent:()=>{},onError:()=>{}};try{b.a=yield b.j.start(a.url,c)}catch(d){b.h.warn(d);try{b.a=yield b.j.start(a.url.replace("https://",
33
- "http://"),c)}catch(e){b.h.error(e),b.a=null}}if(b.a&&YM(b.a)){b.g=ZM(b);try{yield b.g.open();b.f=$M(b);const d=b.m.getConfiguration();b.f.g=d.streaming;b.o=d.preferredTextLanguage;b.A=d.preferredTextRole;b.C=d.preferForcedSubtitles}catch(d){b.h.debug("Could not setup media source..."),b.g=null,b.f=null,b.j=null,b.a=null}}}else b.h.debug("Could not find manifest parser for source. Make sure parsers are registered.");else b.h.debug("Text streamer is not initialized. Will not load()")})}G(a){this.h.debug(_.vA,
34
- a);this.w=!0;let b=_.$C(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.h.debug("canSwitch_");this.w=!1;this.l&&(_.IE(this.f,this.l,!0,0),this.l=null)}U(){this.h.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.h.error("Error while starting streaming engine",b)}})}setTextVisibility(a){this.h.debug("Set text visibility",
35
- a);this.g&&this.g.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.g&&(yield a.g.destroy(),a.g=null)})}};var W=class extends _.S{constructor(){super();this.g=this.a=this.m=null;this.f={};this.h=new _.R("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 YN:0<Object.keys(this.f).length||(this.h.debug("Loading track manager!"),this.load());b=webapis.avplay.getCurrentStreamInfo();0<b.length&&(b=+gN(this,b[0].extra_info).Bit_rate,b=hN(this,{bandwidth:b}))&&(this.w=b,fN(this,b));break;case ZN:eN(this);break;default:this.h.debug("Event type: "+
36
- b+" data: "+a)}}A(a){a.detail.currentState===_.Wn&&this.m.off(_.Jf,this.A)}initialize(a){this.m=a;this.a=this.m.a;this.m.on(_.Jf,b=>{this.B||(b=b.detail,b.currentState===_.Wn&&(this.h.debug("Current state",b.currentState),this.B=!0,iN(this)))});this.a.on($N,this.C,this)}release(){this.f={};this.g=this.w=this.l=this.j=null;this.B=!1;this.o=1}load(){if(this.a&&!(0<Object.keys(this.f).length)){this.g=this.m.g;this.m.off(_.Jf,this.A);this.m.on(_.Jf,this.A,this);try{const a=wN(this.a);this.f=oN(this,a);
37
- const b=this.f[_.L]||[];b.length&&(this.j=b[0].renditions[0]||null);eN(this)}catch(a){this.h.debug("Could not load track manager")}}}destroy(){this.a.off($N,this.C);this.a=this.m=null}getVideoTracks(){return this.f[_.N]||[]}getAudioTracks(){return this.f[_.L]||[]}ia(){return this.f[_.K]||[]}ma(){return rN(this,_.N)}Na(){return rN(this,_.L)}Ea(){return rN(this,_.K)}$a(){return this.w}lb(){this.h.info(EM);return null}mb(){this.h.info(EM);return null}Fa(){const a=this.ma();return a?a.track:null}la(){const a=
38
- this.Na();return a?a.track:null}qa(){const a=this.Ea();return a?a.track:null}gb(a){null===a?(a=this.ma(),yN(this.a,a.bandwidth,null).then(()=>{eN(this)})):0<a.renditions.length&&this.Va(a.renditions[0])}ta(a){a?uN(this,a.renditions[0]):this.h.warn("Cannot disable audio tracks on this platform.","Consider muting audio instead...")}Ha(a){a?(a=a.renditions[0],this.g?dN(this.g,a.track):uN(this,a)):(this.h.debug("Disabling text tracks"),this.l=null,zN(this.a,!1),this.m.trigger(new _.E(_.Hk)))}Va(a){const b=
39
- this.ma();this.a.o||a.width!==b.width||a.height!==b.height||a.bandwidth!==b.bandwidth?(this.w=a,fN(this,a),yN(this.a,b.bandwidth,a.bandwidth).then(()=>{eN(this)}).catch(c=>{const d=new _.H(_.F,7,7200,{tizenerror:c});this.h.debug("Error while switching video track",c);this.m.onError(d)})):this.h.debug("Trying to switch to already active rendition. Doing nothing...")}eb(a){uN(this,a)}fb(a){this.g?dN(this.g,a.track):uN(this,a)}addTextTrack(){}oa(){return this.a.o}};W.prototype.isAbrEnabled=W.prototype.oa;
40
- W.prototype.addTextTrack=W.prototype.addTextTrack;W.prototype.setTextRendition=W.prototype.fb;W.prototype.setAudioRendition=W.prototype.eb;W.prototype.setVideoRendition=W.prototype.Va;W.prototype.setTextTrack=W.prototype.Ha;W.prototype.setAudioTrack=W.prototype.ta;W.prototype.setVideoTrack=W.prototype.gb;W.prototype.getTextTrack=W.prototype.qa;W.prototype.getAudioTrack=W.prototype.la;W.prototype.getVideoTrack=W.prototype.Fa;W.prototype.getLoadingTextRendition=W.prototype.mb;
41
- W.prototype.getLoadingAudioRendition=W.prototype.lb;W.prototype.getLoadingVideoRendition=W.prototype.$a;W.prototype.getTextRendition=W.prototype.Ea;W.prototype.getAudioRendition=W.prototype.Na;W.prototype.getVideoRendition=W.prototype.ma;W.prototype.getTextTracks=W.prototype.ia;W.prototype.getAudioTracks=W.prototype.getAudioTracks;W.prototype.getVideoTracks=W.prototype.getVideoTracks;var dO=class extends _.Xs{constructor(a){super();this.m=a;this.g=null;this.h=new _.R("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(LN))}H(a){this.w=!0;this.trigger(new _.E(RN,{percent:a}))}G(){this.w=!1;this.trigger(new _.E(SN))}L(){this.trigger(new _.E(TN))}K(a,b){this.trigger(new _.E($N,{eventid:a,data:b}))}N(a,b,c,d,e){this.trigger(new _.E(aO,{duration:a,text:b,subtitleType:c,
42
- attriCount:d,attributes:e}))}J(a,b){this.trigger(new _.E(bO,{drmType:a,drmData:b}));this.g&&(a=this.g,a.j&&(a.a===_.yd&&"Challenge"===b.name?NM(a,b):"DrmError"===b.name&&(a.h.debug("DrmError event",b),b=new _.H(_.F,6,6005,{message:JSON.stringify(b)}),a.D.onError(b))))}U(a){this.trigger(new _.E(cO,{eventType:a}))}play(){const a=this.getState(),b=()=>new Promise((c,d)=>{let e=null;const f=()=>{c();clearTimeout(e)};this.one(BN,f,this);e=setTimeout(()=>{this.off(BN,f);d("Timeout")},3E4)});if(a===VN)return(new Promise((c,
43
- d)=>{webapis.avplay.prepareAsync(()=>{DN(this);c(webapis.avplay.play())},e=>{this.trigger(new _.E(cO));d(e)})})).then(()=>b());if(a===VM||a===UN)try{return webapis.avplay.play(),b()}catch(c){return Promise.reject(c)}return a===UM?Promise.resolve():Promise.reject("Player is in invalid state")}pause(){try{webapis.avplay.pause()}catch(a){Promise.reject(a)}return this.getState()===VM?Promise.resolve():Promise.reject()}setPlaybackRate(a){const b=this.getState();if(b===UN||b===UM||b===VM){try{webapis.avplay.setSpeed(a),
44
- this.C=a}catch(c){return this.h.debug("Error while trying to set playback rate",c),this.setPlaybackRate(this.C)}return!0}this.h.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.h.debug("configure()",b||"");try{yield IN(c),yield PN(c,a,b)}catch(d){throw new _.H(_.F,7,7003,null,d);}})}getState(){if(this.f&&this.a)return this.a.Ue;try{return webapis.avplay.getState()}catch(a){this.U(JSON.stringify(a))}}seek(a){const b=
45
- 1E3*a;return new Promise((c,d)=>{this.B=!0;this.m.trigger(new _.E(_.cg));webapis.avplay.seekTo(b,()=>{this.B=!1;this.m.trigger(new _.E(_.bg));c()},()=>{this.B=!1;d()})})}getPosition(){if(this.f&&this.a)return this.a.position;try{return webapis.avplay.getCurrentTime()/1E3}catch(a){this.U(JSON.stringify(a))}}getDuration(){if(this.f&&this.a)return this.a.duration;try{return webapis.avplay.getDuration()/1E3}catch(a){this.U(JSON.stringify(a))}}release(){return new Promise((a,b)=>{try{this.g&&(this.g.release(),
46
- this.g=null);webapis.avplay.stop();webapis.avplay.close();for(const c in this.j){const d=this.j[c];d&&d.Kd.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 FM:this.h.debug("The application does not have the privilege to get the volume.",GM);break;default:this.h.debug(DM,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.h.warn("Invalid value passed for setVolume.",
47
- "The passed value value should be in the range of 0 to 1.");break;case FM:this.h.warn("The application does not have the privilege to set the volume.",GM);break;default:this.h.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.U(JSON.stringify(a))}}stop(){try{webapis.avplay.stop()}catch(a){this.h.debug(a)}}getDrmInfo(){this.g&&this.g.getDrmInfo();return null}setSourceIndex(a){this.F=
48
- a}getSourceIndex(){return this.F}getLoadedSource(){return this.l&&this.l[this.getSourceIndex()]}},VN="IDLE",UN="READY",UM="PLAYING",VM="PAUSED",jN=_.Rb,kN="AUDIO",tN="TEXT",ZN="PLAYER_MSG_RESOLUTION_CHANGED",YN="PLAYER_MSG_BITRATE_CHANGE",RM="PLAYREADY",MM="WIDEVINE_CDM";var hO=class extends _.Xs{constructor(){super();this.a=new dO(this);this.f=new WN(this);this.configuration=this.B=_.Rk();this.w=null;this.h=new _.R("clpp.tizen.Player");this.j=null;this.l=new W;this.C=new _.Yo;this.o=this.g=null;this.A=!1}H(){this.h.debug("On Stream completed. Current time: ",this.getPosition());this.trigger(new _.E(_.Ud));this.configuration.loop?this.seek(this.configuration.startTime||0).catch(()=>{this.h.debug("Could not loop playback")}):this.a.stop()}F(a){this.trigger(new _.E(_.Tf,
49
- {currentTime:a.currentTime/1E3}))}I(a){const b=this.a.getPosition(),c=b+a.duration/1E3;let d=a.text||"";this.h.debug("Got subtitles: ",d,"start:",b,"end:",c,a);(d=_.yi(d))&&this.o.append([new _.ss(b,c,d)],[])}G(a){this.h.debug("DRM event: "+a.drmType+", data: "+a.drmData)}J(){this.A||(this.h.debug("Initial buffering completed..."),this.A=!0)}U(a){this.h.debug(`Error: TYPE: ${a.eventType}`);TM(this.f,_.Sn);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(TN,this.H,this);this.a.on(BN,this.F,this);this.a.on(aO,this.I,this);this.a.on(bO,this.G,this);this.a.on(cO,this.U,this);this.a.on(SN,this.J,this);this.f.initialize();this.l.initialize(this);this.h.debug("Initializing player surface");this.w.hideMediaElement();a=eO;eO+=1;a="__clpp_tizen_player_"+a;this.j=_.ro(_.Ce,{id:a,type:"application/avplayer"});this.w.addElementToContainer(this.j,!0);var c=this.w.getMedia();if(c){a=this.j;{b=[_.zg,_.Yd,"position",
51
- _.ee,"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}_.to(a,d);QN(this)}}getSurface(){return this.w}getConfiguration(){return this.configuration}getTimeline(){return null}setupPlaylist(){return Promise.reject(_.qb)}appendLoad(){return Promise.reject(_.qb)}seekWith(){return Promise.reject(_.qb)}destroy(){const a=this;return _.x(function*(){yield a.release();a.a.off(TN,a.H);a.a.off(BN,
52
- a.F);a.a.off(aO,a.I);a.a.off(bO,a.G);a.a.off(cO,a.U);a.a.off(SN,a.J);a.g&&(yield a.g.destroy(),a.g=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 fO}getPlaybackRate(){return this.a.getPlaybackRate()}setDrmCustomDataModifier(){}setCdnErrorCallback(){}detach(){}setPlaybackRate(a){this.a.setPlaybackRate(a)}getPosition(){return this.getMediaPosition()}getMediaPosition(){return 0<(this.configuration.startTime||0)&&!this.A?0:this.f.getState()===
53
- _.Ln?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.h.warn(_.qa);return new _.Ws}getTrackManager(){return this.l}unload(){return this.a.release().then(()=>
54
- {this.l.release()})}release(){const a=this;return _.x(function*(){a.g&&(yield a.g.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=_.Tk(b.B,a);var c=_.Bn(b.configuration,[_.$d,"native"]);b.o=c.create(b);c=_.Zn(b.configuration)[0];if(b.configuration.tizen&&b.configuration.tizen.sideStreamText){b.g=new XN;b.g.initialize(b);try{yield b.g.load(c),b.g.start()}catch(d){b.h.error(d)}}try{yield b.a.load(b.configuration)}catch(d){throw b.onError(d),
55
- d;}b.l.load()})}play(){this.trigger(new _.E(_.Qe));QN(this);return this.a.play().then(()=>{WM(this.f)})}pause(){return this.a.pause().then(()=>{WM(this.f)})}getState(){return this.f.getState()}getPeriods(){return[]}onError(a){const b=new _.E(_.r,{detail:a});a.severity===_.F&&(TM(this.f,_.Sn),this.a.release());this.trigger(b);b.defaultPrevented&&(b.a=!0)}getDrmInfo(){return this.a.getDrmInfo()}isEnded(){return this.f.getState()===_.Ln}isPaused(){return this.a.getState()===VM}isMuted(){return GN(this.a)}setMuted(a){KN(this.a,
56
- a)}getNetworkEngine(){return this.C}setNetworkEngine(a){this.C=a}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 gO).canPlay(a,b)}getTimelineCues(){return[]}getTextDisplayer(){return this.o}resetAbr(){}};hO.prototype.getTextDisplayer=hO.prototype.getTextDisplayer;hO.prototype.setNetworkEngine=hO.prototype.setNetworkEngine;
57
- hO.prototype.getNetworkEngine=hO.prototype.getNetworkEngine;var fO="clpp.tizen",eO=0,gO=class{a(){return fO}canPlay(a){a=a.type;const b=!!window.webapis;if((a===_.yc||a===_.Lk||a===_.Dc)&&b){if(_.Uj(2))return 2;if(_.Uj(3)||_.Uj(4)||_.Uj(5)||_.Uj(6))return _.C("Use of clpp.tizen.TizenComponent is not recommended for Tizen version \x3e\x3d 3."),1}return 0}f(a){return a===_.na}create(){return new hO}};_.z("clpp.tizen.TizenComponent",class extends _.Pt{f(){_.jh(new gO)}a(){var a=fO;a&&_.hh[a]&&(delete _.hh[a],_.ih.info("Removed Player factory: '"+a+"'"))}id(){return"tizen"}});var LN="onbufferingstart",RN="onbufferingprogress",SN="onbufferingcomplete",TN="onstreamcompleted",BN="oncurrentplaytime",$N="onevent",aO="onsubtitlechange",bO="ondrmevent",cO="onerror",NN="preparingstart",ON="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 MM="An unknown error occurred while trying to get volume",NM="Cannot get loading rendition due to platform limitations",OM="SecurityError",PM="The require privilege is: http://tizen.org/privilege/tv.audio",QM="|STARTBITRATE\x3d",RM=function(a,b,c){const d=e=>{c.call(a,e);a.removeEventListener(b,d)};a.addEventListener(b,d)},UM=function(a){return _.x(function*(){if(a.a!==_.zd&&a.a!==_.xd)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.dd)throw new _.H(_.F,6,6012,`No license server given for ${a.a}`);try{a.a===_.zd?yield SM(a):yield TM(a,b),a.o={keySystem:a.a,licenseServerUri:b.dd,distinctiveIdentifierRequired:!1,persistentStateRequired:b.te,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)});}})},WM=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=_.Si([b.serverurl&&""!==b.serverurl?b.serverurl:c.dd],_.Pi());c.type=3;c.body=e.buffer;c.method=_.ub;try{var f=yield a.D.vb.fetch(c).R;if(a.j){var g=_.J(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(VM,"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:_.Sa,url:h.data.url,status:h.data.status||NaN,response:h.data.response||"",headers:h.data.headers||{}},h),a.D.onError(g)}})},SM=function(a){return _.x(function*(){try{webapis.avplay.setDrm(VM,"Initialize",""),webapis.avplay.setDrm(VM,
5
+ "widevine_app_session",a.l.id),webapis.avplay.setDrm(VM,"widevine_data_type",a.l.type)}catch(b){throw b;}})},TM=function(a,b){return _.x(function*(){var c={};c[XM]=!b.te;c[YM]=b.dd;""!==b.customData&&(c[ZM]=b.customData);c=JSON.stringify(c);a.g.debug("PlayReady properties: ",c);try{webapis.avplay.setDrm($M,"SetProperties",c)}catch(d){throw d;}})},bN=function(a,b){if(a.f!==b)if(a.f===_.Vn&&b!==_.Wn)a.g.debug(_.fA+`${aN(b)}`);else{var c=(new Date).getTime();a.j=a.f;a.f=b;a.f===_.Rn?(a.o=(new Date).getTime(),
6
+ a.m.trigger(new _.E(_.Uc,{detail:{bufferedTimeMS:-1,reason:a.h}}))):a.j===_.Rn&&a.m.trigger(new _.E(_.Qc,{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(_.Nf,{detail:b}));a.g.debug("State changed:",aN(a.j),"-\x3e",aN(a.f))}},aN=function(a){return Object.keys(_.Un)[a]},eN=function(a){if(a.l){var b=a.a.getState(),c=a.f;switch(b){case cN:c=_.Zn;break;case dN:c=_.Yn;break;default:a.m.isEnded()?c=_.On:a.g.debug("Inconsistent AVPlay playback state:",
7
+ b)}bN(a,c)}},fN=function(a){return _.x(function*(){const b=a.m.getConfiguration();let c;(c=yield _.yr(a.B.url,a.m.getNetworkEngine(),b.manifest.attemptParameters,a.B.type||null))&&c.configure(b.manifest);return c})},gN=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},hN=function(a){const b=document.createElement(_.w),c=new _.yG,d=new _.FF,e=a.m.getTextDisplayer();return new _.AG(b,c,e,d,a.m.getConfiguration())},iN=function(a){const b=
8
+ {configuration:{},Db:()=>a.m.getPosition(),$:a.h,vb:a.m.getNetworkEngine(),oe:a.G.bind(a),ne:a.F.bind(a),onError:a.U.bind(a),zf:()=>{},onEvent:()=>{},Cf:a.H.bind(a),Kd:()=>{},vd:()=>new _.rH,Td:()=>!1,Oc:null};return new _.SG(a.a,b)},jN=function(a){const b=a.m.getPosition();let c=null;for(const d of a.a.periods)d.startTime<=b&&(c=d);return c},kN=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 _.hj(String(c++),_.K);e.mimeType=a[d].mimeType;e.language=a[d].language;e.roles=a[d].roles;e.kind=a[d].kind||_.NA;const f=new _.pj(String(a[d].id),e);f.bandwidth=a[d].bandwidth||null;e.renditions.push(f);b.push(e)}return b},lN=function(a){if(a.h&&!a.h.getTextDisplayer().isTextVisible())return null;if(a.f){const b=_.BE(a.f,_.G);let c=null;if(b){a=kN(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},mN=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===_.Wd,a.a&&a.f)){a.setTextVisibility(!0);const c=jN(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):(_.QE(a.f,b,!0,0),a.m.trigger(new _.E(_.Kk))),a.o=b.language):a.g.error(_.eA,d.id)}},nN=function(a){const b=
11
+ a.oa();b&&a.m.trigger(new _.E(_.Nc,{detail:{width:b.width,height:b.height,bandwidth:b.bandwidth,rendition:b}}))},oN=function(a,b){a.m.trigger(new _.E(_.rg,{details:{width:b.width,height:b.height,bandwidth:b.bandwidth,track:b.track,abrSelection:a.a.o}}))},pN=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},qN=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++)_.Yg(a[d].renditions[e],
12
+ b,Object.keys(b))&&c.push(a[d].renditions[e]);return c[0]||null},rN=function(a){const b=a.m.getConfiguration();var c=_.Ah(b.preferredAudioLanguage||[]);const d=a.f[_.L]||[];if(d.length){var e=null;c.some(g=>{e=_.gB(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.wa(c)}else a.g.debug("Preferred language(s) not available")}else a.g.debug("Could not set preferred audio language")},
13
+ xN=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===sN),f=b.filter(l=>l.type===tN);const g=[];for(var h=0;h<f.length;h++){const l=pN(a,f[h].extra_info);if(l){var k=_.bi(l.language||_.ag);k=_.dj(k);k=c(g,k);k||(k=new _.hj(String(a.o++),_.L),g.push(k));k.renditions.push(uN(f[h].index,l,k))}else a.g.warn("Skipping audio stream with no extra info")}c=new _.hj(String(a.o++),_.N);for(f=0;f<
14
+ e.length;f++)(h=pN(a,e[f].extra_info))?c.renditions.push(vN(e[f].index,h,c)):a.g.warn("Skipping video stream with no extra info");e=[];e=a.h?kN(a.h):wN(a,b);d[_.N]=[c];d[_.L]=g;d[_.K]=e;return d},AN=function(a,b){if(b===_.K&&a.h)return lN(a.h);var c=yN(a.a)||[];if(0===c.length)return null;c=c.filter(e=>e.type===b.toUpperCase())[0];var d=null;b===_.N&&(d=pN(a,c.extra_info),d=qN(a,{width:d.Width,height:d.Height}));b===_.L&&(c?(d=zN(a,c,_.L),a.j=d):d=a.j);b===_.K&&(c?(d=zN(a,c,_.K),a.l=d):d=a.l);return d},
15
+ DN=function(a,b){if(b){const c=b.track.type.toUpperCase();BN(a.a,c,Number(b.id)).then(()=>{c===tN&&(a.j=b,a.m.trigger(new _.E(_.Jk)));c===CN&&(a.l=b,a.m.trigger(new _.E(_.Kk)))}).catch(()=>{a.g.error("Could not select "+c+" track.")})}else a.g.debug("Must provide valid rendition")},uN=function(a,b,c){const d=_.bi(b.language||_.ag);c.language=_.dj(d);c.originalLanguage=d;c.channelsCount=b.channels?Number(b.channels):null;c.mimeType=_.Jc;a=new _.pj(String(a),c);a.track=c;a.codec=b.fourCC||null;a.bandwidth=
16
+ b.bit_rate||null;return a},vN=function(a,b,c){c.mimeType=_.mg;a=new _.pj(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},EN=function(a,b,c){b=_.bi(b.track_lang||_.ag);c.mimeType="text/ttml";c.language=_.dj(b);c.originalLanguage=b;c.kind=_.NA;return new _.pj(String(a),c)},wN=function(a,b){b=b.filter(d=>d.type===CN);const c=[];for(let d=0;d<b.length;d++){const e=pN(a,b[d].extra_info);if(!e){a.g.warn("Skipping text stream with no extra info");
17
+ continue}const f=new _.hj(String(a.o++),_.K);f.renditions.push(EN(b[d].index,e,f));c.push(f)}return c},zN=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},FN=function(a){return a.f&&a.a?a.a.zh:webapis.avplay.getTotalTrackInfo()},HN=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=GN(a);a.f=!0;webapis.avplay.stop();webapis.avplay.close();return a.load(a.m.getConfiguration(),d).then(()=>{const e=a.a.We;a.f=!1;a.a=null;return e===dN?a.pause():a.play()})}catch(d){return Promise.reject(d)}},IN=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)}},BN=function(a,b,c){b=b.toUpperCase();
19
+ b===CN&&IN(a,!0);const d=a.j[b];d&&(d.Nd.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,Te:0,Nd:new _.Tj(()=>g(h,c,!0))}),(k=a.j[h])&&3>k.Te?(!a.w&&++k.Te,k.Nd.ha(a.w?.5:.25)):(a.g.debug("Could not set track after multiple attempts.Giving up..."),
20
+ k&&k.Nd.stop(),a.j[h]=null,f())}};g(b,c)})},yN=function(a){return a.f&&a.a?a.a.ng:webapis.avplay.getCurrentStreamInfo()},JN=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;})})},LN=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(KN,{currentTime:b}))},onevent:a.K.bind(a),onsubtitlechange:a.N.bind(a),ondrmevent:a.J.bind(a),onerror:a.U.bind(a)})}catch(b){a.g.error(b)}},MN=function(a){const b=!!a.m.getTrackManager().Ia();try{webapis.avplay.setSilentSubtitle(!b)}catch(c){a.g.debug("Could not set AVPlay subtitle config",c)}},NN=function(a,b){try{const c=b.estimatedBandwidth||0,d=b.currentBandwidth||0;a.g.debug({estimatedBandwidth:c,Ph:d});0!==c&&0!==d&&c>=1.15*d&&webapis.avplay.setStreamingProperty("ADAPTIVE_INFO",
22
+ QM+d)}catch(c){a.g.debug(c)}},ON=function(a,b){try{webapis.avplay.setStreamingProperty("ADAPTIVE_INFO","|BITRATES\x3d"+b+QM+b)}catch(c){throw a.g.debug("Could not set fixed bandwidth",c),c;}},PN=function(a){let b=null;try{b=tizen.tvaudiocontrol.isMute()}catch(c){switch(c.name){case OM:a.g.warn("The application doesn't have the privilege to get the mute state.",PM);break;default:a.g.warn(MM,c)}}return!!b},GN=function(a){return{position:a.getPosition(),state:a.m.getState(),We:a.getState(),playbackRate:a.getPlaybackRate(),
23
+ isLive:a.isLive(),duration:a.getDuration(),isMuted:PN(a),volume:a.getVolume(),zh:FN(a),ng:yN(a)}},QN=function(){return new Promise((a,b)=>{if(window.webapis)a();else{const c=document.createElement("script");RM(c,"load",d=>a(d));RM(c,_.r,d=>b(d));c.src="$WEBAPIS/webapis/webapis.js";document.querySelector("head").appendChild(c)}})},RN=function(a){return _.x(function*(){yield QN();const b=new Promise(c=>{(new _.Tj(c)).ha(5)});if(!(yield Promise.race([JN(a).then(()=>!0),b.then(()=>!1)])))return a.g.debug("Took to long for the SDK to be ready"),
24
+ Promise.reject("SDK Timeout")})},SN=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!");MN(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)}})})},TN=function(a,b){try{tizen.tvaudiocontrol.setMute(b)}catch(c){switch(c.name){case OM:a.g.warn("The application does not have the privilege to set mute.",PM);break;default:a.g.warn(MM,
25
+ c)}}},YN=function(a,b,c){return _.x(function*(){a.l=_.bo(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(UN)),f=c.currentPosition);try{let g=a.l[d].url;if(a.l[d].type===_.zc&&!g.includes(".mpd")){const h=new URL(g);h.searchParams.append("cl-ext",".mpd");g=h.toString()}webapis.avplay.open(g);e.nextBandwidth?(ON(a,e.nextBandwidth),a.o=!1):(a.o||NN(a,e),
26
+ a.o=!0);LN(a);if(b.drm&&b.drm.env){const h={onError:k=>a.m.onError(k),vb:a.m.getNetworkEngine()};a.h=new VN(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(WN));yield SN(a);a.f||a.trigger(new _.E(XN));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&&TN(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;}})},ZN=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())},VN=class{constructor(a,
28
+ b){this.h=a;this.o=null;this.a=_.Ee;this.l=null;this.j=!1;this.f=new Map;this.D=b;this.g=new _.R("clpp.tizen.DrmEngine")}init(){const a=this;return _.x(function*(){var b=_.nl[a.h.env]||null;if(!b)throw a.g.debug(_.va,_.zb+a.h.env+_.aa),new _.H(_.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=_.pl(b,a.h.customData);const d=b[_.xd];d&&a.f.set(_.xd,
29
+ {dd:d.licenseUrl||"",customData:c,te:!1});(b=b[_.zd])&&a.f.set(_.zd,{dd:b.licenseUrl||"",customData:c,te:!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(_.xd))a.a=_.xd;else if(a.f.get(_.zd))a.a=_.zd;else throw new _.H(_.F,6,6001,"Configuration for the target system is missing.");yield UM(a);a.j=!0})}release(){const a=this;return _.x(function*(){a.j=!1;a.o=null;a.a=_.Ee;a.l=null;a.f=new Map})}getDrmInfo(){return this.o}},XM="DeleteLicenseAfterUse",
30
+ YM="LicenseServer",ZM="CustomData";var eO=class{constructor(a){this.m=a;this.a=this.m.a;this.f=_.Wn;this.j=_.At;this.w=(new Date).getTime();this.l=!1;this.o=-1;this.h=2;this.g=new _.R("clpp.tizen.StateManager")}initialize(){this.a.on(UN,this.C,this);this.a.on($N,this.B,this);this.a.on(aO,this.A,this);this.a.on(WN,this.H,this);this.a.on(XN,this.G,this);this.a.on(bO,this.F,this)}release(){bN(this,_.Wn);this.l=!1;this.o=-1;this.h=2}destroy(){this.release();this.a.off(UN,this.C);this.a.off($N,this.B);this.a.off(aO,this.A);this.a.off(WN,
31
+ this.H);this.a.off(XN,this.G);this.a.off(bO,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;bN(this,_.Rn)}B(a){this.g.debug("Buffering progress: "+a.percent+" %. Player state: ",aN(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()===cO;if(!a&&b){bN(this,_.Yn);return}}if(a=this.f!==_.Xn)a=this.a.getState(),a=a===
32
+ cN||a===dN;a&&eN(this)}H(){this.g.debug("Preparing starts. AVPlay State: ",this.a.getState());this.a.getState()===dO?bN(this,_.Xn):this.g.error("AVPlay prepares while state is not IDLE")}G(){this.g.debug("Preparing ends: AVPlay state:",this.a.getState())}F(){bN(this,_.On)}getState(){return this.f}};var fO=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 _.R("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 fN(b),b.j){var c={configurationId:"",networkingEngine:b.m.getNetworkEngine(),filterNewPeriod:()=>{},filterAllPeriods:()=>{},onTimelineCueAdded:()=>{},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&&gN(b.a)){b.h=hN(b);try{yield b.h.open();b.f=iN(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(_.EA,
34
+ a);this.w=!0;let b=_.hD(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&&(_.QE(this.f,this.l,!0,0),this.l=null)}U(){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 W=class extends _.S{constructor(){super();this.h=this.a=this.m=null;this.f={};this.g=new _.R("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 gO:0<Object.keys(this.f).length||(this.g.debug("Loading track manager!"),this.load());b=webapis.avplay.getCurrentStreamInfo();0<b.length&&(b=+pN(this,b[0].extra_info).Bit_rate,b=qN(this,{bandwidth:b}))&&(this.w=b,oN(this,b));break;case hO:nN(this);break;default:this.g.debug("Event type: "+
36
+ b+" data: "+a)}}A(a){a.detail.currentState===_.Zn&&this.m.off(_.Nf,this.A)}initialize(a){this.m=a;this.a=this.m.a;this.m.on(_.Nf,b=>{this.B||(b=b.detail,b.currentState===_.Zn&&(this.g.debug("Current state",b.currentState),this.B=!0,rN(this)))});this.a.on(iO,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(_.Nf,this.A);this.m.on(_.Nf,this.A,this);try{const a=FN(this.a);this.f=xN(this,a);
37
+ const b=this.f[_.L]||[];b.length&&(this.j=b[0].renditions[0]||null);nN(this)}catch(a){this.g.debug("Could not load track manager")}}}destroy(){this.a.off(iO,this.C);this.a=this.m=null}getVideoTracks(){return this.f[_.N]||[]}getAudioTracks(){return this.f[_.L]||[]}ka(){return this.f[_.K]||[]}oa(){return AN(this,_.N)}Qa(){return AN(this,_.L)}Ia(){return AN(this,_.K)}cb(){return this.w}ob(){this.g.info(NM);return null}pb(){this.g.info(NM);return null}Ja(){const a=this.oa();return a?a.track:null}na(){const a=
38
+ this.Qa();return a?a.track:null}ua(){const a=this.Ia();return a?a.track:null}jb(a){null===a?(a=this.oa(),HN(this.a,a.bandwidth,null).then(()=>{nN(this)})):0<a.renditions.length&&this.Ya(a.renditions[0])}wa(a){a?DN(this,a.renditions[0]):this.g.warn("Cannot disable audio tracks on this platform.","Consider muting audio instead...")}La(a){a?(a=a.renditions[0],this.h?mN(this.h,a.track):DN(this,a)):(this.g.debug("Disabling text tracks"),this.l=null,IN(this.a,!1),this.m.trigger(new _.E(_.Kk)))}Ya(a){const b=
39
+ this.oa();this.a.o||a.width!==b.width||a.height!==b.height||a.bandwidth!==b.bandwidth?(this.w=a,oN(this,a),HN(this.a,b.bandwidth,a.bandwidth).then(()=>{nN(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...")}hb(a){DN(this,a)}ib(a){this.h?mN(this.h,a.track):DN(this,a)}addTextTrack(){}ra(){return this.a.o}};W.prototype.isAbrEnabled=W.prototype.ra;
40
+ W.prototype.addTextTrack=W.prototype.addTextTrack;W.prototype.setTextRendition=W.prototype.ib;W.prototype.setAudioRendition=W.prototype.hb;W.prototype.setVideoRendition=W.prototype.Ya;W.prototype.setTextTrack=W.prototype.La;W.prototype.setAudioTrack=W.prototype.wa;W.prototype.setVideoTrack=W.prototype.jb;W.prototype.getTextTrack=W.prototype.ua;W.prototype.getAudioTrack=W.prototype.na;W.prototype.getVideoTrack=W.prototype.Ja;W.prototype.getLoadingTextRendition=W.prototype.pb;
41
+ W.prototype.getLoadingAudioRendition=W.prototype.ob;W.prototype.getLoadingVideoRendition=W.prototype.cb;W.prototype.getTextRendition=W.prototype.Ia;W.prototype.getAudioRendition=W.prototype.Qa;W.prototype.getVideoRendition=W.prototype.oa;W.prototype.getTextTracks=W.prototype.ka;W.prototype.getAudioTracks=W.prototype.getAudioTracks;W.prototype.getVideoTracks=W.prototype.getVideoTracks;var mO=class extends _.ft{constructor(a){super();this.m=a;this.h=null;this.g=new _.R("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(UN))}H(a){this.w=!0;this.trigger(new _.E($N,{percent:a}))}G(){this.w=!1;this.trigger(new _.E(aO))}L(){this.trigger(new _.E(bO))}K(a,b){this.trigger(new _.E(iO,{eventid:a,data:b}))}N(a,b,c,d,e){this.trigger(new _.E(jO,{duration:a,text:b,subtitleType:c,
42
+ attriCount:d,attributes:e}))}J(a,b){this.trigger(new _.E(kO,{drmType:a,drmData:b}));this.h&&(a=this.h,a.j&&(a.a===_.zd&&"Challenge"===b.name?WM(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))))}U(a){this.trigger(new _.E(lO,{eventType:a}))}play(){const a=this.getState(),b=()=>new Promise((c,d)=>{let e=null;const f=()=>{c();clearTimeout(e)};this.one(KN,f,this);e=setTimeout(()=>{this.off(KN,f);d("Timeout")},3E4)});if(a===dO)return(new Promise((c,
43
+ d)=>{webapis.avplay.prepareAsync(()=>{MN(this);c(webapis.avplay.play())},e=>{this.trigger(new _.E(lO));d(e)})})).then(()=>b());if(a===dN||a===cO)try{return webapis.avplay.play(),b()}catch(c){return Promise.reject(c)}return a===cN?Promise.resolve():Promise.reject("Player is in invalid state")}pause(){try{webapis.avplay.pause()}catch(a){Promise.reject(a)}return this.getState()===dN?Promise.resolve():Promise.reject()}setPlaybackRate(a){const b=this.getState();if(b===cO||b===cN||b===dN){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 RN(c),yield YN(c,a,b)}catch(d){throw new _.H(_.F,7,7003,null,d);}})}getState(){if(this.f&&this.a)return this.a.We;try{return webapis.avplay.getState()}catch(a){this.U(JSON.stringify(a))}}seek(a){const b=
45
+ 1E3*a;return new Promise((c,d)=>{this.B=!0;this.m.trigger(new _.E(_.gg));webapis.avplay.seekTo(b,()=>{this.B=!1;this.m.trigger(new _.E(_.fg));c()},()=>{this.B=!1;d()})})}getPosition(){if(this.f&&this.a)return this.a.position;try{return webapis.avplay.getCurrentTime()/1E3}catch(a){this.U(JSON.stringify(a))}}getDuration(){if(this.f&&this.a)return this.a.duration;try{return webapis.avplay.getDuration()/1E3}catch(a){this.U(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.Nd.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 OM:this.g.debug("The application does not have the privilege to get the volume.",PM);break;default:this.g.debug(MM,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 OM:this.g.warn("The application does not have the privilege to set the volume.",PM);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.U(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()]}},dO="IDLE",cO="READY",cN="PLAYING",dN="PAUSED",sN=_.Sb,tN="AUDIO",CN="TEXT",hO="PLAYER_MSG_RESOLUTION_CHANGED",gO="PLAYER_MSG_BITRATE_CHANGE",$M="PLAYREADY",VM="WIDEVINE_CDM";var qO=class extends _.ft{constructor(){super();this.a=new mO(this);this.f=new eO(this);this.configuration=this.B=_.Uk();this.w=null;this.g=new _.R("clpp.tizen.Player");this.j=null;this.l=new W;this.C=new _.ap;this.o=this.h=null;this.A=!1}H(){this.g.debug("On Stream completed. Current time: ",this.getPosition());this.trigger(new _.E(_.Vd));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(_.Xf,
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=_.Bi(d))&&this.o.append([new _.Bs(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)}U(a){this.g.debug(`Error: TYPE: ${a.eventType}`);bN(this.f,_.Vn);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(bO,this.H,this);this.a.on(KN,this.F,this);this.a.on(jO,this.I,this);this.a.on(kO,this.G,this);this.a.on(lO,this.U,this);this.a.on(aO,this.J,this);this.f.initialize();this.l.initialize(this);this.g.debug("Initializing player surface");this.w.hideMediaElement();a=nO;nO+=1;a="__clpp_tizen_player_"+a;this.j=_.uo(_.Fe,{id:a,type:"application/avplayer"});this.w.addElementToContainer(this.j,!0);var c=this.w.getMedia();if(c){a=this.j;{b=[_.Cg,_.Zd,"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}_.wo(a,d);ZN(this)}}getSurface(){return this.w}getConfiguration(){return this.configuration}getTimeline(){return null}setupPlaylist(){return Promise.reject(_.qb)}appendLoad(){return Promise.reject(_.qb)}seekWith(){return Promise.reject(_.qb)}destroy(){const a=this;return _.x(function*(){yield a.release();a.a.off(bO,a.H);a.a.off(KN,
52
+ a.F);a.a.off(jO,a.I);a.a.off(kO,a.G);a.a.off(lO,a.U);a.a.off(aO,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 oO}getPlaybackRate(){return this.a.getPlaybackRate()}setDrmCustomDataModifier(){}setCdnErrorCallback(){}detach(){}setPlaybackRate(a){this.a.setPlaybackRate(a)}getPosition(){return this.getMediaPosition()}getMediaPosition(){return 0<(this.configuration.startTime||0)&&!this.A?0:this.f.getState()===
53
+ _.On?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(_.qa);return new _.et}getTrackManager(){return this.l}unload(){return this.a.release().then(()=>
54
+ {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=_.Wk(b.B,a);var c=_.En(b.configuration,[_.be,"native"]);b.o=c.create(b);c=_.bo(b.configuration)[0];if(b.configuration.tizen&&b.configuration.tizen.sideStreamText){b.h=new fO;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),
55
+ d;}b.l.load()})}play(){this.trigger(new _.E(_.Te));ZN(this);return this.a.play().then(()=>{eN(this.f)})}pause(){return this.a.pause().then(()=>{eN(this.f)})}getState(){return this.f.getState()}getPeriods(){return[]}onError(a){const b=new _.E(_.r,{detail:a});a.severity===_.F&&(bN(this.f,_.Vn),this.a.release());this.trigger(b);b.defaultPrevented&&(b.a=!0)}getDrmInfo(){return this.a.getDrmInfo()}isEnded(){return this.f.getState()===_.On}isPaused(){return this.a.getState()===dN}isMuted(){return PN(this.a)}setMuted(a){TN(this.a,
56
+ a)}getNetworkEngine(){return this.C}setNetworkEngine(a){this.C=a}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 pO).canPlay(a,b)}getTimelineCues(){return[]}getTextDisplayer(){return this.o}resetAbr(){}};qO.prototype.getTextDisplayer=qO.prototype.getTextDisplayer;qO.prototype.setNetworkEngine=qO.prototype.setNetworkEngine;
57
+ qO.prototype.getNetworkEngine=qO.prototype.getNetworkEngine;var oO="clpp.tizen",nO=0,pO=class{a(){return oO}canPlay(a){a=a.type;const b=!!window.webapis;if((a===_.zc||a===_.Ok||a===_.Ec)&&b){if(_.Xj(2))return 2;if(_.Xj(3)||_.Xj(4)||_.Xj(5)||_.Xj(6))return _.C("Use of clpp.tizen.TizenComponent is not recommended for Tizen version \x3e\x3d 3."),1}return 0}f(a){return a===_.na}create(){return new qO}};_.z("clpp.tizen.TizenComponent",class extends _.Yt{f(){_.mh(new pO)}a(){var a=oO;a&&_.kh[a]&&(delete _.kh[a],_.lh.info("Removed Player factory: '"+a+"'"))}id(){return"tizen"}});var UN="onbufferingstart",$N="onbufferingprogress",aO="onbufferingcomplete",bO="onstreamcompleted",KN="oncurrentplaytime",iO="onevent",jO="onsubtitlechange",kO="ondrmevent",lO="onerror",WN="preparingstart",XN="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 Hv='application/mp4; codecs\x3d"stpp.ttml"',Iv='application/mp4; codecs\x3d"stpp.ttml.im1i"',Jv='application/mp4; codecs\x3d"stpp.ttml.im1t"',Kv="backgroundColor",Lv="direction",Mv="displayAlign",Nv="region",Ov="textAlign",Pv="textDecoration",Qv="writingMode",Rv=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},Zv=function(a,b){var c=null;if(Sv.test(a)){{a=Sv.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 Tv.test(a)?c=Uv(Tv,a):Vv.test(a)?c=Uv(Vv,a):Wv.test(a)?(a=Wv.exec(a),c=Number(a[1])/b.frameRate):Xv.test(a)?(a=Xv.exec(a),c=Number(a[1])/b.a):Yv.test(a)&&(c=Uv(Yv,a));return c},Uv=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)},$v=function(a){return a.split(":").pop()},aw=function(a){return a.replace(/(\d*\.?\d+)c/g,
3
- "$1em")},cw=function(a,b){for(;bw.test(a);){const c=bw.exec(a)[0];a=a.replace(c,`${parseInt(c,10)/b}em`)}return a},dw=function(a){return a?a.replace(/(\d*\.?\d+)%/g,(b,c)=>`${c/100}em`):""},ew=function(a,b,c){a=Rv(a,b,Ov);if(!a&&c&&(a=Rv(c,b,Ov),!a&&"rltb"===Rv(c,b,Qv)))return _.vf;switch(a){case _.$c:return _.ns;case _.vf:case _.Td:return _.vf;default:return _.ee}},fw=function(a,b,c){if(_.ui(a.w))return document.createTextNode(_.yi(a.w||""));if(a.A)return _.ro("br");const d=_.ro("span");for(const e of a.f)_.so(d,
4
- e);for(const e of a.j)d.appendChild(fw(c.get(e),b,c));return d},iw=function(a,b,c,d){const e=gw.exec(a);a=hw.exec(a);return typeof b===_.t&&0<b&&a?100*Number(a[c])/b:e?Number(e[c]):a?Number(a[c]):d},jw=function(a,b){return typeof b===_.t&&0<b?_.vs:hw.test(a)?0:_.vs},kw=function(a,b,c){return typeof a===_.t?a:typeof b===_.t?b:c},lw=function(a,b){a=a.getAttribute("extent");return(a=hw.exec(a))?Number(a[b]):null},nw=function(a){a=a.getAttribute("cellResolution");return(a=mw.exec(a))?Number(a[2]):null},
5
- pw=function(){return`${"inline-"}${ow++}`},rw=function(a){return qw.some(b=>b in a.attributes)},sw=function(a,b){if(0===b.length)return[];const c=[];for(const d of b)a.a.has(d)&&c.push(...sw(a,a.a.get(d).f),d);return c},tw=function(a){return $v(a.g.nodeName)},ww=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];-1===["#text","span","br"].indexOf(b.nodeName)&&(c=k.a,d=k.j,f=[...k.f],g={},uw.forEach(l=>
6
- {l in k.attributes&&(g[l]=k.attributes[l])}))}if(b.nodeType===b.ELEMENT_NODE){b.hasAttribute(Nv)&&(c=b.getAttribute(Nv));b.hasAttribute(_.Of)&&f.push(...b.getAttribute(_.Of).split(" "));d=Array.from(b.attributes).map(k=>k.name);for(const k of d)d=$v(k),g[d]=b.getAttribute(k);d=g.backgroundImage}c=new vw(b,c,d,e,f,g);a.a.set(b,c);return c},xw=function(a){return`${String(Math.floor(a/3600)).padStart(2,"0")}:${String(Math.floor(a/60%60)).padStart(2,"0")}:${String(Math.floor(a%60)).padStart(2,"0")}.${String(Math.floor(1E3*
7
- a%1E3)).padStart(3,"0")}`},yw=class{constructor(a,b,c){this.g=a;this.f=b;this.a=c}getId(){return this.g}getAttribute(a){return this.a[a]}};var zw=class extends yw{constructor(a,b,c){super(a,[],c);this.j=b||""}};var Aw=class extends yw{constructor(a,b,c){super(a,b,c)}};var Sv=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Tv=/^(?:(\d{2,}):)?(\d{2}):(\d{2})$/,Vv=/^(?:(\d{2,}):)?(\d{2}):(\d{2}\.\d+)$/,Wv=/^(\d*(?:\.\d*)?)f$/,Xv=/^(\d*(?:\.\d*)?)t$/,Yv=/^(?:(\d*(?:\.\d*)?)h)?(?:(\d*(?:\.\d*)?)m)?(?:(\d*(?:\.\d*)?)s)?(?:(\d*(?:\.\d*)?)ms)?$/,gw=/^(\d{1,2}(?:\.\d+)?|100(?:\.0+)?)% (\d{1,2}(?:\.\d+)?|100(?:\.0+)?)%$/,hw=/^(\d+)px (\d+)px$/,mw=/^(\d+) (\d+)$/,bw=/(\d+)px/,Bw=/^(\d+px|\d+em|\d*\.?\d+c)$/,qw=[Kv,"color",Lv,Mv,"fontFamily","fontSize","fontStyle","fontWeight",
8
- "lineHeight","opacity","padding",Ov,Pv,"textOutline",Qv,"zIndex"],uw=["begin",_.Td];var Cw=class extends Aw{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=Zv(this.a.begin,b);b=Zv(this.a.end,b);if(null===h||null===b)return null;h+=c;b+=c;c=_.ro(_.Fd);for(const k of this.j)c.appendChild(fw(g.get(k),e,g));g=new _.ss(h,b,c.innerHTML.trim(),_.Vf);g.cssClassList=[...this.f];g.textAlign=ew(this,e,null);g.writingMode=_.os;g.line=-1;g.lineInterpretation=_.ps;g.lineAlign=_.qs;g.containerRows=kw(null,nw(a),15);if(this.o&&(f=
9
- f.get(this.o))){g.region=f.build(a,e);g.textAlign=ew(this,e,f);a:switch(Rv(f,e,Qv)){case "tb":case "tblr":a=_.eg;break a;case "tbrl":a=_.fg;break a;default:a=_.os}g.writingMode=a;a:switch(Rv(f,e,Mv)){case _.$c:a=50;break a;case "after":a=-1;break a;default:a=0}g.line=a;a:switch(Rv(f,e,Mv)){case _.$c:a=1;break a;default:a=_.ps}g.lineInterpretation=a;a:switch(Rv(f,e,Mv)){case _.$c:e=_.$c;break a;default:e=_.qs}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 Dw=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 Ew=class extends Aw{constructor(a,b,c){super(a,b,c)}build(a,b){const c=new _.xs;c.id=this.getId();const d=kw(a.j.containerWidth,lw(a,1),720);a=kw(a.j.containerHeight,lw(a,2),480);a:switch(Rv(this,b,Mv)){case "after":var e="flex-start";break a;case _.$c:e=_.$c;break a;default:e="flex-end"}c.displayAlign=e;a:switch(Rv(this,b,Qv)){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")||Rv(this,b,"extent");c.width=iw(e,
11
- d,1,100);c.widthUnits=jw(e,d);c.height=iw(e,a,2,100);c.heightUnits=jw(e,a);b=this.getAttribute("origin")||Rv(this,b,"origin");c.viewportAnchorX=iw(b,d,1,0);c.viewportAnchorY=iw(b,a,2,0);c.viewportAnchorUnits=jw(b,d);c.cssClassList=[...this.f];return c}};var Fw=class extends yw{constructor(a,b){super("root-container",[],b);this.j=a}};var Hw=class extends yw{constructor(a,b,c){super(a,b,c)}build(a){var b=null;var c=nw(a);c&&(b=kw(a.j.containerHeight,lw(a,2),480)/c);b=kw(a.j.fontSizeRadix,b,16);a=[];c=`::ttml .${this.g}, ::ttml .${this.g} * {`;for(const [g,h]of Gw.entries())g in this.a&&(c+=`${h}:${aw(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&&!Bw.test(h)&&Bw.test(k)&&Bw.test(l)?(e=h,g=k):2===d.length&&!Bw.test(h)&&Bw.test(k)?(e=h,g=k):2===d.length&&Bw.test(h)&&Bw.test(k)&&(g=h);if(""!==g){g=aw(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=dw(this.a.textShadow),d=aw(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(Pv 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
- aw(this.a.padding),d+=";"):d="";f=c=c+f+d;"lineHeight"in this.a?(c="",d=this.a.lineHeight,d=aw(d),d=cw(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=aw(c);c=cw(c,b);b=`font-size:${c};`;break a}b=null}b&&(f=`::ttml .${this.g} .clpp-text-wrapper {`,f+=b,f+="}",a.push(f),f=`::ttml .clpp-text-wrapper__${this.g} {`,f+=b,f+="}",a.push(f));return a}},Gw=new Map([[Kv,"background-color"],
15
- ["color","color"],[Lv,Lv],["fontStyle","font-style"],["fontWeight","font-weight"],["opacity","opacity"],["zIndex","z-index"]]);var Iw=class{constructor(a){this.B=a;this.w=this.l=null;this.A=0;this.g=new Map;this.a=new Map;this.j=new Map;this.f=new Map;this.o=[]}Oc(){return this.o.map(a=>a.build(this.l,this.w,this.A,this.g,this.a,this.j,this.f)).filter(a=>null!=a)}},ow=0;var Lw=class{constructor(a){this.a=a.firstChild;this.f=new Set}Ac(){return!!this.a}next(){if(!this.a)return null;let a=this.a;do this.f.add(a),a.nodeType!==Node.TEXT_NODE&&!Jw.has($v(a.nodeName))||Kw.has($v(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&&!Jw.has($v(a.nodeName))));const b=this.a;this.a=a;return b}},Jw=new Set(["tt","head","layout",_.ve,_.ae,Nv,"styling",_.Of,"body",
16
- _.Fd,"p","span","br"]),Kw=new Set([_.Of,_.ae]);var vw=class{constructor(a,b,c,d,e,f){this.g=a;this.a=b;this.j=c;this.l=d;this.f=e;this.attributes=f}getId(){return this.attributes.id}};var Mw=class{constructor(){this.a=new Map}};var Nw=class{constructor(a){this.a=a;this.f=new DOMParser}parseInit(){}parseMedia(a,b,c){c&&c.length||(c=[a.byteLength]);var d=_.Ng(this.a.ttml||{}),e=_.J(a,0,c[0]);e=_.li(e);if(""===e)return{cues:[],styles:[]};var f=null;try{f=this.f.parseFromString(e,_.Sf)}catch(m){throw new _.H(_.F,2,2005,"Failed to parse TTML.");}d=new Iw(d);e=new Mw;f=new Lw(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=_.J(a,b,h);k=_.zi(k);const m=`urn:mpeg:14496-30:subs:${g}`;d.g.set(m,
17
- new zw(m,k,{imageType:"PNG",encoding:"Base64"}));b+=h}for(;f.Ac();)a=f.next(),a=ww(e,a),c=d,b=a,"tt"===tw(b)&&(c.l=new Fw(c.B,Object.assign({},b.attributes))),c=d,b=a,"tt"===tw(b)&&(c.w=new Dw(b.attributes.frameRate,b.attributes.subFrameRate,b.attributes.frameRateMultiplier,b.attributes.tickRate)),c=d,b=a,tw(b)!==_.ae||b.attributes.begin||b.attributes.end||(g=`#${b.getId()}`,c.g.set(g,new zw(g,b.g.textContent,b.attributes))),c=d,g=a,tw(g)===_.ae&&g.attributes.begin&&g.attributes.end?(b=`#${pw()}`,
18
- g=new zw(b,g.g.textContent,g.attributes),c.g.set(b,g),c=g):c=null,c&&(a.j=c.getId()),c=d,b=a,tw(b)===_.Of&&(g=b.getId()||pw(),h=new Hw(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,tw(g)!==_.Of&&rw(g)?(b=pw(),g=new Hw(b,[],Object.assign({},g.attributes)),c.a.set(b,g),c=g):c=null,c&&a.f.push(c.getId()),c=d,g=a,tw(g)!==_.Fd||!g.attributes.extent&&!g.attributes.origin?c=null:(b=pw(),g=new Ew(b,sw(c,g.f),Object.assign({},g.attributes)),c.j.set(b,g),c=g),c&&(a.a=
19
- c.getId()),c=d,g=a,tw(g)!==Nv?c=null:(b=g.getId(),g=new Ew(b,sw(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(tw(g))||0===b.length?c=null:(h=b[b.length-1],c.f.has(h)?(b=pw(),g=new Cw(b,"#text"===g.g.nodeName?g.g.textContent:null,"br"===tw(g),g.a,g.j,sw(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"===tw(g)||g.j?(b=pw(),g=new Cw(b,null,!1,g.a,g.j,sw(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=d.Oc();f=[];for(l of d.a.values())f.push(...l.build(d.l));var l=f;return{cues:e,styles:l}}};var Ow=class{constructor(a){this.f=a}a(a){var b=new Nw(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=xw(d.startTime)+" --\x3e "+xw(d.endTime);{var c=d;const e=[];switch(c.textAlign){case _.ee:e.push("align:left");break;case _.vf:e.push("align:right");break;case _.ns:e.push("align:middle");break;case _.ee:e.push("align:start");break;case _.vf:e.push("align:end")}switch(c.writingMode){case _.eg:e.push("vertical:lr");break;case _.fg:e.push("vertical:rl")}c=
21
- e.length?" "+e.join(" "):""}b=a+(b+c+"\n");b+=d.payload+"\n\n"}return _.pi(b)}},Pw=class{probe(a,b){return a===_.Cc&&b===_.Rf}create(a){return new Ow(a)}};var Qw=class{constructor(a){this.a=new Nw(a);this.h=new _.R("clpp.ttml.Mp4TtmlParser")}parseInit(a){let b=!1;(new _.Jl).M(_.ye,_.Cl).M(_.Uf,_.Cl).M(_.te,_.Cl).M(_.xe,_.Cl).M(_.Lf,_.Cl).ba(_.Nf,_.Dl).M("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 _.Jl).M("moof",_.Cl).M("traf",_.Cl).ba("subs",g=>{const h=_.P(g.reader);for(let k=0;k<h;++k){g.reader.skip(4);const l=_.vl(g.reader);for(let m=0;m<l;++m){const n=1===g.version?
22
- _.P(g.reader):_.vl(g.reader);f.push(n);g.reader.skip(6)}}}).M(_.se,_.El(g=>{c=!0;g=this.a.parseMedia(g,b,f);d=d.concat(g.cues);e=e.concat(g.styles)})).parse(a);c||this.h.warn("Couldn't find the mdat box");return{cues:d,styles:e}}};_.z("clpp.ttml.TtmlComponent",class extends _.Pt{constructor(){super();this.j=new Pw}f(){_.Yr(_.Cc,Nw);_.Yr(_.Ac,Qw);_.Yr(Hv,Qw);_.Yr(Jv,Qw);_.Yr(Iv,Qw);_.Aj.push(this.j)}a(){_.$r(_.Cc);_.$r(_.Ac);_.$r(Hv);_.$r(Jv);_.$r(Iv);_.Cj(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 Qv='application/mp4; codecs\x3d"stpp.ttml"',Rv='application/mp4; codecs\x3d"stpp.ttml.im1i"',Sv='application/mp4; codecs\x3d"stpp.ttml.im1t"',Tv="backgroundColor",Uv="direction",Vv="displayAlign",Wv="region",Xv="textAlign",Yv="textDecoration",Zv="writingMode",$v=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},hw=function(a,b){var c=null;if(aw.test(a)){{a=aw.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 bw.test(a)?c=cw(bw,a):dw.test(a)?c=cw(dw,a):ew.test(a)?(a=ew.exec(a),c=Number(a[1])/b.frameRate):fw.test(a)?(a=fw.exec(a),c=Number(a[1])/b.a):gw.test(a)&&(c=cw(gw,a));return c},cw=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)},iw=function(a){return a.split(":").pop()},jw=function(a){return a.replace(/(\d*\.?\d+)c/g,
3
+ "$1em")},lw=function(a,b){for(;kw.test(a);){const c=kw.exec(a)[0];a=a.replace(c,`${parseInt(c,10)/b}em`)}return a},mw=function(a){return a?a.replace(/(\d*\.?\d+)%/g,(b,c)=>`${c/100}em`):""},nw=function(a,b,c){a=$v(a,b,Xv);if(!a&&c&&(a=$v(c,b,Xv),!a&&"rltb"===$v(c,b,Zv)))return _.zf;switch(a){case _.ad:return _.ws;case _.zf:case _.Ud:return _.zf;default:return _.he}},ow=function(a,b,c){if(_.xi(a.w))return document.createTextNode(_.Bi(a.w||""));if(a.A)return _.uo("br");const d=_.uo("span");for(const e of a.f)_.vo(d,
4
+ e);for(const e of a.j)d.appendChild(ow(c.get(e),b,c));return d},rw=function(a,b,c,d){const e=pw.exec(a);a=qw.exec(a);return typeof b===_.t&&0<b&&a?100*Number(a[c])/b:e?Number(e[c]):a?Number(a[c]):d},sw=function(a,b){return typeof b===_.t&&0<b?_.Es:qw.test(a)?0:_.Es},tw=function(a,b,c){return typeof a===_.t?a:typeof b===_.t?b:c},uw=function(a,b){a=a.getAttribute("extent");return(a=qw.exec(a))?Number(a[b]):null},ww=function(a){a=a.getAttribute("cellResolution");return(a=vw.exec(a))?Number(a[2]):null},
5
+ yw=function(){return`${"inline-"}${xw++}`},Aw=function(a){return zw.some(b=>b in a.attributes)},Bw=function(a,b){if(0===b.length)return[];const c=[];for(const d of b)a.a.has(d)&&c.push(...Bw(a,a.a.get(d).f),d);return c},Cw=function(a){return iw(a.h.nodeName)},Fw=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];-1===["#text","span","br"].indexOf(b.nodeName)&&(c=k.a,d=k.j,f=[...k.f],g={},Dw.forEach(l=>
6
+ {l in k.attributes&&(g[l]=k.attributes[l])}))}if(b.nodeType===b.ELEMENT_NODE){b.hasAttribute(Wv)&&(c=b.getAttribute(Wv));b.hasAttribute(_.Sf)&&f.push(...b.getAttribute(_.Sf).split(" "));d=Array.from(b.attributes).map(k=>k.name);for(const k of d)d=iw(k),g[d]=b.getAttribute(k);d=g.backgroundImage}c=new Ew(b,c,d,e,f,g);a.a.set(b,c);return c},Gw=function(a){return`${String(Math.floor(a/3600)).padStart(2,"0")}:${String(Math.floor(a/60%60)).padStart(2,"0")}:${String(Math.floor(a%60)).padStart(2,"0")}.${String(Math.floor(1E3*
7
+ a%1E3)).padStart(3,"0")}`},Hw=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 Iw=class extends Hw{constructor(a,b,c){super(a,[],c);this.j=b||""}};var Jw=class extends Hw{constructor(a,b,c){super(a,b,c)}};var aw=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,bw=/^(?:(\d{2,}):)?(\d{2}):(\d{2})$/,dw=/^(?:(\d{2,}):)?(\d{2}):(\d{2}\.\d+)$/,ew=/^(\d*(?:\.\d*)?)f$/,fw=/^(\d*(?:\.\d*)?)t$/,gw=/^(?:(\d*(?:\.\d*)?)h)?(?:(\d*(?:\.\d*)?)m)?(?:(\d*(?:\.\d*)?)s)?(?:(\d*(?:\.\d*)?)ms)?$/,pw=/^(\d{1,2}(?:\.\d+)?|100(?:\.0+)?)% (\d{1,2}(?:\.\d+)?|100(?:\.0+)?)%$/,qw=/^(\d+)px (\d+)px$/,vw=/^(\d+) (\d+)$/,kw=/(\d+)px/,Kw=/^(\d+px|\d+em|\d*\.?\d+c)$/,zw=[Tv,"color",Uv,Vv,"fontFamily","fontSize","fontStyle","fontWeight",
8
+ "lineHeight","opacity","padding",Xv,Yv,"textOutline",Zv,"zIndex"],Dw=["begin",_.Ud];var Lw=class extends Jw{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=hw(this.a.begin,b);b=hw(this.a.end,b);if(null===h||null===b)return null;h+=c;b+=c;c=_.uo(_.Gd);for(const k of this.j)c.appendChild(ow(g.get(k),e,g));g=new _.Bs(h,b,c.innerHTML.trim(),_.Zf);g.cssClassList=[...this.f];g.textAlign=nw(this,e,null);g.writingMode=_.xs;g.line=-1;g.lineInterpretation=_.ys;g.lineAlign=_.zs;g.containerRows=tw(null,ww(a),15);if(this.o&&(f=
9
+ f.get(this.o))){g.region=f.build(a,e);g.textAlign=nw(this,e,f);a:switch($v(f,e,Zv)){case "tb":case "tblr":a=_.ig;break a;case "tbrl":a=_.jg;break a;default:a=_.xs}g.writingMode=a;a:switch($v(f,e,Vv)){case _.ad:a=50;break a;case "after":a=-1;break a;default:a=0}g.line=a;a:switch($v(f,e,Vv)){case _.ad:a=1;break a;default:a=_.ys}g.lineInterpretation=a;a:switch($v(f,e,Vv)){case _.ad:e=_.ad;break a;default:e=_.zs}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 Mw=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 Nw=class extends Jw{constructor(a,b,c){super(a,b,c)}build(a,b){const c=new _.Gs;c.id=this.getId();const d=tw(a.j.containerWidth,uw(a,1),720);a=tw(a.j.containerHeight,uw(a,2),480);a:switch($v(this,b,Vv)){case "after":var e="flex-start";break a;case _.ad:e=_.ad;break a;default:e="flex-end"}c.displayAlign=e;a:switch($v(this,b,Zv)){case "tb":case "tblr":e="row-reverse";break a;case "tbrl":e="row";break a;default:e=_.td}c.writingMode=e;e=this.getAttribute("extent")||$v(this,b,"extent");c.width=rw(e,
11
+ d,1,100);c.widthUnits=sw(e,d);c.height=rw(e,a,2,100);c.heightUnits=sw(e,a);b=this.getAttribute("origin")||$v(this,b,"origin");c.viewportAnchorX=rw(b,d,1,0);c.viewportAnchorY=rw(b,a,2,0);c.viewportAnchorUnits=sw(b,d);c.cssClassList=[...this.f];return c}};var Ow=class extends Hw{constructor(a,b){super("root-container",[],b);this.j=a}};var Qw=class extends Hw{constructor(a,b,c){super(a,b,c)}build(a){var b=null;var c=ww(a);c&&(b=tw(a.j.containerHeight,uw(a,2),480)/c);b=tw(a.j.fontSizeRadix,b,16);a=[];c=`::ttml .${this.h}, ::ttml .${this.h} * {`;for(const [g,h]of Pw.entries())g in this.a&&(c+=`${h}:${jw(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&&!Kw.test(h)&&Kw.test(k)&&Kw.test(l)?(e=h,g=k):2===d.length&&!Kw.test(h)&&Kw.test(k)?(e=h,g=k):2===d.length&&Kw.test(h)&&Kw.test(k)&&(g=h);if(""!==g){g=jw(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=mw(this.a.textShadow),d=jw(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(Yv 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
+ jw(this.a.padding),d+=";"):d="";f=c=c+f+d;"lineHeight"in this.a?(c="",d=this.a.lineHeight,d=jw(d),d=lw(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=jw(c);c=lw(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}},Pw=new Map([[Tv,"background-color"],
15
+ ["color","color"],[Uv,Uv],["fontStyle","font-style"],["fontWeight","font-weight"],["opacity","opacity"],["zIndex","z-index"]]);var Rw=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=[]}Rc(){return this.o.map(a=>a.build(this.l,this.w,this.A,this.h,this.a,this.j,this.f)).filter(a=>null!=a)}},xw=0;var Uw=class{constructor(a){this.a=a.firstChild;this.f=new Set}Dc(){return!!this.a}next(){if(!this.a)return null;let a=this.a;do this.f.add(a),a.nodeType!==Node.TEXT_NODE&&!Sw.has(iw(a.nodeName))||Tw.has(iw(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&&!Sw.has(iw(a.nodeName))));const b=this.a;this.a=a;return b}},Sw=new Set(["tt","head","layout",_.ye,_.de,Wv,"styling",_.Sf,"body",
16
+ _.Gd,"p","span","br"]),Tw=new Set([_.Sf,_.de]);var Ew=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 Vw=class{constructor(){this.a=new Map}};var Ww=class{constructor(a){this.a=a;this.f=new DOMParser}parseInit(){}parseMedia(a,b,c){c&&c.length||(c=[a.byteLength]);var d=_.Qg(this.a.ttml||{}),e=_.J(a,0,c[0]);e=_.oi(e);if(""===e)return{cues:[],styles:[]};var f=null;try{f=this.f.parseFromString(e,_.Wf)}catch(m){throw new _.H(_.F,2,2005,"Failed to parse TTML.");}d=new Rw(d);e=new Vw;f=new Uw(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=_.J(a,b,h);k=_.Ci(k);const m=`urn:mpeg:14496-30:subs:${g}`;d.h.set(m,
17
+ new Iw(m,k,{imageType:"PNG",encoding:"Base64"}));b+=h}for(;f.Dc();)a=f.next(),a=Fw(e,a),c=d,b=a,"tt"===Cw(b)&&(c.l=new Ow(c.B,Object.assign({},b.attributes))),c=d,b=a,"tt"===Cw(b)&&(c.w=new Mw(b.attributes.frameRate,b.attributes.subFrameRate,b.attributes.frameRateMultiplier,b.attributes.tickRate)),c=d,b=a,Cw(b)!==_.de||b.attributes.begin||b.attributes.end||(g=`#${b.getId()}`,c.h.set(g,new Iw(g,b.h.textContent,b.attributes))),c=d,g=a,Cw(g)===_.de&&g.attributes.begin&&g.attributes.end?(b=`#${yw()}`,
18
+ g=new Iw(b,g.h.textContent,g.attributes),c.h.set(b,g),c=g):c=null,c&&(a.j=c.getId()),c=d,b=a,Cw(b)===_.Sf&&(g=b.getId()||yw(),h=new Qw(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,Cw(g)!==_.Sf&&Aw(g)?(b=yw(),g=new Qw(b,[],Object.assign({},g.attributes)),c.a.set(b,g),c=g):c=null,c&&a.f.push(c.getId()),c=d,g=a,Cw(g)!==_.Gd||!g.attributes.extent&&!g.attributes.origin?c=null:(b=yw(),g=new Nw(b,Bw(c,g.f),Object.assign({},g.attributes)),c.j.set(b,g),c=g),c&&(a.a=
19
+ c.getId()),c=d,g=a,Cw(g)!==Wv?c=null:(b=g.getId(),g=new Nw(b,Bw(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(Cw(g))||0===b.length?c=null:(h=b[b.length-1],c.f.has(h)?(b=yw(),g=new Lw(b,"#text"===g.h.nodeName?g.h.textContent:null,"br"===Cw(g),g.a,g.j,Bw(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"===Cw(g)||g.j?(b=yw(),g=new Lw(b,null,!1,g.a,g.j,Bw(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=d.Rc();f=[];for(l of d.a.values())f.push(...l.build(d.l));var l=f;return{cues:e,styles:l}}};var Xw=class{constructor(a){this.f=a}a(a){var b=new Ww(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=Gw(d.startTime)+" --\x3e "+Gw(d.endTime);{var c=d;const e=[];switch(c.textAlign){case _.he:e.push("align:left");break;case _.zf:e.push("align:right");break;case _.ws:e.push("align:middle");break;case _.he:e.push("align:start");break;case _.zf:e.push("align:end")}switch(c.writingMode){case _.ig:e.push("vertical:lr");break;case _.jg:e.push("vertical:rl")}c=
21
+ e.length?" "+e.join(" "):""}b=a+(b+c+"\n");b+=d.payload+"\n\n"}return _.si(b)}},Yw=class{probe(a,b){return a===_.Dc&&b===_.Vf}create(a){return new Xw(a)}};var Zw=class{constructor(a){this.a=new Ww(a);this.g=new _.R("clpp.ttml.Mp4TtmlParser")}parseInit(a){let b=!1;(new _.Ml).M(_.Be,_.Fl).M(_.Yf,_.Fl).M(_.we,_.Fl).M(_.Ae,_.Fl).M(_.Pf,_.Fl).ca(_.Rf,_.Gl).M("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 _.Ml).M("moof",_.Fl).M("traf",_.Fl).ca("subs",g=>{const h=_.P(g.reader);for(let k=0;k<h;++k){g.reader.skip(4);const l=_.yl(g.reader);for(let m=0;m<l;++m){const n=1===g.version?
22
+ _.P(g.reader):_.yl(g.reader);f.push(n);g.reader.skip(6)}}}).M(_.ve,_.Hl(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 _.Yt{constructor(){super();this.j=new Yw}f(){_.gs(_.Dc,Ww);_.gs(_.Bc,Zw);_.gs(Qv,Zw);_.gs(Sv,Zw);_.gs(Rv,Zw);_.Dj.push(this.j)}a(){_.is(_.Dc);_.is(_.Bc);_.is(Qv);_.is(Sv);_.is(Rv);_.Fj(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 wv="VerimatrixVCAS",xv="clpp.verimatrix.Vcas",yv="clpp.verimatrix.VcasComponent",Av=function(a,b){return a.C===zv?(a=Object.assign({},{deviceId:_.Ai(_.ri(a.A))},a.a&&{authenticator:_.Ai(_.ri(a.a))}),b+_.hj(a)):b},Gv=class extends _.bt{constructor(a){super(wv);const b={};b[Bv]=Bv;b[Cv]=Cv;const {deviceId:c,authenticator:d,licenseRequestVuidLocation:e=zv,httpHeaderNames:f=b,widevineLicenseUrl:g,playReadyLicenseUrl:h,fairPlayLicenseUrl:k,fairPlayCertificateUrl:l,fairPlaySiteId:m,fairPlayAssetIdStrategy:n=
2
- Dv}=a;this.A=c;this.a=d;this.C=e;this.B=f;this.w=Av(this,g);this.o=Av(this,h);this.l=Av(this,k);this.j=l;this.G=m;this.F=n;this.h=new _.R(xv);_.vi(this.w)?this.h.warn(_.Wb):this.Qa(_.yd,{licenseUrl:this.w,videoRobustness:[_.Fb,void 0],audioRobustness:[_.Eb,void 0],persistentStateRequired:!1,distinctiveIdentifierRequired:!1,serverCertificate:null,modifiers:{licenseRequest:this.g.bind(this)}});_.vi(this.o)?this.h.warn(_.vb):this.Qa(_.wd,{licenseUrl:this.o,videoRobustness:["3000"],audioRobustness:["2000"],
3
- modifiers:{licenseRequest:this.g.bind(this)}});_.vi(this.l)?this.h.warn(_.Ua):_.vi(this.j)?this.h.warn(_.Ta):this.Qa(_.ud,{licenseUrl:this.l,certificateUrl:this.j,modifiers:{licenseRequest:this.J.bind(this),licenseResponse:this.K.bind(this),extractContentId:this.H.bind(this)}})}g(a,b){if(this.C===Ev){a=this.B[Cv];const c={};c[this.B[Bv]]=this.A;this.a&&(c[a]=this.a);Object.keys(c).forEach(d=>{b.headers[d]=c[d]})}}H(a,b){a=_.Il(b);switch(this.F){case Fv:a=_.hj({r:a,Uh:this.G},!0)}return a}J(a,b){this.g(a,
4
- b);_.Nl(b)}K(a,b){_.Ol(b)}};_.z(xv,Gv);Gv.prototype.constructor=Gv.prototype.constructor;Gv.NAME=wv;var zv="query-string",Ev="http-header";Gv.LicenseRequestVuidLocation={QUERY_STRING:zv,HTTP_HEADER:Ev};var Bv="DeviceId",Cv="Authenticator";Gv.LicenseRequestHttpHeader={DEVICE_ID_HEADER:Bv,AUTHENTICATOR_HEADER:Cv};var Dv="keyid",Fv="contentid-siteid";Gv.FairPlayAssetIdStrategy={KEYID:Dv,CONTENTID_SITEID:Fv};_.z(yv,class extends _.Pt{constructor(){super();this.h=new _.R(yv)}a(){delete _.kl.VerimatrixVCAS}g(a){a=a.getConfiguration();if(a.drm&&a.drm.env===wv){({customData:a}=a.drm);if(!a)throw new _.H(_.F,7,7100,_.zd);a=new Gv(a);this.h.info("Registering the Verimatrix VCAS Ultra environment");_.ll(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 Fv="VerimatrixVCAS",Gv="clpp.verimatrix.Vcas",Hv="clpp.verimatrix.VcasComponent",Jv=function(a,b){return a.C===Iv?(a=Object.assign({},{deviceId:_.Di(_.ui(a.A))},a.a&&{authenticator:_.Di(_.ui(a.a))}),b+_.kj(a)):b},Pv=class extends _.kt{constructor(a){super(Fv);const b={};b[Kv]=Kv;b[Lv]=Lv;const {deviceId:c,authenticator:d,licenseRequestVuidLocation:e=Iv,httpHeaderNames:f=b,widevineLicenseUrl:g,playReadyLicenseUrl:h,fairPlayLicenseUrl:k,fairPlayCertificateUrl:l,fairPlaySiteId:m,fairPlayAssetIdStrategy:n=
2
+ Mv}=a;this.A=c;this.a=d;this.C=e;this.B=f;this.w=Jv(this,g);this.o=Jv(this,h);this.l=Jv(this,k);this.j=l;this.G=m;this.F=n;this.g=new _.R(Gv);_.yi(this.w)?this.g.warn(_.Xb):this.Ta(_.zd,{licenseUrl:this.w,videoRobustness:[_.Gb,void 0],audioRobustness:[_.Fb,void 0],persistentStateRequired:!1,distinctiveIdentifierRequired:!1,serverCertificate:null,modifiers:{licenseRequest:this.h.bind(this)}});_.yi(this.o)?this.g.warn(_.wb):this.Ta(_.xd,{licenseUrl:this.o,videoRobustness:["3000"],audioRobustness:["2000"],
3
+ modifiers:{licenseRequest:this.h.bind(this)}});_.yi(this.l)?this.g.warn(_.Ua):_.yi(this.j)?this.g.warn(_.Ta):this.Ta(_.vd,{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===Nv){a=this.B[Lv];const c={};c[this.B[Kv]]=this.A;this.a&&(c[a]=this.a);Object.keys(c).forEach(d=>{b.headers[d]=c[d]})}}H(a,b){a=_.Ll(b);switch(this.F){case Ov:a=_.kj({r:a,Zh:this.G},!0)}return a}J(a,b){this.h(a,
4
+ b);_.Ql(b)}K(a,b){_.Rl(b)}};_.z(Gv,Pv);Pv.prototype.constructor=Pv.prototype.constructor;Pv.NAME=Fv;var Iv="query-string",Nv="http-header";Pv.LicenseRequestVuidLocation={QUERY_STRING:Iv,HTTP_HEADER:Nv};var Kv="DeviceId",Lv="Authenticator";Pv.LicenseRequestHttpHeader={DEVICE_ID_HEADER:Kv,AUTHENTICATOR_HEADER:Lv};var Mv="keyid",Ov="contentid-siteid";Pv.FairPlayAssetIdStrategy={KEYID:Mv,CONTENTID_SITEID:Ov};_.z(Hv,class extends _.Yt{constructor(){super();this.g=new _.R(Hv)}a(){delete _.nl.VerimatrixVCAS}h(a){a=a.getConfiguration();if(a.drm&&a.drm.env===Fv){({customData:a}=a.drm);if(!a)throw new _.H(_.F,7,7100,_.Ad);a=new Pv(a);this.g.info("Registering the Verimatrix VCAS Ultra environment");_.ol(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 mv="Registering listeners",nv="clpp.vimond.VimondPlugin",ov=function(a,b){a.m.trigger(new _.E(_.pg,{detail:b}))},pv=function(a,b,c){b&&(a.B=!0,a.g.stop());a.m.onError(new _.H(b?_.F:1,9,9201,c))},qv=function(a,b){const c=a.m.getState();if(1===b)return["str-start",_.af];if(a.g)return[_.Td,_.Me];if(c===_.Ln)return[_.Td,null];if(c===_.Sn)return[_.r,_.Me];b=_.Me;if(c===_.On||c===_.Wn||a.f)b=_.af;return["period",b]},rv=class{constructor(a,b,c,d,e){this.K=a;this.L=b;this.N=c;this.m=d;this.F=
2
- e;this.a=new _.ks;this.l=!0;this.f=this.j=this.B=!1;this.C=null;this.g=new _.Qj(this.A.bind(this));this.h=new _.R("clpp.vimond.VimondDispatcher");this.o=this.w=0;this.m&&this.a&&(this.h.debug(mv),this.a.on(this.m,_.Jf,this.I.bind(this)),this.a.on(this.m,_.Tf,this.J.bind(this)),this.a.on(this.m,_.bc,this.G.bind(this)),this.a.on(this.m,_.cc,this.H.bind(this)))}J(){this.f||(this.f=1<Math.abs(this.w-this.m.getPosition()));this.w=this.m.getPosition()}G(){this.h.debug("Ad break started");this.j=!0}H(){this.h.debug("Ad break stopped");
3
- this.j=!1}I(a){const b=this;return _.x(function*(){const c=a.detail,d=c.currentState;b.h.debug(`State changed, prev: ${c.previousState} curr: ${d}`);b.B||b.j||(d!==b.C||b.f?b.l&&d!==_.Wn||(b.f&&[_.Vn,_.On].includes(d)?b.h.debug("Seeking"):(b.f&&d===_.Wn&&(b.h.debug("Seeked"),b.f=!1),[_.Wn,_.Vn,_.Sn,_.Ln].includes(d)&&(b.C=d,yield b.A(),d===_.Ln&&b.g.stop()))):b.h.debug("Ignore transition"))})}A(){const a=this;return _.x(function*(){{const n=Math.floor(Date.now()/1E3);0<a.o&&a.h.debug(`Last event was ${n-
4
- a.o} seconds ago`);a.o=n}a.g.stop();a.g.fa(a.l?10:a.K);a.l=!1;try{{var b=a.F;b.f++;const q=_.Mg(b.o);q.client.buildName=_.ra;q.client.buildVersion=_.fa;var c=q.client;{const B=b.a.m.getDrmInfo();var d=B?B.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 B=b.a.m.getLoadedSource();var f=((new _.Hl(B.url)).scheme||"").replace(":",
5
- "")}e.videoProtocol=f;const u=qv(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 B=g.m.getPresentationStartTime()||0,D=Math.floor(B+g.m.getPosition());var h=(new Date(1E3*D)).toISOString()}v.position=h;{var k=b.a;const B=k.m.getPosition(),D=k.m.getSeekRange().end;var l=30>Math.abs(D-B)}v.onLiveEdge=l;typeof v.liveResumePossible!==_.Nc&&(v.liveResumePossible=!0)}q.progress.eventNumber=
6
- b.f;q.timestamp=(new Date).toISOString();b.h.debug("Fire an event");const y=_.Pi(b.l);y.method="POST";y.contentType="application/json";y.headers.Authorization=`Bearer ${b.g}`;y.body=_.ri(JSON.stringify(q));var m=b.j.fetch(y).P}const n=yield m;ov(a,n)}catch(n){m=n.code,b=n.data,[1002,1003].includes(m)?(a.h.debug("Unreachable service"),ov(a,b),pv(a,a.L,b)):1001===m?(a.h.debug("Generic service error"),ov(a,b),pv(a,a.N,b)):a.h.error(n.toString())}})}dispose(){this.h.debug(_.Ob);_.mh(this.a);this.g.stop()}};var sv=class{constructor(a,b,c,d,e){this.l=a;this.o=c;this.g=b;this.a=d;this.j=e;this.h=new _.R("clpp.vimond.VimondService");this.f=0}Ke(a){this.g=a}};var uv=class{constructor(a){this.m=a;this.a=new _.ks;this.h=new _.R("clpp.vimond.VimondAdapter");this.f=this.g=!1;this.m&&this.a&&(this.h.debug(mv),this.a.on(this.m,_.rf,this.o.bind(this)),this.a.on(this.m,_.bc,this.j.bind(this)),this.a.on(this.m,_.cc,this.l.bind(this)))}getPosition(){return Math.floor(this.m.getPosition())}o(){this.g=!0}j(){this.f=!0}l(){this.f=!1}dispose(){this.h.debug(_.Ob);_.mh(this.a)}};var vv=class extends _.ru{constructor(){super();this.a=!1;this.h=new _.R(nv);this.j=this.g=this.f=null}onPlayerCreated(){}onContentWillLoad(a){var b=a.getConfiguration();(this.a=!_.A(b.vimond)&&typeof b.vimond===_.Ce)?a.namespace()===_.jd&&(this.a=!1,this.h.info("Vimond does not report when casting.")):this.h.warn("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.h.warn(`${c} key is missing`);
7
- a.onError(new _.H(1,9,9200));return}this.h.debug(_.sa);c=b.failIfUnreachable;typeof c!==_.Nc&&(c=!0);var d=b.failOnError;typeof d!==_.Nc&&(d=!0);this.f=new uv(a);this.g=new sv(b.playerEventRequest.uri,b.authToken,b.playerEventRequest.body,this.f,a.getNetworkEngine());this.j=new rv(b.playerEventRequest.eventInterval,c,d,a,this.g)}}onPlayerWillRelease(){this.a&&(this.f&&this.f.dispose(),this.j&&this.j.dispose(),this.j=this.g=this.f=null)}onPlayerWillDestroy(){}id(){return"vimond"}Ke(a){this.a&&this.g&&
8
- this.g.Ke(a)}};_.z(nv,vv);vv.prototype.updateAuthToken=vv.prototype.Ke;vv.Id="vimond";_.ap(new class{create(){return new vv}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var wv="Registering listeners",xv="clpp.vimond.VimondPlugin",yv=function(a,b){a.m.trigger(new _.E(_.sg,{detail:b}))},zv=function(a,b,c){b&&(a.B=!0,a.h.stop());a.m.onError(new _.H(b?_.F:1,9,9201,c))},Av=function(a,b){const c=a.m.getState();if(1===b)return["str-start",_.df];if(a.h)return[_.Ud,_.Pe];if(c===_.On)return[_.Ud,null];if(c===_.Vn)return[_.r,_.Pe];b=_.Pe;if(c===_.Rn||c===_.Zn||a.f)b=_.df;return["period",b]},Bv=class{constructor(a,b,c,d,e){this.K=a;this.L=b;this.N=c;this.m=d;this.F=
2
+ e;this.a=new _.ts;this.l=!0;this.f=this.j=this.B=!1;this.C=null;this.h=new _.Tj(this.A.bind(this));this.g=new _.R("clpp.vimond.VimondDispatcher");this.o=this.w=0;this.m&&this.a&&(this.g.debug(wv),this.a.on(this.m,_.Nf,this.I.bind(this)),this.a.on(this.m,_.Xf,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!==_.Zn||(b.f&&[_.Yn,_.Rn].includes(d)?b.g.debug("Seeking"):(b.f&&d===_.Zn&&(b.g.debug("Seeked"),b.f=!1),[_.Zn,_.Yn,_.Vn,_.On].includes(d)&&(b.C=d,yield b.A(),d===_.On&&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.ha(a.l?10:a.K);a.l=!1;try{{var b=a.F;b.f++;const q=_.Pg(b.o);q.client.buildName=_.ra;q.client.buildVersion=_.fa;var c=q.client;{const B=b.a.m.getDrmInfo();var d=B?B.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 B=b.a.m.getLoadedSource();var f=((new _.Kl(B.url)).scheme||"").replace(":",
5
+ "")}e.videoProtocol=f;const u=Av(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 B=g.m.getPresentationStartTime()||0,D=Math.floor(B+g.m.getPosition());var h=(new Date(1E3*D)).toISOString()}v.position=h;{var k=b.a;const B=k.m.getPosition(),D=k.m.getSeekRange().end;var l=30>Math.abs(D-B)}v.onLiveEdge=l;typeof v.liveResumePossible!==_.Pc&&(v.liveResumePossible=!0)}q.progress.eventNumber=
6
+ b.f;q.timestamp=(new Date).toISOString();b.g.debug("Fire an event");const y=_.Si(b.l);y.method=_.ub;y.contentType="application/json";y.headers.Authorization=`Bearer ${b.h}`;y.body=_.ui(JSON.stringify(q));var m=b.j.fetch(y).R}const n=yield m;yv(a,n)}catch(n){m=n.code,b=n.data,[1002,1003].includes(m)?(a.g.debug("Unreachable service"),yv(a,b),zv(a,a.L,b)):1001===m?(a.g.debug("Generic service error"),yv(a,b),zv(a,a.N,b)):a.g.error(n.toString())}})}dispose(){this.g.debug(_.Pb);_.ph(this.a);this.h.stop()}};var Cv=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 _.R("clpp.vimond.VimondService");this.f=0}Me(a){this.h=a}};var Dv=class{constructor(a){this.m=a;this.a=new _.ts;this.g=new _.R("clpp.vimond.VimondAdapter");this.f=this.h=!1;this.m&&this.a&&(this.g.debug(wv),this.a.on(this.m,_.vf,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}dispose(){this.g.debug(_.Pb);_.ph(this.a)}};var Ev=class extends _.Au{constructor(){super();this.a=!1;this.g=new _.R(xv);this.j=this.h=this.f=null}onPlayerCreated(){}onContentWillLoad(a){var b=a.getConfiguration();(this.a=!_.A(b.vimond)&&typeof b.vimond===_.Fe)?a.namespace()===_.kd&&(this.a=!1,this.g.info("Vimond does not report when casting.")):this.g.warn("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(_.sa);c=b.failIfUnreachable;typeof c!==_.Pc&&(c=!0);var d=b.failOnError;typeof d!==_.Pc&&(d=!0);this.f=new Dv(a);this.h=new Cv(b.playerEventRequest.uri,b.authToken,b.playerEventRequest.body,this.f,a.getNetworkEngine());this.j=new Bv(b.playerEventRequest.eventInterval,c,d,a,this.h)}}onPlayerWillRelease(){this.a&&(this.f&&this.f.dispose(),this.j&&this.j.dispose(),this.j=this.h=this.f=null)}onPlayerWillDestroy(){}id(){return"vimond"}Me(a){this.a&&this.h&&
8
+ this.h.Me(a)}};_.z(xv,Ev);Ev.prototype.updateAuthToken=Ev.prototype.Me;Ev.Id="vimond";_.dp(new class{create(){return new Ev}});};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 Tu="touchmove",Uu="touchstart",Wu=function(a,b,c){c*=.5;const d=Math.sqrt(a*a+b*b),e=Math.sin(c);return new Vu(a/d*e,b/d*e,0/d*e,Math.cos(c))},Xu=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)},Yu=function(a,b){isFinite(b)?(a.x*=b,a.y*=b,a.a*=b):(a.x=0,a.y=0,a.a=0)},Zu=function(a,b){return a.x*b.x+a.y*b.y+a.a*b.a},$u=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},av=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},cv=function(a){var b=new bv(0,0,0),c=new bv(0,0,1);const d=new bv,e=new bv,f=new bv;a=a.a;var g=
3
- new bv(0,1,0);f.x=b.x-g.x;f.y=b.y-g.y;f.a=b.a-g.a;g=f.length();Yu(f,1/g);c=$u(d,c,f);g=c.length();Yu(c,1/g);$u(e,f,d);a[0]=d.x;a[1]=d.y;a[2]=d.a;a[3]=-Zu(d,b);a[4]=e.x;a[5]=e.y;a[6]=e.a;a[7]=-Zu(e,b);a[8]=f.x;a[9]=f.y;a[10]=f.a;a[11]=-Zu(f,b);a[12]=0;a[13]=0;a[14]=0;a[15]=1},dv=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},ev=function(a){a.a&&(a.a.removeEventListener("mousemove",a.A,!1),a.a.removeEventListener(Tu,a.A,!1),a.a.removeEventListener("mouseup",a.B,!1),a.a.removeEventListener("touchend",a.B,!1))},fv=function(a){const b=Wu(1,0,a.l*Math.PI/180);Xu(Wu(0,1,a.j*Math.PI/180),a.R);Xu(b,a.S);cv(a.Y);av(a.aa,a.R,a.Y);av(a.G,a.S,a.aa)},Vu=class{constructor(a,b,c,d){this.x=a||0;this.y=b||0;this.a=c||0;this.f=d||1}};var bv=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 gv=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 B=this.a;B[0]=a;B[4]=b;B[8]=c;B[12]=d;B[1]=e;B[5]=f;B[9]=g;B[13]=h;B[2]=k;B[6]=l;B[10]=m;B[14]=n;B[3]=q;B[7]=u;B[11]=v;B[15]=y;return this}};var hv=class{constructor(a){this.a=a;this.f=a.createProgram();this.l=dv(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=dv(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.g=a.getUniformLocation(this.f,"Mvpm");a.uniform1i(a.getUniformLocation(this.f,"Texture0"),0);a.useProgram(null)}};var iv=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.g=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 jv=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 kv={alpha:!1,depth:!0,stencil:!1,antialias:!0,premultipliedAlpha:!1,preserveDrawingBuffer:!1,devicePixelRatio:1},lv=class extends _.ru{constructor(){super();this.o=this.w=this.K=this.I=this.C=this.X=this.G=this.f=this.a=this.m=null;this.h=new _.R("clpp.vr");this.H=70;this.W=1;this.N=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.g={x:0,y:0};this.R=new gv;this.S=new gv;this.Y=new gv;this.aa=new gv;this.A=this.da.bind(this);this.B=this.ja.bind(this);this.J=this.ea.bind(this)}onPlayerCreated(a){this.h.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&&_.Ug(d))this.H=d;else throw new _.H(1,7,7100,"fieldOfView configuration must be a number");if(void 0!==e&&_.Ug(e)&&0<e)this.W=e;else throw new _.H(1,7,7100,"sensitivity configuration must be a positive number");this.L=!!f;this.N=!!c}if(a=a.getSurface())if((d=a.getMedia())&&d.tagName.toLowerCase()===_.w){this.h.info("Initialize VR Surface");if(!this.a){this.a=document.createElement("canvas");this.a.style.width="100%";this.f=this.a.getContext("webgl",kv)||this.a.getContext("experimental-webgl",
9
- kv);if(!this.f)throw new _.H(1,9,9003,"Unable to create GL context");this.G=new gv;cv(this.G);this.X=new iv(this.f);this.C=new hv(this.f);this.I=new gv;this.K=new gv;this.o=this.w=null;this.a.addEventListener(_.uf,this.F)}a.addElementToContainer(this.a,!0,!0);a.hideMediaElement();b.vr.attachMouseListener&&(this.a.addEventListener("mousedown",this.J,!1),this.a.addEventListener(Uu,this.J,!1));this.F();this.T()}else this.h.info("No video element found, can not initialize VR plugin");else this.h.info("No surface found, can not initialize VR plugin")}}onPlayerWillRelease(){this.h.info("Releasing VR plugin resources");
10
- this.w&&cancelAnimationFrame(this.w);this.g.x=0;this.l=this.j=this.g.y=0;this.f&&(delete this.f,this.f=null);this.a&&(ev(this),this.a.removeEventListener(_.uf,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"}T(){if(this.m&&this.f){var a=this.m.getSurface();if(a&&(a=a.getMedia())&&a.tagName.toLowerCase()===_.w){this.w=requestAnimationFrame(this.T.bind(this));
11
- var b=this.f;this.o||a.readyState!==a.HAVE_ENOUGH_DATA||(this.o=new jv(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=av(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.g,!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.g);a=this.o;a.a.bindTexture(a.a.TEXTURE_2D,null);this.C.a.useProgram(null)}}}}ea(a){this.h.debug("Mouse Down. Enable VR mouse interaction");a.preventDefault();if(0===a.button||a.type===Uu)a.type===Uu?a.touches[0]&&(this.g.x=a.touches[0].clientX,this.g.y=a.touches[0].clientY):(this.g.x=a.clientX,this.g.y=a.clientY),this.h.debug("Mouse Start coordinates:",this.g,a),this.a.addEventListener("mousemove",this.A,!1),this.a.addEventListener(Tu,this.A,!1),this.a.addEventListener("mouseup",this.B,!1),this.a.addEventListener("touchend",
14
- this.B,!1)}da(a){a.preventDefault();var b=a.clientX;let c=a.clientY;a.type===Tu&&a.touches[0]&&(b=a.touches[0].clientX,c=a.touches[0].clientY);a=this.g.x-b;const d=this.g.y-c;this.g.x=b;this.g.y=c;b=this.W;const {eg:e,fg:f}={eg:a*b*(this.L?-1:1),fg:d*b*(this.N?-1:1)};this.j+=e;this.l+=f;fv(this)}ja(a){this.h.debug("Mouse Up. Removing mouse interaction listeners");a.preventDefault();ev(this)}Wg(a,b){this.l=b;this.j=a;fv(this)}yg(){return{x:this.j,y:this.l}}jh(a){this.H=a;this.F()}};
15
- _.z("clpp.vr.VrPlugin",lv);lv.prototype.setCameraFieldOfView=lv.prototype.jh;lv.prototype.getCameraCoordinates=lv.prototype.yg;lv.prototype.moveCamera=lv.prototype.Wg;lv.Id="vr";_.ap(new class{create(){return new lv}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var bv="touchmove",cv="touchstart",ev=function(a,b,c){c*=.5;const d=Math.sqrt(a*a+b*b),e=Math.sin(c);return new dv(a/d*e,b/d*e,0/d*e,Math.cos(c))},fv=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)},gv=function(a,b){isFinite(b)?(a.x*=b,a.y*=b,a.a*=b):(a.x=0,a.y=0,a.a=0)},hv=function(a,b){return a.x*b.x+a.y*b.y+a.a*b.a},iv=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},jv=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},lv=function(a){var b=new kv(0,0,0),c=new kv(0,0,1);const d=new kv,e=new kv,f=new kv;a=a.a;var g=
3
+ new kv(0,1,0);f.x=b.x-g.x;f.y=b.y-g.y;f.a=b.a-g.a;g=f.length();gv(f,1/g);c=iv(d,c,f);g=c.length();gv(c,1/g);iv(e,f,d);a[0]=d.x;a[1]=d.y;a[2]=d.a;a[3]=-hv(d,b);a[4]=e.x;a[5]=e.y;a[6]=e.a;a[7]=-hv(e,b);a[8]=f.x;a[9]=f.y;a[10]=f.a;a[11]=-hv(f,b);a[12]=0;a[13]=0;a[14]=0;a[15]=1},mv=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},nv=function(a){a.a&&(a.a.removeEventListener("mousemove",a.A,!1),a.a.removeEventListener(bv,a.A,!1),a.a.removeEventListener("mouseup",a.B,!1),a.a.removeEventListener("touchend",a.B,!1))},ov=function(a){const b=ev(1,0,a.l*Math.PI/180);fv(ev(0,1,a.j*Math.PI/180),a.O);fv(b,a.S);lv(a.Z);jv(a.aa,a.O,a.Z);jv(a.G,a.S,a.aa)},dv=class{constructor(a,b,c,d){this.x=a||0;this.y=b||0;this.a=c||0;this.f=d||1}};var kv=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 pv=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 B=this.a;B[0]=a;B[4]=b;B[8]=c;B[12]=d;B[1]=e;B[5]=f;B[9]=g;B[13]=h;B[2]=k;B[6]=l;B[10]=m;B[14]=n;B[3]=q;B[7]=u;B[11]=v;B[15]=y;return this}};var qv=class{constructor(a){this.a=a;this.f=a.createProgram();this.l=mv(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=mv(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 rv=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 sv=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 uv={alpha:!1,depth:!0,stencil:!1,antialias:!0,premultipliedAlpha:!1,preserveDrawingBuffer:!1,devicePixelRatio:1},vv=class extends _.Au{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 _.R("clpp.vr");this.H=70;this.W=1;this.N=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 pv;this.S=new pv;this.Z=new pv;this.aa=new pv;this.A=this.ea.bind(this);this.B=this.la.bind(this);this.J=this.ga.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&&_.Xg(d))this.H=d;else throw new _.H(1,7,7100,"fieldOfView configuration must be a number");if(void 0!==e&&_.Xg(e)&&0<e)this.W=e;else throw new _.H(1,7,7100,"sensitivity configuration must be a positive number");this.L=!!f;this.N=!!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",uv)||this.a.getContext("experimental-webgl",
9
+ uv);if(!this.f)throw new _.H(1,9,9003,"Unable to create GL context");this.G=new pv;lv(this.G);this.X=new rv(this.f);this.C=new qv(this.f);this.I=new pv;this.K=new pv;this.o=this.w=null;this.a.addEventListener(_.yf,this.F)}a.addElementToContainer(this.a,!0,!0);a.hideMediaElement();b.vr.attachMouseListener&&(this.a.addEventListener("mousedown",this.J,!1),this.a.addEventListener(cv,this.J,!1));this.F();this.T()}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&&(nv(this),this.a.removeEventListener(_.yf,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"}T(){if(this.m&&this.f){var a=this.m.getSurface();if(a&&(a=a.getMedia())&&a.tagName.toLowerCase()===_.w){this.w=requestAnimationFrame(this.T.bind(this));
11
+ var b=this.f;this.o||a.readyState!==a.HAVE_ENOUGH_DATA||(this.o=new sv(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=jv(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)}}}}ga(a){this.g.debug("Mouse Down. Enable VR mouse interaction");a.preventDefault();if(0===a.button||a.type===cv)a.type===cv?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(bv,this.A,!1),this.a.addEventListener("mouseup",this.B,!1),this.a.addEventListener("touchend",
14
+ this.B,!1)}ea(a){a.preventDefault();var b=a.clientX;let c=a.clientY;a.type===bv&&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.W;const {gg:e,hg:f}={gg:a*b*(this.L?-1:1),hg:d*b*(this.N?-1:1)};this.j+=e;this.l+=f;ov(this)}la(a){this.g.debug("Mouse Up. Removing mouse interaction listeners");a.preventDefault();nv(this)}Zg(a,b){this.l=b;this.j=a;ov(this)}Ag(){return{x:this.j,y:this.l}}nh(a){this.H=a;this.F()}};
15
+ _.z("clpp.vr.VrPlugin",vv);vv.prototype.setCameraFieldOfView=vv.prototype.nh;vv.prototype.getCameraCoordinates=vv.prototype.Ag;vv.prototype.moveCamera=vv.prototype.Zg;vv.Id="vr";_.dp(new class{create(){return new vv}});};f.call(g, window);