@castlabs/prestoplay 6.22.0 → 6.23.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/cjs/cl.adobe.js +3 -3
  3. package/cjs/cl.airplay.js +3 -3
  4. package/cjs/cl.broadpeak.js +7 -7
  5. package/cjs/cl.cast.js +116 -116
  6. package/cjs/cl.conviva.js +32 -33
  7. package/cjs/cl.core.js +592 -590
  8. package/cjs/cl.crypto.js +9 -9
  9. package/cjs/cl.dash.js +86 -80
  10. package/cjs/cl.externs.js +43 -36
  11. package/cjs/cl.freewheel.js +24 -24
  12. package/cjs/cl.hls.js +71 -70
  13. package/cjs/cl.hlssmpte.js +6 -6
  14. package/cjs/cl.htmlcue.js +30 -29
  15. package/cjs/cl.ima.js +23 -23
  16. package/cjs/cl.mse.js +342 -328
  17. package/cjs/cl.muxdata.js +15 -15
  18. package/cjs/cl.onboard.js +3 -3
  19. package/cjs/cl.persistent.js +14 -14
  20. package/cjs/cl.playlist.js +6 -6
  21. package/cjs/cl.sessions.js +16 -16
  22. package/cjs/cl.simid.js +15 -15
  23. package/cjs/cl.smooth.js +72 -72
  24. package/cjs/cl.thumbnails.js +26 -26
  25. package/cjs/cl.tizen.js +72 -72
  26. package/cjs/cl.ttml.js +29 -29
  27. package/cjs/cl.verimatrix.js +5 -5
  28. package/cjs/cl.vimond.js +12 -13
  29. package/cjs/cl.vr.js +19 -19
  30. package/cjs/cl.vtt.js +14 -14
  31. package/cjs/cl.yospace.js +4 -4
  32. package/cjs/cl.youbora.js +37 -37
  33. package/cl.adobe.js +3 -3
  34. package/cl.airplay.js +3 -3
  35. package/cl.broadpeak.js +5 -5
  36. package/cl.cast.js +86 -86
  37. package/cl.conviva.js +27 -27
  38. package/cl.core.js +474 -472
  39. package/cl.crypto.js +9 -9
  40. package/cl.dash.js +80 -75
  41. package/cl.externs.js +43 -36
  42. package/cl.freewheel.js +19 -19
  43. package/cl.hls.js +74 -74
  44. package/cl.hlssmpte.js +5 -5
  45. package/cl.htmlcue.js +26 -26
  46. package/cl.ima.js +16 -16
  47. package/cl.mse.js +303 -290
  48. package/cl.muxdata.js +13 -13
  49. package/cl.onboard.js +4 -4
  50. package/cl.persistent.js +10 -10
  51. package/cl.playlist.js +5 -5
  52. package/cl.sessions.js +10 -10
  53. package/cl.simid.js +13 -13
  54. package/cl.smooth.js +59 -59
  55. package/cl.thumbnails.js +19 -19
  56. package/cl.tizen.js +57 -57
  57. package/cl.ttml.js +22 -22
  58. package/cl.verimatrix.js +4 -4
  59. package/cl.vimond.js +8 -8
  60. package/cl.vr.js +15 -15
  61. package/cl.vtt.js +12 -12
  62. package/cl.yospace.js +3 -3
  63. package/cl.youbora.js +27 -26
  64. package/package.json +1 -1
  65. package/typings.d.ts +53 -6
