@castlabs/prestoplay 6.32.0 → 6.33.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/cjs/cl.adobe.js +3 -3
  3. package/cjs/cl.airplay.js +3 -3
  4. package/cjs/cl.broadpeak.js +19 -19
  5. package/cjs/cl.cast.js +129 -127
  6. package/cjs/cl.conviva.js +32 -32
  7. package/cjs/cl.core.js +620 -625
  8. package/cjs/cl.crypto.js +9 -9
  9. package/cjs/cl.dash.js +101 -101
  10. package/cjs/cl.externs.js +45 -41
  11. package/cjs/cl.freewheel.js +25 -25
  12. package/cjs/cl.hls.js +76 -76
  13. package/cjs/cl.hlssmpte.js +6 -6
  14. package/cjs/cl.htmlcue.js +30 -30
  15. package/cjs/cl.ima.js +26 -26
  16. package/cjs/cl.mediatailor.js +3 -3
  17. package/cjs/cl.mse.js +359 -352
  18. package/cjs/cl.muxdata.js +14 -14
  19. package/cjs/cl.onboard.js +4 -4
  20. package/cjs/cl.persistent.js +14 -14
  21. package/cjs/cl.playlist.js +6 -6
  22. package/cjs/cl.simid.js +16 -16
  23. package/cjs/cl.smooth.js +71 -71
  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 +35 -35
  33. package/cl.adobe.js +3 -3
  34. package/cl.airplay.js +3 -3
  35. package/cl.broadpeak.js +14 -14
  36. package/cl.cast.js +101 -102
  37. package/cl.conviva.js +27 -27
  38. package/cl.core.js +497 -503
  39. package/cl.crypto.js +9 -9
  40. package/cl.dash.js +89 -89
  41. package/cl.externs.js +50 -42
  42. package/cl.freewheel.js +20 -20
  43. package/cl.hls.js +82 -82
  44. package/cl.hlssmpte.js +5 -5
  45. package/cl.htmlcue.js +26 -26
  46. package/cl.ima.js +20 -20
  47. package/cl.mediatailor.js +2 -2
  48. package/cl.mse.js +305 -303
  49. package/cl.muxdata.js +13 -13
  50. package/cl.onboard.js +5 -4
  51. package/cl.persistent.js +11 -11
  52. package/cl.playlist.js +5 -5
  53. package/cl.simid.js +14 -14
  54. package/cl.smooth.js +61 -61
  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 +30 -30
  64. package/package.json +1 -1
  65. package/typings.d.ts +32 -24
