@vkontakte/videoplayer-interactive 1.0.14-beta.1 → 1.0.14-dev.1121b4e6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es2015.cjs.js +6 -6
- package/es2015.esm.js +6 -6
- package/es2018.cjs.js +6 -6
- package/es2018.esm.js +6 -6
- package/esnext.cjs.js +6 -6
- package/esnext.esm.js +6 -6
- package/evergreen.esm.js +6 -6
- package/package.json +3 -3
- package/types/modules/Interactives/Interactives.d.ts +2 -2
- package/types/utils/typeCheck.d.ts +0 -5
package/es2015.esm.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-interactive v1.0.14-
|
|
3
|
-
* Thu,
|
|
2
|
+
* @vkontakte/videoplayer-interactive v1.0.14-dev.1121b4e6.0
|
|
3
|
+
* Thu, 15 Aug 2024 19:01:31 GMT
|
|
4
4
|
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-14/doc/
|
|
5
5
|
*/
|
|
6
|
-
var Ga=Object.create;var mr=Object.defineProperty,Ua=Object.defineProperties,za=Object.getOwnPropertyDescriptor,Wa=Object.getOwnPropertyDescriptors,Ka=Object.getOwnPropertyNames,vt=Object.getOwnPropertySymbols,Qa=Object.getPrototypeOf,yr=Object.prototype.hasOwnProperty,Mi=Object.prototype.propertyIsEnumerable;var fr=(t,e,r)=>e in t?mr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,d=(t,e)=>{for(var r in e||(e={}))yr.call(e,r)&&fr(t,r,e[r]);if(vt)for(var r of vt(e))Mi.call(e,r)&&fr(t,r,e[r]);return t},x=(t,e)=>Ua(t,Wa(e));var Q=(t,e)=>{var r={};for(var i in t)yr.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&vt)for(var i of vt(t))e.indexOf(i)<0&&Mi.call(t,i)&&(r[i]=t[i]);return r};var p=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Ya=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ka(e))!yr.call(t,n)&&n!==r&&mr(t,n,{get:()=>e[n],enumerable:!(i=za(e,n))||i.enumerable});return t};var Xa=(t,e,r)=>(r=t!=null?Ga(Qa(t)):{},Ya(e||!t||!t.__esModule?mr(r,"default",{value:t,enumerable:!0}):r,t));var $=(t,e,r)=>(fr(t,typeof e!="symbol"?e+"":e,r),r),vr=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)};var a=(t,e,r)=>(vr(t,e,"read from private field"),r?r.call(t):e.get(t)),E=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},g=(t,e,r,i)=>(vr(t,e,"write to private field"),i?i.call(t,r):e.set(t,r),r);var Oi=(t,e,r,i)=>({set _(n){g(t,e,n,r)},get _(){return a(t,e,i)}}),k=(t,e,r)=>(vr(t,e,"access private method"),r);var A=(t,e,r)=>new Promise((i,n)=>{var s=c=>{try{o(r.next(c))}catch(h){n(h)}},l=c=>{try{o(r.throw(c))}catch(h){n(h)}},o=c=>c.done?i(c.value):Promise.resolve(c.value).then(s,l);o((r=r.apply(t,e)).next())});var ae=p((fn,mn)=>{"use strict";var Gt=function(t){return t&&t.Math==Math&&t};mn.exports=Gt(typeof globalThis=="object"&&globalThis)||Gt(typeof window=="object"&&window)||Gt(typeof self=="object"&&self)||Gt(typeof global=="object"&&global)||function(){return this}()||fn||Function("return this")()});var ge=p((Xd,yn)=>{"use strict";yn.exports=function(t){try{return!!t()}catch(e){return!0}}});var at=p((Zd,vn)=>{"use strict";var Ao=ge();vn.exports=!Ao(function(){var t=function(){}.bind();return typeof t!="function"||t.hasOwnProperty("prototype")})});var xn=p((Jd,Cn)=>{"use strict";var Mo=at(),En=Function.prototype,gn=En.apply,bn=En.call;Cn.exports=typeof Reflect=="object"&&Reflect.apply||(Mo?bn.bind(gn):function(){return bn.apply(gn,arguments)})});var _e=p((ep,Tn)=>{"use strict";var In=at(),Sn=Function.prototype,qr=Sn.call,Oo=In&&Sn.bind.bind(qr,qr);Tn.exports=In?Oo:function(t){return function(){return qr.apply(t,arguments)}}});var Dr=p((tp,_n)=>{"use strict";var wn=_e(),Lo=wn({}.toString),jo=wn("".slice);_n.exports=function(t){return jo(Lo(t),8,-1)}});var Hr=p((rp,Rn)=>{"use strict";var No=Dr(),Po=_e();Rn.exports=function(t){if(No(t)==="Function")return Po(t)}});var Ur=p((ip,Vn)=>{"use strict";var Gr=typeof document=="object"&&document.all,ko=typeof Gr=="undefined"&&Gr!==void 0;Vn.exports={all:Gr,IS_HTMLDDA:ko}});var be=p((np,Mn)=>{"use strict";var An=Ur(),$o=An.all;Mn.exports=An.IS_HTMLDDA?function(t){return typeof t=="function"||t===$o}:function(t){return typeof t=="function"}});var qe=p((sp,On)=>{"use strict";var Fo=ge();On.exports=!Fo(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!=7})});var zt=p((ap,Ln)=>{"use strict";var Bo=at(),Ut=Function.prototype.call;Ln.exports=Bo?Ut.bind(Ut):function(){return Ut.apply(Ut,arguments)}});var kn=p(Pn=>{"use strict";var jn={}.propertyIsEnumerable,Nn=Object.getOwnPropertyDescriptor,qo=Nn&&!jn.call({1:2},1);Pn.f=qo?function(e){var r=Nn(this,e);return!!r&&r.enumerable}:jn});var zr=p((cp,$n)=>{"use strict";$n.exports=function(t,e){return{enumerable:!(t&1),configurable:!(t&2),writable:!(t&4),value:e}}});var Bn=p((lp,Fn)=>{"use strict";var Do=_e(),Ho=ge(),Go=Dr(),Wr=Object,Uo=Do("".split);Fn.exports=Ho(function(){return!Wr("z").propertyIsEnumerable(0)})?function(t){return Go(t)=="String"?Uo(t,""):Wr(t)}:Wr});var Kr=p((hp,qn)=>{"use strict";qn.exports=function(t){return t==null}});var Qr=p((up,Dn)=>{"use strict";var zo=Kr(),Wo=TypeError;Dn.exports=function(t){if(zo(t))throw Wo("Can't call method on "+t);return t}});var Gn=p((dp,Hn)=>{"use strict";var Ko=Bn(),Qo=Qr();Hn.exports=function(t){return Ko(Qo(t))}});var ot=p((pp,Wn)=>{"use strict";var Un=be(),zn=Ur(),Yo=zn.all;Wn.exports=zn.IS_HTMLDDA?function(t){return typeof t=="object"?t!==null:Un(t)||t===Yo}:function(t){return typeof t=="object"?t!==null:Un(t)}});var Yr=p((fp,Kn)=>{"use strict";Kn.exports={}});var Jr=p((mp,Yn)=>{"use strict";var Xr=Yr(),Zr=ae(),Xo=be(),Qn=function(t){return Xo(t)?t:void 0};Yn.exports=function(t,e){return arguments.length<2?Qn(Xr[t])||Qn(Zr[t]):Xr[t]&&Xr[t][e]||Zr[t]&&Zr[t][e]}});var Zn=p((yp,Xn)=>{"use strict";var Zo=_e();Xn.exports=Zo({}.isPrototypeOf)});var es=p((vp,Jn)=>{"use strict";Jn.exports=typeof navigator!="undefined"&&String(navigator.userAgent)||""});var os=p((gp,as)=>{"use strict";var ss=ae(),ei=es(),ts=ss.process,rs=ss.Deno,is=ts&&ts.versions||rs&&rs.version,ns=is&&is.v8,re,Wt;ns&&(re=ns.split("."),Wt=re[0]>0&&re[0]<4?1:+(re[0]+re[1]));!Wt&&ei&&(re=ei.match(/Edge\/(\d+)/),(!re||re[1]>=74)&&(re=ei.match(/Chrome\/(\d+)/),re&&(Wt=+re[1])));as.exports=Wt});var ti=p((bp,ls)=>{"use strict";var cs=os(),Jo=ge(),ec=ae(),tc=ec.String;ls.exports=!!Object.getOwnPropertySymbols&&!Jo(function(){var t=Symbol();return!tc(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&cs&&cs<41})});var ri=p((Ep,hs)=>{"use strict";var rc=ti();hs.exports=rc&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var ii=p((Cp,us)=>{"use strict";var ic=Jr(),nc=be(),sc=Zn(),ac=ri(),oc=Object;us.exports=ac?function(t){return typeof t=="symbol"}:function(t){var e=ic("Symbol");return nc(e)&&sc(e.prototype,oc(t))}});var ps=p((xp,ds)=>{"use strict";var cc=String;ds.exports=function(t){try{return cc(t)}catch(e){return"Object"}}});var ni=p((Ip,fs)=>{"use strict";var lc=be(),hc=ps(),uc=TypeError;fs.exports=function(t){if(lc(t))return t;throw uc(hc(t)+" is not a function")}});var ys=p((Sp,ms)=>{"use strict";var dc=ni(),pc=Kr();ms.exports=function(t,e){var r=t[e];return pc(r)?void 0:dc(r)}});var gs=p((Tp,vs)=>{"use strict";var si=zt(),ai=be(),oi=ot(),fc=TypeError;vs.exports=function(t,e){var r,i;if(e==="string"&&ai(r=t.toString)&&!oi(i=si(r,t))||ai(r=t.valueOf)&&!oi(i=si(r,t))||e!=="string"&&ai(r=t.toString)&&!oi(i=si(r,t)))return i;throw fc("Can't convert object to primitive value")}});var Es=p((wp,bs)=>{"use strict";bs.exports=!0});var Is=p((_p,xs)=>{"use strict";var Cs=ae(),mc=Object.defineProperty;xs.exports=function(t,e){try{mc(Cs,t,{value:e,configurable:!0,writable:!0})}catch(r){Cs[t]=e}return e}});var ws=p((Rp,Ts)=>{"use strict";var yc=ae(),vc=Is(),Ss="__core-js_shared__",gc=yc[Ss]||vc(Ss,{});Ts.exports=gc});var Vs=p((Vp,Rs)=>{"use strict";var bc=Es(),_s=ws();(Rs.exports=function(t,e){return _s[t]||(_s[t]=e!==void 0?e:{})})("versions",[]).push({version:"3.31.0",mode:bc?"pure":"global",copyright:"\xA9 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.31.0/LICENSE",source:"https://github.com/zloirock/core-js"})});var ci=p((Ap,As)=>{"use strict";var Ec=Qr(),Cc=Object;As.exports=function(t){return Cc(Ec(t))}});var Kt=p((Mp,Ms)=>{"use strict";var xc=_e(),Ic=ci(),Sc=xc({}.hasOwnProperty);Ms.exports=Object.hasOwn||function(e,r){return Sc(Ic(e),r)}});var Ls=p((Op,Os)=>{"use strict";var Tc=_e(),wc=0,_c=Math.random(),Rc=Tc(1 .toString);Os.exports=function(t){return"Symbol("+(t===void 0?"":t)+")_"+Rc(++wc+_c,36)}});var Ps=p((Lp,Ns)=>{"use strict";var Vc=ae(),Ac=Vs(),js=Kt(),Mc=Ls(),Oc=ti(),Lc=ri(),De=Vc.Symbol,li=Ac("wks"),jc=Lc?De.for||De:De&&De.withoutSetter||Mc;Ns.exports=function(t){return js(li,t)||(li[t]=Oc&&js(De,t)?De[t]:jc("Symbol."+t)),li[t]}});var Bs=p((jp,Fs)=>{"use strict";var Nc=zt(),ks=ot(),$s=ii(),Pc=ys(),kc=gs(),$c=Ps(),Fc=TypeError,Bc=$c("toPrimitive");Fs.exports=function(t,e){if(!ks(t)||$s(t))return t;var r=Pc(t,Bc),i;if(r){if(e===void 0&&(e="default"),i=Nc(r,t,e),!ks(i)||$s(i))return i;throw Fc("Can't convert object to primitive value")}return e===void 0&&(e="number"),kc(t,e)}});var hi=p((Np,qs)=>{"use strict";var qc=Bs(),Dc=ii();qs.exports=function(t){var e=qc(t,"string");return Dc(e)?e:e+""}});var Gs=p((Pp,Hs)=>{"use strict";var Hc=ae(),Ds=ot(),ui=Hc.document,Gc=Ds(ui)&&Ds(ui.createElement);Hs.exports=function(t){return Gc?ui.createElement(t):{}}});var di=p((kp,Us)=>{"use strict";var Uc=qe(),zc=ge(),Wc=Gs();Us.exports=!Uc&&!zc(function(){return Object.defineProperty(Wc("div"),"a",{get:function(){return 7}}).a!=7})});var Ks=p(Ws=>{"use strict";var Kc=qe(),Qc=zt(),Yc=kn(),Xc=zr(),Zc=Gn(),Jc=hi(),el=Kt(),tl=di(),zs=Object.getOwnPropertyDescriptor;Ws.f=Kc?zs:function(e,r){if(e=Zc(e),r=Jc(r),tl)try{return zs(e,r)}catch(i){}if(el(e,r))return Xc(!Qc(Yc.f,e,r),e[r])}});var Ys=p((Fp,Qs)=>{"use strict";var rl=ge(),il=be(),nl=/#|\.prototype\./,ct=function(t,e){var r=al[sl(t)];return r==cl?!0:r==ol?!1:il(e)?rl(e):!!e},sl=ct.normalize=function(t){return String(t).replace(nl,".").toLowerCase()},al=ct.data={},ol=ct.NATIVE="N",cl=ct.POLYFILL="P";Qs.exports=ct});var Js=p((Bp,Zs)=>{"use strict";var Xs=Hr(),ll=ni(),hl=at(),ul=Xs(Xs.bind);Zs.exports=function(t,e){return ll(t),e===void 0?t:hl?ul(t,e):function(){return t.apply(e,arguments)}}});var ta=p((qp,ea)=>{"use strict";var dl=qe(),pl=ge();ea.exports=dl&&pl(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!=42})});var ia=p((Dp,ra)=>{"use strict";var fl=ot(),ml=String,yl=TypeError;ra.exports=function(t){if(fl(t))return t;throw yl(ml(t)+" is not an object")}});var aa=p(sa=>{"use strict";var vl=qe(),gl=di(),bl=ta(),Qt=ia(),na=hi(),El=TypeError,pi=Object.defineProperty,Cl=Object.getOwnPropertyDescriptor,fi="enumerable",mi="configurable",yi="writable";sa.f=vl?bl?function(e,r,i){if(Qt(e),r=na(r),Qt(i),typeof e=="function"&&r==="prototype"&&"value"in i&&yi in i&&!i[yi]){var n=Cl(e,r);n&&n[yi]&&(e[r]=i.value,i={configurable:mi in i?i[mi]:n[mi],enumerable:fi in i?i[fi]:n[fi],writable:!1})}return pi(e,r,i)}:pi:function(e,r,i){if(Qt(e),r=na(r),Qt(i),gl)try{return pi(e,r,i)}catch(n){}if("get"in i||"set"in i)throw El("Accessors not supported");return"value"in i&&(e[r]=i.value),e}});var ca=p((Gp,oa)=>{"use strict";var xl=qe(),Il=aa(),Sl=zr();oa.exports=xl?function(t,e,r){return Il.f(t,e,Sl(1,r))}:function(t,e,r){return t[e]=r,t}});var ua=p((Up,ha)=>{"use strict";var Yt=ae(),Tl=xn(),wl=Hr(),_l=be(),Rl=Ks().f,Vl=Ys(),He=Yr(),Al=Js(),Ge=ca(),la=Kt(),Ml=function(t){var e=function(r,i,n){if(this instanceof e){switch(arguments.length){case 0:return new t;case 1:return new t(r);case 2:return new t(r,i)}return new t(r,i,n)}return Tl(t,this,arguments)};return e.prototype=t.prototype,e};ha.exports=function(t,e){var r=t.target,i=t.global,n=t.stat,s=t.proto,l=i?Yt:n?Yt[r]:(Yt[r]||{}).prototype,o=i?He:He[r]||Ge(He,r,{})[r],c=o.prototype,h,m,S,v,I,T,R,_,f;for(v in e)h=Vl(i?v:r+(n?".":"#")+v,t.forced),m=!h&&l&&la(l,v),T=o[v],m&&(t.dontCallGetSet?(f=Rl(l,v),R=f&&f.value):R=l[v]),I=m&&R?R:e[v],!(m&&typeof T==typeof I)&&(t.bind&&m?_=Al(I,Yt):t.wrap&&m?_=Ml(I):s&&_l(I)?_=wl(I):_=I,(t.sham||I&&I.sham||T&&T.sham)&&Ge(_,"sham",!0),Ge(o,v,_),s&&(S=r+"Prototype",la(He,S)||Ge(He,S,{}),Ge(He[S],v,I),t.real&&c&&(h||!c[v])&&Ge(c,v,I)))}});var pa=p((zp,da)=>{"use strict";var Ol=Math.ceil,Ll=Math.floor;da.exports=Math.trunc||function(e){var r=+e;return(r>0?Ll:Ol)(r)}});var vi=p((Wp,fa)=>{"use strict";var jl=pa();fa.exports=function(t){var e=+t;return e!==e||e===0?0:jl(e)}});var ya=p((Kp,ma)=>{"use strict";var Nl=vi(),Pl=Math.min;ma.exports=function(t){return t>0?Pl(Nl(t),9007199254740991):0}});var ga=p((Qp,va)=>{"use strict";var kl=ya();va.exports=function(t){return kl(t.length)}});var Ea=p((Yp,ba)=>{"use strict";ba.exports=function(){}});var Ca=p(()=>{"use strict";var $l=ua(),Fl=ci(),Bl=ga(),ql=vi(),Dl=Ea();$l({target:"Array",proto:!0},{at:function(e){var r=Fl(this),i=Bl(r),n=ql(e),s=n>=0?n:i+n;return s<0||s>=i?void 0:r[s]}});Dl("at")});var Ia=p((Jp,xa)=>{"use strict";var Hl=Jr();xa.exports=Hl});var Ta=p((ef,Sa)=>{"use strict";Ca();var Gl=Ia();Sa.exports=Gl("Array","at")});var _a=p((tf,wa)=>{"use strict";var Ul=Ta();wa.exports=Ul});var Va=p((rf,Ra)=>{"use strict";var zl=_a();Ra.exports=zl});var Li="1.0.14-beta.1";function gr(t,e=1){let r="0",i="0",n="0";return t.length===4?(r="0x"+t[1]+t[1],i="0x"+t[2]+t[2],n="0x"+t[3]+t[3]):t.length===7&&(r="0x"+t[1]+t[2],i="0x"+t[3]+t[4],n="0x"+t[5]+t[6]),`rgba(${+r},${+i},${+n},${e})`}var H="SDK_NAME",Za="SDK_NAME-controls-container",gt=()=>document.querySelector(`.${Za}`),ki=.4,Y={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0},ji={top:"flex-start",bottom:"flex-end",center:"center"},Ni={start:"flex-start",end:"flex-end",center:"center"},Pi={start:"left",end:"right",center:"center"},bt=({target:t,props:e})=>{var r,i,n,s,l,o;t.style.alignItems=(i=ji[(r=e==null?void 0:e.text)==null?void 0:r.gravityVertical])!=null?i:ji.center,t.style.justifyContent=(s=Ni[(n=e==null?void 0:e.text)==null?void 0:n.gravityHorizontal])!=null?s:Ni.center,t.style.textAlign=(o=Pi[(l=e==null?void 0:e.text)==null?void 0:l.alignment])!=null?o:Pi.start},Et=({target:t,props:e,fallback:r,dependsOn:i})=>{var n,s,l,o,c,h;t.style.color=(s=(n=e==null?void 0:e.text)==null?void 0:n.color)!=null?s:r.textColor,t.style.fontSize=`calc(${i.height} * ${(o=(l=e==null?void 0:e.text)==null?void 0:l.size)!=null?o:r.textSize})`,t.textContent=(h=(c=e==null?void 0:e.text)==null?void 0:c.value)!=null?h:r.textContent},Ct=({target:t,props:e,fallback:r})=>{var i,n,s,l;t.style.backgroundColor=gr((n=(i=e==null?void 0:e.background)==null?void 0:i.color)!=null?n:r.backgroundColor,(l=(s=e==null?void 0:e.background)==null?void 0:s.alpha)!=null?l:r.backgroundAlpha)},xt=({target:t,props:e,fallback:r,dependsOn:i})=>{var n,s,l,o,c,h,m,S,v,I,T;t.style.border=`calc(${i.height} * ${(l=(s=(n=e==null?void 0:e.shape)==null?void 0:n.border)==null?void 0:s.width)!=null?l:r.borderWidth}) solid ${gr((h=(c=(o=e==null?void 0:e.shape)==null?void 0:o.border)==null?void 0:c.color)!=null?h:r.borderColor,(v=(S=(m=e==null?void 0:e.shape)==null?void 0:m.border)==null?void 0:S.alpha)!=null?v:r.borderAlpha)}`,t.style.borderRadius=`calc(${i.height} * ${(T=(I=e==null?void 0:e.shape)==null?void 0:I.roundCorners)!=null?T:r.roundCorners})`},Ne=({target:t,layoutParams:e,fallback:r})=>{t.style.transform=`rotate(${-e.angle}rad)`};var br="int",Pe={AREA:`${br}_area`,TEXT:`${br}_text`,BUTTON:`${br}_bttn`};var ye=class{constructor(e){this.control=e}createView(e){var n;let r=document.createElement("div");r.classList.add(`${H}-control-container-${this.control.id}`),e(r,this.control.layoutParams);let i=((n=this.control.layoutParams.innerSizesDependOn)!=null?n:Y.innerSizesDependOn)==="self"?{height:r.style.height,width:r.style.width}:{height:"var(--interactive-content-height)",width:"var(--interactive-content-width)"};return{controlContainerEl:r,dependsOn:i}}setEvents(e,r){e&&this.control.events.forEach(i=>{switch(i.type.trim().toLowerCase()){case"onclick":e.addEventListener("click",s=>{s.stopPropagation(),r&&r({action:i.action,controlId:this.control.id,controlType:this.control.type})});break;default:break}})}getElement(){return document.querySelector(`.${H}-control-container-${this.control.id}`)}};var It=t=>{if(t.type.trim().toLowerCase()==="area")return new Er(t)},Er=class extends ye{constructor(e){super(e)}createView({parent:e,layoutFn:r}){let{dependsOn:i,controlContainerEl:n}=super.createView(r),s=document.createElement("button");return s.classList.add(`${H}-${this.control.id}`),s.setAttribute("data-testid",Pe.AREA),s.style.display="flex",s.style.width="100%",s.style.height="100%",s.style.cursor="pointer",s.type="button",Ct({target:s,props:this.control.props,fallback:x(d({},Y),{backgroundColor:"transparent"})}),xt({target:s,props:this.control.props,fallback:x(d({},Y),{borderAlpha:0}),dependsOn:i}),Ne({target:s,layoutParams:this.control.layoutParams,fallback:Y}),n.append(s),e.append(n),this.controlEl=s,n}disable(){this.controlEl&&(this.controlEl.style.cursor="default")}enable(){this.controlEl&&(this.controlEl.style.cursor="pointer")}getElement(){return document.querySelector(`.${H}-${this.control.id}`)}};var St=()=>{let t=document.createElement("span");return t.style.display="inline-block",t.style.whiteSpace="pre",t.style.overflow="hidden",t.style.textOverflow="ellipsis",t.style.maxWidth="100%",t.style.maxHeight="100%",t};var Tt=t=>{if(t.type.trim().toLowerCase()==="button")return new Cr(t)},Cr=class extends ye{constructor(e){super(e)}createView({parent:e,layoutFn:r}){let{dependsOn:i,controlContainerEl:n}=super.createView(r),s=document.createElement("button");s.type="button",s.classList.add(`${H}-${this.control.id}`),s.setAttribute("data-testid",Pe.BUTTON),s.style.display="flex",s.style.width="100%",s.style.height="100%",s.style.cursor="pointer",s.style.fontFamily="inherit";let l=St();return Ne({target:s,layoutParams:this.control.layoutParams,fallback:Y}),Ct({target:s,props:this.control.props,fallback:Y}),xt({target:s,props:this.control.props,fallback:Y,dependsOn:i}),bt({target:s,props:this.control.props}),Et({target:l,props:this.control.props,fallback:Y,dependsOn:i}),s.append(l),n.append(s),e.append(n),this.controlEl=s,n}disable(){this.controlEl&&(this.controlEl.style.cursor="default")}enable(){this.controlEl&&(this.controlEl.style.cursor="pointer")}getElement(){return document.querySelector(`.${H}-${this.control.id}`)}};var $i=t=>{if(t.type.trim().toLowerCase()==="text")return new xr(t)},xr=class extends ye{constructor(e){super(e)}createView({parent:e,layoutFn:r}){let{dependsOn:i,controlContainerEl:n}=super.createView(r),s=document.createElement("div");s.classList.add(`${H}-${this.control.id}`),s.setAttribute("data-testid",Pe.TEXT),s.style.display="flex",s.style.width="100%",s.style.height="100%",s.style.fontFamily="inherit";let l=St();return Ne({target:s,layoutParams:this.control.layoutParams,fallback:Y}),bt({target:s,props:this.control.props}),Et({target:l,props:this.control.props,fallback:Y,dependsOn:i}),s.append(l),n.append(s),e.append(n),this.controlEl=s,n}disable(){}enable(){}getElement(){return document.querySelector(`.${H}-${this.control.id}`)}};var Ir=class{constructor(e){this.layout=e}},Fi=t=>{if(t.type.trim().toLowerCase()==="relative")return new Ye(t)},Ye=class extends Ir{constructor(e){super(e)}setContainerLayout(e){e.style.position="relative"}setControlLayout(e,r){e.style.position="absolute",e.style.width=`calc(var(--interactive-content-width) * ${r.width})`,e.style.height=`calc(var(--interactive-content-height) * ${r.height})`,e.style.left=`calc(var(--interactive-content-width) * ${r.x} + ((var(--interactive-width) - var(--interactive-content-width)) / 2))`,e.style.top=`calc(var(--interactive-content-height) * ${r.y} + ((var(--interactive-height) - var(--interactive-content-height)) / 2))`}};var ke,wt,_t,Bi,$e=class{constructor(e){E(this,ke);E(this,_t);this.container=e,this.factories=new Map,k(this,ke,wt).call(this)}addControlFactory(e,r){this.factories.set(e.trim().toLowerCase(),r),k(this,ke,wt).call(this)}removeControlFactory(e){this.factories.delete(e.trim().toLowerCase()),k(this,ke,wt).call(this)}};ke=new WeakSet,wt=function(){this.controls=k(this,_t,Bi).call(this)},_t=new WeakSet,Bi=function(){var e;return(e=this.container.controls)==null?void 0:e.reduce((r,i)=>{let n=i.type.trim().toLowerCase(),s=this.factories.get(n);return s?[...r,s(i)]:[...r]},[])};var Rt=(t,e)=>{if(t.type.trim().toLowerCase()==="choice")return new Sr(t,e)},Sr=class extends $e{constructor(e,r){super(e),this.rootElement=r!=null?r:gt(),this.layout=new Ye(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",Tt),this.addControlFactory("text",$i),this.addControlFactory("area",It)}createView(e){let r=document.createElement("div");return r.classList.add(`${H}-${this.container.id}`),this.layout.setContainerLayout(r),this.controls.forEach(i=>{let n=i.createView({parent:r,layoutFn:this.layout.setControlLayout});i.setEvents(n,e)}),this.rootElement.append(r),this.isRemoved=!1,r}hide(){let e=this.getElement();e&&(e.style.visibility="hidden")}show(){let e=this.getElement();e&&(e.style.visibility="visible")}enable(){let e=this.getElement();e&&(this.controls.forEach(r=>r.enable()),e.style.opacity=1,this.isDisabled=!1)}disable(){let e=this.getElement();e&&(this.controls.forEach(r=>r.disable()),e.style.opacity=ki,this.isDisabled=!0)}removeView(){var e;this.isRemoved||((e=this.getElement())==null||e.remove(),this.isRemoved=!0)}getElement(){return this.rootElement.querySelector(`.${H}-${this.container.id}`)}};import{Subject as Xl,ValueSubject as ne,Observable as Na,once as Zl,Subscription as Jl,getCurrentBrowser as eh,CurrentClientBrowser as th,combine as rh}from"@vkontakte/videoplayer-shared";import{loadVKLangPack as eo}from"@vkontakte/videoplayer-shared";function Vt(t,e){let r;return(...i)=>{clearTimeout(r),r=setTimeout(()=>t(...i),e)}}var Xe={Object:"Object",String:"String",Array:"Array",Number:"Number",Function:"Function",Boolean:"Boolean"},Se=(t,e)=>Object.prototype.toString.call(t)===`[object ${e}]`,Ze=t=>Se(t,Xe.Object),At=t=>Se(t,Xe.String),Mt=t=>Se(t,Xe.Array),Ot=t=>Se(t,Xe.Number),qi=t=>Se(t,Xe.Function);var Tr=t=>Ot(t)&&!isNaN(t);var Te=t=>Ze(t)&&Object.keys(t).length===0,wr=t=>Mt(t)&&!t.length;var Je=(t,e)=>At(t)&&(e?t.trim():t).length;var _r=window.navigator.userAgent.toLowerCase(),Wh=/ipad|iphone|ipod/.test(_r),Di=/mobi/i.test(_r),Kh=_r.indexOf("android")>-1&&Di,Ja=!Di,Qh=window.safari!==void 0&&Ja;var Hi="video_interactive",Gi="videoint";var to=250,et=class{constructor(e){$(this,"onResize",e=>{this.isReady&&(!e[0].contentRect.width||!e[0].contentRect.height||(this.lastZoomInfo&&this.ngEditor.zoomTo(this.getNextPoint()),this.ngEditorSize={width:e[0].contentRect.width,height:e[0].contentRect.height}))});$(this,"handleChapterChange",e=>{var r;if(this.isReady){if(this.isHidden||this.hide(),!(e!=null&&e.id)){(r=this.onError)==null||r.call(this,"Id is not found"),console.error("Id is not found");return}this.visitedChapterIds.add(e.id),this.ngEditor.selectChapter(e.id),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId=e.id,this.lastZoomInfo=void 0}});$(this,"handleManifestChange",(i,...n)=>A(this,[i,...n],function*(e,r=[]){var s;if(!Ot(e.graph.edit.chapters[0].x)){this.isReady=!1,(s=this.onError)==null||s.call(this,"Can't show graph"),console.error("Can't show graph");return}if(this.lastZoomInfo=void 0,!this.ngEditor){let l;try{l=yield eo(this.lang,Hi,Gi)}catch(c){console.log("Unable to load graph language pack")}let{GraphEditor:o}=yield import("@interactiveplatform/movika-graph-editor");this.ngEditor=new o(this.graphWrapperElement,{mode:"read",lang:this.lang,translation:l}),this.ngEditor.on("control",({name:c,chapterId:h})=>{c==="openPreview"&&this.onOpenPreviewClick(h)}),this.ngEditor.on("zoomEnd",c=>{this.lastZoomInfo=d({},c)})}this.visitedChapterIds=new Set(r),e.metadata.id!==this.currentManifestId?(this.ngEditor.update(e),this.currentManifestId=e.metadata.id):this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.isReady=!0}));this.init(e)}init({root:e,onOpenPreviewClick:r,onError:i,lang:n,visitedChapters:s=[]}){this.isHidden=!0,this.currentManifestId=void 0,this.currentChapterId=void 0,this.visitedChapterIds=new Set(s),this.onOpenPreviewClick=r,this.onError=i,this.lang=n!=null?n:"ru",this.zoom=.7,this.isReady=!1,this.lastZoomInfo=void 0,this.ngEditorSize=void 0,this.ngEditor=void 0,this.graphWrapperElement=ro(e),this.resizeObserver=new ResizeObserver(Vt(this.onResize,to)),this.resizeObserver.observe(this.graphWrapperElement)}getNextPoint(e=this.ngEditorSize){return[(this.lastZoomInfo.x-e.width/2)/this.lastZoomInfo.value*-1,(this.lastZoomInfo.y-e.height/2)/this.lastZoomInfo.value*-1]}setVisitedChapters(e){this.visitedChapterIds=new Set([...this.visitedChapterIds,...e]),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds))}updateVideosInfo(e){this.ngEditor.updateVideosInfo(e)}show(){!this.ngEditor||!this.isReady||(this.graphWrapperElement.style.display="block",this.lastZoomInfo||this.ngEditor.focusChapter(this.currentChapterId),this.isHidden=!1)}hide(){this.graphWrapperElement.style.display="none",this.isHidden=!0}destroy(){var e,r;this.hide(),this.resizeObserver.disconnect(),(e=this.ngEditor)==null||e.setVisitedChapters([]),this.onOpenPreviewClick=void 0,(r=this.ngEditor)==null||r.dispose(),this.graphWrapperElement.remove(),this.isReady=!1}};function ro(t){let e=document.createElement("div");return e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.height="100%",e.style.width="100%",e.style.display="none",t.append(e),e}var Rr=()=>{let t=[],e=null;return{setPlayer:l=>{e=l},setContainers:l=>{t=l},deleteContainer:l=>{t=t.filter(o=>o.id!==l)},getNextInteractiveTime:(l=3e3)=>{if(!t.length||e===null)return null;let o=-1,c=!1,h=Math.round(e.info.position$.getValue()*1e3);for(let m of t){let S=m.startTime-l;if(S<=h&&(h<=m.endTime||m.endTime===null)){c=!0;break}h<S&&(o=o===-1?S:Math.min(o,S))}return!c&&o!==-1?o:null}}};var ve=(t="",e="")=>{t=t.split("."),e=e.split(".");let r=0;for(let i=0;i<Math.max(t.length,e.length)&&!r;i++)t[i]>e[i]?r=1:t[i]<e[i]?r=-1:r=0;return r};import{v4 as io}from"uuid";var no="3.1",Ui={default:"setNextBranch",random:"setRandomBranch",weightlessRandom:"setWeightlessRandomBranch",max:"setMaxWeightBranch",min:"setMinWeightBranch"},so={type:"onSuspense",action:{type:"continuePlayback",args:{shouldOpenNow:!0,isDetachContainer:!0}}},zi=t=>{let e=[];for(let l of t.chapters){let o,c=[];for(let r of l.branches){let i=r,{isDefault:S}=i,v=Q(i,["isDefault"]);S&&(o=v.id),c.push(v)}let h=[],m=[];for(let n of l.containers){let s=n,{fallbackStrategy:S}=s,v=Q(s,["fallbackStrategy"]);let I=!!v.endTime,T=[so];switch(S){case"await":I?T=[]:h=[];break;case"default":{let R={type:"onSuspense",action:{type:Ui.default,args:{branchId:o,shouldOpenNow:!I,isDetachContainer:!0}}};I?T=[R]:h=[R];break}case"random":case"weightlessRandom":case"max":case"min":{let R={type:"onSuspense",action:{type:Ui[S],args:{}}};I?T=[R]:h=[R];break}}for(let R of v.controls)m.push(x(d({},v),{controls:[d({},R)],id:io(),events:T}))}e.push(x(d({},l),{containers:m,events:h,branches:c}))}return t.metadata.version=no,t.metadata.updated=new Date().toISOString(),x(d({},t),{chapters:e})};var ao="3.2",Wi=t=>{if(!t.media){let e=t.metadata,{media:r}=e,i=Q(e,["media"]);return x(d({},t),{metadata:x(d({},i),{version:ao}),media:r})}return t};var oo="3.3",co=(t=[])=>({edit:{chapters:t},view:{}}),Ki={type:"onSuspense",action:{type:"expect",args:{shouldOpenNow:!0,isDetachContainer:!0}}},Qi=t=>{var n;let e=[],r=[];for(let s of t.chapters){let i=s,{id:l,x:o,y:c}=i,h=Q(i,["id","x","y"]),m=h.containers.map(S=>{var v;return x(d({},S),{controls:S.controls.map(_=>{var f=_,{subtype:I,type:T}=f,R=Q(f,["subtype","type"]);return x(d({},R),{type:I!=null?I:T})}),events:(v=S.events)!=null&&v.length?S.events:[Ki]})});e.push(x(d({id:l},h),{containers:m,events:(n=h.events)!=null&&n.length?h.events:[Ki]})),r.push({id:l,x:o,y:c})}return x(d({},t),{chapters:e,graph:co(r),metadata:x(d({},t.metadata),{version:oo})})};var lo=[{version:"3.0",migrate:zi},{version:"3.1",migrate:Wi},{version:"3.2",migrate:Qi}],Vr=t=>lo.reduce((e,r)=>ve(e.metadata.version,r.version)?e:r.migrate(e),t);var Su=Object.freeze({Choice:"Choice",TextInput:"TextInput"}),Yi=Object.freeze({Button:"Button",Area:"Area",Text:"Text"}),Tu=Object.freeze({onClick:"onClick",onSuspense:"onSuspense"}),P=Object.freeze({openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"}),Ar=(s=>(s.GO_NEXT_BUTTON="GO_NEXT_BUTTON",s.GO_NEXT_AREA="GO_NEXT_AREA",s.WATCH_AGAIN="WATCH_AGAIN",s.OPEN_GRAPH="OPEN_GRAPH",s.CLOSE_GRAPH="CLOSE_GRAPH",s))(Ar||{});var Xi={metadata:"Object",chapters:"Array"},ho="3.0.0",uo="3.3.0",Lt=t=>{let e=ve(t,ho);return e===-1?!1:e===0?!0:ve(t,uo)!==1},Zi=t=>{if(!Ze(t))return!1;for(let e in Xi)if(!t[e]||!Se(t[e],Xi[e]))return!1;return Lt(t.metadata.version)},jt=t=>t.type===Yi.Text;var V=class{constructor(e,r,...i){this.severity=e,this.category=r,this.data=i}toString(){return`SDK_NAME ERROR ${JSON.stringify(this,null," ")}`}};$(V,"Severity",{RECOVERABLE:1,CRITICAL:2}),$(V,"Category",{VIDEO:0,INTERACTIVES:1,GRAPH:2,MANIFEST:3,LOADERS:4,HISTORY:5,SEAMLESS:6});var Fe=class{constructor(){$(this,"listeners",{})}addListener(e,r){return this.listeners[e]=this.listeners[e]||[],this.listeners[e].push(r),this}on(e,r){return this.addListener(e,r)}once(e,r){this.listeners[e]=this.listeners[e]||[];let i=()=>{r(),this.off(e,i)};return this.listeners[e].push(i),this}off(e,r){return this.removeListener(e,r)}reset(){this.listeners={}}removeListener(e,r){let i=this.listeners[e];if(!i)return this;for(let n=i.length;n>0;n--)if(i[n]===r){i.splice(n,1);break}return this}emit(e,...r){let i=this.listeners[e];return i?(i.forEach(n=>{n(...r)}),!0):!1}listenerCount(e){return(this.listeners[e]||[]).length}rawListeners(e){return this.listeners[e]}};var Nt=class{constructor(e){$(this,"addFn",(e,r=!1)=>{qi(e)&&(this.fns.push(e),r&&this.updateFn())});$(this,"removeFn",(e,r=!1)=>{this.fns=this.fns.filter(i=>i!==e),r&&this.updateFn()});$(this,"updateFn",()=>{this.fn=()=>{this.fns.forEach(e=>e()),this.raf&&this.forceRequestAnimation()}});$(this,"forceRequestAnimation",()=>{this.fn&&(this.raf=requestAnimationFrame(this.fn))});$(this,"requestAnimation",()=>{this.raf||this.forceRequestAnimation()});$(this,"cancelAnimation",()=>{cancelAnimationFrame(this.raf),this.raf=void 0});this.raf,this.fn,this.fns=[],this.addFn(e)}release(){this.cancelAnimation(),this.fn=void 0,this.fns=[]}};import{ValueSubject as bo}from"@vkontakte/videoplayer-shared";var Pt=class{constructor(e){var r,i;this.loaders={chapterLoaders:(r=e==null?void 0:e.chapterLoaders)!=null?r:[],manifestLoaders:(i=e==null?void 0:e.manifestLoaders)!=null?i:[]}}exec(e,r){return A(this,null,function*(){return po(...this.loaders[e])(r)})}};function po(...t){return function(r){return A(this,null,function*(){let i=[...t];for(;i.length>0;)r=yield i.shift()(r);return r})}}function tt(t,e,r){return t?x(d({},t),{[e]:t[e]?[r,...t[e]]:[r]}):{[e]:[r]}}function kt(n){var s=n,{actions:t,errors:e,chapterId:r}=s,i=Q(s,["actions","errors","chapterId"]);if(r){let l=t.getManifest(),o=t.getChapter(l.chapters,r);if(o){let c=t.getMedia(l.media,o.videoId),h=t.getGraph(l.graph,o.id);return c?x(d({},i),{actions:t,errors:e,result:{chapter:o,media:c,graph:h}}):x(d({},i),{errors:tt(e,kt.name,"Could not find media"),actions:t})}}return x(d({},i),{errors:tt(e,kt.name,"Could not find chapter"),actions:t})}var fo=t=>A(void 0,null,function*(){try{let e,r;if(Ze(t))e=t;else if(At(t)){r=new URL(t).href;let n=yield fetch(r);if(!n.ok)return{};e=yield n.json()}else return{};if(!Zi(e))return{};let i=e.metadata.media;if(At(i)&&!e.media)try{let n;r?n=new URL(i,r).href:(n=new URL(i).href,r=n);let s=yield fetch(n);if(!s.ok)throw new Error;e.metadata.media=yield s.json()}catch(n){return vo(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:r}}catch(e){return{}}});function Ji(t){return A(this,null,function*(){let{manifest:e,manifestURL:r}=yield fo(t),i=Vr(e);return i.media=mo(i.media,r),delete i.metadata.media,i})}function $t(t,e){return t.find(r=>r.id===e)}function Mr(t,e){var r,i;return(r=t.edit)!=null&&r.chapters?t.edit.chapters.find(n=>n.id===e):(i=t.view)!=null&&i.chapters?t.view.chapters.find(n=>n.id===e):void 0}function Or(t,e){return t.videos.find(r=>r.id===e)}function mo(t,e){return x(d({},t),{videos:t.videos.map(r=>x(d({},r),{variants:r.variants.map(i=>{let n=yo(i.url,e);return x(d({},i),{url:n||i.url})})}))})}function yo(t,e){try{return new URL(t,e).href}catch(r){return""}}function vo(t){return ve(t,"3.2.0")>=0}var q=Object.freeze({nothing:0,beforeInteractive:1,interactive:2,afterInteractive:3,end:4,removed:5,destroyed:6}),Ft=t=>Mt(t)&&!wr(t),se=t=>t.order==="end",Bt=t=>Mt(t.containers)&&!wr(t.containers)&&se(t),en=(t,e)=>{var i;let r=t*1e3;return Ft(e.controls)&&r<((i=e.startTime)!=null?i:0)},Lr=(t,e)=>{var i,n;let r=t*1e3;return Ft(e.controls)&&r>=((i=e.startTime)!=null?i:0)&&r<=((n=e.endTime)!=null?n:1/0)};var we=t=>t.some(e=>e.action.type==="expect"),jr=t=>t.find(e=>e.action.type==="expect"),go=t=>(t==null?void 0:t.length)===1,qt=t=>go(t)&&jt(t[0]);var tn=({fn:t,type:e=1},...r)=>(...i)=>e?t(...i,...r):t(d(d({},i[e]),r[e])),rn=(t,e)=>we(t.events)?!1:e.some(({container:r})=>r.container.id!==t.id&&we(r.container.events)&&r.container.endTime===t.endTime&&!r.isRemoved);var Be=class extends Pt{constructor(e,r){super(e),this.onError=r,this.prevChapter$=new bo(null),this.release()}release(){return this.manifest=null,this.chapter=null,this.media=null,this.graph=null,this.prevChapter$.next(null),this}setManifest(e){return A(this,null,function*(){var n;this.release();let r=yield this.exec("manifestLoaders",{actions:{addErrorMessage:tt},result:null,errors:null,source:e});r.errors&&this.errorHandler(r.errors);let i=yield Ji((n=r.result)!=null?n:e);return this.manifest=i,this})}setInitial(){return A(this,null,function*(){return this.setNext()})}setNext(){return A(this,arguments,function*(e=this.manifest.metadata.initChapterId){this.prevChapter$.next(this.chapter);let r=yield this.exec("chapterLoaders",kt({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:Mr,getChapter:$t,getMedia:Or,getByBranches:this.getByBranches.bind(this),addErrorMessage:tt},result:null,errors:null,chapterId:e}));return r.errors&&this.errorHandler(r.errors),this.chapter=r.result.chapter,this.media=r.result.media,this.graph=r.result.graph,this})}errorHandler(e){this.onError(e),console.error("Something went wrong with loaders",{errors:e})}getInitial(){return this.getByChapterId(this.manifest.metadata.initChapterId)||null}getByChapterId(e=this.manifest.metadata.initChapterId){let r=$t(this.manifest.chapters,e);if(r){let i=Or(this.manifest.media,r.videoId),n=Mr(this.manifest.graph,r.id);if(i)return{chapter:r,media:i,graph:n}}return null}getBranches(e=this.chapter.id){if(e===this.chapter.id)return this.getByBranches(this.chapter.branches);{let r=$t(this.manifest.chapters,e);return this.getByBranches(r==null?void 0:r.branches)}}getByBranches(e=[]){return e.reduce((r,i)=>{let n=this.getByChapterId(i.chapterId);return n&&r.push(n),r},[])}getCurrent(){return{chapter:this.chapter,media:this.media,graph:this.graph}}isInitialChapter(){return this.chapter.id===this.manifest.metadata.initChapterId}isEndChapter(){return se(this.chapter)}};import{Player as Eo}from"@vkontakte/videoplayer-core";import{Subscription as Co}from"@vkontakte/videoplayer-shared";var nn=t=>{let e=t.variants.find(r=>{var i;return((i=r.payload)==null?void 0:i.type)==="vk"});if(e&&"payload"in e){let[r,i]=e.payload.id.split("_");return[r,i]}return[]};var C={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},rt={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},L={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};function Nr(){let t=new Map;function e(o){var c=o,{listId:n=Math.random().toString(),itemId:s=Math.random().toString()}=c,l=Q(c,["listId","itemId"]);let h=t.get(n),m=d({},l);return h?h[s]=m:t.set(n,{[s]:m}),d({listId:n,itemId:s},l)}function r(n,s){var o,c,h;let l=t.get(n);if(l){if(s)return(o=l[s])==null||o.player.destroy(),(c=l[s])==null||c.container.remove(),(h=l[s])==null||h.subscription.unsubscribe(),delete l[s],Object.keys(l).length||t.delete(n),!0;for(let m of Object.values(l))m.player.destroy(),m.container.remove();return t.delete(n),!0}else throw Error("Can't remove. Not find.")}function i(){for(let n of t)r(n[0])}return{createPlayer:e,removePlayer:r,map:t,removeAll:i}}function Pr(t,e=[]){var s,l,o;let r={},i,n=!e.length;for(let c of t.variants)if(!i&&"cover"in c&&(i=c.cover),"url"in c)switch(c.type.toLowerCase()){case"mp4":(n||e.includes("mp4"))&&(r.MPEG=x(d({},r.MPEG),{[(s=c.standard)!=null?s:"Invariant quality"]:c.url}));break;case"mpeg":(n||e.includes("mpeg"))&&(r.MPEG=x(d({},r.MPEG),{[(l=c.standard)!=null?l:"Invariant quality"]:c.url}));break;case"hls":(n||e.includes("hls"))&&(r=x(d({},r),{HLS:{type:"url",url:c.url}}));break;case"dash":(n||e.includes("dash"))&&(r=x(d({},r),{DASH_SEP:{compatibilityMode:!0,type:"url",url:c.url}}));break;default:break}return{sources:r,thumbUrl:i,title:(o=t.title)!=null?o:""}}var it=(t,e)=>{let r=t.info.currentQuality$.getValue(),i=t.info.availableQualities$.getValue();r!==e&&i.includes(e)&&(t.setQuality(e),t.setAutoQuality(!1))};var nt={activePlayerChanged:"sc-active-player-changed",initiated:"sc-initiated",playerCreated:"sc-player-created"},xo=2;function kr(t){let e=Nr(),r,i,n=new Fe,s={},l=!1,o=null,c=!1,h;t&&m(t);function m(u){o=u}function S(u,b,w){var N;if(!o)throw Error("need to set interactive controller");if(!o.options)return;let M=((N=e.map.get(u))!=null?N:{})[b];if(M){s=d({chapterId:w,listId:u,itemId:b},M);let B=s.player;i=B.info.currentQuality$.subscribe(O=>{if(!(!O||!B.info.position$.getValue())){r=O;for(let te of e.map)Object.values(te[1]).forEach(({player:J})=>{B.info.isAutoQualityEnabled$.getValue()||it(J,O)})}}),M.container.remove(),l=!1,o.setPlayer(M.player),c||(o.init(),c=!0),n.emit(nt.activePlayerChanged,{player:s.player,config:s.config});return}throw Error("Can't set. Not find.")}function v(u,b,w){return A(this,null,function*(){if(!o)throw Error("need to set interactive controller");if(Te(s)||u!==s.itemId)return;if(w>=0&&!l){let M=o.getChapterBranches();l=!0;let N=new Set;for(let B of M)N.has(B.media.id)||(yield T({media:B.media,chapterId:B.chapter.id,setAsActive:!1,title:B.chapter.label}),N.add(B.media.id))}})}function I(w){return A(this,arguments,function*({chapter:{id:u},media:b}){if(Te(s))return;i==null||i.unsubscribe();let y=s.player.info.muted$.getValue(),M=s.player.info.currentQuality$.getValue(),N=s.player.info.isAutoQualityEnabled$.getValue(),B=s.player.info.volume$.getValue(),O=s.player.info.currentPlaybackRate$.getValue(),te=!N,J=!1;for(let W of e.map)if(W[0]===b.id){let me=Object.keys(W[1]);for(let K of me)K===s.itemId?(me.length<xo||(J=!0),e.removePlayer(W[0],K)):(J=!0,S(W[0],K,u),te?it(s.player,M):s.player.setAutoQuality(!0),s.player.setVolume(B),s.player.setMuted(y),s.player.setPlaybackRate(O))}else e.removePlayer(W[0]);J||(yield T({media:b,chapterId:u,setAsActive:!0,playbackRate:O}),te?it(s.player,M):s.player.setAutoQuality(!0),s.player.setVolume(B),s.player.setMuted(y))})}function T(te){return A(this,arguments,function*({media:u,chapterId:b,prefetch:w=!0,setAsActive:y=!0,autoplay:M=!1,preferredExt:N,title:B,playbackRate:O}){var wi,_i,Ri,Vi,Ai;let J=Math.random().toString(),W=document.createElement("div");h.append(W);let me=(wi=s==null?void 0:s.player)==null?void 0:wi.info.isAutoQualityEnabled$.getValue(),K;if((_i=o==null?void 0:o.options)!=null&&_i.vkVideoLoader){let yt=nn(u);yt.length&&(K=yield o.options.vkVideoLoader(...yt))}let Ii=((Ri=o==null?void 0:o.options)==null?void 0:Ri.coreConfig)||{},Ha=x(d({},Ii),{configName:[...(Vi=Ii.configName)!=null?Vi:[],"interactive"]}),Si=x(d({container:W},((Ai=K==null?void 0:K.videos)==null?void 0:Ai[0])||{sources:Pr(u,N).sources}),{title:B,failoverHosts:(K==null?void 0:K.failoverHosts)||[]}),Ie=new Eo(Ha);Ie.initVideo(Si);let Ti=new Co;Ti.add(Ie.info.position$.subscribe(function(yt){v(J,Ie.info.duration$.getValue(),yt)})).add(Ie.events.canplay$.subscribe(function(){me||it(Ie,r),O&&Ie.setPlaybackRate(O)}));let je=e.createPlayer({listId:u.id,itemId:J,player:Ie,container:W,sources:Pr(u,N).sources,config:Si,subscription:Ti});return y&&S(u.id,je.itemId,b),M&&je.player.play(),w&&!M&&je.player.prepare(),n.emit(nt.playerCreated,je.player),{player:je.player,config:je.config}})}function R(){_(),o=null}function _(){o==null||o.off(C.chapterChanged,I),e.removeAll(),s={},c=!1,l=!1}function f(b){return A(this,arguments,function*({container:u}){if(!o)throw Error("need to set interactive controller");_(),h=u;let{media:w,chapter:y}=o.getCurrentChapter();if(w){o.on(C.chapterChanged,I);let{player:M,config:N}=yield T({media:w,chapterId:y.id,title:y.label});return n.emit(nt.initiated,{container:u,media:w,chapterId:y.id}),{player:M,config:N}}else console.error("not found")})}return x(d({},e),{on:n.on.bind(n),off:n.off.bind(n),init:f,setInteractiveController:m,createPlayer:T,removeAll:R,getActivePlayer:function(){return s}})}import{Subscription as Io}from"@vkontakte/videoplayer-shared";var Dt=class{constructor({player:e,container:r,branches:i,selectBranches:n,interactiveEvents:s,globalEventEmitter:l,ignoreContainerEvent:o,permanentTextControls:c,disabledControls$:h,onRemove:m}){$(this,"hide",()=>{setTimeout(()=>{var e,r;this.gameState!==q.end&&(we(this.container.container.events)&&this.gameState===q.afterInteractive||this.selectBranches.state.isExpect||(this.gameState!==q.interactive&&((r=(e=this.container).hide)==null||r.call(e)),this.globalEventEmitter.emit(C.interactives,{subjectId:this.container.container.id,subjectName:"container",type:L.visibility,visibility:!1})))})});$(this,"show",()=>{var e,r,i,n;if(this.gameState===q.interactive&&!this.isSelectedControlEvent)if(this.container.getElement())(n=(i=this.container).show)==null||n.call(i),this.globalEventEmitter.emit(C.interactives,{subjectId:this.container.container.id,subjectName:"container",type:L.visibility,visibility:!0,isFirst:!1});else{let l=tn({fn:this.selectBranches.onControlEvent,type:0},{isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.globalEventEmitter.emit(C.interactives,{subjectId:this.container.container.id,subjectName:"container",type:L.visibility,visibility:!1})},onEvent:(o,c)=>{this.isSelectedControlEvent=!0,o!==!1&&(this.removeView(),this.globalEventEmitter.emit(C.interactives,{subjectId:this.container.container.id,subjectName:"container",type:L.visibility,visibility:!1})),(this.gameState===q.end||this.gameState===q.afterInteractive||this.selectBranches.state.isExpect)&&(this.selectBranches.stopExpect(),c(),this.removeView(),this.globalEventEmitter.emit(C.interactives,{subjectId:this.container.container.id,subjectName:"container",type:L.visibility,visibility:!1}))},isEOV:()=>this.gameState===q.end});this.container.createView(l),this.globalEventEmitter.emit(C.interactives,{subjectId:this.container.container.id,subjectName:"container",type:L.visibility,visibility:!0,isFirst:!0}),this.disabledControls$.getValue()&&((r=(e=this.container).disable)==null||r.call(e))}});$(this,"onEndOfVideo",()=>{this.gameState=q.end,this.selectContainerEvent(!0)});$(this,"whilePlaying",()=>{var s,l;if(((s=this.player.experimental.element$.getValue())==null?void 0:s.readyState)<1||[q.destroyed,q.removed].includes(this.gameState)&&!this.isPermanentText)return;let r=this.player.getExactTime();if(en(r,this.container.container))this.gameState!==q.beforeInteractive&&(this.gameState=q.beforeInteractive,this.onBeforeStartTime());else if(Lr(r,this.container.container))this.gameState!==q.interactive&&(this.gameState=q.interactive,this.onStartTime());else if(this.gameState!==q.afterInteractive){let o=this.gameState;this.gameState=q.afterInteractive,o===q.interactive&&this.onEndTime()}else this.gameState!==q.destroyed&&!this.isPermanentText&&this.removeView();let i=Lr(r,this.container.container),n=this.container.container.startTime?[this.container.container.startTime,(l=this.container.container.endTime)!=null?l:1/0]:[];this.globalEventEmitter.emit(C.eachTick,{subjectId:this.container.container.id,subjectName:"container",range:n,currentTime:r,isInteractiveTime:i})});this.container=r,this.branches=i,this.selectBranches=n,this.subscription=new Io,this.player=e,this.interactiveEvents=s,this.ignoreContainerEvent=o,this.isPermanentText=c&&qt(r.container.controls),this.disabledControls$=h,this.onRemove=m,this.globalEventEmitter=l,this.gameState=q.nothing,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}registerEvents(){this.subscription.add(this.player.events.playing$.subscribe(this.show)).add(this.player.events.paused$.subscribe(this.hide)).add(this.player.events.ended$.subscribe(this.onEndOfVideo)).add(this.disabledControls$.subscribe(e=>{var r,i,n,s;e?(i=(r=this.container).disable)==null||i.call(r):(s=(n=this.container).enable)==null||s.call(n)}))}selectContainerEvent(e=!1){this.interactiveEvents.containersEventsCallState.setCalled({timestamp:e?1/0:this.container.container.endTime,id:this.container.container.id}),!(this.isSelectedControlEvent||this.isSelectedContainerEvent)&&(this.isSelectedContainerEvent=!0,this.ignoreContainerEvent()||this.selectBranches.setManifestContainerEvents({container:this.container.container,branches:this.branches,isEOV:e}),!e&&this.interactiveEvents.exec(this.container.container.endTime))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);let e=we(this.container.container.events)||this.ignoreContainerEvent();(this.isSelectedControlEvent||!e)&&this.removeView()}onBeforeStartTime(){var e,r;(r=(e=this.container).hide)==null||r.call(e),this.globalEventEmitter.emit(C.interactives,{subjectId:this.container.container.id,subjectName:"container",type:L.visibility,visibility:!1})}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=q.beforeInteractive}removeView(){var e;this.container.removeView(),this.globalEventEmitter.emit(C.interactives,{subjectId:this.container.container.id,subjectName:"container",type:L.containerRemoved,visibility:!1}),this.gameState=q.removed,(e=this.onRemove)==null||e.call(this)}destroy(){var e;this.reset(),this.removeView(),this.gameState=q.destroyed,this.subscription.unsubscribe(),this.branches=[],this.interactiveEvents.containersEventsCallState.setCalled({timestamp:(e=this.container.container.endTime)!=null?e:1/0,id:this.container.container.id})}};var sn=(t=[])=>t.reduce((e,r,i)=>{var s,l,o;let n=((s=r==null?void 0:r.controls)!=null?s:[]).filter(c=>!jt(c));if(Ft(n)){let c=[(l=r.startTime)!=null?l:0,(o=r.endTime)!=null?o:1/0],h=r.id;if(!i)e.push({subjects:[h],range:c});else{let m=[],S=-1/0,v=1/0,I=[],T=[];for(let R=0;R<e.length;R++){let _=e[R];if(T.push(..._.subjects),_.range[0]<v&&(v=_.range[0]),_.range[1]>S&&(S=_.range[1]),c[0]>=_.range[0]&&c[1]<=_.range[1])return e[R].subjects.push(h),e;c[0]<_.range[0]&&c[1]>_.range[0]&&(m.push(R),I=I.concat(_.subjects)),c[0]>=_.range[0]&&c[0]<=_.range[1]&&(m.push(R),I=I.concat(_.subjects),c[0]=_.range[0]),c[1]>=_.range[0]&&c[1]<=_.range[1]&&(m.push(R),I=I.concat(_.subjects),c[1]=_.range[1])}if(T.push(h),c[0]<=v&&c[1]>=S)return[{subjects:T,range:c}];m.length&&m.reverse().forEach(R=>{e.splice(R,1)}),e.push({subjects:I.concat([h]),range:c})}}return e},[]).sort((e,r)=>e.range[0]-r.range[0]);function an(){let t={};function e(){for(let o in t)Object.prototype.hasOwnProperty.call(t,o)&&delete t[o];return!0}function r(o){let c={};for(let h in t)+h<=o&&(c[h]=t[h]);return c}function i(o){let c={};for(let h in t)+h>=o&&(c[h]=t[h]);return c}function n({timestamp:o,priority:c,initiator:h}){var m;if(Tr(o)){let S=(m=t[o])!=null?m:null;if(S&&Je(c,!0)){let v={},I=S[c];if(I&&(v=d(d({},v),I)),v=Te(v)?null:v,v&&Je(h,!0)){let T=v[h];return T!=null?T:null}return v}return S}return null}function s({timestamp:o,priority:c,initiator:h}){if(Tr(o))if(t[o]){if(Je(c,!0))if(t[o][c]){if(Je(h,!0))if(t[o][c][h]){if(delete t[o][c][h],!Te(t[o][c]))return!0}else return!1;if(delete t[o][c],!Te(t[o]))return!0}else return!1;return delete t[o]}else return!1}function l(S){var v=S,{timestamp:o,priority:c,initiator:h}=v,m=Q(v,["timestamp","priority","initiator"]);var I,T,R;(T=(I=t[o])==null?void 0:I[c])!=null&&T[h]?t[o][c][h].push(d({},m)):(R=t[o])!=null&&R[c]?t[o][c]=x(d({},t[o][c]),{[h]:[d({},m)]}):t[o]?t[o]=x(d({},t[o]),{[c]:{[h]:[d({},m)]}}):t[o]={[c]:{[h]:[d({},m)]}}}return{map:t,remove:s,add:l,removeAll:e,get:n,getLte:r,getGte:i}}var So=[P.expect,P.setNextBranch],To=1/0;function $r(t){let e=t,r,i=wo(),n=new an,s,l=()=>{v(),f()},o=u=>{n.add.call(void 0,u),T()},c=(u=[])=>{for(let b of u)if(b.action(),So.includes(b.actionType))break},h=(u=1/0)=>{var M,N,B;let b=Ht((M=n.get({timestamp:u,priority:"control"}))!=null?M:{}),w=Ht((N=n.get({timestamp:u,priority:"container"}))!=null?N:{}),y=Ht((B=n.get({timestamp:u,priority:"chapter"}))!=null?B:{});return[...b,...w,...y]},m=u=>{i.isReady(u)&&c(h(u))},S=()=>{var u;c([...Ht((u=n.get({timestamp:1/0,priority:"chapter"}))!=null?u:{})])},v=()=>{r&&(s==null||s.unsubscribe(),r=void 0)},I=u=>{},T=()=>{r||(r=()=>setTimeout(()=>{m(1/0)}),s=e.events.ended$.subscribe(r))},R=u=>{v(),e=u},_=u=>{u.priority==="container"&&i.resetCalled(u.timestamp),n.remove(u)},f=()=>{i.release(),n.removeAll()};return{setPlayer:R,add:o,remove:_,exec:m,execEndOfVideo:S,listen:T,unlisten:v,release:l,containersEventsCallState:i,getPreparedToExecActions:h}}function wo(){let t=new Map;return{setCalled:({timestamp:l,id:o})=>{let c=t.get(l);c&&c[o]!==void 0&&(c[o]=!0)},setData:(l=[])=>{var o,c;for(let h of l){let m=(o=h.endTime)!=null?o:To,S=(c=t.get(m))!=null?c:{};t.set(m,x(d({},S),{[h.id]:!1}))}},resetCalled:l=>{let o=t.get(l);if(o)for(let c in o)o[c]=!1},isReady:l=>{let o=t.get(l);return o?!Object.values(o).some(c=>!c):!0},release:()=>t.clear()}}function Ht(t){return Object.values(t).flat().sort(e=>e.actionType===P.expect?-1:1)}var on=(t,e)=>{let{height:r,width:i}=e.info.intrinsicVideoSize$.getValue()||{};if(!(r&&i))return{videoContentHeight:0,videoContentWidth:0};let{clientHeight:n,clientWidth:s}=e.experimental.element$.value||{};if(!(n&&s))return{videoContentHeight:0,videoContentWidth:0};let l=r/i,o=n/s,c,h;return o>l?(h=s,c=s*l):o<l?(h=n/l,c=n):(h=s,c=n),{videoContentWidth:h,videoContentHeight:c}};var _o=250;function cn(t){let e=()=>{},r=new ResizeObserver(o=>{s(o),e=s.bind(null,o)});function i(o){let{parentElement:c,player:h}=t();if(c&&h){let{videoContentWidth:m,videoContentHeight:S}=on(c,h);c.style.setProperty("--interactive-content-width",`${m}px`),c.style.setProperty("--interactive-content-height",`${S}px`),c.style.setProperty("--interactive-width",`${o[0].contentRect.width}px`),c.style.setProperty("--interactive-height",`${o[0].contentRect.height}px`)}}function n(){let{parentElement:o}=t();o.removeAttribute("style")}let s=Vt(o=>{let{fns:c=[]}=t();i(o);for(let h of c)h()},_o);function l(){e=void 0,r.disconnect(),n()}return{resizeObserver:r,calc:()=>{e()},release:l}}var st=class{constructor(){this.map={}}push(e,r){e in this.map?this.map[e].push(r):this.map[e]=[r]}get(e){let r=this.map[e];return r?r.slice():null}getAll(){let e=[];for(let r in this.map)e.push(...this.map[r]);return e}remove(e,r){e in this.map&&(this.map[e]=this.map[e].filter(i=>i!==r),this.map[e].length===0&&delete this.map[e])}clear(){this.map={}}size(){return Object.keys(this.map).length}keys(){return Object.keys(this.map)}};var Ro=t=>Math.floor(Math.random()*t),ln=t=>{let e=t.length,r=1/0,i=null;for(;e--;)t[e].weight<r&&(r=t[e].weight,i=t[e]);return i},hn=t=>{let e=t.length,r=-1/0,i=null;for(;e--;)t[e].weight>r&&(r=t[e].weight,i=t[e]);return i};var un=t=>{let e=t.length,r=Ro(e);return t[r]};var dn=t=>{var i,n;let e=0;for(let s=0;s<t.length;++s)e+=(i=t[s].weight)!=null?i:1;let r=Math.random()*e;e=0;for(let s=0;s<t.length-1;++s)if(e+=(n=t[s].weight)!=null?n:1,e>=r)return t[s];return t[t.length-1]};var pn=Object.freeze({shouldOpenNow:!0,isDetachContainer:!0});var Fr=(t,e=!1)=>x(d({},t),{args:e?d(d({},t.args),pn):d(d({},pn),t.args)}),Br=({globalEventEmitter:t,player:e,interactiveEvents:r,removeControllers:i})=>{let n={isExpect:!1},s=()=>{n.isExpect&&(n.isExpect=!1)},l=({action:f,controlType:u,controlId:b,containerId:w,branches:y=[],onEvent:M,isEOV:N=()=>!1,isDisabled:B=()=>!1})=>{let O=Fr(f,N()),te={timestamp:1/0,priority:"control",initiator:b,actionType:O.type},J=B(),W=t.emit.bind(t,C.interactives,{subjectId:b,subjectType:u,subjectName:"control",type:J?L.actionChoiceCanceled:L.actionChoice,actionType:f.type,payload:d({containerId:w},O.args)});if(J){W();return}switch(O.type.trim().toLowerCase()){case P.setNextBranch.trim().toLowerCase():{let me=y.find(K=>K.id===O.args.branchId);if(!me)return;M(O.args.isDetachContainer,v.bind(null,{subjectId:b,subjectName:"control"})),W(),O.args.shouldOpenNow?T({subjectId:b,subjectName:"control",subjectType:u,action:O,payload:{chapterId:me.chapterId,autoSelect:!1}}):(r.add(x(d({},te),{action:T.bind(null,{subjectId:b,subjectName:"control",subjectType:u,action:O,payload:{chapterId:me.chapterId,autoSelect:!1}})})),i==null||i());return}case P.continuePlayback.trim().toLowerCase():{M(O.args.isDetachContainer,v.bind(null,{subjectId:b,subjectName:"control"})),W(),O.args.shouldOpenNow?I({subjectId:b,subjectName:"control",subjectType:u,action:f}):r.add(x(d({},te),{action:I.bind(null,{subjectId:b,subjectName:"control",subjectType:u,action:f})}));return}case P.openURI.trim().toLowerCase():{M(O.args.isDetachContainer,v.bind(null,{subjectId:b,subjectName:"control"})),W(),O.args.shouldOpenNow?_({subjectId:b,subjectName:"control",subjectType:u,action:O,payload:{URI:f.args.uri}}):(r.add(x(d({},te),{action:_.bind(null,{subjectId:b,subjectName:"control",subjectType:u,action:O,payload:{URI:f.args.uri}})})),i==null||i());return}default:console.error("Unexpected control event"),t.emit(C.errors,new V(V.Severity.RECOVERABLE,V.Category.INTERACTIVES,{message:"Unexpected control event"}));return}},o=({action:f,container:{id:u,endTime:b},branches:w=[],isEOV:y=!1,autoSelected:M=!1})=>{let N=Fr(f,y),B={timestamp:!N.args.shouldOpenNow||y?1/0:b,priority:"container",initiator:u,actionType:N.type},O=t.emit.bind(t,C.interactives,{subjectId:u,subjectName:"container",type:L.actionChoice,actionType:N.type,payload:N.args});switch(N.type.trim().toLowerCase()){case P.setNextBranch.trim().toLowerCase():{let te=w.find(J=>J.id===N.args.branchId);if(!te)return;O(),r.add(x(d({},B),{action:T.bind(null,{subjectId:u,subjectName:"container",action:N,payload:{chapterId:te.chapterId,autoSelect:M}})})),i==null||i();return}case P.setMaxWeightBranch.trim().toLowerCase():return;case P.setMinWeightBranch.trim().toLowerCase():return;case P.setRandomBranch.trim().toLowerCase():return;case P.setWeightlessRandomBranch.trim().toLowerCase():return;case P.continuePlayback.trim().toLowerCase():{O(),r.add(x(d({},B),{action:I.bind(null,{subjectId:u,subjectName:"container",action:N})}));return}case P.openURI.trim().toLowerCase():{O(),r.add(x(d({},B),{action:_.bind(null,{subjectId:u,subjectName:"container",action:N,payload:{URI:f.args.uri}})})),i==null||i();return}default:console.error("Unexpected container event"),t.emit(C.errors,new V(V.Severity.RECOVERABLE,V.Category.INTERACTIVES,{message:"Unexpected container event"}));return}};function c({container:f,branches:u,isEOV:b=!1}){let w=jr(f.events);if(w){let y=Fr(w.action,b);t.emit(C.interactives,{subjectId:f.id,subjectName:"container",type:L.actionChoice,actionType:y.type,payload:y.args}),r.add({timestamp:b?1/0:f.endTime,priority:"container",initiator:f.id,actionType:P.expect,action:S.bind(null,{subjectId:f.id,subjectName:"container"})}),n.isExpect=!0}else for(let y of f.events)o({action:y.action,container:f,branches:u,isEOV:b})}let h=({chapterId:f,action:u,branches:b=[]})=>{let w=t.emit.bind(t,C.interactives,{subjectId:f,subjectName:"chapter",type:L.actionChoice,actionType:u.type,payload:u.args});switch(u.type.trim().toLowerCase()){case P.setNextBranch.trim().toLowerCase():{let y=b.find(M=>M.id===u.args.branchId);return y!=null&&y.chapterId?(w(),T.bind(null,{subjectId:f,subjectName:"chapter",action:u,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case P.setWeightlessRandomBranch.trim().toLowerCase():{let y=un(b);return y!=null&&y.chapterId?(w(),T.bind(null,{subjectId:f,subjectName:"chapter",action:u,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case P.setRandomBranch.trim().toLowerCase():{let y=dn(b);return y!=null&&y.chapterId?(w(),T.bind(null,{subjectId:f,subjectName:"chapter",action:u,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case P.setMaxWeightBranch.trim().toLowerCase():{let y=hn(b);return y!=null&&y.chapterId?(w(),T.bind(null,{subjectId:f,subjectName:"chapter",action:u,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case P.setMinWeightBranch.trim().toLowerCase():{let y=ln(b);return y!=null&&y.chapterId?(w(),T.bind(null,{subjectId:f,subjectName:"chapter",action:u,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case P.continuePlayback.trim().toLowerCase():return w(),I.bind(null,{subjectId:f,subjectName:"chapter",action:u});case P.openURI.trim().toLowerCase():return w(),_.bind(null,{subjectId:f,subjectName:"chapter",action:u,payload:{URI:u.args.uri}});default:console.error("Unexpected chapter event"),t.emit(C.errors,new V(V.Severity.RECOVERABLE,V.Category.INTERACTIVES,{message:"Unexpected chapter event"}));return}};function m(f){let u=jr(f.events);if(u){if(se(f))return;t.emit(C.interactives,{subjectId:f.id,subjectName:"chapter",type:L.actionChoice,actionType:u.action.type,payload:u.action.args}),r.add({timestamp:1/0,priority:"chapter",initiator:f.id,actionType:P.expect,action:S.bind(null,{subjectId:f.id,subjectName:"chapter"})})}else f.events.forEach(b=>{let w=h({chapterId:f.id,action:b.action,branches:f.branches});w&&r.add({timestamp:1/0,priority:"chapter",initiator:f.id,actionType:b.action.type,action:w})})}let S=({subjectId:f,subjectName:u,action:b})=>{var w;e.pause(),t.emit(C.interactives,{subjectId:f,subjectName:u,type:L.actionExecution,actionType:(w=b==null?void 0:b.type)!=null?w:P.expect})},v=({subjectId:f,subjectName:u})=>{e.info.isEnded$.getValue()?r.execEndOfVideo():e.play(),t.emit(C.interactives,{subjectId:f,subjectName:u,type:L.actionExecution,actionType:"after-expect"})},I=({subjectId:f,subjectName:u,subjectType:b,action:w})=>{t.emit(C.interactives,{subjectId:f,subjectName:u,subjectType:b,type:L.actionExecution,actionType:w.type})},T=({subjectId:f,subjectName:u,subjectType:b,action:w,payload:y})=>{y.behaviour="change-chapter",t.emit(C.interactives,{subjectId:f,subjectName:u,subjectType:b,type:L.actionExecution,actionType:w.type,payload:y})},R=({subjectId:f,subjectName:u,subjectType:b,action:w,payload:y})=>{y.behaviour="change-manifest",t.emit(C.interactives,{subjectId:f,subjectName:u,subjectType:b,type:L.actionExecution,actionType:w.type,payload:y})},_=({subjectId:f,subjectName:u,subjectType:b,action:w,payload:y})=>{if(!y.URI)return;let M=window.open(y.URI,"_blank","noopener,noreferrer");M&&(M.opener=null),t.emit(C.interactives,{subjectId:f,subjectName:u,subjectType:b,type:L.actionExecution,actionType:w.type})};return{onControlEvent:l,onContainerEvent:o,onChapterEvent:h,onExpectEvent:S,expectEventHandler:v,setManifestChapterEvents:m,setManifestContainerEvents:c,stopExpect:s,state:n}};var bi=Xa(Va(),1);import{Subscription as Yl,ValueSubject as lt}from"@vkontakte/videoplayer-shared";var gi=(t,e)=>{let r={};return t.map(i=>{if(!r[i]){let n=e.chapters.find(l=>l.id===i);if(!n)return null;let s=e.media.videos.find(l=>n.videoId===l.id);if(!s)return null;r[i]=Aa(s)}return r[i]}).filter(Boolean)},Wl=t=>{for(let e of t.variants)if(Kl(e)&&"payload"in e)return e.payload.id},Kl=t=>t.type==="custom"&&"payload"in t&&t.payload.type==="vk",Aa=t=>{let e=Wl(t);if(!e)return null;let r=e.split("_").pop();return r?parseInt(r,10):null},Ql=(t,e)=>{for(let r of t.media.videos)if(e===Aa(r)){for(let i of t.chapters)if(i.videoId===r.id)return i.id;return}},Ma=(t,e)=>t.reduce((r,i)=>{let n=Ql(e,i);return n?[...r,n]:r},[]);var oe,Re,Ve,ee,Xt,ce,le,ie,Ae,Ue,ze,ht=class{constructor({globalEventEmitter:e,videoId:r,interactiveController:i,historyApi:n,settings:s}){this.state={history$:new lt([]),hasPrevChapter$:new lt(!1),prevChapter$:new lt(null),isInitialChapter$:new lt(!1),isGoBackLimited$:new lt(!1)};E(this,oe,null);E(this,Re,void 0);E(this,Ve,!1);E(this,ee,null);E(this,Xt,null);E(this,ce,null);E(this,le,null);E(this,ie,null);E(this,Ae,new Yl);E(this,Ue,!1);E(this,ze,0);var l,o,c;g(this,ce,r),g(this,ie,e),g(this,le,i),g(this,oe,n),g(this,Re,s),(l=this.state)!=null&&l.history$&&a(this,Ae)&&((c=a(this,Ae))==null||c.add((o=this.state)==null?void 0:o.history$.subscribe(h=>{var m,S,v,I,T,R;(m=this.state)==null||m.prevChapter$.next((0,bi.default)(h,-2)||null),(S=this.state)==null||S.hasPrevChapter$.next(h.length>1),(T=this.state)==null||T.isInitialChapter$.next(this.getInitialChapterId()===((I=(v=a(this,ee))==null?void 0:v.metadata)==null?void 0:I.initChapterId)),(R=this.state)==null||R.isGoBackLimited$.next(a(this,ze)===a(this,Re).maxLength-1)})))}setManifest(e){return A(this,null,function*(){!a(this,le)||!a(this,ie)||(g(this,ee,e),yield this.getProjectHistory(),yield a(this,le).setChapter({chapterId:this.getInitialChapterId(),pushToHistory:!1}),a(this,Ve)||(g(this,Ve,!0),a(this,ie).emit(C.historyInited,{initChapterId:this.getInitialChapterId()})))})}get inited(){return a(this,Ve)}updateHistory(e,r=!0){return A(this,null,function*(){var o,c;if(!a(this,ee))return;a(this,Ue)?(g(this,Ue,!1),Oi(this,ze)._++):g(this,ze,0);let i=a(this,ee),n=e.length-a(this,Re).maxLength,s=n>0?e.slice(n):e,l=gi(s,i);if(g(this,Xt,l),(o=this==null?void 0:this.state)==null||o.history$.next(s),!(!r||!a(this,oe)||!a(this,ce)))try{yield a(this,oe).save(a(this,ce),l)}catch(h){(c=a(this,ie))==null||c.emit(C.errors,new V(V.Severity.RECOVERABLE,V.Category.HISTORY,"Unable to save interactive history"))}})}goBack(){return A(this,null,function*(){var i;if(!this.state||!a(this,le))return(i=a(this,ie))==null?void 0:i.emit(C.errors,new V(V.Severity.RECOVERABLE,V.Category.HISTORY,"Cannot go back because HistoryController has not been initialized"));g(this,Ue,!0);let e=this.state.history$.getValue().slice(0,-1),r=e.pop();this.state.history$.next(e),yield a(this,le).setChapter({chapterId:r})})}getProjectHistory(){return A(this,null,function*(){var n,s;if(!a(this,ee)||!a(this,ce))return;let e=a(this,ee),r=[this.getInitialVideoId()];if(a(this,oe))try{let l=yield a(this,oe).get(a(this,ce));l.length&&(r=l)}catch(l){(n=a(this,ie))==null||n.emit(C.errors,new V(V.Severity.RECOVERABLE,V.Category.HISTORY,"Error while trying to fetch data"))}let i=Ma(r,e);(s=this==null?void 0:this.state)==null||s.history$.next(i)})}getInitialChapterId(){var r,i;let e=(r=this.state)==null?void 0:r.history$.getValue();return(0,bi.default)(e,-1)||a(this,Re).initChapterId||((i=a(this,ee))==null?void 0:i.metadata.initChapterId)}getInitialVideoId(){if(a(this,ee)){let e=this.getInitialChapterId();return gi([e],a(this,ee)).pop()}return null}destroy(){var e,r;this.state=null,g(this,ce,null),g(this,oe,null),g(this,le,null),(e=a(this,Ae))==null||e.unsubscribe(),g(this,Ae,null),g(this,Ve,!1),(r=a(this,ie))==null||r.emit(C.historyDestroyed),g(this,ie,null)}};oe=new WeakMap,Re=new WeakMap,Ve=new WeakMap,ee=new WeakMap,Xt=new WeakMap,ce=new WeakMap,le=new WeakMap,ie=new WeakMap,Ae=new WeakMap,Ue=new WeakMap,ze=new WeakMap;var Jt,Oa,ut,er,La,he=class he{constructor(e,r,i,n){var s;this.target=e,this.type=r,this.listener=i,this.options=k(s=he,Jt,Oa).call(s,e,n),this.target.addEventListener(r,i,this.options)}unlisten(){this.target.removeEventListener(this.type,this.listener,this.options),this.target=null,this.listener=null,this.options=!1}};Jt=new WeakSet,Oa=function(e,r){var i;if(r===void 0)return!1;if(typeof r=="boolean")return r;{let n=new Set(["passive","capture"]),s=Object.keys(r).filter(o=>!n.has(o));return s.length===0&&console.warn("Unsupported flag(s) to addEventListener: "+s.join(",")),k(i=he,er,La).call(i,e)?r:r.capture||!1}},ut=new WeakMap,er=new WeakSet,La=function(e){let r=a(he,ut);if(r===void 0){r=!1;try{let i={},n={get:()=>(r=!0,!1)};Object.defineProperty(i,"passive",n),Object.defineProperty(i,"capture",n);let s=()=>{};e.addEventListener("test",s,i),e.removeEventListener("test",s,i)}catch(i){r=!1}g(he,ut,r)}return r||!1},E(he,Jt),E(he,er),E(he,ut,void 0);var Zt=he;var tr=class{constructor(){this.bindingMap=new st}release(){this.removeAll(),this.bindingMap=null}listen(e,r,i,n){if(!this.bindingMap)return;let s=new Zt(e,r,i,n);this.bindingMap.push(r,s)}listenOnce(e,r,i,n){let s=l=>{this.unlisten(e,r,s),i(l)};this.listen(e,r,s,n)}unlisten(e,r,i){if(!this.bindingMap)return;let n=this.bindingMap.get(r)||[];for(let s of n)s.target===e&&(i===s.listener||!i)&&(s.unlisten(),this.bindingMap.remove(r,s))}removeAll(){if(!this.bindingMap)return;let e=this.bindingMap.getAll();for(let r of e)r.unlisten();this.bindingMap.clear()}};var rr=class{constructor(){this._prevSizeId=0;this.rootElement=document.createElement("canvas")}clear(){var e;(e=this.rootElement.getContext("2d"))==null||e.clearRect(0,0,this.rootElement.width,this.rootElement.height)}isImageDrawn(){var n;let e=(n=this.rootElement.getContext("2d"))==null?void 0:n.getImageData(0,0,this.rootElement.width,this.rootElement.height);if(!e)return!1;let r=e.data,i=r.length;for(let s=3;s<i;s+=40)if(r[s]!==0)return!0;return!1}destroy(){this.rootElement.remove()}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}setCanvasImageSource(e){this.canvasImgSrc=e}draw(){var e;this.canvasImgSrc&&((e=this.rootElement.getContext("2d"))==null||e.drawImage(this.canvasImgSrc,0,0,this.rootElement.width,this.rootElement.height))}updateCanvasDimensions(e,r=!1){return A(this,null,function*(){let i=e.width+e.height;if(this._prevSizeId===i)return;let n;r&&(n=yield this.save()),this.rootElement.width=e.width,this.rootElement.height=e.height,r&&n&&this.restore(n),this._prevSizeId=i})}save(){return A(this,null,function*(){let e=this.rootElement.toDataURL("image/jpeg",1),r=new Image;return r.crossOrigin="anonymous",r.src=e,yield r.decode(),r})}restore(e){var r;this.rootElement&&((r=this.rootElement.getContext("2d"))==null||r.drawImage(e,0,0,this.rootElement.width,this.rootElement.height))}};var ir=class{constructor({parentElement:e,endOffsetMs:r=250,onError:i}){this.currentVideoDurationMs=1/0;this._containerTimeFrameShouldReceived=!1;this._endTimeFrameReceived=!1;this._shouldCallSkip=!1;this.onEachTick=e=>{let r=e!=null?e:this.lastFrameCanvas.canvasImgSrc.currentTime*1e3,i=this.isChapterEndTime(r);if(this.isContainerTime(r))this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!0,this._shouldCallSkip=!0;else if(i)this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1,this._endTimeFrameReceived||(this.draw(),this._endTimeFrameReceived=!0,this.show());else{if(this._shouldCallSkip){this._shouldCallSkip=!1;return}this.reset()}};this.onSeek=()=>{this.onEachTick(),!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived&&(this.hide(),this.lastFrameCanvas.clear())};this.rootElement=document.createElement("div"),this.rootElement.style.cssText=`
|
|
6
|
+
var gn=Object.defineProperty,vn=Object.defineProperties;var bn=Object.getOwnPropertyDescriptors;var ie=Object.getOwnPropertySymbols;var bi=Object.prototype.hasOwnProperty,Ci=Object.prototype.propertyIsEnumerable;var Ei=i=>{throw TypeError(i)};var $e=(i,t,e)=>t in i?gn(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,p=(i,t)=>{for(var e in t||(t={}))bi.call(t,e)&&$e(i,e,t[e]);if(ie)for(var e of ie(t))Ci.call(t,e)&&$e(i,e,t[e]);return i},v=(i,t)=>vn(i,bn(t));var X=(i,t)=>{var e={};for(var n in i)bi.call(i,n)&&t.indexOf(n)<0&&(e[n]=i[n]);if(i!=null&&ie)for(var n of ie(i))t.indexOf(n)<0&&Ci.call(i,n)&&(e[n]=i[n]);return e};var O=(i,t,e)=>$e(i,typeof t!="symbol"?t+"":t,e),Oe=(i,t,e)=>t.has(i)||Ei("Cannot "+e);var a=(i,t,e)=>(Oe(i,t,"read from private field"),e?e.call(i):t.get(i)),I=(i,t,e)=>t.has(i)?Ei("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(i):t.set(i,e),m=(i,t,e,n)=>(Oe(i,t,"write to private field"),n?n.call(i,e):t.set(i,e),e),$=(i,t,e)=>(Oe(i,t,"access private method"),e);var Ii=(i,t,e,n)=>({set _(r){m(i,t,r,e)},get _(){return a(i,t,n)}});var V=(i,t,e)=>new Promise((n,r)=>{var s=c=>{try{o(e.next(c))}catch(h){r(h)}},l=c=>{try{o(e.throw(c))}catch(h){r(h)}},o=c=>c.done?n(c.value):Promise.resolve(c.value).then(s,l);o((e=e.apply(i,t)).next())});var xi="1.0.14-dev.1121b4e6.0";function Be(i,t=1){let e="0",n="0",r="0";return i.length===4?(e="0x"+i[1]+i[1],n="0x"+i[2]+i[2],r="0x"+i[3]+i[3]):i.length===7&&(e="0x"+i[1]+i[2],n="0x"+i[3]+i[4],r="0x"+i[5]+i[6]),`rgba(${+e},${+n},${+r},${t})`}var G="SDK_NAME",Cn="SDK_NAME-controls-container",ne=()=>document.querySelector(`.${Cn}`),Vi=.4,q={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0},Ti={top:"flex-start",bottom:"flex-end",center:"center"},Si={start:"flex-start",end:"flex-end",center:"center"},wi={start:"left",end:"right",center:"center"},se=({target:i,props:t})=>{var e,n,r,s,l,o;i.style.alignItems=(n=Ti[(e=t==null?void 0:t.text)==null?void 0:e.gravityVertical])!=null?n:Ti.center,i.style.justifyContent=(s=Si[(r=t==null?void 0:t.text)==null?void 0:r.gravityHorizontal])!=null?s:Si.center,i.style.textAlign=(o=wi[(l=t==null?void 0:t.text)==null?void 0:l.alignment])!=null?o:wi.start},re=({target:i,props:t,fallback:e,dependsOn:n})=>{var r,s,l,o,c,h;i.style.color=(s=(r=t==null?void 0:t.text)==null?void 0:r.color)!=null?s:e.textColor,i.style.fontSize=`calc(${n.height} * ${(o=(l=t==null?void 0:t.text)==null?void 0:l.size)!=null?o:e.textSize})`,i.textContent=(h=(c=t==null?void 0:t.text)==null?void 0:c.value)!=null?h:e.textContent},ae=({target:i,props:t,fallback:e})=>{var n,r,s,l;i.style.backgroundColor=Be((r=(n=t==null?void 0:t.background)==null?void 0:n.color)!=null?r:e.backgroundColor,(l=(s=t==null?void 0:t.background)==null?void 0:s.alpha)!=null?l:e.backgroundAlpha)},oe=({target:i,props:t,fallback:e,dependsOn:n})=>{var r,s,l,o,c,h,b,C,E,S,x;i.style.border=`calc(${n.height} * ${(l=(s=(r=t==null?void 0:t.shape)==null?void 0:r.border)==null?void 0:s.width)!=null?l:e.borderWidth}) solid ${Be((h=(c=(o=t==null?void 0:t.shape)==null?void 0:o.border)==null?void 0:c.color)!=null?h:e.borderColor,(E=(C=(b=t==null?void 0:t.shape)==null?void 0:b.border)==null?void 0:C.alpha)!=null?E:e.borderAlpha)}`,i.style.borderRadius=`calc(${n.height} * ${(x=(S=t==null?void 0:t.shape)==null?void 0:S.roundCorners)!=null?x:e.roundCorners})`},At=({target:i,layoutParams:t,fallback:e})=>{i.style.transform=`rotate(${-t.angle}rad)`};var Fe="int",Mt={AREA:`${Fe}_area`,TEXT:`${Fe}_text`,BUTTON:`${Fe}_bttn`};var ut=class{constructor(t){this.control=t}createView(t){var r;let e=document.createElement("div");e.classList.add(`${G}-control-container-${this.control.id}`),t(e,this.control.layoutParams);let n=((r=this.control.layoutParams.innerSizesDependOn)!=null?r:q.innerSizesDependOn)==="self"?{height:e.style.height,width:e.style.width}:{height:"var(--interactive-content-height)",width:"var(--interactive-content-width)"};return{controlContainerEl:e,dependsOn:n}}setEvents(t,e){t&&this.control.events.forEach(n=>{switch(n.type.trim().toLowerCase()){case"onclick":t.addEventListener("click",s=>{s.stopPropagation(),e&&e({action:n.action,controlId:this.control.id,controlType:this.control.type})});break;default:break}})}getElement(){return document.querySelector(`.${G}-control-container-${this.control.id}`)}};var ce=i=>{if(i.type.trim().toLowerCase()==="area")return new De(i)},De=class extends ut{constructor(t){super(t)}createView({parent:t,layoutFn:e}){let{dependsOn:n,controlContainerEl:r}=super.createView(e),s=document.createElement("button");return s.classList.add(`${G}-${this.control.id}`),s.setAttribute("data-testid",Mt.AREA),s.style.display="flex",s.style.width="100%",s.style.height="100%",s.style.cursor="pointer",s.type="button",ae({target:s,props:this.control.props,fallback:v(p({},q),{backgroundColor:"transparent"})}),oe({target:s,props:this.control.props,fallback:v(p({},q),{borderAlpha:0}),dependsOn:n}),At({target:s,layoutParams:this.control.layoutParams,fallback:q}),r.append(s),t.append(r),this.controlEl=s,r}disable(){this.controlEl&&(this.controlEl.style.cursor="default")}enable(){this.controlEl&&(this.controlEl.style.cursor="pointer")}getElement(){return document.querySelector(`.${G}-${this.control.id}`)}};var le=()=>{let i=document.createElement("span");return i.style.display="inline-block",i.style.whiteSpace="pre",i.style.overflow="hidden",i.style.textOverflow="ellipsis",i.style.maxWidth="100%",i.style.maxHeight="100%",i};var he=i=>{if(i.type.trim().toLowerCase()==="button")return new He(i)},He=class extends ut{constructor(t){super(t)}createView({parent:t,layoutFn:e}){let{dependsOn:n,controlContainerEl:r}=super.createView(e),s=document.createElement("button");s.type="button",s.classList.add(`${G}-${this.control.id}`),s.setAttribute("data-testid",Mt.BUTTON),s.style.display="flex",s.style.width="100%",s.style.height="100%",s.style.cursor="pointer",s.style.fontFamily="inherit";let l=le();return At({target:s,layoutParams:this.control.layoutParams,fallback:q}),ae({target:s,props:this.control.props,fallback:q}),oe({target:s,props:this.control.props,fallback:q,dependsOn:n}),se({target:s,props:this.control.props}),re({target:l,props:this.control.props,fallback:q,dependsOn:n}),s.append(l),r.append(s),t.append(r),this.controlEl=s,r}disable(){this.controlEl&&(this.controlEl.style.cursor="default")}enable(){this.controlEl&&(this.controlEl.style.cursor="pointer")}getElement(){return document.querySelector(`.${G}-${this.control.id}`)}};var Ri=i=>{if(i.type.trim().toLowerCase()==="text")return new Ge(i)},Ge=class extends ut{constructor(t){super(t)}createView({parent:t,layoutFn:e}){let{dependsOn:n,controlContainerEl:r}=super.createView(e),s=document.createElement("div");s.classList.add(`${G}-${this.control.id}`),s.setAttribute("data-testid",Mt.TEXT),s.style.display="flex",s.style.width="100%",s.style.height="100%",s.style.fontFamily="inherit";let l=le();return At({target:s,layoutParams:this.control.layoutParams,fallback:q}),se({target:s,props:this.control.props}),re({target:l,props:this.control.props,fallback:q,dependsOn:n}),s.append(l),r.append(s),t.append(r),this.controlEl=s,r}disable(){}enable(){}getElement(){return document.querySelector(`.${G}-${this.control.id}`)}};var Ue=class{constructor(t){this.layout=t}},_i=i=>{if(i.type.trim().toLowerCase()==="relative")return new Ft(i)},Ft=class extends Ue{constructor(t){super(t)}setContainerLayout(t){t.style.position="relative"}setControlLayout(t,e){t.style.position="absolute",t.style.width=`calc(var(--interactive-content-width) * ${e.width})`,t.style.height=`calc(var(--interactive-content-height) * ${e.height})`,t.style.left=`calc(var(--interactive-content-width) * ${e.x} + ((var(--interactive-width) - var(--interactive-content-width)) / 2))`,t.style.top=`calc(var(--interactive-content-height) * ${e.y} + ((var(--interactive-height) - var(--interactive-content-height)) / 2))`}};var ft,de,Ai,Lt=class{constructor(t){I(this,ft);this.container=t,this.factories=new Map,$(this,ft,de).call(this)}addControlFactory(t,e){this.factories.set(t.trim().toLowerCase(),e),$(this,ft,de).call(this)}removeControlFactory(t){this.factories.delete(t.trim().toLowerCase()),$(this,ft,de).call(this)}};ft=new WeakSet,de=function(){this.controls=$(this,ft,Ai).call(this)},Ai=function(){var t;return(t=this.container.controls)==null?void 0:t.reduce((e,n)=>{let r=n.type.trim().toLowerCase(),s=this.factories.get(r);return s?[...e,s(n)]:[...e]},[])};var pe=(i,t)=>{if(i.type.trim().toLowerCase()==="choice")return new ze(i,t)},ze=class extends Lt{constructor(t,e){super(t),this.rootElement=e!=null?e:ne(),this.layout=new Ft(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",he),this.addControlFactory("text",Ri),this.addControlFactory("area",ce)}createView(t){let e=document.createElement("div");return e.classList.add(`${G}-${this.container.id}`),this.layout.setContainerLayout(e),this.controls.forEach(n=>{let r=n.createView({parent:e,layoutFn:this.layout.setControlLayout});n.setEvents(r,t)}),this.rootElement.append(e),this.isRemoved=!1,e}hide(){let t=this.getElement();t&&(t.style.visibility="hidden")}show(){let t=this.getElement();t&&(t.style.visibility="visible")}enable(){let t=this.getElement();t&&(this.controls.forEach(e=>e.enable()),t.style.opacity=1,this.isDisabled=!1)}disable(){let t=this.getElement();t&&(this.controls.forEach(e=>e.disable()),t.style.opacity=Vi,this.isDisabled=!0)}removeView(){var t;this.isRemoved||((t=this.getElement())==null||t.remove(),this.isRemoved=!0)}getElement(){return this.rootElement.querySelector(`.${G}-${this.container.id}`)}};import{Subject as ts,ValueSubject as nt,Observable as cn,once as es,Subscription as is,CC as ns,combine as ss}from"@vkontakte/videoplayer-shared";import{loadVKLangPack as En}from"@vkontakte/videoplayer-shared";function ue(i,t){let e;return(...n)=>{clearTimeout(e),e=setTimeout(()=>i(...n),t)}}var Dt={Object:"Object",String:"String",Array:"Array",Number:"Number",Function:"Function",Boolean:"Boolean"},Et=(i,t)=>Object.prototype.toString.call(i)===`[object ${t}]`,Ht=i=>Et(i,Dt.Object),fe=i=>Et(i,Dt.String),me=i=>Et(i,Dt.Array),ye=i=>Et(i,Dt.Number),Mi=i=>Et(i,Dt.Function);var We=i=>ye(i)&&!isNaN(i);var It=i=>Ht(i)&&Object.keys(i).length===0,Qe=i=>me(i)&&!i.length;var Gt=(i,t)=>fe(i)&&(t?i.trim():i).length;var Li="video_interactive",Ni="videoint";var In=250,Ut=class{constructor(t){O(this,"onResize",t=>{this.isReady&&(!t[0].contentRect.width||!t[0].contentRect.height||(this.lastZoomInfo&&this.ngEditor.zoomTo(this.getNextPoint()),this.ngEditorSize={width:t[0].contentRect.width,height:t[0].contentRect.height}))});O(this,"handleChapterChange",t=>{var e;if(this.isReady){if(this.isHidden||this.hide(),!(t!=null&&t.id)){(e=this.onError)==null||e.call(this,"Id is not found"),console.error("Id is not found");return}this.visitedChapterIds.add(t.id),this.ngEditor.selectChapter(t.id),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId=t.id,this.lastZoomInfo=void 0}});O(this,"handleManifestChange",(n,...r)=>V(this,[n,...r],function*(t,e=[]){var s;if(!ye(t.graph.edit.chapters[0].x)){this.isReady=!1,(s=this.onError)==null||s.call(this,"Can't show graph"),console.error("Can't show graph");return}if(this.lastZoomInfo=void 0,!this.ngEditor){let l;try{l=yield En(this.lang,Li,Ni)}catch(c){console.log("Unable to load graph language pack")}let{GraphEditor:o}=yield import("@interactiveplatform/movika-graph-editor");this.ngEditor=new o(this.graphWrapperElement,{mode:"read",lang:this.lang,translation:l}),this.ngEditor.on("control",({name:c,chapterId:h})=>{c==="openPreview"&&this.onOpenPreviewClick(h)}),this.ngEditor.on("zoomEnd",c=>{this.lastZoomInfo=p({},c)})}this.visitedChapterIds=new Set(e),t.metadata.id!==this.currentManifestId?(this.ngEditor.update(t),this.currentManifestId=t.metadata.id):this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.isReady=!0}));this.init(t)}init({root:t,onOpenPreviewClick:e,onError:n,lang:r,visitedChapters:s=[]}){this.isHidden=!0,this.currentManifestId=void 0,this.currentChapterId=void 0,this.visitedChapterIds=new Set(s),this.onOpenPreviewClick=e,this.onError=n,this.lang=r!=null?r:"ru",this.zoom=.7,this.isReady=!1,this.lastZoomInfo=void 0,this.ngEditorSize=void 0,this.ngEditor=void 0,this.graphWrapperElement=xn(t),this.resizeObserver=new ResizeObserver(ue(this.onResize,In)),this.resizeObserver.observe(this.graphWrapperElement)}getNextPoint(t=this.ngEditorSize){return[(this.lastZoomInfo.x-t.width/2)/this.lastZoomInfo.value*-1,(this.lastZoomInfo.y-t.height/2)/this.lastZoomInfo.value*-1]}setVisitedChapters(t){this.visitedChapterIds=new Set([...this.visitedChapterIds,...t]),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds))}updateVideosInfo(t){this.ngEditor.updateVideosInfo(t)}show(){!this.ngEditor||!this.isReady||(this.graphWrapperElement.style.display="block",this.lastZoomInfo||this.ngEditor.focusChapter(this.currentChapterId),this.isHidden=!1)}hide(){this.graphWrapperElement.style.display="none",this.isHidden=!0}destroy(){var t,e;this.hide(),this.resizeObserver.disconnect(),(t=this.ngEditor)==null||t.setVisitedChapters([]),this.onOpenPreviewClick=void 0,(e=this.ngEditor)==null||e.dispose(),this.graphWrapperElement.remove(),this.isReady=!1}};function xn(i){let t=document.createElement("div");return t.style.position="absolute",t.style.top="0",t.style.left="0",t.style.height="100%",t.style.width="100%",t.style.display="none",i.append(t),t}var Ke=()=>{let i=[],t=null;return{setPlayer:l=>{t=l},setContainers:l=>{i=l},deleteContainer:l=>{i=i.filter(o=>o.id!==l)},getNextInteractiveTime:(l=3e3)=>{if(!i.length||t===null)return null;let o=-1,c=!1,h=Math.round(t.info.position$.getValue()*1e3);for(let b of i){let C=b.startTime-l;if(C<=h&&(h<=b.endTime||b.endTime===null)){c=!0;break}h<C&&(o=o===-1?C:Math.min(o,C))}return!c&&o!==-1?o:null}}};var mt=(i="",t="")=>{i=i.split("."),t=t.split(".");let e=0;for(let n=0;n<Math.max(i.length,t.length)&&!e;n++)i[n]>t[n]?e=1:i[n]<t[n]?e=-1:e=0;return e};import{v4 as Tn}from"uuid";var Sn="3.1",ki={default:"setNextBranch",random:"setRandomBranch",weightlessRandom:"setWeightlessRandomBranch",max:"setMaxWeightBranch",min:"setMinWeightBranch"},wn={type:"onSuspense",action:{type:"continuePlayback",args:{shouldOpenNow:!0,isDetachContainer:!0}}},ji=i=>{let t=[];for(let l of i.chapters){let o,c=[];for(let e of l.branches){let n=e,{isDefault:C}=n,E=X(n,["isDefault"]);C&&(o=E.id),c.push(E)}let h=[],b=[];for(let r of l.containers){let s=r,{fallbackStrategy:C}=s,E=X(s,["fallbackStrategy"]);let S=!!E.endTime,x=[wn];switch(C){case"await":S?x=[]:h=[];break;case"default":{let R={type:"onSuspense",action:{type:ki.default,args:{branchId:o,shouldOpenNow:!S,isDetachContainer:!0}}};S?x=[R]:h=[R];break}case"random":case"weightlessRandom":case"max":case"min":{let R={type:"onSuspense",action:{type:ki[C],args:{}}};S?x=[R]:h=[R];break}}for(let R of E.controls)b.push(v(p({},E),{controls:[p({},R)],id:Tn(),events:x}))}t.push(v(p({},l),{containers:b,events:h,branches:c}))}return i.metadata.version=Sn,i.metadata.updated=new Date().toISOString(),v(p({},i),{chapters:t})};var Vn="3.2",Pi=i=>{if(!i.media){let t=i.metadata,{media:e}=t,n=X(t,["media"]);return v(p({},i),{metadata:v(p({},n),{version:Vn}),media:e})}return i};var Rn="3.3",_n=(i=[])=>({edit:{chapters:i},view:{}}),$i={type:"onSuspense",action:{type:"expect",args:{shouldOpenNow:!0,isDetachContainer:!0}}},Oi=i=>{var r;let t=[],e=[];for(let s of i.chapters){let n=s,{id:l,x:o,y:c}=n,h=X(n,["id","x","y"]),b=h.containers.map(C=>{var E;return v(p({},C),{controls:C.controls.map(_=>{var f=_,{subtype:S,type:x}=f,R=X(f,["subtype","type"]);return v(p({},R),{type:S!=null?S:x})}),events:(E=C.events)!=null&&E.length?C.events:[$i]})});t.push(v(p({id:l},h),{containers:b,events:(r=h.events)!=null&&r.length?h.events:[$i]})),e.push({id:l,x:o,y:c})}return v(p({},i),{chapters:t,graph:_n(e),metadata:v(p({},i.metadata),{version:Rn})})};var An=[{version:"3.0",migrate:ji},{version:"3.1",migrate:Pi},{version:"3.2",migrate:Oi}],Xe=i=>An.reduce((t,e)=>mt(t.metadata.version,e.version)?t:e.migrate(t),i);var xr=Object.freeze({Choice:"Choice",TextInput:"TextInput"}),Bi=Object.freeze({Button:"Button",Area:"Area",Text:"Text"}),Tr=Object.freeze({onClick:"onClick",onSuspense:"onSuspense"}),P=Object.freeze({openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"}),qe=(s=>(s.GO_NEXT_BUTTON="GO_NEXT_BUTTON",s.GO_NEXT_AREA="GO_NEXT_AREA",s.WATCH_AGAIN="WATCH_AGAIN",s.OPEN_GRAPH="OPEN_GRAPH",s.CLOSE_GRAPH="CLOSE_GRAPH",s))(qe||{});var Fi={metadata:"Object",chapters:"Array"},Mn="3.0.0",Ln="3.3.0",ge=i=>{let t=mt(i,Mn);return t===-1?!1:t===0?!0:mt(i,Ln)!==1},Di=i=>{if(!Ht(i))return!1;for(let t in Fi)if(!i[t]||!Et(i[t],Fi[t]))return!1;return ge(i.metadata.version)},ve=i=>i.type===Bi.Text;var w=class{constructor(t,e,...n){this.severity=t,this.category=e,this.data=n}toString(){return`SDK_NAME ERROR ${JSON.stringify(this,null," ")}`}};O(w,"Severity",{RECOVERABLE:1,CRITICAL:2}),O(w,"Category",{VIDEO:0,INTERACTIVES:1,GRAPH:2,MANIFEST:3,LOADERS:4,HISTORY:5,SEAMLESS:6});var Nt=class{constructor(){O(this,"listeners",{})}addListener(t,e){return this.listeners[t]=this.listeners[t]||[],this.listeners[t].push(e),this}on(t,e){return this.addListener(t,e)}once(t,e){this.listeners[t]=this.listeners[t]||[];let n=()=>{e(),this.off(t,n)};return this.listeners[t].push(n),this}off(t,e){return this.removeListener(t,e)}reset(){this.listeners={}}removeListener(t,e){let n=this.listeners[t];if(!n)return this;for(let r=n.length;r>0;r--)if(n[r]===e){n.splice(r,1);break}return this}emit(t,...e){let n=this.listeners[t];return n?(n.forEach(r=>{r(...e)}),!0):!1}listenerCount(t){return(this.listeners[t]||[]).length}rawListeners(t){return this.listeners[t]}};var be=class{constructor(t){O(this,"addFn",(t,e=!1)=>{Mi(t)&&(this.fns.push(t),e&&this.updateFn())});O(this,"removeFn",(t,e=!1)=>{this.fns=this.fns.filter(n=>n!==t),e&&this.updateFn()});O(this,"updateFn",()=>{this.fn=()=>{this.fns.forEach(t=>t()),this.raf&&this.forceRequestAnimation()}});O(this,"forceRequestAnimation",()=>{this.fn&&(this.raf=requestAnimationFrame(this.fn))});O(this,"requestAnimation",()=>{this.raf||this.forceRequestAnimation()});O(this,"cancelAnimation",()=>{cancelAnimationFrame(this.raf),this.raf=void 0});this.raf,this.fn,this.fns=[],this.addFn(t)}release(){this.cancelAnimation(),this.fn=void 0,this.fns=[]}};import{ValueSubject as Bn}from"@vkontakte/videoplayer-shared";var Ce=class{constructor(t){var e,n;this.loaders={chapterLoaders:(e=t==null?void 0:t.chapterLoaders)!=null?e:[],manifestLoaders:(n=t==null?void 0:t.manifestLoaders)!=null?n:[]}}exec(t,e){return V(this,null,function*(){return Nn(...this.loaders[t])(e)})}};function Nn(...i){return function(e){return V(this,null,function*(){let n=[...i];for(;n.length>0;)e=yield n.shift()(e);return e})}}function zt(i,t,e){return i?v(p({},i),{[t]:i[t]?[e,...i[t]]:[e]}):{[t]:[e]}}function Ee(r){var s=r,{actions:i,errors:t,chapterId:e}=s,n=X(s,["actions","errors","chapterId"]);if(e){let l=i.getManifest(),o=i.getChapter(l.chapters,e);if(o){let c=i.getMedia(l.media,o.videoId),h=i.getGraph(l.graph,o.id);return c?v(p({},n),{actions:i,errors:t,result:{chapter:o,media:c,graph:h}}):v(p({},n),{errors:zt(t,Ee.name,"Could not find media"),actions:i})}}return v(p({},n),{errors:zt(t,Ee.name,"Could not find chapter"),actions:i})}var kn=i=>V(void 0,null,function*(){try{let t,e;if(Ht(i))t=i;else if(fe(i)){e=new URL(i).href;let r=yield fetch(e);if(!r.ok)return{};t=yield r.json()}else return{};if(!Di(t))return{};let n=t.metadata.media;if(fe(n)&&!t.media)try{let r;e?r=new URL(n,e).href:(r=new URL(n).href,e=r);let s=yield fetch(r);if(!s.ok)throw new Error;t.metadata.media=yield s.json()}catch(r){return $n(t.metadata.version)?{manifest:t}:{}}return{manifest:t,manifestURL:e}}catch(t){return{}}});function Hi(i){return V(this,null,function*(){let{manifest:t,manifestURL:e}=yield kn(i),n=Xe(t);return n.media=jn(n.media,e),delete n.metadata.media,n})}function Ie(i,t){return i.find(e=>e.id===t)}function Ze(i,t){var e,n;return(e=i.edit)!=null&&e.chapters?i.edit.chapters.find(r=>r.id===t):(n=i.view)!=null&&n.chapters?i.view.chapters.find(r=>r.id===t):void 0}function Ye(i,t){return i.videos.find(e=>e.id===t)}function jn(i,t){return v(p({},i),{videos:i.videos.map(e=>v(p({},e),{variants:e.variants.map(n=>{let r=Pn(n.url,t);return v(p({},n),{url:r||n.url})})}))})}function Pn(i,t){try{return new URL(i,t).href}catch(e){return""}}function $n(i){return mt(i,"3.2.0")>=0}var D=Object.freeze({nothing:0,beforeInteractive:1,interactive:2,afterInteractive:3,end:4,removed:5,destroyed:6}),xe=i=>me(i)&&!Qe(i),st=i=>i.order==="end",Te=i=>me(i.containers)&&!Qe(i.containers)&&st(i),Gi=(i,t)=>{var n;let e=i*1e3;return xe(t.controls)&&e<((n=t.startTime)!=null?n:0)},Je=(i,t)=>{var n,r;let e=i*1e3;return xe(t.controls)&&e>=((n=t.startTime)!=null?n:0)&&e<=((r=t.endTime)!=null?r:1/0)};var xt=i=>i.some(t=>t.action.type==="expect"),ti=i=>i.find(t=>t.action.type==="expect"),On=i=>(i==null?void 0:i.length)===1,Se=i=>On(i)&&ve(i[0]);var Ui=({fn:i,type:t=1},...e)=>(...n)=>t?i(...n,...e):i(p(p({},n[t]),e[t])),zi=(i,t)=>xt(i.events)?!1:t.some(({container:e})=>e.container.id!==i.id&&xt(e.container.events)&&e.container.endTime===i.endTime&&!e.isRemoved);var kt=class extends Ce{constructor(t,e){super(t),this.onError=e,this.prevChapter$=new Bn(null),this.release()}release(){return this.manifest=null,this.chapter=null,this.media=null,this.graph=null,this.prevChapter$.next(null),this}setManifest(t){return V(this,null,function*(){var r;this.release();let e=yield this.exec("manifestLoaders",{actions:{addErrorMessage:zt},result:null,errors:null,source:t});e.errors&&this.errorHandler(e.errors);let n=yield Hi((r=e.result)!=null?r:t);return this.manifest=n,this})}setInitial(){return V(this,null,function*(){return this.setNext()})}setNext(){return V(this,arguments,function*(t=this.manifest.metadata.initChapterId){this.prevChapter$.next(this.chapter);let e=yield this.exec("chapterLoaders",Ee({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:Ze,getChapter:Ie,getMedia:Ye,getByBranches:this.getByBranches.bind(this),addErrorMessage:zt},result:null,errors:null,chapterId:t}));return e.errors&&this.errorHandler(e.errors),this.chapter=e.result.chapter,this.media=e.result.media,this.graph=e.result.graph,this})}errorHandler(t){this.onError(t),console.error("Something went wrong with loaders",{errors:t})}getInitial(){return this.getByChapterId(this.manifest.metadata.initChapterId)||null}getByChapterId(t=this.manifest.metadata.initChapterId){let e=Ie(this.manifest.chapters,t);if(e){let n=Ye(this.manifest.media,e.videoId),r=Ze(this.manifest.graph,e.id);if(n)return{chapter:e,media:n,graph:r}}return null}getBranches(t=this.chapter.id){if(t===this.chapter.id)return this.getByBranches(this.chapter.branches);{let e=Ie(this.manifest.chapters,t);return this.getByBranches(e==null?void 0:e.branches)}}getByBranches(t=[]){return t.reduce((e,n)=>{let r=this.getByChapterId(n.chapterId);return r&&e.push(r),e},[])}getCurrent(){return{chapter:this.chapter,media:this.media,graph:this.graph}}isInitialChapter(){return this.chapter.id===this.manifest.metadata.initChapterId}isEndChapter(){return st(this.chapter)}};import{Player as Fn}from"@vkontakte/videoplayer-core";import{Subscription as Dn}from"@vkontakte/videoplayer-shared";var Wi=i=>{let t=i.variants.find(e=>{var n;return((n=e.payload)==null?void 0:n.type)==="vk"});if(t&&"payload"in t){let[e,n]=t.payload.id.split("_");return[e,n]}return[]};var g={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},Wt={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},N={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};function ei(){let i=new Map;function t(o){var c=o,{listId:r=Math.random().toString(),itemId:s=Math.random().toString()}=c,l=X(c,["listId","itemId"]);let h=i.get(r),b=p({},l);return h?h[s]=b:i.set(r,{[s]:b}),p({listId:r,itemId:s},l)}function e(r,s){var o,c,h;let l=i.get(r);if(l){if(s)return(o=l[s])==null||o.player.destroy(),(c=l[s])==null||c.container.remove(),(h=l[s])==null||h.subscription.unsubscribe(),delete l[s],Object.keys(l).length||i.delete(r),!0;for(let b of Object.values(l))b.player.destroy(),b.container.remove();return i.delete(r),!0}else throw Error("Can't remove. Not find.")}function n(){for(let r of i)e(r[0])}return{createPlayer:t,removePlayer:e,map:i,removeAll:n}}function ii(i,t=[]){var s,l,o;let e={},n,r=!t.length;for(let c of i.variants)if(!n&&"cover"in c&&(n=c.cover),"url"in c)switch(c.type.toLowerCase()){case"mp4":(r||t.includes("mp4"))&&(e.MPEG=v(p({},e.MPEG),{[(s=c.standard)!=null?s:"Invariant quality"]:c.url}));break;case"mpeg":(r||t.includes("mpeg"))&&(e.MPEG=v(p({},e.MPEG),{[(l=c.standard)!=null?l:"Invariant quality"]:c.url}));break;case"hls":(r||t.includes("hls"))&&(e=v(p({},e),{HLS:{type:"url",url:c.url}}));break;case"dash":(r||t.includes("dash"))&&(e=v(p({},e),{DASH_SEP:{compatibilityMode:!0,type:"url",url:c.url}}));break;default:break}return{sources:e,thumbUrl:n,title:(o=i.title)!=null?o:""}}var Qt=(i,t)=>{let e=i.info.currentQuality$.getValue(),n=i.info.availableQualities$.getValue();e!==t&&n.includes(t)&&(i.setQuality(t),i.setAutoQuality(!1))};var Kt={activePlayerChanged:"sc-active-player-changed",initiated:"sc-initiated",playerCreated:"sc-player-created"},Hn=2;function ni(i){let t=ei(),e,n,r=new Nt,s={},l=!1,o=null,c=!1,h;i&&b(i);function b(d){o=d}function C(d,y,T){var j;if(!o)throw Error("need to set interactive controller");if(!o.options)return;let M=((j=t.map.get(d))!=null?j:{})[y];if(M){s=p({chapterId:T,listId:d,itemId:y},M);let F=s.player;n=F.info.currentQuality$.subscribe(L=>{if(!(!L||!F.info.position$.getValue())){e=L;for(let et of t.map)Object.values(et[1]).forEach(({player:J})=>{F.info.isAutoQualityEnabled$.getValue()||Qt(J,L)})}}),M.container.remove(),l=!1,o.setPlayer(M.player),c||(o.init(),c=!0),r.emit(Kt.activePlayerChanged,{player:s.player,config:s.config});return}throw Error("Can't set. Not find.")}function E(d,y,T){return V(this,null,function*(){if(!o)throw Error("need to set interactive controller");if(It(s)||d!==s.itemId)return;if(T>=0&&!l){let M=o.getChapterBranches();l=!0;let j=new Set;for(let F of M)j.has(F.media.id)||(yield x({media:F.media,chapterId:F.chapter.id,setAsActive:!1,title:F.chapter.label}),j.add(F.media.id))}})}function S(T){return V(this,arguments,function*({chapter:{id:d},media:y}){if(It(s))return;n==null||n.unsubscribe();let u=s.player.info.muted$.getValue(),M=s.player.info.currentQuality$.getValue(),j=s.player.info.isAutoQualityEnabled$.getValue(),F=s.player.info.volume$.getValue(),L=s.player.info.currentPlaybackRate$.getValue(),et=!j,J=!1;for(let Q of t.map)if(Q[0]===y.id){let pt=Object.keys(Q[1]);for(let K of pt)K===s.itemId?(pt.length<Hn||(J=!0),t.removePlayer(Q[0],K)):(J=!0,C(Q[0],K,d),et?Qt(s.player,M):s.player.setAutoQuality(!0),s.player.setVolume(F),s.player.setMuted(u),s.player.setPlaybackRate(L))}else t.removePlayer(Q[0]);J||(yield x({media:y,chapterId:d,setAsActive:!0,playbackRate:L}),et?Qt(s.player,M):s.player.setAutoQuality(!0),s.player.setVolume(F),s.player.setMuted(u))})}function x(et){return V(this,arguments,function*({media:d,chapterId:y,prefetch:T=!0,setAsActive:u=!0,autoplay:M=!1,preferredExt:j,title:F,playbackRate:L}){var fi,mi,yi,gi,vi;let J=Math.random().toString(),Q=document.createElement("div");h.append(Q);let pt=(fi=s==null?void 0:s.player)==null?void 0:fi.info.isAutoQualityEnabled$.getValue(),K;if((mi=o==null?void 0:o.options)!=null&&mi.vkVideoLoader){let ee=Wi(d);ee.length&&(K=yield o.options.vkVideoLoader(...ee))}let di=((yi=o==null?void 0:o.options)==null?void 0:yi.coreConfig)||{},yn=v(p({},di),{configName:[...(gi=di.configName)!=null?gi:[],"interactive"]}),pi=v(p({container:Q},((vi=K==null?void 0:K.videos)==null?void 0:vi[0])||{sources:ii(d,j).sources}),{title:F,failoverHosts:(K==null?void 0:K.failoverHosts)||[]}),Ct=new Fn(yn);Ct.initVideo(pi);let ui=new Dn;ui.add(Ct.info.position$.subscribe(function(ee){E(J,Ct.info.duration$.getValue(),ee)})).add(Ct.events.canplay$.subscribe(function(){pt||Qt(Ct,e),L&&Ct.setPlaybackRate(L)}));let _t=t.createPlayer({listId:d.id,itemId:J,player:Ct,container:Q,sources:ii(d,j).sources,config:pi,subscription:ui});return u&&C(d.id,_t.itemId,y),M&&_t.player.play(),T&&!M&&_t.player.prepare(),r.emit(Kt.playerCreated,_t.player),{player:_t.player,config:_t.config}})}function R(){_(),o=null}function _(){o==null||o.off(g.chapterChanged,S),t.removeAll(),s={},c=!1,l=!1}function f(y){return V(this,arguments,function*({container:d}){if(!o)throw Error("need to set interactive controller");_(),h=d;let{media:T,chapter:u}=o.getCurrentChapter();if(T){o.on(g.chapterChanged,S);let{player:M,config:j}=yield x({media:T,chapterId:u.id,title:u.label});return r.emit(Kt.initiated,{container:d,media:T,chapterId:u.id}),{player:M,config:j}}else console.error("not found")})}return v(p({},t),{on:r.on.bind(r),off:r.off.bind(r),init:f,setInteractiveController:b,createPlayer:x,removeAll:R,getActivePlayer:function(){return s}})}import{Subscription as Gn}from"@vkontakte/videoplayer-shared";var we=class{constructor({player:t,container:e,branches:n,selectBranches:r,interactiveEvents:s,globalEventEmitter:l,ignoreContainerEvent:o,permanentTextControls:c,disabledControls$:h,onRemove:b}){O(this,"hide",()=>{setTimeout(()=>{var t,e;this.gameState!==D.end&&(xt(this.container.container.events)&&this.gameState===D.afterInteractive||this.selectBranches.state.isExpect||(this.gameState!==D.interactive&&((e=(t=this.container).hide)==null||e.call(t)),this.globalEventEmitter.emit(g.interactives,{subjectId:this.container.container.id,subjectName:"container",type:N.visibility,visibility:!1})))})});O(this,"show",()=>{var t,e,n,r;if(this.gameState===D.interactive&&!this.isSelectedControlEvent)if(this.container.getElement())(r=(n=this.container).show)==null||r.call(n),this.globalEventEmitter.emit(g.interactives,{subjectId:this.container.container.id,subjectName:"container",type:N.visibility,visibility:!0,isFirst:!1});else{let l=Ui({fn:this.selectBranches.onControlEvent,type:0},{isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.globalEventEmitter.emit(g.interactives,{subjectId:this.container.container.id,subjectName:"container",type:N.visibility,visibility:!1})},onEvent:(o,c)=>{this.isSelectedControlEvent=!0,o!==!1&&(this.removeView(),this.globalEventEmitter.emit(g.interactives,{subjectId:this.container.container.id,subjectName:"container",type:N.visibility,visibility:!1})),(this.gameState===D.end||this.gameState===D.afterInteractive||this.selectBranches.state.isExpect)&&(this.selectBranches.stopExpect(),c(),this.removeView(),this.globalEventEmitter.emit(g.interactives,{subjectId:this.container.container.id,subjectName:"container",type:N.visibility,visibility:!1}))},isEOV:()=>this.gameState===D.end});this.container.createView(l),this.globalEventEmitter.emit(g.interactives,{subjectId:this.container.container.id,subjectName:"container",type:N.visibility,visibility:!0,isFirst:!0}),this.disabledControls$.getValue()&&((e=(t=this.container).disable)==null||e.call(t))}});O(this,"onEndOfVideo",()=>{this.gameState=D.end,this.selectContainerEvent(!0)});O(this,"whilePlaying",()=>{var s,l;if(((s=this.player.experimental.element$.getValue())==null?void 0:s.readyState)<1||[D.destroyed,D.removed].includes(this.gameState)&&!this.isPermanentText)return;let e=this.player.getExactTime();if(Gi(e,this.container.container))this.gameState!==D.beforeInteractive&&(this.gameState=D.beforeInteractive,this.onBeforeStartTime());else if(Je(e,this.container.container))this.gameState!==D.interactive&&(this.gameState=D.interactive,this.onStartTime());else if(this.gameState!==D.afterInteractive){let o=this.gameState;this.gameState=D.afterInteractive,o===D.interactive&&this.onEndTime()}else this.gameState!==D.destroyed&&!this.isPermanentText&&this.removeView();let n=Je(e,this.container.container),r=this.container.container.startTime?[this.container.container.startTime,(l=this.container.container.endTime)!=null?l:1/0]:[];this.globalEventEmitter.emit(g.eachTick,{subjectId:this.container.container.id,subjectName:"container",range:r,currentTime:e,isInteractiveTime:n})});this.container=e,this.branches=n,this.selectBranches=r,this.subscription=new Gn,this.player=t,this.interactiveEvents=s,this.ignoreContainerEvent=o,this.isPermanentText=c&&Se(e.container.controls),this.disabledControls$=h,this.onRemove=b,this.globalEventEmitter=l,this.gameState=D.nothing,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}registerEvents(){this.subscription.add(this.player.events.playing$.subscribe(this.show)).add(this.player.events.paused$.subscribe(this.hide)).add(this.player.events.ended$.subscribe(this.onEndOfVideo)).add(this.disabledControls$.subscribe(t=>{var e,n,r,s;t?(n=(e=this.container).disable)==null||n.call(e):(s=(r=this.container).enable)==null||s.call(r)}))}selectContainerEvent(t=!1){this.interactiveEvents.containersEventsCallState.setCalled({timestamp:t?1/0:this.container.container.endTime,id:this.container.container.id}),!(this.isSelectedControlEvent||this.isSelectedContainerEvent)&&(this.isSelectedContainerEvent=!0,this.ignoreContainerEvent()||this.selectBranches.setManifestContainerEvents({container:this.container.container,branches:this.branches,isEOV:t}),!t&&this.interactiveEvents.exec(this.container.container.endTime))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);let t=xt(this.container.container.events)||this.ignoreContainerEvent();(this.isSelectedControlEvent||!t)&&this.removeView()}onBeforeStartTime(){var t,e;(e=(t=this.container).hide)==null||e.call(t),this.globalEventEmitter.emit(g.interactives,{subjectId:this.container.container.id,subjectName:"container",type:N.visibility,visibility:!1})}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=D.beforeInteractive}removeView(){var t;this.container.removeView(),this.globalEventEmitter.emit(g.interactives,{subjectId:this.container.container.id,subjectName:"container",type:N.containerRemoved,visibility:!1}),this.gameState=D.removed,(t=this.onRemove)==null||t.call(this)}destroy(){var t;this.reset(),this.removeView(),this.gameState=D.destroyed,this.subscription.unsubscribe(),this.branches=[],this.interactiveEvents.containersEventsCallState.setCalled({timestamp:(t=this.container.container.endTime)!=null?t:1/0,id:this.container.container.id})}};var Qi=(i=[])=>i.reduce((t,e,n)=>{var s,l,o;let r=((s=e==null?void 0:e.controls)!=null?s:[]).filter(c=>!ve(c));if(xe(r)){let c=[(l=e.startTime)!=null?l:0,(o=e.endTime)!=null?o:1/0],h=e.id;if(!n)t.push({subjects:[h],range:c});else{let b=[],C=-1/0,E=1/0,S=[],x=[];for(let R=0;R<t.length;R++){let _=t[R];if(x.push(..._.subjects),_.range[0]<E&&(E=_.range[0]),_.range[1]>C&&(C=_.range[1]),c[0]>=_.range[0]&&c[1]<=_.range[1])return t[R].subjects.push(h),t;c[0]<_.range[0]&&c[1]>_.range[0]&&(b.push(R),S=S.concat(_.subjects)),c[0]>=_.range[0]&&c[0]<=_.range[1]&&(b.push(R),S=S.concat(_.subjects),c[0]=_.range[0]),c[1]>=_.range[0]&&c[1]<=_.range[1]&&(b.push(R),S=S.concat(_.subjects),c[1]=_.range[1])}if(x.push(h),c[0]<=E&&c[1]>=C)return[{subjects:x,range:c}];b.length&&b.reverse().forEach(R=>{t.splice(R,1)}),t.push({subjects:S.concat([h]),range:c})}}return t},[]).sort((t,e)=>t.range[0]-e.range[0]);function Ki(){let i={};function t(){for(let o in i)Object.prototype.hasOwnProperty.call(i,o)&&delete i[o];return!0}function e(o){let c={};for(let h in i)+h<=o&&(c[h]=i[h]);return c}function n(o){let c={};for(let h in i)+h>=o&&(c[h]=i[h]);return c}function r({timestamp:o,priority:c,initiator:h}){var b;if(We(o)){let C=(b=i[o])!=null?b:null;if(C&&Gt(c,!0)){let E={},S=C[c];if(S&&(E=p(p({},E),S)),E=It(E)?null:E,E&&Gt(h,!0)){let x=E[h];return x!=null?x:null}return E}return C}return null}function s({timestamp:o,priority:c,initiator:h}){if(We(o))if(i[o]){if(Gt(c,!0))if(i[o][c]){if(Gt(h,!0))if(i[o][c][h]){if(delete i[o][c][h],!It(i[o][c]))return!0}else return!1;if(delete i[o][c],!It(i[o]))return!0}else return!1;return delete i[o]}else return!1}function l(C){var E=C,{timestamp:o,priority:c,initiator:h}=E,b=X(E,["timestamp","priority","initiator"]);var S,x,R;(x=(S=i[o])==null?void 0:S[c])!=null&&x[h]?i[o][c][h].push(p({},b)):(R=i[o])!=null&&R[c]?i[o][c]=v(p({},i[o][c]),{[h]:[p({},b)]}):i[o]?i[o]=v(p({},i[o]),{[c]:{[h]:[p({},b)]}}):i[o]={[c]:{[h]:[p({},b)]}}}return{map:i,remove:s,add:l,removeAll:t,get:r,getLte:e,getGte:n}}var Un=[P.expect,P.setNextBranch],zn=1/0;function si(i){let t=i,e,n=Wn(),r=new Ki,s,l=()=>{E(),f()},o=d=>{r.add.call(void 0,d),x()},c=(d=[])=>{for(let y of d)if(y.action(),Un.includes(y.actionType))break},h=(d=1/0)=>{var M,j,F;let y=Ve((M=r.get({timestamp:d,priority:"control"}))!=null?M:{}),T=Ve((j=r.get({timestamp:d,priority:"container"}))!=null?j:{}),u=Ve((F=r.get({timestamp:d,priority:"chapter"}))!=null?F:{});return[...y,...T,...u]},b=d=>{n.isReady(d)&&c(h(d))},C=()=>{var d;c([...Ve((d=r.get({timestamp:1/0,priority:"chapter"}))!=null?d:{})])},E=()=>{e&&(s==null||s.unsubscribe(),e=void 0)},S=d=>{},x=()=>{e||(e=()=>setTimeout(()=>{b(1/0)}),s=t.events.ended$.subscribe(e))},R=d=>{E(),t=d},_=d=>{d.priority==="container"&&n.resetCalled(d.timestamp),r.remove(d)},f=()=>{n.release(),r.removeAll()};return{setPlayer:R,add:o,remove:_,exec:b,execEndOfVideo:C,listen:x,unlisten:E,release:l,containersEventsCallState:n,getPreparedToExecActions:h}}function Wn(){let i=new Map;return{setCalled:({timestamp:l,id:o})=>{let c=i.get(l);c&&c[o]!==void 0&&(c[o]=!0)},setData:(l=[])=>{var o,c;for(let h of l){let b=(o=h.endTime)!=null?o:zn,C=(c=i.get(b))!=null?c:{};i.set(b,v(p({},C),{[h.id]:!1}))}},resetCalled:l=>{let o=i.get(l);if(o)for(let c in o)o[c]=!1},isReady:l=>{let o=i.get(l);return o?!Object.values(o).some(c=>!c):!0},release:()=>i.clear()}}function Ve(i){return Object.values(i).flat().sort(t=>t.actionType===P.expect?-1:1)}var Xi=(i,t)=>{let{height:e,width:n}=t.info.intrinsicVideoSize$.getValue()||{};if(!(e&&n))return{videoContentHeight:0,videoContentWidth:0};let{clientHeight:r,clientWidth:s}=t.experimental.element$.value||{};if(!(r&&s))return{videoContentHeight:0,videoContentWidth:0};let l=e/n,o=r/s,c,h;return o>l?(h=s,c=s*l):o<l?(h=r/l,c=r):(h=s,c=r),{videoContentWidth:h,videoContentHeight:c}};var Qn=250;function qi(i){let t=()=>{},e=new ResizeObserver(o=>{s(o),t=s.bind(null,o)});function n(o){let{parentElement:c,player:h}=i();if(c&&h){let{videoContentWidth:b,videoContentHeight:C}=Xi(c,h);c.style.setProperty("--interactive-content-width",`${b}px`),c.style.setProperty("--interactive-content-height",`${C}px`),c.style.setProperty("--interactive-width",`${o[0].contentRect.width}px`),c.style.setProperty("--interactive-height",`${o[0].contentRect.height}px`)}}function r(){let{parentElement:o}=i();o.removeAttribute("style")}let s=ue(o=>{let{fns:c=[]}=i();n(o);for(let h of c)h()},Qn);function l(){t=void 0,e.disconnect(),r()}return{resizeObserver:e,calc:()=>{t()},release:l}}var Xt=class{constructor(){this.map={}}push(t,e){t in this.map?this.map[t].push(e):this.map[t]=[e]}get(t){let e=this.map[t];return e?e.slice():null}getAll(){let t=[];for(let e in this.map)t.push(...this.map[e]);return t}remove(t,e){t in this.map&&(this.map[t]=this.map[t].filter(n=>n!==e),this.map[t].length===0&&delete this.map[t])}clear(){this.map={}}size(){return Object.keys(this.map).length}keys(){return Object.keys(this.map)}};var Kn=i=>Math.floor(Math.random()*i),Zi=i=>{let t=i.length,e=1/0,n=null;for(;t--;)i[t].weight<e&&(e=i[t].weight,n=i[t]);return n},Yi=i=>{let t=i.length,e=-1/0,n=null;for(;t--;)i[t].weight>e&&(e=i[t].weight,n=i[t]);return n};var Ji=i=>{let t=i.length,e=Kn(t);return i[e]};var tn=i=>{var n,r;let t=0;for(let s=0;s<i.length;++s)t+=(n=i[s].weight)!=null?n:1;let e=Math.random()*t;t=0;for(let s=0;s<i.length-1;++s)if(t+=(r=i[s].weight)!=null?r:1,t>=e)return i[s];return i[i.length-1]};var en=Object.freeze({shouldOpenNow:!0,isDetachContainer:!0});var ri=(i,t=!1)=>v(p({},i),{args:t?p(p({},i.args),en):p(p({},en),i.args)}),ai=({globalEventEmitter:i,player:t,interactiveEvents:e,removeControllers:n})=>{let r={isExpect:!1},s=()=>{r.isExpect&&(r.isExpect=!1)},l=({action:f,controlType:d,controlId:y,containerId:T,branches:u=[],onEvent:M,isEOV:j=()=>!1,isDisabled:F=()=>!1})=>{let L=ri(f,j()),et={timestamp:1/0,priority:"control",initiator:y,actionType:L.type},J=F(),Q=i.emit.bind(i,g.interactives,{subjectId:y,subjectType:d,subjectName:"control",type:J?N.actionChoiceCanceled:N.actionChoice,actionType:f.type,payload:p({containerId:T},L.args)});if(J){Q();return}switch(L.type.trim().toLowerCase()){case P.setNextBranch.trim().toLowerCase():{let pt=u.find(K=>K.id===L.args.branchId);if(!pt)return;M(L.args.isDetachContainer,E.bind(null,{subjectId:y,subjectName:"control"})),Q(),L.args.shouldOpenNow?x({subjectId:y,subjectName:"control",subjectType:d,action:L,payload:{chapterId:pt.chapterId,autoSelect:!1}}):(e.add(v(p({},et),{action:x.bind(null,{subjectId:y,subjectName:"control",subjectType:d,action:L,payload:{chapterId:pt.chapterId,autoSelect:!1}})})),n==null||n());return}case P.continuePlayback.trim().toLowerCase():{M(L.args.isDetachContainer,E.bind(null,{subjectId:y,subjectName:"control"})),Q(),L.args.shouldOpenNow?S({subjectId:y,subjectName:"control",subjectType:d,action:f}):e.add(v(p({},et),{action:S.bind(null,{subjectId:y,subjectName:"control",subjectType:d,action:f})}));return}case P.openURI.trim().toLowerCase():{M(L.args.isDetachContainer,E.bind(null,{subjectId:y,subjectName:"control"})),Q(),L.args.shouldOpenNow?_({subjectId:y,subjectName:"control",subjectType:d,action:L,payload:{URI:f.args.uri}}):(e.add(v(p({},et),{action:_.bind(null,{subjectId:y,subjectName:"control",subjectType:d,action:L,payload:{URI:f.args.uri}})})),n==null||n());return}default:console.error("Unexpected control event"),i.emit(g.errors,new w(w.Severity.RECOVERABLE,w.Category.INTERACTIVES,{message:"Unexpected control event"}));return}},o=({action:f,container:{id:d,endTime:y},branches:T=[],isEOV:u=!1,autoSelected:M=!1})=>{let j=ri(f,u),F={timestamp:!j.args.shouldOpenNow||u?1/0:y,priority:"container",initiator:d,actionType:j.type},L=i.emit.bind(i,g.interactives,{subjectId:d,subjectName:"container",type:N.actionChoice,actionType:j.type,payload:j.args});switch(j.type.trim().toLowerCase()){case P.setNextBranch.trim().toLowerCase():{let et=T.find(J=>J.id===j.args.branchId);if(!et)return;L(),e.add(v(p({},F),{action:x.bind(null,{subjectId:d,subjectName:"container",action:j,payload:{chapterId:et.chapterId,autoSelect:M}})})),n==null||n();return}case P.setMaxWeightBranch.trim().toLowerCase():return;case P.setMinWeightBranch.trim().toLowerCase():return;case P.setRandomBranch.trim().toLowerCase():return;case P.setWeightlessRandomBranch.trim().toLowerCase():return;case P.continuePlayback.trim().toLowerCase():{L(),e.add(v(p({},F),{action:S.bind(null,{subjectId:d,subjectName:"container",action:j})}));return}case P.openURI.trim().toLowerCase():{L(),e.add(v(p({},F),{action:_.bind(null,{subjectId:d,subjectName:"container",action:j,payload:{URI:f.args.uri}})})),n==null||n();return}default:console.error("Unexpected container event"),i.emit(g.errors,new w(w.Severity.RECOVERABLE,w.Category.INTERACTIVES,{message:"Unexpected container event"}));return}};function c({container:f,branches:d,isEOV:y=!1}){let T=ti(f.events);if(T){let u=ri(T.action,y);i.emit(g.interactives,{subjectId:f.id,subjectName:"container",type:N.actionChoice,actionType:u.type,payload:u.args}),e.add({timestamp:y?1/0:f.endTime,priority:"container",initiator:f.id,actionType:P.expect,action:C.bind(null,{subjectId:f.id,subjectName:"container"})}),r.isExpect=!0}else for(let u of f.events)o({action:u.action,container:f,branches:d,isEOV:y})}let h=({chapterId:f,action:d,branches:y=[]})=>{let T=i.emit.bind(i,g.interactives,{subjectId:f,subjectName:"chapter",type:N.actionChoice,actionType:d.type,payload:d.args});switch(d.type.trim().toLowerCase()){case P.setNextBranch.trim().toLowerCase():{let u=y.find(M=>M.id===d.args.branchId);return u!=null&&u.chapterId?(T(),x.bind(null,{subjectId:f,subjectName:"chapter",action:d,payload:{chapterId:u.chapterId,autoSelect:!0}})):void 0}case P.setWeightlessRandomBranch.trim().toLowerCase():{let u=Ji(y);return u!=null&&u.chapterId?(T(),x.bind(null,{subjectId:f,subjectName:"chapter",action:d,payload:{chapterId:u.chapterId,autoSelect:!0}})):void 0}case P.setRandomBranch.trim().toLowerCase():{let u=tn(y);return u!=null&&u.chapterId?(T(),x.bind(null,{subjectId:f,subjectName:"chapter",action:d,payload:{chapterId:u.chapterId,autoSelect:!0}})):void 0}case P.setMaxWeightBranch.trim().toLowerCase():{let u=Yi(y);return u!=null&&u.chapterId?(T(),x.bind(null,{subjectId:f,subjectName:"chapter",action:d,payload:{chapterId:u.chapterId,autoSelect:!0}})):void 0}case P.setMinWeightBranch.trim().toLowerCase():{let u=Zi(y);return u!=null&&u.chapterId?(T(),x.bind(null,{subjectId:f,subjectName:"chapter",action:d,payload:{chapterId:u.chapterId,autoSelect:!0}})):void 0}case P.continuePlayback.trim().toLowerCase():return T(),S.bind(null,{subjectId:f,subjectName:"chapter",action:d});case P.openURI.trim().toLowerCase():return T(),_.bind(null,{subjectId:f,subjectName:"chapter",action:d,payload:{URI:d.args.uri}});default:console.error("Unexpected chapter event"),i.emit(g.errors,new w(w.Severity.RECOVERABLE,w.Category.INTERACTIVES,{message:"Unexpected chapter event"}));return}};function b(f){let d=ti(f.events);if(d){if(st(f))return;i.emit(g.interactives,{subjectId:f.id,subjectName:"chapter",type:N.actionChoice,actionType:d.action.type,payload:d.action.args}),e.add({timestamp:1/0,priority:"chapter",initiator:f.id,actionType:P.expect,action:C.bind(null,{subjectId:f.id,subjectName:"chapter"})})}else f.events.forEach(y=>{let T=h({chapterId:f.id,action:y.action,branches:f.branches});T&&e.add({timestamp:1/0,priority:"chapter",initiator:f.id,actionType:y.action.type,action:T})})}let C=({subjectId:f,subjectName:d,action:y})=>{var T;t.pause(),i.emit(g.interactives,{subjectId:f,subjectName:d,type:N.actionExecution,actionType:(T=y==null?void 0:y.type)!=null?T:P.expect})},E=({subjectId:f,subjectName:d})=>{t.info.isEnded$.getValue()?e.execEndOfVideo():t.play(),i.emit(g.interactives,{subjectId:f,subjectName:d,type:N.actionExecution,actionType:"after-expect"})},S=({subjectId:f,subjectName:d,subjectType:y,action:T})=>{i.emit(g.interactives,{subjectId:f,subjectName:d,subjectType:y,type:N.actionExecution,actionType:T.type})},x=({subjectId:f,subjectName:d,subjectType:y,action:T,payload:u})=>{u.behaviour="change-chapter",i.emit(g.interactives,{subjectId:f,subjectName:d,subjectType:y,type:N.actionExecution,actionType:T.type,payload:u})},R=({subjectId:f,subjectName:d,subjectType:y,action:T,payload:u})=>{u.behaviour="change-manifest",i.emit(g.interactives,{subjectId:f,subjectName:d,subjectType:y,type:N.actionExecution,actionType:T.type,payload:u})},_=({subjectId:f,subjectName:d,subjectType:y,action:T,payload:u})=>{if(!u.URI)return;let M=window.open(u.URI,"_blank","noopener,noreferrer");M&&(M.opener=null),i.emit(g.interactives,{subjectId:f,subjectName:d,subjectType:y,type:N.actionExecution,actionType:T.type})};return{onControlEvent:l,onContainerEvent:o,onChapterEvent:h,onExpectEvent:C,expectEventHandler:E,setManifestChapterEvents:b,setManifestContainerEvents:c,stopExpect:s,state:r}};import{Subscription as Jn,ValueSubject as qt}from"@vkontakte/videoplayer-shared";var oi=(i,t)=>{let e={};return i.map(n=>{if(!e[n]){let r=t.chapters.find(l=>l.id===n);if(!r)return null;let s=t.media.videos.find(l=>r.videoId===l.id);if(!s)return null;e[n]=nn(s)}return e[n]}).filter(Boolean)},qn=i=>{for(let t of i.variants)if(Zn(t)&&"payload"in t)return t.payload.id},Zn=i=>i.type==="custom"&&"payload"in i&&i.payload.type==="vk",nn=i=>{let t=qn(i);if(!t)return null;let e=t.split("_").pop();return e?parseInt(e,10):null},Yn=(i,t)=>{for(let e of i.media.videos)if(t===nn(e)){for(let n of i.chapters)if(n.videoId===e.id)return n.id;return}},sn=(i,t)=>i.reduce((e,n)=>{let r=Yn(t,n);return r?[...e,r]:e},[]);var rt,Tt,St,tt,Re,at,ot,it,wt,jt,Pt,Zt=class{constructor({globalEventEmitter:t,videoId:e,interactiveController:n,historyApi:r,settings:s}){this.state={history$:new qt([]),hasPrevChapter$:new qt(!1),prevChapter$:new qt(null),isInitialChapter$:new qt(!1),isGoBackLimited$:new qt(!1)};I(this,rt,null);I(this,Tt);I(this,St,!1);I(this,tt,null);I(this,Re,null);I(this,at,null);I(this,ot,null);I(this,it,null);I(this,wt,new Jn);I(this,jt,!1);I(this,Pt,0);var l,o,c;m(this,at,e),m(this,it,t),m(this,ot,n),m(this,rt,r),m(this,Tt,s),(l=this.state)!=null&&l.history$&&a(this,wt)&&((c=a(this,wt))==null||c.add((o=this.state)==null?void 0:o.history$.subscribe(h=>{var b,C,E,S,x,R;(b=this.state)==null||b.prevChapter$.next(h.at(-2)||null),(C=this.state)==null||C.hasPrevChapter$.next(h.length>1),(x=this.state)==null||x.isInitialChapter$.next(this.getInitialChapterId()===((S=(E=a(this,tt))==null?void 0:E.metadata)==null?void 0:S.initChapterId)),(R=this.state)==null||R.isGoBackLimited$.next(a(this,Pt)===a(this,Tt).maxLength-1)})))}setManifest(t){return V(this,null,function*(){!a(this,ot)||!a(this,it)||(m(this,tt,t),yield this.getProjectHistory(),yield a(this,ot).setChapter({chapterId:this.getInitialChapterId(),pushToHistory:!1}),a(this,St)||(m(this,St,!0),a(this,it).emit(g.historyInited,{initChapterId:this.getInitialChapterId()})))})}get inited(){return a(this,St)}updateHistory(t,e=!0){return V(this,null,function*(){var o,c;if(!a(this,tt))return;a(this,jt)?(m(this,jt,!1),Ii(this,Pt)._++):m(this,Pt,0);let n=a(this,tt),r=t.length-a(this,Tt).maxLength,s=r>0?t.slice(r):t,l=oi(s,n);if(m(this,Re,l),(o=this==null?void 0:this.state)==null||o.history$.next(s),!(!e||!a(this,rt)||!a(this,at)))try{yield a(this,rt).save(a(this,at),l)}catch(h){(c=a(this,it))==null||c.emit(g.errors,new w(w.Severity.RECOVERABLE,w.Category.HISTORY,"Unable to save interactive history"))}})}goBack(){return V(this,null,function*(){var n;if(!this.state||!a(this,ot))return(n=a(this,it))==null?void 0:n.emit(g.errors,new w(w.Severity.RECOVERABLE,w.Category.HISTORY,"Cannot go back because HistoryController has not been initialized"));m(this,jt,!0);let t=this.state.history$.getValue().slice(0,-1),e=t.pop();this.state.history$.next(t),yield a(this,ot).setChapter({chapterId:e})})}getProjectHistory(){return V(this,null,function*(){var r,s;if(!a(this,tt)||!a(this,at))return;let t=a(this,tt),e=[this.getInitialVideoId()];if(a(this,rt))try{let l=yield a(this,rt).get(a(this,at));l.length&&(e=l)}catch(l){(r=a(this,it))==null||r.emit(g.errors,new w(w.Severity.RECOVERABLE,w.Category.HISTORY,"Error while trying to fetch data"))}let n=sn(e,t);(s=this==null?void 0:this.state)==null||s.history$.next(n)})}getInitialChapterId(){var e,n;let t=(e=this.state)==null?void 0:e.history$.getValue();return(t==null?void 0:t.at(-1))||a(this,Tt).initChapterId||((n=a(this,tt))==null?void 0:n.metadata.initChapterId)}getInitialVideoId(){if(a(this,tt)){let t=this.getInitialChapterId();return oi([t],a(this,tt)).pop()}return null}destroy(){var t,e;this.state=null,m(this,at,null),m(this,rt,null),m(this,ot,null),(t=a(this,wt))==null||t.unsubscribe(),m(this,wt,null),m(this,St,!1),(e=a(this,it))==null||e.emit(g.historyDestroyed),m(this,it,null)}};rt=new WeakMap,Tt=new WeakMap,St=new WeakMap,tt=new WeakMap,Re=new WeakMap,at=new WeakMap,ot=new WeakMap,it=new WeakMap,wt=new WeakMap,jt=new WeakMap,Pt=new WeakMap;var $t,rn,Yt,an,yt=class yt{constructor(t,e,n,r){var s;this.target=t,this.type=e,this.listener=n,this.options=$(s=yt,$t,rn).call(s,t,r),this.target.addEventListener(e,n,this.options)}unlisten(){this.target.removeEventListener(this.type,this.listener,this.options),this.target=null,this.listener=null,this.options=!1}};$t=new WeakSet,rn=function(t,e){var n;if(e===void 0)return!1;if(typeof e=="boolean")return e;{let r=new Set(["passive","capture"]),s=Object.keys(e).filter(o=>!r.has(o));return s.length===0&&console.warn("Unsupported flag(s) to addEventListener: "+s.join(",")),$(n=yt,$t,an).call(n,t)?e:e.capture||!1}},Yt=new WeakMap,an=function(t){let e=a(yt,Yt);if(e===void 0){e=!1;try{let n={},r={get:()=>(e=!0,!1)};Object.defineProperty(n,"passive",r),Object.defineProperty(n,"capture",r);let s=()=>{};t.addEventListener("test",s,n),t.removeEventListener("test",s,n)}catch(n){e=!1}m(yt,Yt,e)}return e||!1},I(yt,$t),I(yt,Yt);var _e=yt;var Ae=class{constructor(){this.bindingMap=new Xt}release(){this.removeAll(),this.bindingMap=null}listen(t,e,n,r){if(!this.bindingMap)return;let s=new _e(t,e,n,r);this.bindingMap.push(e,s)}listenOnce(t,e,n,r){let s=l=>{this.unlisten(t,e,s),n(l)};this.listen(t,e,s,r)}unlisten(t,e,n){if(!this.bindingMap)return;let r=this.bindingMap.get(e)||[];for(let s of r)s.target===t&&(n===s.listener||!n)&&(s.unlisten(),this.bindingMap.remove(e,s))}removeAll(){if(!this.bindingMap)return;let t=this.bindingMap.getAll();for(let e of t)e.unlisten();this.bindingMap.clear()}};var Me=class{constructor(){this._prevSizeId=0;this.rootElement=document.createElement("canvas")}clear(){var t;(t=this.rootElement.getContext("2d"))==null||t.clearRect(0,0,this.rootElement.width,this.rootElement.height)}isImageDrawn(){var r;let t=(r=this.rootElement.getContext("2d"))==null?void 0:r.getImageData(0,0,this.rootElement.width,this.rootElement.height);if(!t)return!1;let e=t.data,n=e.length;for(let s=3;s<n;s+=40)if(e[s]!==0)return!0;return!1}destroy(){this.rootElement.remove()}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}setCanvasImageSource(t){this.canvasImgSrc=t}draw(){var t;this.canvasImgSrc&&((t=this.rootElement.getContext("2d"))==null||t.drawImage(this.canvasImgSrc,0,0,this.rootElement.width,this.rootElement.height))}updateCanvasDimensions(t,e=!1){return V(this,null,function*(){let n=t.width+t.height;if(this._prevSizeId===n)return;let r;e&&(r=yield this.save()),this.rootElement.width=t.width,this.rootElement.height=t.height,e&&r&&this.restore(r),this._prevSizeId=n})}save(){return V(this,null,function*(){let t=this.rootElement.toDataURL("image/jpeg",1),e=new Image;return e.crossOrigin="anonymous",e.src=t,yield e.decode(),e})}restore(t){var e;this.rootElement&&((e=this.rootElement.getContext("2d"))==null||e.drawImage(t,0,0,this.rootElement.width,this.rootElement.height))}};var Le=class{constructor({parentElement:t,endOffsetMs:e=250,onError:n}){this.currentVideoDurationMs=1/0;this._containerTimeFrameShouldReceived=!1;this._endTimeFrameReceived=!1;this._shouldCallSkip=!1;this.onEachTick=t=>{let e=t!=null?t:this.lastFrameCanvas.canvasImgSrc.currentTime*1e3,n=this.isChapterEndTime(e);if(this.isContainerTime(e))this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!0,this._shouldCallSkip=!0;else if(n)this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1,this._endTimeFrameReceived||(this.draw(),this._endTimeFrameReceived=!0,this.show());else{if(this._shouldCallSkip){this._shouldCallSkip=!1;return}this.reset()}};this.onSeek=()=>{this.onEachTick(),!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived&&(this.hide(),this.lastFrameCanvas.clear())};this.rootElement=document.createElement("div"),this.rootElement.style.cssText=`
|
|
7
7
|
position: absolute;
|
|
8
8
|
top: 0;
|
|
9
9
|
left: 0;
|
|
@@ -11,13 +11,13 @@ var Ga=Object.create;var mr=Object.defineProperty,Ua=Object.defineProperties,za=
|
|
|
11
11
|
height: var(--interactive-height);
|
|
12
12
|
background-color: var(--black);
|
|
13
13
|
visibility: hidden;
|
|
14
|
-
`,this.lastFrameCanvas=new
|
|
14
|
+
`,this.lastFrameCanvas=new Me,this.endOffsetMs=e,this._callbacks={onError:n},this.lastFrameCanvas.rootElement.style.cssText=`
|
|
15
15
|
position: absolute;
|
|
16
16
|
top: 50%;
|
|
17
17
|
left: 50%;
|
|
18
18
|
transform: translate(-50%, -50%);
|
|
19
|
-
`,this.rootElement.prepend(this.lastFrameCanvas.rootElement),
|
|
19
|
+
`,this.rootElement.prepend(this.lastFrameCanvas.rootElement),t.prepend(this.rootElement)}destroy(){this.hide(),this.reset(),this._callbacks=void 0,this.lastFrameCanvas.destroy(),this.rootElement.remove()}setVideoDuration(t){this.currentVideoDurationMs=t}setVideoElement(t){this.lastFrameCanvas.setCanvasImageSource(t)}setCurrentChapter(t){this.currentChapter=t}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}updateCanvasDimensions(t=!1){return V(this,null,function*(){this._containerTimeFrameShouldReceived||this._endTimeFrameReceived||(t=!1);let e=getComputedStyle(this.rootElement),n={width:parseInt(e.getPropertyValue("--interactive-content-width"),10),height:parseInt(e.getPropertyValue("--interactive-content-height"),10)};try{this.lastFrameCanvas.updateCanvasDimensions(n,t)}catch(r){this._onError(r)}})}draw(){(this._containerTimeFrameShouldReceived||!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived)&&this.lastFrameCanvas.draw()}isChapterEndTime(t){return this.currentVideoDurationMs&&t>=this.currentVideoDurationMs-this.endOffsetMs}isContainerTime(t){if(this.currentChapter)return this.currentChapter.containers.some(e=>{var n,r,s;return((n=e.controls)==null?void 0:n.length)&&t>=((r=e.startTime)!=null?r:0)&&t<=Math.min((s=e.endTime)!=null?s:1/0,this.currentVideoDurationMs-this.endOffsetMs)})}reset(){this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1}_onError(t){var e,n;(n=(e=this._callbacks)==null?void 0:e.onError)==null||n.call(e,t)}};function on(i=0){return new Promise(t=>{setTimeout(()=>{t(0)},i)})}var ln=Object.freeze({parentElement:null,fullscreenTargetElement:null,lang:"ru",loaders:{},graph:!1,historyApi:null,historyParams:null,projectInfo:{},initSeamless:!1,lastFrame:!1,permanentTextControls:!0,config:{historyMaxLength:100,noInteractionEventTimeout:3e4}}),ct=Object.freeze({created:0,initiated:1,ready:2,destroyed:3});function rs(){let i=document.createElement("div");return i.style.cssText=`
|
|
20
20
|
position: absolute;
|
|
21
21
|
top: 0;
|
|
22
22
|
left: 0;
|
|
23
|
-
`,t}var Ee,X,Ce,z,de,G,Z,pe,F,fe,We,U,Ke,D,j,xe,Me,ar,ka,or,$a,Qe,nr,xi,cr,lr,Fa,pt,Ei,Oe,Le,dt,hr,Ba,ft,Ci,ur,qa,dr,Da,pr,mt,sr=class{constructor(e){E(this,ar);E(this,or);E(this,Qe);E(this,lr);E(this,pt);E(this,Le);E(this,hr);E(this,ft);E(this,ur);E(this,dr);E(this,Ee,null);E(this,X,null);E(this,Ce,null);E(this,z,null);E(this,de,null);E(this,G,null);E(this,Z,null);E(this,pe,null);E(this,F,null);E(this,fe,new ne(!1));E(this,We,new Set);E(this,U,null);E(this,Ke,null);E(this,D,null);E(this,j,null);E(this,xe,Rr());E(this,Me,null);$(this,"state",{prevChapter$:new ne(null),isInitialChapter$:new ne(!1),isEndChapter$:new ne(!1),isInteractiveExpectation$:new ne(!1),calledByInteractive$:new ne(!1),lastChapterChangeWasInitiatedByInteractive$:new ne(!1),disabledControls$:new ne(!1),interactiveRanges$:new ne([]),isInteractiveTime$:new ne(!1)});$(this,"events",{noInteraction$:new Xl});$(this,"emitPlayerChanged",e=>{a(this,j).emit(C.playerChanged,e)});E(this,xi,()=>{a(this,Z).fns.forEach(i=>i());let e=this.options.player.info.position$.getValue()*1e3,r=(a(this,F).chapter.containers||[]).filter(i=>i.startTime>=Math.floor(e));for(let i of r){a(this,G).remove({timestamp:1/0,priority:"container",initiator:i.id});for(let n of i.controls)a(this,G).remove({timestamp:1/0,priority:"control",initiator:n.id});a(this,X).find(n=>n.container.container.id===i.id).reset()}});E(this,cr,()=>{a(this,Ee).calc(),a(this,Z).requestAnimation()});E(this,Oe,(e=!0)=>{a(this,X).forEach(r=>{!e&&r.isPermanentText||(a(this,Z).removeFn(r.whilePlaying),r.destroy())})});E(this,pr,e=>{let{interactiveRanges$:r}=this.state,n=r.getValue().map(s=>x(d({},s),{subjects:s.subjects.filter(l=>l!==e)}));r.next(n)});E(this,mt,()=>{a(this,Me)&&(clearTimeout(a(this,Me)),g(this,Me,null))});var r;this.options=x(d(d({},Pa),e),{config:d(d({},Pa.config),e.config)}),g(this,X,[]),this.factories=new Map([["choice",Rt]]),this.rootElement=ih(),this.options.parentElement.append(this.rootElement),g(this,j,new Fe),g(this,de,new Jl),g(this,Ce,new tr),g(this,z,new ht({interactiveController:this,globalEventEmitter:a(this,j),videoId:(r=this.options.projectInfo)==null?void 0:r.videoId,historyApi:this.options.historyApi,settings:{maxLength:this.options.config.historyMaxLength,initChapterId:this.options.initChapterId}})),this.options.lastFrame&&g(this,D,new ir({parentElement:this.options.parentElement,interactivesRootElement:this.rootElement,onError:i=>a(this,j).emit(C.errors,new V(V.Severity.RECOVERABLE,V.Category.SEAMLESS,i))})),a(this,Ce).listen(this.rootElement,"mousedown",i=>i.stopPropagation()),a(this,Ce).listen(this.rootElement,"mouseup",i=>i.stopPropagation()),g(this,F,new Be(this.options.loaders,i=>a(this,j).emit(C.errors,new V(V.Severity.RECOVERABLE,V.Category.MANIFEST,i)))),g(this,G,$r(this.options.player)),g(this,Z,new Nt),g(this,pe,Br({player:this.options.player,interactiveEvents:a(this,G),globalEventEmitter:a(this,j),removeControllers:a(this,Oe)})),g(this,Ee,cn(()=>{var i,n,s;return{player:(i=this.options)==null?void 0:i.player,parentElement:(n=this.options)==null?void 0:n.parentElement,fns:(s=this.options)!=null&&s.lastFrame?[()=>{a(this,D).updateCanvasDimensions(!0)}]:[]}})),this.options.graph&&g(this,U,new et({root:this.options.parentElement,lang:this.options.lang,onOpenPreviewClick:i=>{this.setChapter({chapterId:i}),a(this,j).emit(C.graph,{type:rt.watchAgainClicked,chapterId:i})},onError:i=>a(this,j).emit(C.errors,new V(V.Severity.RECOVERABLE,V.Category.LOADERS,{message:i}))})),k(this,ar,ka).call(this,this.options.initSeamless),this.isFirstChapterFetched=!1,this.appState=ue.created}getStatEvents(){return{click$:new Na(e=>{a(this,j).on(C.graph,({type:r,visibility:i})=>{r==="visibility"&&e.next(i?"OPEN_GRAPH":"CLOSE_GRAPH"),r==="watchAgainClicked"&&e.next("WATCH_AGAIN")}),a(this,j).on(C.interactives,({type:r,subjectName:i,subjectType:n})=>{r!=="action-choice"||i!=="control"||(n==="Button"&&e.next("GO_NEXT_BUTTON"),n==="Area"&&e.next("GO_NEXT_AREA"))})}),nextMovie$:new Na(e=>{a(this,j).on(C.playerChanged,({config:r})=>{r!=null&&r.unitedVideoId&&e.next(r.unitedVideoId)})})}}setPlayer(e){k(this,Qe,nr).call(this),this.options.player=e,a(this,xe).setPlayer(this.options.player),a(this,G)?a(this,G).setPlayer(this.options.player):g(this,G,$r(this.options.player)),g(this,pe,Br({player:this.options.player,interactiveEvents:a(this,G),globalEventEmitter:a(this,j),removeControllers:()=>a(this,Oe).call(this,!1)})),this.appState===ue.initiated&&(k(this,pt,Ei).call(this),k(this,Le,dt).call(this,a(this,F).chapter))}setManifest(e){return A(this,null,function*(){k(this,Qe,nr).call(this),this.isFirstChapterFetched=!1;let r=yield a(this,F).setManifest(e);return a(this,U)&&(yield a(this,U).handleManifestChange(r.manifest)),yield a(this,z).setManifest(r.manifest),a(this,j).emit(C.manifestChanged,{manifest:r.manifest}),k(this,Le,dt).call(this,a(this,F).chapter),r.manifest})}setVisitedChapters(e){var r;Array.isArray(e)&&((r=a(this,U))==null||r.setVisitedChapters(e))}updateGraphVideosInfo(e){var r;Array.isArray(e)&&((r=a(this,U))==null||r.updateVideosInfo(e))}setChapter(){return A(this,arguments,function*({chapterId:e,pushToHistory:r=!0}={}){var o;k(this,Qe,nr).call(this),a(this,D)&&this.isFirstChapterFetched&&(a(this,D).draw(),a(this,D).show()),eh().browser===th.Safari&&(yield ja(35));let{chapter:n,media:s,graph:l}=yield e?a(this,F).setNext(e):a(this,F).setInitial();return r&&k(this,dr,Da).call(this,n.id),this.state.isInitialChapter$.next(a(this,F).isInitialChapter()),this.state.isEndChapter$.next(a(this,F).isEndChapter()),a(this,U)&&a(this,U).handleChapterChange(l),(o=a(this,D))==null||o.setCurrentChapter(this.getCurrentChapter().chapter),a(this,j).emit(C.chapterChanged,{chapter:n,media:s,graph:l}),k(this,Le,dt).call(this,a(this,F).chapter),g(this,We,new Set),this.isFirstChapterFetched=!0,{chapter:n,media:s,graph:l}})}toggleGraphView(e=!0){a(this,U)&&(e?(a(this,U).show(),a(this,fe).next(!1)):(a(this,U).hide(),k(this,ft,Ci).call(this)),a(this,j).emit(C.graph,{type:rt.visibility,visibility:e}))}init(){a(this,F).chapter&&this.options.parentElement&&this.options.player&&this.options.fullscreenTargetElement&&this.appState===ue.created&&(a(this,Ee).resizeObserver.observe(this.options.fullscreenTargetElement),k(this,pt,Ei).call(this),this.appState=ue.initiated,k(this,Le,dt).call(this,a(this,F).chapter))}deadEndCheck(){var i,n;return!((n=(i=a(this,G))==null?void 0:i.getPreparedToExecActions())!=null?n:[]).some(s=>s.actionType===P.setNextBranch)}allControlsAreRemoved(){return!a(this,X).some(r=>!r.container.isRemoved)}isEndedExpectation(){var i;if(!((i=this.options)!=null&&i.player)||!a(this,X))return!1;let e=this.options.player.info.position$.getValue(),r=this.options.player.info.duration$.getValue();return e===r&&a(this,X).some(n=>{let s=n.container.container;return!s.isRemoved&&s.endTime===null&&we(s.events)})}playPrevChapter(){var e;(e=a(this,z))==null||e.goBack()}setDisabledControls(e){this.state.disabledControls$.next(e)}isSupport(e=a(this,F).manifest){return Lt(e.metadata.version)}getInitialVideoInfo(){return{videoId:a(this,z).getInitialVideoId(),chapterId:a(this,z).getInitialChapterId()}}getHistoryState(){return a(this,z).state}getIsSeekable(){return a(this,fe)}getInteractiveRanges(){var e;return sn((e=a(this,F).chapter)==null?void 0:e.containers)}getNextInteractiveStartTime(e){return a(this,xe).getNextInteractiveTime(e)}getChapterBranches(e){return a(this,F).getBranches(e)}getCurrentChapter(){return a(this,F).getCurrent()}getCurrentManifest(){return a(this,F).manifest}addFactory(e,r){this.factories.set(e.trim().toLowerCase(),r)}removeFactory(e){this.factories.delete(e.trim().toLowerCase())}on(...e){return a(this,j).on(...e),this}off(...e){return a(this,j).off(...e),this}once(...e){return a(this,j).once(...e),this}destroy(){var e,r;a(this,Oe).call(this),g(this,X,void 0),this.state=void 0,(e=a(this,U))==null||e.destroy(),g(this,U,void 0),a(this,Ee).release(),g(this,Ee,void 0),g(this,pe,void 0),a(this,Z).release(),g(this,Z,void 0),a(this,G).release(),g(this,G,void 0),a(this,F).release(),g(this,pe,void 0),a(this,Ce).release(),g(this,Ce,void 0),a(this,de).unsubscribe(),g(this,de,void 0),a(this,j).reset(),g(this,j,void 0),(r=a(this,D))==null||r.destroy(),g(this,D,void 0),this.rootElement.remove(),this.rootElement=void 0,a(this,z).destroy(),g(this,z,void 0),this.factories=void 0,this.options=void 0,this.isFirstChapterFetched=!1,this.appState=ue.destroyed}};Ee=new WeakMap,X=new WeakMap,Ce=new WeakMap,z=new WeakMap,de=new WeakMap,G=new WeakMap,Z=new WeakMap,pe=new WeakMap,F=new WeakMap,fe=new WeakMap,We=new WeakMap,U=new WeakMap,Ke=new WeakMap,D=new WeakMap,j=new WeakMap,xe=new WeakMap,Me=new WeakMap,ar=new WeakSet,ka=function(e=!1){a(this,j).on(C.historyInited,n=>A(this,[n],function*({initChapterId:r,videosInfo:i=[]}){e&&(yield k(this,or,$a).call(this,{initialChapter:r,videosInfo:i}))})),a(this,j).on(C.interactives,r=>A(this,null,function*(){var i,n;if(r.type===L.actionExecution){if(this.state.calledByInteractive$.next(!0),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!0),((i=r.payload)==null?void 0:i.behaviour)==="change-chapter"){let{chapterId:l}=r.payload;this.setChapter({chapterId:l})}if(((n=r.payload)==null?void 0:n.behaviour)==="change-manifest"){let{manifestURL:l}=r.payload;this.setManifest(l)}let s=r.type==="action-execution";s&&r.actionType==="expect"?this.state.isInteractiveExpectation$.next(!0):s&&r.actionType==="after-expect"&&this.state.isInteractiveExpectation$.next(!1)}r.type===L.containerRemoved&&a(this,pr).call(this,r.subjectId)})),a(this,j).on(C.manifestChanged,()=>{this.state.calledByInteractive$.next(!1),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)})},or=new WeakSet,$a=function(i){return A(this,arguments,function*({source:e,videosInfo:r=[]}){g(this,Ke,kr(this));let n=document.createElement("div");a(this,Ke).on(nt.activePlayerChanged,this.emitPlayerChanged);let{player:s,config:l}=yield a(this,Ke).init({source:e,initialChapter:a(this,z).getInitialChapterId(),container:n});return this.updateGraphVideosInfo(r),{player:s,config:l}})},Qe=new WeakSet,nr=function(){var e;this.appState===ue.ready&&(a(this,Oe).call(this),g(this,X,[]),a(this,Z).release(),(e=a(this,G))==null||e.release(),this.appState=ue.initiated,a(this,fe).next(!1),a(this,mt).call(this))},xi=new WeakMap,cr=new WeakMap,lr=new WeakSet,Fa=function(e){(!a(this,U)||a(this,U).isHidden)&&k(this,ft,Ci).call(this);let r=e*1e3,n=this.getInteractiveRanges().findLast(({range:s})=>r>=s[1]);if(n){let s=n.range.join("-");a(this,We).has(s)||(a(this,We).add(s),a(this,j).emit(C.interactives,{type:L.rangeEnded,payload:n,visibility:!0}))}},pt=new WeakSet,Ei=function(){a(this,de).unsubscribe(),a(this,de).add(this.options.player.events.started$.pipe(Zl()).subscribe(a(this,cr))).add(this.options.player.events.playing$.subscribe(a(this,Z).requestAnimation)).add(this.options.player.events.willPause$.subscribe(a(this,Z).cancelAnimation)).add(this.options.player.info.position$.subscribe(k(this,lr,Fa).bind(this))).add(a(this,F).prevChapter$.subscribe(e=>this.state.prevChapter$.next(e))).add(rh({position:this.options.player.info.position$,interactiveRanges:this.state.interactiveRanges$,isInteractiveExpectation:this.state.isInteractiveExpectation$}).subscribe(({position:e,interactiveRanges:r,isInteractiveExpectation:i})=>{let n;if(i)n=!0;else{let s=e*1e3;n=!!(r==null?void 0:r.find(({range:[o,c],subjects:h})=>o<s&&s<c&&h.length))}n!==this.state.isInteractiveTime$.getValue()&&(this.state.isInteractiveTime$.next(n),n?g(this,Me,setTimeout(()=>{this.events.noInteraction$.next()},this.options.config.noInteractionEventTimeout)):a(this,mt).call(this))})),this.options.lastFrame&&a(this,de).add(this.options.player.info.duration$.subscribe(e=>{a(this,D).setVideoDuration(e*1e3)})).add(this.options.player.experimental.element$.subscribe(e=>{e&&a(this,D).setVideoElement(e)})).add(this.options.player.events.firstFrame$.subscribe(()=>{a(this,D).reset(),setTimeout(()=>{a(this,D).hide(),a(this,D).lastFrameCanvas.clear()},50)})).add(this.options.player.events.seeked$.subscribe(a(this,D).onSeek))},Oe=new WeakMap,Le=new WeakSet,dt=function(e){a(this,F).chapter&&this.appState===ue.initiated&&(a(this,pe).setManifestChapterEvents(e),g(this,X,k(this,hr,Ba).call(this,e)),a(this,G).containersEventsCallState.setData(e.containers),a(this,xe).setContainers(a(this,X).map(r=>r.container.container).filter(r=>!qt(r.controls))),this.options.lastFrame&&a(this,Z).addFn(()=>{a(this,D).onEachTick(this.options.player.info.position$.getValue()*1e3)},!0),this.state.interactiveRanges$.next(this.getInteractiveRanges()),this.appState=ue.ready)},hr=new WeakSet,Ba=function(e){var r,i;return(i=(r=e==null?void 0:e.containers)==null?void 0:r.reduce((n,s)=>{let l=s.type.trim().toLowerCase(),o=this.factories.get(l);if(o){let c=new Dt({player:this.options.player,container:o(s,this.rootElement),branches:a(this,F).chapter.branches,selectBranches:a(this,pe),interactiveEvents:a(this,G),globalEventEmitter:a(this,j),ignoreContainerEvent:()=>rn(s,a(this,X)),permanentTextControls:this.options.permanentTextControls,disabledControls$:this.state.disabledControls$,onRemove:()=>{a(this,xe).deleteContainer(s.id)}});return a(this,Z).addFn(c.whilePlaying,!0),[...n,c]}return[...n]},[]))!=null?i:[]},ft=new WeakSet,Ci=function(){if(this.state.isInteractiveExpectation$.getValue()){a(this,fe).next(!1);return}let r=a(this,fe).getValue(),i=!!a(this,xe).getNextInteractiveTime();(i&&!r||!i&&r)&&a(this,fe).next(!r)},ur=new WeakSet,qa=function(){this.state.calledByInteractive$.getValue()?this.state.calledByInteractive$.next(!1):this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)},dr=new WeakSet,Da=function(e){var o;if(k(this,ur,qa).call(this),!a(this,z).inited)return;let r=this.state.lastChapterChangeWasInitiatedByInteractive$.getValue(),i=this.state.prevChapter$.getValue(),n=(o=i&&se(i)&&Bt(i))!=null?o:!1,s=a(this,F).manifest.metadata.initChapterId===e,l=a(this,z).state.history$.getValue();if(s||n&&r){a(this,z).updateHistory([e]);return}l.at(-1)!==e&&a(this,z).updateHistory([...l,e])},pr=new WeakMap,mt=new WeakMap;var nh={Container:$e,createChoiceContainer:Rt,createAreaControl:It,createButtonControl:Tt,createRelativeLayout:Fi,getRootEl:gt,classnamesPrefix:H};var em={version:Li};export{V as CustomError,C as EVENT_NAMES,Ar as INTERACTIVE_CLICK_ACTIONS,sr as Interactives,Be as ManifestController,em as SDKInfo,gi as chapterIdsToVKVideoIds,ve as compareVersions,Ql as getChapterIdByVkVideoId,Aa as getVKVideoIdByMedia,Wl as getVideoRawIdByMedia,rt as graphEventTypes,Bt as hasEndTemplate,L as interactivesEventTypes,se as isLastChapter,Lt as isSupportedManifest,Kl as isVKVariantItem,nh as utils,Ma as vkVideoIdsToChapterIds};
|
|
23
|
+
`,i}var gt,Z,vt,W,lt,U,Y,ht,B,dt,Ot,z,Bt,H,k,bt,Vt,A,hn,dn,Ne,hi,je,pn,ci,Rt,Jt,un,li,fn,mn,Pe,te,ke=class{constructor(t){I(this,A);I(this,gt,null);I(this,Z,null);I(this,vt,null);I(this,W,null);I(this,lt,null);I(this,U,null);I(this,Y,null);I(this,ht,null);I(this,B,null);I(this,dt,new nt(!1));I(this,Ot,new Set);I(this,z,null);I(this,Bt,null);I(this,H,null);I(this,k,null);I(this,bt,Ke());I(this,Vt,null);O(this,"state",{prevChapter$:new nt(null),isInitialChapter$:new nt(!1),isEndChapter$:new nt(!1),isInteractiveExpectation$:new nt(!1),calledByInteractive$:new nt(!1),lastChapterChangeWasInitiatedByInteractive$:new nt(!1),disabledControls$:new nt(!1),interactiveRanges$:new nt([]),isInteractiveTime$:new nt(!1)});O(this,"events",{noInteraction$:new ts});O(this,"emitPlayerChanged",t=>{a(this,k).emit(g.playerChanged,t)});I(this,hi,()=>{a(this,Y).fns.forEach(n=>n());let t=this.options.player.info.position$.getValue()*1e3,e=(a(this,B).chapter.containers||[]).filter(n=>n.startTime>=Math.floor(t));for(let n of e){a(this,U).remove({timestamp:1/0,priority:"container",initiator:n.id});for(let r of n.controls)a(this,U).remove({timestamp:1/0,priority:"control",initiator:r.id});a(this,Z).find(r=>r.container.container.id===n.id).reset()}});I(this,je,()=>{a(this,gt).calc(),a(this,Y).requestAnimation()});I(this,Rt,(t=!0)=>{a(this,Z).forEach(e=>{!t&&e.isPermanentText||(a(this,Y).removeFn(e.whilePlaying),e.destroy())})});I(this,Pe,t=>{let{interactiveRanges$:e}=this.state,r=e.getValue().map(s=>v(p({},s),{subjects:s.subjects.filter(l=>l!==t)}));e.next(r)});I(this,te,()=>{a(this,Vt)&&(clearTimeout(a(this,Vt)),m(this,Vt,null))});var e;this.options=v(p(p({},ln),t),{config:p(p({},ln.config),t.config)}),m(this,Z,[]),this.factories=new Map([["choice",pe]]),this.rootElement=rs(),this.options.parentElement.append(this.rootElement),m(this,k,new Nt),m(this,lt,new is),m(this,vt,new Ae),m(this,W,new Zt({interactiveController:this,globalEventEmitter:a(this,k),videoId:(e=this.options.projectInfo)==null?void 0:e.videoId,historyApi:this.options.historyApi,settings:{maxLength:this.options.config.historyMaxLength,initChapterId:this.options.initChapterId}})),this.options.lastFrame&&m(this,H,new Le({parentElement:this.options.parentElement,interactivesRootElement:this.rootElement,onError:n=>a(this,k).emit(g.errors,new w(w.Severity.RECOVERABLE,w.Category.SEAMLESS,n))})),a(this,vt).listen(this.rootElement,"mousedown",n=>n.stopPropagation()),a(this,vt).listen(this.rootElement,"mouseup",n=>n.stopPropagation()),m(this,B,new kt(this.options.loaders,n=>a(this,k).emit(g.errors,new w(w.Severity.RECOVERABLE,w.Category.MANIFEST,n)))),m(this,U,si(this.options.player)),m(this,Y,new be),m(this,ht,ai({player:this.options.player,interactiveEvents:a(this,U),globalEventEmitter:a(this,k),removeControllers:a(this,Rt)})),m(this,gt,qi(()=>{var n,r,s;return{player:(n=this.options)==null?void 0:n.player,parentElement:(r=this.options)==null?void 0:r.parentElement,fns:(s=this.options)!=null&&s.lastFrame?[()=>{a(this,H).updateCanvasDimensions(!0)}]:[]}})),this.options.graph&&m(this,z,new Ut({root:this.options.parentElement,lang:this.options.lang,onOpenPreviewClick:n=>{this.setChapter({chapterId:n}),a(this,k).emit(g.graph,{type:Wt.watchAgainClicked,chapterId:n})},onError:n=>a(this,k).emit(g.errors,new w(w.Severity.RECOVERABLE,w.Category.LOADERS,{message:n}))})),$(this,A,hn).call(this,this.options.initSeamless),this.isFirstChapterFetched=!1,this.appState=ct.created}getStatEvents(){return{click$:new cn(t=>{a(this,k).on(g.graph,({type:e,visibility:n})=>{e==="visibility"&&t.next(n?"OPEN_GRAPH":"CLOSE_GRAPH"),e==="watchAgainClicked"&&t.next("WATCH_AGAIN")}),a(this,k).on(g.interactives,({type:e,subjectName:n,subjectType:r})=>{e!=="action-choice"||n!=="control"||(r==="Button"&&t.next("GO_NEXT_BUTTON"),r==="Area"&&t.next("GO_NEXT_AREA"))})}),nextMovie$:new cn(t=>{a(this,k).on(g.playerChanged,({config:e})=>{e!=null&&e.unitedVideoId&&t.next(e.unitedVideoId)})})}}setPlayer(t){$(this,A,Ne).call(this),this.options.player=t,a(this,bt).setPlayer(this.options.player),a(this,U)?a(this,U).setPlayer(this.options.player):m(this,U,si(this.options.player)),m(this,ht,ai({player:this.options.player,interactiveEvents:a(this,U),globalEventEmitter:a(this,k),removeControllers:()=>a(this,Rt).call(this,!1)})),this.appState===ct.initiated&&($(this,A,ci).call(this),$(this,A,Jt).call(this,a(this,B).chapter))}setManifest(t){return V(this,null,function*(){$(this,A,Ne).call(this),this.isFirstChapterFetched=!1;let e=yield a(this,B).setManifest(t);return a(this,z)&&(yield a(this,z).handleManifestChange(e.manifest)),yield a(this,W).setManifest(e.manifest),a(this,k).emit(g.manifestChanged,{manifest:e.manifest}),$(this,A,Jt).call(this,a(this,B).chapter),e.manifest})}setVisitedChapters(t){var e;Array.isArray(t)&&((e=a(this,z))==null||e.setVisitedChapters(t))}updateGraphVideosInfo(t){var e;Array.isArray(t)&&((e=a(this,z))==null||e.updateVideosInfo(t))}setChapter(){return V(this,arguments,function*({chapterId:t,pushToHistory:e=!0}={}){var l;$(this,A,Ne).call(this),a(this,H)&&this.isFirstChapterFetched&&(a(this,H).draw(),a(this,H).show()),ns.isSafari&&(yield on(35));let{chapter:n,media:r,graph:s}=yield t?a(this,B).setNext(t):a(this,B).setInitial();return e&&$(this,A,mn).call(this,n.id),this.state.isInitialChapter$.next(a(this,B).isInitialChapter()),this.state.isEndChapter$.next(a(this,B).isEndChapter()),a(this,z)&&a(this,z).handleChapterChange(s),(l=a(this,H))==null||l.setCurrentChapter(this.getCurrentChapter().chapter),a(this,k).emit(g.chapterChanged,{chapter:n,media:r,graph:s}),$(this,A,Jt).call(this,a(this,B).chapter),m(this,Ot,new Set),this.isFirstChapterFetched=!0,{chapter:n,media:r,graph:s}})}toggleGraphView(t=!0){a(this,z)&&(t?(a(this,z).show(),a(this,dt).next(!1)):(a(this,z).hide(),$(this,A,li).call(this)),a(this,k).emit(g.graph,{type:Wt.visibility,visibility:t}))}init(){a(this,B).chapter&&this.options.parentElement&&this.options.player&&this.options.fullscreenTargetElement&&this.appState===ct.created&&(a(this,gt).resizeObserver.observe(this.options.fullscreenTargetElement),$(this,A,ci).call(this),this.appState=ct.initiated,$(this,A,Jt).call(this,a(this,B).chapter))}deadEndCheck(){var n,r;return!((r=(n=a(this,U))==null?void 0:n.getPreparedToExecActions())!=null?r:[]).some(s=>s.actionType===P.setNextBranch)}allControlsAreRemoved(){return!a(this,Z).some(e=>!e.container.isRemoved)}isEndedExpectation(){var n;if(!((n=this.options)!=null&&n.player)||!a(this,Z))return!1;let t=this.options.player.info.position$.getValue(),e=this.options.player.info.duration$.getValue();return t===e&&a(this,Z).some(r=>{let s=r.container.container;return!s.isRemoved&&s.endTime===null&&xt(s.events)})}playPrevChapter(){var t;(t=a(this,W))==null||t.goBack()}setDisabledControls(t){this.state.disabledControls$.next(t)}isSupport(t=a(this,B).manifest){return ge(t.metadata.version)}getInitialVideoInfo(){return{videoId:a(this,W).getInitialVideoId(),chapterId:a(this,W).getInitialChapterId()}}getHistoryState(){return a(this,W).state}getIsSeekable(){return a(this,dt)}getInteractiveRanges(){var t;return Qi((t=a(this,B).chapter)==null?void 0:t.containers)}getNextInteractiveStartTime(t){return a(this,bt).getNextInteractiveTime(t)}getChapterBranches(t){return a(this,B).getBranches(t)}getCurrentChapter(){return a(this,B).getCurrent()}getCurrentManifest(){return a(this,B).manifest}addFactory(t,e){this.factories.set(t.trim().toLowerCase(),e)}removeFactory(t){this.factories.delete(t.trim().toLowerCase())}on(...t){return a(this,k).on(...t),this}off(...t){return a(this,k).off(...t),this}once(...t){return a(this,k).once(...t),this}destroy(){var t,e;a(this,Rt).call(this),m(this,Z,void 0),this.state=void 0,(t=a(this,z))==null||t.destroy(),m(this,z,void 0),a(this,gt).release(),m(this,gt,void 0),m(this,ht,void 0),a(this,Y).release(),m(this,Y,void 0),a(this,U).release(),m(this,U,void 0),a(this,B).release(),m(this,ht,void 0),a(this,vt).release(),m(this,vt,void 0),a(this,lt).unsubscribe(),m(this,lt,void 0),a(this,k).reset(),m(this,k,void 0),(e=a(this,H))==null||e.destroy(),m(this,H,void 0),this.rootElement.remove(),this.rootElement=void 0,a(this,W).destroy(),m(this,W,void 0),this.factories=void 0,this.options=void 0,this.isFirstChapterFetched=!1,this.appState=ct.destroyed}};gt=new WeakMap,Z=new WeakMap,vt=new WeakMap,W=new WeakMap,lt=new WeakMap,U=new WeakMap,Y=new WeakMap,ht=new WeakMap,B=new WeakMap,dt=new WeakMap,Ot=new WeakMap,z=new WeakMap,Bt=new WeakMap,H=new WeakMap,k=new WeakMap,bt=new WeakMap,Vt=new WeakMap,A=new WeakSet,hn=function(t=!1){a(this,k).on(g.historyInited,r=>V(this,[r],function*({initChapterId:e,videosInfo:n=[]}){t&&(yield $(this,A,dn).call(this,{initialChapter:e,videosInfo:n}))})),a(this,k).on(g.interactives,e=>V(this,null,function*(){var n,r;if(e.type===N.actionExecution){if(this.state.calledByInteractive$.next(!0),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!0),((n=e.payload)==null?void 0:n.behaviour)==="change-chapter"){let{chapterId:l}=e.payload;this.setChapter({chapterId:l})}if(((r=e.payload)==null?void 0:r.behaviour)==="change-manifest"){let{manifestURL:l}=e.payload;this.setManifest(l)}let s=e.type==="action-execution";s&&e.actionType==="expect"?this.state.isInteractiveExpectation$.next(!0):s&&e.actionType==="after-expect"&&this.state.isInteractiveExpectation$.next(!1)}e.type===N.containerRemoved&&a(this,Pe).call(this,e.subjectId)})),a(this,k).on(g.manifestChanged,()=>{this.state.calledByInteractive$.next(!1),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)})},dn=function(n){return V(this,arguments,function*({source:t,videosInfo:e=[]}){m(this,Bt,ni(this));let r=document.createElement("div");a(this,Bt).on(Kt.activePlayerChanged,this.emitPlayerChanged);let{player:s,config:l}=yield a(this,Bt).init({source:t,initialChapter:a(this,W).getInitialChapterId(),container:r});return this.updateGraphVideosInfo(e),{player:s,config:l}})},Ne=function(){var t;this.appState===ct.ready&&(a(this,Rt).call(this),m(this,Z,[]),a(this,Y).release(),(t=a(this,U))==null||t.release(),this.appState=ct.initiated,a(this,dt).next(!1),a(this,te).call(this))},hi=new WeakMap,je=new WeakMap,pn=function(t){(!a(this,z)||a(this,z).isHidden)&&$(this,A,li).call(this);let e=t*1e3,r=this.getInteractiveRanges().findLast(({range:s})=>e>=s[1]);if(r){let s=r.range.join("-");a(this,Ot).has(s)||(a(this,Ot).add(s),a(this,k).emit(g.interactives,{type:N.rangeEnded,payload:r,visibility:!0}))}},ci=function(){a(this,lt).unsubscribe(),a(this,lt).add(this.options.player.events.started$.pipe(es()).subscribe(a(this,je))).add(this.options.player.events.playing$.subscribe(a(this,Y).requestAnimation)).add(this.options.player.events.willPause$.subscribe(a(this,Y).cancelAnimation)).add(this.options.player.info.position$.subscribe($(this,A,pn).bind(this))).add(a(this,B).prevChapter$.subscribe(t=>this.state.prevChapter$.next(t))).add(ss({position:this.options.player.info.position$,interactiveRanges:this.state.interactiveRanges$,isInteractiveExpectation:this.state.isInteractiveExpectation$}).subscribe(({position:t,interactiveRanges:e,isInteractiveExpectation:n})=>{let r;if(n)r=!0;else{let s=t*1e3;r=!!(e==null?void 0:e.find(({range:[o,c],subjects:h})=>o<s&&s<c&&h.length))}r!==this.state.isInteractiveTime$.getValue()&&(this.state.isInteractiveTime$.next(r),r?m(this,Vt,setTimeout(()=>{this.events.noInteraction$.next()},this.options.config.noInteractionEventTimeout)):a(this,te).call(this))})),this.options.lastFrame&&a(this,lt).add(this.options.player.info.duration$.subscribe(t=>{a(this,H).setVideoDuration(t*1e3)})).add(this.options.player.experimental.element$.subscribe(t=>{t&&a(this,H).setVideoElement(t)})).add(this.options.player.events.firstFrame$.subscribe(()=>{a(this,H).reset(),setTimeout(()=>{a(this,H).hide(),a(this,H).lastFrameCanvas.clear()},50)})).add(this.options.player.events.seeked$.subscribe(a(this,H).onSeek))},Rt=new WeakMap,Jt=function(t){a(this,B).chapter&&this.appState===ct.initiated&&(a(this,ht).setManifestChapterEvents(t),m(this,Z,$(this,A,un).call(this,t)),a(this,U).containersEventsCallState.setData(t.containers),a(this,bt).setContainers(a(this,Z).map(e=>e.container.container).filter(e=>!Se(e.controls))),this.options.lastFrame&&a(this,Y).addFn(()=>{a(this,H).onEachTick(this.options.player.info.position$.getValue()*1e3)},!0),this.state.interactiveRanges$.next(this.getInteractiveRanges()),this.appState=ct.ready)},un=function(t){var e,n;return(n=(e=t==null?void 0:t.containers)==null?void 0:e.reduce((r,s)=>{let l=s.type.trim().toLowerCase(),o=this.factories.get(l);if(o){let c=new we({player:this.options.player,container:o(s,this.rootElement),branches:a(this,B).chapter.branches,selectBranches:a(this,ht),interactiveEvents:a(this,U),globalEventEmitter:a(this,k),ignoreContainerEvent:()=>zi(s,a(this,Z)),permanentTextControls:this.options.permanentTextControls,disabledControls$:this.state.disabledControls$,onRemove:()=>{a(this,bt).deleteContainer(s.id)}});return a(this,Y).addFn(c.whilePlaying,!0),[...r,c]}return[...r]},[]))!=null?n:[]},li=function(){if(this.state.isInteractiveExpectation$.getValue()){a(this,dt).next(!1);return}let e=a(this,dt).getValue(),n=!!a(this,bt).getNextInteractiveTime();(n&&!e||!n&&e)&&a(this,dt).next(!e)},fn=function(){this.state.calledByInteractive$.getValue()?this.state.calledByInteractive$.next(!1):this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)},mn=function(t){var o;if($(this,A,fn).call(this),!a(this,W).inited)return;let e=this.state.lastChapterChangeWasInitiatedByInteractive$.getValue(),n=this.state.prevChapter$.getValue(),r=(o=n&&st(n)&&Te(n))!=null?o:!1,s=a(this,B).manifest.metadata.initChapterId===t,l=a(this,W).state.history$.getValue();if(s||r&&e){a(this,W).updateHistory([t]);return}l.at(-1)!==t&&a(this,W).updateHistory([...l,t])},Pe=new WeakMap,te=new WeakMap;var as={Container:Lt,createChoiceContainer:pe,createAreaControl:ce,createButtonControl:he,createRelativeLayout:_i,getRootEl:ne,classnamesPrefix:G};var Qo={version:xi};export{w as CustomError,g as EVENT_NAMES,qe as INTERACTIVE_CLICK_ACTIONS,ke as Interactives,kt as ManifestController,Qo as SDKInfo,oi as chapterIdsToVKVideoIds,mt as compareVersions,Yn as getChapterIdByVkVideoId,nn as getVKVideoIdByMedia,qn as getVideoRawIdByMedia,Wt as graphEventTypes,Te as hasEndTemplate,N as interactivesEventTypes,st as isLastChapter,ge as isSupportedManifest,Zn as isVKVariantItem,as as utils,sn as vkVideoIdsToChapterIds};
|