@castlabs/prestoplay 6.24.0 → 6.25.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/cjs/cl.adobe.js +3 -3
  3. package/cjs/cl.airplay.js +3 -3
  4. package/cjs/cl.broadpeak.js +7 -7
  5. package/cjs/cl.cast.js +116 -116
  6. package/cjs/cl.conviva.js +32 -32
  7. package/cjs/cl.core.js +596 -597
  8. package/cjs/cl.crypto.js +9 -9
  9. package/cjs/cl.dash.js +88 -87
  10. package/cjs/cl.externs.js +42 -55
  11. package/cjs/cl.freewheel.js +25 -25
  12. package/cjs/cl.hls.js +77 -73
  13. package/cjs/cl.hlssmpte.js +6 -6
  14. package/cjs/cl.htmlcue.js +30 -30
  15. package/cjs/cl.ima.js +24 -23
  16. package/cjs/cl.mse.js +346 -341
  17. package/cjs/cl.muxdata.js +15 -15
  18. package/cjs/cl.onboard.js +3 -3
  19. package/cjs/cl.persistent.js +15 -15
  20. package/cjs/cl.playlist.js +6 -6
  21. package/cjs/cl.sessions.js +16 -16
  22. package/cjs/cl.simid.js +15 -15
  23. package/cjs/cl.smooth.js +72 -72
  24. package/cjs/cl.thumbnails.js +26 -26
  25. package/cjs/cl.tizen.js +72 -72
  26. package/cjs/cl.ttml.js +29 -29
  27. package/cjs/cl.verimatrix.js +5 -5
  28. package/cjs/cl.vimond.js +12 -12
  29. package/cjs/cl.vr.js +19 -19
  30. package/cjs/cl.vtt.js +14 -14
  31. package/cjs/cl.yospace.js +4 -4
  32. package/cjs/cl.youbora.js +31 -31
  33. package/cl.adobe.js +3 -3
  34. package/cl.airplay.js +3 -3
  35. package/cl.broadpeak.js +5 -5
  36. package/cl.cast.js +84 -84
  37. package/cl.conviva.js +27 -27
  38. package/cl.core.js +473 -474
  39. package/cl.crypto.js +9 -9
  40. package/cl.dash.js +75 -74
  41. package/cl.externs.js +42 -55
  42. package/cl.freewheel.js +15 -15
  43. package/cl.hls.js +79 -75
  44. package/cl.hlssmpte.js +5 -5
  45. package/cl.htmlcue.js +26 -26
  46. package/cl.ima.js +15 -14
  47. package/cl.mse.js +306 -304
  48. package/cl.muxdata.js +13 -13
  49. package/cl.onboard.js +4 -4
  50. package/cl.persistent.js +10 -10
  51. package/cl.playlist.js +5 -5
  52. package/cl.sessions.js +10 -10
  53. package/cl.simid.js +13 -13
  54. package/cl.smooth.js +60 -59
  55. package/cl.thumbnails.js +19 -19
  56. package/cl.tizen.js +57 -57
  57. package/cl.ttml.js +22 -22
  58. package/cl.verimatrix.js +4 -4
  59. package/cl.vimond.js +8 -8
  60. package/cl.vr.js +14 -14
  61. package/cl.vtt.js +12 -12
  62. package/cl.yospace.js +3 -3
  63. package/cl.youbora.js +26 -26
  64. package/clpp.styles.css +4 -0
  65. package/package.json +1 -1
  66. package/typings.d.ts +19 -26