package/cl.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 ES="Unsupported unit",FS="clpp-text-plain",GS="clpp-text-ttml",HS="clpp.htmlcue.HtmlTextDisplayer",IS="initial",JS=function(a){return _.Zh(a,{rf:(b,c)=>b.Cc(c)})},KS=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)},LS=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},MS=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},OS=function(a){let b=null;for(;b=a.match(/&(amp|lt|gt|lrm|rlm|nbsp);/);)a=a.replace(b[0],c=>NS[c]);return a},QS=function(a,b){PS(a,b);Array.from(b.getElementsByTagName("*")).forEach(c=>{PS(a,c)})},PS=function(a,b){for(const c in a)null!=a[c]&&(b.style[c]=a[c])},RS=function(a,b){return 0===a?"0":a+b},SS=function(a,b){return 1>Math.abs(a-b)||a<b},TS=function(a,b){return a<b&&1<Math.abs(a-b)},US=function(a,b){return a>b&&1<Math.abs(a-b)},VS=
3
- function(a,b){return 1>Math.abs(a-b)||a>b},XS=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 WS(b.left+d,b.right+e,g,(b.bottom||g+f)+c,f,(b.width||a.offsetWidth)-
4
- d-e)},YS=function(a){return new WS(a.left,a.f,a.top,a.a,a.height,a.width)},ZS=function(a,b){return b.some(c=>TS(a.left,c.f)&&US(a.f,c.left)&&TS(a.top,c.a)&&US(a.a,c.top))},$S=function(a,b){return VS(a.top,b.top)&&SS(a.a,b.a)&&VS(a.left,b.left)&&SS(a.f,b.f)},aT=function(a,b,c){switch(c){case "+x":return TS(a.left,b.left);case "-x":return US(a.f,b.f);case "+y":return TS(a.top,b.top);case "-y":return US(a.a,b.a);default:throw Error("Unknown axis");}},bT=function(a){return a.f.writingMode===_.nt},cT=
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 bT(a)?b:c},dT=function(a){switch(a.f.writingMode){case _.nt:return"horizontal-tb";case _.lg:return _.lg;case _.mg:return _.mg;default:throw Error("Unknown writing mode");}},eT=function(a){switch(a.f.positionAlign){case _.ke:return _.he;case "auto":case _.dd:return _.mt;case _.le:return _.Bf}return a.f.textAlign},fT=function(a,b){if(typeof a.f.position===_.t&&typeof a.f.size===
6
- _.t)switch(b){case _.ke:return a.f.position;case "auto":case _.dd:return a.f.position-a.f.size/2;case _.le:return a.f.position-a.f.size}return 0},gT=function(a){if(!a.f.positionAlign)switch(a.f.textAlign){case _.he:case _.he:return _.ke;case _.mt:return _.dd;case _.Bf:case _.Bf:return _.le}return a.f.positionAlign},jT=function(a,b,c){return(hT(a)||iT(a))&&_.ah(c)?RS(c,_.uf):hT(a)&&_.B(c)?RS(0,_.uf):bT(a)&&_.ah(b)?RS(b,"%"):IS},kT=function(a,b,c){return bT(a)&&_.ah(c)?RS(c,_.uf):(hT(a)||iT(a))&&_.ah(b)?
7
- RS(b,"%"):IS},iT=function(a){return a.f.writingMode===_.mg},hT=function(a){return a.f.writingMode===_.lg},lT=function(a,b){if(a.j)switch(b.writingMode){case _.nt:return["-y"];case _.lg:return["+x"];case _.mg:return["-x"]}a=[];switch(b.writingMode){case _.nt:a=["+y","-y"];break;case _.lg:a=["+x","-x"];break;case _.mg:a=["-x","+x"]}0>b.line&&(a=a.reverse());return a},mT=function(a){for(a.h=[];0<a.f.childNodes.length;)a.f.removeChild(a.f.childNodes[0]);a.a=XS(a.l.a)},nT=function(a,b){mT(a.h);a.l.unshift(b);
8
- for(const c of a.l)a.h.append(c)},oT=function(a,b,c){a=a.f;const d=a.viewportAnchorUnits;if(d===_.ut)return a.viewportAnchorY/100*c-a.regionAnchorY/100*b;if(0===d)return a.viewportAnchorY-a.regionAnchorY;throw Error(ES);},qT=function(a,b,c,d){const e=document.createElement(_.Uf),f=e.dataset;f.name=b;f.for=c;d&&(f.name=`${b} (sandbox)`,f.sandbox=!0);c=document.head;c.appendChild(e);pT(a,c,b);a.g.debug(`Created HTML style element #${b}.`);return e.sheet},rT=function(a,b){a=`.${a.j} .clpp-text-container`;
9
- const c=`${a} .clpp-text-cue`;return b=b.replace(/::cue\((#[^)]+)\)/g,`${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)},sT=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);
10
- return c},tT=function(a){if(null!=a.a){for(;0<a.a.cssRules.length;)a.a.deleteRule(0);a.o=[]}},pT=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())},uT=function(a){a=_.Ug(a.htmlcue||{});_.B(a.stretchSmpteImage)&&(a.stretchSmpteImage=!1);_.B(a.enableResizeObserver)&&(a.enableResizeObserver=
11
- !0);return a},AT=function(a,b){if((b||a.l)&&a.F){var c=a.m.getPosition();if(b||a.J!==c&&a.m.getState()===_.Fo)if(a.J=c,c=vT(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,wT(a),c)){b={color:a.getFontColor()||void 0,backgroundColor:a.getBackgroundColor()||void 0,fontFamily:a.getFontFamily()||void 0,textShadow:_.dt(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 _.wg:g="clpp-text-vtt";
12
- break;case _.ag:g=GS;break;case _.lt:g=FS}g&&!f.classList.contains(g)&&_.$o(f,g);f=XS(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{PS({fontSize:xT(c,d.containerRows)},c.a.a);f=null;g=d.payloadType===_.wg;var h=d.payloadType===_.ag;d.region&&(g||h||d.backgroundImage)&&(c.B.has(d.region.id)?f=c.B.get(d.region.id):(f=new yT(d.region,
13
- {}),c.B.set(d.region.id,f),nT(c.a,f)));d=new zT(d,c.L,e);f?nT(f,d):nT(c.a,d)}}}}},BT=function(a){wT(a);a.J=null;a.o=null;a.f=[]},CT=function(a,b){return a.startTime<=b&&a.endTime>b},vT=function(a,b){var c=LS(a.f,d=>CT(d,b)?0:b!==d.startTime?b-d.startTime:b-d.endTime);if(-1===c)return null;{let d=c;for(;0<=d-1&&CT(a.f[d-1],b);)d--;for(;c+1<a.f.length&&CT(a.f[c+1],b);)c++;return{start:d,end:c}}},wT=function(a){a.B.clear();if(a.a){const b=a.a.a;b.classList.remove("clpp-text-vtt");b.classList.remove(GS);
14
- b.classList.remove(FS);a=a.a;mT(a.h);a.l=[]}},xT=function(a,b){const c=XS(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===_.t&&0<b)return`${Math.round(c/b)}px`;a=a.getFontSizePercent();return`${Math.round(c*a)}px`},GT=class{parse(a){a={input:a};const b=_.bp(_.Id),c=[];let d=b;for(var e;null!==(e=MS(a));)if("\x3c"===e[0])if("/"===e[1])c.length&&c[c.length-1]===e.substr(2).replace("\x3e","")&&(c.pop(),d=d.parentNode);
15
- else{if(e=e.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/)){var f=e[1];var g=e[3];var h=DT[f];h?(h=_.bp(h),(f=ET[f])&&g&&h.setAttribute(f,g.trim()),g=h):g=null;!g||FT[g.localName]&&FT[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(OS(e)));return b}},DT={c:"c",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"v",lang:"lang"},ET={v:"voice",lang:"lang"},FT={rt:"ruby"},NS={"\x26amp;":"\x26",
16
- "\x26lt;":"\x3c","\x26gt;":"\x3e","\x26lrm;":"\u200e","\x26rlm;":"\u200f","\x26nbsp;":"\u00a0"};var WS=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 HT=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 zT=class extends HT{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)_.$o(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===_.ag){var c=_.bp(_.Id);c.innerHTML=b.payload;b=c}else b.payloadType===
17
- _.wg?b=(new GT).parse(b.payload):(c=_.bp(_.Id),c.textContent=b.payload,b=c);_.$o(b,this.w);this.id&&(b.id=this.id);for(d of this.f.cssClassList)_.$o(b,d);PS({writingMode:dT(this)},b);var d=b;this.a.appendChild(d);_.$o(this.a,"clpp-text-wrapper");for(var e of this.f.cssClassList)_.$o(this.a,`clpp-text-wrapper__${e}`);_.B(this.f.line)&&(this.f.lineInterpretation=_.ot,this.f.line=bT(this)?-1:0);e=dT(this);PS({writingMode:e,webkitWritingMode:e,direction:IS,textAlign:eT(this)},this.a);if(!this.f.region||
18
- !this.f.region.displayAlign){e=fT(this,gT(this));PS({position:"absolute",left:jT(this,e,null),right:iT(this)&&_.B(null)?RS(0,_.uf):IS,top:kT(this,e,null),width:bT(this)?RS(this.f.size,"%"):IS,height:hT(this)||iT(this)?RS(this.f.size,"%"):IS},this.a);b=this.f;a=bT(this)?a.height:a.width;c=cT(this);if(b.lineInterpretation===_.ot){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 _.dd:g-=f/2;break;case _.Wd:g-=f}f=Math.round(g/
19
- 100*a)}iT(this)&&(f=a-f-c);a=f;PS({left:jT(this,e,a),right:iT(this)&&_.B(a)?RS(0,_.uf):IS,top:kT(this,e,a)},this.a)}QS(this.C,d)}}o(){return _.bp(_.Id)}};var IT=class{constructor(a,b){this.l=a;this.f=a.a;this.j=void 0===b?!1:b;this.a=XS(a.a);this.h=[]}append(a){const b=a.a;b.style.visibility=_.ce;this.f.appendChild(b);a.j||a.init(this.a);if(a.A()){a:{var c=XS(a.a);var d=lT(this,a.f),e=cT(a);const g=YS(c);let h=null,k=0;for(const l of d){for(;aT(c,this.a,l)||$S(c,this.a)&&ZS(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||$S(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=YS(c),k=d);c=YS(g)}c=h||g}PS({top:RS(c.top-this.a.top,_.uf),bottom:RS(this.a.a-c.a,_.uf),left:RS(c.left-this.a.left,_.uf),right:RS(this.a.f-c.f,_.uf),height:RS(c.height,_.uf),width:RS(c.width,_.uf)},a.a)}b.style.visibility="visible";this.h.push(XS(a.a))}};var JT=class extends HT{constructor(a,b,c){super(a,b,c);this.h=null;this.l=[]}init(){this.h=new IT(this);this.j=!0}o(){const a=_.bp(_.Id);_.$o(a,this.w);this.id&&(a.id=this.id);return a}};var yT=class extends JT{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 _.ut:b=b.width/100*a.width;break a;default:throw Error(ES);}}var c=this.f;var d=c.viewportAnchorUnits;if(d===_.ut)c=c.viewportAnchorX/100*a.width-c.regionAnchorX/100*b;else if(0===d)c=c.viewportAnchorX-c.regionAnchorX;else throw Error(ES);d=a.height;const e=oT(this,d,a.height);PS(this.B,this.a);PS({left:RS(c,_.uf),top:RS(e,_.uf),width:RS(b,
21
- _.uf),height:RS(d,_.uf)},this.a);this.f.writingMode&&PS({display:"flex","flex-direction":this.f.writingMode},this.a);this.f.displayAlign&&PS({"justify-content":this.f.displayAlign},this.a);for(var f of this.f.cssClassList)_.$o(this.a,f);a:switch(f=this.f,f.heightUnits){case 0:f=f.height;break a;case _.ut:f=f.height/100*a.height;break a;case 2:f=f.height;c=new zT(new _.rt(0,1,"Lorem ipsum",_.lt),{},{});b=c.a;this.a.appendChild(b);c.init(XS(this.a));c=b.getBoundingClientRect().height;this.a.removeChild(b);
22
- b=c;f*=b;break a;default:throw Error(ES);}a=oT(this,f,a.height);PS({top:RS(a,_.uf),height:RS(f,_.uf)},this.a);this.h=new IT(this,!0);this.j=!0}getId(){return this.f.id}};var KT=class{constructor(a,b){this.g=new _.S("clpp.htmlcue.StyleManager");this.l=[];this.j=a;this.h=b;this.o=[];this.a=qT(this,this.h,this.j);this.f=qT(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=rT(this,a);if(sT(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 _.x(function*(){null!=a.a&&(a.l.forEach(b=>b()),a.l=[],tT(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 LT=class extends _.fv{constructor(a){super(a);this.g=new _.S(HS);this.m=a;this.L=uT(a.getConfiguration());this.l=!1;this.f=[];this.F=a.getSurface().getContainer();this.j=new KT(a.getSurface().getUniqueCssClass(),"CLPP Subtitle Styles");this.a=new JT(null,"clpp-text-container",{});this.A=new _.Zu(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 _.vk(()=>{AT(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=KS(this.f,JS(a));this.o=null;AT(this,!1)}}h(){null==this.j||AT(this,!0)}destroy(){const a=this;return _.x(function*(){null!=a.j&&(BT(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;AT(this,!0);return!0}isTextVisible(){return this.l}setTextVisibility(a){null!=this.j&&this.l!==a&&((this.l=a)?(this.G.xb(.25),this.L.enableResizeObserver&&this.A.start(),AT(this,!0)):(this.G.stop(),this.A.stop(),BT(this)))}S(){AT(this,!0)}};_.z(HS,LT);LT.prototype.setTextVisibility=LT.prototype.setTextVisibility;LT.prototype.isTextVisible=LT.prototype.isTextVisible;LT.prototype.remove=LT.prototype.remove;LT.prototype.destroy=LT.prototype.destroy;
26
- LT.prototype.append=LT.prototype.append;var MT=class{a(a){return!!a.enableHtmlCue&&!_.Lk()}create(a){return new LT(a)}};_.z("clpp.htmlcue.HtmlCueComponent",class extends _.Iu{f(){_.jo(_.de,new MT)}a(){_.ho.has(_.de)&&(_.ho.delete(_.de),_.io.info("Removed factory: 'html'"))}id(){return _.Vf}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var iT="Unsupported unit",jT="clpp-text-plain",kT="clpp-text-ttml",lT="clpp.htmlcue.HtmlTextDisplayer",mT="initial",nT=function(a){return _.ei(a,{Af:(b,c)=>b.Fc(c)})},oT=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)},pT=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},qT=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},sT=function(a){let b=null;for(;b=a.match(/&(amp|lt|gt|lrm|rlm|nbsp);/);)a=a.replace(b[0],c=>rT[c]);return a},uT=function(a,b){tT(a,b);Array.from(b.getElementsByTagName("*")).forEach(c=>{tT(a,c)})},tT=function(a,b){for(const c in a)null!=a[c]&&(b.style[c]=a[c])},vT=function(a,b){return 0===a?"0":a+b},wT=function(a,b){return 1>Math.abs(a-b)||a<b},xT=function(a,b){return a<b&&1<Math.abs(a-b)},yT=function(a,b){return a>b&&1<Math.abs(a-b)},zT=
3
+ function(a,b){return 1>Math.abs(a-b)||a>b},BT=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 AT(b.left+d,b.right+e,g,(b.bottom||g+f)+c,f,(b.width||a.offsetWidth)-
4
+ d-e)},CT=function(a){return new AT(a.left,a.f,a.top,a.a,a.height,a.width)},DT=function(a,b){return b.some(c=>xT(a.left,c.f)&&yT(a.f,c.left)&&xT(a.top,c.a)&&yT(a.a,c.top))},ET=function(a,b){return zT(a.top,b.top)&&wT(a.a,b.a)&&zT(a.left,b.left)&&wT(a.f,b.f)},FT=function(a,b,c){switch(c){case "+x":return xT(a.left,b.left);case "-x":return yT(a.f,b.f);case "+y":return xT(a.top,b.top);case "-y":return yT(a.a,b.a);default:throw Error("Unknown axis");}},GT=function(a){return a.f.writingMode===_.Bt},HT=
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 GT(a)?b:c},IT=function(a){switch(a.f.writingMode){case _.Bt:return"horizontal-tb";case _.pg:return _.pg;case _.qg:return _.qg;default:throw Error("Unknown writing mode");}},JT=function(a){switch(a.f.positionAlign){case _.pe:return _.me;case "auto":case _.ed:return _.At;case _.qe:return _.Ef}return a.f.textAlign},KT=function(a,b){if(typeof a.f.position===_.t&&typeof a.f.size===
6
+ _.t)switch(b){case _.pe:return a.f.position;case "auto":case _.ed:return a.f.position-a.f.size/2;case _.qe:return a.f.position-a.f.size}return 0},LT=function(a){if(!a.f.positionAlign)switch(a.f.textAlign){case _.me:case _.me:return _.pe;case _.At:return _.ed;case _.Ef:case _.Ef:return _.qe}return a.f.positionAlign},OT=function(a,b,c){return(MT(a)||NT(a))&&_.gh(c)?vT(c,_.xf):MT(a)&&_.B(c)?vT(0,_.xf):GT(a)&&_.gh(b)?vT(b,"%"):mT},PT=function(a,b,c){return GT(a)&&_.gh(c)?vT(c,_.xf):(MT(a)||NT(a))&&_.gh(b)?
7
+ vT(b,"%"):mT},NT=function(a){return a.f.writingMode===_.qg},MT=function(a){return a.f.writingMode===_.pg},QT=function(a,b){if(a.j)switch(b.writingMode){case _.Bt:return["-y"];case _.pg:return["+x"];case _.qg:return["-x"]}a=[];switch(b.writingMode){case _.Bt:a=["+y","-y"];break;case _.pg:a=["+x","-x"];break;case _.qg:a=["-x","+x"]}0>b.line&&(a=a.reverse());return a},RT=function(a){for(a.h=[];0<a.f.childNodes.length;)a.f.removeChild(a.f.childNodes[0]);a.a=BT(a.l.a)},ST=function(a,b,c){a=a.f;const d=
8
+ a.viewportAnchorUnits;if(d===_.It)return a.viewportAnchorY/100*c-a.regionAnchorY/100*b;if(0===d)return a.viewportAnchorY-a.regionAnchorY;throw Error(iT);},UT=function(a,b,c,d){const e=document.createElement(_.Xf),f=e.dataset;f.name=b;f.for=c;d&&(f.name=`${b} (sandbox)`,f.sandbox=!0);c=document.head;c.appendChild(e);TT(a,c,b);a.g.debug(`Created HTML style element #${b}.`);return e.sheet},VT=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)},WT=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},XT=function(a){if(null!=a.a){for(;0<a.a.cssRules.length;)a.a.deleteRule(0);
10
+ a.o=[]}},TT=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())},YT=function(a){a=_.$g(a.htmlcue||{});_.B(a.stretchSmpteImage)&&(a.stretchSmpteImage=!1);_.B(a.enableResizeObserver)&&(a.enableResizeObserver=!0);return a},dU=function(a,b){if((b||a.l)&&a.F){var c=a.m.getPosition();
11
+ if(b||a.J!==c&&a.m.getState()===_.ap)if(a.J=c,c=ZT(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,$T(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 _.Ag:g="clpp-text-vtt";break;case _.dg:g=kT;break;case _.zt:g=jT}g&&!f.classList.contains(g)&&
12
+ _.wp(f,g);f=BT(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{tT({fontSize:aU(c,d.containerRows)},c.a.a);f=null;g=d.payloadType===_.Ag;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 bU(d.region,{}),c.B.set(d.region.id,f),c.a.appendChild(f)));d=new cU(d,c.L,e);f?f.appendChild(d):
13
+ c.a.appendChild(d)}}}}},eU=function(a){$T(a);a.J=null;a.o=null;a.f=[]},fU=function(a,b){return a.startTime<=b&&a.endTime>b},ZT=function(a,b){var c=pT(a.f,d=>fU(d,b)?0:b!==d.startTime?b-d.startTime:b-d.endTime);if(-1===c)return null;{let d=c;for(;0<=d-1&&fU(a.f[d-1],b);)d--;for(;c+1<a.f.length&&fU(a.f[c+1],b);)c++;return{start:d,end:c}}},$T=function(a){a.B.clear();if(a.a){const b=a.a.a;b.classList.remove("clpp-text-vtt");b.classList.remove(kT);b.classList.remove(jT);a=a.a;RT(a.h);a.l=[]}},aU=function(a,
14
+ b){const c=BT(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===_.t&&0<b)return`${Math.round(c/b)}px`;a=a.getFontSizePercent();return`${Math.round(c*a)}px`},jU=class{parse(a){a={input:a};const b=_.yp(_.Ld),c=[];let d=b;for(var e;null!==(e=qT(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=gU[f];h?(h=_.yp(h),(f=hU[f])&&g&&h.setAttribute(f,g.trim()),g=h):g=null;!g||iU[g.localName]&&iU[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(sT(e)));return b}},gU={c:"c",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"v",lang:"lang"},hU={v:"voice",lang:"lang"},iU={rt:"ruby"},rT={"\x26amp;":"\x26","\x26lt;":"\x3c","\x26gt;":"\x3e","\x26lrm;":"\u200e","\x26rlm;":"\u200f",
16
+ "\x26nbsp;":"\u00a0"};var AT=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 kU=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 cU=class extends kU{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)_.wp(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=_.yp(_.Ld);c.innerHTML=b.payload;b=c}else b.payloadType===
17
+ _.Ag?b=(new jU).parse(b.payload):(c=_.yp(_.Ld),c.textContent=b.payload,b=c);_.wp(b,this.w);this.id&&(b.id=this.id);for(d of this.f.cssClassList)_.wp(b,d);tT({writingMode:IT(this)},b);var d=b;this.a.appendChild(d);_.wp(this.a,"clpp-text-wrapper");for(var e of this.f.cssClassList)_.wp(this.a,`clpp-text-wrapper__${e}`);_.B(this.f.line)&&(this.f.lineInterpretation=_.Ct,this.f.line=GT(this)?-1:0);e=IT(this);tT({writingMode:e,webkitWritingMode:e,direction:mT,textAlign:JT(this)},this.a);if(!this.f.region||
18
+ !this.f.region.displayAlign){e=KT(this,LT(this));tT({position:"absolute",left:OT(this,e,null),right:NT(this)&&_.B(null)?vT(0,_.xf):mT,top:PT(this,e,null),width:GT(this)?vT(this.f.size,"%"):mT,height:MT(this)||NT(this)?vT(this.f.size,"%"):mT},this.a);b=this.f;a=GT(this)?a.height:a.width;c=HT(this);if(b.lineInterpretation===_.Ct){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 _.ed:g-=f/2;break;case _.ae:g-=f}f=Math.round(g/
19
+ 100*a)}NT(this)&&(f=a-f-c);a=f;tT({left:OT(this,e,a),right:NT(this)&&_.B(a)?vT(0,_.xf):mT,top:PT(this,e,a)},this.a)}uT(this.C,d)}}o(){return _.yp(_.Ld)}};var lU=class{constructor(a,b){this.l=a;this.f=a.a;this.j=void 0===b?!1:b;this.a=BT(a.a);this.h=[]}append(a){const b=a.a;b.style.visibility=_.he;this.f.appendChild(b);a.j||a.init(this.a);if(a.A()){a:{var c=BT(a.a);var d=QT(this,a.f),e=HT(a);const g=CT(c);let h=null,k=0;for(const l of d){for(;FT(c,this.a,l)||ET(c,this.a)&&DT(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||ET(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=CT(c),k=d);c=CT(g)}c=h||g}tT({top:vT(c.top-this.a.top,_.xf),bottom:vT(this.a.a-c.a,_.xf),left:vT(c.left-this.a.left,_.xf),right:vT(this.a.f-c.f,_.xf),height:vT(c.height,_.xf),width:vT(c.width,_.xf)},a.a)}b.style.visibility="visible";this.h.push(BT(a.a))}};var mU=class extends kU{constructor(a,b,c){super(a,b,c);this.h=null;this.l=[]}init(){this.h=new lU(this);this.j=!0}o(){const a=_.yp(_.Ld);_.wp(a,this.w);this.id&&(a.id=this.id);return a}appendChild(a){RT(this.h);this.l.unshift(a);for(const b of this.l)this.h.append(b)}};var bU=class extends mU{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 _.It:b=b.width/100*a.width;break a;default:throw Error(iT);}}var c=this.f;var d=c.viewportAnchorUnits;if(d===_.It)c=c.viewportAnchorX/100*a.width-c.regionAnchorX/100*b;else if(0===d)c=c.viewportAnchorX-c.regionAnchorX;else throw Error(iT);d=a.height;const e=ST(this,d,a.height);tT(this.B,this.a);tT({left:vT(c,_.xf),top:vT(e,_.xf),width:vT(b,
21
+ _.xf),height:vT(d,_.xf)},this.a);this.f.writingMode&&tT({display:"flex","flex-direction":this.f.writingMode},this.a);this.f.displayAlign&&tT({"justify-content":this.f.displayAlign},this.a);for(var f of this.f.cssClassList)_.wp(this.a,f);a:switch(f=this.f,f.heightUnits){case 0:f=f.height;break a;case _.It:f=f.height/100*a.height;break a;case 2:f=f.height;c=new cU(new _.Ft(0,1,"Lorem ipsum",_.zt),{},{});b=c.a;this.a.appendChild(b);c.init(BT(this.a));c=b.getBoundingClientRect().height;this.a.removeChild(b);
22
+ b=c;f*=b;break a;default:throw Error(iT);}a=ST(this,f,a.height);tT({top:vT(a,_.xf),height:vT(f,_.xf)},this.a);this.h=new lU(this,!0);this.j=!0}getId(){return this.f.id}};var nU=class{constructor(a,b){this.g=new _.S("clpp.htmlcue.StyleManager");this.l=[];this.j=a;this.h=b;this.o=[];this.a=UT(this,this.h,this.j);this.f=UT(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=VT(this,a);if(WT(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 _.x(function*(){null!=a.a&&(a.l.forEach(b=>b()),a.l=[],XT(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 oU=class extends _.Cv{constructor(a){super(a);this.g=new _.S(lT);this.m=a;this.L=YT(a.getConfiguration());this.l=!1;this.f=[];this.F=a.getSurface().getContainer();this.j=new nU(a.getSurface().getUniqueCssClass(),"CLPP Subtitle Styles");this.a=new mU(null,"clpp-text-container",{});this.A=new _.vv(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 _.Ck(()=>{dU(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=oT(this.f,nT(a));this.o=null;dU(this,!1)}}h(){null==this.j||dU(this,!0)}destroy(){const a=this;return _.x(function*(){null!=a.j&&(eU(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;dU(this,!0);return!0}isTextVisible(){return this.l}setTextVisibility(a){null!=this.j&&this.l!==a&&((this.l=a)?(this.G.yb(.25),this.L.enableResizeObserver&&this.A.start(),dU(this,!0)):(this.G.stop(),this.A.stop(),eU(this)))}S(){dU(this,!0)}};_.z(lT,oU);oU.prototype.setTextVisibility=oU.prototype.setTextVisibility;oU.prototype.isTextVisible=oU.prototype.isTextVisible;oU.prototype.remove=oU.prototype.remove;oU.prototype.destroy=oU.prototype.destroy;
26
+ oU.prototype.append=oU.prototype.append;var pU=class{a(a){return!!a.enableHtmlCue&&!_.Sk()}create(a){return new oU(a)}};_.z("clpp.htmlcue.HtmlCueComponent",class extends _.pv{f(){_.Ho(_.ie,new pU)}a(){_.Fo.has(_.ie)&&(_.Fo.delete(_.ie),_.Go.info("Removed factory: 'html'"))}id(){return _.Yf}});};f.call(g, window);
package/cl.ima.js CHANGED
@@ -1,17 +1,17 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var oS="clpp.ima.AdsManagerFactory",pS=function(a){a=a.I;const b=new google.ima.AdsRenderingSettings;b.restoreCustomPlaybackStateOnAdBreakComplete=!1;typeof a.bitrate===_.t&&(b.bitrate=a.bitrate);b.enablePreloading=typeof a.enablePreloading===_.Rc?a.enablePreloading:!0;typeof a.loadVideoTimeout===_.t&&(b.loadVideoTimeout=a.loadVideoTimeout);Array.isArray(a.mimeTypes)&&(b.mimeTypes=a.mimeTypes);typeof a.playAdsAfterTime===_.t&&(b.playAdsAfterTime=a.playAdsAfterTime);typeof a.useStyledLinearAds===
2
- _.Rc&&(b.useStyledLinearAds=a.useStyledLinearAds);b.uiElements=Array.isArray(a.uiElements)?a.uiElements:[];return b},qS=function(a){return!1===a.I.disableCustomPlayback&&a.a.isCustomPlaybackUsed()&&_.zk()},rS=function(a){const b=a.a,c=a.J,d=google.ima.AdEvent.Type;c.on(b,d.AD_BREAK_READY,a.La.bind(a));c.on(b,d.LOADED,a.Y.bind(a));c.on(b,d.CONTENT_PAUSE_REQUESTED,a.kc.bind(a));c.on(b,d.STARTED,a.ba.bind(a));c.on(b,d.LOG,a.Ya.bind(a));c.on(b,d.AD_PROGRESS,a.zb.bind(a));c.on(b,d.AD_BUFFERING,a.Wa.bind(a));
3
- c.on(b,d.FIRST_QUARTILE,a.V.bind(a));c.on(b,d.MIDPOINT,a.Ma.bind(a));c.on(b,d.THIRD_QUARTILE,a.ca.bind(a));c.on(b,d.PAUSED,a.yb.bind(a));c.on(b,d.RESUMED,a.ec.bind(a));c.on(b,d.CLICK,a.S.bind(a));c.on(b,d.SKIPPED,a.Z.bind(a));c.on(b,d.IMPRESSION,a.X.bind(a));c.on(b,d.COMPLETE,a.Xa.bind(a));c.on(b,d.CONTENT_RESUME_REQUESTED,a.mc.bind(a))},sS=function(a,b){const c=b?a.ha.create(b.getErrorCode()):null;a.m.onError(new _.I(1,9,10003,{errorType:c},b))},tS=function(a,b,c){c=c&&c.getAd();let d=null;c&&(d=
4
- {ad:new W(c,a.G,a.F)});a.m.trigger(new _.E(b,d))},uS=function(a){a.B=null;tS(a,_.uc);a.m.getSurface().hide(a.P)},vS=function(a){_.ap(a.A,{visibility:"visible"})},xS=function(a){return _.x(function*(){a.R.initialize();const b=!!a.m.getConfiguration().muted;(yield a.L.canPlay(b))||qS(a)?wS(a):(tS(a,_.Pc),a.g.warn(_.ia))})},yS=function(a,b){return _.x(function*(){a.R.initialize();yield b.play();wS(a)})},wS=function(a){a.a.init(a.A.offsetWidth,a.A.offsetHeight,google.ima.ViewMode.NORMAL);a.a.start();
5
- a.M=!0},zS=function(){return!window.google||!google.ima||!google.ima.AdsLoader},W=class{constructor(a,b,c){this.a=a;this.f=a.getAdPodInfo();this.j=b;this.h=c}lb(){return"Google IMA SDK"}nb(){return google.ima.VERSION}qb(){return 0}getId(){return this.a.getAdId()}getCreativeId(){return this.a.getCreativeId()}Nb(){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()}Qb(){return this.f?
6
- this.f.getIsBumper():!1}ob(){let a=null;const b=this.a,c=Object.keys(b).find(d=>typeof b[d]===_.Ge&&typeof b[d].clickThroughUrl===_.Sf);c&&(a=b[c].clickThroughUrl);return a}getMediaUrl(){return this.a.getMediaUrl()}eb(){return this.a.getVastMediaWidth()}cb(){return this.a.getVastMediaHeight()}Qa(){return this.a.getVastMediaBitrate()}Ra(){return this.h?2:this.j?1:0}getPodIndex(){return this.f?this.f.getPodIndex():0}Db(){return this.f?this.f.getTimeOffset():0}Eb(){return this.f?this.f.getAdPosition():
7
- 1}fb(){return this.f?this.f.getTotalAds():1}getWrapperAdIds(){return this.a.getWrapperAdIds()}getWrapperAdSystems(){return this.a.getWrapperAdSystems()}getWrapperCreativeIds(){return this.a.getWrapperCreativeIds()}Pb(){return null}};W.prototype.getVideoElement=W.prototype.Pb;W.prototype.getWrapperCreativeIds=W.prototype.getWrapperCreativeIds;W.prototype.getWrapperAdSystems=W.prototype.getWrapperAdSystems;W.prototype.getWrapperAdIds=W.prototype.getWrapperAdIds;W.prototype.getSequenceLength=W.prototype.fb;
8
- W.prototype.getPositionInSequence=W.prototype.Eb;W.prototype.getPodTimeOffset=W.prototype.Db;W.prototype.getPodIndex=W.prototype.getPodIndex;W.prototype.getPodType=W.prototype.Ra;W.prototype.getMediaBitrate=W.prototype.Qa;W.prototype.getMediaHeight=W.prototype.cb;W.prototype.getMediaWidth=W.prototype.eb;W.prototype.getMediaUrl=W.prototype.getMediaUrl;W.prototype.getClickThroughUrl=W.prototype.ob;W.prototype.isBumper=W.prototype.Qb;W.prototype.getSkipTimeOffset=W.prototype.getSkipTimeOffset;
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var TS="clpp.ima.AdsManagerFactory",US=function(a){a=a.I;const b=new google.ima.AdsRenderingSettings;b.restoreCustomPlaybackStateOnAdBreakComplete=!1;typeof a.bitrate===_.t&&(b.bitrate=a.bitrate);b.enablePreloading=typeof a.enablePreloading===_.Uc?a.enablePreloading:!0;typeof a.loadVideoTimeout===_.t&&(b.loadVideoTimeout=a.loadVideoTimeout);Array.isArray(a.mimeTypes)&&(b.mimeTypes=a.mimeTypes);typeof a.playAdsAfterTime===_.t&&(b.playAdsAfterTime=a.playAdsAfterTime);typeof a.useStyledLinearAds===
2
+ _.Uc&&(b.useStyledLinearAds=a.useStyledLinearAds);b.uiElements=Array.isArray(a.uiElements)?a.uiElements:[];return b},VS=function(a){return!1===a.I.disableCustomPlayback&&a.a.isCustomPlaybackUsed()&&_.Gk()},WS=function(a){const b=a.a,c=a.J,d=google.ima.AdEvent.Type;c.on(b,d.AD_BREAK_READY,a.Aa.bind(a));c.on(b,d.LOADED,a.X.bind(a));c.on(b,d.CONTENT_PAUSE_REQUESTED,a.kc.bind(a));c.on(b,d.STARTED,a.aa.bind(a));c.on(b,d.LOG,a.Ma.bind(a));c.on(b,d.AD_PROGRESS,a.Z.bind(a));c.on(b,d.AD_BUFFERING,a.Ga.bind(a));
3
+ c.on(b,d.FIRST_QUARTILE,a.V.bind(a));c.on(b,d.MIDPOINT,a.ib.bind(a));c.on(b,d.THIRD_QUARTILE,a.fa.bind(a));c.on(b,d.PAUSED,a.Jb.bind(a));c.on(b,d.RESUMED,a.Kb.bind(a));c.on(b,d.CLICK,a.S.bind(a));c.on(b,d.SKIPPED,a.da.bind(a));c.on(b,d.IMPRESSION,a.W.bind(a));c.on(b,d.COMPLETE,a.Va.bind(a));c.on(b,d.CONTENT_RESUME_REQUESTED,a.nc.bind(a))},XS=function(a,b){const c=b?a.za.create(b.getErrorCode()):null;a.m.onError(new _.H(1,9,10003,{errorType:c},b))},YS=function(a,b,c){c=c&&c.getAd();let d=null;c&&(d=
4
+ {ad:new W(c,a.G,a.F)});a.m.trigger(new _.E(b,d))},ZS=function(a){a.B=null;YS(a,_.xc);a.m.getSurface().hide(a.O)},$S=function(a){_.xp(a.A,{visibility:"visible"})},bT=function(a){return _.x(function*(){a.R.initialize();const b=!!a.m.getConfiguration().muted;(yield a.L.canPlay(b))||VS(a)?aT(a):(YS(a,_.Sc),a.g.warn(_.ja))})},cT=function(a,b){return _.x(function*(){a.R.initialize();yield b.play();aT(a)})},aT=function(a){a.a.init(a.A.offsetWidth,a.A.offsetHeight,google.ima.ViewMode.NORMAL);a.a.start();
5
+ a.M=!0},dT=function(){return!window.google||!google.ima||!google.ima.AdsLoader},W=class{constructor(a,b,c){this.a=a;this.f=a.getAdPodInfo();this.j=b;this.h=c}lb(){return"Google IMA SDK"}nb(){return google.ima.VERSION}qb(){return 0}getId(){return this.a.getAdId()}getCreativeId(){return this.a.getCreativeId()}Nb(){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()}Qb(){return this.f?
6
+ this.f.getIsBumper():!1}ob(){let a=null;const b=this.a,c=Object.keys(b).find(d=>typeof b[d]===_.Ke&&typeof b[d].clickThroughUrl===_.Vf);c&&(a=b[c].clickThroughUrl);return a}getMediaUrl(){return this.a.getMediaUrl()}bb(){return this.a.getVastMediaWidth()}ab(){return this.a.getVastMediaHeight()}Qa(){return this.a.getVastMediaBitrate()}Ra(){return this.h?2:this.j?1:0}getPodIndex(){return this.f?this.f.getPodIndex():0}Cb(){return this.f?this.f.getTimeOffset():0}Db(){return this.f?this.f.getAdPosition():
7
+ 1}cb(){return this.f?this.f.getTotalAds():1}getWrapperAdIds(){return this.a.getWrapperAdIds()}getWrapperAdSystems(){return this.a.getWrapperAdSystems()}getWrapperCreativeIds(){return this.a.getWrapperCreativeIds()}Pb(){return null}};W.prototype.getVideoElement=W.prototype.Pb;W.prototype.getWrapperCreativeIds=W.prototype.getWrapperCreativeIds;W.prototype.getWrapperAdSystems=W.prototype.getWrapperAdSystems;W.prototype.getWrapperAdIds=W.prototype.getWrapperAdIds;W.prototype.getSequenceLength=W.prototype.cb;
8
+ W.prototype.getPositionInSequence=W.prototype.Db;W.prototype.getPodTimeOffset=W.prototype.Cb;W.prototype.getPodIndex=W.prototype.getPodIndex;W.prototype.getPodType=W.prototype.Ra;W.prototype.getMediaBitrate=W.prototype.Qa;W.prototype.getMediaHeight=W.prototype.ab;W.prototype.getMediaWidth=W.prototype.bb;W.prototype.getMediaUrl=W.prototype.getMediaUrl;W.prototype.getClickThroughUrl=W.prototype.ob;W.prototype.isBumper=W.prototype.Qb;W.prototype.getSkipTimeOffset=W.prototype.getSkipTimeOffset;
9
9
  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.Nb;W.prototype.getCreativeId=W.prototype.getCreativeId;W.prototype.getId=W.prototype.getId;W.prototype.getTechnology=W.prototype.qb;
10
- W.prototype.getAdManagerVersion=W.prototype.nb;W.prototype.getAdManagerName=W.prototype.lb;var AS=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 BS=class{constructor(a){this.a=a}getCuePoints(){return this.a}Gb(){return 0<=this.a.indexOf(0)||0===this.a.length}Fb(){return 0<=this.a.indexOf(-1)}};BS.prototype.hasPostroll=BS.prototype.Fb;BS.prototype.hasPreroll=BS.prototype.Gb;BS.prototype.getCuePoints=BS.prototype.getCuePoints;var CS=class{constructor(a){var b=a.Wc("ima");if(!b)throw Error("IMA plugin not created.");var c=b.Dc(),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.A=e;a=this.m.getConfiguration();a=_.Ug(a.ima||{});this.I=a=_.Tg({disableCustomPlayback:!1},a);this.P=c;this.R=d;this.w=b;this.L=new _.av;this.g=new _.S("clpp.ima");this.j=this.a=null;this.f=new _.In;this.M=!1;this.J=new _.jt;this.ha=new AS;
11
- this.B=null;this.H=this.F=this.G=!1;this.K=this.C=null;c=this.J;d=google.ima.AdErrorEvent.Type.AD_ERROR;c.one(this.w,google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,this.hc.bind(this));c.on(this.w,d,this.fc.bind(this));c.on(this.m,_.Xd,this.ic.bind(this))}hc(a){this.a=a.getAdsManager(this.A,pS(this));this.a.isCustomPlaybackUsed()&&!qS(this)?(this.g.warn("IMA plugin is disabled for this platform with single video element. Disposing."),this.m.onError(new _.I(1,9,10002)),this.h()):(this.j=new _.Zu(this.m.getSurface(),
12
- (b,c,d)=>{this.a.resize(b,c,d?google.ima.ViewMode.FULLSCREEN:google.ima.ViewMode.NORMAL)}),a=this.a.getCuePoints(),this.C=new BS(a),this.m.trigger(new _.E(_.xc,{adsTimeline:this.C})),rS(this));this.f.resolve()}fc(a){sS(this,a.getError());this.f.resolve()}kc(a){const b=this;return _.x(function*(){b.H=!0;if(qS(b)){b.K=b.m.getPosition();yield b.m.detach();var c=b.m;c.a&&c.a.stopForwardingEventsTo(c)}else yield b.m.pause(),_.ap(b.A,{visibility:_.ce});tS(b,_.cc,a);b.j.start()})}La(){const a=this;return _.x(function*(){a.a.start()})}Y(a){a.getAd().isLinear()?
13
- tS(this,_.mc,a):(this.a.discardAdBreak(),this.G||(this.G=!0,this.m.play()))}ba(a){this.B=a.getAd().getDuration();tS(this,_.tc,a);this.m.getSurface().show(this.P)}Ya(a){a=a.getAdData();sS(this,a?a.adError:null);uS(this)}zb(a){tS(this,_.qc,a)}Wa(a){tS(this,_.ec,a)}V(a){tS(this,_.hc,a)}Ma(a){tS(this,_.nc,a)}ca(a){tS(this,_.vc,a)}yb(a){tS(this,_.oc,a)}ec(a){tS(this,_.rc,a)}S(a){this.pause();tS(this,_.fc,a)}Z(a){tS(this,_.sc,a);uS(this)}X(a){tS(this,_.lc,a)}Xa(a){tS(this,_.gc,a);uS(this)}mc(){const a=
14
- this;return _.x(function*(){a.G=!0;if(qS(a)&&null!==a.K){var b=a.m;b.a&&b.a.forwardEventsTo(b);yield _.qr(a.m);a.F||(yield a.m.seek(a.K))}else{if(!a.H)return a.m.play();vS(a)}a.H=!1;a.j&&a.j.stop();a.F||(yield a.m.play());tS(a,_.dc)})}ic(){this.F=!0;this.w.contentComplete()}load(){const a=this;return _.x(function*(){var b=a.m;const c=a.I;try{if(typeof c.adTagUrl!==_.Sf)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(),
15
- a.f;b=yield a.L.canPlay(!1);const d=yield a.L.canPlay(!0),e=new google.ima.AdsRequest;e.adTagUrl=c.adTagUrl;e.setAdWillAutoPlay(b);e.setAdWillPlayMuted(d);a.w.getSettings().setAutoPlayAdBreaks(!1);a.w.requestAds(e);return a.f})}start(a){const b=this;return _.x(function*(){b.a&&b.C&&!b.M?b.C.Gb()?yield xS(b):yield yS(b,a):yield a.play()})}o(){}l(){return!0}resume(){this.a&&this.a.resume()}pause(){this.a&&this.a.pause()}skip(){this.a&&this.a.skip()}getVolume(){return this.a?this.a.getVolume():1}setVolume(a){this.a&&
16
- this.a.setVolume(a)}getPosition(){if(!this.a||null===this.B)return-1;const a=this.a.getRemainingTime();return 0>a?0:this.B-a}h(){this.a&&(this.a.destroy(),this.a=null);vS(this);this.J.release();this.j&&(this.j.stop(),this.j=null);return Promise.resolve()}};CS.prototype.getPosition=CS.prototype.getPosition;CS.prototype.setVolume=CS.prototype.setVolume;CS.prototype.getVolume=CS.prototype.getVolume;CS.prototype.skip=CS.prototype.skip;CS.prototype.pause=CS.prototype.pause;CS.prototype.resume=CS.prototype.resume;var DS=class extends _.iv{constructor(){super();this.a=this.h=this.f=null}onPlayerCreated(a){if(zS())return a.onError(new _.I(1,9,1E4));this.f=_.Zo(_.Id,{"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(_.pa);this.a.getSettings().setPlayerVersion(_.da);this.a.getSettings().setAutoPlayAdBreaks(!0)}onPlayerWillDestroy(a){this.a&&
17
- (this.a.destroy(),this.a=null);this.h&&(this.h.destroy(),this.h=null);this.f&&(a.getSurface().removeElementFromContainer(this.f),this.f=null)}Vg(){return this.a}Tg(){return this.h}Dc(){return this.f}id(){return"ima"}};_.z("clpp.ima.ImaPlugin",DS);DS.prototype.getAdContainer=DS.prototype.Dc;DS.prototype.getAdDisplayContainer=DS.prototype.Tg;DS.prototype.getAdsLoader=DS.prototype.Vg;DS.Id="ima";DS.isSdkMissing=zS;_.Yq(new class{create(){return new DS}});_.Xo(new class{constructor(){this.f=new _.S(oS)}name(){return oS}a(a,b){return a.namespace()===_.ld?!1:zS()?(this.f.warn("IMA SDK is not loaded."),!1):!(!b||!b.ima)}create(a){return new CS(a)}});};f.call(g, window);
10
+ W.prototype.getAdManagerVersion=W.prototype.nb;W.prototype.getAdManagerName=W.prototype.lb;var eT=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 fT=class{constructor(a){this.a=a}getCuePoints(){return this.a}Fb(){return 0<=this.a.indexOf(0)||0===this.a.length}Eb(){return 0<=this.a.indexOf(-1)}};fT.prototype.hasPostroll=fT.prototype.Eb;fT.prototype.hasPreroll=fT.prototype.Fb;fT.prototype.getCuePoints=fT.prototype.getCuePoints;var gT=class{constructor(a){var b=a.Zc("ima");if(!b)throw Error("IMA plugin not created.");var c=b.Gc(),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.A=e;a=this.m.getConfiguration();a=_.$g(a.ima||{});this.I=a=_.Zg({disableCustomPlayback:!1},a);this.O=c;this.R=d;this.w=b;this.L=new _.xv;this.g=new _.S("clpp.ima");this.j=this.a=null;this.f=new _.hn;this.M=!1;this.J=new _.xt;this.za=new eT;
11
+ this.B=null;this.H=this.F=this.G=!1;this.K=this.C=null;c=this.J;d=google.ima.AdErrorEvent.Type.AD_ERROR;c.one(this.w,google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,this.hc.bind(this));c.on(this.w,d,this.fc.bind(this));c.on(this.m,_.be,this.ic.bind(this))}hc(a){this.a=a.getAdsManager(this.A,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 _.H(1,9,10002)),this.h()):(this.j=new _.vv(this.m.getSurface(),
12
+ (b,c,d)=>{this.a.resize(b,c,d?google.ima.ViewMode.FULLSCREEN:google.ima.ViewMode.NORMAL)}),a=this.a.getCuePoints(),this.C=new fT(a),this.m.trigger(new _.E(_.Ac,{adsTimeline:this.C})),WS(this));this.f.resolve()}fc(a){XS(this,a.getError());this.f.resolve()}kc(a){const b=this;return _.x(function*(){b.H=!0;if(VS(b)){b.K=b.m.getPosition();yield b.m.detach();var c=b.m;c.a&&c.a.stopForwardingEventsTo(c)}else yield b.m.pause(),_.xp(b.A,{visibility:_.he});YS(b,_.cc,a);b.j.start()})}Aa(){const a=this;return _.x(function*(){a.a.start()})}X(a){a.getAd().isLinear()?
13
+ YS(this,_.nc,a):(this.a.discardAdBreak(),this.G||(this.G=!0,this.m.play()))}aa(a){this.B=a.getAd().getDuration();YS(this,_.uc,a);this.m.getSurface().show(this.O)}Ma(a){a=a.getAdData();XS(this,a?a.adError:null);ZS(this)}Z(a){YS(this,_.qc,a)}Ga(a){YS(this,_.fc,a)}V(a){YS(this,_.ic,a)}ib(a){YS(this,_.oc,a)}fa(a){YS(this,_.yc,a)}Jb(a){YS(this,_.pc,a)}Kb(a){YS(this,_.rc,a)}S(a){this.pause();YS(this,_.gc,a)}da(a){YS(this,_.tc,a);ZS(this)}W(a){YS(this,_.mc,a)}Va(a){YS(this,_.hc,a);ZS(this)}nc(){const a=
14
+ this;return _.x(function*(){a.G=!0;if(VS(a)&&null!==a.K){var b=a.m;b.a&&b.a.forwardEventsTo(b);yield _.Nr(a.m);a.F||(yield a.m.seek(a.K))}else{if(!a.H)return a.m.play();$S(a)}a.H=!1;a.j&&a.j.stop();a.F||(yield a.m.play());YS(a,_.ec)})}ic(){this.F=!0;this.w.contentComplete()}load(){const a=this;return _.x(function*(){var b=a.m;const c=a.I;try{if(typeof c.adTagUrl!==_.Vf)throw new _.H(1,9,10001,{missingKeys:"adTagUrl"});}catch(f){return b.onError(f),a.f.resolve(),a.f}if(!c.adTagUrl)return a.f.resolve(),
15
+ a.f;b=yield a.L.canPlay(!1);const d=yield a.L.canPlay(!0),e=new google.ima.AdsRequest;e.adTagUrl=c.adTagUrl;e.setAdWillAutoPlay(b);e.setAdWillPlayMuted(d);a.w.getSettings().setAutoPlayAdBreaks(!1);a.w.requestAds(e);return a.f})}start(a){const b=this;return _.x(function*(){b.a&&b.C&&!b.M?b.C.Fb()?yield bT(b):yield cT(b,a):yield a.play()})}o(){}l(){return!0}resume(){this.a&&this.a.resume()}pause(){this.a&&this.a.pause()}skip(){this.a&&this.a.skip()}getVolume(){return this.a?this.a.getVolume():1}setVolume(a){this.a&&
16
+ this.a.setVolume(a)}getPosition(){if(!this.a||null===this.B)return-1;const a=this.a.getRemainingTime();return 0>a?0:this.B-a}h(){this.a&&(this.a.destroy(),this.a=null);$S(this);this.J.release();this.j&&(this.j.stop(),this.j=null);return Promise.resolve()}};gT.prototype.getPosition=gT.prototype.getPosition;gT.prototype.setVolume=gT.prototype.setVolume;gT.prototype.getVolume=gT.prototype.getVolume;gT.prototype.skip=gT.prototype.skip;gT.prototype.pause=gT.prototype.pause;gT.prototype.resume=gT.prototype.resume;var hT=class extends _.Fv{constructor(){super();this.a=this.h=this.f=null}onPlayerCreated(a){if(dT())return a.onError(new _.H(1,9,1E4));this.f=_.vp(_.Ld,{"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(_.qa);this.a.getSettings().setPlayerVersion(_.ea);this.a.getSettings().setAutoPlayAdBreaks(!0)}onPlayerWillDestroy(a){this.a&&
17
+ (this.a.destroy(),this.a=null);this.h&&(this.h.destroy(),this.h=null);this.f&&(a.getSurface().removeElementFromContainer(this.f),this.f=null)}eh(){return this.a}bh(){return this.h}Gc(){return this.f}id(){return"ima"}};_.z("clpp.ima.ImaPlugin",hT);hT.prototype.getAdContainer=hT.prototype.Gc;hT.prototype.getAdDisplayContainer=hT.prototype.bh;hT.prototype.getAdsLoader=hT.prototype.eh;hT.Id="ima";hT.isSdkMissing=dT;_.ur(new class{create(){return new hT}});_.tp(new class{constructor(){this.f=new _.S(TS)}name(){return TS}a(a,b){return a.namespace()===_.md?!1:dT()?(this.f.warn("IMA SDK is not loaded."),!1):!(!b||!b.ima)}create(a){return new gT(a)}});};f.call(g, window);