package/cl.htmlcue.js CHANGED
@@ -1,26 +1,26 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var LS="Unsupported unit",MS="clpp-text-plain",NS="clpp-text-ttml",OS="clpp.htmlcue.HtmlTextDisplayer",PS="initial",QS=function(a,b){let c=0,d=a.length-1;for(;c<=d;){const e=c+d>>1,f=b(a[e]);if(0===f)return e;0<f?c=e+1:d=e-1}return-1},RS=function(a){return _.ci(a,{ig:(b,c)=>b.Zc(c)})},SS=function(a,b){if(0===b.length)return a;let c=a;a=a.findIndex(d=>d.startTime>=b[0].startTime);0<=a&&(c=c.slice(0,a));return c.concat(b)},TS=function(a){if(!a.input)return null;var b=a.input.match(/^([^<]*)(<[^>]+>?)?/);
2
- b=b[1]?b[1]:b[2];a.input=a.input.substr(b.length);return b},VS=function(a){let b=null;for(;b=a.match(/&(amp|lt|gt|lrm|rlm|nbsp);/);)a=a.replace(b[0],c=>US[c]);return a},XS=function(a,b){WS(a,b);Array.from(b.getElementsByTagName("*")).forEach(c=>{WS(a,c)})},WS=function(a,b){for(const c in a)null!=a[c]&&(b.style[c]=a[c])},YS=function(a,b){return 0===a?"0":a+b},ZS=function(a,b){return 1>Math.abs(a-b)||a<b},$S=function(a,b){return a<b&&1<Math.abs(a-b)},aT=function(a,b){return a>b&&1<Math.abs(a-b)},bT=
3
- function(a,b){return 1>Math.abs(a-b)||a>b},dT=function(a){const b=a.getBoundingClientRect();var c=getComputedStyle(a,null);const d=parseFloat(c.getPropertyValue("border-left-width"))||0,e=parseFloat(c.getPropertyValue("border-right-width"))||0;var f=parseFloat(c.getPropertyValue("border-top-width"))||0;c=parseFloat(c.getPropertyValue("border-bottom-width"))||0;const g=(b.top||a.offsetTop)+f;f=(b.height||a.offsetHeight)-f-c;return new cT(b.left+d,b.right+e,g,(b.bottom||g+f)+c,f,(b.width||a.offsetWidth)-
4
- d-e)},eT=function(a){return new cT(a.left,a.f,a.top,a.a,a.height,a.width)},fT=function(a,b){return b.some(c=>$S(a.left,c.f)&&aT(a.f,c.left)&&$S(a.top,c.a)&&aT(a.a,c.top))},gT=function(a,b){return bT(a.top,b.top)&&ZS(a.a,b.a)&&bT(a.left,b.left)&&ZS(a.f,b.f)},hT=function(a,b,c){switch(c){case "+x":return $S(a.left,b.left);case "-x":return aT(a.f,b.f);case "+y":return $S(a.top,b.top);case "-y":return aT(a.a,b.a);default:throw Error("Unknown axis");}},iT=function(a){return a.f.writingMode===_.qu},jT=
5
- function(a){var b=a.a.childNodes[0],c=a.a.getBoundingClientRect();const d=b.getClientRects();b=c.height/d.length;c=c.width/d.length;return iT(a)?b:c},kT=function(a){switch(a.f.writingMode){case _.qu:return"horizontal-tb";case _.xg:return _.xg;case _.yg:return _.yg;default:throw Error("Unknown writing mode");}},lT=function(a){switch(a.f.positionAlign){case _.ne:return _.ke;case "auto":case _.Yc:return _.pu;case _.oe:return _.Cf}return a.f.textAlign},mT=function(a,b){if(typeof a.f.position===_.r&&typeof a.f.size===
6
- _.r)switch(b){case _.ne:return a.f.position;case "auto":case _.Yc:return a.f.position-a.f.size/2;case _.oe:return a.f.position-a.f.size}return 0},nT=function(a){if(!a.f.positionAlign)switch(a.f.textAlign){case _.Qf:case _.ke:return _.ne;case _.pu:return _.Yc;case _.Wd:case _.Cf:return _.oe}return a.f.positionAlign},qT=function(a,b,c){return(oT(a)||pT(a))&&_.lh(c)?YS(c,_.vf):oT(a)&&_.z(c)?YS(0,_.vf):iT(a)&&_.lh(b)?YS(b,"%"):PS},rT=function(a,b,c){return iT(a)&&_.lh(c)?YS(c,_.vf):(oT(a)||pT(a))&&_.lh(b)?
7
- YS(b,"%"):PS},pT=function(a){return a.f.writingMode===_.yg},oT=function(a){return a.f.writingMode===_.xg},sT=function(a,b){if(a.j)switch(b.writingMode){case _.qu:return["-y"];case _.xg:return["+x"];case _.yg:return["-x"]}a=[];switch(b.writingMode){case _.qu:a=["+y","-y"];break;case _.xg:a=["+x","-x"];break;case _.yg:a=["-x","+x"]}0>b.line&&(a=a.reverse());return a},tT=function(a){for(a.h=[];0<a.f.childNodes.length;)a.f.removeChild(a.f.childNodes[0]);a.a=dT(a.l.a)},uT=function(a,b,c){a=a.f;const d=
8
- a.viewportAnchorUnits;if(d===_.xu)return a.viewportAnchorY/100*c-a.regionAnchorY/100*b;if(0===d)return a.viewportAnchorY-a.regionAnchorY;throw Error(LS);},wT=function(a,b,c,d){const e=document.createElement(_.Wf),f=e.dataset;f.name=b;f.for=c;d&&(f.name=`${b} (sandbox)`,f.sandbox=!0);c=document.head;c.appendChild(e);vT(a,c,b);a.g.debug(`Created HTML style element #${b}.`);return e.sheet},xT=function(a,b){a=`.${a.j} .clpp-text-container`;const c=`${a} .clpp-text-cue`;return b=b.replace(/::cue\((#[^)]+)\)/g,
9
- `${a} $1`).replace(/::cue\(([^)]+)\)/g,`${c} $1`).replace(/::cue-region\(([^)]+)\)/g,`${a} $1 .clpp-text-cue`).replace(/::cue/g,c).replace(/::cue-region/g,`${a} .clpp-text-cue-region .clpp-text-cue`).replace(/::ttml/g,a)},yT=function(a,b){let c=!1;try{a.f.insertRule(b,0);const d=a.f.cssRules[0];d instanceof CSSStyleRule&&(c=d.selectorText.split(",").every(e=>0===e.trim().indexOf(`.${a.j} `)))}catch(d){}0<a.f.cssRules.length&&a.f.deleteRule(0);return c},zT=function(a){if(null!=a.a){for(;0<a.a.cssRules.length;)a.a.deleteRule(0);
10
- a.o=[]}},vT=function(a,b,c){const d=new MutationObserver(e=>{e.forEach(f=>{f.removedNodes.forEach(g=>{g.id===c&&a.g.error(`PRESTOplay HTML style element #${c} has `+"been unexpectedly removed! Some styles will not work!")})})});d.observe(b,{subtree:!1,childList:!0});a.l.push(()=>d.disconnect())},AT=function(a){a=_.eh(a.htmlcue||{});_.z(a.stretchSmpteImage)&&(a.stretchSmpteImage=!1);_.z(a.enableResizeObserver)&&(a.enableResizeObserver=!0);return a},GT=function(a,b){if((b||a.l)&&a.F){var c=a.m.getPosition();
11
- if(b||a.J!==c&&3===a.m.getState())if(a.J=c,c=BT(a,c),b||(b=a.o,b=!(null===b&&null===c||null!==b&&null!==c&&b.start===c.start&&b.end===c.end)),b&&(a.o=c,CT(a),c)){b={color:a.getFontColor()||void 0,backgroundColor:a.getBackgroundColor()||void 0,fontFamily:a.getFontFamily()||void 0,textShadow:_.Gt(a)||void 0};c=a.f.slice(c.start,c.end+1);for(const k of c){c=a;var d=k,e=b,f=c.a.a,g=null;switch(d.payloadType){case _.Fg:g="clpp-text-vtt";break;case _.jg:g=NS;break;case _.ou:g=MS}g&&!f.classList.contains(g)&&
12
- _.Ci(f,g);f=dT(c.a.a);if(0===f.width||0===f.height)c.g.warn("The height or width of the `.clpp-text-container` element is zero. Captions will not be displayed. Please check if the `clpp.styles.css` file has been included.");else{WS({fontSize:DT(c,d.containerRows)},c.a.a);f=null;g=d.payloadType===_.Fg;var h=d.payloadType===_.jg;d.region&&(g||h||d.backgroundImage)&&(c.B.has(d.region.id)?f=c.B.get(d.region.id):(f=new ET(d.region,{}),c.B.set(d.region.id,f),c.a.appendChild(f)));d=new FT(d,c.L,e);f?f.appendChild(d):
13
- c.a.appendChild(d)}}}}},HT=function(a){CT(a);a.J=null;a.o=null;a.f=[]},IT=function(a,b){return a.startTime<=b&&a.endTime>b},BT=function(a,b){var c=QS(a.f,d=>IT(d,b)?0:b!==d.startTime?b-d.startTime:b-d.endTime);if(-1===c)return null;{let d=c;for(;0<=d-1&&IT(a.f[d-1],b);)d--;for(;c+1<a.f.length&&IT(a.f[c+1],b);)c++;return{start:d,end:c}}},CT=function(a){a.B.clear();if(a.a){const b=a.a.a;b.classList.remove("clpp-text-vtt");b.classList.remove(NS);b.classList.remove(MS);a=a.a;tT(a.h);a.l=[]}},DT=function(a,
14
- b){const c=dT(a.a.a).height;if(null!==a.I)return a.getFontSize();if(null!==a.C)return a=a.getFontSizePercent(),`${Math.round(c*a)}px`;if(typeof b===_.r&&0<b)return`${Math.round(c/b)}px`;a=a.getFontSizePercent();return`${Math.round(c*a)}px`},MT=class{parse(a){a={input:a};const b=_.Ei(_.Gd),c=[];let d=b;for(var e;null!==(e=TS(a));)if("\x3c"===e[0])if("/"===e[1])c.length&&c[c.length-1]===e.substr(2).replace("\x3e","")&&(c.pop(),d=d.parentNode);else{if(e=e.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/)){var f=
15
- e[1];var g=e[3];var h=JT[f];h?(h=_.Ei(h),(f=KT[f])&&g&&h.setAttribute(f,g.trim()),g=h):g=null;!g||LT[g.localName]&&LT[g.localName]!==d.localName||(e[2]&&(g.className=e[2].substr(1).replace(/\./g," ")),c.push(e[1]),d.appendChild(g),d=g)}}else d.appendChild(document.createTextNode(VS(e)));return b}},JT={c:"c",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"v",lang:"lang"},KT={v:"voice",lang:"lang"},LT={rt:"ruby"},US={"\x26amp;":"\x26","\x26lt;":"\x3c","\x26gt;":"\x3e","\x26lrm;":"\u200e","\x26rlm;":"\u200f",
16
- "\x26nbsp;":"\u00a0"};var cT=class{constructor(a,b,c,d,e,f){this.left=a;this.f=b;this.top=c;this.a=d;this.height=e;this.width=f}};var NT=class{constructor(a,b,c){this.id=a;this.w=b;this.B=c;this.a=this.o();this.j=!1}init(){this.j=!0}A(){return!1}};var FT=class extends NT{constructor(a,b,c){super(a.id,"clpp-text-cue",{});this.l=b;this.f=a;this.h=!!this.f.backgroundImage;this.C=c}A(){return!this.h&&!(this.f.region&&this.f.region.displayAlign)}init(a){super.init(a);if(this.h)_.Ci(this.a,"clpp-text-cue-image"),this.a.style.backgroundImage=`url("${this.f.backgroundImage}")`,this.l.stretchSmpteImage&&(this.a.style.backgroundSize="contain");else if(a){var b=this.f;if(b.payloadType===_.jg){var c=_.Ei(_.Gd);c.innerHTML=b.payload;b=c}else b.payloadType===
17
- _.Fg?b=(new MT).parse(b.payload):(c=_.Ei(_.Gd),c.textContent=b.payload,b=c);_.Ci(b,this.w);this.id&&(b.id=this.id);for(d of this.f.cssClassList)_.Ci(b,d);WS({writingMode:kT(this)},b);var d=b;this.a.appendChild(d);_.Ci(this.a,"clpp-text-wrapper");for(var e of this.f.cssClassList)_.Ci(this.a,`clpp-text-wrapper__${e}`);_.z(this.f.line)&&(this.f.lineInterpretation=_.ru,this.f.line=iT(this)?-1:0);e=kT(this);WS({writingMode:e,webkitWritingMode:e,direction:PS,textAlign:lT(this)},this.a);if(!this.f.region||
18
- !this.f.region.displayAlign){e=mT(this,nT(this));WS({position:"absolute",left:qT(this,e,null),right:pT(this)&&_.z(null)?YS(0,_.vf):PS,top:rT(this,e,null),width:iT(this)?YS(this.f.size,"%"):PS,height:oT(this)||pT(this)?YS(this.f.size,"%"):PS},this.a);b=this.f;a=iT(this)?a.height:a.width;c=jT(this);if(b.lineInterpretation===_.ru){var f=c*Math.round(b.line);Math.abs(f)>a&&(f=c*(0>b.line?0:-1));0>f&&(f+=a)}else{f=c/a*100;let g=b.line;switch(b.lineAlign){case _.Yc:g-=f/2;break;case _.Wd:g-=f}f=Math.round(g/
19
- 100*a)}pT(this)&&(f=a-f-c);a=f;WS({left:qT(this,e,a),right:pT(this)&&_.z(a)?YS(0,_.vf):PS,top:rT(this,e,a)},this.a)}XS(this.C,d)}}o(){return _.Ei(_.Gd)}};var OT=class{constructor(a,b){this.l=a;this.f=a.a;this.j=void 0===b?!1:b;this.a=dT(a.a);this.h=[]}append(a){const b=a.a;b.style.visibility=_.de;this.f.appendChild(b);a.j||a.init(this.a);if(a.A()){a:{var c=dT(a.a);var d=sT(this,a.f),e=jT(a);const g=eT(c);let h=null,k=0;for(const l of d){for(;hT(c,this.a,l)||gT(c,this.a)&&fT(c,this.h);){d=c;var f=e;switch(l){case "+x":d.left+=f;d.f+=f;break;case "-x":d.left-=f;d.f-=f;break;case "+y":d.top+=f;d.a+=f;break;case "-y":d.top-=f,d.a-=f}}if(this.j||gT(c,this.a))break a;
20
- d=this.a;d=Math.max(0,Math.min(c.f,d.f)-Math.max(c.left,d.left))*Math.max(0,Math.min(c.a,d.a)-Math.max(c.top,d.top))/(c.height*c.width);d>k&&(h=eT(c),k=d);c=eT(g)}c=h||g}WS({top:YS(c.top-this.a.top,_.vf),bottom:YS(this.a.a-c.a,_.vf),left:YS(c.left-this.a.left,_.vf),right:YS(this.a.f-c.f,_.vf),height:YS(c.height,_.vf),width:YS(c.width,_.vf)},a.a)}b.style.visibility="visible";this.h.push(dT(a.a))}};var PT=class extends NT{constructor(a,b,c){super(a,b,c);this.h=null;this.l=[]}init(){this.h=new OT(this);this.j=!0}o(){const a=_.Ei(_.Gd);_.Ci(a,this.w);this.id&&(a.id=this.id);return a}appendChild(a){tT(this.h);this.l.unshift(a);for(const b of this.l)this.h.append(b)}};var ET=class extends PT{constructor(a,b){super(a.id,"clpp-text-cue-region",b);this.f=a}init(a){a:{var b=this.f;switch(b.widthUnits){case 0:b=b.width;break a;case _.xu:b=b.width/100*a.width;break a;default:throw Error(LS);}}var c=this.f;var d=c.viewportAnchorUnits;if(d===_.xu)c=c.viewportAnchorX/100*a.width-c.regionAnchorX/100*b;else if(0===d)c=c.viewportAnchorX-c.regionAnchorX;else throw Error(LS);d=a.height;const e=uT(this,d,a.height);WS(this.B,this.a);WS({left:YS(c,_.vf),top:YS(e,_.vf),width:YS(b,
21
- _.vf),height:YS(d,_.vf)},this.a);this.f.writingMode&&WS({display:"flex","flex-direction":this.f.writingMode},this.a);this.f.displayAlign&&WS({"justify-content":this.f.displayAlign},this.a);for(var f of this.f.cssClassList)_.Ci(this.a,f);a:switch(f=this.f,f.heightUnits){case 0:f=f.height;break a;case _.xu:f=f.height/100*a.height;break a;case 2:f=f.height;c=new FT(new _.uu(0,1,"Lorem ipsum",_.ou),{},{});b=c.a;this.a.appendChild(b);c.init(dT(this.a));c=b.getBoundingClientRect().height;this.a.removeChild(b);
22
- b=c;f*=b;break a;default:throw Error(LS);}a=uT(this,f,a.height);WS({top:YS(a,_.vf),height:YS(f,_.vf)},this.a);this.h=new OT(this,!0);this.j=!0}getId(){return this.f.id}};var QT=class{constructor(a,b){this.g=new _.T("clpp.htmlcue.StyleManager");this.l=[];this.j=a;this.h=b;this.o=[];this.a=wT(this,this.h,this.j);this.f=wT(this,this.h,this.j,!0);this.f.disabled=!0;this.g.debug(`Stylesheet ${this.h} has been created.`)}appendRule(a){if(null!=this.a&&!this.o.some(b=>b===a)){const b=xT(this,a);if(yT(this,b)){try{this.a.insertRule(b,this.a.cssRules.length),this.g.debug(`Added CSS rule ${b}`)}catch(c){this.g.error(`An error occurred when adding a CSS rule: ${b}`)}this.o.push(a)}else this.g.warn(`Stylesheet ${this.h} ignoring the CSS rule `+
23
- `because it's not safe: ${b}`)}}destroy(){const a=this;return _.w(function*(){null!=a.a&&(a.l.forEach(b=>b()),a.l=[],zT(a),document.head.removeChild(a.a.ownerNode),document.head.removeChild(a.f.ownerNode),a.a=null,a.f=null,a.g.debug(`Stylesheet ${a.h} has been destroyed.`))})}};var RT=class extends _.Mv{constructor(a){super(a);this.g=new _.T(OS);this.m=a;this.L=AT(a.getConfiguration());this.l=!1;this.f=[];this.F=a.getSurface().getContainer();this.j=new QT(a.getSurface().getUniqueCssClass(),"CLPP Subtitle Styles");this.a=new PT(null,"clpp-text-container",{});this.A=new _.Iv(a.getSurface(),this.S.bind(this));this.J=null;this.F?(this.F.appendChild(this.a.a),this.a.init(null)):this.g.warn("No container element! Subtitles will not appear. Please check your player surface configuration or switch to NativeTextDisplayer.");
24
- this.G=new _.Li(()=>{GT(this)});this.B=new Map;this.o=null}append(a,b){if(null!=this.j&&0!==a.length){for(const c of b)this.j.appendRule(c);a.sort((c,d)=>c.startTime!==d.startTime?c.startTime-d.startTime:c.endTime-d.endTime);this.f=SS(this.f,RS(a));this.o=null;GT(this,!1)}}h(){null==this.j||GT(this,!0)}destroy(){const a=this;return _.w(function*(){null!=a.j&&(HT(a),a.G.stop(),yield a.j.destroy(),a.j=null,a.F.removeChild(a.a.a),a.a=null,a.A.stop(),a.A=null,a.l=!1)})}remove(a,b){if(null==this.j)return!1;
25
- this.f=this.f.filter(c=>c.startTime<a||c.endTime>=b);this.o=null;GT(this,!0);return!0}isTextVisible(){return this.l}setTextVisibility(a){null!=this.j&&this.l!==a&&((this.l=a)?(this.G.Hb(.25),this.L.enableResizeObserver&&this.A.start(),GT(this,!0)):(this.G.stop(),this.A.stop(),HT(this)))}S(){GT(this,!0)}};_.x(OS,RT);RT.prototype.setTextVisibility=RT.prototype.setTextVisibility;RT.prototype.isTextVisible=RT.prototype.isTextVisible;RT.prototype.remove=RT.prototype.remove;RT.prototype.destroy=RT.prototype.destroy;
26
- RT.prototype.append=RT.prototype.append;var ST=class{a(a){return!!a.enableHtmlCue&&!_.$i()}create(a){return new RT(a)}};_.x("clpp.htmlcue.HtmlCueComponent",class extends _.Ev{install(){_.ms(_.fe,new ST)}uninstall(){_.ks.has(_.fe)&&(_.ks.delete(_.fe),_.ls.info("Removed factory: 'html'"))}id(){return _.Xf}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var CS="Unsupported unit",DS="clpp-text-plain",ES="clpp-text-ttml",FS="clpp.htmlcue.HtmlTextDisplayer",GS="initial",HS=function(a,b){let c=0,d=a.length-1;for(;c<=d;){const e=c+d>>1,f=b(a[e]);if(0===f)return e;0<f?c=e+1:d=e-1}return-1},IS=function(a){return _.Yh(a,{eg:(b,c)=>b.Xc(c)})},JS=function(a,b){if(0===b.length)return a;let c=a;a=a.findIndex(d=>d.startTime>=b[0].startTime);0<=a&&(c=c.slice(0,a));return c.concat(b)},KS=function(a){if(!a.input)return null;var b=a.input.match(/^([^<]*)(<[^>]+>?)?/);
2
+ b=b[1]?b[1]:b[2];a.input=a.input.substr(b.length);return b},MS=function(a){let b=null;for(;b=a.match(/&(amp|lt|gt|lrm|rlm|nbsp);/);)a=a.replace(b[0],c=>LS[c]);return a},OS=function(a,b){NS(a,b);Array.from(b.getElementsByTagName("*")).forEach(c=>{NS(a,c)})},NS=function(a,b){for(const c in a)null!=a[c]&&(b.style[c]=a[c])},PS=function(a,b){return 0===a?"0":a+b},QS=function(a,b){return 1>Math.abs(a-b)||a<b},RS=function(a,b){return a<b&&1<Math.abs(a-b)},SS=function(a,b){return a>b&&1<Math.abs(a-b)},TS=
3
+ function(a,b){return 1>Math.abs(a-b)||a>b},VS=function(a){const b=a.getBoundingClientRect();var c=getComputedStyle(a,null);const d=parseFloat(c.getPropertyValue("border-left-width"))||0,e=parseFloat(c.getPropertyValue("border-right-width"))||0;var f=parseFloat(c.getPropertyValue("border-top-width"))||0;c=parseFloat(c.getPropertyValue("border-bottom-width"))||0;const g=(b.top||a.offsetTop)+f;f=(b.height||a.offsetHeight)-f-c;return new US(b.left+d,b.right+e,g,(b.bottom||g+f)+c,f,(b.width||a.offsetWidth)-
4
+ d-e)},WS=function(a){return new US(a.left,a.f,a.top,a.a,a.height,a.width)},XS=function(a,b){return b.some(c=>RS(a.left,c.f)&&SS(a.f,c.left)&&RS(a.top,c.a)&&SS(a.a,c.top))},YS=function(a,b){return TS(a.top,b.top)&&QS(a.a,b.a)&&TS(a.left,b.left)&&QS(a.f,b.f)},ZS=function(a,b,c){switch(c){case "+x":return RS(a.left,b.left);case "-x":return SS(a.f,b.f);case "+y":return RS(a.top,b.top);case "-y":return SS(a.a,b.a);default:throw Error("Unknown axis");}},$S=function(a){return a.f.writingMode===_.du},aT=
5
+ function(a){var b=a.a.childNodes[0],c=a.a.getBoundingClientRect();const d=b.getClientRects();b=c.height/d.length;c=c.width/d.length;return $S(a)?b:c},bT=function(a){switch(a.f.writingMode){case _.du:return"horizontal-tb";case _.og:return _.og;case _.pg:return _.pg;default:throw Error("Unknown writing mode");}},cT=function(a){switch(a.f.positionAlign){case _.he:return _.ee;case "auto":case _.Wc:return _.cu;case _.ie:return _.wf}return a.f.textAlign},dT=function(a,b){if(typeof a.f.position===_.r&&typeof a.f.size===
6
+ _.r)switch(b){case _.he:return a.f.position;case "auto":case _.Wc:return a.f.position-a.f.size/2;case _.ie:return a.f.position-a.f.size}return 0},eT=function(a){if(!a.f.positionAlign)switch(a.f.textAlign){case _.Kf:case _.ee:return _.he;case _.cu:return _.Wc;case _.Qd:case _.wf:return _.ie}return a.f.positionAlign},hT=function(a,b,c){return(fT(a)||gT(a))&&_.fh(c)?PS(c,_.pf):fT(a)&&_.z(c)?PS(0,_.pf):$S(a)&&_.fh(b)?PS(b,"%"):GS},iT=function(a,b,c){return $S(a)&&_.fh(c)?PS(c,_.pf):(fT(a)||gT(a))&&_.fh(b)?
7
+ PS(b,"%"):GS},gT=function(a){return a.f.writingMode===_.pg},fT=function(a){return a.f.writingMode===_.og},jT=function(a,b){if(a.j)switch(b.writingMode){case _.du:return["-y"];case _.og:return["+x"];case _.pg:return["-x"]}a=[];switch(b.writingMode){case _.du:a=["+y","-y"];break;case _.og:a=["+x","-x"];break;case _.pg:a=["-x","+x"]}0>b.line&&(a=a.reverse());return a},kT=function(a){for(a.h=[];0<a.f.childNodes.length;)a.f.removeChild(a.f.childNodes[0]);a.a=VS(a.l.a)},lT=function(a,b,c){a=a.f;const d=
8
+ a.viewportAnchorUnits;if(d===_.ku)return a.viewportAnchorY/100*c-a.regionAnchorY/100*b;if(0===d)return a.viewportAnchorY-a.regionAnchorY;throw Error(CS);},nT=function(a,b,c,d){const e=document.createElement(_.Qf),f=e.dataset;f.name=b;f.for=c;d&&(f.name=`${b} (sandbox)`,f.sandbox=!0);c=document.head;c.appendChild(e);mT(a,c,b);a.g.debug(`Created HTML style element #${b}.`);return e.sheet},oT=function(a,b){a=`.${a.j} .clpp-text-container`;const c=`${a} .clpp-text-cue`;return b=b.replace(/::cue\((#[^)]+)\)/g,
9
+ `${a} $1`).replace(/::cue\(([^)]+)\)/g,`${c} $1`).replace(/::cue-region\(([^)]+)\)/g,`${a} $1 .clpp-text-cue`).replace(/::cue/g,c).replace(/::cue-region/g,`${a} .clpp-text-cue-region .clpp-text-cue`).replace(/::ttml/g,a)},pT=function(a,b){let c=!1;try{a.f.insertRule(b,0);const d=a.f.cssRules[0];d instanceof CSSStyleRule&&(c=d.selectorText.split(",").every(e=>0===e.trim().indexOf(`.${a.j} `)))}catch(d){}0<a.f.cssRules.length&&a.f.deleteRule(0);return c},qT=function(a){if(null!=a.a){for(;0<a.a.cssRules.length;)a.a.deleteRule(0);
10
+ a.o=[]}},mT=function(a,b,c){const d=new MutationObserver(e=>{e.forEach(f=>{f.removedNodes.forEach(g=>{g.id===c&&a.g.error(`PRESTOplay HTML style element #${c} has `+"been unexpectedly removed! Some styles will not work!")})})});d.observe(b,{subtree:!1,childList:!0});a.l.push(()=>d.disconnect())},rT=function(a){a=_.Zg(a.htmlcue||{});_.z(a.stretchSmpteImage)&&(a.stretchSmpteImage=!1);_.z(a.enableResizeObserver)&&(a.enableResizeObserver=!0);return a},xT=function(a,b){if((b||a.l)&&a.F){var c=a.m.getPosition();
11
+ if(b||a.J!==c&&3===a.m.getState())if(a.J=c,c=sT(a,c),b||(b=a.o,b=!(null===b&&null===c||null!==b&&null!==c&&b.start===c.start&&b.end===c.end)),b&&(a.o=c,tT(a),c)){b={color:a.getFontColor()||void 0,backgroundColor:a.getBackgroundColor()||void 0,fontFamily:a.getFontFamily()||void 0,textShadow:_.rt(a)||void 0};c=a.f.slice(c.start,c.end+1);for(const k of c){c=a;var d=k,e=b,f=c.a.a,g=null;switch(d.payloadType){case _.zg:g="clpp-text-vtt";break;case _.dg:g=ES;break;case _.bu:g=DS}g&&!f.classList.contains(g)&&
12
+ _.zi(f,g);f=VS(c.a.a);if(0===f.width||0===f.height)c.g.warn("The height or width of the `.clpp-text-container` element is zero. Captions will not be displayed. Please check if the `clpp.styles.css` file has been included.");else{NS({fontSize:uT(c,d.containerRows)},c.a.a);f=null;g=d.payloadType===_.zg;var h=d.payloadType===_.dg;d.region&&(g||h||d.backgroundImage)&&(c.B.has(d.region.id)?f=c.B.get(d.region.id):(f=new vT(d.region,{}),c.B.set(d.region.id,f),c.a.appendChild(f)));d=new wT(d,c.L,e);f?f.appendChild(d):
13
+ c.a.appendChild(d)}}}}},yT=function(a){tT(a);a.J=null;a.o=null;a.f=[]},zT=function(a,b){return a.startTime<=b&&a.endTime>b},sT=function(a,b){var c=HS(a.f,d=>zT(d,b)?0:b!==d.startTime?b-d.startTime:b-d.endTime);if(-1===c)return null;{let d=c;for(;0<=d-1&&zT(a.f[d-1],b);)d--;for(;c+1<a.f.length&&zT(a.f[c+1],b);)c++;return{start:d,end:c}}},tT=function(a){a.B.clear();if(a.a){const b=a.a.a;b.classList.remove("clpp-text-vtt");b.classList.remove(ES);b.classList.remove(DS);a=a.a;kT(a.h);a.l=[]}},uT=function(a,
14
+ b){const c=VS(a.a.a).height;if(null!==a.I)return a.getFontSize();if(null!==a.C)return a=a.getFontSizePercent(),`${Math.round(c*a)}px`;if(typeof b===_.r&&0<b)return`${Math.round(c/b)}px`;a=a.getFontSizePercent();return`${Math.round(c*a)}px`},DT=class{parse(a){a={input:a};const b=_.Bi(_.Ad),c=[];let d=b;for(var e;null!==(e=KS(a));)if("\x3c"===e[0])if("/"===e[1])c.length&&c[c.length-1]===e.substr(2).replace("\x3e","")&&(c.pop(),d=d.parentNode);else{if(e=e.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/)){var f=
15
+ e[1];var g=e[3];var h=AT[f];h?(h=_.Bi(h),(f=BT[f])&&g&&h.setAttribute(f,g.trim()),g=h):g=null;!g||CT[g.localName]&&CT[g.localName]!==d.localName||(e[2]&&(g.className=e[2].substr(1).replace(/\./g," ")),c.push(e[1]),d.appendChild(g),d=g)}}else d.appendChild(document.createTextNode(MS(e)));return b}},AT={c:"c",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"v",lang:"lang"},BT={v:"voice",lang:"lang"},CT={rt:"ruby"},LS={"\x26amp;":"\x26","\x26lt;":"\x3c","\x26gt;":"\x3e","\x26lrm;":"\u200e","\x26rlm;":"\u200f",
16
+ "\x26nbsp;":"\u00a0"};var US=class{constructor(a,b,c,d,e,f){this.left=a;this.f=b;this.top=c;this.a=d;this.height=e;this.width=f}};var ET=class{constructor(a,b,c){this.id=a;this.w=b;this.B=c;this.a=this.o();this.j=!1}init(){this.j=!0}A(){return!1}};var wT=class extends ET{constructor(a,b,c){super(a.id,"clpp-text-cue",{});this.l=b;this.f=a;this.h=!!this.f.backgroundImage;this.C=c}A(){return!this.h&&!(this.f.region&&this.f.region.displayAlign)}init(a){super.init(a);if(this.h)_.zi(this.a,"clpp-text-cue-image"),this.a.style.backgroundImage=`url("${this.f.backgroundImage}")`,this.l.stretchSmpteImage&&(this.a.style.backgroundSize="contain");else if(a){var b=this.f;if(b.payloadType===_.dg){var c=_.Bi(_.Ad);c.innerHTML=b.payload;b=c}else b.payloadType===
17
+ _.zg?b=(new DT).parse(b.payload):(c=_.Bi(_.Ad),c.textContent=b.payload,b=c);_.zi(b,this.w);this.id&&(b.id=this.id);for(d of this.f.cssClassList)_.zi(b,d);NS({writingMode:bT(this)},b);var d=b;this.a.appendChild(d);_.zi(this.a,"clpp-text-wrapper");for(var e of this.f.cssClassList)_.zi(this.a,`clpp-text-wrapper__${e}`);_.z(this.f.line)&&(this.f.lineInterpretation=_.eu,this.f.line=$S(this)?-1:0);e=bT(this);NS({writingMode:e,webkitWritingMode:e,direction:GS,textAlign:cT(this)},this.a);if(!this.f.region||
18
+ !this.f.region.displayAlign){e=dT(this,eT(this));NS({position:"absolute",left:hT(this,e,null),right:gT(this)&&_.z(null)?PS(0,_.pf):GS,top:iT(this,e,null),width:$S(this)?PS(this.f.size,"%"):GS,height:fT(this)||gT(this)?PS(this.f.size,"%"):GS},this.a);b=this.f;a=$S(this)?a.height:a.width;c=aT(this);if(b.lineInterpretation===_.eu){var f=c*Math.round(b.line);Math.abs(f)>a&&(f=c*(0>b.line?0:-1));0>f&&(f+=a)}else{f=c/a*100;let g=b.line;switch(b.lineAlign){case _.Wc:g-=f/2;break;case _.Qd:g-=f}f=Math.round(g/
19
+ 100*a)}gT(this)&&(f=a-f-c);a=f;NS({left:hT(this,e,a),right:gT(this)&&_.z(a)?PS(0,_.pf):GS,top:iT(this,e,a)},this.a)}OS(this.C,d)}}o(){return _.Bi(_.Ad)}};var FT=class{constructor(a,b){this.l=a;this.f=a.a;this.j=void 0===b?!1:b;this.a=VS(a.a);this.h=[]}append(a){const b=a.a;b.style.visibility=_.Yd;this.f.appendChild(b);a.j||a.init(this.a);if(a.A()){a:{var c=VS(a.a);var d=jT(this,a.f),e=aT(a);const g=WS(c);let h=null,k=0;for(const l of d){for(;ZS(c,this.a,l)||YS(c,this.a)&&XS(c,this.h);){d=c;var f=e;switch(l){case "+x":d.left+=f;d.f+=f;break;case "-x":d.left-=f;d.f-=f;break;case "+y":d.top+=f;d.a+=f;break;case "-y":d.top-=f,d.a-=f}}if(this.j||YS(c,this.a))break a;
20
+ d=this.a;d=Math.max(0,Math.min(c.f,d.f)-Math.max(c.left,d.left))*Math.max(0,Math.min(c.a,d.a)-Math.max(c.top,d.top))/(c.height*c.width);d>k&&(h=WS(c),k=d);c=WS(g)}c=h||g}NS({top:PS(c.top-this.a.top,_.pf),bottom:PS(this.a.a-c.a,_.pf),left:PS(c.left-this.a.left,_.pf),right:PS(this.a.f-c.f,_.pf),height:PS(c.height,_.pf),width:PS(c.width,_.pf)},a.a)}b.style.visibility="visible";this.h.push(VS(a.a))}};var GT=class extends ET{constructor(a,b,c){super(a,b,c);this.h=null;this.l=[]}init(){this.h=new FT(this);this.j=!0}o(){const a=_.Bi(_.Ad);_.zi(a,this.w);this.id&&(a.id=this.id);return a}appendChild(a){kT(this.h);this.l.unshift(a);for(const b of this.l)this.h.append(b)}};var vT=class extends GT{constructor(a,b){super(a.id,"clpp-text-cue-region",b);this.f=a}init(a){a:{var b=this.f;switch(b.widthUnits){case 0:b=b.width;break a;case _.ku:b=b.width/100*a.width;break a;default:throw Error(CS);}}var c=this.f;var d=c.viewportAnchorUnits;if(d===_.ku)c=c.viewportAnchorX/100*a.width-c.regionAnchorX/100*b;else if(0===d)c=c.viewportAnchorX-c.regionAnchorX;else throw Error(CS);d=a.height;const e=lT(this,d,a.height);NS(this.B,this.a);NS({left:PS(c,_.pf),top:PS(e,_.pf),width:PS(b,
21
+ _.pf),height:PS(d,_.pf)},this.a);this.f.writingMode&&NS({display:"flex","flex-direction":this.f.writingMode},this.a);this.f.displayAlign&&NS({"justify-content":this.f.displayAlign},this.a);for(var f of this.f.cssClassList)_.zi(this.a,f);a:switch(f=this.f,f.heightUnits){case 0:f=f.height;break a;case _.ku:f=f.height/100*a.height;break a;case 2:f=f.height;c=new wT(new _.hu(0,1,"Lorem ipsum",_.bu),{},{});b=c.a;this.a.appendChild(b);c.init(VS(this.a));c=b.getBoundingClientRect().height;this.a.removeChild(b);
22
+ b=c;f*=b;break a;default:throw Error(CS);}a=lT(this,f,a.height);NS({top:PS(a,_.pf),height:PS(f,_.pf)},this.a);this.h=new FT(this,!0);this.j=!0}getId(){return this.f.id}};var HT=class{constructor(a,b){this.g=new _.T("clpp.htmlcue.StyleManager");this.l=[];this.j=a;this.h=b;this.o=[];this.a=nT(this,this.h,this.j);this.f=nT(this,this.h,this.j,!0);this.f.disabled=!0;this.g.debug(`Stylesheet ${this.h} has been created.`)}appendRule(a){if(null!=this.a&&!this.o.some(b=>b===a)){const b=oT(this,a);if(pT(this,b)){try{this.a.insertRule(b,this.a.cssRules.length),this.g.debug(`Added CSS rule ${b}`)}catch(c){this.g.error(`An error occurred when adding a CSS rule: ${b}`)}this.o.push(a)}else this.g.warn(`Stylesheet ${this.h} ignoring the CSS rule `+
23
+ `because it's not safe: ${b}`)}}destroy(){const a=this;return _.v(function*(){null!=a.a&&(a.l.forEach(b=>b()),a.l=[],qT(a),document.head.removeChild(a.a.ownerNode),document.head.removeChild(a.f.ownerNode),a.a=null,a.f=null,a.g.debug(`Stylesheet ${a.h} has been destroyed.`))})}};var IT=class extends _.wv{constructor(a){super(a);this.g=new _.T(FS);this.m=a;this.L=rT(a.getConfiguration());this.l=!1;this.f=[];this.F=a.getSurface().getContainer();this.j=new HT(a.getSurface().getUniqueCssClass(),"CLPP Subtitle Styles");this.a=new GT(null,"clpp-text-container",{});this.A=new _.rv(a.getSurface(),this.S.bind(this));this.J=null;this.F?(this.F.appendChild(this.a.a),this.a.init(null)):this.g.warn("No container element! Subtitles will not appear. Please check your player surface configuration or switch to NativeTextDisplayer.");
24
+ this.G=new _.Ii(()=>{xT(this)});this.B=new Map;this.o=null}append(a,b){if(null!=this.j&&0!==a.length){for(const c of b)this.j.appendRule(c);a.sort((c,d)=>c.startTime!==d.startTime?c.startTime-d.startTime:c.endTime-d.endTime);this.f=JS(this.f,IS(a));this.o=null;xT(this,!1)}}h(){null==this.j||xT(this,!0)}destroy(){const a=this;return _.v(function*(){null!=a.j&&(yT(a),a.G.stop(),yield a.j.destroy(),a.j=null,a.F.removeChild(a.a.a),a.a=null,a.A.stop(),a.A=null,a.l=!1)})}remove(a,b){if(null==this.j)return!1;
25
+ this.f=this.f.filter(c=>c.startTime<a||c.endTime>=b);this.o=null;xT(this,!0);return!0}isTextVisible(){return this.l}setTextVisibility(a){null!=this.j&&this.l!==a&&((this.l=a)?(this.G.Gb(.25),this.L.enableResizeObserver&&this.A.start(),xT(this,!0)):(this.G.stop(),this.A.stop(),yT(this)))}S(){xT(this,!0)}};_.w(FS,IT);IT.prototype.setTextVisibility=IT.prototype.setTextVisibility;IT.prototype.isTextVisible=IT.prototype.isTextVisible;IT.prototype.remove=IT.prototype.remove;IT.prototype.destroy=IT.prototype.destroy;
26
+ IT.prototype.append=IT.prototype.append;var JT=class{a(a){return!!a.enableHtmlCue&&!_.Xi()}create(a){return new IT(a)}};_.w("clpp.htmlcue.HtmlCueComponent",class extends _.jv{install(){_.Qr(_.$d,new JT)}uninstall(){_.Or.has(_.$d)&&(_.Or.delete(_.$d),_.Pr.info("Removed factory: 'html'"))}id(){return _.Rf}});};f.call(g, window);
package/cl.ima.js CHANGED
@@ -1,20 +1,20 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var sS="clpp.ima.AdsManagerFactory",tS=function(){return!window.google||!google.ima||!google.ima.AdsLoader},uS=function(a){a=a.H;const b=new google.ima.AdsRenderingSettings;b.restoreCustomPlaybackStateOnAdBreakComplete=!1;typeof a.bitrate===_.r&&(b.bitrate=a.bitrate);b.enablePreloading=typeof a.enablePreloading===_.Oc?a.enablePreloading:!0;typeof a.loadVideoTimeout===_.r&&(b.loadVideoTimeout=a.loadVideoTimeout);Array.isArray(a.mimeTypes)&&(b.mimeTypes=a.mimeTypes);typeof a.playAdsAfterTime===
2
- _.r&&(b.playAdsAfterTime=a.playAdsAfterTime);typeof a.useStyledLinearAds===_.Oc&&(b.useStyledLinearAds=a.useStyledLinearAds);b.uiElements=Array.isArray(a.uiElements)?a.uiElements:[];return b},vS=function(a){const b=_.Pi()||_.Si()||_.$i();return!1===a.H.disableCustomPlayback&&b},wS=function(a){const b=a.a,c=a.S,d=google.ima.AdEvent.Type;c.on(b,d.AD_BREAK_READY,a.yc.bind(a));c.on(b,d.LOADED,a.lb.bind(a));c.on(b,d.CONTENT_PAUSE_REQUESTED,a.md.bind(a));c.on(b,d.STARTED,a.Tb.bind(a));c.on(b,d.LOG,a.Dc.bind(a));
3
- c.on(b,d.AD_PROGRESS,a.Ib.bind(a));c.on(b,d.AD_BUFFERING,a.Ac.bind(a));c.on(b,d.FIRST_QUARTILE,a.La.bind(a));c.on(b,d.MIDPOINT,a.Fc.bind(a));c.on(b,d.THIRD_QUARTILE,a.Ub.bind(a));c.on(b,d.PAUSED,a.Ic.bind(a));c.on(b,d.RESUMED,a.Jc.bind(a));c.on(b,d.CLICK,a.Aa.bind(a));c.on(b,d.SKIPPED,a.Jb.bind(a));c.on(b,d.IMPRESSION,a.bb.bind(a));c.on(b,d.COMPLETE,a.Bc.bind(a));c.on(b,d.CONTENT_RESUME_REQUESTED,a.od.bind(a))},xS=function(a,b){const c=b?a.xc.create(b.getErrorCode()):null;a.m.onError(new _.I(1,9,
4
- 10003,{errorType:c},b))},yS=function(a){return vS(a)&&a.a.isCustomPlaybackUsed()},zS=function(a,b,c){c=c&&c.getAd();let d=null;c&&(d={ad:new W(c,a.J,a.I)});a.m.trigger(new _.H(b,d))},BS=function(a){_.w(function*(){a.M=a.m.getPosition();yield AS(a,3);yield a.m.pause();yield a.m.detach();a.a.start()})},AS=function(a,b){return _.w(function*(){return new Promise((c,d)=>{const e=setTimeout(()=>{clearInterval(f);d(Error("Timeout waiting for player state"))},1E4),f=setInterval(()=>{a.m.getState()>=b&&(clearInterval(f),
5
- clearTimeout(e),c())},200)})})},CS=function(a){a.U=!1;a.G=null;zS(a,_.nc);a.m.getSurface().hide(a.da)},DS=function(a){_.Di(a.F,{visibility:"visible"})},FS=function(a){_.w(function*(){a.ia.initialize();const b=!!a.m.getConfiguration().muted;(yield a.X.canPlay(b))||yS(a)?ES(a):(zS(a,_.Mc),a.g.warn(_.ka))})},ES=function(a){a.a.init(a.F.offsetWidth,a.F.offsetHeight,google.ima.ViewMode.NORMAL);yS(a)?a.H.isVast&&BS(a):a.a.start();a.ca=!0},W=class{constructor(a,b,c){this.a=a;this.f=a.getAdPodInfo();this.j=
6
- b;this.h=c}cb(){return"Google IMA SDK"}eb(){return google.ima.VERSION}gb(){return 0}getId(){return this.a.getAdId()}getCreativeId(){return this.a.getCreativeId()}zb(){return""}getApiFramework(){return this.a.getApiFramework()}getAdSystem(){return this.a.getAdSystem()}getAdvertiserName(){return this.a.getAdvertiserName()}getTitle(){return this.a.getTitle()}getDuration(){return this.a.getDuration()}getPosition(){return 0}getSkipTimeOffset(){return this.a.getSkipTimeOffset()}Bb(){return this.f?this.f.getIsBumper():
7
- !1}Qa(){let a=null;const b=this.a,c=Object.keys(b).find(d=>typeof b[d]===_.Ie&&typeof b[d].clickThroughUrl===_.Uf);c&&(a=b[c].clickThroughUrl);return a}getMediaUrl(){return this.a.getMediaUrl()}Ua(){return this.a.getVastMediaWidth()}Ta(){return this.a.getVastMediaHeight()}Ba(){return this.a.getVastMediaBitrate()}Ca(){return this.h?2:this.j?1:0}getPodIndex(){return this.f?this.f.getPodIndex():0}pb(){return this.f?this.f.getTimeOffset():0}fb(){return this.f?this.f.getAdPosition():1}Va(){return this.f?
8
- this.f.getTotalAds():1}getWrapperAdIds(){return this.a.getWrapperAdIds()}canSeek(){return!1}getWrapperAdSystems(){return this.a.getWrapperAdSystems()}getWrapperCreativeIds(){return this.a.getWrapperCreativeIds()}Ab(){return null}};W.prototype.getVideoElement=W.prototype.Ab;W.prototype.getWrapperCreativeIds=W.prototype.getWrapperCreativeIds;W.prototype.getWrapperAdSystems=W.prototype.getWrapperAdSystems;W.prototype.canSeek=W.prototype.canSeek;W.prototype.getWrapperAdIds=W.prototype.getWrapperAdIds;
9
- W.prototype.getSequenceLength=W.prototype.Va;W.prototype.getPositionInSequence=W.prototype.fb;W.prototype.getPodTimeOffset=W.prototype.pb;W.prototype.getPodIndex=W.prototype.getPodIndex;W.prototype.getPodType=W.prototype.Ca;W.prototype.getMediaBitrate=W.prototype.Ba;W.prototype.getMediaHeight=W.prototype.Ta;W.prototype.getMediaWidth=W.prototype.Ua;W.prototype.getMediaUrl=W.prototype.getMediaUrl;W.prototype.getClickThroughUrl=W.prototype.Qa;W.prototype.isBumper=W.prototype.Bb;
10
- W.prototype.getSkipTimeOffset=W.prototype.getSkipTimeOffset;W.prototype.getPosition=W.prototype.getPosition;W.prototype.getDuration=W.prototype.getDuration;W.prototype.getTitle=W.prototype.getTitle;W.prototype.getAdvertiserName=W.prototype.getAdvertiserName;W.prototype.getAdSystem=W.prototype.getAdSystem;W.prototype.getApiFramework=W.prototype.getApiFramework;W.prototype.getSourceId=W.prototype.zb;W.prototype.getCreativeId=W.prototype.getCreativeId;W.prototype.getId=W.prototype.getId;
11
- W.prototype.getTechnology=W.prototype.gb;W.prototype.getAdManagerVersion=W.prototype.eb;W.prototype.getAdManagerName=W.prototype.cb;var GS=class{create(a){const b=google.ima.AdError.ErrorCode;switch(a){case b.VAST_LOAD_TIMEOUT:case b.VAST_MEDIA_LOAD_TIMEOUT:case b.FAILED_TO_REQUEST_ADS:return 0;case b.VIDEO_PLAY_ERROR:return 1;default:return 2}}};var HS=class{constructor(a){this.a=a}getCuePoints(){return this.a}Qb(){return 0<=this.a.indexOf(0)||0===this.a.length}Pb(){return 0<=this.a.indexOf(-1)}};HS.prototype.hasPostroll=HS.prototype.Pb;HS.prototype.hasPreroll=HS.prototype.Qb;HS.prototype.getCuePoints=HS.prototype.getCuePoints;var IS=class extends _.Uv{constructor(){super();this.a=this.h=this.f=null}onPlayerCreated(a){if(tS())return a.onError(new _.I(1,9,1E4));this.f=_.Bi(_.Gd,{"class":"clpp-ima clpp-hidden"});a.getSurface().addElementToContainer(this.f);this.h=new google.ima.AdDisplayContainer(this.f,a.getSurface().getMedia());this.a=new google.ima.AdsLoader(this.h);this.a.getSettings().setPlayerType(_.ra);this.a.getSettings().setPlayerVersion(_.ea);this.a.getSettings().setAutoPlayAdBreaks(!0)}onPlayerWillDestroy(a){this.a&&
12
- (this.a.destroy(),this.a=null);this.h&&(this.h.destroy(),this.h=null);this.f&&(a.getSurface().removeElementFromContainer(this.f),this.f=null)}Xh(){return this.a}Vh(){return this.h}$c(){return this.f}id(){return"ima"}};_.x("clpp.ima.ImaPlugin",IS);IS.prototype.getAdContainer=IS.prototype.$c;IS.prototype.getAdDisplayContainer=IS.prototype.Vh;IS.prototype.getAdsLoader=IS.prototype.Xh;IS.Id="ima";IS.isSdkMissing=tS;var JS=class{create(){return new IS}};var KS=class{constructor(a){var b=a.Gd("ima");if(!b)throw Error("IMA plugin not created.");var c=b.$c(),d=b.h;b=b.a;if(!c||!d||!b)throw Error("IMA plugin not initialized.");const e=a.getSurface().getMedia();if(!e)throw Error("Missing media element.");this.m=a;this.F=e;a=this.m.getConfiguration();a=_.eh(a.ima||{});this.H=a=_.dh({disableCustomPlayback:!1},a);this.da=c;this.ia=d;this.B=b;this.X=new _.Kv;this.g=new _.T("clpp.ima");this.a=null;this.W=!1;this.l=null;this.f=new _.Gl;this.ca=!1;this.S=new _.Qt;
13
- this.xc=new GS;this.G=null;this.C=this.U=!1;this.L=1;this.P=this.I=this.J=!1;this.M=this.R=null;this.K=!0;c=this.S;d=google.ima.AdErrorEvent.Type.AD_ERROR;c.one(this.B,google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,this.hd.bind(this));c.on(this.B,d,this.Lc.bind(this));c.on(this.m,_.Xd,this.jd.bind(this))}hd(a){this.a=a.getAdsManager(this.F,uS(this));this.a.isCustomPlaybackUsed()&&!vS(this)?(this.g.warn("IMA plugin is disabled for this platform with single video element. Disposing."),this.m.onError(new _.I(1,
14
- 9,10002)),this.o()):(this.setMuted(this.C),this.h(this.L),this.l=new _.Iv(this.m.getSurface(),(b,c,d)=>{this.a.resize(b,c,d?google.ima.ViewMode.FULLSCREEN:google.ima.ViewMode.NORMAL)}),a=this.a.getCuePoints(),this.R=new HS(a),this.m.trigger(new _.H(_.qc,{adsTimeline:this.R})),wS(this));this.f.resolve()}Lc(a){xS(this,a.getError());this.f.resolve()}md(a){this.P=!0;yS(this)||(this.m.pause(),_.Di(this.F,{visibility:_.de}));zS(this,_.Ub,a);this.l.start()}yc(){yS(this)?BS(this):this.a.start()}lb(a){a.getAd().isLinear()?
15
- zS(this,_.dc,a):(this.a.discardAdBreak(),this.J||(this.J=!0,this.m.play()))}Tb(a){this.U=!0;this.K=!1;this.G=a.getAd().getDuration();zS(this,_.mc,a);this.m.getSurface().show(this.da)}Dc(a){a=a.getAdData();xS(this,a?a.adError:null);CS(this)}Ib(a){zS(this,_.jc,a)}Ac(a){zS(this,_.Wb,a)}La(a){zS(this,_.Zb,a)}Fc(a){zS(this,_.ec,a)}Ub(a){zS(this,_.oc,a)}Ic(a){this.K=!0;zS(this,_.hc,a)}Jc(a){this.K=!1;zS(this,_.kc,a)}Aa(a){this.pause();zS(this,_.Xb,a)}Jb(a){zS(this,_.lc,a);CS(this)}bb(a){zS(this,_.cc,a)}Bc(a){zS(this,
16
- _.Yb,a);CS(this)}od(){const a=this;return _.w(function*(){a.J=!0;if(yS(a)&&null!==a.M){const c=a.m.getVolume(),d=a.m.isMuted();var b=a.m;b.a&&b.a.forwardEventsTo(b);b=a.m;b.f=_.dh(b.f,{volume:c,muted:d});yield _.jo(a.m);!a.I&&a.M&&(yield AS(a,2),yield a.m.play(),yield a.m.pause(),yield AS(a,4),yield a.m.setPosition(a.M))}else{if(!a.P)return a.m.play();DS(a)}a.P=!1;a.l&&a.l.stop();a.I||(yield a.m.play());zS(a,_.Vb)})}jd(){this.I=!0;this.B.contentComplete()}load(){const a=this;return _.w(function*(){var b=
17
- a.m;const c=a.H;try{if(typeof c.adTagUrl!==_.Uf)throw new _.I(1,9,10001,{missingKeys:"adTagUrl"});}catch(f){return b.onError(f),a.f.resolve(),a.f}if(!c.adTagUrl)return a.f.resolve(),a.f;b=yield a.X.canPlay(!1);const d=yield a.X.canPlay(!0),e=new google.ima.AdsRequest;e.adTagUrl=c.adTagUrl;e.setAdWillAutoPlay(b);e.setAdWillPlayMuted(d);a.B.getSettings().setAutoPlayAdBreaks(!1);a.B.requestAds(e);return a.f})}j(){if(this.W||!this.a||this.W)return!0;if(!this.ca){if(this.R.Qb())return FS(this),!1;this.ia.initialize();
18
- ES(this);return!0}return this.qb()&&this.a?(this.a.resume(),!1):!0}A(){}w(){return!0}ib(){this.a&&this.a.pause()}isPaused(){return this.K}skip(){this.a&&this.a.skip()}getAdVolume(){return this.a?this.C?this.L:this.a.getVolume():1}h(a){this.L=a;this.a&&(this.C||this.a.setVolume(a))}setVolume(a){this.h(a)}getVolume(){return this.getAdVolume()}pause(){this.ib()}resume(){this.j()}setMuted(a){this.C=a;this.a&&(a?this.a.setVolume(0):this.a.setVolume(this.L))}isMuted(){return this.C}qb(){return this.U}getPosition(){if(!this.a||
19
- null===this.G)return-1;const a=this.a.getRemainingTime();return 0>a?0:this.G-a}o(){this.a&&(this.a.destroy(),this.a=null);this.W=!0;DS(this);this.S.release();this.l&&(this.l.stop(),this.l=null);return Promise.resolve()}};KS.prototype.getPosition=KS.prototype.getPosition;KS.prototype.resume=KS.prototype.resume;KS.prototype.pause=KS.prototype.pause;KS.prototype.getVolume=KS.prototype.getVolume;KS.prototype.setVolume=KS.prototype.setVolume;KS.prototype.getAdVolume=KS.prototype.getAdVolume;
20
- KS.prototype.skip=KS.prototype.skip;KS.prototype.pauseAd=KS.prototype.ib;_.Gh(new class{constructor(){this.Xa=new _.T(sS)}name(){return sS}a(a,b){return a.namespace()===_.id?!1:tS()?(this.Xa.warn("IMA SDK is not loaded."),!1):!(!b||!b.ima)}create(a){return new KS(a)}});_.Pn(new JS);};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var jS="clpp.ima.AdsManagerFactory",kS=function(){return!window.google||!google.ima||!google.ima.AdsLoader},lS=function(a){a=a.H;const b=new google.ima.AdsRenderingSettings;b.restoreCustomPlaybackStateOnAdBreakComplete=!1;typeof a.bitrate===_.r&&(b.bitrate=a.bitrate);b.enablePreloading=typeof a.enablePreloading===_.Mc?a.enablePreloading:!0;typeof a.loadVideoTimeout===_.r&&(b.loadVideoTimeout=a.loadVideoTimeout);Array.isArray(a.mimeTypes)&&(b.mimeTypes=a.mimeTypes);typeof a.playAdsAfterTime===
2
+ _.r&&(b.playAdsAfterTime=a.playAdsAfterTime);typeof a.useStyledLinearAds===_.Mc&&(b.useStyledLinearAds=a.useStyledLinearAds);b.uiElements=Array.isArray(a.uiElements)?a.uiElements:[];return b},mS=function(a){const b=_.Mi()||_.Pi()||_.Xi();return!1===a.H.disableCustomPlayback&&b},nS=function(a){const b=a.a,c=a.S,d=google.ima.AdEvent.Type;c.on(b,d.AD_BREAK_READY,a.wc.bind(a));c.on(b,d.LOADED,a.lb.bind(a));c.on(b,d.CONTENT_PAUSE_REQUESTED,a.kd.bind(a));c.on(b,d.STARTED,a.Hb.bind(a));c.on(b,d.LOG,a.Bc.bind(a));
3
+ c.on(b,d.AD_PROGRESS,a.Ib.bind(a));c.on(b,d.AD_BUFFERING,a.yc.bind(a));c.on(b,d.FIRST_QUARTILE,a.ab.bind(a));c.on(b,d.MIDPOINT,a.Dc.bind(a));c.on(b,d.THIRD_QUARTILE,a.Ub.bind(a));c.on(b,d.PAUSED,a.Gc.bind(a));c.on(b,d.RESUMED,a.Hc.bind(a));c.on(b,d.CLICK,a.Aa.bind(a));c.on(b,d.SKIPPED,a.Jb.bind(a));c.on(b,d.IMPRESSION,a.bb.bind(a));c.on(b,d.COMPLETE,a.zc.bind(a));c.on(b,d.CONTENT_RESUME_REQUESTED,a.md.bind(a))},oS=function(a,b){const c=b?a.vc.create(b.getErrorCode()):null;a.m.onError(new _.I(1,9,
4
+ 10003,{errorType:c},b))},pS=function(a){return mS(a)&&a.a.isCustomPlaybackUsed()},qS=function(a,b,c){c=c&&c.getAd();let d=null;c&&(d={ad:new W(c,a.J,a.I)});a.m.trigger(new _.H(b,d))},sS=function(a){_.v(function*(){a.M=a.m.getPosition();yield rS(a,[3,4,5]);yield a.m.pause();yield a.m.detach();a.a.start()})},rS=function(a,b){return _.v(function*(){return new Promise((c,d)=>{const e=setTimeout(()=>{clearInterval(f);d(Error("Timeout waiting for player state"))},1E4),f=setInterval(()=>{const g=a.m.getState();
5
+ g===_.ko?(clearInterval(f),clearTimeout(e),d(Error("Player entered error state"))):b.includes(g)&&(clearInterval(f),clearTimeout(e),c())},200)})})},tS=function(a){a.U=!1;a.G=null;qS(a,_.lc);a.m.getSurface().hide(a.da)},uS=function(a){_.Ai(a.F,{visibility:"visible"})},wS=function(a){_.v(function*(){a.ia.initialize();const b=!!a.m.getConfiguration().muted;(yield a.Z.canPlay(b))||pS(a)?vS(a):(qS(a,_.Kc),a.g.warn(_.la))})},vS=function(a){a.a.init(a.F.offsetWidth,a.F.offsetHeight,google.ima.ViewMode.NORMAL);
6
+ pS(a)?a.H.isVast&&sS(a):a.a.start();a.ca=!0},W=class{constructor(a,b,c){this.a=a;this.f=a.getAdPodInfo();this.j=b;this.h=c}cb(){return"Google IMA SDK"}eb(){return google.ima.VERSION}gb(){return 0}getId(){return this.a.getAdId()}getCreativeId(){return this.a.getCreativeId()}yb(){return""}getApiFramework(){return this.a.getApiFramework()}getAdSystem(){return this.a.getAdSystem()}getAdvertiserName(){return this.a.getAdvertiserName()}getTitle(){return this.a.getTitle()}getDuration(){return this.a.getDuration()}getPosition(){return 0}getSkipTimeOffset(){return this.a.getSkipTimeOffset()}Ab(){return this.f?
7
+ this.f.getIsBumper():!1}Pa(){let a=null;const b=this.a,c=Object.keys(b).find(d=>typeof b[d]===_.Ce&&typeof b[d].clickThroughUrl===_.Of);c&&(a=b[c].clickThroughUrl);return a}getMediaUrl(){return this.a.getMediaUrl()}Ta(){return this.a.getVastMediaWidth()}Sa(){return this.a.getVastMediaHeight()}Ba(){return this.a.getVastMediaBitrate()}Ca(){return this.h?2:this.j?1:0}getPodIndex(){return this.f?this.f.getPodIndex():0}ob(){return this.f?this.f.getTimeOffset():0}fb(){return this.f?this.f.getAdPosition():
8
+ 1}Ua(){return this.f?this.f.getTotalAds():1}getWrapperAdIds(){return this.a.getWrapperAdIds()}canSeek(){return!1}getWrapperAdSystems(){return this.a.getWrapperAdSystems()}getWrapperCreativeIds(){return this.a.getWrapperCreativeIds()}zb(){return null}};W.prototype.getVideoElement=W.prototype.zb;W.prototype.getWrapperCreativeIds=W.prototype.getWrapperCreativeIds;W.prototype.getWrapperAdSystems=W.prototype.getWrapperAdSystems;W.prototype.canSeek=W.prototype.canSeek;W.prototype.getWrapperAdIds=W.prototype.getWrapperAdIds;
9
+ W.prototype.getSequenceLength=W.prototype.Ua;W.prototype.getPositionInSequence=W.prototype.fb;W.prototype.getPodTimeOffset=W.prototype.ob;W.prototype.getPodIndex=W.prototype.getPodIndex;W.prototype.getPodType=W.prototype.Ca;W.prototype.getMediaBitrate=W.prototype.Ba;W.prototype.getMediaHeight=W.prototype.Sa;W.prototype.getMediaWidth=W.prototype.Ta;W.prototype.getMediaUrl=W.prototype.getMediaUrl;W.prototype.getClickThroughUrl=W.prototype.Pa;W.prototype.isBumper=W.prototype.Ab;
10
+ W.prototype.getSkipTimeOffset=W.prototype.getSkipTimeOffset;W.prototype.getPosition=W.prototype.getPosition;W.prototype.getDuration=W.prototype.getDuration;W.prototype.getTitle=W.prototype.getTitle;W.prototype.getAdvertiserName=W.prototype.getAdvertiserName;W.prototype.getAdSystem=W.prototype.getAdSystem;W.prototype.getApiFramework=W.prototype.getApiFramework;W.prototype.getSourceId=W.prototype.yb;W.prototype.getCreativeId=W.prototype.getCreativeId;W.prototype.getId=W.prototype.getId;
11
+ W.prototype.getTechnology=W.prototype.gb;W.prototype.getAdManagerVersion=W.prototype.eb;W.prototype.getAdManagerName=W.prototype.cb;var xS=class{create(a){const b=google.ima.AdError.ErrorCode;switch(a){case b.VAST_LOAD_TIMEOUT:case b.VAST_MEDIA_LOAD_TIMEOUT:case b.FAILED_TO_REQUEST_ADS:return 0;case b.VIDEO_PLAY_ERROR:return 1;default:return 2}}};var yS=class{constructor(a){this.a=a}getCuePoints(){return this.a}Qb(){return 0<=this.a.indexOf(0)||0===this.a.length}Pb(){return 0<=this.a.indexOf(-1)}};yS.prototype.hasPostroll=yS.prototype.Pb;yS.prototype.hasPreroll=yS.prototype.Qb;yS.prototype.getCuePoints=yS.prototype.getCuePoints;var zS=class extends _.Ev{constructor(){super();this.a=this.h=this.f=null}onPlayerCreated(a){if(kS())return a.onError(new _.I(1,9,1E4));this.f=_.yi(_.Ad,{"class":"clpp-ima clpp-hidden"});a.getSurface().addElementToContainer(this.f);this.h=new google.ima.AdDisplayContainer(this.f,a.getSurface().getMedia());this.a=new google.ima.AdsLoader(this.h);this.a.getSettings().setPlayerType(_.sa);this.a.getSettings().setPlayerVersion(_.ea);this.a.getSettings().setAutoPlayAdBreaks(!0)}onPlayerWillDestroy(a){this.a&&
12
+ (this.a.destroy(),this.a=null);this.h&&(this.h.destroy(),this.h=null);this.f&&(a.getSurface().removeElementFromContainer(this.f),this.f=null)}Uh(){return this.a}Sh(){return this.h}Yc(){return this.f}id(){return"ima"}};_.w("clpp.ima.ImaPlugin",zS);zS.prototype.getAdContainer=zS.prototype.Yc;zS.prototype.getAdDisplayContainer=zS.prototype.Sh;zS.prototype.getAdsLoader=zS.prototype.Uh;zS.Id="ima";zS.isSdkMissing=kS;var AS=class{create(){return new zS}};var BS=class{constructor(a){var b=a.Ed("ima");if(!b)throw Error("IMA plugin not created.");var c=b.Yc(),d=b.h;b=b.a;if(!c||!d||!b)throw Error("IMA plugin not initialized.");const e=a.getSurface().getMedia();if(!e)throw Error("Missing media element.");this.m=a;this.F=e;a=this.m.getConfiguration();a=_.Zg(a.ima||{});this.H=a=_.Yg({disableCustomPlayback:!1},a);this.da=c;this.ia=d;this.B=b;this.Z=new _.uv;this.g=new _.T("clpp.ima");this.a=null;this.W=!1;this.l=null;this.f=new _.wl;this.ca=!1;this.S=new _.Bt;
13
+ this.vc=new xS;this.G=null;this.C=this.U=!1;this.L=1;this.P=this.I=this.J=!1;this.M=this.R=null;this.K=!0;c=this.S;d=google.ima.AdErrorEvent.Type.AD_ERROR;c.one(this.B,google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,this.fd.bind(this));c.on(this.B,d,this.Jc.bind(this));c.on(this.m,_.Rd,this.gd.bind(this))}fd(a){this.a=a.getAdsManager(this.F,lS(this));this.a.isCustomPlaybackUsed()&&!mS(this)?(this.g.warn("IMA plugin is disabled for this platform with single video element. Disposing."),this.m.onError(new _.I(1,
14
+ 9,10002)),this.o()):(this.setMuted(this.C),this.h(this.L),this.l=new _.rv(this.m.getSurface(),(b,c,d)=>{this.a.resize(b,c,d?google.ima.ViewMode.FULLSCREEN:google.ima.ViewMode.NORMAL)}),a=this.a.getCuePoints(),this.R=new yS(a),this.m.trigger(new _.H(_.oc,{adsTimeline:this.R})),nS(this));this.f.resolve()}Jc(a){oS(this,a.getError());this.f.resolve()}kd(a){this.P=!0;pS(this)||(this.m.pause(),_.Ai(this.F,{visibility:_.Yd}));qS(this,_.Sb,a);this.l.start()}wc(){pS(this)?sS(this):this.a.start()}lb(a){a.getAd().isLinear()?
15
+ qS(this,_.bc,a):(this.a.discardAdBreak(),this.J||(this.J=!0,this.m.play()))}Hb(a){this.U=!0;this.K=!1;this.G=a.getAd().getDuration();qS(this,_.kc,a);this.m.getSurface().show(this.da)}Bc(a){a=a.getAdData();oS(this,a?a.adError:null);tS(this)}Ib(a){qS(this,_.ec,a)}yc(a){qS(this,_.Ub,a)}ab(a){qS(this,_.Xb,a)}Dc(a){qS(this,_.cc,a)}Ub(a){qS(this,_.mc,a)}Gc(a){this.K=!0;qS(this,_.dc,a)}Hc(a){this.K=!1;qS(this,_.hc,a)}Aa(a){this.pause();qS(this,_.Vb,a)}Jb(a){qS(this,_.jc,a);tS(this)}bb(a){qS(this,_.ac,a)}zc(a){qS(this,
16
+ _.Wb,a);tS(this)}md(){const a=this;return _.v(function*(){a.J=!0;if(pS(a)&&null!==a.M){const c=a.m.getVolume(),d=a.m.isMuted();var b=a.m;b.a&&b.a.forwardEventsTo(b);b=a.m;b.f=_.Yg(b.f,{volume:c,muted:d});yield _.Yn(a.m);!a.I&&a.M&&(yield rS(a,[2,3,4,5]),yield a.m.play(),yield a.m.pause(),yield rS(a,[4,5]),yield a.m.setPosition(a.M))}else{if(!a.P)return a.m.play();uS(a)}a.P=!1;a.l&&a.l.stop();a.I||(yield a.m.play());qS(a,_.Tb)})}gd(){this.I=!0;this.B.contentComplete()}load(){const a=this;return _.v(function*(){var b=
17
+ a.m;const c=a.H;try{if(typeof c.adTagUrl!==_.Of)throw new _.I(1,9,10001,{missingKeys:"adTagUrl"});}catch(f){return b.onError(f),a.f.resolve(),a.f}if(!c.adTagUrl)return a.f.resolve(),a.f;b=yield a.Z.canPlay(!1);const d=yield a.Z.canPlay(!0),e=new google.ima.AdsRequest;e.adTagUrl=c.adTagUrl;e.setAdWillAutoPlay(b);e.setAdWillPlayMuted(d);a.B.getSettings().setAutoPlayAdBreaks(!1);a.B.requestAds(e);return a.f})}j(){if(this.W||!this.a||this.W)return!0;if(!this.ca){if(this.R.Qb())return wS(this),!1;this.ia.initialize();
18
+ vS(this);return!0}return this.pb()&&this.a?(this.a.resume(),!1):!0}A(){}w(){return!0}ib(){this.a&&this.a.pause()}isPaused(){return this.K}skip(){this.a&&this.a.skip()}getAdVolume(){return this.a?this.C?this.L:this.a.getVolume():1}h(a){this.L=a;this.a&&(this.C||this.a.setVolume(a))}setVolume(a){this.h(a)}getVolume(){return this.getAdVolume()}pause(){this.ib()}resume(){this.j()}setMuted(a){this.C=a;this.a&&(a?this.a.setVolume(0):this.a.setVolume(this.L))}isMuted(){return this.C}pb(){return this.U}getPosition(){if(!this.a||
19
+ null===this.G)return-1;const a=this.a.getRemainingTime();return 0>a?0:this.G-a}o(){this.a&&(this.a.destroy(),this.a=null);this.W=!0;uS(this);this.S.release();this.l&&(this.l.stop(),this.l=null);return Promise.resolve()}};BS.prototype.getPosition=BS.prototype.getPosition;BS.prototype.resume=BS.prototype.resume;BS.prototype.pause=BS.prototype.pause;BS.prototype.getVolume=BS.prototype.getVolume;BS.prototype.setVolume=BS.prototype.setVolume;BS.prototype.getAdVolume=BS.prototype.getAdVolume;
20
+ BS.prototype.skip=BS.prototype.skip;BS.prototype.pauseAd=BS.prototype.ib;_.Ah(new class{constructor(){this.Wa=new _.T(jS)}name(){return jS}a(a,b){return a.namespace()===_.gd?!1:kS()?(this.Wa.warn("IMA SDK is not loaded."),!1):!(!b||!b.ima)}create(a){return new BS(a)}});_.En(new AS);};f.call(g, window);
package/cl.mediatailor.js CHANGED
@@ -1,2 +1,2 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var qS=function(a,b,c){return _.w(function*(){var d=yield(yield fetch(b,{method:_.eb,body:JSON.stringify(c.sessionConfig)})).json();const e=d.trackingUrl;d={Rg:_.Pm(d.manifestUrl,b),Pj:e?_.Pm(e,b):null};a.g.info(`Media Tailor session initialized.
2
- - manifest URI: ${d.Rg}`);return d})},rS=class extends _.Uv{constructor(){super();this.g=new _.T("clpp.mediatailor.MediaTailorPlugin")}onContentWillLoad(a,b){const c=this;return _.w(function*(){const d=a.getConfiguration().mediatailor;if(d.enabled){c.g.info("MediaTailor plugin is enabled");try{const e=yield qS(c,b.url,d);a.trigger(new _.H("mt-session-started"));b.url=e.Rg}catch(e){throw c.g.error("Failed to start session",e),new _.I(_.D,9,7003,"Media Tailor session failed to initialize.");}}})}id(){return"mediatailor"}};_.Pn(new class{create(){return new rS}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var hS=function(a,b,c){return _.v(function*(){var d=yield(yield fetch(b,{method:_.bb,body:JSON.stringify(c.sessionConfig)})).json();const e=d.trackingUrl;d={Ng:_.Bm(d.manifestUrl,b),Oj:e?_.Bm(e,b):null};a.g.info(`Media Tailor session initialized.
2
+ - manifest URI: ${d.Ng}`);return d})},iS=class extends _.Ev{constructor(){super();this.g=new _.T("clpp.mediatailor.MediaTailorPlugin")}onContentWillLoad(a,b){const c=this;return _.v(function*(){const d=a.getConfiguration().mediatailor;if(d.enabled){c.g.info("MediaTailor plugin is enabled");try{const e=yield hS(c,b.url,d);a.trigger(new _.H("mt-session-started"));b.url=e.Ng}catch(e){throw c.g.error("Failed to start session",e),new _.I(_.D,9,7003,"Media Tailor session failed to initialize.");}}})}id(){return"mediatailor"}};_.En(new class{create(){return new iS}});};f.call(g, window);