package/cl.thumbnails.js CHANGED
@@ -1,19 +1,19 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Ty="Thumbnail URL is mandatory",Uy="Wrong gridSize format",Vy="clpp.thumbnails",Xy=function(a,b){b.reduce((c,d)=>{let e=d,f=!1;typeof d===_.Re&&(e=d.step,f=d.preloadWhileBuffering);return c.then(()=>Wy(a,0,e,!!f))},Promise.resolve())},Wy=function(a,b,c,d){if(a.w||b>=a.a.length)return Promise.resolve();const e=b+c;return Yy(a,d).then(()=>a.a[b].load()).then(()=>Wy(a,e,c,d))},Yy=function(a,b){return new Promise(c=>{if(b||a.player.getState()!==_.cp)c();else a.player.one(_.$c,()=>{c()})})},
2
- Zy=function(a){const b=a.a.byteLength;a.f.forEach(c=>{c.offset+c.length<b&&c.Qc.resolve()})},bz=function(a,b){return $y(a,b).then(c=>new az(c,b.time,b.duration))},$y=function(a,b){return b.load().then(()=>{const c=_.K(a.a,b.offset,b.length);return"data:image/jpeg;base64,"+_.qj(c)})},cz=function(a){a=a.split(/\.|:/).map(parseFloat);let b=0,c;const d={3:.001,2:1,1:60,0:3600};for(c=a.length-1;0<=c;c--)b+=a[c]*d[c];return b},dz=function(a,b){let c=null;for(const d of a)d.startTime<=b&&(c=d);return c},
3
- ez=function(a,b){const c=a.horizontalTiles||b.horizontalTiles||1,d=a.verticalTiles||b.verticalTiles||1,e=c*d;return{kd:c,pf:d,Zf:e,durationPerTile:a.durationPerTile||b.durationPerTile||(a.endTime-a.startTime)/e}},fz=function(a){return a.some(b=>0<b.thumbStreams.length)},nz=function(a){return a?a===gz||a===hz?new iz:a===jz?new kz:a===lz?new mz:null:null},oz=function(a){if(!a)return null;a=new _.Am(a);return a.path.match(/.*\.vtt$/i)?jz:a.path.match(/.*\.bif$/i)?lz:a.path.match(/.*\.(png|jpg|jpeg)$/i)?
4
- gz:null};var pz=class{constructor(){this.log=new _.S(Vy);this.player=null;this.a=[];this.w=!1}init(a,b){this.player=a;a.one(_.Hf,()=>{this.w=!0});a.isLive()||this.l().then(()=>{b&&b.preload&&Xy(this,b.preload)})}};var az=class{constructor(a,b,c,d,e,f,g,h,k,l,m,n){d=void 0===d?0:d;e=void 0===e?0:e;f=void 0===f?0:f;g=void 0===g?0:g;h=void 0===h?1:h;k=void 0===k?1:k;l=void 0===l?0:l;m=void 0===m?0:m;n=void 0===n?new Image:n;this.time=b;this.src=a;this.duration=c;this.x=d;this.y=e;this.width=f;this.height=g;this.ta=n;this.ah=h;this.fi=k;this.Bh=l;this.Ch=m;this.Ce=null}raw(){return this.ta.cloneNode(!1)}element(a,b){let c=this.width,d=this.height;const e=this.width/this.height;void 0!==a&&void 0===b&&(b=0);null!==
5
- a&&void 0!==a&&(c=a);null!==b&&void 0!==b&&(d=b);c||(c=Math.ceil(d*e));d||(d=Math.ceil(c/e));a=document.createElement(_.Sd);a.style.width=c+_.Ef;a.style.height=d+_.Ef;a.style.backgroundColor="#000";a.style.backgroundRepeat="no-repeat";a.style.backgroundImage=`url("${this.src}")`;a.style.backgroundSize=`${Math.ceil(c/this.width*(this.ta.naturalWidth||this.ta.width))}px ${Math.ceil(d/this.height*(this.ta.naturalHeight||this.ta.height))}px`;b=this.y/this.height;a.style.backgroundPositionX="-"+this.x/
6
- this.width*c+_.Ef;a.style.backgroundPositionY="-"+b*d+_.Ef;return a}load(){this.Ce||(this.Ce=new Promise((a,b)=>{const c=()=>{this.width||(this.width=(this.ta.naturalWidth||this.ta.width)/this.ah);this.height||(this.height=(this.ta.naturalHeight||this.ta.height)/this.fi);this.x||(this.x=this.width*this.Bh);this.y||(this.y=this.height*this.Ch)};if(this.ta.src&&this.ta.complete)c(),a(this);else{var d=null,e=()=>{c();this.ta.removeEventListener(_.Ce,e);this.ta.removeEventListener(_.r,d);a(this)};d=f=>
7
- {this.ta.removeEventListener(_.Ce,e);this.ta.removeEventListener(_.r,d);b(new _.I(1,9,2014,"Failed to load thumbnail.",f))};this.ta.addEventListener(_.Ce,e);this.ta.addEventListener(_.r,d);this.ta.src=this.src}}));return this.Ce}};_.z("clpp.thumbnails.Thumbnail",az);az.prototype.load=az.prototype.load;az.prototype.element=az.prototype.element;az.prototype.raw=az.prototype.raw;var iz=class extends pz{constructor(){super();this.f=null;this.o=this.h=1;this.j=0}init(a,b){if(!b||!b.url)throw new _.I(1,9,7100,Ty);if("GRID"===b.mode&&!b.gridSize)throw new _.I(1,9,7100,"Grid size is mandatory for GRID mode");if(!b.duration)throw new _.I(1,9,7100,"Duration is mandatory");this.f=b;this.j=this.f.duration;if(this.f.gridSize)try{const c=this.f.gridSize.split(/x/).map(d=>parseInt(d,10)).filter(d=>0<d);if(2===c.length)this.h=c[0],this.o=c[1];else throw new _.I(1,9,7100,Uy);}catch(c){throw this.log.error("Error during parsing gridSize",
8
- c),new _.I(1,9,7100,Uy);}super.init(a,b)}get(a){const b=this;return _.x(function*(){var c=b.player.getDuration();if(0>a||a>c)throw new _.I(1,9,2014,`Position is out of range: ${a}`);c=Math.floor(a/b.f.duration);const d=b.a[c];if(!d)throw new _.I(1,9,2014,"No thumbnail found for position "+a+" at index "+c);yield d.load();return d})}l(){if(0<this.a.length)return Promise.resolve();var a=this.player.getDuration();const b=this.h*this.o;a=Math.ceil(Math.ceil(a/this.j)/b);const c=this.f.templateKey||"$index$";
9
- for(let d=0;d<a;d++){const e=this.f.url.replace(c,String(d+1)),f=new Image;for(let g=0;g<b;g++)this.a.push(new az(e,this.j*(d*b+g),this.j,0,0,0,0,this.h,this.o,g%this.h,Math.floor(g/this.h),f))}return Promise.resolve()}};var qz=class{constructor(a,b){this.time=a;this.duration=0;this.offset=b;this.length=0;this.Qc=new _.qn}load(){return this.Qc}},mz=class{constructor(){this.g=new _.S(Vy);this.a=new ArrayBuffer(0);this.f=[];this.h=new _.qn}init(a,b){if(!b||!b.url)throw new _.I(1,9,7100,Ty);const c=b.url;b=_.Jj(c);b.type=_.Ij;a.getNetworkEngine().fetch(b).U.then(d=>{var e=d.data;d=_.K(this.a);e=_.K(e);var f=d.byteLength+e.byteLength,g=new ArrayBuffer(f),h=new DataView(g),k=0;for(let l=0,m=d.byteLength;l<m;l++)h.setUint8(k,
10
- d[l]),k+=1;for(let l=0,m=e.byteLength;l<m;l++)h.setUint8(k,e[l]),k+=1;this.a=g;this.g.info(`Appended ${e.byteLength} bytes.`+`Total data now ${f} bytes.`);f=this.a;d=_.K(f);h=String.fromCharCode.apply(null,rz);k=Array.prototype.slice.call(d,0,8);d=64;e=0;g=!1;if(h===String.fromCharCode.apply(null,k))for(f=new DataView(f,16,20),f=f.getUint32(0,!0),0===f&&(f=1E3);!g;){e+=1;k=f;h=new DataView(this.a,d);g=h.getUint32(0,!0);k=g*k/1E3;h=h.getUint32(4,!0);h=new qz(k,h);if(k=this.f.length)k=this.f[k-1],k.length=
11
- h.offset-k.offset,k.duration=h.time-k.time;this.f.push(h);d+=8;(g=4294967295===g)&&this.h.resolve();if(1E5<e)throw Error("There was a problem during reading BIF entries");}else throw Error("The file is not a valid BIF format");Zy(this)}).catch(d=>{this.g.error(`[BIF] Error while loading thumbnails '
12
- + 'URL: ${c}`,d);a.onError(new _.I(1,9,2013,"Error while loading and parsing BIF thumbnails.",d))})}get(a){const b=this;return _.x(function*(){if(0>a)throw new _.I(1,9,2014,`Position is out of range: ${a}`);yield b.h;var c=b.f.find(d=>a>=d.time&&a<d.time+d.duration);if(!c)throw new _.I(1,9,2014,`No thumbnail found for position: ${a}`);c=yield bz(b,c);yield c.load();return c})}},rz=[137,66,73,70,13,10,26,10];var kz=class extends pz{constructor(){super();this.f=null}init(a,b){if(!b||!b.url)throw new _.I(1,9,7100,Ty);const c=b.url,d=_.Jj(c);d.type=_.Ij;this.f=a.getNetworkEngine().fetch(d).U.then(e=>{e=e.data;if(!e)throw Error("No data in the response");e=_.cj(e).split(/\n/);for(let m=0;m<e.length;m++){var f=e[m],g=f.split(" --\x3e ");if(2===g.length){f=e[++m];var h=f.indexOf("\x3d");var k=h=0>h?[]:f.substr(h+1).split(/,/).map(parseFloat);h=k[0];const n=k[1],q=k[2];k=k[3];var l=f.indexOf("#");f=0>l?f:f.substr(0,
13
- l);f.match(/^http|^\/\//)||(f=c.substr(0,c.lastIndexOf("/"))+"/"+f);l=cz(g[0]);g=cz(g[1])-l;this.a.push(new az(f,l,g,h,n,q,k,0,0))}}}).catch(e=>{this.log.error("[VTT] Error while loading thumbnails "+`URL: ${c}`,e);a.onError(new _.I(1,9,2013,"Error while loading VTT thumbnails.",e))});super.init(a,b)}get(a){const b=this;return _.x(function*(){if(0>a)throw new _.I(1,9,2014,`Position is out of range: ${a}`);yield b.f;const c=b.a.find(d=>a>=d.time&&a<d.time+d.duration);if(!c)throw new _.I(1,9,2014,`No thumbnail found for position: ${a}`);
14
- yield c.load();return c})}l(){return this.f}};var sz=class extends pz{get(a){const b=this;return _.x(function*(){function c(){return new _.I(1,9,2014,`No thumbnail found for position: ${a}`)}if(0>a)throw b.log.error("Position must be greater than 0 but is "+a),new _.I(1,9,2014,`Position is out of range: ${a}`);var d=b.player.getPeriods();d=dz(d,a);if(!d)throw b.log.error("Could not find period for specified position",a),c();var e=d.thumbStreams.sort(b.f)[0];if(!e)throw b.log.error("Could not find thumb stream for specified position",a),c();d=
15
- e.findSegmentPosition(a-d.startTime);if(null===d||void 0===d)throw b.log.error("Could not find segment index for specified position",a),c();var f=e.getSegmentReference(d);if(f){const h=ez(f,e),k=Math.floor((a-f.startTime)/h.durationPerTile);var g;if(0<b.a.length)f=e.findSegmentPosition(0),null!==f&&(g=b.a[(d-f)*h.Zf+k]);else if((e=f.ab())&&0<e.length){let l=g=0;f=f.startTime;1<h.Zf&&(g=k%h.kd,l=Math.floor(k/h.kd),f+=k*h.durationPerTile);g=new az(e[0],f,h.durationPerTile,void 0,void 0,void 0,void 0,
16
- h.kd,h.pf,g,l)}if(g)return yield g.load(),g}b.log.error("segment reference for specified segment index does not exist",d);throw c();})}f(a,b){return void 0!==a.bandwidth&&void 0!==b.bandwidth?a.bandwidth-b.bandwidth:0}l(){if(0<this.a.length)return Promise.resolve();var a=this.player.getPeriods();for(const b of a)if(a=b.thumbStreams.sort(this.f)[0]){let c=a.findSegmentPosition(0),d;for(;null!==c&&!_.B(d=a.getSegmentReference(c++));){const e=ez(d,a),f=d.ab()[0],g=new Image;let h=d.startTime;for(let k=
17
- 0;k<e.pf;++k)for(let l=0;l<e.kd;++l)this.a.push(new az(f,h,e.durationPerTile,void 0,void 0,void 0,void 0,e.kd,e.pf,l,k,g)),h+=e.durationPerTile}}return Promise.resolve()}};var tz=class{constructor(){this.g=new _.S(Vy);this.a=this.m=null}onPlayerCreated(a){this.m=a}onPlayerWillDestroy(){this.m=null}onPlayerWillRelease(){this.a=null}onContentWillLoad(a){const b=a.getConfiguration().thumbnails;if(b)if(!1===b.enabled)this.g.info("Thumbnails disabled.");else{var c=b.mode||null;c||(c=oz(b.url||null));(this.a=nz(c))?(this.g.info("Loading thumbs configuration",b),this.m.one(_.Ee,()=>{this.g.info("Initialize thumbnails provider");try{this.a.init(a,b)}catch(d){this.m.onError(d)}})):
18
- this.g.warn("Unknown thumbnail mode",c)}else this.a=null}onContentLoaded(a){if(!this.a){var b=a.getConfiguration();b=b&&b.thumbnails;if(!b||void 0===b.enabled||b.enabled){var c=a.getPeriods();if(fz(c)){this.a=new sz;try{this.a.init(a,b)}catch(d){this.m.onError(d)}}}}}get(a){return this.a?this.a.get(a):Promise.reject(new _.I(1,9,2014,"Thumbnail format is not supported"))}id(){return"thumbnails"}};_.z("clpp.thumbnails.ThumbnailsPlugin",tz);tz.prototype.get=tz.prototype.get;tz.Id="thumbnails";_.Mr(new class{create(){return new tz}});
19
- var gz="SINGLE",hz="GRID",jz="WEBVTT",lz="BIF";};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Vy="Thumbnail URL is mandatory",Wy="Wrong gridSize format",Xy="clpp.thumbnails",Zy=function(a,b){b.reduce((c,d)=>{let e=d,f=!1;typeof d===_.Se&&(e=d.step,f=d.preloadWhileBuffering);return c.then(()=>Yy(a,0,e,!!f))},Promise.resolve())},Yy=function(a,b,c,d){if(a.w||b>=a.a.length)return Promise.resolve();const e=b+c;return $y(a,d).then(()=>a.a[b].load()).then(()=>Yy(a,e,c,d))},$y=function(a,b){return new Promise(c=>{if(b||a.player.getState()!==_.dp)c();else a.player.one(_.ad,()=>{c()})})},
2
+ az=function(a){const b=a.a.byteLength;a.f.forEach(c=>{c.offset+c.length<b&&c.Rc.resolve()})},dz=function(a,b){return bz(a,b).then(c=>new cz(c,b.time,b.duration))},bz=function(a,b){return b.load().then(()=>{const c=_.K(a.a,b.offset,b.length);return"data:image/jpeg;base64,"+_.Wl(c)})},ez=function(a){a=a.split(/\.|:/).map(parseFloat);let b=0,c;const d={3:.001,2:1,1:60,0:3600};for(c=a.length-1;0<=c;c--)b+=a[c]*d[c];return b},fz=function(a,b){let c=null;for(const d of a)d.startTime<=b&&(c=d);return c},
3
+ gz=function(a,b){const c=a.horizontalTiles||b.horizontalTiles||1,d=a.verticalTiles||b.verticalTiles||1,e=c*d;return{ld:c,pf:d,Zf:e,durationPerTile:a.durationPerTile||b.durationPerTile||(a.endTime-a.startTime)/e}},hz=function(a){return a.some(b=>0<b.thumbStreams.length)},pz=function(a){return a?a===iz||a===jz?new kz:a===lz?new mz:a===nz?new oz:null:null},qz=function(a){if(!a)return null;a=new _.Bm(a);return a.path.match(/.*\.vtt$/i)?lz:a.path.match(/.*\.bif$/i)?nz:a.path.match(/.*\.(png|jpg|jpeg)$/i)?
4
+ iz:null};var rz=class{constructor(){this.log=new _.S(Xy);this.player=null;this.a=[];this.w=!1}init(a,b){this.player=a;a.one(_.If,()=>{this.w=!0});a.isLive()||this.l().then(()=>{b&&b.preload&&Zy(this,b.preload)})}};var cz=class{constructor(a,b,c,d,e,f,g,h,k,l,m,n){d=void 0===d?0:d;e=void 0===e?0:e;f=void 0===f?0:f;g=void 0===g?0:g;h=void 0===h?1:h;k=void 0===k?1:k;l=void 0===l?0:l;m=void 0===m?0:m;n=void 0===n?new Image:n;this.time=b;this.src=a;this.duration=c;this.x=d;this.y=e;this.width=f;this.height=g;this.ta=n;this.ah=h;this.gi=k;this.Bh=l;this.Ch=m;this.Ce=null}raw(){return this.ta.cloneNode(!1)}element(a,b){let c=this.width,d=this.height;const e=this.width/this.height;void 0!==a&&void 0===b&&(b=0);null!==
5
+ a&&void 0!==a&&(c=a);null!==b&&void 0!==b&&(d=b);c||(c=Math.ceil(d*e));d||(d=Math.ceil(c/e));a=document.createElement(_.Sd);a.style.width=c+_.Ff;a.style.height=d+_.Ff;a.style.backgroundColor="#000";a.style.backgroundRepeat="no-repeat";a.style.backgroundImage=`url("${this.src}")`;a.style.backgroundSize=`${Math.ceil(c/this.width*(this.ta.naturalWidth||this.ta.width))}px ${Math.ceil(d/this.height*(this.ta.naturalHeight||this.ta.height))}px`;b=this.y/this.height;a.style.backgroundPositionX="-"+this.x/
6
+ this.width*c+_.Ff;a.style.backgroundPositionY="-"+b*d+_.Ff;return a}load(){this.Ce||(this.Ce=new Promise((a,b)=>{const c=()=>{this.width||(this.width=(this.ta.naturalWidth||this.ta.width)/this.ah);this.height||(this.height=(this.ta.naturalHeight||this.ta.height)/this.gi);this.x||(this.x=this.width*this.Bh);this.y||(this.y=this.height*this.Ch)};if(this.ta.src&&this.ta.complete)c(),a(this);else{var d=null,e=()=>{c();this.ta.removeEventListener(_.De,e);this.ta.removeEventListener(_.q,d);a(this)};d=f=>
7
+ {this.ta.removeEventListener(_.De,e);this.ta.removeEventListener(_.q,d);b(new _.I(1,9,2014,"Failed to load thumbnail.",f))};this.ta.addEventListener(_.De,e);this.ta.addEventListener(_.q,d);this.ta.src=this.src}}));return this.Ce}};_.z("clpp.thumbnails.Thumbnail",cz);cz.prototype.load=cz.prototype.load;cz.prototype.element=cz.prototype.element;cz.prototype.raw=cz.prototype.raw;var kz=class extends rz{constructor(){super();this.f=null;this.o=this.h=1;this.j=0}init(a,b){if(!b||!b.url)throw new _.I(1,9,7100,Vy);if("GRID"===b.mode&&!b.gridSize)throw new _.I(1,9,7100,"Grid size is mandatory for GRID mode");if(!b.duration)throw new _.I(1,9,7100,"Duration is mandatory");this.f=b;this.j=this.f.duration;if(this.f.gridSize)try{const c=this.f.gridSize.split(/x/).map(d=>parseInt(d,10)).filter(d=>0<d);if(2===c.length)this.h=c[0],this.o=c[1];else throw new _.I(1,9,7100,Wy);}catch(c){throw this.log.error("Error during parsing gridSize",
8
+ c),new _.I(1,9,7100,Wy);}super.init(a,b)}get(a){const b=this;return _.x(function*(){var c=b.player.getDuration();if(0>a||a>c)throw new _.I(1,9,2014,`Position is out of range: ${a}`);c=Math.floor(a/b.f.duration);const d=b.a[c];if(!d)throw new _.I(1,9,2014,"No thumbnail found for position "+a+" at index "+c);yield d.load();return d})}l(){if(0<this.a.length)return Promise.resolve();var a=this.player.getDuration();const b=this.h*this.o;a=Math.ceil(Math.ceil(a/this.j)/b);const c=this.f.templateKey||"$index$";
9
+ for(let d=0;d<a;d++){const e=this.f.url.replace(c,String(d+1)),f=new Image;for(let g=0;g<b;g++)this.a.push(new cz(e,this.j*(d*b+g),this.j,0,0,0,0,this.h,this.o,g%this.h,Math.floor(g/this.h),f))}return Promise.resolve()}};var sz=class{constructor(a,b){this.time=a;this.duration=0;this.offset=b;this.length=0;this.Rc=new _.rn}load(){return this.Rc}},oz=class{constructor(){this.g=new _.S(Xy);this.a=new ArrayBuffer(0);this.f=[];this.h=new _.rn}init(a,b){if(!b||!b.url)throw new _.I(1,9,7100,Vy);const c=b.url;b=_.Bj(c);b.type=_.Aj;a.getNetworkEngine().fetch(b).V.then(d=>{var e=d.data;d=_.K(this.a);e=_.K(e);var f=d.byteLength+e.byteLength,g=new ArrayBuffer(f),h=new DataView(g),k=0;for(let l=0,m=d.byteLength;l<m;l++)h.setUint8(k,
10
+ d[l]),k+=1;for(let l=0,m=e.byteLength;l<m;l++)h.setUint8(k,e[l]),k+=1;this.a=g;this.g.info(`Appended ${e.byteLength} bytes.`+`Total data now ${f} bytes.`);f=this.a;d=_.K(f);h=String.fromCharCode.apply(null,tz);k=Array.prototype.slice.call(d,0,8);d=64;e=0;g=!1;if(h===String.fromCharCode.apply(null,k))for(f=new DataView(f,16,20),f=f.getUint32(0,!0),0===f&&(f=1E3);!g;){e+=1;k=f;h=new DataView(this.a,d);g=h.getUint32(0,!0);k=g*k/1E3;h=h.getUint32(4,!0);h=new sz(k,h);if(k=this.f.length)k=this.f[k-1],k.length=
11
+ h.offset-k.offset,k.duration=h.time-k.time;this.f.push(h);d+=8;(g=4294967295===g)&&this.h.resolve();if(1E5<e)throw Error("There was a problem during reading BIF entries");}else throw Error("The file is not a valid BIF format");az(this)}).catch(d=>{this.g.error(`[BIF] Error while loading thumbnails '
12
+ + 'URL: ${c}`,d);a.onError(new _.I(1,9,2013,"Error while loading and parsing BIF thumbnails.",d))})}get(a){const b=this;return _.x(function*(){if(0>a)throw new _.I(1,9,2014,`Position is out of range: ${a}`);yield b.h;var c=b.f.find(d=>a>=d.time&&a<d.time+d.duration);if(!c)throw new _.I(1,9,2014,`No thumbnail found for position: ${a}`);c=yield dz(b,c);yield c.load();return c})}},tz=[137,66,73,70,13,10,26,10];var mz=class extends rz{constructor(){super();this.f=null}init(a,b){if(!b||!b.url)throw new _.I(1,9,7100,Vy);const c=b.url,d=_.Bj(c);d.type=_.Aj;this.f=a.getNetworkEngine().fetch(d).V.then(e=>{e=e.data;if(!e)throw Error("No data in the response");e=_.ij(e).split(/\n/);for(let m=0;m<e.length;m++){var f=e[m],g=f.split(" --\x3e ");if(2===g.length){f=e[++m];var h=f.indexOf("\x3d");var k=h=0>h?[]:f.substr(h+1).split(/,/).map(parseFloat);h=k[0];const n=k[1],r=k[2];k=k[3];var l=f.indexOf("#");f=0>l?f:f.substr(0,
13
+ l);f.match(/^http|^\/\//)||(f=c.substr(0,c.lastIndexOf("/"))+"/"+f);l=ez(g[0]);g=ez(g[1])-l;this.a.push(new cz(f,l,g,h,n,r,k,0,0))}}}).catch(e=>{this.log.error("[VTT] Error while loading thumbnails "+`URL: ${c}`,e);a.onError(new _.I(1,9,2013,"Error while loading VTT thumbnails.",e))});super.init(a,b)}get(a){const b=this;return _.x(function*(){if(0>a)throw new _.I(1,9,2014,`Position is out of range: ${a}`);yield b.f;const c=b.a.find(d=>a>=d.time&&a<d.time+d.duration);if(!c)throw new _.I(1,9,2014,`No thumbnail found for position: ${a}`);
14
+ yield c.load();return c})}l(){return this.f}};var uz=class extends rz{get(a){const b=this;return _.x(function*(){function c(){return new _.I(1,9,2014,`No thumbnail found for position: ${a}`)}if(0>a)throw b.log.error("Position must be greater than 0 but is "+a),new _.I(1,9,2014,`Position is out of range: ${a}`);var d=b.player.getPeriods();d=fz(d,a);if(!d)throw b.log.error("Could not find period for specified position",a),c();var e=d.thumbStreams.sort(b.f)[0];if(!e)throw b.log.error("Could not find thumb stream for specified position",a),c();d=
15
+ e.findSegmentPosition(a-d.startTime);if(null===d||void 0===d)throw b.log.error("Could not find segment index for specified position",a),c();var f=e.getSegmentReference(d);if(f){const h=gz(f,e),k=Math.floor((a-f.startTime)/h.durationPerTile);var g;if(0<b.a.length)f=e.findSegmentPosition(0),null!==f&&(g=b.a[(d-f)*h.Zf+k]);else if((e=f.ab())&&0<e.length){let l=g=0;f=f.startTime;1<h.Zf&&(g=k%h.ld,l=Math.floor(k/h.ld),f+=k*h.durationPerTile);g=new cz(e[0],f,h.durationPerTile,void 0,void 0,void 0,void 0,
16
+ h.ld,h.pf,g,l)}if(g)return yield g.load(),g}b.log.error("segment reference for specified segment index does not exist",d);throw c();})}f(a,b){return void 0!==a.bandwidth&&void 0!==b.bandwidth?a.bandwidth-b.bandwidth:0}l(){if(0<this.a.length)return Promise.resolve();var a=this.player.getPeriods();for(const b of a)if(a=b.thumbStreams.sort(this.f)[0]){let c=a.findSegmentPosition(0),d;for(;null!==c&&!_.B(d=a.getSegmentReference(c++));){const e=gz(d,a),f=d.ab()[0],g=new Image;let h=d.startTime;for(let k=
17
+ 0;k<e.pf;++k)for(let l=0;l<e.ld;++l)this.a.push(new cz(f,h,e.durationPerTile,void 0,void 0,void 0,void 0,e.ld,e.pf,l,k,g)),h+=e.durationPerTile}}return Promise.resolve()}};var vz=class{constructor(){this.g=new _.S(Xy);this.a=this.m=null}onPlayerCreated(a){this.m=a}onPlayerWillDestroy(){this.m=null}onPlayerWillRelease(){this.a=null}onContentWillLoad(a){const b=a.getConfiguration().thumbnails;if(b)if(!1===b.enabled)this.g.info("Thumbnails disabled.");else{var c=b.mode||null;c||(c=qz(b.url||null));(this.a=pz(c))?(this.g.info("Loading thumbs configuration",b),this.m.one(_.Fe,()=>{this.g.info("Initialize thumbnails provider");try{this.a.init(a,b)}catch(d){this.m.onError(d)}})):
18
+ this.g.warn("Unknown thumbnail mode",c)}else this.a=null}onContentLoaded(a){if(!this.a){var b=a.getConfiguration();b=b&&b.thumbnails;if(!b||void 0===b.enabled||b.enabled){var c=a.getPeriods();if(hz(c)){this.a=new uz;try{this.a.init(a,b)}catch(d){this.m.onError(d)}}}}}get(a){return this.a?this.a.get(a):Promise.reject(new _.I(1,9,2014,"Thumbnail format is not supported"))}id(){return"thumbnails"}};_.z("clpp.thumbnails.ThumbnailsPlugin",vz);vz.prototype.get=vz.prototype.get;vz.Id="thumbnails";_.Nr(new class{create(){return new vz}});
19
+ var iz="SINGLE",jz="GRID",lz="WEBVTT",nz="BIF";};f.call(g, window);
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 bQ="An unknown error occurred while trying to get volume",cQ="Cannot get loading rendition due to platform limitations",dQ="SecurityError",eQ="The require privilege is: http://tizen.org/privilege/tv.audio",fQ="|STARTBITRATE\x3d",gQ=function(a,b,c){const d=e=>{c.call(a,e);a.removeEventListener(b,d)};a.addEventListener(b,d)},jQ=function(a){return _.x(function*(){if(a.a!==_.Jd&&a.a!==_.Hd)throw new _.I(_.F,6,6001,`The key system ${a.a} is not supported by `+"the player or the platform");
2
- const b=a.f.get(a.a);if(!b.qd)throw new _.I(_.F,6,6012,`No license server given for ${a.a}`);try{a.a===_.Jd?yield hQ(a):yield iQ(a,b),a.o={keySystem:a.a,licenseServerUri:b.qd,distinctiveIdentifierRequired:!1,persistentStateRequired:b.Pe,audioRobustness:"",videoRobustness:"",serverCertificate:null,initData:[],keyIds:[],periodId:null}}catch(c){throw a.g.error(`Error while configuring CDM for ${a.a}`,c),new _.I(_.F,6,6005,{message:JSON.stringify(c)});}})},lQ=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=_.Jj([b.serverurl&&""!==b.serverurl?b.serverurl:c.qd],_.Fj());c.type=3;c.body=e.buffer;c.method=_.rb;try{var f=yield a.D.yb.fetch(c).U;if(a.j){var g=_.K(f.data);const h=g.byteLength;e="";for(f=0;f<h;f++)e+=String.fromCharCode(g[f]);const k=`${b.session_id}PARAM_START_POSITION`+`${btoa(e)}PARAM_START_POSITION`;a.g.debug("Widevine license params",k);
4
- try{webapis.avplay.setDrm(kQ,"widevine_license_data",k)}catch(l){a.g.error("License response rejected by CDM");const m=new _.I(_.F,6,6008,{browserError:JSON.stringify(l)});a.D.onError(m)}}}catch(h){a.g.error("License request failed.",JSON.stringify(h)),g=new _.I(_.F,6,6007,{message:"Error while fetching license!",url:h.data.url,status:h.data.status||NaN,response:h.data.response||"",headers:h.data.headers||{}},h),a.D.onError(g)}})},hQ=function(a){return _.x(function*(){try{webapis.avplay.setDrm(kQ,
5
- "Initialize",""),webapis.avplay.setDrm(kQ,"widevine_app_session",a.l.id),webapis.avplay.setDrm(kQ,"widevine_data_type",a.l.type)}catch(b){throw b;}})},iQ=function(a,b){return _.x(function*(){var c={};c[mQ]=!b.Pe;c[nQ]=b.qd;""!==b.customData&&(c[oQ]=b.customData);c=JSON.stringify(c);a.g.debug("PlayReady properties: ",c);try{webapis.avplay.setDrm(pQ,"SetProperties",c)}catch(d){throw d;}})},rQ=function(a,b){if(a.f!==b)if(a.f===_.$o&&b!==_.gp)a.g.debug(_.cC+`${qQ(b)}`);else{var c=(new Date).getTime();
6
- a.j=a.f;a.f=b;a.f===_.cp?(a.o=(new Date).getTime(),a.m.trigger(new _.D(_.ad,{detail:{bufferedTimeMS:-1,reason:a.h}}))):a.j===_.cp&&a.m.trigger(new _.D(_.$c,{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 _.D(_.Zf,{detail:b}));a.g.debug("State changed:",qQ(a.j),"-\x3e",qQ(a.f))}},qQ=function(a){return Object.keys(_.fp)[a]},uQ=function(a){if(a.l){var b=a.a.getState(),c=a.f;switch(b){case sQ:c=_.jp;break;case tQ:c=
7
- _.ip;break;default:a.m.isEnded()?c=_.Zo:a.g.debug("Inconsistent AVPlay playback state:",b)}rQ(a,c)}},vQ=function(a){return _.x(function*(){const b=a.m.getConfiguration();let c;(c=yield _.at(a.B.url,a.m.getNetworkEngine(),b.manifest.attemptParameters,a.B.type||null))&&c.configure(b.manifest);return c})},wQ=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},xQ=function(a){const b=document.createElement(_.w),c=new _.pJ,d=new _.wI,e=a.m.getTextDisplayer();
8
- return new _.rJ(b,c,e,d,a.m.getConfiguration())},yQ=function(a){const b={configuration:{},Jb:()=>a.m.getPosition(),aa:a.h,yb:a.m.getNetworkEngine(),Ic:null,Ke:a.G.bind(a),Je:a.F.bind(a),onError:a.H.bind(a),hg:()=>{},onEvent:()=>{},lg:a.I.bind(a),be:()=>{},cd:()=>new _.oK,pe:()=>!1,$c:null};return new _.LJ(a.a,b)},zQ=function(a){const b=a.m.getPosition();let c=null;for(const d of a.a.periods)d.startTime<=b&&(c=d);return c},AQ=function(a){a.g.debug("getTextStreams()",a.a);if(a.a){var b=[],c=a.a.periods;
9
- a.g.debug("getting text streams");for(var d=0;d<c.length;d++)if(a.g.debug(c[d].startTime,a.m.getPosition()),c[d].startTime<=a.m.getPosition()){b=c[d].textStreams;break}a=b}else a=[];b=[];c=0;for(d=0;d<a.length;d++){const e=new _.dk(String(c++),_.L);e.mimeType=a[d].mimeType;e.language=a[d].language;e.roles=a[d].roles;e.kind=a[d].kind||_.NC;const f=new _.lk(String(a[d].id),e);f.bandwidth=a[d].bandwidth||null;e.renditions.push(f);b.push(e)}return b},BQ=function(a){if(a.h&&!a.h.getTextDisplayer().isTextVisible())return null;
10
- if(a.f){const b=_.lH(a.f,_.H);let c=null;if(b){a=AQ(a);for(let d=0;d<a.length;d++)if(a[d].renditions[0].id===String(b.id)){c=a[d].renditions[0];break}}return c}return null},CQ=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===_.ke,a.a&&a.f)){a.setTextVisibility(!0);const c=zQ(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):(_.yH(a.f,b,!0,0),a.m.trigger(new _.D(_.ig))),
11
- a.o=b.language):a.g.error(_.aC,d.id)}},DQ=function(a){const b=a.oa();b&&a.m.trigger(new _.D(_.Yc,{detail:{width:b.width,height:b.height,bandwidth:b.bandwidth,rendition:b}}))},EQ=function(a,b){a.m.trigger(new _.D(_.Jg,{details:{width:b.width,height:b.height,bandwidth:b.bandwidth,track:b.track,abrSelection:a.a.o}}))},FQ=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},GQ=function(a,b){a=a.f[_.N]||[];const c=[];for(let d=0;d<
12
- a.length;d++)for(let e=0;e<a[d].renditions.length;e++)_.th(a[d].renditions[e],b,Object.keys(b))&&c.push(a[d].renditions[e]);return c[0]||null},HQ=function(a){const b=a.m.getConfiguration();var c=_.oi(b.preferredAudioLanguage||[]);const d=a.f[_.M]||[];if(d.length){var e=null;c.some(g=>{e=_.jD(g,d.map(h=>h.language));return!!e});if(e){var f=d.filter(g=>g.language===e);c=f[0];1<f.length&&b.preferredAudioRole&&(f=f.filter(g=>0<=g.roles.indexOf(b.preferredAudioRole)),0<f.length&&(c=f[0]));a.g.debug("Setting audio track with preferred language:",
13
- e);a.ya(c)}else a.g.debug("Preferred language(s) not available")}else a.g.debug("Could not set preferred audio language")},NQ=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===IQ),f=b.filter(l=>l.type===JQ);const g=[];for(var h=0;h<f.length;h++){const l=FQ(a,f[h].extra_info);if(l){var k=_.Pi(l.language||_.sg);k=_.Zj(k);k=c(g,k);k||(k=new _.dk(String(a.h++),_.M),g.push(k));k.renditions.push(KQ(f[h].index,
14
- l,k))}else a.g.warn("Skipping audio stream with no extra info")}c=new _.dk(String(a.h++),_.N);for(f=0;f<e.length;f++)(h=FQ(a,e[f].extra_info))?c.renditions.push(LQ(e[f].index,h,c)):a.g.warn("Skipping video stream with no extra info");e=[];e=a.j?AQ(a.j):MQ(a,b);d[_.N]=[c];d[_.M]=g;d[_.L]=e;return d},QQ=function(a,b){if(b===_.L&&a.j)return BQ(a.j);var c=OQ(a.a)||[];if(0===c.length)return null;c=c.filter(e=>e.type===b.toUpperCase())[0];var d=null;b===_.N&&(d=FQ(a,c.extra_info),d=GQ(a,{width:d.Width,
15
- height:d.Height}));b===_.M&&(c?(d=PQ(a,c,_.M),a.l=d):d=a.l);b===_.L&&(c?(d=PQ(a,c,_.L),a.o=d):d=a.o);return d},TQ=function(a,b){if(b){const c=b.track.type.toUpperCase();RQ(a.a,c,Number(b.id)).then(()=>{c===JQ&&(a.l=b,a.m.trigger(new _.D(_.Wc)));c===SQ&&(a.o=b,a.m.trigger(new _.D(_.ig)))}).catch(()=>{a.g.error("Could not select "+c+" track.")})}else a.g.debug("Must provide valid rendition")},KQ=function(a,b,c){const d=_.Pi(b.language||_.sg);c.language=_.Zj(d);c.originalLanguage=d;c.channelsCount=b.channels?
16
- Number(b.channels):null;c.mimeType=_.Tc;a=new _.lk(String(a),c);a.track=c;a.codec=b.fourCC||null;a.bandwidth=b.bit_rate||null;return a},LQ=function(a,b,c){c.mimeType=_.Hg;a=new _.lk(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},UQ=function(a,b,c){b=_.Pi(b.track_lang||_.sg);c.mimeType="text/ttml";c.language=_.Zj(b);c.originalLanguage=b;c.kind=_.NC;return new _.lk(String(a),c)},MQ=function(a,b){b=
17
- b.filter(d=>d.type===SQ);const c=[];for(let d=0;d<b.length;d++){const e=FQ(a,b[d].extra_info);if(!e){a.g.warn("Skipping text stream with no extra info");continue}const f=new _.dk(String(a.h++),_.L);f.renditions.push(UQ(b[d].index,e,f));c.push(f)}return c},PQ=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},VQ=function(a){return a.f&&a.a?a.a.xi:webapis.avplay.getTotalTrackInfo()},
18
- XQ=function(a,b,c){a.g.debug("switchVideoTrack()");try{const d={estimatedBandwidth:parseInt(webapis.avplay.getStreamingProperty("CURRENT_BANDWITH"),10),currentBandwidth:b,nextBandwidth:c,currentPosition:a.getPosition()};a.a=WQ(a);a.f=!0;webapis.avplay.stop();webapis.avplay.close();return a.load(a.m.getConfiguration(),d).then(()=>{const e=a.a.Bf;a.f=!1;a.a=null;return e===tQ?a.pause():a.play()})}catch(d){return Promise.reject(d)}},YQ=function(a,b){var c=a.m.getTextDisplayer();c&&c.setTextVisibility(b);
19
- c=a.m.h;try{c||webapis.avplay.setSilentSubtitle(!b)}catch(d){a.g.debug("Could not set text track visibility",d)}},RQ=function(a,b,c){b=b.toUpperCase();b===SQ&&YQ(a,!0);const d=a.j[b];d&&(d.he.stop(),a.j[b]=null,a.g.debug(`Cancelled pending track switch for ${b}`));return new Promise((e,f)=>{const g=(h,k,l)=>{l=void 0===l?!1:l;try{webapis.avplay.setSelectTrack(h,k),a.j[h]=null,e()}catch(m){a.g.debug(`Could not set ${h} track. Trying again...`+`AVPlay state: ${a.getState()}, `+`buffering: ${a.w}`,m),
20
- !1===l&&(a.j[h]={type:h,index:k,xf:0,he:new _.Mk(()=>g(h,c,!0))}),(k=a.j[h])&&3>k.xf?(!a.w&&++k.xf,k.he.ia(a.w?.5:.25)):(a.g.debug("Could not set track after multiple attempts.Giving up..."),k&&k.he.stop(),a.j[h]=null,f())}};g(b,c)})},OQ=function(a){return a.f&&a.a?a.a.dh:webapis.avplay.getCurrentStreamInfo()},ZQ=function(a){return _.x(function*(){tizen.systeminfo.getPropertyValue("DISPLAY",b=>{a.A=b.resolutionWidth/1920;a.g.debug("Display resolution ratio: ",a.A)},b=>{a.g.debug("Could not load DISPLAY property");
21
- throw b;})})},aR=function(a){try{webapis.avplay.setListener({onbufferingstart:a.J.bind(a),onbufferingprogress:a.I.bind(a),onbufferingcomplete:a.H.bind(a),onstreamcompleted:a.M.bind(a),oncurrentplaytime:b=>{a.trigger(new _.D($Q,{currentTime:b}))},onevent:a.L.bind(a),onsubtitlechange:a.O.bind(a),ondrmevent:a.K.bind(a),onerror:a.B.bind(a)})}catch(b){a.g.error(b)}},bR=function(a){const b=!!a.m.getTrackManager().Va();try{webapis.avplay.setSilentSubtitle(!b)}catch(c){a.g.debug("Could not set AVPlay subtitle config",
22
- c)}},cR=function(a,b){try{const c=b.estimatedBandwidth||0,d=b.currentBandwidth||0;a.g.debug({estimatedBandwidth:c,Mi:d});0!==c&&0!==d&&c>=1.15*d&&webapis.avplay.setStreamingProperty("ADAPTIVE_INFO",fQ+d)}catch(c){a.g.debug(c)}},dR=function(a,b){try{webapis.avplay.setStreamingProperty("ADAPTIVE_INFO","|BITRATES\x3d"+b+fQ+b)}catch(c){throw a.g.debug("Could not set fixed bandwidth",c),c;}},eR=function(a){let b=null;try{b=tizen.tvaudiocontrol.isMute()}catch(c){switch(c.name){case dQ:a.g.warn("The application doesn't have the privilege to get the mute state.",
23
- eQ);break;default:a.g.warn(bQ,c)}}return!!b},WQ=function(a){return{position:a.getPosition(),state:a.m.getState(),Bf:a.getState(),playbackRate:a.getPlaybackRate(),isLive:a.isLive(),duration:a.getDuration(),isMuted:eR(a),volume:a.getVolume(),xi:VQ(a),dh:OQ(a)}},fR=function(){return new Promise((a,b)=>{if(window.webapis)a();else{const c=document.createElement("script");gQ(c,_.Ce,d=>a(d));gQ(c,_.r,d=>b(d));c.src="$WEBAPIS/webapis/webapis.js";document.querySelector("head").appendChild(c)}})},gR=function(a){return _.x(function*(){yield fR();
24
- const b=new Promise(c=>{(new _.Mk(c)).ia(5)});if(!(yield Promise.race([ZQ(a).then(()=>!0),b.then(()=>!1)])))return a.g.debug("Took to long for the SDK to be ready"),Promise.reject("SDK Timeout")})},hR=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!");bR(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)}})})},iR=function(a,
25
- b){try{tizen.tvaudiocontrol.setMute(b)}catch(c){switch(c.name){case dQ:a.g.warn("The application does not have the privilege to set mute.",eQ);break;default:a.g.warn(bQ,c)}}},nR=function(a,b,c){return _.x(function*(){a.l=_.mp(b);const d=a.G,e=c||{estimatedBandwidth:0,currentBandwidth:0,nextBandwidth:null,currentPosition:0};a.g.debug(`Loading manifest URL: ${a.l[d].url}`);let f=b.startTime||void 0;a.f&&(a.trigger(new _.D(jR)),f=c.currentPosition);try{let g=a.l[d].url;if(a.l[d].type===_.Jc&&!g.includes(".mpd")){const h=
26
- new URL(g);h.searchParams.append("cl-ext",".mpd");g=h.toString()}webapis.avplay.open(g);e.nextBandwidth?(dR(a,e.nextBandwidth),a.o=!1):(a.o||cR(a,e),a.o=!0);aR(a);if(b.drm&&b.drm.env){const h={onError:k=>a.m.onError(k),yb:a.m.getNetworkEngine()};a.h=new kR(b.drm,h);yield a.h.init()}else a.g.debug("No DRM configuration was provided. Assuming clear content");a.f||a.trigger(new _.D(lR));yield hR(a);a.f||a.trigger(new _.D(mR));f&&typeof f===_.t&&0<f&&a.seek(f).catch(h=>{a.g.debug("Couldn't set start position",
27
- h)});a.f||(b.volume&&a.setVolume(b.volume),b.muted&&iR(a,b.muted),b.autoplay&&a.m.play().catch(h=>{a.g.debug("Autoplay failed",h)}))}catch(g){throw a.g.debug("Error while attempting to load source."),g;}})},oR=function(a){if("NONE"!==a.a.getState()){var b=a.j.getBoundingClientRect();{a=a.a;const c=Math.floor(b.left*a.A),d=Math.floor(b.top*a.A),e=Math.floor(b.width*a.A);b=Math.floor(b.height*a.A);a.g.debug("Setting display area to","x:",c,"y:",d,"width:",e,"height:",b);webapis.avplay.setDisplayRect(c,
28
- d,e,b);0===c&&0===d&&1920===e&&1080===b&&webapis.avplay.setDisplayMethod("PLAYER_DISPLAY_MODE_LETTER_BOX")}}else a.g.debug("Could not apply dimension. Player state "+a.a.getState())},kR=class{constructor(a,b){this.h=a;this.o=null;this.a=_.Qe;this.l=null;this.j=!1;this.f=new Map;this.D=b;this.g=new _.S("clpp.tizen.DrmEngine")}init(){const a=this;return _.x(function*(){var b=_.dm[a.h.env]||null;if(!b)throw a.g.debug(_.ua,_.vb+a.h.env+_.aa),new _.I(_.F,6,6015,`DRM environment '${a.h.env}' is missing.`);
29
- a.l={id:String(Math.floor(1E4*Math.random())),type:"MPEG-DASH"};var c=Object.keys(a.h.customData||{}).length?btoa(JSON.stringify(a.h.customData)):"";b=_.fm(b,a.h.customData);const d=b[_.Hd];d&&a.f.set(_.Hd,{qd:d.licenseUrl||"",customData:c,Pe:!1});(b=b[_.Jd])&&a.f.set(_.Jd,{qd:b.licenseUrl||"",customData:c,Pe:!1});if(0===a.f.size)throw new _.I(_.F,6,6E3);if((c=a.h.preferredDrmSystem)&&a.f.get(c))a.a=c;else if(a.f.get(_.Hd))a.a=_.Hd;else if(a.f.get(_.Jd))a.a=_.Jd;else throw new _.I(_.F,6,6001,"Configuration for the target system is missing.");
30
- yield jQ(a);a.j=!0})}release(){const a=this;return _.x(function*(){a.j=!1;a.o=null;a.a=_.Qe;a.l=null;a.f=new Map})}getDrmInfo(){return this.o}},mQ="DeleteLicenseAfterUse",nQ="LicenseServer",oQ="CustomData";var uR=class{constructor(a){this.m=a;this.a=this.m.a;this.f=_.gp;this.j=_.pv;this.w=(new Date).getTime();this.l=!1;this.o=-1;this.h=2;this.g=new _.S("clpp.tizen.StateManager")}initialize(){this.a.on(jR,this.C,this);this.a.on(pR,this.B,this);this.a.on(qR,this.A,this);this.a.on(lR,this.H,this);this.a.on(mR,this.G,this);this.a.on(rR,this.F,this)}release(){rQ(this,_.gp);this.l=!1;this.o=-1;this.h=2}destroy(){this.release();this.a.off(jR,this.C);this.a.off(pR,this.B);this.a.off(qR,this.A);this.a.off(lR,
31
- this.H);this.a.off(mR,this.G);this.a.off(rR,this.F);this.m=this.a=null}C(){this.g.debug("Buffering start. Player state: ",this.a.getState());this.h=this.a.C?1:2;rQ(this,_.cp)}B(a){this.g.debug("Buffering progress: "+a.percent+" %. Player state: ",qQ(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()===sR;if(!a&&b){rQ(this,_.ip);return}}if(a=this.f!==_.hp)a=this.a.getState(),a=a===
32
- sQ||a===tQ;a&&uQ(this)}H(){this.g.debug("Preparing starts. AVPlay State: ",this.a.getState());this.a.getState()===tR?rQ(this,_.hp):this.g.error("AVPlay prepares while state is not IDLE")}G(){this.g.debug("Preparing ends: AVPlay state:",this.a.getState())}F(){rQ(this,_.Zo)}getState(){return this.f}};var vR=class{constructor(){this.o=this.A=this.f=this.h=this.B=this.m=this.j=this.a=null;this.C=!1;this.w=!0;this.l=null;this.g=new _.S("clpp.tizen.TextStreamer")}initialize(a){this.m=a}load(a){const b=this;return _.x(function*(){if(b.m)if(b.B=a,b.j=yield vQ(b),b.j){var c={configurationId:"",networkingEngine:b.m.getNetworkEngine(),onContentSteeringInfoFound:()=>null,filterNewPeriod:()=>{},filterAllPeriods:()=>{},onEvent:()=>{},onError:()=>{}};try{b.a=yield b.j.start(a.url,c)}catch(d){b.g.warn(d);try{b.a=
33
- yield b.j.start(a.url.replace("https://","http://"),c)}catch(e){b.g.error(e),b.a=null}}if(b.a&&wQ(b.a)){b.h=xQ(b);try{yield b.h.open();b.f=yQ(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(_.EC,
34
- a);this.w=!0;let b=_.kG(a.textStreams,this.o||"",this.A||"",this.C)[0]||null;this.l&&(a.textStreams.includes(this.l)&&(b=this.l),this.l=null);return{video:null,audio:null,text:b,bb:null}}F(){this.g.debug("canSwitch_");this.w=!1;this.l&&(_.yH(this.f,this.l,!0,0),this.l=null)}H(){this.g.debug("onError_")}I(){this.j&&this.j.update&&this.j.update()}start(){const a=this;return _.x(function*(){if(a.f)try{a.f.start()}catch(b){a.g.error("Error while starting streaming engine",b)}})}setTextVisibility(a){this.g.debug("Set text visibility",
35
- a);this.h&&this.h.getTextDisplayer().setTextVisibility(a)}release(){const a=this;return _.x(function*(){a.m=null;a.a=null;a.B=null;a.A=null;a.o=null;a.w=!0;a.l=null})}destroy(){const a=this;return _.x(function*(){a.j&&(yield a.j.stop(),a.j=null);a.f&&(yield a.f.destroy(),a.f=null,a.w=!0);a.h&&(yield a.h.destroy(),a.h=null)})}};var zR=class extends _.T{constructor(){super();this.j=this.a=this.m=null;this.f={};this.g=new _.S("clpp.tizen.TrackManager");this.w=this.o=this.l=null;this.B=!1;this.h=1}C(a){var b=a.eventid;a=a.data;switch(b){case wR:0<Object.keys(this.f).length||(this.g.debug("Loading track manager!"),this.load());b=webapis.avplay.getCurrentStreamInfo();0<b.length&&(b=+FQ(this,b[0].extra_info).Bit_rate,b=GQ(this,{bandwidth:b}))&&(this.w=b,EQ(this,b));break;case xR:DQ(this);break;default:this.g.debug("Event type: "+
36
- b+" data: "+a)}}A(a){a.detail.currentState===_.jp&&this.m.off(_.Zf,this.A)}initialize(a){this.m=a;this.a=this.m.a;this.m.on(_.Zf,b=>{this.B||(b=b.detail,b.currentState===_.jp&&(this.g.debug("Current state",b.currentState),this.B=!0,HQ(this)))});this.a.on(yR,this.C,this)}release(){this.f={};this.j=this.w=this.o=this.l=null;this.B=!1;this.h=1}load(){if(this.a&&!(0<Object.keys(this.f).length)){this.j=this.m.h;this.m.off(_.Zf,this.A);this.m.on(_.Zf,this.A,this);try{const a=VQ(this.a);this.f=NQ(this,a);
37
- const b=this.f[_.M]||[];b.length&&(this.l=b[0].renditions[0]||null);DQ(this)}catch(a){this.g.debug("Could not load track manager")}}}destroy(){this.a.off(yR,this.C);this.a=this.m=null}getVideoTracks(){return this.f[_.N]||[]}getAudioTracks(){return this.f[_.M]||[]}na(){return this.f[_.L]||[]}oa(){return QQ(this,_.N)}Ra(){return QQ(this,_.M)}Va(){return QQ(this,_.L)}vb(){return this.w}Gb(){this.g.info(cQ);return null}Hb(){this.g.info(cQ);return null}Ia(){const a=this.oa();return a?a.track:null}ra(){const a=
38
- this.Ra();return a?a.track:null}xa(){const a=this.Va();return a?a.track:null}Db(a){null===a?(a=this.oa(),XQ(this.a,a.bandwidth,null).then(()=>{DQ(this)})):0<a.renditions.length&&this.nb(a.renditions[0])}ya(a){a?TQ(this,a.renditions[0]):this.g.warn("Cannot disable audio tracks on this platform.","Consider muting audio instead...")}Xa(a){a?(a=a.renditions[0],this.j?CQ(this.j,a.track):TQ(this,a)):(this.g.debug("Disabling text tracks"),this.o=null,YQ(this.a,!1),this.m.trigger(new _.D(_.ig)))}nb(a){const b=
39
- this.oa();this.a.o||a.width!==b.width||a.height!==b.height||a.bandwidth!==b.bandwidth?(this.w=a,EQ(this,a),XQ(this.a,b.bandwidth,a.bandwidth).then(()=>{DQ(this)}).catch(c=>{const d=new _.I(_.F,7,7200,{tizenerror:c});this.g.debug("Error while switching video track",c);this.m.onError(d)})):this.g.debug("Trying to switch to already active rendition. Doing nothing...")}Bb(a){TQ(this,a)}Cb(a){this.j?CQ(this.j,a.track):TQ(this,a)}addTextTrack(){}ua(){return this.a.o}};zR.prototype.isAbrEnabled=zR.prototype.ua;
40
- zR.prototype.addTextTrack=zR.prototype.addTextTrack;zR.prototype.setTextRendition=zR.prototype.Cb;zR.prototype.setAudioRendition=zR.prototype.Bb;zR.prototype.setVideoRendition=zR.prototype.nb;zR.prototype.setTextTrack=zR.prototype.Xa;zR.prototype.setAudioTrack=zR.prototype.ya;zR.prototype.setVideoTrack=zR.prototype.Db;zR.prototype.getTextTrack=zR.prototype.xa;zR.prototype.getAudioTrack=zR.prototype.ra;zR.prototype.getVideoTrack=zR.prototype.Ia;zR.prototype.getLoadingTextRendition=zR.prototype.Hb;
41
- zR.prototype.getLoadingAudioRendition=zR.prototype.Gb;zR.prototype.getLoadingVideoRendition=zR.prototype.vb;zR.prototype.getTextRendition=zR.prototype.Va;zR.prototype.getAudioRendition=zR.prototype.Ra;zR.prototype.getVideoRendition=zR.prototype.oa;zR.prototype.getTextTracks=zR.prototype.na;zR.prototype.getAudioTracks=zR.prototype.getAudioTracks;zR.prototype.getVideoTracks=zR.prototype.getVideoTracks;var DR=class extends _.Bu{constructor(a){super();this.m=a;this.h=null;this.g=new _.S("clpp.tizen.Middleware");this.F=1;this.C=!1;this.l=null;this.G=0;this.o=!0;this.f=!1;this.a=null;this.A=1;this.w=!1;this.j={}}J(){this.w=!0;this.f||this.trigger(new _.D(jR))}I(a){this.w=!0;this.trigger(new _.D(pR,{percent:a}))}H(){this.w=!1;this.trigger(new _.D(qR))}M(){this.trigger(new _.D(rR))}L(a,b){this.trigger(new _.D(yR,{eventid:a,data:b}))}O(a,b,c,d,e){this.trigger(new _.D(AR,{duration:a,text:b,subtitleType:c,
42
- attriCount:d,attributes:e}))}K(a,b){this.trigger(new _.D(BR,{drmType:a,drmData:b}));this.h&&(a=this.h,a.j&&(a.a===_.Jd&&"Challenge"===b.name?lQ(a,b):"DrmError"===b.name&&(a.g.debug("DrmError event",b),b=new _.I(_.F,6,6005,{message:JSON.stringify(b)}),a.D.onError(b))))}B(a){this.trigger(new _.D(CR,{eventType:a}))}play(){const a=this.getState(),b=()=>new Promise((c,d)=>{let e=null;const f=()=>{c();clearTimeout(e)};this.one($Q,f,this);e=setTimeout(()=>{this.off($Q,f);d("Timeout")},3E4)});if(a===tR)return(new Promise((c,
43
- d)=>{webapis.avplay.prepareAsync(()=>{bR(this);c(webapis.avplay.play())},e=>{this.trigger(new _.D(CR));d(e)})})).then(()=>b());if(a===tQ||a===sR)try{return webapis.avplay.play(),b()}catch(c){return Promise.reject(c)}return a===sQ?Promise.resolve():Promise.reject("Player is in invalid state")}pause(){try{webapis.avplay.pause()}catch(a){Promise.reject(a)}return this.getState()===tQ?Promise.resolve():Promise.reject()}setPlaybackRate(a){const b=this.getState();if(b===sR||b===sQ||b===tQ){try{webapis.avplay.setSpeed(a),
44
- this.F=a}catch(c){return this.g.debug("Error while trying to set playback rate",c),this.setPlaybackRate(this.F)}return!0}this.g.debug("Cannot set playback rate; AVPlay is in inconsistent state: "+b);return!1}getPlaybackRate(){return this.F}load(a,b){const c=this;return _.x(function*(){c.g.debug("configure()",b||"");try{yield gR(c),yield nR(c,a,b)}catch(d){throw new _.I(_.F,7,7003,null,d);}})}getState(){if(this.f&&this.a)return this.a.Bf;try{return webapis.avplay.getState()}catch(a){this.B(JSON.stringify(a))}}seek(a){const b=
45
- 1E3*a;return new Promise((c,d)=>{this.C=!0;this.m.trigger(new _.D(_.Bg));webapis.avplay.seekTo(b,()=>{this.C=!1;this.m.trigger(new _.D(_.Ag));c()},()=>{this.C=!1;d()})})}getPosition(){if(this.f&&this.a)return this.a.position;try{return webapis.avplay.getCurrentTime()/1E3}catch(a){this.B(JSON.stringify(a))}}getDuration(){if(this.f&&this.a)return this.a.duration;try{return webapis.avplay.getDuration()/1E3}catch(a){this.B(JSON.stringify(a))}}release(){return new Promise((a,b)=>{try{this.h&&(this.h.release(),
46
- this.h=null);webapis.avplay.stop();webapis.avplay.close();for(const c in this.j){const d=this.j[c];d&&d.he.stop()}this.j={};this.F=1;this.C=!1;this.a=this.l=null;return a()}catch(c){return b(c)}})}getVolume(){let a=null;try{a=tizen.tvaudiocontrol.getVolume()}catch(b){switch(b.name){case dQ:this.g.debug("The application does not have the privilege to get the volume.",eQ);break;default:this.g.debug(bQ,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 dQ:this.g.warn("The application does not have the privilege to set the volume.",eQ);break;default:this.g.warn("An unknown error occurred while trying to set volume",b)}}}isLive(){if(this.f&&this.a)return this.a.isLive;try{return"1"===webapis.avplay.getStreamingProperty("IS_LIVE")}catch(a){this.B(JSON.stringify(a))}}stop(){try{webapis.avplay.stop()}catch(a){this.g.debug(a)}}getDrmInfo(){this.h&&this.h.getDrmInfo();return null}setSourceIndex(a){this.G=
48
- a}getSourceIndex(){return this.G}getLoadedSource(){return this.l&&this.l[this.getSourceIndex()]}},tR="IDLE",sR="READY",sQ="PLAYING",tQ="PAUSED",IQ=_.Sb,JQ=_.CB,SQ="TEXT",xR="PLAYER_MSG_RESOLUTION_CHANGED",wR="PLAYER_MSG_BITRATE_CHANGE",pQ="PLAYREADY",kQ="WIDEVINE_CDM";var HR=class extends _.Bu{constructor(){super();this.a=new DR(this);this.f=new uR(this);this.configuration=this.B=_.Ml();this.w=null;this.g=new _.S("clpp.tizen.Player");this.j=null;this.l=new zR;this.C=new _.Dr;this.o=this.h=null;this.A=!1}I(){this.g.debug("On Stream completed. Current time: ",this.getPosition());this.trigger(new _.D(_.ie));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 _.D(_.ng,
49
- {currentTime:a.currentTime/1E3}))}J(a){const b=this.a.getPosition(),c=b+a.duration/1E3;let d=a.text||"";this.g.debug("Got subtitles: ",d,"start:",b,"end:",c,a);(d=_.pj(d))&&this.o.append([new _.Zt(b,c,d)],[])}G(a){this.g.debug("DRM event: "+a.drmType+", data: "+a.drmData)}K(){this.A||(this.g.debug("Initial buffering completed..."),this.A=!0)}H(a){this.g.debug(`Error: TYPE: ${a.eventType}`);rQ(this.f,_.$o);a=new _.I(_.F,7,7200,{tizenerror:a.eventType});this.a.release();this.trigger(new _.D(_.r,{detail:a}))}init(a,
50
- b){this.configuration=this.B=b;this.w=a;this.a.on(rR,this.I,this);this.a.on($Q,this.F,this);this.a.on(AR,this.J,this);this.a.on(BR,this.G,this);this.a.on(CR,this.H,this);this.a.on(qR,this.K,this);this.f.initialize();this.l.initialize(this);this.g.debug("Initializing player surface");this.w.hideMediaElement();a=ER;ER+=1;a="__clpp_tizen_player_"+a;this.j=_.Cp(_.Re,{id:a,type:"application/avplayer"});this.w.addElementToContainer(this.j,!0);var c=this.w.getMedia();if(c){a=this.j;{b=[_.Ug,_.ne,"position",
51
- _.te,"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}_.Ep(a,d);oR(this)}}getSurface(){return this.w}getConfiguration(){return this.configuration}getTimeline(){return null}setupPlaylist(){return Promise.reject(_.nb)}appendLoad(){return Promise.reject(_.nb)}seekWith(){return Promise.reject(_.nb)}setSeekInterceptor(){}setPlaybackSessionId(){}getBandwidthEstimate(){return null}destroy(){const a=
52
- this;return _.x(function*(){yield a.release();a.a.off(rR,a.I);a.a.off($Q,a.F);a.a.off(AR,a.J);a.a.off(BR,a.G);a.a.off(CR,a.H);a.a.off(qR,a.K);a.h&&(yield a.h.destroy(),a.h=null);a.j&&(a.j.parentElement.removeChild(a.j),a.j=null);a.l.destroy();a.f.destroy();a.l=null;a.f=null})}namespace(){return FR}getPlaybackRate(){return this.a.getPlaybackRate()}setDrmCustomDataModifier(){}setCdnErrorCallback(){}detach(){}setPlaybackRate(a){this.a.setPlaybackRate(a)}getPosition(){return this.getMediaPosition()}getMediaPosition(){return 0<
53
- (this.configuration.startTime||0)&&!this.A?0:this.f.getState()===_.Zo?this.getDuration():this.a.getPosition()||0}seek(a){return typeof a===_.t&&0<=a?(this.isLive()||(a=Math.min(a,this.getDuration())),this.a.seek(a)):Promise.reject()}getPresentationStartTime(){return null}getSeekRange(){return{start:0,end:0}}getVolume(){const a=this.a.getVolume();return typeof a===_.t?a/100:null}setVolume(a){this.a.setVolume(a)}getDuration(){return this.getMediaDuration()}getMediaDuration(){return this.a.getDuration()}getBufferInfo(){this.g.warn(_.pa);
54
- return new _.Au}getTrackManager(){return this.l}unload(){return this.a.release().then(()=>{this.l.release()})}release(){const a=this;return _.x(function*(){a.h&&(yield a.h.release());a.o&&(yield a.o.destroy(),a.o=null);yield a.a.release();a.l.release();a.f.release();a.A=!1})}load(a){const b=this;return _.x(function*(){b.configuration=_.Ol(b.B,a);var c=_.Ro(b.configuration,[_.pe,"native"]);b.o=c.create(b);c=_.mp(b.configuration)[0];if(b.configuration.tizen&&b.configuration.tizen.sideStreamText){b.h=
55
- new vR;b.h.initialize(b);try{yield b.h.load(c),b.h.start()}catch(d){b.g.error(d)}}try{yield b.a.load(b.configuration)}catch(d){throw b.onError(d),d;}b.l.load()})}play(){this.trigger(new _.D(_.ff));oR(this);return this.a.play().then(()=>{uQ(this.f)})}pause(){return this.a.pause().then(()=>{uQ(this.f)})}getState(){return this.f.getState()}getPeriods(){return[]}onError(a){const b=new _.D(_.r,{detail:a});a.severity===_.F&&(rQ(this.f,_.$o),this.a.release());this.trigger(b);b.defaultPrevented&&(b.a=!0)}getDrmInfo(){return this.a.getDrmInfo()}isEnded(){return this.f.getState()===
56
- _.Zo}isPaused(){return this.a.getState()===tQ}isMuted(){return eR(this.a)}setMuted(a){iR(this.a,a)}getNetworkEngine(){return this.C}setNetworkEngine(a){this.C=a}setCmsdManager(){}isLive(){return this.a.isLive()}getStats(){return null}setSourceIndex(a){this.a.setSourceIndex(a)}getSourceIndex(){return this.a.getSourceIndex()}getLoadedSource(){return this.a.getLoadedSource()}canPlay(a,b){return(new GR).canPlay(a,b)}getTimelineCues(){return[]}getCueTimeline(){return null}getTextDisplayer(){return this.o}resetAbr(){}},
57
- FR="clpp.tizen",ER=0,GR=class{a(){return FR}canPlay(a){a=a.type;const b=!!window.webapis;if((a===_.Jc||a===_.Fl||a===_.Oc)&&b){if(_.Qk(2))return 2;if(_.Qk(3)||_.Qk(4)||_.Qk(5)||_.Qk(6))return _.C("Use of clpp.tizen.TizenComponent is not recommended for Tizen version \x3e\x3d 3."),1}return 0}f(a){return a===_.ma}create(){return new HR}};_.z("clpp.tizen.TizenComponent",class extends _.Iv{f(){_.Jh(new GR)}a(){var a=FR;a&&_.Hh[a]&&(delete _.Hh[a],_.Ih.info("Removed Player factory: '"+a+"'"))}id(){return"tizen"}});var jR="onbufferingstart",pR="onbufferingprogress",qR="onbufferingcomplete",rR="onstreamcompleted",$Q="oncurrentplaytime",yR="onevent",AR="onsubtitlechange",BR="ondrmevent",CR="onerror",lR="preparingstart",mR="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 cQ="An unknown error occurred while trying to get volume",dQ="Cannot get loading rendition due to platform limitations",eQ="SecurityError",fQ="The require privilege is: http://tizen.org/privilege/tv.audio",gQ="|STARTBITRATE\x3d",hQ=function(a,b,c){const d=e=>{c.call(a,e);a.removeEventListener(b,d)};a.addEventListener(b,d)},kQ=function(a){return _.x(function*(){if(a.a!==_.Jd&&a.a!==_.Hd)throw new _.I(_.F,6,6001,`The key system ${a.a} is not supported by `+"the player or the platform");
2
+ const b=a.f.get(a.a);if(!b.qd)throw new _.I(_.F,6,6012,`No license server given for ${a.a}`);try{a.a===_.Jd?yield iQ(a):yield jQ(a,b),a.o={keySystem:a.a,licenseServerUri:b.qd,distinctiveIdentifierRequired:!1,persistentStateRequired:b.Pe,audioRobustness:"",videoRobustness:"",serverCertificate:null,initData:[],keyIds:[],periodId:null}}catch(c){throw a.g.error(`Error while configuring CDM for ${a.a}`,c),new _.I(_.F,6,6005,{message:JSON.stringify(c)});}})},mQ=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=_.Bj([b.serverurl&&""!==b.serverurl?b.serverurl:c.qd],_.xj());c.type=3;c.body=e.buffer;c.method=_.sb;try{var f=yield a.D.yb.fetch(c).V;if(a.j){var g=_.K(f.data);const h=g.byteLength;e="";for(f=0;f<h;f++)e+=String.fromCharCode(g[f]);const k=`${b.session_id}PARAM_START_POSITION`+`${btoa(e)}PARAM_START_POSITION`;a.g.debug("Widevine license params",k);
4
+ try{webapis.avplay.setDrm(lQ,"widevine_license_data",k)}catch(l){a.g.error("License response rejected by CDM");const m=new _.I(_.F,6,6008,{browserError:JSON.stringify(l)});a.D.onError(m)}}}catch(h){a.g.error("License request failed.",JSON.stringify(h)),g=new _.I(_.F,6,6007,{message:"Error while fetching license!",url:h.data.url,status:h.data.status||NaN,response:h.data.response||"",headers:h.data.headers||{}},h),a.D.onError(g)}})},iQ=function(a){return _.x(function*(){try{webapis.avplay.setDrm(lQ,
5
+ "Initialize",""),webapis.avplay.setDrm(lQ,"widevine_app_session",a.l.id),webapis.avplay.setDrm(lQ,"widevine_data_type",a.l.type)}catch(b){throw b;}})},jQ=function(a,b){return _.x(function*(){var c={};c[nQ]=!b.Pe;c[oQ]=b.qd;""!==b.customData&&(c[pQ]=b.customData);c=JSON.stringify(c);a.g.debug("PlayReady properties: ",c);try{webapis.avplay.setDrm(qQ,"SetProperties",c)}catch(d){throw d;}})},sQ=function(a,b){if(a.f!==b)if(a.f===_.ap&&b!==_.hp)a.g.debug(_.dC+`${rQ(b)}`);else{var c=(new Date).getTime();
6
+ a.j=a.f;a.f=b;a.f===_.dp?(a.o=(new Date).getTime(),a.m.trigger(new _.D(_.bd,{detail:{bufferedTimeMS:-1,reason:a.h}}))):a.j===_.dp&&a.m.trigger(new _.D(_.ad,{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 _.D(_.$f,{detail:b}));a.g.debug("State changed:",rQ(a.j),"-\x3e",rQ(a.f))}},rQ=function(a){return Object.keys(_.gp)[a]},vQ=function(a){if(a.l){var b=a.a.getState(),c=a.f;switch(b){case tQ:c=_.kp;break;case uQ:c=
7
+ _.jp;break;default:a.m.isEnded()?c=_.$o:a.g.debug("Inconsistent AVPlay playback state:",b)}sQ(a,c)}},wQ=function(a){return _.x(function*(){const b=a.m.getConfiguration();let c;(c=yield _.bt(a.B.url,a.m.getNetworkEngine(),b.manifest.attemptParameters,a.B.type||null))&&c.configure(b.manifest);return c})},xQ=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},yQ=function(a){const b=document.createElement(_.w),c=new _.qJ,d=new _.xI,e=a.m.getTextDisplayer();
8
+ return new _.sJ(b,c,e,d,a.m.getConfiguration())},zQ=function(a){const b={configuration:{},Jb:()=>a.m.getPosition(),aa:a.h,yb:a.m.getNetworkEngine(),Ic:null,Ke:a.G.bind(a),Je:a.F.bind(a),onError:a.H.bind(a),hg:()=>{},onEvent:()=>{},lg:a.I.bind(a),ce:()=>{},dd:()=>new _.pK,pe:()=>!1,bd:null};return new _.MJ(a.a,b)},AQ=function(a){const b=a.m.getPosition();let c=null;for(const d of a.a.periods)d.startTime<=b&&(c=d);return c},BQ=function(a){a.g.debug("getTextStreams()",a.a);if(a.a){var b=[],c=a.a.periods;
9
+ a.g.debug("getting text streams");for(var d=0;d<c.length;d++)if(a.g.debug(c[d].startTime,a.m.getPosition()),c[d].startTime<=a.m.getPosition()){b=c[d].textStreams;break}a=b}else a=[];b=[];c=0;for(d=0;d<a.length;d++){const e=new _.Xj(String(c++),_.L);e.mimeType=a[d].mimeType;e.language=a[d].language;e.roles=a[d].roles;e.kind=a[d].kind||_.OC;const f=new _.fk(String(a[d].id),e);f.bandwidth=a[d].bandwidth||null;e.renditions.push(f);b.push(e)}return b},CQ=function(a){if(a.h&&!a.h.getTextDisplayer().isTextVisible())return null;
10
+ if(a.f){const b=_.mH(a.f,_.H);let c=null;if(b){a=BQ(a);for(let d=0;d<a.length;d++)if(a[d].renditions[0].id===String(b.id)){c=a[d].renditions[0];break}}return c}return null},DQ=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===_.le,a.a&&a.f)){a.setTextVisibility(!0);const c=AQ(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):(_.zH(a.f,b,!0,0),a.m.trigger(new _.D(_.jg))),
11
+ a.o=b.language):a.g.error("No stream with id",d.id)}},EQ=function(a){const b=a.oa();b&&a.m.trigger(new _.D(_.Zc,{detail:{width:b.width,height:b.height,bandwidth:b.bandwidth,rendition:b}}))},FQ=function(a,b){a.m.trigger(new _.D(_.Kg,{details:{width:b.width,height:b.height,bandwidth:b.bandwidth,track:b.track,abrSelection:a.a.o}}))},GQ=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},HQ=function(a,b){a=a.f[_.N]||[];const c=
12
+ [];for(let d=0;d<a.length;d++)for(let e=0;e<a[d].renditions.length;e++)_.uh(a[d].renditions[e],b,Object.keys(b))&&c.push(a[d].renditions[e]);return c[0]||null},IQ=function(a){const b=a.m.getConfiguration();var c=_.pi(b.preferredAudioLanguage||[]);const d=a.f[_.M]||[];if(d.length){var e=null;c.some(g=>{e=_.kD(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]));
13
+ a.g.debug("Setting audio track with preferred language:",e);a.ya(c)}else a.g.debug("Preferred language(s) not available")}else a.g.debug("Could not set preferred audio language")},OQ=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===JQ),f=b.filter(l=>l.type===KQ);const g=[];for(var h=0;h<f.length;h++){const l=GQ(a,f[h].extra_info);if(l){var k=_.Qi(l.language||_.tg);k=_.Tj(k);k=c(g,k);k||
14
+ (k=new _.Xj(String(a.h++),_.M),g.push(k));k.renditions.push(LQ(f[h].index,l,k))}else a.g.warn("Skipping audio stream with no extra info")}c=new _.Xj(String(a.h++),_.N);for(f=0;f<e.length;f++)(h=GQ(a,e[f].extra_info))?c.renditions.push(MQ(e[f].index,h,c)):a.g.warn("Skipping video stream with no extra info");e=[];e=a.j?BQ(a.j):NQ(a,b);d[_.N]=[c];d[_.M]=g;d[_.L]=e;return d},RQ=function(a,b){if(b===_.L&&a.j)return CQ(a.j);var c=PQ(a.a)||[];if(0===c.length)return null;c=c.filter(e=>e.type===b.toUpperCase())[0];
15
+ var d=null;b===_.N&&(d=GQ(a,c.extra_info),d=HQ(a,{width:d.Width,height:d.Height}));b===_.M&&(c?(d=QQ(a,c,_.M),a.l=d):d=a.l);b===_.L&&(c?(d=QQ(a,c,_.L),a.o=d):d=a.o);return d},UQ=function(a,b){if(b){const c=b.track.type.toUpperCase();SQ(a.a,c,Number(b.id)).then(()=>{c===KQ&&(a.l=b,a.m.trigger(new _.D(_.Xc)));c===TQ&&(a.o=b,a.m.trigger(new _.D(_.jg)))}).catch(()=>{a.g.error("Could not select "+c+" track.")})}else a.g.debug("Must provide valid rendition")},LQ=function(a,b,c){const d=_.Qi(b.language||
16
+ _.tg);c.language=_.Tj(d);c.originalLanguage=d;c.channelsCount=b.channels?Number(b.channels):null;c.mimeType=_.Uc;a=new _.fk(String(a),c);a.track=c;a.codec=b.fourCC||null;a.bandwidth=b.bit_rate||null;return a},MQ=function(a,b,c){c.mimeType=_.Ig;a=new _.fk(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},VQ=function(a,b,c){b=_.Qi(b.track_lang||_.tg);c.mimeType="text/ttml";c.language=_.Tj(b);c.originalLanguage=
17
+ b;c.kind=_.OC;return new _.fk(String(a),c)},NQ=function(a,b){b=b.filter(d=>d.type===TQ);const c=[];for(let d=0;d<b.length;d++){const e=GQ(a,b[d].extra_info);if(!e){a.g.warn("Skipping text stream with no extra info");continue}const f=new _.Xj(String(a.h++),_.L);f.renditions.push(VQ(b[d].index,e,f));c.push(f)}return c},QQ=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},
18
+ WQ=function(a){return a.f&&a.a?a.a.yi:webapis.avplay.getTotalTrackInfo()},YQ=function(a,b,c){a.g.debug("switchVideoTrack()");try{const d={estimatedBandwidth:parseInt(webapis.avplay.getStreamingProperty("CURRENT_BANDWITH"),10),currentBandwidth:b,nextBandwidth:c,currentPosition:a.getPosition()};a.a=XQ(a);a.f=!0;webapis.avplay.stop();webapis.avplay.close();return a.load(a.m.getConfiguration(),d).then(()=>{const e=a.a.Bf;a.f=!1;a.a=null;return e===uQ?a.pause():a.play()})}catch(d){return Promise.reject(d)}},
19
+ ZQ=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)}},SQ=function(a,b,c){b=b.toUpperCase();b===TQ&&ZQ(a,!0);const d=a.j[b];d&&(d.je.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...`+
20
+ `AVPlay state: ${a.getState()}, `+`buffering: ${a.w}`,m),!1===l&&(a.j[h]={type:h,index:k,xf:0,je:new _.Gk(()=>g(h,c,!0))}),(k=a.j[h])&&3>k.xf?(!a.w&&++k.xf,k.je.ha(a.w?.5:.25)):(a.g.debug("Could not set track after multiple attempts.Giving up..."),k&&k.je.stop(),a.j[h]=null,f())}};g(b,c)})},PQ=function(a){return a.f&&a.a?a.a.dh:webapis.avplay.getCurrentStreamInfo()},$Q=function(a){return _.x(function*(){tizen.systeminfo.getPropertyValue("DISPLAY",b=>{a.A=b.resolutionWidth/1920;a.g.debug("Display resolution ratio: ",
21
+ a.A)},b=>{a.g.debug("Could not load DISPLAY property");throw b;})})},bR=function(a){try{webapis.avplay.setListener({onbufferingstart:a.J.bind(a),onbufferingprogress:a.I.bind(a),onbufferingcomplete:a.H.bind(a),onstreamcompleted:a.M.bind(a),oncurrentplaytime:b=>{a.trigger(new _.D(aR,{currentTime:b}))},onevent:a.L.bind(a),onsubtitlechange:a.O.bind(a),ondrmevent:a.K.bind(a),onerror:a.B.bind(a)})}catch(b){a.g.error(b)}},cR=function(a){const b=!!a.m.getTrackManager().Va();try{webapis.avplay.setSilentSubtitle(!b)}catch(c){a.g.debug("Could not set AVPlay subtitle config",
22
+ c)}},dR=function(a,b){try{const c=b.estimatedBandwidth||0,d=b.currentBandwidth||0;a.g.debug({estimatedBandwidth:c,Ni:d});0!==c&&0!==d&&c>=1.15*d&&webapis.avplay.setStreamingProperty("ADAPTIVE_INFO",gQ+d)}catch(c){a.g.debug(c)}},eR=function(a,b){try{webapis.avplay.setStreamingProperty("ADAPTIVE_INFO","|BITRATES\x3d"+b+gQ+b)}catch(c){throw a.g.debug("Could not set fixed bandwidth",c),c;}},fR=function(a){let b=null;try{b=tizen.tvaudiocontrol.isMute()}catch(c){switch(c.name){case eQ:a.g.warn("The application doesn't have the privilege to get the mute state.",
23
+ fQ);break;default:a.g.warn(cQ,c)}}return!!b},XQ=function(a){return{position:a.getPosition(),state:a.m.getState(),Bf:a.getState(),playbackRate:a.getPlaybackRate(),isLive:a.isLive(),duration:a.getDuration(),isMuted:fR(a),volume:a.getVolume(),yi:WQ(a),dh:PQ(a)}},gR=function(){return new Promise((a,b)=>{if(window.webapis)a();else{const c=document.createElement("script");hQ(c,_.De,d=>a(d));hQ(c,_.q,d=>b(d));c.src="$WEBAPIS/webapis/webapis.js";document.querySelector("head").appendChild(c)}})},hR=function(a){return _.x(function*(){yield gR();
24
+ const b=new Promise(c=>{(new _.Gk(c)).ha(5)});if(!(yield Promise.race([$Q(a).then(()=>!0),b.then(()=>!1)])))return a.g.debug("Took to long for the SDK to be ready"),Promise.reject("SDK Timeout")})},iR=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!");cR(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)}})})},jR=function(a,
25
+ b){try{tizen.tvaudiocontrol.setMute(b)}catch(c){switch(c.name){case eQ:a.g.warn("The application does not have the privilege to set mute.",fQ);break;default:a.g.warn(cQ,c)}}},oR=function(a,b,c){return _.x(function*(){a.l=_.np(b);const d=a.G,e=c||{estimatedBandwidth:0,currentBandwidth:0,nextBandwidth:null,currentPosition:0};a.g.debug(`Loading manifest URL: ${a.l[d].url}`);let f=b.startTime||void 0;a.f&&(a.trigger(new _.D(kR)),f=c.currentPosition);try{let g=a.l[d].url;if(a.l[d].type===_.Kc&&!g.includes(".mpd")){const h=
26
+ new URL(g);h.searchParams.append("cl-ext",".mpd");g=h.toString()}webapis.avplay.open(g);e.nextBandwidth?(eR(a,e.nextBandwidth),a.o=!1):(a.o||dR(a,e),a.o=!0);bR(a);if(b.drm&&b.drm.env){const h={onError:k=>a.m.onError(k),yb:a.m.getNetworkEngine()};a.h=new lR(b.drm,h);yield a.h.init()}else a.g.debug("No DRM configuration was provided. Assuming clear content");a.f||a.trigger(new _.D(mR));yield iR(a);a.f||a.trigger(new _.D(nR));f&&typeof f===_.t&&0<f&&a.seek(f).catch(h=>{a.g.debug("Couldn't set start position",
27
+ h)});a.f||(b.volume&&a.setVolume(b.volume),b.muted&&jR(a,b.muted),b.autoplay&&a.m.play().catch(h=>{a.g.debug("Autoplay failed",h)}))}catch(g){throw a.g.debug("Error while attempting to load source."),g;}})},pR=function(a){if("NONE"!==a.a.getState()){var b=a.j.getBoundingClientRect();{a=a.a;const c=Math.floor(b.left*a.A),d=Math.floor(b.top*a.A),e=Math.floor(b.width*a.A);b=Math.floor(b.height*a.A);a.g.debug("Setting display area to","x:",c,"y:",d,"width:",e,"height:",b);webapis.avplay.setDisplayRect(c,
28
+ d,e,b);0===c&&0===d&&1920===e&&1080===b&&webapis.avplay.setDisplayMethod("PLAYER_DISPLAY_MODE_LETTER_BOX")}}else a.g.debug("Could not apply dimension. Player state "+a.a.getState())},lR=class{constructor(a,b){this.h=a;this.o=null;this.a=_.Re;this.l=null;this.j=!1;this.f=new Map;this.D=b;this.g=new _.S("clpp.tizen.DrmEngine")}init(){const a=this;return _.x(function*(){var b=_.em[a.h.env]||null;if(!b)throw a.g.debug(_.ua,_.wb+a.h.env+_.aa),new _.I(_.F,6,6015,`DRM environment '${a.h.env}' is missing.`);
29
+ a.l={id:String(Math.floor(1E4*Math.random())),type:"MPEG-DASH"};var c=Object.keys(a.h.customData||{}).length?btoa(JSON.stringify(a.h.customData)):"";b=_.gm(b,a.h.customData);const d=b[_.Hd];d&&a.f.set(_.Hd,{qd:d.licenseUrl||"",customData:c,Pe:!1});(b=b[_.Jd])&&a.f.set(_.Jd,{qd:b.licenseUrl||"",customData:c,Pe:!1});if(0===a.f.size)throw new _.I(_.F,6,6E3);if((c=a.h.preferredDrmSystem)&&a.f.get(c))a.a=c;else if(a.f.get(_.Hd))a.a=_.Hd;else if(a.f.get(_.Jd))a.a=_.Jd;else throw new _.I(_.F,6,6001,"Configuration for the target system is missing.");
30
+ yield kQ(a);a.j=!0})}release(){const a=this;return _.x(function*(){a.j=!1;a.o=null;a.a=_.Re;a.l=null;a.f=new Map})}getDrmInfo(){return this.o}},nQ="DeleteLicenseAfterUse",oQ="LicenseServer",pQ="CustomData";var vR=class{constructor(a){this.m=a;this.a=this.m.a;this.f=_.hp;this.j=_.rv;this.w=(new Date).getTime();this.l=!1;this.o=-1;this.h=2;this.g=new _.S("clpp.tizen.StateManager")}initialize(){this.a.on(kR,this.C,this);this.a.on(qR,this.B,this);this.a.on(rR,this.A,this);this.a.on(mR,this.H,this);this.a.on(nR,this.G,this);this.a.on(sR,this.F,this)}release(){sQ(this,_.hp);this.l=!1;this.o=-1;this.h=2}destroy(){this.release();this.a.off(kR,this.C);this.a.off(qR,this.B);this.a.off(rR,this.A);this.a.off(mR,
31
+ this.H);this.a.off(nR,this.G);this.a.off(sR,this.F);this.m=this.a=null}C(){this.g.debug("Buffering start. Player state: ",this.a.getState());this.h=this.a.C?1:2;sQ(this,_.dp)}B(a){this.g.debug("Buffering progress: "+a.percent+" %. Player state: ",rQ(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()===tR;if(!a&&b){sQ(this,_.jp);return}}if(a=this.f!==_.ip)a=this.a.getState(),a=a===
32
+ tQ||a===uQ;a&&vQ(this)}H(){this.g.debug("Preparing starts. AVPlay State: ",this.a.getState());this.a.getState()===uR?sQ(this,_.ip):this.g.error("AVPlay prepares while state is not IDLE")}G(){this.g.debug("Preparing ends: AVPlay state:",this.a.getState())}F(){sQ(this,_.$o)}getState(){return this.f}};var wR=class{constructor(){this.o=this.A=this.f=this.h=this.B=this.m=this.j=this.a=null;this.C=!1;this.w=!0;this.l=null;this.g=new _.S("clpp.tizen.TextStreamer")}initialize(a){this.m=a}load(a){const b=this;return _.x(function*(){if(b.m)if(b.B=a,b.j=yield wQ(b),b.j){var c={configurationId:"",networkingEngine:b.m.getNetworkEngine(),onContentSteeringInfoFound:()=>null,filterNewPeriod:()=>{},filterAllPeriods:()=>{},onEvent:()=>{},onError:()=>{}};try{b.a=yield b.j.start(a.url,c)}catch(d){b.g.warn(d);try{b.a=
33
+ yield b.j.start(a.url.replace("https://","http://"),c)}catch(e){b.g.error(e),b.a=null}}if(b.a&&xQ(b.a)){b.h=yQ(b);try{yield b.h.open();b.f=zQ(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(_.FC,
34
+ a);this.w=!0;let b=_.lG(a.textStreams,this.o||"",this.A||"",this.C)[0]||null;this.l&&(a.textStreams.includes(this.l)&&(b=this.l),this.l=null);return{video:null,audio:null,text:b,bb:null}}F(){this.g.debug("canSwitch_");this.w=!1;this.l&&(_.zH(this.f,this.l,!0,0),this.l=null)}H(){this.g.debug("onError_")}I(){this.j&&this.j.update&&this.j.update()}start(){const a=this;return _.x(function*(){if(a.f)try{a.f.start()}catch(b){a.g.error("Error while starting streaming engine",b)}})}setTextVisibility(a){this.g.debug("Set text visibility",
35
+ a);this.h&&this.h.getTextDisplayer().setTextVisibility(a)}release(){const a=this;return _.x(function*(){a.m=null;a.a=null;a.B=null;a.A=null;a.o=null;a.w=!0;a.l=null})}destroy(){const a=this;return _.x(function*(){a.j&&(yield a.j.stop(),a.j=null);a.f&&(yield a.f.destroy(),a.f=null,a.w=!0);a.h&&(yield a.h.destroy(),a.h=null)})}};var AR=class extends _.T{constructor(){super();this.j=this.a=this.m=null;this.f={};this.g=new _.S("clpp.tizen.TrackManager");this.w=this.o=this.l=null;this.B=!1;this.h=1}C(a){var b=a.eventid;a=a.data;switch(b){case xR:0<Object.keys(this.f).length||(this.g.debug("Loading track manager!"),this.load());b=webapis.avplay.getCurrentStreamInfo();0<b.length&&(b=+GQ(this,b[0].extra_info).Bit_rate,b=HQ(this,{bandwidth:b}))&&(this.w=b,FQ(this,b));break;case yR:EQ(this);break;default:this.g.debug("Event type: "+
36
+ b+" data: "+a)}}A(a){a.detail.currentState===_.kp&&this.m.off(_.$f,this.A)}initialize(a){this.m=a;this.a=this.m.a;this.m.on(_.$f,b=>{this.B||(b=b.detail,b.currentState===_.kp&&(this.g.debug("Current state",b.currentState),this.B=!0,IQ(this)))});this.a.on(zR,this.C,this)}release(){this.f={};this.j=this.w=this.o=this.l=null;this.B=!1;this.h=1}load(){if(this.a&&!(0<Object.keys(this.f).length)){this.j=this.m.h;this.m.off(_.$f,this.A);this.m.on(_.$f,this.A,this);try{const a=WQ(this.a);this.f=OQ(this,a);
37
+ const b=this.f[_.M]||[];b.length&&(this.l=b[0].renditions[0]||null);EQ(this)}catch(a){this.g.debug("Could not load track manager")}}}destroy(){this.a.off(zR,this.C);this.a=this.m=null}getVideoTracks(){return this.f[_.N]||[]}getAudioTracks(){return this.f[_.M]||[]}na(){return this.f[_.L]||[]}oa(){return RQ(this,_.N)}Ra(){return RQ(this,_.M)}Va(){return RQ(this,_.L)}vb(){return this.w}Gb(){this.g.info(dQ);return null}Hb(){this.g.info(dQ);return null}Ia(){const a=this.oa();return a?a.track:null}ra(){const a=
38
+ this.Ra();return a?a.track:null}xa(){const a=this.Va();return a?a.track:null}Db(a){null===a?(a=this.oa(),YQ(this.a,a.bandwidth,null).then(()=>{EQ(this)})):0<a.renditions.length&&this.nb(a.renditions[0])}ya(a){a?UQ(this,a.renditions[0]):this.g.warn("Cannot disable audio tracks on this platform.","Consider muting audio instead...")}Xa(a){a?(a=a.renditions[0],this.j?DQ(this.j,a.track):UQ(this,a)):(this.g.debug("Disabling text tracks"),this.o=null,ZQ(this.a,!1),this.m.trigger(new _.D(_.jg)))}nb(a){const b=
39
+ this.oa();this.a.o||a.width!==b.width||a.height!==b.height||a.bandwidth!==b.bandwidth?(this.w=a,FQ(this,a),YQ(this.a,b.bandwidth,a.bandwidth).then(()=>{EQ(this)}).catch(c=>{const d=new _.I(_.F,7,7200,{tizenerror:c});this.g.debug("Error while switching video track",c);this.m.onError(d)})):this.g.debug("Trying to switch to already active rendition. Doing nothing...")}Bb(a){UQ(this,a)}Cb(a){this.j?DQ(this.j,a.track):UQ(this,a)}addTextTrack(){}ua(){return this.a.o}};AR.prototype.isAbrEnabled=AR.prototype.ua;
40
+ AR.prototype.addTextTrack=AR.prototype.addTextTrack;AR.prototype.setTextRendition=AR.prototype.Cb;AR.prototype.setAudioRendition=AR.prototype.Bb;AR.prototype.setVideoRendition=AR.prototype.nb;AR.prototype.setTextTrack=AR.prototype.Xa;AR.prototype.setAudioTrack=AR.prototype.ya;AR.prototype.setVideoTrack=AR.prototype.Db;AR.prototype.getTextTrack=AR.prototype.xa;AR.prototype.getAudioTrack=AR.prototype.ra;AR.prototype.getVideoTrack=AR.prototype.Ia;AR.prototype.getLoadingTextRendition=AR.prototype.Hb;
41
+ AR.prototype.getLoadingAudioRendition=AR.prototype.Gb;AR.prototype.getLoadingVideoRendition=AR.prototype.vb;AR.prototype.getTextRendition=AR.prototype.Va;AR.prototype.getAudioRendition=AR.prototype.Ra;AR.prototype.getVideoRendition=AR.prototype.oa;AR.prototype.getTextTracks=AR.prototype.na;AR.prototype.getAudioTracks=AR.prototype.getAudioTracks;AR.prototype.getVideoTracks=AR.prototype.getVideoTracks;var ER=class extends _.Cu{constructor(a){super();this.m=a;this.h=null;this.g=new _.S("clpp.tizen.Middleware");this.F=1;this.C=!1;this.l=null;this.G=0;this.o=!0;this.f=!1;this.a=null;this.A=1;this.w=!1;this.j={}}J(){this.w=!0;this.f||this.trigger(new _.D(kR))}I(a){this.w=!0;this.trigger(new _.D(qR,{percent:a}))}H(){this.w=!1;this.trigger(new _.D(rR))}M(){this.trigger(new _.D(sR))}L(a,b){this.trigger(new _.D(zR,{eventid:a,data:b}))}O(a,b,c,d,e){this.trigger(new _.D(BR,{duration:a,text:b,subtitleType:c,
42
+ attriCount:d,attributes:e}))}K(a,b){this.trigger(new _.D(CR,{drmType:a,drmData:b}));this.h&&(a=this.h,a.j&&(a.a===_.Jd&&"Challenge"===b.name?mQ(a,b):"DrmError"===b.name&&(a.g.debug("DrmError event",b),b=new _.I(_.F,6,6005,{message:JSON.stringify(b)}),a.D.onError(b))))}B(a){this.trigger(new _.D(DR,{eventType:a}))}play(){const a=this.getState(),b=()=>new Promise((c,d)=>{let e=null;const f=()=>{c();clearTimeout(e)};this.one(aR,f,this);e=setTimeout(()=>{this.off(aR,f);d("Timeout")},3E4)});if(a===uR)return(new Promise((c,
43
+ d)=>{webapis.avplay.prepareAsync(()=>{cR(this);c(webapis.avplay.play())},e=>{this.trigger(new _.D(DR));d(e)})})).then(()=>b());if(a===uQ||a===tR)try{return webapis.avplay.play(),b()}catch(c){return Promise.reject(c)}return a===tQ?Promise.resolve():Promise.reject("Player is in invalid state")}pause(){try{webapis.avplay.pause()}catch(a){Promise.reject(a)}return this.getState()===uQ?Promise.resolve():Promise.reject()}setPlaybackRate(a){const b=this.getState();if(b===tR||b===tQ||b===uQ){try{webapis.avplay.setSpeed(a),
44
+ this.F=a}catch(c){return this.g.debug("Error while trying to set playback rate",c),this.setPlaybackRate(this.F)}return!0}this.g.debug("Cannot set playback rate; AVPlay is in inconsistent state: "+b);return!1}getPlaybackRate(){return this.F}load(a,b){const c=this;return _.x(function*(){c.g.debug("configure()",b||"");try{yield hR(c),yield oR(c,a,b)}catch(d){throw new _.I(_.F,7,7003,null,d);}})}getState(){if(this.f&&this.a)return this.a.Bf;try{return webapis.avplay.getState()}catch(a){this.B(JSON.stringify(a))}}seek(a){const b=
45
+ 1E3*a;return new Promise((c,d)=>{this.C=!0;this.m.trigger(new _.D(_.Cg));webapis.avplay.seekTo(b,()=>{this.C=!1;this.m.trigger(new _.D(_.Bg));c()},()=>{this.C=!1;d()})})}getPosition(){if(this.f&&this.a)return this.a.position;try{return webapis.avplay.getCurrentTime()/1E3}catch(a){this.B(JSON.stringify(a))}}getDuration(){if(this.f&&this.a)return this.a.duration;try{return webapis.avplay.getDuration()/1E3}catch(a){this.B(JSON.stringify(a))}}release(){return new Promise((a,b)=>{try{this.h&&(this.h.release(),
46
+ this.h=null);webapis.avplay.stop();webapis.avplay.close();for(const c in this.j){const d=this.j[c];d&&d.je.stop()}this.j={};this.F=1;this.C=!1;this.a=this.l=null;return a()}catch(c){return b(c)}})}getVolume(){let a=null;try{a=tizen.tvaudiocontrol.getVolume()}catch(b){switch(b.name){case eQ:this.g.debug("The application does not have the privilege to get the volume.",fQ);break;default:this.g.debug(cQ,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 eQ:this.g.warn("The application does not have the privilege to set the volume.",fQ);break;default:this.g.warn("An unknown error occurred while trying to set volume",b)}}}isLive(){if(this.f&&this.a)return this.a.isLive;try{return"1"===webapis.avplay.getStreamingProperty("IS_LIVE")}catch(a){this.B(JSON.stringify(a))}}stop(){try{webapis.avplay.stop()}catch(a){this.g.debug(a)}}getDrmInfo(){this.h&&this.h.getDrmInfo();return null}setSourceIndex(a){this.G=
48
+ a}getSourceIndex(){return this.G}getLoadedSource(){return this.l&&this.l[this.getSourceIndex()]}},uR="IDLE",tR="READY",tQ="PLAYING",uQ="PAUSED",JQ=_.Tb,KQ=_.EB,TQ="TEXT",yR="PLAYER_MSG_RESOLUTION_CHANGED",xR="PLAYER_MSG_BITRATE_CHANGE",qQ="PLAYREADY",lQ="WIDEVINE_CDM";var IR=class extends _.Cu{constructor(){super();this.a=new ER(this);this.f=new vR(this);this.configuration=this.B=_.Gl();this.w=null;this.g=new _.S("clpp.tizen.Player");this.j=null;this.l=new AR;this.C=new _.Er;this.o=this.h=null;this.A=!1}I(){this.g.debug("On Stream completed. Current time: ",this.getPosition());this.trigger(new _.D(_.je));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 _.D(_.og,
49
+ {currentTime:a.currentTime/1E3}))}J(a){const b=this.a.getPosition(),c=b+a.duration/1E3;let d=a.text||"";this.g.debug("Got subtitles: ",d,"start:",b,"end:",c,a);(d=_.vj(d))&&this.o.append([new _.$t(b,c,d)],[])}G(a){this.g.debug("DRM event: "+a.drmType+", data: "+a.drmData)}K(){this.A||(this.g.debug("Initial buffering completed..."),this.A=!0)}H(a){this.g.debug(`Error: TYPE: ${a.eventType}`);sQ(this.f,_.ap);a=new _.I(_.F,7,7200,{tizenerror:a.eventType});this.a.release();this.trigger(new _.D(_.q,{detail:a}))}init(a,
50
+ b){this.configuration=this.B=b;this.w=a;this.a.on(sR,this.I,this);this.a.on(aR,this.F,this);this.a.on(BR,this.J,this);this.a.on(CR,this.G,this);this.a.on(DR,this.H,this);this.a.on(rR,this.K,this);this.f.initialize();this.l.initialize(this);this.g.debug("Initializing player surface");this.w.hideMediaElement();a=FR;FR+=1;a="__clpp_tizen_player_"+a;this.j=_.Dp(_.Se,{id:a,type:"application/avplayer"});this.w.addElementToContainer(this.j,!0);var c=this.w.getMedia();if(c){a=this.j;{b=[_.Vg,_.oe,"position",
51
+ _.ue,"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}_.Fp(a,d);pR(this)}}getSurface(){return this.w}getConfiguration(){return this.configuration}getTimeline(){return null}setupPlaylist(){return Promise.reject(_.ob)}appendLoad(){return Promise.reject(_.ob)}seekWith(){return Promise.reject(_.ob)}setSeekInterceptor(){}setPlaybackSessionId(){}getBandwidthEstimate(){return null}destroy(){const a=
52
+ this;return _.x(function*(){yield a.release();a.a.off(sR,a.I);a.a.off(aR,a.F);a.a.off(BR,a.J);a.a.off(CR,a.G);a.a.off(DR,a.H);a.a.off(rR,a.K);a.h&&(yield a.h.destroy(),a.h=null);a.j&&(a.j.parentElement.removeChild(a.j),a.j=null);a.l.destroy();a.f.destroy();a.l=null;a.f=null})}namespace(){return GR}getPlaybackRate(){return this.a.getPlaybackRate()}setDrmCustomDataModifier(){}setCdnErrorCallback(){}detach(){}setPlaybackRate(a){this.a.setPlaybackRate(a)}getPosition(){return this.getMediaPosition()}getMediaPosition(){return 0<
53
+ (this.configuration.startTime||0)&&!this.A?0:this.f.getState()===_.$o?this.getDuration():this.a.getPosition()||0}seek(a){return typeof a===_.t&&0<=a?(this.isLive()||(a=Math.min(a,this.getDuration())),this.a.seek(a)):Promise.reject()}getPresentationStartTime(){return null}getSeekRange(){return{start:0,end:0}}getVolume(){const a=this.a.getVolume();return typeof a===_.t?a/100:null}setVolume(a){this.a.setVolume(a)}getDuration(){return this.getMediaDuration()}getMediaDuration(){return this.a.getDuration()}getBufferInfo(){this.g.warn(_.pa);
54
+ return new _.Bu}getTrackManager(){return this.l}unload(){return this.a.release().then(()=>{this.l.release()})}release(){const a=this;return _.x(function*(){a.h&&(yield a.h.release());a.o&&(yield a.o.destroy(),a.o=null);yield a.a.release();a.l.release();a.f.release();a.A=!1})}load(a){const b=this;return _.x(function*(){b.configuration=_.Il(b.B,a);var c=_.So(b.configuration,[_.qe,"native"]);b.o=c.create(b);c=_.np(b.configuration)[0];if(b.configuration.tizen&&b.configuration.tizen.sideStreamText){b.h=
55
+ new wR;b.h.initialize(b);try{yield b.h.load(c),b.h.start()}catch(d){b.g.error(d)}}try{yield b.a.load(b.configuration)}catch(d){throw b.onError(d),d;}b.l.load()})}play(){this.trigger(new _.D(_.gf));pR(this);return this.a.play().then(()=>{vQ(this.f)})}pause(){return this.a.pause().then(()=>{vQ(this.f)})}getState(){return this.f.getState()}getPeriods(){return[]}onError(a){const b=new _.D(_.q,{detail:a});a.severity===_.F&&(sQ(this.f,_.ap),this.a.release());this.trigger(b);b.defaultPrevented&&(b.a=!0)}getDrmInfo(){return this.a.getDrmInfo()}isEnded(){return this.f.getState()===
56
+ _.$o}isPaused(){return this.a.getState()===uQ}isMuted(){return fR(this.a)}setMuted(a){jR(this.a,a)}getNetworkEngine(){return this.C}setNetworkEngine(a){this.C=a}setCmsdManager(){}isLive(){return this.a.isLive()}getStats(){return null}setSourceIndex(a){this.a.setSourceIndex(a)}getSourceIndex(){return this.a.getSourceIndex()}getLoadedSource(){return this.a.getLoadedSource()}canPlay(a,b){return(new HR).canPlay(a,b)}getTimelineCues(){return[]}getCueTimeline(){return null}getTextDisplayer(){return this.o}resetAbr(){}},
57
+ GR="clpp.tizen",FR=0,HR=class{a(){return GR}canPlay(a){a=a.type;const b=!!window.webapis;if((a===_.Kc||a===_.zl||a===_.Pc)&&b){if(_.Kk(2))return 2;if(_.Kk(3)||_.Kk(4)||_.Kk(5)||_.Kk(6))return _.C("Use of clpp.tizen.TizenComponent is not recommended for Tizen version \x3e\x3d 3."),1}return 0}f(a){return a===_.ma}create(){return new IR}};_.z("clpp.tizen.TizenComponent",class extends _.Kv{f(){_.Kh(new HR)}a(){var a=GR;a&&_.Ih[a]&&(delete _.Ih[a],_.Jh.info("Removed Player factory: '"+a+"'"))}id(){return"tizen"}});var kR="onbufferingstart",qR="onbufferingprogress",rR="onbufferingcomplete",sR="onstreamcompleted",aR="oncurrentplaytime",zR="onevent",BR="onsubtitlechange",CR="ondrmevent",DR="onerror",mR="preparingstart",nR="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 Ix='application/mp4; codecs\x3d"stpp.ttml"',Jx='application/mp4; codecs\x3d"stpp.ttml.im1i"',Kx='application/mp4; codecs\x3d"stpp.ttml.im1t"',Lx="backgroundColor",Mx="direction",Nx="displayAlign",Ox="region",Px="textAlign",Qx="textDecoration",Rx="writingMode",Sx=function(a,b,c){a=a.f;for(let d=a.length-1;0<=d;d--){const e=b.get(a[d]);if(e.hasAttribute(c))return e.getAttribute(c)}return null},$x=function(a,b){var c=null;if(Tx.test(a)){{a=Tx.exec(a);c=Number(a[1]);const d=Number(a[2]);
2
- let e=Number(a[3]),f=Number(a[4]);f+=(Number(a[5])||0)/b.f;e+=f/b.frameRate;c=e+60*d+3600*c}}else Ux.test(a)?c=Vx(Ux,a):Wx.test(a)?c=Vx(Wx,a):Xx.test(a)?(a=Xx.exec(a),c=Number(a[1])/b.frameRate):Yx.test(a)?(a=Yx.exec(a),c=Number(a[1])/b.a):Zx.test(a)&&(c=Vx(Zx,a));return c},Vx=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)},ay=function(a){return a.split(":").pop()},by=function(a){return a.replace(/(\d*\.?\d+)c/g,
3
- "$1em")},dy=function(a,b){for(;cy.test(a);){const c=cy.exec(a)[0];a=a.replace(c,`${parseInt(c,10)/b}em`)}return a},ey=function(a){return a?a.replace(/(\d*\.?\d+)%/g,(b,c)=>`${c/100}em`):""},fy=function(a,b,c){a=Sx(a,b,Px);if(!a&&c&&(a=Sx(c,b,Px),!a&&"rltb"===Sx(c,b,Rx)))return _.Lf;switch(a){case _.kd:return _.Ut;case _.Lf:case _.he:return _.Lf;default:return _.te}},gy=function(a,b,c){if(_.lj(a.w))return document.createTextNode(_.pj(a.w||""));if(a.A)return _.Cp("br");const d=_.Cp("span");for(const e of a.f)_.Dp(d,
4
- e);for(const e of a.j)d.appendChild(gy(c.get(e),b,c));return d},jy=function(a,b,c,d){const e=hy.exec(a);a=iy.exec(a);return typeof b===_.t&&0<b&&a?100*Number(a[c])/b:e?Number(e[c]):a?Number(a[c]):d},ky=function(a,b){return typeof b===_.t&&0<b?_.bu:iy.test(a)?0:_.bu},ly=function(a,b,c){return typeof a===_.t?a:typeof b===_.t?b:c},my=function(a,b){a=a.getAttribute("extent");return(a=iy.exec(a))?Number(a[b]):null},oy=function(a){a=a.getAttribute("cellResolution");return(a=ny.exec(a))?Number(a[2]):null},
5
- qy=function(){return`${"inline-"}${py++}`},sy=function(a){return ry.some(b=>b in a.attributes)},ty=function(a,b){if(0===b.length)return[];const c=[];for(const d of b)a.a.has(d)&&c.push(...ty(a,a.a.get(d).f),d);return c},uy=function(a){return a.o.map(b=>b.build(a.l,a.w,a.A,a.h,a.a,a.j,a.f)).filter(b=>null!=b)},vy=function(a){return ay(a.h.nodeName)},yy=function(a,b){if(a.a.has(b))return a.a.get(b);var c=null,d=null;let e=[],f=[],g={};const h=b.parentNode;if(h&&a.a.has(h)){const k=a.a.get(h);e=[...k.l];
6
- -1===[_.da,"span","br"].indexOf(b.nodeName)&&(c=k.a,d=k.j,f=[...k.f],g={},wy.forEach(l=>{l in k.attributes&&(g[l]=k.attributes[l])}))}if(b.nodeType===b.ELEMENT_NODE){b.hasAttribute(Ox)&&(c=b.getAttribute(Ox));b.hasAttribute(_.dg)&&f.push(...b.getAttribute(_.dg).split(" "));d=Array.from(b.attributes).map(k=>k.name);for(const k of d)d=ay(k),g[d]=b.getAttribute(k);d=g.backgroundImage}c=new xy(b,c,d,e,f,g);a.a.set(b,c);return c},zy=function(a){return`${String(Math.floor(a/3600)).padStart(2,"0")}:${String(Math.floor(a/
7
- 60%60)).padStart(2,"0")}:${String(Math.floor(a%60)).padStart(2,"0")}.${String(Math.floor(1E3*a%1E3)).padStart(3,"0")}`},Ay=class{constructor(a,b,c){this.h=a;this.f=b;this.a=c}getId(){return this.h}hasAttribute(a){return a in this.a}getAttribute(a){return this.a[a]}};var By=class extends Ay{constructor(a,b,c){super(a,[],c);this.j=b||""}};var Cy=class extends Ay{constructor(a,b,c){super(a,b,c)}};var Tx=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Ux=/^(?:(\d{2,}):)?(\d{2}):(\d{2})$/,Wx=/^(?:(\d{2,}):)?(\d{2}):(\d{2}\.\d+)$/,Xx=/^(\d*(?:\.\d*)?)f$/,Yx=/^(\d*(?:\.\d*)?)t$/,Zx=/^(?:(\d*(?:\.\d*)?)h)?(?:(\d*(?:\.\d*)?)m)?(?:(\d*(?:\.\d*)?)s)?(?:(\d*(?:\.\d*)?)ms)?$/,hy=/^(\d{1,2}(?:\.\d+)?|100(?:\.0+)?)% (\d{1,2}(?:\.\d+)?|100(?:\.0+)?)%$/,iy=/^(\d+)px (\d+)px$/,ny=/^(\d+) (\d+)$/,cy=/(\d+)px/,Dy=/^(\d+px|\d+em|\d*\.?\d+c)$/,ry=[Lx,"color",Mx,Nx,"fontFamily","fontSize","fontStyle","fontWeight",
8
- "lineHeight","opacity","padding",Px,Qx,"textOutline",Rx,"zIndex"],wy=["begin",_.he];var Ey=class extends Cy{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=$x(this.a.begin,b);b=$x(this.a.end,b);if(null===h||null===b)return null;h+=c;b+=c;c=_.Cp(_.Sd);for(const k of this.j)c.appendChild(gy(g.get(k),e,g));g=new _.Zt(h,b,c.innerHTML.trim(),_.qg);g.cssClassList=[...this.f];g.textAlign=fy(this,e,null);g.writingMode=_.Vt;g.line=-1;g.lineInterpretation=_.Wt;g.lineAlign=_.Xt;g.containerRows=ly(null,oy(a),15);if(this.o&&(f=
9
- f.get(this.o))){g.region=f.build(a,e);g.textAlign=fy(this,e,f);a:switch(Sx(f,e,Rx)){case "tb":case "tblr":a=_.Eg;break a;case "tbrl":a=_.Fg;break a;default:a=_.Vt}g.writingMode=a;a:switch(Sx(f,e,Nx)){case _.kd:a=50;break a;case "after":a=-1;break a;default:a=0}g.line=a;a:switch(Sx(f,e,Nx)){case _.kd:a=1;break a;default:a=_.Wt}g.lineInterpretation=a;a:switch(Sx(f,e,Nx)){case _.kd:e=_.kd;break a;default:e=_.Xt}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 Fy=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 Gy=class extends Cy{constructor(a,b,c){super(a,b,c)}build(a,b){const c=new _.du;c.id=this.getId();const d=ly(a.j.containerWidth,my(a,1),720);a=ly(a.j.containerHeight,my(a,2),480);a:switch(Sx(this,b,Nx)){case "after":var e="flex-start";break a;case _.kd:e=_.kd;break a;default:e="flex-end"}c.displayAlign=e;a:switch(Sx(this,b,Rx)){case "tb":case "tblr":e="row-reverse";break a;case "tbrl":e="row";break a;default:e=_.Bd}c.writingMode=e;e=this.getAttribute("extent")||Sx(this,b,"extent");c.width=jy(e,
11
- d,1,100);c.widthUnits=ky(e,d);c.height=jy(e,a,2,100);c.heightUnits=ky(e,a);b=this.getAttribute("origin")||Sx(this,b,"origin");c.viewportAnchorX=jy(b,d,1,0);c.viewportAnchorY=jy(b,a,2,0);c.viewportAnchorUnits=ky(b,d);c.cssClassList=[...this.f];return c}};var Hy=class extends Ay{constructor(a,b){super("root-container",[],b);this.j=a}};var Jy=class extends Ay{constructor(a,b,c){super(a,b,c)}build(a){var b=null;var c=oy(a);c&&(b=ly(a.j.containerHeight,my(a,2),480)/c);b=ly(a.j.fontSizeRadix,b,16);a=[];c=`::ttml .${this.h}, ::ttml .${this.h} * {`;for(const [g,h]of Iy.entries())g in this.a&&(c+=`${h}:${by(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&&!Dy.test(h)&&Dy.test(k)&&Dy.test(l)?(e=h,g=k):2===d.length&&!Dy.test(h)&&Dy.test(k)?(e=h,g=k):2===d.length&&Dy.test(h)&&Dy.test(k)&&(g=h);if(""!==g){g=by(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=ey(this.a.textShadow),d=by(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(Qx 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
- by(this.a.padding),d+=";"):d="";f=c=c+f+d;"lineHeight"in this.a?(c="",d=this.a.lineHeight,d=by(d),d=dy(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=by(c);c=dy(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}},Iy=new Map([[Lx,"background-color"],
15
- ["color","color"],[Mx,Mx],["fontStyle","font-style"],["fontWeight","font-weight"],["opacity","opacity"],["zIndex","z-index"]]);var Ky=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=[]}},py=0;var Ny=class{constructor(a){this.a=a.firstChild;this.f=new Set}jd(){return!!this.a}next(){if(!this.a)return null;let a=this.a;do this.f.add(a),a.nodeType!==Node.TEXT_NODE&&!Ly.has(ay(a.nodeName))||My.has(ay(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&&!Ly.has(ay(a.nodeName))));const b=this.a;this.a=a;return b}},Ly=new Set(["tt","head","layout",_.Ke,_.qe,Ox,"styling",_.dg,"body",
16
- _.Sd,"p","span","br"]),My=new Set([_.dg,_.qe]);var xy=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 Oy=class{constructor(){this.a=new Map}};var Py=class{constructor(a){this.a=a;this.f=new DOMParser}parseInit(){}parseMedia(a,b,c){c&&c.length||(c=[a.byteLength]);var d=_.lh(this.a.ttml||{}),e=_.K(a,0,c[0]);e=_.cj(e);if(""===e)return{cues:[],styles:[]};var f=null;try{f=this.f.parseFromString(e,_.hg)}catch(m){throw new _.I(_.F,2,2005,"Failed to parse TTML.");}d=new Ky(d);e=new Oy;f=new Ny(f);b=b.periodStart;typeof b===_.t&&(d.A=b);b=c[0];for(var g=1;g<c.length;++g){var h=c[g],k=_.K(a,b,h);k=_.qj(k);const m=`urn:mpeg:14496-30:subs:${g}`;d.h.set(m,
17
- new By(m,k,{imageType:"PNG",encoding:"Base64"}));b+=h}for(;f.jd();)a=f.next(),a=yy(e,a),c=d,b=a,"tt"===vy(b)&&(c.l=new Hy(c.B,Object.assign({},b.attributes))),c=d,b=a,"tt"===vy(b)&&(c.w=new Fy(b.attributes.frameRate,b.attributes.subFrameRate,b.attributes.frameRateMultiplier,b.attributes.tickRate)),c=d,b=a,vy(b)!==_.qe||b.attributes.begin||b.attributes.end||(g=`#${b.getId()}`,c.h.set(g,new By(g,b.h.textContent,b.attributes))),c=d,g=a,vy(g)===_.qe&&g.attributes.begin&&g.attributes.end?(b=`#${qy()}`,
18
- g=new By(b,g.h.textContent,g.attributes),c.h.set(b,g),c=g):c=null,c&&(a.j=c.getId()),c=d,b=a,vy(b)===_.dg&&(g=b.getId()||qy(),h=new Jy(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,vy(g)!==_.dg&&sy(g)?(b=qy(),g=new Jy(b,[],Object.assign({},g.attributes)),c.a.set(b,g),c=g):c=null,c&&a.f.push(c.getId()),c=d,g=a,vy(g)!==_.Sd||!g.attributes.extent&&!g.attributes.origin?c=null:(b=qy(),g=new Gy(b,ty(c,g.f),Object.assign({},g.attributes)),c.j.set(b,g),c=g),c&&(a.a=
19
- c.getId()),c=d,g=a,vy(g)!==Ox?c=null:(b=g.getId(),g=new Gy(b,ty(c,g.f),Object.assign({},g.attributes)),c.j.set(b,g),c=g),c&&(a.a=c.getId()),c=d,g=a,b=g.l,-1===[_.da,"span","br"].indexOf(vy(g))||0===b.length?c=null:(h=b[b.length-1],c.f.has(h)?(b=qy(),g=new Ey(b,g.h.nodeName===_.da?g.h.textContent:null,"br"===vy(g),g.a,g.j,ty(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"===vy(g)||g.j?(b=qy(),g=new Ey(b,null,!1,g.a,g.j,ty(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=uy(d);f=[];for(l of d.a.values())f.push(...l.build(d.l));var l=f;return{cues:e,styles:l}}};var Qy=class{constructor(a){this.f=a}a(a){var b=new Py(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=zy(d.startTime)+" --\x3e "+zy(d.endTime);{var c=d;const e=[];switch(c.textAlign){case _.te:e.push("align:left");break;case _.Lf:e.push("align:right");break;case _.Ut:e.push("align:middle");break;case _.te:e.push("align:start");break;case _.Lf: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 _.gj(b)}},Ry=class{probe(a,b){return a===_.Nc&&b===_.gg}create(a){return new Qy(a)}};var Sy=class{constructor(a){this.a=new Py(a);this.g=new _.S("clpp.ttml.Mp4TtmlParser")}parseInit(a){let b=!1;(new _.Cm).N(_.Ne,_.vm).N(_.pg,_.vm).N(_.Ie,_.vm).N(_.Me,_.vm).N(_.ag,_.vm).ea(_.cg,_.wm).N("stpp",c=>{b=!0;c.parser.stop()}).parse(a);if(!b)throw new _.I(_.F,2,2007);}parseMedia(a,b){let c=!1,d=[],e=[];const f=[];(new _.Cm).N("moof",_.vm).N("traf",_.vm).ea("subs",g=>{const h=_.P(g.reader);for(let k=0;k<h;++k){g.reader.skip(4);const l=_.om(g.reader);for(let m=0;m<l;++m){const n=1===g.version?
22
- _.P(g.reader):_.om(g.reader);f.push(n);g.reader.skip(6)}}}).N(_.He,_.xm(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 _.Iv{constructor(){super();this.j=new Ry}f(){_.Ct(_.Nc,Py);_.Ct(_.Lc,Sy);_.Ct(Ix,Sy);_.Ct(Kx,Sy);_.Ct(Jx,Sy);_.xk.push(this.j)}a(){_.Et(_.Nc);_.Et(_.Lc);_.Et(Ix);_.Et(Kx);_.Et(Jx);_.zk(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 Kx='application/mp4; codecs\x3d"stpp.ttml"',Lx='application/mp4; codecs\x3d"stpp.ttml.im1i"',Mx='application/mp4; codecs\x3d"stpp.ttml.im1t"',Nx="backgroundColor",Ox="direction",Px="displayAlign",Qx="region",Rx="textAlign",Sx="textDecoration",Tx="writingMode",Ux=function(a,b,c){a=a.f;for(let d=a.length-1;0<=d;d--){const e=b.get(a[d]);if(e.hasAttribute(c))return e.getAttribute(c)}return null},by=function(a,b){var c=null;if(Vx.test(a)){{a=Vx.exec(a);c=Number(a[1]);const d=Number(a[2]);
2
+ let e=Number(a[3]),f=Number(a[4]);f+=(Number(a[5])||0)/b.f;e+=f/b.frameRate;c=e+60*d+3600*c}}else Wx.test(a)?c=Xx(Wx,a):Yx.test(a)?c=Xx(Yx,a):Zx.test(a)?(a=Zx.exec(a),c=Number(a[1])/b.frameRate):$x.test(a)?(a=$x.exec(a),c=Number(a[1])/b.a):ay.test(a)&&(c=Xx(ay,a));return c},Xx=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)},cy=function(a){return a.split(":").pop()},dy=function(a){return a.replace(/(\d*\.?\d+)c/g,
3
+ "$1em")},fy=function(a,b){for(;ey.test(a);){const c=ey.exec(a)[0];a=a.replace(c,`${parseInt(c,10)/b}em`)}return a},gy=function(a){return a?a.replace(/(\d*\.?\d+)%/g,(b,c)=>`${c/100}em`):""},hy=function(a,b,c){a=Ux(a,b,Rx);if(!a&&c&&(a=Ux(c,b,Rx),!a&&"rltb"===Ux(c,b,Tx)))return _.ie;switch(a){case _.ld:return _.Vt;case _.Mf:case _.ie:return _.ie;default:return _.Zf}},iy=function(a,b,c){if(_.rj(a.w))return document.createTextNode(_.vj(a.w||""));if(a.A)return _.Dp("br");const d=_.Dp("span");for(const e of a.f)_.Ep(d,
4
+ e);for(const e of a.j)d.appendChild(iy(c.get(e),b,c));return d},ly=function(a,b,c,d){const e=jy.exec(a);a=ky.exec(a);return typeof b===_.t&&0<b&&a?100*Number(a[c])/b:e?Number(e[c]):a?Number(a[c]):d},my=function(a,b){return typeof b===_.t&&0<b?_.cu:ky.test(a)?0:_.cu},ny=function(a,b,c){return typeof a===_.t?a:typeof b===_.t?b:c},oy=function(a,b){a=a.getAttribute("extent");return(a=ky.exec(a))?Number(a[b]):null},qy=function(a){a=a.getAttribute("cellResolution");return(a=py.exec(a))?Number(a[2]):null},
5
+ sy=function(){return`${"inline-"}${ry++}`},uy=function(a){return ty.some(b=>b in a.attributes)},vy=function(a,b){if(0===b.length)return[];const c=[];for(const d of b)a.a.has(d)&&c.push(...vy(a,a.a.get(d).f),d);return c},wy=function(a){return a.o.map(b=>b.build(a.l,a.w,a.A,a.h,a.a,a.j,a.f)).filter(b=>null!=b)},xy=function(a){return cy(a.h.nodeName)},Ay=function(a,b){if(a.a.has(b))return a.a.get(b);var c=null,d=null;let e=[],f=[],g={};const h=b.parentNode;if(h&&a.a.has(h)){const k=a.a.get(h);e=[...k.l];
6
+ -1===[_.da,"span","br"].indexOf(b.nodeName)&&(c=k.a,d=k.j,f=[...k.f],g={},yy.forEach(l=>{l in k.attributes&&(g[l]=k.attributes[l])}))}if(b.nodeType===b.ELEMENT_NODE){b.hasAttribute(Qx)&&(c=b.getAttribute(Qx));b.hasAttribute(_.eg)&&f.push(...b.getAttribute(_.eg).split(" "));d=Array.from(b.attributes).map(k=>k.name);for(const k of d)d=cy(k),g[d]=b.getAttribute(k);d=g.backgroundImage}c=new zy(b,c,d,e,f,g);a.a.set(b,c);return c},By=function(a){return`${String(Math.floor(a/3600)).padStart(2,"0")}:${String(Math.floor(a/
7
+ 60%60)).padStart(2,"0")}:${String(Math.floor(a%60)).padStart(2,"0")}.${String(Math.floor(1E3*a%1E3)).padStart(3,"0")}`},Cy=class{constructor(a,b,c){this.h=a;this.f=b;this.a=c}getId(){return this.h}hasAttribute(a){return a in this.a}getAttribute(a){return this.a[a]}};var Dy=class extends Cy{constructor(a,b,c){super(a,[],c);this.j=b||""}};var Ey=class extends Cy{constructor(a,b,c){super(a,b,c)}};var Vx=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Wx=/^(?:(\d{2,}):)?(\d{2}):(\d{2})$/,Yx=/^(?:(\d{2,}):)?(\d{2}):(\d{2}\.\d+)$/,Zx=/^(\d*(?:\.\d*)?)f$/,$x=/^(\d*(?:\.\d*)?)t$/,ay=/^(?:(\d*(?:\.\d*)?)h)?(?:(\d*(?:\.\d*)?)m)?(?:(\d*(?:\.\d*)?)s)?(?:(\d*(?:\.\d*)?)ms)?$/,jy=/^(\d{1,2}(?:\.\d+)?|100(?:\.0+)?)% (\d{1,2}(?:\.\d+)?|100(?:\.0+)?)%$/,ky=/^(\d+)px (\d+)px$/,py=/^(\d+) (\d+)$/,ey=/(\d+)px/,Fy=/^(\d+px|\d+em|\d*\.?\d+c)$/,ty=[Nx,"color",Ox,Px,"fontFamily","fontSize","fontStyle","fontWeight",
8
+ "lineHeight","opacity","padding",Rx,Sx,"textOutline",Tx,"zIndex"],yy=["begin",_.ie];var Gy=class extends Ey{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=by(this.a.begin,b);b=by(this.a.end,b);if(null===h||null===b)return null;h+=c;b+=c;c=_.Dp(_.Sd);for(const k of this.j)c.appendChild(iy(g.get(k),e,g));g=new _.$t(h,b,c.innerHTML.trim(),_.rg);g.cssClassList=[...this.f];g.textAlign=hy(this,e,null);g.writingMode=_.Wt;g.line=-1;g.lineInterpretation=_.Xt;g.lineAlign=_.Yt;g.containerRows=ny(null,qy(a),15);if(this.o&&(f=
9
+ f.get(this.o))){g.region=f.build(a,e);g.textAlign=hy(this,e,f);a:switch(Ux(f,e,Tx)){case "tb":case "tblr":a=_.Fg;break a;case "tbrl":a=_.Gg;break a;default:a=_.Wt}g.writingMode=a;a:switch(Ux(f,e,Px)){case _.ld:a=50;break a;case "after":a=-1;break a;default:a=0}g.line=a;a:switch(Ux(f,e,Px)){case _.ld:a=1;break a;default:a=_.Xt}g.lineInterpretation=a;a:switch(Ux(f,e,Px)){case _.ld:e=_.ld;break a;default:e=_.Yt}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 Hy=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 Iy=class extends Ey{constructor(a,b,c){super(a,b,c)}build(a,b){const c=new _.eu;c.id=this.getId();const d=ny(a.j.containerWidth,oy(a,1),720);a=ny(a.j.containerHeight,oy(a,2),480);a:switch(Ux(this,b,Px)){case "after":var e="flex-start";break a;case _.ld:e=_.ld;break a;default:e="flex-end"}c.displayAlign=e;a:switch(Ux(this,b,Tx)){case "tb":case "tblr":e="row-reverse";break a;case "tbrl":e="row";break a;default:e=_.Cd}c.writingMode=e;e=this.getAttribute("extent")||Ux(this,b,"extent");c.width=ly(e,
11
+ d,1,100);c.widthUnits=my(e,d);c.height=ly(e,a,2,100);c.heightUnits=my(e,a);b=this.getAttribute("origin")||Ux(this,b,"origin");c.viewportAnchorX=ly(b,d,1,0);c.viewportAnchorY=ly(b,a,2,0);c.viewportAnchorUnits=my(b,d);c.cssClassList=[...this.f];return c}};var Jy=class extends Cy{constructor(a,b){super("root-container",[],b);this.j=a}};var Ly=class extends Cy{constructor(a,b,c){super(a,b,c)}build(a){var b=null;var c=qy(a);c&&(b=ny(a.j.containerHeight,oy(a,2),480)/c);b=ny(a.j.fontSizeRadix,b,16);a=[];c=`::ttml .${this.h}, ::ttml .${this.h} * {`;for(const [g,h]of Ky.entries())g in this.a&&(c+=`${h}:${dy(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&&!Fy.test(h)&&Fy.test(k)&&Fy.test(l)?(e=h,g=k):2===d.length&&!Fy.test(h)&&Fy.test(k)?(e=h,g=k):2===d.length&&Fy.test(h)&&Fy.test(k)&&(g=h);if(""!==g){g=dy(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=gy(this.a.textShadow),d=dy(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(Sx 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
+ dy(this.a.padding),d+=";"):d="";f=c=c+f+d;"lineHeight"in this.a?(c="",d=this.a.lineHeight,d=dy(d),d=fy(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=dy(c);c=fy(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}},Ky=new Map([[Nx,"background-color"],
15
+ ["color","color"],[Ox,Ox],["fontStyle","font-style"],["fontWeight","font-weight"],["opacity","opacity"],["zIndex","z-index"]]);var My=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=[]}},ry=0;var Py=class{constructor(a){this.a=a.firstChild;this.f=new Set}kd(){return!!this.a}next(){if(!this.a)return null;let a=this.a;do this.f.add(a),a.nodeType!==Node.TEXT_NODE&&!Ny.has(cy(a.nodeName))||Oy.has(cy(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&&!Ny.has(cy(a.nodeName))));const b=this.a;this.a=a;return b}},Ny=new Set(["tt","head","layout",_.Le,_.re,Qx,"styling",_.eg,"body",
16
+ _.Sd,"p","span","br"]),Oy=new Set([_.eg,_.re]);var zy=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 Qy=class{constructor(){this.a=new Map}};var Ry=class{constructor(a){this.a=a;this.f=new DOMParser}parseInit(){}parseMedia(a,b,c){c&&c.length||(c=[a.byteLength]);var d=_.mh(this.a.ttml||{}),e=_.K(a,0,c[0]);e=_.ij(e);if(""===e)return{cues:[],styles:[]};var f=null;try{f=this.f.parseFromString(e,_.ig)}catch(m){throw new _.I(_.F,2,2005,"Failed to parse TTML.");}d=new My(d);e=new Qy;f=new Py(f);b=b.periodStart;typeof b===_.t&&(d.A=b);b=c[0];for(var g=1;g<c.length;++g){var h=c[g],k=_.K(a,b,h);k=_.Wl(k);const m=`urn:mpeg:14496-30:subs:${g}`;d.h.set(m,
17
+ new Dy(m,k,{imageType:"PNG",encoding:"Base64"}));b+=h}for(;f.kd();)a=f.next(),a=Ay(e,a),c=d,b=a,"tt"===xy(b)&&(c.l=new Jy(c.B,Object.assign({},b.attributes))),c=d,b=a,"tt"===xy(b)&&(c.w=new Hy(b.attributes.frameRate,b.attributes.subFrameRate,b.attributes.frameRateMultiplier,b.attributes.tickRate)),c=d,b=a,xy(b)!==_.re||b.attributes.begin||b.attributes.end||(g=`#${b.getId()}`,c.h.set(g,new Dy(g,b.h.textContent,b.attributes))),c=d,g=a,xy(g)===_.re&&g.attributes.begin&&g.attributes.end?(b=`#${sy()}`,
18
+ g=new Dy(b,g.h.textContent,g.attributes),c.h.set(b,g),c=g):c=null,c&&(a.j=c.getId()),c=d,b=a,xy(b)===_.eg&&(g=b.getId()||sy(),h=new Ly(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,xy(g)!==_.eg&&uy(g)?(b=sy(),g=new Ly(b,[],Object.assign({},g.attributes)),c.a.set(b,g),c=g):c=null,c&&a.f.push(c.getId()),c=d,g=a,xy(g)!==_.Sd||!g.attributes.extent&&!g.attributes.origin?c=null:(b=sy(),g=new Iy(b,vy(c,g.f),Object.assign({},g.attributes)),c.j.set(b,g),c=g),c&&(a.a=
19
+ c.getId()),c=d,g=a,xy(g)!==Qx?c=null:(b=g.getId(),g=new Iy(b,vy(c,g.f),Object.assign({},g.attributes)),c.j.set(b,g),c=g),c&&(a.a=c.getId()),c=d,g=a,b=g.l,-1===[_.da,"span","br"].indexOf(xy(g))||0===b.length?c=null:(h=b[b.length-1],c.f.has(h)?(b=sy(),g=new Gy(b,g.h.nodeName===_.da?g.h.textContent:null,"br"===xy(g),g.a,g.j,vy(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"===xy(g)||g.j?(b=sy(),g=new Gy(b,null,!1,g.a,g.j,vy(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=wy(d);f=[];for(l of d.a.values())f.push(...l.build(d.l));var l=f;return{cues:e,styles:l}}};var Sy=class{constructor(a){this.f=a}a(a){var b=new Ry(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=By(d.startTime)+" --\x3e "+By(d.endTime);{var c=d;const e=[];switch(c.textAlign){case _.ue:e.push("align:left");break;case _.Mf:e.push("align:right");break;case _.Vt:e.push("align:middle");break;case _.Zf:e.push("align:start");break;case _.ie:e.push("align:end")}switch(c.writingMode){case _.Fg:e.push("vertical:lr");break;case _.Gg:e.push("vertical:rl")}c=
21
+ e.length?" "+e.join(" "):""}b=a+(b+c+"\n");b+=d.payload+"\n\n"}return _.mj(b)}},Ty=class{probe(a,b){return a===_.Oc&&b===_.hg}create(a){return new Sy(a)}};var Uy=class{constructor(a){this.a=new Ry(a);this.g=new _.S("clpp.ttml.Mp4TtmlParser")}parseInit(a){let b=!1;(new _.Dm).N(_.Oe,_.wm).N(_.qg,_.wm).N(_.Je,_.wm).N(_.Ne,_.wm).N(_.bg,_.wm).ea(_.dg,_.xm).N("stpp",c=>{b=!0;c.parser.stop()}).parse(a);if(!b)throw new _.I(_.F,2,2007);}parseMedia(a,b){let c=!1,d=[],e=[];const f=[];(new _.Dm).N("moof",_.wm).N("traf",_.wm).ea("subs",g=>{const h=_.P(g.reader);for(let k=0;k<h;++k){g.reader.skip(4);const l=_.pm(g.reader);for(let m=0;m<l;++m){const n=1===g.version?
22
+ _.P(g.reader):_.pm(g.reader);f.push(n);g.reader.skip(6)}}}).N(_.Ie,_.ym(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 _.Kv{constructor(){super();this.j=new Ty}f(){_.Dt(_.Oc,Ry);_.Dt(_.Mc,Uy);_.Dt(Kx,Uy);_.Dt(Mx,Uy);_.Dt(Lx,Uy);_.rk.push(this.j)}a(){_.Ft(_.Oc);_.Ft(_.Mc);_.Ft(Kx);_.Ft(Mx);_.Ft(Lx);_.tk(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 xx="VerimatrixVCAS",yx="clpp.verimatrix.Vcas",zx="clpp.verimatrix.VcasComponent",Bx=function(a,b){return a.C===Ax?(a=Object.assign({},{deviceId:_.rj(_.ij(a.A))},a.a&&{authenticator:_.rj(_.ij(a.a))}),b+_.gk(a)):b},Hx=class extends _.Gu{constructor(a){super(xx);const b={};b[Cx]=Cx;b[Dx]=Dx;const {deviceId:c,authenticator:d,licenseRequestVuidLocation:e=Ax,httpHeaderNames:f=b,widevineLicenseUrl:g,playReadyLicenseUrl:h,fairPlayLicenseUrl:k,fairPlayCertificateUrl:l,fairPlaySiteId:m,fairPlayAssetIdStrategy:n=
2
- Ex}=a;this.A=c;this.a=d;this.C=e;this.B=f;this.w=Bx(this,g);this.o=Bx(this,h);this.l=Bx(this,k);this.j=l;this.G=m;this.F=n;this.g=new _.S(yx);_.mj(this.w)?this.g.warn(_.Wb):this.cb(_.Jd,{licenseUrl:this.w,videoRobustness:[_.Bb,void 0],audioRobustness:[_.Ab,void 0],persistentStateRequired:!1,distinctiveIdentifierRequired:!1,serverCertificate:null,modifiers:{licenseRequest:this.h.bind(this)}});_.mj(this.o)?this.g.warn(_.sb):this.cb(_.Hd,{licenseUrl:this.o,videoRobustness:["3000"],audioRobustness:["2000"],
3
- modifiers:{licenseRequest:this.h.bind(this)}});_.mj(this.l)?this.g.warn(_.Ta):_.mj(this.j)?this.g.warn(_.Ra):this.cb(_.Dd,{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===Fx){a=this.B[Dx];const c={};c[this.B[Cx]]=this.A;this.a&&(c[a]=this.a);Object.keys(c).forEach(d=>{b.headers[d]=c[d]})}}H(a,b){a=_.Bm(b);switch(this.F){case Gx:a=_.gk({r:a,Yi:this.G},!0)}return a}J(a,b){this.h(a,
4
- b);_.Gm(b)}K(a,b){_.Hm(b)}};_.z(yx,Hx);Hx.prototype.constructor=Hx.prototype.constructor;Hx.NAME=xx;var Ax="query-string",Fx="http-header";Hx.LicenseRequestVuidLocation={QUERY_STRING:Ax,HTTP_HEADER:Fx};var Cx="DeviceId",Dx="Authenticator";Hx.LicenseRequestHttpHeader={DEVICE_ID_HEADER:Cx,AUTHENTICATOR_HEADER:Dx};var Ex="keyid",Gx="contentid-siteid";Hx.FairPlayAssetIdStrategy={KEYID:Ex,CONTENTID_SITEID:Gx};_.z(zx,class extends _.Iv{constructor(){super();this.g=new _.S(zx)}a(){delete _.dm.VerimatrixVCAS}h(a){a=a.getConfiguration();if(a.drm&&a.drm.env===xx){({customData:a}=a.drm);if(!a)throw new _.I(_.F,7,7100,_.Kd);a=new Hx(a);this.g.info("Registering the Verimatrix VCAS Ultra environment");_.em(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 zx="VerimatrixVCAS",Ax="clpp.verimatrix.Vcas",Bx="clpp.verimatrix.VcasComponent",Dx=function(a,b){return a.C===Cx?(a=Object.assign({},{deviceId:_.Xl(_.oj(a.A))},a.a&&{authenticator:_.Xl(_.oj(a.a))}),b+_.ak(a)):b},Jx=class extends _.Iu{constructor(a){super(zx);const b={};b[Ex]=Ex;b[Fx]=Fx;const {deviceId:c,authenticator:d,licenseRequestVuidLocation:e=Cx,httpHeaderNames:f=b,widevineLicenseUrl:g,playReadyLicenseUrl:h,fairPlayLicenseUrl:k,fairPlayCertificateUrl:l,fairPlaySiteId:m,fairPlayAssetIdStrategy:n=
2
+ Gx}=a;this.A=c;this.a=d;this.C=e;this.B=f;this.w=Dx(this,g);this.o=Dx(this,h);this.l=Dx(this,k);this.j=l;this.G=m;this.F=n;this.g=new _.S(Ax);_.sj(this.w)?this.g.warn(_.Xb):this.cb(_.Jd,{licenseUrl:this.w,videoRobustness:[_.Db,void 0],audioRobustness:[_.Cb,void 0],persistentStateRequired:!1,distinctiveIdentifierRequired:!1,serverCertificate:null,modifiers:{licenseRequest:this.h.bind(this)}});_.sj(this.o)?this.g.warn(_.tb):this.cb(_.Hd,{licenseUrl:this.o,videoRobustness:["3000"],audioRobustness:["2000"],
3
+ modifiers:{licenseRequest:this.h.bind(this)}});_.sj(this.l)?this.g.warn(_.Ta):_.sj(this.j)?this.g.warn(_.Sa):this.cb(_.Ed,{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===Hx){a=this.B[Fx];const c={};c[this.B[Ex]]=this.A;this.a&&(c[a]=this.a);Object.keys(c).forEach(d=>{b.headers[d]=c[d]})}}H(a,b){a=_.Cm(b);switch(this.F){case Ix:a=_.ak({r:a,Zi:this.G},!0)}return a}J(a,b){this.h(a,
4
+ b);_.Hm(b)}K(a,b){_.Im(b)}};_.z(Ax,Jx);Jx.prototype.constructor=Jx.prototype.constructor;Jx.NAME=zx;var Cx="query-string",Hx="http-header";Jx.LicenseRequestVuidLocation={QUERY_STRING:Cx,HTTP_HEADER:Hx};var Ex="DeviceId",Fx="Authenticator";Jx.LicenseRequestHttpHeader={DEVICE_ID_HEADER:Ex,AUTHENTICATOR_HEADER:Fx};var Gx="keyid",Ix="contentid-siteid";Jx.FairPlayAssetIdStrategy={KEYID:Gx,CONTENTID_SITEID:Ix};_.z(Bx,class extends _.Kv{constructor(){super();this.g=new _.S(Bx)}a(){delete _.em.VerimatrixVCAS}h(a){a=a.getConfiguration();if(a.drm&&a.drm.env===zx){({customData:a}=a.drm);if(!a)throw new _.I(_.F,7,7100,_.Kd);a=new Jx(a);this.g.info("Registering the Verimatrix VCAS Ultra environment");_.fm(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 ox="Registering listeners",px="clpp.vimond.VimondPlugin",qx=function(a,b){a.m.trigger(new _.D(_.Kg,{detail:b}))},rx=function(a,b,c){b&&(a.B=!0,a.h.stop());a.m.onError(new _.I(b?_.F:1,9,9201,c))},sx=function(a,b){const c=a.m.getState();if(1===b)return["str-start",_.rf];if(a.h)return[_.he,_.bf];if(c===_.Zo)return[_.he,null];if(c===_.$o)return[_.r,_.bf];b=_.bf;if(c===_.cp||c===_.jp||a.f)b=_.rf;return["period",b]},tx=class{constructor(a,b,c,d,e){this.K=a;this.L=b;this.M=c;this.m=d;this.F=
2
- e;this.a=new _.Rt;this.l=!0;this.f=this.j=this.B=!1;this.C=null;this.h=new _.Mk(this.A.bind(this));this.g=new _.S("clpp.vimond.VimondDispatcher");this.o=this.w=0;this.m&&this.a&&(this.g.debug(ox),this.a.on(this.m,_.Zf,this.I.bind(this)),this.a.on(this.m,_.ng,this.J.bind(this)),this.a.on(this.m,_.hc,this.G.bind(this)),this.a.on(this.m,_.ic,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!==_.jp||(b.f&&[_.ip,_.cp].includes(d)?b.g.debug("Seeking"):(b.f&&d===_.jp&&(b.g.debug("Seeked"),b.f=!1),[_.jp,_.ip,_.$o,_.Zo].includes(d)&&(b.C=d,yield b.A(),d===_.Zo&&b.h.stop()))):b.g.debug("Ignore transition"))})}A(){const a=this;return _.x(function*(){var b=Math.floor(Date.now()/1E3);0<a.o&&a.g.debug(`Last event was ${b-
4
- a.o} seconds ago`);a.o=b;a.h.stop();a.h.ia(a.l?10:a.K);a.l=!1;try{var c=yield a.F.fireEvent();qx(a,c)}catch(d){b=d.code,c=d.data,[1002,1003].includes(b)?(a.g.debug("Unreachable service"),qx(a,c),rx(a,a.L,c)):1001===b?(a.g.debug("Generic service error"),qx(a,c),rx(a,a.M,c)):a.g.error(d.toString())}})}};var ux=class{constructor(a,b,c,d,e){this.l=a;this.o=c;this.h=b;this.a=d;this.j=e;this.g=new _.S("clpp.vimond.VimondService");this.f=0}fireEvent(){this.f++;const a=_.kh(this.o);a.client.buildName=_.qa;a.client.buildVersion=_.ea;var b=a.client;var c=(c=this.a.m.getDrmInfo())?c.keySystem:"";b.drm=c;a.client.pageUrl=document.location.href;a.client.streamUrl=this.a.m.getLoadedSource().url;a.client.userAgent=navigator.userAgent;a.client.videoFormat=this.a.m.getLoadedSource().type||"";b=a.client;c=this.a.m.getLoadedSource();
5
- c=((new _.Am(c.url)).scheme||"").replace(":","");b.videoProtocol=c;b=sx(this.a,this.f);a.client.playerEvent=b[0]||"";a.client.playerState=b[1]||"";a.progress.vod&&(a.progress.vod.position=this.a.getPosition());if(b=a.progress.live){c=this.a;var d=c.m.getPresentationStartTime()||0;c=Math.floor(d+c.m.getPosition());c=(new Date(1E3*c)).toISOString();b.position=c;d=this.a;c=d.m.getPosition();d=d.m.getSeekRange().end;c=30>Math.abs(d-c);b.onLiveEdge=c;typeof b.liveResumePossible!==_.Zc&&(b.liveResumePossible=
6
- !0)}a.progress.eventNumber=this.f;a.timestamp=(new Date).toISOString();this.g.debug("Fire an event");b=_.Jj(this.l);b.method=_.rb;b.contentType="application/json";b.headers.Authorization=`Bearer ${this.h}`;b.body=_.ij(JSON.stringify(a));return this.j.fetch(b).U}lf(a){this.h=a}};var vx=class{constructor(a){this.m=a;this.a=new _.Rt;this.g=new _.S("clpp.vimond.VimondAdapter");this.f=this.h=!1;this.m&&this.a&&(this.g.debug(ox),this.a.on(this.m,_.Hf,this.o.bind(this)),this.a.on(this.m,_.hc,this.j.bind(this)),this.a.on(this.m,_.ic,this.l.bind(this)))}getPosition(){return Math.floor(this.m.getPosition())}o(){this.h=!0}j(){this.f=!0}l(){this.f=!1}};var wx=class extends _.Xv{constructor(){super();this.a=!1;this.g=new _.S(px);this.j=this.h=this.f=null}onPlayerCreated(){}onContentWillLoad(a){var b=a.getConfiguration();(this.a=!_.B(b.vimond)&&typeof b.vimond===_.Re)?a.namespace()===_.td&&(this.a=!1,this.g.info("Vimond does not report when casting.")):this.g.debug("Vimond plugin is loaded but not configured. Will do nothing.");if(this.a){b=a.getConfiguration().vimond;for(var c of["authToken","playerEventRequest"])if(!b[c]){this.g.warn(`${c} key is missing`);
7
- a.onError(new _.I(1,9,9200));return}this.g.debug(_.ra);c=b.failIfUnreachable;typeof c!==_.Zc&&(c=!0);var d=b.failOnError;typeof d!==_.Zc&&(d=!0);this.f=new vx(a);this.h=new ux(b.playerEventRequest.uri,b.authToken,b.playerEventRequest.body,this.f,a.getNetworkEngine());this.j=new tx(b.playerEventRequest.eventInterval,c,d,a,this.h)}}onPlayerWillRelease(){if(this.a){if(this.f){var a=this.f;a.g.debug(_.Ob);_.Sh(a.a)}this.j&&(a=this.j,a.g.debug(_.Ob),_.Sh(a.a),a.h.stop());this.j=this.h=this.f=null}}onPlayerWillDestroy(){}id(){return"vimond"}lf(a){this.a&&
8
- this.h&&this.h.lf(a)}};_.z(px,wx);wx.prototype.updateAuthToken=wx.prototype.lf;wx.Id="vimond";_.Mr(new class{create(){return new wx}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var qx="Registering listeners",rx="clpp.vimond.VimondPlugin",sx=function(a,b){a.m.trigger(new _.D(_.Lg,{detail:b}))},tx=function(a,b,c){b&&(a.B=!0,a.h.stop());a.m.onError(new _.I(b?_.F:1,9,9201,c))},ux=function(a,b){const c=a.m.getState();if(1===b)return["str-start",_.sf];if(a.h)return[_.ie,_.cf];if(c===_.$o)return[_.ie,null];if(c===_.ap)return[_.q,_.cf];b=_.cf;if(c===_.dp||c===_.kp||a.f)b=_.sf;return["period",b]},vx=class{constructor(a,b,c,d,e){this.K=a;this.L=b;this.M=c;this.m=d;this.F=
2
+ e;this.a=new _.St;this.l=!0;this.f=this.j=this.B=!1;this.C=null;this.h=new _.Gk(this.A.bind(this));this.g=new _.S("clpp.vimond.VimondDispatcher");this.o=this.w=0;this.m&&this.a&&(this.g.debug(qx),this.a.on(this.m,_.$f,this.I.bind(this)),this.a.on(this.m,_.og,this.J.bind(this)),this.a.on(this.m,_.jc,this.G.bind(this)),this.a.on(this.m,_.kc,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!==_.kp||(b.f&&[_.jp,_.dp].includes(d)?b.g.debug("Seeking"):(b.f&&d===_.kp&&(b.g.debug("Seeked"),b.f=!1),[_.kp,_.jp,_.ap,_.$o].includes(d)&&(b.C=d,yield b.A(),d===_.$o&&b.h.stop()))):b.g.debug("Ignore transition"))})}A(){const a=this;return _.x(function*(){var b=Math.floor(Date.now()/1E3);0<a.o&&a.g.debug(`Last event was ${b-
4
+ a.o} seconds ago`);a.o=b;a.h.stop();a.h.ha(a.l?10:a.K);a.l=!1;try{var c=yield a.F.fireEvent();sx(a,c)}catch(d){b=d.code,c=d.data,[1002,1003].includes(b)?(a.g.debug("Unreachable service"),sx(a,c),tx(a,a.L,c)):1001===b?(a.g.debug("Generic service error"),sx(a,c),tx(a,a.M,c)):a.g.error(d.toString())}})}};var wx=class{constructor(a,b,c,d,e){this.l=a;this.o=c;this.h=b;this.a=d;this.j=e;this.g=new _.S("clpp.vimond.VimondService");this.f=0}fireEvent(){this.f++;const a=_.lh(this.o);a.client.buildName=_.qa;a.client.buildVersion=_.ea;var b=a.client;var c=(c=this.a.m.getDrmInfo())?c.keySystem:"";b.drm=c;a.client.pageUrl=document.location.href;a.client.streamUrl=this.a.m.getLoadedSource().url;a.client.userAgent=navigator.userAgent;a.client.videoFormat=this.a.m.getLoadedSource().type||"";b=a.client;c=this.a.m.getLoadedSource();
5
+ c=((new _.Bm(c.url)).scheme||"").replace(":","");b.videoProtocol=c;b=ux(this.a,this.f);a.client.playerEvent=b[0]||"";a.client.playerState=b[1]||"";a.progress.vod&&(a.progress.vod.position=this.a.getPosition());if(b=a.progress.live){c=this.a;var d=c.m.getPresentationStartTime()||0;c=Math.floor(d+c.m.getPosition());c=(new Date(1E3*c)).toISOString();b.position=c;d=this.a;c=d.m.getPosition();d=d.m.getSeekRange().end;c=30>Math.abs(d-c);b.onLiveEdge=c;typeof b.liveResumePossible!==_.$c&&(b.liveResumePossible=
6
+ !0)}a.progress.eventNumber=this.f;a.timestamp=(new Date).toISOString();this.g.debug("Fire an event");b=_.Bj(this.l);b.method=_.sb;b.contentType="application/json";b.headers.Authorization=`Bearer ${this.h}`;b.body=_.oj(JSON.stringify(a));return this.j.fetch(b).V}lf(a){this.h=a}};var xx=class{constructor(a){this.m=a;this.a=new _.St;this.g=new _.S("clpp.vimond.VimondAdapter");this.f=this.h=!1;this.m&&this.a&&(this.g.debug(qx),this.a.on(this.m,_.If,this.o.bind(this)),this.a.on(this.m,_.jc,this.j.bind(this)),this.a.on(this.m,_.kc,this.l.bind(this)))}getPosition(){return Math.floor(this.m.getPosition())}o(){this.h=!0}j(){this.f=!0}l(){this.f=!1}};var yx=class extends _.Zv{constructor(){super();this.a=!1;this.g=new _.S(rx);this.j=this.h=this.f=null}onPlayerCreated(){}onContentWillLoad(a){var b=a.getConfiguration();(this.a=!_.B(b.vimond)&&typeof b.vimond===_.Se)?a.namespace()===_.ud&&(this.a=!1,this.g.info("Vimond does not report when casting.")):this.g.debug("Vimond plugin is loaded but not configured. Will do nothing.");if(this.a){b=a.getConfiguration().vimond;for(var c of["authToken","playerEventRequest"])if(!b[c]){this.g.warn(`${c} key is missing`);
7
+ a.onError(new _.I(1,9,9200));return}this.g.debug(_.ra);c=b.failIfUnreachable;typeof c!==_.$c&&(c=!0);var d=b.failOnError;typeof d!==_.$c&&(d=!0);this.f=new xx(a);this.h=new wx(b.playerEventRequest.uri,b.authToken,b.playerEventRequest.body,this.f,a.getNetworkEngine());this.j=new vx(b.playerEventRequest.eventInterval,c,d,a,this.h)}}onPlayerWillRelease(){if(this.a){if(this.f){var a=this.f;a.g.debug(_.Pb);_.Th(a.a)}this.j&&(a=this.j,a.g.debug(_.Pb),_.Th(a.a),a.h.stop());this.j=this.h=this.f=null}}onPlayerWillDestroy(){}id(){return"vimond"}lf(a){this.a&&
8
+ this.h&&this.h.lf(a)}};_.z(rx,yx);yx.prototype.updateAuthToken=yx.prototype.lf;yx.Id="vimond";_.Nr(new class{create(){return new yx}});};f.call(g, window);