@vkontakte/videoplayer-interactive 1.0.33-dev.f7191504.0 → 1.0.34-dev.d1ff213b.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 +16 -105
- package/es2015.esm.js +16 -105
- package/es2018.cjs.js +16 -105
- package/es2018.esm.js +16 -105
- package/esnext.cjs.js +16 -105
- package/esnext.esm.js +16 -105
- package/evergreen.esm.js +16 -105
- package/package.json +5 -5
- package/types/index.d.ts +1 -1
- package/types/modules/Interactives/Interactives.d.ts +0 -4
- package/types/modules/Interactives/containers/ChoiceContainer.d.ts +0 -2
- package/types/modules/Interactives/containers/Container.d.ts +1 -1
- package/types/modules/Interactives/containers/types.d.ts +1 -1
- package/types/modules/Interactives/controls/AreaControl.d.ts +0 -5
- package/types/modules/Interactives/controls/ButtonControl.d.ts +0 -5
- package/types/modules/Interactives/controls/Control.d.ts +2 -5
- package/types/modules/Interactives/controls/TextControl.d.ts +0 -2
- package/types/modules/Interactives/controls/types.d.ts +1 -1
- package/types/modules/Interactives/controls/utils.d.ts +0 -4
- package/types/modules/Interactives/index.d.ts +7 -17
- package/types/modules/Interactives/types.d.ts +2 -5
- package/types/modules/Interactives/utils/GameController.d.ts +0 -2
- package/types/modules/Interactives/utils/gameUtils.d.ts +2 -13
- package/types/modules/Interactives/utils/renderingUtils.d.ts +1 -15
- package/types/utils/typeCheck.d.ts +2 -2
- package/types/modules/Interactives/utils/blinkAnimationReference.d.ts +0 -8
- package/types/modules/Interactives/utils/functionUtils.d.ts +0 -5
- package/types/utils/FrameAverageColor/FrameAverageColor.d.ts +0 -19
- package/types/utils/FrameAverageColor/helpers.d.ts +0 -17
- package/types/utils/FrameAverageColor/index.d.ts +0 -2
package/esnext.esm.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-interactive v1.0.
|
|
3
|
-
*
|
|
4
|
-
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-
|
|
2
|
+
* @vkontakte/videoplayer-interactive v1.0.34-dev.d1ff213b.0
|
|
3
|
+
* Thu, 13 Mar 2025 07:21:12 GMT
|
|
4
|
+
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-34/doc/
|
|
5
5
|
*/
|
|
6
|
-
var wa=Object.create;var Yr=Object.defineProperty;var Ra=Object.getOwnPropertyDescriptor;var Oa=Object.getOwnPropertyNames;var ka=Object.getPrototypeOf,Pa=Object.prototype.hasOwnProperty;var u=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Va=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Oa(e))!Pa.call(t,i)&&i!==r&&Yr(t,i,{get:()=>e[i],enumerable:!(n=Ra(e,i))||n.enumerable});return t};var z=(t,e,r)=>(r=t!=null?wa(ka(t)):{},Va(e||!t||!t.__esModule?Yr(r,"default",{value:t,enumerable:!0}):r,t));var K=u((Wt,hn)=>{"use strict";var ge=function(t){return t&&t.Math===Math&&t};hn.exports=ge(typeof globalThis=="object"&&globalThis)||ge(typeof window=="object"&&window)||ge(typeof self=="object"&&self)||ge(typeof global=="object"&&global)||ge(typeof Wt=="object"&&Wt)||function(){return this}()||Function("return this")()});var _=u((vd,dn)=>{"use strict";dn.exports=function(t){try{return!!t()}catch{return!0}}});var Ee=u((yd,mn)=>{"use strict";var Fa=_();mn.exports=!Fa(function(){var t=function(){}.bind();return typeof t!="function"||t.hasOwnProperty("prototype")})});var Cn=u((bd,bn)=>{"use strict";var ja=Ee(),yn=Function.prototype,fn=yn.apply,vn=yn.call;bn.exports=typeof Reflect=="object"&&Reflect.apply||(ja?vn.bind(fn):function(){return vn.apply(fn,arguments)})});var U=u((Cd,xn)=>{"use strict";var gn=Ee(),En=Function.prototype,Kt=En.call,_a=gn&&En.bind.bind(Kt,Kt);xn.exports=gn?_a:function(t){return function(){return Kt.apply(t,arguments)}}});var xe=u((gd,Tn)=>{"use strict";var In=U(),Ba=In({}.toString),qa=In("".slice);Tn.exports=function(t){return qa(Ba(t),8,-1)}});var Qt=u((Ed,Sn)=>{"use strict";var Da=xe(),Ha=U();Sn.exports=function(t){if(Da(t)==="Function")return Ha(t)}});var B=u((xd,An)=>{"use strict";var Xt=typeof document=="object"&&document.all;An.exports=typeof Xt>"u"&&Xt!==void 0?function(t){return typeof t=="function"||t===Xt}:function(t){return typeof t=="function"}});var re=u((Id,wn)=>{"use strict";var Ua=_();wn.exports=!Ua(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var at=u((Td,Rn)=>{"use strict";var Ga=Ee(),st=Function.prototype.call;Rn.exports=Ga?st.bind(st):function(){return st.apply(st,arguments)}});var Yt=u(Pn=>{"use strict";var On={}.propertyIsEnumerable,kn=Object.getOwnPropertyDescriptor,za=kn&&!On.call({1:2},1);Pn.f=za?function(e){var r=kn(this,e);return!!r&&r.enumerable}:On});var Zt=u((Ad,Vn)=>{"use strict";Vn.exports=function(t,e){return{enumerable:!(t&1),configurable:!(t&2),writable:!(t&4),value:e}}});var $n=u((wd,Mn)=>{"use strict";var Wa=U(),Ka=_(),Qa=xe(),Jt=Object,Xa=Wa("".split);Mn.exports=Ka(function(){return!Jt("z").propertyIsEnumerable(0)})?function(t){return Qa(t)==="String"?Xa(t,""):Jt(t)}:Jt});var er=u((Rd,Ln)=>{"use strict";Ln.exports=function(t){return t==null}});var tr=u((Od,Nn)=>{"use strict";var Ya=er(),Za=TypeError;Nn.exports=function(t){if(Ya(t))throw new Za("Can't call method on "+t);return t}});var Ie=u((kd,Fn)=>{"use strict";var Ja=$n(),el=tr();Fn.exports=function(t){return Ja(el(t))}});var le=u((Pd,jn)=>{"use strict";var tl=B();jn.exports=function(t){return typeof t=="object"?t!==null:tl(t)}});var lt=u((Vd,_n)=>{"use strict";_n.exports={}});var ct=u((Md,qn)=>{"use strict";var rr=lt(),nr=K(),rl=B(),Bn=function(t){return rl(t)?t:void 0};qn.exports=function(t,e){return arguments.length<2?Bn(rr[t])||Bn(nr[t]):rr[t]&&rr[t][e]||nr[t]&&nr[t][e]}});var Hn=u(($d,Dn)=>{"use strict";var nl=U();Dn.exports=nl({}.isPrototypeOf)});var Wn=u((Ld,zn)=>{"use strict";var il=K(),Un=il.navigator,Gn=Un&&Un.userAgent;zn.exports=Gn?String(Gn):""});var ei=u((Nd,Jn)=>{"use strict";var Zn=K(),ir=Wn(),Kn=Zn.process,Qn=Zn.Deno,Xn=Kn&&Kn.versions||Qn&&Qn.version,Yn=Xn&&Xn.v8,G,pt;Yn&&(G=Yn.split("."),pt=G[0]>0&&G[0]<4?1:+(G[0]+G[1]));!pt&&ir&&(G=ir.match(/Edge\/(\d+)/),(!G||G[1]>=74)&&(G=ir.match(/Chrome\/(\d+)/),G&&(pt=+G[1])));Jn.exports=pt});var or=u((Fd,ri)=>{"use strict";var ti=ei(),ol=_(),sl=K(),al=sl.String;ri.exports=!!Object.getOwnPropertySymbols&&!ol(function(){var t=Symbol("symbol detection");return!al(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&ti&&ti<41})});var sr=u((jd,ni)=>{"use strict";var ll=or();ni.exports=ll&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var ar=u((_d,ii)=>{"use strict";var cl=ct(),pl=B(),ul=Hn(),hl=sr(),dl=Object;ii.exports=hl?function(t){return typeof t=="symbol"}:function(t){var e=cl("Symbol");return pl(e)&&ul(e.prototype,dl(t))}});var si=u((Bd,oi)=>{"use strict";var ml=String;oi.exports=function(t){try{return ml(t)}catch{return"Object"}}});var lr=u((qd,ai)=>{"use strict";var fl=B(),vl=si(),yl=TypeError;ai.exports=function(t){if(fl(t))return t;throw new yl(vl(t)+" is not a function")}});var ci=u((Dd,li)=>{"use strict";var bl=lr(),Cl=er();li.exports=function(t,e){var r=t[e];return Cl(r)?void 0:bl(r)}});var ui=u((Hd,pi)=>{"use strict";var cr=at(),pr=B(),ur=le(),gl=TypeError;pi.exports=function(t,e){var r,n;if(e==="string"&&pr(r=t.toString)&&!ur(n=cr(r,t))||pr(r=t.valueOf)&&!ur(n=cr(r,t))||e!=="string"&&pr(r=t.toString)&&!ur(n=cr(r,t)))return n;throw new gl("Can't convert object to primitive value")}});var di=u((Ud,hi)=>{"use strict";hi.exports=!0});var vi=u((Gd,fi)=>{"use strict";var mi=K(),El=Object.defineProperty;fi.exports=function(t,e){try{El(mi,t,{value:e,configurable:!0,writable:!0})}catch{mi[t]=e}return e}});var ut=u((zd,Ci)=>{"use strict";var xl=di(),Il=K(),Tl=vi(),yi="__core-js_shared__",bi=Ci.exports=Il[yi]||Tl(yi,{});(bi.versions||(bi.versions=[])).push({version:"3.38.0",mode:xl?"pure":"global",copyright:"\xA9 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.38.0/LICENSE",source:"https://github.com/zloirock/core-js"})});var hr=u((Wd,Ei)=>{"use strict";var gi=ut();Ei.exports=function(t,e){return gi[t]||(gi[t]=e||{})}});var Te=u((Kd,xi)=>{"use strict";var Sl=tr(),Al=Object;xi.exports=function(t){return Al(Sl(t))}});var ce=u((Qd,Ii)=>{"use strict";var wl=U(),Rl=Te(),Ol=wl({}.hasOwnProperty);Ii.exports=Object.hasOwn||function(e,r){return Ol(Rl(e),r)}});var dr=u((Xd,Ti)=>{"use strict";var kl=U(),Pl=0,Vl=Math.random(),Ml=kl(1 .toString);Ti.exports=function(t){return"Symbol("+(t===void 0?"":t)+")_"+Ml(++Pl+Vl,36)}});var Se=u((Yd,Ai)=>{"use strict";var $l=K(),Ll=hr(),Si=ce(),Nl=dr(),Fl=or(),jl=sr(),pe=$l.Symbol,mr=Ll("wks"),_l=jl?pe.for||pe:pe&&pe.withoutSetter||Nl;Ai.exports=function(t){return Si(mr,t)||(mr[t]=Fl&&Si(pe,t)?pe[t]:_l("Symbol."+t)),mr[t]}});var ki=u((Zd,Oi)=>{"use strict";var Bl=at(),wi=le(),Ri=ar(),ql=ci(),Dl=ui(),Hl=Se(),Ul=TypeError,Gl=Hl("toPrimitive");Oi.exports=function(t,e){if(!wi(t)||Ri(t))return t;var r=ql(t,Gl),n;if(r){if(e===void 0&&(e="default"),n=Bl(r,t,e),!wi(n)||Ri(n))return n;throw new Ul("Can't convert object to primitive value")}return e===void 0&&(e="number"),Dl(t,e)}});var fr=u((Jd,Pi)=>{"use strict";var zl=ki(),Wl=ar();Pi.exports=function(t){var e=zl(t,"string");return Wl(e)?e:e+""}});var $i=u((em,Mi)=>{"use strict";var Kl=K(),Vi=le(),vr=Kl.document,Ql=Vi(vr)&&Vi(vr.createElement);Mi.exports=function(t){return Ql?vr.createElement(t):{}}});var yr=u((tm,Li)=>{"use strict";var Xl=re(),Yl=_(),Zl=$i();Li.exports=!Xl&&!Yl(function(){return Object.defineProperty(Zl("div"),"a",{get:function(){return 7}}).a!==7})});var ji=u(Fi=>{"use strict";var Jl=re(),ec=at(),tc=Yt(),rc=Zt(),nc=Ie(),ic=fr(),oc=ce(),sc=yr(),Ni=Object.getOwnPropertyDescriptor;Fi.f=Jl?Ni:function(e,r){if(e=nc(e),r=ic(r),sc)try{return Ni(e,r)}catch{}if(oc(e,r))return rc(!ec(tc.f,e,r),e[r])}});var Bi=u((nm,_i)=>{"use strict";var ac=_(),lc=B(),cc=/#|\.prototype\./,Ae=function(t,e){var r=uc[pc(t)];return r===dc?!0:r===hc?!1:lc(e)?ac(e):!!e},pc=Ae.normalize=function(t){return String(t).replace(cc,".").toLowerCase()},uc=Ae.data={},hc=Ae.NATIVE="N",dc=Ae.POLYFILL="P";_i.exports=Ae});var br=u((im,Di)=>{"use strict";var qi=Qt(),mc=lr(),fc=Ee(),vc=qi(qi.bind);Di.exports=function(t,e){return mc(t),e===void 0?t:fc?vc(t,e):function(){return t.apply(e,arguments)}}});var Ui=u((om,Hi)=>{"use strict";var yc=re(),bc=_();Hi.exports=yc&&bc(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var zi=u((sm,Gi)=>{"use strict";var Cc=le(),gc=String,Ec=TypeError;Gi.exports=function(t){if(Cc(t))return t;throw new Ec(gc(t)+" is not an object")}});var Qi=u(Ki=>{"use strict";var xc=re(),Ic=yr(),Tc=Ui(),ht=zi(),Wi=fr(),Sc=TypeError,Cr=Object.defineProperty,Ac=Object.getOwnPropertyDescriptor,gr="enumerable",Er="configurable",xr="writable";Ki.f=xc?Tc?function(e,r,n){if(ht(e),r=Wi(r),ht(n),typeof e=="function"&&r==="prototype"&&"value"in n&&xr in n&&!n[xr]){var i=Ac(e,r);i&&i[xr]&&(e[r]=n.value,n={configurable:Er in n?n[Er]:i[Er],enumerable:gr in n?n[gr]:i[gr],writable:!1})}return Cr(e,r,n)}:Cr:function(e,r,n){if(ht(e),r=Wi(r),ht(n),Ic)try{return Cr(e,r,n)}catch{}if("get"in n||"set"in n)throw new Sc("Accessors not supported");return"value"in n&&(e[r]=n.value),e}});var Yi=u((lm,Xi)=>{"use strict";var wc=re(),Rc=Qi(),Oc=Zt();Xi.exports=wc?function(t,e,r){return Rc.f(t,e,Oc(1,r))}:function(t,e,r){return t[e]=r,t}});var Re=u((cm,Ji)=>{"use strict";var we=K(),kc=Cn(),Pc=Qt(),Vc=B(),Mc=ji().f,$c=Bi(),ue=lt(),Lc=br(),he=Yi(),Zi=ce();ut();var Nc=function(t){var e=function(r,n,i){if(this instanceof e){switch(arguments.length){case 0:return new t;case 1:return new t(r);case 2:return new t(r,n)}return new t(r,n,i)}return kc(t,this,arguments)};return e.prototype=t.prototype,e};Ji.exports=function(t,e){var r=t.target,n=t.global,i=t.stat,o=t.proto,l=n?we:i?we[r]:we[r]&&we[r].prototype,s=n?ue:ue[r]||he(ue,r,{})[r],a=s.prototype,c,d,m,f,y,k,A,g,x;for(f in e)c=$c(n?f:r+(i?".":"#")+f,t.forced),d=!c&&l&&Zi(l,f),k=s[f],d&&(t.dontCallGetSet?(x=Mc(l,f),A=x&&x.value):A=l[f]),y=d&&A?A:e[f],!(!c&&!o&&typeof k==typeof y)&&(t.bind&&d?g=Lc(y,we):t.wrap&&d?g=Nc(y):o&&Vc(y)?g=Pc(y):g=y,(t.sham||y&&y.sham||k&&k.sham)&&he(g,"sham",!0),he(s,f,g),o&&(m=r+"Prototype",Zi(ue,m)||he(ue,m,{}),he(ue[m],f,y),t.real&&a&&(c||!a[f])&&he(a,f,y)))}});var to=u((pm,eo)=>{"use strict";var Fc=Math.ceil,jc=Math.floor;eo.exports=Math.trunc||function(e){var r=+e;return(r>0?jc:Fc)(r)}});var Oe=u((um,ro)=>{"use strict";var _c=to();ro.exports=function(t){var e=+t;return e!==e||e===0?0:_c(e)}});var io=u((hm,no)=>{"use strict";var Bc=Oe(),qc=Math.min;no.exports=function(t){var e=Bc(t);return e>0?qc(e,9007199254740991):0}});var ke=u((dm,oo)=>{"use strict";var Dc=io();oo.exports=function(t){return Dc(t.length)}});var dt=u((mm,so)=>{"use strict";so.exports=function(){}});var ao=u(()=>{"use strict";var Hc=Re(),Uc=Te(),Gc=ke(),zc=Oe(),Wc=dt();Hc({target:"Array",proto:!0},{at:function(e){var r=Uc(this),n=Gc(r),i=zc(e),o=i>=0?i:n+i;return o<0||o>=n?void 0:r[o]}});Wc("at")});var mt=u((ym,lo)=>{"use strict";var Kc=ct();lo.exports=Kc});var po=u((bm,co)=>{"use strict";ao();var Qc=mt();co.exports=Qc("Array","at")});var ho=u((Cm,uo)=>{"use strict";var Xc=po();uo.exports=Xc});var Ir=u((gm,mo)=>{"use strict";var Yc=ho();mo.exports=Yc});var So=u((Ef,To)=>{"use strict";var op=Oe(),sp=Math.max,ap=Math.min;To.exports=function(t,e){var r=op(t);return r<0?sp(r+e,0):ap(r,e)}});var Or=u((xf,wo)=>{"use strict";var lp=Ie(),cp=So(),pp=ke(),Ao=function(t){return function(e,r,n){var i=lp(e),o=pp(i);if(o===0)return!t&&-1;var l=cp(n,o),s;if(t&&r!==r){for(;o>l;)if(s=i[l++],s!==s)return!0}else for(;o>l;l++)if((t||l in i)&&i[l]===r)return t||l||0;return!t&&-1}};wo.exports={includes:Ao(!0),indexOf:Ao(!1)}});var Ro=u(()=>{"use strict";var up=Re(),hp=Or().includes,dp=_(),mp=dt(),fp=dp(function(){return!Array(1).includes()});up({target:"Array",proto:!0,forced:fp},{includes:function(e){return hp(this,e,arguments.length>1?arguments[1]:void 0)}});mp("includes")});var ko=u((Sf,Oo)=>{"use strict";Ro();var vp=mt();Oo.exports=vp("Array","includes")});var Vo=u((Af,Po)=>{"use strict";var yp=ko();Po.exports=yp});var Fe=u((wf,Mo)=>{"use strict";var bp=Vo();Mo.exports=bp});var Bo=u((jf,_o)=>{"use strict";var Ep=hr(),xp=dr(),jo=Ep("keys");_o.exports=function(t){return jo[t]||(jo[t]=xp(t))}});var Do=u((_f,qo)=>{"use strict";var Ip=_();qo.exports=!Ip(function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype})});var Go=u((Bf,Uo)=>{"use strict";var Tp=ce(),Sp=B(),Ap=Te(),wp=Bo(),Rp=Do(),Ho=wp("IE_PROTO"),Vr=Object,Op=Vr.prototype;Uo.exports=Rp?Vr.getPrototypeOf:function(t){var e=Ap(t);if(Tp(e,Ho))return e[Ho];var r=e.constructor;return Sp(r)&&e instanceof r?r.prototype:e instanceof Vr?Op:null}});var Wo=u((qf,zo)=>{"use strict";zo.exports={}});var Xo=u((Df,Qo)=>{"use strict";var kp=U(),Mr=ce(),Pp=Ie(),Vp=Or().indexOf,Mp=Wo(),Ko=kp([].push);Qo.exports=function(t,e){var r=Pp(t),n=0,i=[],o;for(o in r)!Mr(Mp,o)&&Mr(r,o)&&Ko(i,o);for(;e.length>n;)Mr(r,o=e[n++])&&(~Vp(i,o)||Ko(i,o));return i}});var Zo=u((Hf,Yo)=>{"use strict";Yo.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var es=u((Uf,Jo)=>{"use strict";var $p=Xo(),Lp=Zo();Jo.exports=Object.keys||function(e){return $p(e,Lp)}});var ss=u((Gf,os)=>{"use strict";var rs=re(),Np=_(),ns=U(),Fp=Go(),jp=es(),_p=Ie(),Bp=Yt().f,is=ns(Bp),qp=ns([].push),Dp=rs&&Np(function(){var t=Object.create(null);return t[2]=2,!is(t,2)}),ts=function(t){return function(e){for(var r=_p(e),n=jp(r),i=Dp&&Fp(r)===null,o=n.length,l=0,s=[],a;o>l;)a=n[l++],(!rs||(i?a in r:is(r,a)))&&qp(s,t?[a,r[a]]:r[a]);return s}};os.exports={entries:ts(!0),values:ts(!1)}});var as=u(()=>{"use strict";var Hp=Re(),Up=ss().values;Hp({target:"Object",stat:!0},{values:function(e){return Up(e)}})});var cs=u((Kf,ls)=>{"use strict";as();var Gp=lt();ls.exports=Gp.Object.values});var us=u((Qf,ps)=>{"use strict";var zp=cs();ps.exports=zp});var Rt=u((Xf,hs)=>{"use strict";var Wp=us();hs.exports=Wp});var _r=u((Cv,Cs)=>{"use strict";var Jp=xe();Cs.exports=Array.isArray||function(e){return Jp(e)==="Array"}});var Es=u((gv,gs)=>{"use strict";var eu=TypeError,tu=9007199254740991;gs.exports=function(t){if(t>tu)throw eu("Maximum allowed index exceeded");return t}});var Ts=u((Ev,Is)=>{"use strict";var ru=_r(),nu=ke(),iu=Es(),ou=br(),xs=function(t,e,r,n,i,o,l,s){for(var a=i,c=0,d=l?ou(l,s):!1,m,f;c<n;)c in r&&(m=d?d(r[c],c,e):r[c],o>0&&ru(m)?(f=nu(m),a=xs(t,e,m,f,a,o-1)-1):(iu(a+1),t[a]=m),a++),c++;return a};Is.exports=xs});var ws=u((xv,As)=>{"use strict";var su=Se(),au=su("toStringTag"),Ss={};Ss[au]="z";As.exports=String(Ss)==="[object z]"});var Os=u((Iv,Rs)=>{"use strict";var lu=ws(),cu=B(),kt=xe(),pu=Se(),uu=pu("toStringTag"),hu=Object,du=kt(function(){return arguments}())==="Arguments",mu=function(t,e){try{return t[e]}catch{}};Rs.exports=lu?kt:function(t){var e,r,n;return t===void 0?"Undefined":t===null?"Null":typeof(r=mu(e=hu(t),uu))=="string"?r:du?kt(e):(n=kt(e))==="Object"&&cu(e.callee)?"Arguments":n}});var Ps=u((Tv,ks)=>{"use strict";var fu=U(),vu=B(),Br=ut(),yu=fu(Function.toString);vu(Br.inspectSource)||(Br.inspectSource=function(t){return yu(t)});ks.exports=Br.inspectSource});var Fs=u((Sv,Ns)=>{"use strict";var bu=U(),Cu=_(),Vs=B(),gu=Os(),Eu=ct(),xu=Ps(),Ms=function(){},$s=Eu("Reflect","construct"),qr=/^\s*(?:class|function)\b/,Iu=bu(qr.exec),Tu=!qr.test(Ms),qe=function(e){if(!Vs(e))return!1;try{return $s(Ms,[],e),!0}catch{return!1}},Ls=function(e){if(!Vs(e))return!1;switch(gu(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Tu||!!Iu(qr,xu(e))}catch{return!0}};Ls.sham=!0;Ns.exports=!$s||Cu(function(){var t;return qe(qe.call)||!qe(Object)||!qe(function(){t=!0})||t})?Ls:qe});var qs=u((Av,Bs)=>{"use strict";var js=_r(),Su=Fs(),Au=le(),wu=Se(),Ru=wu("species"),_s=Array;Bs.exports=function(t){var e;return js(t)&&(e=t.constructor,Su(e)&&(e===_s||js(e.prototype))?e=void 0:Au(e)&&(e=e[Ru],e===null&&(e=void 0))),e===void 0?_s:e}});var Hs=u((wv,Ds)=>{"use strict";var Ou=qs();Ds.exports=function(t,e){return new(Ou(t))(e===0?0:e)}});var Us=u(()=>{"use strict";var ku=Re(),Pu=Ts(),Vu=Te(),Mu=ke(),$u=Oe(),Lu=Hs();ku({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,r=Vu(this),n=Mu(r),i=Lu(r,0);return i.length=Pu(i,r,r,n,0,e===void 0?1:$u(e)),i}})});var Gs=u(()=>{"use strict";var Nu=dt();Nu("flat")});var Ws=u((Vv,zs)=>{"use strict";Us();Gs();var Fu=mt();zs.exports=Fu("Array","flat")});var Qs=u((Mv,Ks)=>{"use strict";var ju=Ws();Ks.exports=ju});var Ys=u(($v,Xs)=>{"use strict";var _u=Qs();Xs.exports=_u});var Zr="1.0.33-dev.f7191504.0";var Ft=class{constructor(e){this.layout=e}},We=class extends Ft{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))`}};function Jr(t){return"features"in t}var se=class{constructor(e,r){this.container=e,this.options=r,this.factories=new Map,this.controls=[],this.setControls()}featureIsEnabled(e){return this.options&&Jr(this.options)&&this.options.features[e]}addControlFactory(e,r){this.factories.set(e.trim().toLowerCase(),r),this.setControls()}removeControlFactory(e){this.factories.delete(e.trim().toLowerCase()),this.setControls()}setControls(){this.controls=this.chooseControls()}chooseControls(){return this.container.controls?.reduce((e,r)=>{let n=r.type.trim().toLowerCase(),i=this.factories.get(n);if(i){let o=i(r,this.options);if(o)return[...e,o]}return[...e]},[])||[]}};import{fromEvent as et,once as La}from"@vkontakte/videoplayer-shared";function ye(t,e=1){let r="0",n="0",i="0";return t.length===4?(r="0x"+t[1]+t[1],n="0x"+t[2]+t[2],i="0x"+t[3]+t[3]):t.length===7&&(r="0x"+t[1]+t[2],n="0x"+t[3]+t[4],i="0x"+t[5]+t[6]),`rgba(${+r},${+n},${+i},${e})`}var en="interactive",$={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderWidthRawValue:"1px",roundCornersRawValue:"0",borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0,shadowColorLight:"#fff",shadowColorDark:"#000",shadowColorAlpha:.24},tn=(n=>(n.top="flex-start",n.bottom="flex-end",n.center="center",n))(tn||{}),rn=(n=>(n.start="flex-start",n.end="flex-end",n.center="center",n))(rn||{}),nn=(n=>(n.start="left",n.end="right",n.center="center",n))(nn||{}),Ke=({target:t,props:e})=>{t.style.alignItems=(e?.gravityVertical&&tn[e.gravityVertical])??"center",t.style.justifyContent=(e?.gravityHorizontal&&rn[e.gravityHorizontal])??"center",t.style.textAlign=(e?.alignment&&nn[e.alignment])??"center"},Qe=({target:t,props:e,fallback:r,dependsOn:n})=>{t.style.color=e?.text?.color??r.textColor,t.style.fontSize=`calc(${n.height} * ${e?.text?.size??r.textSize})`,t.textContent=e?.text?.value??r.textContent},Xe=({target:t,props:e,fallback:r})=>{t.style.backgroundColor=ye(e?.background?.color??r.backgroundColor,e?.background?.alpha??r.backgroundAlpha)},be=({target:t,props:e,fallback:r,dependsOn:n,useRawValues:i=!1})=>{let o=i?r.borderWidthRawValue:`calc(${n.height} * ${e?.shape?.border?.width??r.borderWidth})`,l=i?r.roundCornersRawValue:`calc(${n.height} * ${e?.shape?.roundCorners??r.roundCorners})`;t.style.borderWidth=o,t.style.borderStyle="solid",t.style.borderColor=ye(i?r.borderColor:e?.shape?.border?.color??r.borderColor,i?r.borderAlpha:e?.shape?.border?.alpha??r.borderAlpha),t.style.borderRadius=l},on=({target:t,frameToneIsDark:e,baseDimension:r,fallback:n})=>{let l=ye(n.shadowColorLight,n.shadowColorAlpha),s=ye(n.shadowColorDark,n.shadowColorAlpha),a=`calc(${r} * ${.25})`,c=`calc(${r} * ${.11})`,d=`0px 0px ${a} ${c} ${e?l:s}`;t.style.boxShadow=d},ae=({target:t,layoutParams:e,fallback:r})=>{let n=e.angle??r.angle;n=n&&n*-1,t.style.transform=`rotate(${n}rad)`};import{fromEvent as Ma,Subscription as $a}from"@vkontakte/videoplayer-shared";var jt="int",ee=(n=>(n.AREA=`${jt}_area`,n.TEXT=`${jt}_text`,n.BUTTON=`${jt}_bttn`,n))(ee||{});function sn(t){return"features"in t}var W="interactive-control",b={common:W,selected:`${W}-selected`,wrapper:`${W}-wrapper`,disabled:`${W}-disabled`,button:`${W}-button`,area:`${W}-area`,text:`${W}-text`,blinkAnim:`${W}-blink-anim`,blinkAnimButton:`${W}-blink-anim-button`,blinkAnimArea:`${W}-blink-anim-area`};var Y=class{constructor(e,r){this.control=e;this.options=r;this.container=null;this.controlElement=null;this.subscriptions=new $a}createContainerElement(e){let r=document.createElement("div");r.classList.add(b.wrapper),e.setControlLayout(r,this.control.layoutParams);let n=(this.control.layoutParams.innerSizesDependOn??$.innerSizesDependOn)==="self"?{height:r.style.height,width:r.style.width}:{height:"var(--interactive-content-height)",width:"var(--interactive-content-width)"};this.container={element:r,dimensions:n}}createClickListener(e){return r=>{r.stopPropagation(),e()}}featureIsEnabled(e){return this.options&&sn(this.options)&&this.options.features[e]}setEvents(e){!this.container||!this.control.events||this.control.events.forEach(r=>{switch(r.type.trim().toLowerCase()){case"onclick":{if(!this.container)break;this.subscriptions.add(Ma(this.container.element,"click").subscribe(this.createClickListener(()=>e({action:r.action,controlId:this.control.id,controlType:this.control.type}))));break}default:break}})}removeListeners(){this.subscriptions.unsubscribe()}};var Z=(t,e)=>Object.prototype.toString.call(t)===`[object ${e}]`,J=t=>Z(t,"Object"),Ye=t=>Z(t,"String"),Ze=t=>Z(t,"Array"),Je=t=>Z(t,"Number"),an=t=>Z(t,"Function"),ln=t=>Z(t,"Boolean"),_t=t=>Je(t)&&!isNaN(t);var te=t=>J(t)&&Object.keys(t).length===0,Bt=t=>Ze(t)&&!t.length;var Ce=(t,e)=>Ye(t)&&(e?t.trim():t).length;var qt="interactive-blink-anim-reference",V={common:qt,animation:`${qt}-animation`,disabled:`${qt}-disabled`},cn=()=>{let t=document.createElement("div");return t.classList.add(V.common,V.animation),t},pn=t=>{t.classList.add(V.disabled),requestAnimationFrame(()=>{t.classList.remove(V.disabled)})};var Dt="interactive-container",w={common:Dt,hidden:`${Dt}-hidden`,disabled:`${Dt}-disabled`};var tt=(t,e)=>{if(t.type.trim().toLowerCase()==="area")return new Ht(t,e)},Ht=class extends Y{constructor(e,r){super(e,r)}createView({parentElement:e,callbacks:r}){if(super.createContainerElement(r),!this.container)return;let n=document.createElement("button");n.type="button",n.classList.add(b.common,b.area),n.setAttribute("data-testid",ee.AREA),Xe({target:n,props:this.control.props,fallback:{...$,backgroundColor:"transparent"}}),this.updateShadowStyles(),ae({target:n,layoutParams:this.control.layoutParams,fallback:$}),this.container.element.append(n),e.append(this.container.element),this.controlElement=n,this.registerEvents()}registerEvents(){if(this.featureIsEnabled("controlsExpectTimeBlinkAnimation")){let e=this.container?.element.parentElement;if(!e||!this.controlElement)return;this.subscriptions.add(et(this.controlElement,"mouseleave").subscribe(()=>{if(e.classList.contains(w.disabled))return;let r=e.parentElement;if(r){let n=r.querySelector(`.${V.common}`);n&&this.syncBlinkAnimation(n)}})),this.subscriptions.add(et(this.controlElement,"mouseenter").subscribe(()=>{e.classList.contains(w.disabled)||this.onBlinkHovering()})).add(et(this.controlElement,"mouseleave").subscribe(()=>{this.controlElement&&(this.controlElement.style.animation="")}))}}disable(){this.controlElement&&this.controlElement.classList.add(b.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(b.disabled)}getElement(){return this.controlElement}updateShadowStyles(e){if(!(!this.container||!this.controlElement))if(ln(e)){let r=Math.min(this.controlElement.offsetWidth,this.controlElement.offsetHeight)+"px";on({target:this.controlElement,props:this.control.props,fallback:$,frameToneIsDark:e,baseDimension:r}),be({target:this.controlElement,props:this.control.props,fallback:{...$,borderColor:e?"#fff":"#000",borderAlpha:1,borderWidthRawValue:"0.1px",roundCornersRawValue:`calc(${this.container.dimensions.height} * ${this.control.props?.shape?.roundCorners??$.roundCorners})`},dependsOn:this.container.dimensions,useRawValues:!0})}else be({target:this.controlElement,props:this.control.props,fallback:{...$,borderAlpha:0},dependsOn:this.container.dimensions})}toggleBlinkAnimation(e){this.controlElement?.classList.toggle(b.blinkAnim,e),this.controlElement?.classList.toggle(b.blinkAnimArea,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${b.blinkAnimArea}`)||this.controlElement.classList.contains(b.selected)||this.controlElement.classList.contains(V.disabled)||(this.controlElement.classList.add(V.disabled),this.subscriptions.add(et(e,"animationiteration").pipe(La()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(V.disabled)}))))}onBlinkHovering(){if(!this.controlElement||!this.controlElement.classList.contains(`${b.blinkAnimArea}`)||this.controlElement.classList.contains(b.selected))return;let e=window.getComputedStyle(this.controlElement),r=e.getPropertyValue("--interactive-area-hover-opacity").trim();this.controlElement.style.opacity=e.opacity,this.controlElement.style.animation="none",requestAnimationFrame(()=>{this.controlElement&&(this.controlElement.style.opacity=r)})}onProgress(){}onResize(){}};import{fromEvent as nt,once as Na}from"@vkontakte/videoplayer-shared";var rt=t=>{let e=document.createElement("span");switch(t){case"Button":case"button":{let r=document.createElement("div"),n={overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center"};Object.assign(r.style,n),r.append(e);let i={display:"inline-block",whiteSpace:"pre",textOverflow:"ellipsis",maxWidth:"initial",maxHeight:"100%",wordBreak:"normal"};return Object.assign(e.style,i),r}default:{let r={display:"inline-block",whiteSpace:"break-spaces",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%",maxHeight:"100%",wordBreak:"break-all"};return Object.assign(e.style,r),e}}};var it=(t,e)=>{if(t.type.trim().toLowerCase()==="button")return new Ut(t,e)},Ut=class extends Y{constructor(e,r){super(e,r)}createView({parentElement:e,callbacks:r}){if(super.createContainerElement(r),!this.container)return;let n=document.createElement("button");n.type="button",n.classList.add(b.common,b.button),n.setAttribute("data-testid",ee.BUTTON),ae({target:n,layoutParams:this.control.layoutParams,fallback:$}),Xe({target:n,props:this.control.props,fallback:$}),be({target:n,props:this.control.props,fallback:$,dependsOn:this.container.dimensions}),Ke({target:n,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let i=rt(this.control.type.trim().toLowerCase()),o=i.firstElementChild??i;Qe({target:o,props:this.control.props,fallback:$,dependsOn:this.container.dimensions}),n.append(i),this.container.element.append(n),e.append(this.container.element),this.controlElement=n,this.registerEvents()}registerEvents(){if(this.featureIsEnabled("controlsExpectTimeBlinkAnimation")){let e=this.container?.element.parentElement;if(!e||!this.controlElement)return;this.subscriptions.add(nt(this.controlElement,"mouseleave").subscribe(()=>{if(e.classList.contains(w.disabled))return;let r=e.parentElement;if(r){let n=r.querySelector(`.${V.common}`);n&&this.syncBlinkAnimation(n)}})),this.subscriptions.add(nt(this.controlElement,"mouseenter").subscribe(()=>{e.classList.contains(w.disabled)||this.onBlinkHovering()})).add(nt(this.controlElement,"mouseleave").subscribe(()=>{this.controlElement&&(this.controlElement.style.animation="")}))}}disable(){this.controlElement&&this.controlElement.classList.add(b.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(b.disabled)}getElement(){return this.controlElement}toggleBlinkAnimation(e){this.controlElement?.classList.toggle(b.blinkAnim,e),this.controlElement?.classList.toggle(b.blinkAnimButton,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${b.blinkAnimButton}`)||this.controlElement.classList.contains(b.selected)||this.controlElement.classList.contains(V.disabled)||(this.controlElement.classList.add(V.disabled),this.subscriptions.add(nt(e,"animationiteration").pipe(Na()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(V.disabled)}))))}onBlinkHovering(){if(!this.controlElement||!this.controlElement.classList.contains(`${b.blinkAnimButton}`)||this.controlElement.classList.contains(b.selected))return;let e=window.getComputedStyle(this.controlElement),r=e.getPropertyValue("--interactive-button-hover-opacity").trim();this.controlElement.style.opacity=e.opacity,this.controlElement.style.animation="none",requestAnimationFrame(()=>{this.controlElement&&(this.controlElement.style.opacity=r)})}onProgress(){}onResize(){}updateShadowStyles(){}};var un=(t,e)=>{if(t.type.trim().toLowerCase()==="text")return new Gt(t,e)},Gt=class extends Y{constructor(e,r){super(e,r)}createView({parentElement:e,callbacks:r}){if(super.createContainerElement(r),!this.container)return;let n=document.createElement("div");n.classList.add(b.common,b.text),n.setAttribute("data-testid",ee.TEXT),ae({target:n,layoutParams:this.control.layoutParams,fallback:$}),Ke({target:n,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let i=rt(this.control.type.trim().toLowerCase()),o=i.firstElementChild??i;Qe({target:o,props:this.control.props,fallback:$,dependsOn:this.container.dimensions}),n.append(i),this.container.element.append(n),e.append(this.container.element),this.controlElement=n}getElement(){return this.controlElement}disable(){}enable(){}onProgress(){}onResize(){}updateShadowStyles(){}toggleBlinkAnimation(){}};var ot=(t,e,r)=>{if(t.type.trim().toLowerCase()==="choice")return new zt(t,e,r)},zt=class extends se{constructor(r,n,i){super(r,i);this.containerElement=null;this.rootElement=n,this.layout=new We(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",it),this.addControlFactory("text",un),this.addControlFactory("area",tt)}createView({eventCallback:r}){let n=document.createElement("div");return n.classList.add(w.common,w.disabled),requestAnimationFrame(()=>{n.classList.remove(w.disabled)}),this.layout.setContainerLayout(n),this.controls.forEach(i=>{i.createView({parentElement:n,callbacks:{setControlLayout:this.layout.setControlLayout}}),i.setEvents(r)}),this.rootElement.append(n),this.isRemoved=!1,this.containerElement=n,n}hide(){let r=this.getElement();r&&r.classList.add(w.hidden)}show(){let r=this.getElement();r&&r.classList.remove(w.hidden)}enable(){let r=this.getElement();r&&(r.classList.remove(w.disabled),this.controls.forEach(n=>n.enable()),this.isDisabled=!1)}disable(){let r=this.getElement();r&&(r.classList.add(w.disabled),this.controls.forEach(n=>n.disable()),this.isDisabled=!0)}removeView(){let r=this.getElement();r&&(this.controls.forEach(n=>n.removeListeners()),r.remove(),this.isRemoved=!0,this.containerElement=null)}fakeRemove(){this.isRemoved||(this.isRemoved=!0)}getElement(){return this.containerElement}onProgress(r,n){n&&this.controls.forEach(i=>{i.onProgress(r)})}onResize(r){r&&this.controls.forEach(n=>{n.onResize()})}updateControlsShadowStyles(r){this.controls.forEach(n=>n.updateShadowStyles(r))}toggleBlinkAnimation(r){this.controls.forEach(n=>n.toggleBlinkAnimation(r))}};var Sa=z(Ir(),1);import{clientChecker as nh,combine as ih,InterfaceLanguage as oh,Observable as xa,once as sh,Subject as F,Subscription as Qr,ValueSubject as j,fromEvent as Ia}from"@vkontakte/videoplayer-shared";import{InteractiveInterfaceClick as Ge}from"@vkontakte/videoplayer-statistics";import{loadVKLangPack as Zc}from"@vkontakte/videoplayer-shared";function Pe(t,e){let r;return(...n)=>{clearTimeout(r),r=setTimeout(()=>t(...n),e)}}var fo="video_interactive",vo="videoint";var yo=250,Ve=class{constructor(e){this.handleZoomChange=Pe(e=>{this.lastZoomInfo=e},yo);this.onResize=e=>{if(!this.isReady||this.isHidden||!e[0].contentRect.width||!e[0].contentRect.height)return;let r=this.getNextPoint();r&&this.ngEditor?.zoomTo(r),this.ngEditorSize={width:e[0].contentRect.width,height:e[0].contentRect.height}};this.handleChapterChange=e=>{if(this.manifest){if(this.isHidden||this.hide(),!e?.id){this.onError?.("Chapter 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=null}};this.handleManifestChange=(e,r=[])=>{if(this.isReady=!1,!Je(e.graph.edit.chapters[0].x)){this.onError?.("Can't show graph");return}this.lastZoomInfo=null,this.manifest=e,this.visitedChapterIds=new Set(r),this.ngEditor&&(this.manifest.metadata.id!==this.currentManifestId?(this.ngEditor.update(e),this.currentManifestId=this.manifest.metadata.id):this.ngEditor.setVisitedChapters(Array.from(r)),this.isReady=!0)};this.init(e)}init({root:e,onOpenPreviewClick:r,onError:n,lang:i,visitedChapters:o=[]}){this.isReady=!1,this.isHidden=!0,this.manifest=null,this.visitedChapterIds=new Set(o),this.onOpenPreviewClick=r,this.onError=n,this.lang=i??"ru",this.zoom=.7,this.lastZoomInfo=null,this.currentManifestId=null,this.currentChapterId=null,this.ngEditor=null,this.ngEditorSize=null,this.graphWrapperElement=Jc(e),this.resizeObserver=new ResizeObserver(Pe(this.onResize,yo)),this.resizeObserver.observe(this.graphWrapperElement)}getNextPoint(e=this.ngEditorSize){return!this.lastZoomInfo||!e?null:[(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)}async show(){this.manifest&&(this.ngEditor||await this.initNgEditor(),this.graphWrapperElement.style.display="block",!this.lastZoomInfo&&this.currentChapterId&&this.ngEditor?.focusChapter(this.currentChapterId),this.isHidden=!1)}async initNgEditor(){if(!this.manifest)return;let e;try{e=await Zc(this.lang,fo,vo)}catch{this.onError?.("Unable to load graph language pack")}let{GraphEditor:r}=await import("@interactiveplatform/movika-graph-editor");this.ngEditor=new r(this.graphWrapperElement,{mode:"read",lang:this.lang==="ru"?"ru":"en",translation:e}),this.currentManifestId=this.manifest.metadata.id,this.ngEditor.update(this.manifest),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId&&this.ngEditor.selectChapter(this.currentChapterId),this.ngEditor.on("control",({name:n,...i})=>{n==="openPreview"&&"chapterId"in i&&this.onOpenPreviewClick?.(i.chapterId)}),this.ngEditor.on("zoom",this.handleZoomChange),this.isReady=!0}hide(){this.graphWrapperElement.style.display="none",this.isHidden=!0}destroy(){this.hide(),this.manifest=null,this.resizeObserver.disconnect(),this.ngEditor?.setVisitedChapters([]),this.onOpenPreviewClick=void 0,this.ngEditor?.dispose(),this.graphWrapperElement.remove(),this.isReady=!1}};function Jc(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 Me=class{constructor(){this._containers=[];this._player=null;this.setPlayer=e=>{this._player=e};this.setContainers=e=>{this._containers=e};this.deleteContainer=e=>{this._containers=this._containers.filter(r=>r.id!==e)};this.getNextInteractiveTime=(e=3e3)=>{if(!this._containers.length||this._player===null)return null;let r=-1,n=!1,i=Math.round(this._player.info.position$.getValue()*1e3);for(let o of this._containers){let l=o.startTime-e;if(l<=i&&(o.endTime&&i<=o.endTime||o.endTime===null)){n=!0;break}i<l&&(r=r===-1?l:Math.min(r,l))}return!n&&r!==-1?r:null}}};import{isSupportedManifest as vt,ContainerTypes as Um,ControlTypes as yt,EventActionTypes as R,EventTypes as Gm,migrateManifestToLatestVersion as Eo,compareVersions as zm}from"@interactiveplatform/movika-manifest";var bo={metadata:"Object",chapters:"Array"},Co=t=>{if(!J(t))return!1;for(let e in bo)if(!t[e]||!Z(t[e],bo[e]))return!1;return vt(t.metadata.version)},ft=t=>t.type===yt.Text,Nm=t=>t.type===yt.Button,Fm=t=>t.type===yt.Area,jm={Choice:"Choice",TextInput:"TextInput"},_m={Button:"Button",Area:"Area",Text:"Text"},Bm={onClick:"onClick",onSuspense:"onSuspense"},go={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var L=class{constructor(e,r,...n){this.severity=e;this.category=r;this.data=n}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};var bt=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 n=()=>{r(),this.off(e,n)};return this.listeners[e].push(n),this}off(e,r){return this.removeListener(e,r)}reset(){this.listeners={}}removeListener(e,r){let n=this.listeners[e]||[];for(let i=n.length;i>0;i--)if(n[i]===r){n.splice(i,1);break}return this}emit(e,...r){let n=this.listeners[e];return n?(n.forEach(i=>{i(...r)}),!0):!1}listenerCount(e){return this.rawListeners(e).length}rawListeners(e){return this.listeners[e]||[]}};var Ct=class{constructor(e){this.fns=[];this.addFn=(e,r=!1)=>{an(e)&&(this.fns.push(e),r&&this.updateFn())};this.removeFn=(e,r=!1)=>{this.fns=this.fns.filter(n=>n!==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=()=>{this.raf&&(cancelAnimationFrame(this.raf),this.raf=void 0)};e&&(this.fn=e,this.addFn(e))}release(){this.cancelAnimation(),this.fn=void 0,this.fns=[]}};import{ValueSubject as gp}from"@vkontakte/videoplayer-shared";var gt=class{constructor(e){this.loaders={chapterLoaders:e?.chapterLoaders??[],manifestLoaders:e?.manifestLoaders??[]}}async exec(e,r){return ep(...this.loaders[e])(r)}};function ep(...t){return async function(r){let n=[...t];for(;n.length>0;)r=await n.shift()(r);return r}}function $e(t,e,r){return t?{...t,[e]:t[e]?[r,...t[e]]:[r]}:{[e]:[r]}}function Et({actions:t,errors:e,chapterId:r,...n}){if(r){let i=t.getManifest();if(i){let o=t.getChapter(i.chapters,r);if(o){let l=t.getMedia(i.media,o.videoId),s=t.getGraph(i.graph,o.id);return l?{...n,actions:t,errors:e,result:{chapter:o,media:l,graph:s}}:{...n,errors:$e(e,Et.name,"Could not find media"),actions:t}}}}return{...n,errors:$e(e,Et.name,"Could not find chapter"),actions:t}}var xt=class{constructor(){Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}addEventListener(e,r,n){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:r,options:n})}removeEventListener(e,r){if(!(e in this.listeners))return;let n=this.listeners[e];for(let i=0,o=n.length;i<o;i++)if(n[i].callback===r){n.splice(i,1);return}}dispatchEvent(e){if(!(e.type in this.listeners))return;let n=this.listeners[e.type].slice();for(let i=0,o=n.length;i<o;i++){let l=n[i];try{l.callback.call(this,e)}catch(s){Promise.resolve().then(()=>{throw s})}l.options&&l.options.once&&this.removeEventListener(e.type,l.callback)}return!e.defaultPrevented}},de=class extends xt{constructor(){super(),this.listeners||xt.call(this),Object.defineProperty(this,"aborted",{value:!1,writable:!0,configurable:!0}),Object.defineProperty(this,"onabort",{value:null,writable:!0,configurable:!0}),Object.defineProperty(this,"reason",{value:void 0,writable:!0,configurable:!0})}toString(){return"[object AbortSignal]"}dispatchEvent(e){e.type==="abort"&&(this.aborted=!0,typeof this.onabort=="function"&&this.onabort.call(this,e)),super.dispatchEvent(e)}},Le=class{constructor(){Object.defineProperty(this,"signal",{value:new de,writable:!0,configurable:!0})}abort(e){let r;try{r=new Event("abort")}catch{typeof document<"u"?document.createEvent?(r=document.createEvent("Event"),r.initEvent("abort",!1,!1)):(r=document.createEventObject(),r.type="abort"):r={type:"abort",bubbles:!1,cancelable:!1}}let n=e;if(n===void 0)if(typeof document>"u")n=new Error("This operation was aborted"),n.name="AbortError";else try{n=new DOMException("signal is aborted without reason")}catch{n=new Error("This operation was aborted"),n.name="AbortError"}this.signal.reason=n,this.signal.dispatchEvent(r)}toString(){return"[object AbortController]"}};typeof Symbol<"u"&&Symbol.toStringTag&&(Le.prototype[Symbol.toStringTag]="AbortController",de.prototype[Symbol.toStringTag]="AbortSignal");function It(t){return t.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill"),!0):typeof t.Request=="function"&&!t.Request.prototype.hasOwnProperty("signal")||!t.AbortController}function Tr(t){typeof t=="function"&&(t={fetch:t});let{fetch:e,Request:r=e.Request,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:i=!1}=t;if(!It({fetch:e,Request:r,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:i}))return{fetch:e,Request:o};let o=r;(o&&!o.prototype.hasOwnProperty("signal")||i)&&(o=function(c,d){let m;d&&d.signal&&(m=d.signal,delete d.signal);let f=new r(c,d);return m&&Object.defineProperty(f,"signal",{writable:!1,enumerable:!1,configurable:!0,value:m}),f},o.prototype=r.prototype);let l=e;return{fetch:(a,c)=>{let d=o&&o.prototype.isPrototypeOf(a)?a.signal:c?c.signal:void 0;if(d){let m;try{m=new DOMException("Aborted","AbortError")}catch{m=new Error("Aborted"),m.name="AbortError"}if(d.aborted)return Promise.reject(m);let f=new Promise((y,k)=>{d.addEventListener("abort",()=>k(m),{once:!0})});return c&&c.signal&&delete c.signal,Promise.race([f,l(a,c)])}return l(a,c)},Request:o}}var Ne=It({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),xo=Ne?Tr({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,Sr=Ne?xo.fetch:window.fetch,uf=Ne?xo.Request:window.Request,hf=Ne?Le:window.AbortController,df=Ne?de:window.AbortSignal;var Ar=(t="",e="")=>{let r=t.split("."),n=e.split("."),i=0;for(let o=0;o<Math.max(r.length,n.length)&&!i;o++)r[o]>n[o]?i=1:r[o]<n[o]?i=-1:i=0;return i};var tp=async t=>{try{let e={},r;if(Ye(t)){r=new URL(t).href;let i=await Sr(r);if(!i.ok)return{};e=await i.json()}else if(J(t))e=t;else return{};if(!Co(e))return{};let n=e.metadata.media;if(Ye(n)&&!("media"in e))try{let i;r?i=new URL(n,r).href:(i=new URL(n).href,r=i);let o=await Sr(i);if(!o.ok)throw new Error;e.metadata.media=await o.json()}catch{return ip(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:r}}catch{return{}}};async function Io(t){let{manifest:e,manifestURL:r}=await tp(t);if(!e)throw new Error("Failed on fetch");let n=Eo(e);return n.media=rp(n.media,r),delete n.metadata.media,n}function Tt(t,e){if(e)return t.find(r=>r.id===e)}function wr(t,e){return t.edit?.chapters?t.edit.chapters.find(r=>r.id===e):t.view?.chapters?t.view.chapters.find(r=>r.id===e):void 0}function Rr(t,e){return t.videos.find(r=>r.id===e)}function rp(t,e){return{...t,videos:t.videos.map(r=>({...r,variants:r.variants.map(n=>{let i="url"in n?n.url:"",o=np(i,e);return{...n,url:o||i}})}))}}function np(t="",e){try{return new URL(t,e).href}catch{return""}}function ip(t){return Ar(t,"3.2.0")>=0}var $o=z(Fe(),1);var St=t=>Ze(t)&&!Bt(t),Q=t=>t.order==="end",At=t=>Ze(t.containers)&&!Bt(t.containers)&&Q(t),Lo=(t,e)=>{let r=t*1e3;return St(e.controls)&&r<(e.startTime??0)},kr=(t,e)=>{let r=t*1e3;return St(e.controls)&&r>=(e.startTime??0)&&r<=(e.endTime??1/0)};var ne=(t=[])=>t.some(e=>e.action.type==="expect"),Pr=(t=[])=>t.find(e=>e.action.type==="expect"),Cp=t=>t?.length===1,me=t=>Cp(t)&&ft(t[0]);function No(t=[],e=1/0,r=[]){return t.filter(({container:n})=>!(0,$o.default)(r,n.container.id)&&ne(n.container.events)&&n.container.endTime===e&&!n.isRemoved)}function wt({gameControllers:t=[],subjectName:e,subjectId:r,execFn:n}){for(let i of t)if(e==="container"&&i.container.container.id===r){n(i),No(t,i.container.container.endTime,[i.container.container.id]).forEach(l=>{n(l)});break}}var Fo=(t,e)=>{let r=A=>e.find(({container:x})=>x.container.id===A)?.container.isRemoved,n=ne(t.events)&&!r(t.id),i=(A,g=!1,x=!1)=>{let h=x?"every":"some";return A.controls[h](p=>{let v=g?A.endTime===t.endTime:!0;return p.events?.[h](C=>C.action?.type===go.openURI)&&v})},o=A=>A.some(({container:g})=>i(g.container,!0,!1)&&!g.isRemoved),l=A=>A.every(({container:g})=>g.isRemoved?!0:i(g.container,!0,!0)),s=No(e,t.endTime,[t.id]).length,a=A=>A.controls.some(g=>g.events?.some(x=>x.action?.args?.shouldOpenNow)),c=n||s>0,d=o(e),m=i(t),f=l(e),y=n?!1:s>0,k=a(t);return{isExpectTime:c,hasOtherExpect:s>0,hasOpenURIEvent:d,hasOpenURIEventInCurrentContainer:m,isAllOpenURIEventsValid:f,isExpectEventForCurrentContainer:y,hasShouldOpenNowEvent:k}};var fe=class extends gt{constructor(r,n){super(r);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new gp(null);this.onError=n,this.release()}release(){return this.manifest=null,this.chapter=null,this.media=null,this.graph=null,this.prevChapter$.next(null),this}async setManifest(r){this.release();let n=await this.exec("manifestLoaders",{actions:{addErrorMessage:$e},result:null,errors:null,source:r});return n.errors&&this.errorHandler(n.errors),this.manifest=await Io(n.result??r),this}async setInitial(){return this.setNext()}async setNext(r=this.manifest?.metadata.initChapterId){if(!r)return this;this.prevChapter$.next(this.chapter);let n=await this.exec("chapterLoaders",Et({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:wr,getChapter:Tt,getMedia:Rr,getByBranches:this.getByBranches.bind(this),addErrorMessage:$e},result:null,errors:null,chapterId:r}));return n.errors&&this.errorHandler(n.errors),n.result&&(this.chapter=n.result.chapter,this.media=n.result.media,this.graph=n.result.graph),this}errorHandler(r){this.onError(r),console.error("Something went wrong with loaders",{errors:r})}getInitial(){return this.getByChapterId(this.manifest?.metadata.initChapterId)||null}getByChapterId(r=this.manifest?.metadata.initChapterId){if(!r||!this.manifest)return null;let n=Tt(this.manifest.chapters,r);if(n){let i=Rr(this.manifest.media,n.videoId),o=wr(this.manifest.graph,n.id);if(i)return{chapter:n,media:i,graph:o}}return null}getBranches(r=this.chapter?.id){if(r===this.chapter?.id)return this.getByBranches(this.chapter?.branches);{let n=Tt(this.manifest?.chapters||[],r);return this.getByBranches(n?.branches)}}getByBranches(r=[]){return r.reduce((n,i)=>{let o=this.getByChapterId(i.chapterId);return o&&n.push(o),n},[])}getCurrent(){return{chapter:this.chapter,media:this.media,graph:this.graph}}isInitialChapter(){return this.chapter?.id===this.manifest?.metadata.initChapterId}isEndChapter(){return this.chapter?Q(this.chapter):!1}};var fs=z(Rt(),1);import{Player as Kp}from"@vkontakte/videoplayer-core";import{Subscription as Nr,Tracer as Qp,ValueSubject as Xp}from"@vkontakte/videoplayer-shared";var ds=t=>{let e=t.variants.find(r=>r.payload?.type==="vk");if(e&&e.payload){let[r,n]=e.payload.id.split("_");return[r,n]}return[]};var ms=z(Rt(),1);function $r(){let t=new Map;function e({listId:o=Math.random().toString(),itemId:l=Math.random().toString(),...s}){let a=t.get(o),c={...s};return a?a[l]=c:t.set(o,{[l]:c}),{listId:o,itemId:l,...s}}function r(o){o.player.destroy(),o.container.remove(),o.subscription.unsubscribe(),o.statistics?.oneStat.destroy(),o.statistics?.statSubscription.unsubscribe()}function n(o,l){let s=t.get(o);if(!s)throw Error("Can't remove. Not find.");if(l){let a=s[l];a&&r(a),delete s[l],Object.keys(s).length||t.delete(o)}else{for(let a of(0,ms.default)(s))r(a);t.delete(o)}}function i(){for(let o of t)n(o[0])}return{createPlayer:e,removePlayer:n,map:t,removeAll:i}}var ve=z(Fe(),1);function Lr(t,e=[]){let r={},n,i=!e.length;for(let o of t.variants)if(!n&&"cover"in o&&(n=o.cover),"url"in o)switch(o.type.toLowerCase()){case"mp4":(i||(0,ve.default)(e,"mp4"))&&(r.MPEG={...r.MPEG,[o.standard??"Invariant quality"]:o.url});break;case"mpeg":(i||(0,ve.default)(e,"mpeg"))&&(r.MPEG={...r.MPEG,[o.standard??"Invariant quality"]:o.url});break;case"hls":(i||(0,ve.default)(e,"hls"))&&(r={...r,HLS:{type:"url",url:o.url}});break;case"dash":(i||(0,ve.default)(e,"dash"))&&(r={...r,DASH_SEP:{compatibilityMode:!0,type:"url",url:o.url}});break;default:break}return{sources:r,thumbUrl:n,title:t.title??""}}var je=(t,e)=>{let r=t.info.currentQuality$.getValue(),n=t.info.availableQualities$.getValue();r!==e&&(0,ve.default)(n,e)&&(t.setQuality(e),t.setAutoQuality(!1))};var Yp=2;function Fr(t){let e=$r(),r=new Nr,n={},i=null,o=!1,l,s=new Xp(null);t&&a(t);function a(g){i=g}function c(g,x,h){if(!i)throw Error("need to set interactive controller");if(!i.options)return;let v=(e.map.get(g)??{})[x];if(v){n={chapterId:h,listId:g,itemId:x,...v};let C=n.player;n.subscription.add(C.info.currentQuality$.subscribe(E=>{let I=C.info.position$.getValue(),O=C.info.isAutoQualityEnabled$.getValue();if(!(!E||!I||O))for(let M of e.map)(0,fs.default)(M[1]).forEach(({player:S})=>{je(S,E)})})).add(C.events.started$.subscribe(()=>{d(x)})),v.container.remove(),i.setPlayer(v.player),o||(i.init(),o=!0),s.next({player:n.player,config:n.config,statistics:n.statistics});return}throw Error("Can't set. Not find.")}async function d(g){if(!i)throw Error("need to set interactive controller");if(te(n)||g!==n.itemId)return;let x=i.getChapterBranches(),h=new Set;for(let p of x)h.has(p.media.id)||(await f({media:p.media,chapterId:p.chapter.id,setAsActive:!1,title:p.chapter.label}),h.add(p.media.id))}async function m({chapter:{id:g},manifestVideo:x}){if(te(n)||!i)return;let h=n.player.info.muted$.getValue(),p=n.player.info.currentQuality$.getValue(),v=n.player.info.isAutoQualityEnabled$.getValue(),C=n.player.info.volume$.getValue(),E=n.player.info.currentPlaybackRate$.getValue(),I=!v,O=!1;for(let M of e.map)if(M[0]===x.id&&!i.state.isReplay$.getValue()){let S=Object.keys(M[1]);for(let N of S)N===n.itemId?(S.length<Yp||(O=!0),e.removePlayer(M[0],N)):(O=!0,c(M[0],N,g),I?je(n.player,p):n.player.setAutoQuality(!0),n.player.setVolume(C),n.player.setMuted(h),n.player.setPlaybackRate(E))}else e.removePlayer(M[0]);O||(await f({media:x,chapterId:g,setAsActive:!0,playbackRate:E}),I?je(n.player,p):n.player.setAutoQuality(!0),n.player.setVolume(C),n.player.setMuted(h))}async function f({media:g,chapterId:x,prefetch:h=!0,setAsActive:p=!0,autoplay:v=!1,preferredExt:C,title:E,playbackRate:I}){let O=Math.random().toString(),M=document.createElement("div");l.append(M);let S;if(i?.options?.vkVideoLoader){let ze=ds(g);ze.length&&(S=await i.options.vkVideoLoader(...ze))}let N=i?.options?.coreConfig||void 0,q={...N,configName:[...N?.configName??[],"interactive"]},D={container:M,...S?.videos?.[0]||{sources:Lr(g,C).sources},title:E,failoverHosts:S?.failoverHosts||[]},H=new Kp(q,Qp.createRootTracer());H.initVideo(D);let X=null;if(S?.videos&&i?.options.createOneStat){let ze=S.videos[0],Nt=i.options.createOneStat(ze),Xr=new Nr;Nt&&(Xr.add(Nt.attachTo(H)),X={oneStat:Nt,statSubscription:Xr})}let ie=new Nr,Aa=n?.player?.info.isAutoQualityEnabled$.getValue();ie.add(H.events.canplay$.subscribe(function(){Aa||je(H,n.player.info.currentQuality$.getValue()),I&&H.setPlaybackRate(I)}));let oe=e.createPlayer({listId:g.id,itemId:O,player:H,container:M,sources:Lr(g,C).sources,config:D,subscription:ie,statistics:X});return p&&c(g.id,oe.itemId,x),v&&oe.player.play(),h&&!v&&oe.player.prepare(),{player:oe.player,config:oe.config,statistics:oe.statistics}}function y(){k(),i=null,l.remove()}function k(){r.unsubscribe(),e.removeAll(),n={},o=!1}async function A(){if(!i)throw Error("need to set interactive controller");k(),l=document.createElement("div");let{media:g,chapter:x}=i.getCurrentChapter();g&&x?(r.add(i.events.chapterChanged$.subscribe(m)),await f({media:g,chapterId:x.id,title:x.label})):console.error("not found")}return{...e,init:A,setInteractiveController:a,createPlayer:f,removeAll:y,getActivePlayer:function(){return n},activePlayerChanged:s}}var T={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},_e={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},P={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};var ys=z(Fe(),1);import{Subscription as Zp}from"@vkontakte/videoplayer-shared";function jr(t){return function(...r){return t(...r.reverse())}}function Be(t,...e){return(...r)=>J(e[0])&&J(r[0])?t({...e[0],...r[0]}):t(...e,...r)}var Ot=class{constructor({player:e,container:r,branches:n,selectBranches:i,interactiveEvents:o,globalEvents:l,globalEventEmitter:s,getContainerEventState:a,permanentTextControls:c,interactiveTimeOpenUri:d,disabledControls$:m,onRemove:f}){this.hide=()=>{setTimeout(()=>{this.gameState!==4&&(ne(this.container.container.events)&&this.gameState===3||this.selectBranches.state.isExpect||(this.gameState!==2&&this.container.hide?.(),this.emitContainerVisibilityEvent(!1)))})};this.show=()=>{if(this.gameState!==2||this.isSelectedControlEvent)return;if(this.container.getElement()){let{hasOpenURIEventInCurrentContainer:r}=this.getContainerEventState();if(this.container.show?.(),this.interactiveTimeOpenUri&&r)return;this.emitContainerVisibilityEvent(!0,!1)}else{let r={isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.emitContainerVisibilityEvent(!1)},onEvent:(i,o)=>{let{isExpectTime:l,hasOtherExpect:s,hasOpenURIEvent:a,hasOpenURIEventInCurrentContainer:c,isAllOpenURIEventsValid:d,hasShouldOpenNowEvent:m}=this.getContainerEventState(),f=this.interactiveTimeOpenUri&&!c,y=this.interactiveTimeOpenUri&&c;if((!this.interactiveTimeOpenUri||f)&&(this.isSelectedControlEvent=!0),i!==!1){if(!this.selectBranches.state.isExpect&&(!this.interactiveTimeOpenUri||f)){if(this.interactiveTimeOpenUri){let k=!s&&!d&&c;k&&this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:k})}this.removeView()}this.emitContainerVisibilityEvent(!1)}if(this.gameState===4||this.gameState===3||this.selectBranches.state.isExpect||this.interactiveTimeOpenUri&&a&&this.gameState!==5){if(y){let A=((g,x,h,p)=>!g&&!x&&h||g&&!x&&h&&!p||g&&!x&&h&&p)(l,s,d,this.isSelectedContainerEvent);this.fakeRemoveView(A)}else this.removeView(),this.emitContainerVisibilityEvent(!1);(!l||!s||!m)&&(this.selectBranches.stopExpect(),o())}},isEOV:()=>this.gameState===4},n=Be(this.selectBranches.onControlEvent,r);this.container.createView({eventCallback:n}),this.emitContainerVisibilityEvent(!0,!0),this.disabledControls$.getValue()&&this.container.disable?.()}};this.onEndOfVideo=()=>{this.gameState=4,this.selectContainerEvent(!0)};this.whilePlaying=()=>{let e=this.player.experimental.element$.getValue(),n=e instanceof HTMLVideoElement?e.readyState:void 0,i=[6,5];if(!n||(0,ys.default)(i,this.gameState)&&!this.isPermanentText)return;let o=this.player.getExactTime();if(Lo(o,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(kr(o,this.container.container))this.gameState!==2&&(this.gameState=2,this.onStartTime());else if(this.gameState!==3){let c=this.gameState;this.gameState=3,c===2&&this.onEndTime()}else{let{hasOpenURIEventInCurrentContainer:c}=this.getContainerEventState(),d=this.selectBranches.state.isExpect,m=this.interactiveTimeOpenUri&&c;if(m&&!d){let f=this.container.getElement();f&&(f.style.visibility!=="hidden"&&this.container.hide?.(),this.container.isRemoved||this.fakeRemoveView())}!this.isPermanentText&&!m&&this.removeView()}let l=kr(o,this.container.container),s=this.container.container.startTime?[this.container.container.startTime,this.container.container.endTime??1/0]:[],a={subjectId:this.container.container.id,subjectName:"container",range:s,currentTime:o,isInteractiveTime:l};this.container.onProgress(o*1e3,l),this.globalEventEmitter.emit(T.eachTick,a),this.globalEvents.eachTick$.next(a)};this.container=r,this.branches=n,this.selectBranches=i,this.subscription=new Zp,this.player=e,this.interactiveEvents=o,this.getContainerEventState=a,this.isPermanentText=c&&me(r.container.controls),this.interactiveTimeOpenUri=d,this.disabledControls$=m,this.onRemove=f,this.globalEventEmitter=s,this.gameState=0,this.globalEvents=l,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}emitContainerVisibilityEvent(e,r=!1){e?(this.globalEventEmitter.emit(T.interactives,{subjectId:this.container.container.id,subjectName:"container",type:P.visibility,visibility:e,isFirst:r}),this.globalEvents.interactiveVisibilityChanged$.next({subjectId:this.container.container.id,subjectName:"container",type:"visibility",visibility:e,isFirst:r})):(this.globalEventEmitter.emit(T.interactives,{subjectId:this.container.container.id,subjectName:"container",type:P.visibility,visibility:!1}),this.globalEvents.interactiveVisibilityChanged$.next({subjectId:this.container.container.id,subjectName:"container",type:"visibility",visibility:e}))}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=>{e?this.container.disable?.():this.container.enable?.()}))}selectContainerEvent(e=!1){let{isExpectEventForCurrentContainer:r}=this.getContainerEventState();this.interactiveEvents.containersEventsCallState.setCalled({timestamp:e?1/0:this.container.container.endTime??1/0,id:this.container.container.id}),!(this.isSelectedControlEvent||this.isSelectedContainerEvent)&&(this.isSelectedContainerEvent=!0,!r&&!this.container.isRemoved&&this.selectBranches.setManifestContainerEvents({container:this.container.container,branches:this.branches,isEOV:e}),!e&&this.interactiveEvents.exec(this.container.container.endTime??1/0))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);let{isExpectTime:e,hasOpenURIEventInCurrentContainer:r}=this.getContainerEventState(),n=this.interactiveTimeOpenUri?e||r:ne(this.container.container.events)||e;(this.isSelectedControlEvent||!n)&&this.removeView()}onBeforeStartTime(){this.container.hide?.(),this.emitContainerVisibilityEvent(!1)}onResize(e){this.container.onResize(e)}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=1}removeView(){this.container.removeView(),this.globalEventEmitter.emit(T.interactives,{subjectId:this.container.container.id,subjectName:"container",type:P.containerRemoved,visibility:!1}),this.globalEvents.interactiveContainerRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-removed"}),this.gameState=5,this.onRemove?.()}fakeRemoveView(e=!1){this.container.isRemoved||this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:e}),this.container.fakeRemove()}updateControlsShadowStyles(e){this.container.updateControlsShadowStyles(e)}toggleBlinkAnimation(e){this.container.toggleBlinkAnimation(e)}destroy(){this.reset(),this.removeView(),this.gameState=6,this.subscription.unsubscribe(),this.branches=[],this.interactiveEvents.containersEventsCallState.setCalled({timestamp:this.container.container.endTime??1/0,id:this.container.container.id})}};var bs=(t=[])=>t.reduce((e,r,n)=>{let i=(r?.controls??[]).filter(o=>!ft(o));if(St(i)){let o=[r.startTime??0,r.endTime??1/0],l={id:r.id,isRemoved:!1};if(!n)e.push({subjects:[l],range:o});else{let s=[],a=-1/0,c=1/0,d=[],m=[];for(let f=0;f<e.length;f++){let y=e[f];if(m.push(...y.subjects),y.range[0]<c&&(c=y.range[0]),y.range[1]>a&&(a=y.range[1]),o[0]>=y.range[0]&&o[1]<=y.range[1])return e[f].subjects.push(l),e;o[0]<y.range[0]&&o[1]>y.range[0]&&(s.push(f),d=d.concat(y.subjects)),o[0]>=y.range[0]&&o[0]<=y.range[1]&&(s.push(f),d=d.concat(y.subjects),o[0]=y.range[0]),o[1]>=y.range[0]&&o[1]<=y.range[1]&&(s.push(f),d=d.concat(y.subjects),o[1]=y.range[1])}if(m.push(l),o[0]<=c&&o[1]>=a)return[{subjects:m,range:o}];s.length&&s.reverse().forEach(f=>{e.splice(f,1)}),e.push({subjects:d.concat([l]),range:o})}}return e},[]).sort((e,r)=>e.range[0]-r.range[0]);var Js=z(Fe(),1),Dr=z(Rt(),1),ea=z(Ys(),1);function Zs(){let t={};function e(){for(let s in t)Object.prototype.hasOwnProperty.call(t,s)&&delete t[s]}function r(s){let a={};for(let c in t)+c<=s&&(a[c]=t[c]);return a}function n(s){let a={};for(let c in t)+c>=s&&(a[c]=t[c]);return a}function i({timestamp:s,priority:a,initiator:c}){if(_t(s)){let d=t[s]??null;if(d&&a&&Ce(a,!0)){let m={},f=d[a];return f&&(m={...m,...f}),m=te(m)?null:m,m&&Ce(c,!0)?m[c]??null:m}return d}return null}function o({timestamp:s,priority:a,initiator:c}){if(_t(s))if(t[s]){if(a&&Ce(a,!0))if(t[s][a]){if(c&&Ce(c,!0))if(t[s][a][c]){if(delete t[s][a][c],!te(t[s][a]))return!0}else return!1;if(delete t[s][a],!te(t[s]))return!0}else return!1;return delete t[s]}else return!1;return!1}function l({timestamp:s,priority:a,initiator:c,...d}){t[s]?.[a]?.[c]?t[s][a][c].push({...d}):t[s]?.[a]?t[s][a]={...t[s][a],[c]:[{...d}]}:t[s]?t[s]={...t[s],[a]:{[c]:[{...d}]}}:t[s]={[a]:{[c]:[{...d}]}}}return{map:t,remove:o,add:l,removeAll:e,get:i,getLte:r,getGte:n}}var Bu=[R.expect,R.setNextBranch],qu=1/0;function ta(t,e){let r=t,n,i=Du(e),o=Zs(),l,s=()=>{y(),h()},a=p=>{o.add.call(void 0,p),A()},c=(p=[])=>{for(let v of p)if(v.action(),(0,Js.default)(Bu,v.actionType))break},d=(p=1/0)=>{let v=Pt(o.get({timestamp:p,priority:"control"})??{}),C=Pt(o.get({timestamp:p,priority:"container"})??{}),E=Pt(o.get({timestamp:p,priority:"chapter"})??{});return[...v,...C,...E]},m=p=>{i.isReady(p)&&c(d(p))},f=()=>{c([...Pt(o.get({timestamp:1/0,priority:"chapter"})??{})])},y=()=>{n&&(l?.unsubscribe(),n=void 0)},k=p=>{},A=()=>{n||(n=()=>setTimeout(()=>{m(1/0)}),l=r.events.ended$.subscribe(n))},g=p=>{y(),r=p},x=p=>{p.priority==="container"&&i.resetCalled(p.timestamp),o.remove(p)},h=()=>{i.release(),o.removeAll()};return{setPlayer:g,add:a,remove:x,exec:m,execEndOfVideo:f,listen:A,unlisten:y,release:s,containersEventsCallState:i,getPreparedToExecActions:d}}function Du(t){let e=new Map;return{setCalled:({timestamp:s,id:a})=>{let c=e.get(s);c&&c[a]!==void 0&&(c[a]=!0)},setData:(s=[])=>{for(let a of s){let c=a.endTime??qu,d=e.get(c);e.set(c,{...d,[a.id]:!1})}},resetCalled:s=>{let a=e.get(s);if(a)for(let c in a)a[c]=!1},isReady:s=>{let a=e.get(s);if(!a)return!0;let c=(0,Dr.default)(a);return t?c.some(m=>m):!c.some(m=>!m)},release:()=>e.clear()}}function Pt(t){return(0,ea.default)((0,Dr.default)(t)).sort(e=>e.actionType===R.expect?-1:1)}var ra={videoContentHeight:0,videoContentWidth:0},na=t=>{let{height:e,width:r}=t.info.intrinsicVideoSize$.getValue()||{};if(!(e&&r))return ra;let{clientHeight:n,clientWidth:i}=t.experimental.element$.getValue()||{};if(!(n&&i))return ra;let o=e/r,l=n/i,s,a;return l>o?(a=i,s=i*o):l<o?(a=n/o,s=n):(a=i,s=n),{videoContentWidth:a,videoContentHeight:s}};var Hu=250;function ia(t){let e,r=new ResizeObserver(s=>{o(s),e=o.bind(null,s)});function n(s){let{parentElement:a,player:c}=t();if(a&&c){let{videoContentWidth:d,videoContentHeight:m}=na(c);a.style.setProperty("--interactive-content-width",`${d}px`),a.style.setProperty("--interactive-content-height",`${m}px`),a.style.setProperty("--interactive-width",`${s[0].contentRect.width}px`),a.style.setProperty("--interactive-height",`${s[0].contentRect.height}px`)}}function i(){let{parentElement:s}=t();s.removeAttribute("style")}let o=Pe(s=>{let{fns:a=[]}=t();n(s);for(let c of a)c()},Hu);function l(){e=void 0,r.disconnect(),i()}return{resizeObserver:r,calc:()=>{e?.()},release:l}}var Uu=t=>Math.floor(Math.random()*t),sa=t=>{let e=t.length,r=1/0,n=null;for(;e--;){let i=t[e],o=i.weight??1;o<r&&(r=o,n=i)}return n},aa=t=>{let e=t.length,r=-1/0,n=null;for(;e--;){let i=t[e],o=i.weight??0;o>r&&(r=o,n=i)}return n};var la=t=>{let e=t.length,r=Uu(e);return t[r]},oa=1,ca=t=>{let e=0;for(let n=0;n<t.length;++n)e+=t[n].weight??oa;let r=Math.random()*e;e=0;for(let n=0;n<t.length-1;++n)if(e+=t[n].weight??oa,e>=r)return t[n];return t[t.length-1]};var pa={shouldOpenNow:!0,isDetachContainer:!0},ua="after-expect";var Hr=(t,e=!1)=>({...t,args:e?{...t.args,...pa}:{...pa,...t.args}}),ma=({globalEventEmitter:t,globalEvents:e,player:r,interactiveEvents:n})=>{let i={isExpect:!1},o=()=>{i.isExpect&&(i.isExpect=!1)},l=({action:h,controlType:p,controlId:v,containerId:C,branches:E=[],onEvent:I,isEOV:O=()=>!1,isDisabled:M=()=>!1})=>{let S=Hr(h,O()),N={timestamp:1/0,priority:"control",initiator:v,actionType:S.type},q=M(),D=t.emit.bind(t,T.interactives,{subjectId:v,subjectType:p,subjectName:"control",type:q?P.actionChoiceCanceled:P.actionChoice,actionType:h.type,payload:{invokeImmediately:S.args.shouldOpenNow,containerId:C,...S.args}}),H=()=>{e.interactiveActionChoice$.next({subjectId:v,subjectType:p,subjectName:"control",type:q?"action-choice-canceled":"action-choice",actionType:h.type,payload:{invokeImmediately:S.args.shouldOpenNow,containerId:C,...S.args}})};if(q){D(),H();return}switch(S.type.trim().toLowerCase()){case R.setNextBranch.trim().toLowerCase():{let X=E.find(ie=>ie.id===S.args.branchId);if(!X)return;I(S.args.isDetachContainer,y.bind(null,{subjectId:v,subjectName:"control"})),D(),H(),S.args.shouldOpenNow?A({subjectId:v,subjectName:"control",subjectType:p,action:S,payload:{chapterId:X.chapterId,autoSelect:!1}}):n.add({...N,action:A.bind(null,{subjectId:v,subjectName:"control",subjectType:p,action:S,payload:{chapterId:X.chapterId,autoSelect:!1}})});return}case R.continuePlayback.trim().toLowerCase():{I(S.args.isDetachContainer,y.bind(null,{subjectId:v,subjectName:"control"})),D(),H(),S.args.shouldOpenNow?k({subjectId:v,subjectName:"control",subjectType:p,action:h}):n.add({...N,action:k.bind(null,{subjectId:v,subjectName:"control",subjectType:p,action:h})});return}case R.openURI.trim().toLowerCase():{I(S.args.isDetachContainer,y.bind(null,{subjectId:v,subjectName:"control"})),D(),H(),S.args.shouldOpenNow?x({subjectId:v,subjectName:"control",subjectType:p,action:S,payload:{URI:h.args.uri}}):n.add({...N,action:x.bind(null,{subjectId:v,subjectName:"control",subjectType:p,action:S,payload:{URI:h.args.uri}})});return}default:{let X="Unexpected control event",ie=new L(1,1,{message:X});d(ie,X);return}}},s=({action:h,container:{id:p,endTime:v},branches:C=[],isEOV:E=!1,autoSelected:I=!1})=>{let O=Hr(h,E),M={timestamp:!O.args.shouldOpenNow||E?1/0:v??1/0,priority:"container",initiator:p,actionType:O.type},S=t.emit.bind(t,T.interactives,{subjectId:p,subjectName:"container",type:P.actionChoice,actionType:O.type,payload:{invokeImmediately:O.args.shouldOpenNow,...O.args}}),N=()=>{e.interactiveActionChoice$.next({subjectId:p,subjectName:"container",type:"action-choice",actionType:O.type,payload:{invokeImmediately:O.args.shouldOpenNow,...O.args}})};switch(O.type.trim().toLowerCase()){case R.setNextBranch.trim().toLowerCase():{let q=C.find(D=>D.id===O.args.branchId);if(!q)return;S(),N(),n.add({...M,action:A.bind(null,{subjectId:p,subjectName:"container",action:O,payload:{chapterId:q.chapterId,autoSelect:I}})});return}case R.setMaxWeightBranch.trim().toLowerCase():return;case R.setMinWeightBranch.trim().toLowerCase():return;case R.setRandomBranch.trim().toLowerCase():return;case R.setWeightlessRandomBranch.trim().toLowerCase():return;case R.continuePlayback.trim().toLowerCase():{S(),N(),n.add({...M,action:k.bind(null,{subjectId:p,subjectName:"container",action:O})});return}case R.openURI.trim().toLowerCase():{S(),N(),n.add({...M,action:x.bind(null,{subjectId:p,subjectName:"container",action:O,payload:{URI:h.args.uri}})});return}default:{let q="Unexpected container event",D=new L(1,1,{message:q});d(D,q);return}}};function a({container:h,branches:p,isEOV:v=!1}){let C=Pr(h.events);if(C){let E=Hr(C.action,v);t.emit(T.interactives,{subjectId:h.id,subjectName:"container",type:P.actionChoice,actionType:E.type,payload:{invokeImmediately:E.args.shouldOpenNow,...E.args}}),e.interactiveActionChoice$.next({subjectId:h.id,subjectName:"container",type:"action-choice",actionType:E.type,payload:{invokeImmediately:E.args.shouldOpenNow,...E.args}}),n.add({timestamp:v?1/0:h.endTime??1/0,priority:"container",initiator:h.id,actionType:R.expect,action:f.bind(null,{subjectId:h.id,subjectName:"container"})}),i.isExpect=!0}else for(let E of h.events??[])s({action:E.action,container:h,branches:p,isEOV:v})}let c=({chapterId:h,action:p,branches:v=[]})=>{let C=t.emit.bind(t,T.interactives,{subjectId:h,subjectName:"chapter",type:P.actionChoice,actionType:p.type,payload:p.args}),E=()=>{e.interactiveActionChoice$.next({subjectId:h,subjectName:"chapter",type:"action-choice",actionType:p.type,payload:p.args})};switch(p.type.trim().toLowerCase()){case R.setNextBranch.trim().toLowerCase():{let I=v.find(O=>O.id===p.args.branchId);return I?.chapterId?(C(),E(),A.bind(null,{subjectId:h,subjectName:"chapter",action:p,payload:{chapterId:I.chapterId,autoSelect:!0}})):void 0}case R.setWeightlessRandomBranch.trim().toLowerCase():{let I=la(v);return I?.chapterId?(C(),E(),A.bind(null,{subjectId:h,subjectName:"chapter",action:p,payload:{chapterId:I.chapterId,autoSelect:!0}})):void 0}case R.setRandomBranch.trim().toLowerCase():{let I=ca(v);return I?.chapterId?(C(),E(),A.bind(null,{subjectId:h,subjectName:"chapter",action:p,payload:{chapterId:I.chapterId,autoSelect:!0}})):void 0}case R.setMaxWeightBranch.trim().toLowerCase():{let I=aa(v);return I?.chapterId?(C(),E(),A.bind(null,{subjectId:h,subjectName:"chapter",action:p,payload:{chapterId:I.chapterId,autoSelect:!0}})):void 0}case R.setMinWeightBranch.trim().toLowerCase():{let I=sa(v);return I?.chapterId?(C(),E(),A.bind(null,{subjectId:h,subjectName:"chapter",action:p,payload:{chapterId:I.chapterId,autoSelect:!0}})):void 0}case R.continuePlayback.trim().toLowerCase():return C(),E(),k.bind(null,{subjectId:h,subjectName:"chapter",action:p});case R.openURI.trim().toLowerCase():return C(),E(),x.bind(null,{subjectId:h,subjectName:"chapter",action:p,payload:{URI:p.args.uri}});default:{let I="Unexpected chapter event",O=new L(1,1,{message:I});d(O,I);return}}};function d(h,p){console.error(p),e.error$.next(h),t.emit(T.errors,h)}function m(h){let p=Pr(h.events);if(p){if(Q(h))return;t.emit(T.interactives,{subjectId:h.id,subjectName:"chapter",type:P.actionChoice,actionType:p.action.type,payload:p.action.args}),e.interactiveActionChoice$.next({subjectId:h.id,subjectName:"chapter",type:"action-choice",actionType:p.action.type,payload:p.action.args}),n.add({timestamp:1/0,priority:"chapter",initiator:h.id,actionType:R.expect,action:f.bind(null,{subjectId:h.id,subjectName:"chapter"})})}else h.events?.forEach(v=>{let C=c({chapterId:h.id,action:v.action,branches:h.branches});C&&n.add({timestamp:1/0,priority:"chapter",initiator:h.id,actionType:v.action.type,action:C})})}let f=({subjectId:h,subjectName:p})=>{r.pause(),t.emit(T.interactives,{subjectId:h,subjectName:p,type:P.actionExecution,actionType:R.expect}),e.interactiveActionExecution$.next({subjectId:h,subjectName:p,type:"action-execution",actionType:R.expect})},y=({subjectId:h,subjectName:p})=>{r.info.isEnded$.getValue()?n.execEndOfVideo():r.play(),t.emit(T.interactives,{subjectId:h,subjectName:p,type:P.actionExecution,actionType:ua}),e.interactiveActionExecution$.next({subjectId:h,subjectName:p,type:"action-execution",actionType:ua})},k=({subjectId:h,subjectName:p,subjectType:v,action:C})=>{t.emit(T.interactives,{subjectId:h,subjectName:p,subjectType:v,type:P.actionExecution,actionType:C.type}),e.interactiveActionExecution$.next({subjectId:h,subjectName:p,subjectType:v,type:"action-execution",actionType:C.type})},A=({subjectId:h,subjectName:p,subjectType:v,action:C,payload:E})=>{E.behaviour="change-chapter",t.emit(T.interactives,{subjectId:h,subjectName:p,subjectType:v,type:P.actionExecution,actionType:C.type,payload:E}),e.interactiveActionExecution$.next({subjectId:h,subjectName:p,subjectType:v,type:"action-execution",actionType:C.type,payload:E})},g=({subjectId:h,subjectName:p,subjectType:v,action:C,payload:E})=>{E.behaviour="change-manifest",t.emit(T.interactives,{subjectId:h,subjectName:p,subjectType:v,type:P.actionExecution,actionType:C.type,payload:E}),e.interactiveActionExecution$.next({subjectId:h,subjectName:p,subjectType:v,type:"action-execution",actionType:C.type,payload:E})},x=({subjectId:h,subjectName:p,subjectType:v,action:C,payload:E})=>{if(!E.URI)return;let I=window.open(E.URI,"_blank","noopener,noreferrer");I&&(I.opener=null),t.emit(T.interactives,{subjectId:h,subjectName:p,subjectType:v,type:P.actionExecution,actionType:C.type}),e.interactiveActionExecution$.next({subjectId:h,subjectName:p,subjectType:v,type:"action-execution",actionType:C.type})};return{onControlEvent:l,onContainerEvent:s,onChapterEvent:c,onExpectEvent:f,expectEventHandler:y,setManifestChapterEvents:m,setManifestContainerEvents:a,stopExpect:o,state:i}};var zr=z(Ir(),1);import{Subscription as Qu,Subject as Gr,ValueSubject as De}from"@vkontakte/videoplayer-shared";var Ur=(t,e)=>{let r={};return t.map(n=>{if(!r[n]){let i=e.chapters.find(l=>l.id===n);if(!i)return null;let o=e.media.videos.find(l=>i.videoId===l.id);if(!o)return null;r[n]=fa(o)}return r[n]}).filter(Boolean)},zu=t=>{for(let e of t.variants)if(Wu(e)&&e.payload)return e.payload.id},Wu=t=>!!(t.type==="custom"&&t.payload&&t.payload.type==="vk"),fa=t=>{let e=zu(t);if(!e)return null;let r=e.split("_").pop();return r?parseInt(r,10):null},Ku=(t,e)=>{for(let r of t.media.videos)if(e===fa(r)){for(let n of t.chapters)if(n.videoId===r.id)return n.id;return}},va=(t,e)=>t.reduce((r,n)=>{let i=Ku(e,n);return i?[...r,i]:r},[]);var He=class{constructor({globalEventEmitter:e,videoId:r,interactiveController:n,historyApi:i,settings:o}){this.state={history$:new De([]),hasPrevChapter$:new De(!1),prevChapter$:new De(null),isInitialChapter$:new De(!1),isGoBackLimited$:new De(!1)};this.#r=null;this.#s=!1;this.#e=null;this.#p=null;this.events={inited$:new Gr,destroyed$:new Gr,error$:new Gr};this.#n=null;this.#i=null;this.#t=null;this.#a=new Qu;this.#l=!1;this.#c=0;this.#n=r,this.#t=e,this.#i=n,this.#r=i,this.#o=o,this.state.history$&&this.#a&&this.#a?.add(this.state.history$.subscribe(l=>{this.state.prevChapter$.next((0,zr.default)(l,-2)||null),this.state.hasPrevChapter$.next(l.length>1),this.state.isInitialChapter$.next(this.getInitialChapterId()===this.#e?.metadata?.initChapterId),this.state.isGoBackLimited$.next(this.#c===this.#o.maxLength-1)}))}#r;#o;#s;#e;#p;#n;#i;#t;#a;#l;#c;async setManifest(e){if(!this.#i||!this.#t)return;this.#e=e,await this.getProjectHistory();let r=this.getInitialChapterId();await this.#i.setChapter({chapterId:r,pushToHistory:!1}),this.#s||(this.#s=!0,this.events.inited$.next({initChapterId:r}))}get inited(){return this.#s}async updateHistory(e,r=!0){if(!this.#e)return;this.#l?(this.#l=!1,this.#c++):this.#c=0;let n=this.#e,i=e.length-this.#o.maxLength,o=i>0?e.slice(i):e,l=Ur(o,n);if(this.#p=l,this.state.history$.next(o),!(!r||!this.#r||!this.#n))try{await this.#r.save(this.#n,l)}catch{let a=new L(1,5,"Unable to save interactive history");this.events.error$.next(a),this.#t?.emit(T.errors,a)}}async goBack(){if(!this.state||!this.#i){let n=new L(1,5,"Unable to save interactive history");return this.events.error$.next(n),this.#t?.emit(T.errors,n)}this.#l=!0;let e=this.state.history$.getValue().slice(0,-1),r=e.pop();this.state.history$.next(e),await this.#i.setChapter({chapterId:r,playPrev:!0})}async getProjectHistory(){if(!this.#e||!this.#n)return;let e=this.#e,r=[this.getInitialVideoId()];if(this.#r)try{let i=await this.#r.get(this.#n);i.length&&(r=i)}catch{let o=new L(1,5,"Error while trying to fetch data");this.events.error$.next(o),this.#t?.emit(T.errors,o)}let n=va(r,e);this.state.history$.next(n)}getInitialChapterId(){let e=this.state.history$.getValue();return(0,zr.default)(e,-1)||this.#o.initChapterId||this.#e?.metadata.initChapterId}getInitialVideoId(){if(this.#e){let e=this.getInitialChapterId();return Ur([e],this.#e).pop()}return null}destroy(){this.#n=null,this.#r=null,this.#i=null,this.#a?.unsubscribe(),this.#a=null,this.#s=!1,this.#t?.emit(T.historyDestroyed),this.events.destroyed$.next(),this.#t=null}};var Vt=class{constructor(){this._prevSizeId=0;this.rootElement=document.createElement("canvas")}clear(){this.rootElement.getContext("2d")?.clearRect(0,0,this.rootElement.width,this.rootElement.height)}isImageDrawn(){let e=this.rootElement.getContext("2d")?.getImageData(0,0,this.rootElement.width,this.rootElement.height);if(!e)return!1;let r=e.data,n=r.length;for(let i=3;i<n;i+=40)if(r[i]!==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(){this.canvasImgSrc&&this.rootElement.getContext("2d")?.drawImage(this.canvasImgSrc,0,0,this.rootElement.width,this.rootElement.height)}async updateCanvasDimensions(e,r=!1){let n=e.width+e.height;if(this._prevSizeId===n)return;let i;r&&(i=await this.save()),this.rootElement.width=e.width,this.rootElement.height=e.height,r&&i&&this.restore(i),this._prevSizeId=n}async save(){let e=this.rootElement.toDataURL("image/jpeg",1),r=new Image;return r.crossOrigin="anonymous",r.src=e,await r.decode(),r}restore(e){this.rootElement&&this.rootElement.getContext("2d")?.drawImage(e,0,0,this.rootElement.width,this.rootElement.height)}};var Mt=class{constructor({parentElement:e,endOffsetMs:r=250,onError:n}){this.currentVideoDurationMs=1/0;this._containerTimeFrameShouldReceived=!1;this._endTimeFrameReceived=!1;this._shouldCallSkip=!1;this.onEachTick=e=>{let r=e??this.lastFrameCanvas.canvasImgSrc.currentTime*1e3,n=this.isChapterEndTime(r);if(this.isContainerTime(r))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=`
|
|
6
|
+
var ca=Object.create;var qr=Object.defineProperty;var la=Object.getOwnPropertyDescriptor;var pa=Object.getOwnPropertyNames;var ua=Object.getPrototypeOf,ha=Object.prototype.hasOwnProperty;var u=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var da=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of pa(e))!ha.call(t,i)&&i!==r&&qr(t,i,{get:()=>e[i],enumerable:!(n=la(e,i))||n.enumerable});return t};var K=(t,e,r)=>(r=t!=null?ca(ua(t)):{},da(e||!t||!t.__esModule?qr(r,"default",{value:t,enumerable:!0}):r,t));var G=u(($t,Qr)=>{"use strict";var fe=function(t){return t&&t.Math===Math&&t};Qr.exports=fe(typeof globalThis=="object"&&globalThis)||fe(typeof window=="object"&&window)||fe(typeof self=="object"&&self)||fe(typeof global=="object"&&global)||fe(typeof $t=="object"&&$t)||function(){return this}()||Function("return this")()});var _=u((Vh,Xr)=>{"use strict";Xr.exports=function(t){try{return!!t()}catch{return!0}}});var ve=u((Mh,Yr)=>{"use strict";var ma=_();Yr.exports=!ma(function(){var t=function(){}.bind();return typeof t!="function"||t.hasOwnProperty("prototype")})});var rn=u((Nh,tn)=>{"use strict";var fa=ve(),en=Function.prototype,Zr=en.apply,Jr=en.call;tn.exports=typeof Reflect=="object"&&Reflect.apply||(fa?Jr.bind(Zr):function(){return Jr.apply(Zr,arguments)})});var H=u((jh,on)=>{"use strict";var nn=ve(),sn=Function.prototype,_t=sn.call,va=nn&&sn.bind.bind(_t,_t);on.exports=nn?va:function(t){return function(){return _t.apply(t,arguments)}}});var ye=u((Lh,cn)=>{"use strict";var an=H(),ya=an({}.toString),ba=an("".slice);cn.exports=function(t){return ba(ya(t),8,-1)}});var Ft=u(($h,ln)=>{"use strict";var Ca=ye(),ga=H();ln.exports=function(t){if(Ca(t)==="Function")return ga(t)}});var F=u((_h,pn)=>{"use strict";var qt=typeof document=="object"&&document.all;pn.exports=typeof qt>"u"&&qt!==void 0?function(t){return typeof t=="function"||t===qt}:function(t){return typeof t=="function"}});var Y=u((Fh,un)=>{"use strict";var Ea=_();un.exports=!Ea(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var Ye=u((qh,hn)=>{"use strict";var Ia=ve(),Xe=Function.prototype.call;hn.exports=Ia?Xe.bind(Xe):function(){return Xe.apply(Xe,arguments)}});var Bt=u(fn=>{"use strict";var dn={}.propertyIsEnumerable,mn=Object.getOwnPropertyDescriptor,Ta=mn&&!dn.call({1:2},1);fn.f=Ta?function(e){var r=mn(this,e);return!!r&&r.enumerable}:dn});var Dt=u((Dh,vn)=>{"use strict";vn.exports=function(t,e){return{enumerable:!(t&1),configurable:!(t&2),writable:!(t&4),value:e}}});var bn=u((Hh,yn)=>{"use strict";var xa=H(),Sa=_(),wa=ye(),Ht=Object,Aa=xa("".split);yn.exports=Sa(function(){return!Ht("z").propertyIsEnumerable(0)})?function(t){return wa(t)==="String"?Aa(t,""):Ht(t)}:Ht});var Ut=u((Uh,Cn)=>{"use strict";Cn.exports=function(t){return t==null}});var Gt=u((Gh,gn)=>{"use strict";var Ra=Ut(),Oa=TypeError;gn.exports=function(t){if(Ra(t))throw new Oa("Can't call method on "+t);return t}});var be=u((zh,En)=>{"use strict";var Pa=bn(),ka=Gt();En.exports=function(t){return Pa(ka(t))}});var oe=u((Wh,In)=>{"use strict";var Va=F();In.exports=function(t){return typeof t=="object"?t!==null:Va(t)}});var Ze=u((Kh,Tn)=>{"use strict";Tn.exports={}});var Je=u((Qh,Sn)=>{"use strict";var zt=Ze(),Wt=G(),Ma=F(),xn=function(t){return Ma(t)?t:void 0};Sn.exports=function(t,e){return arguments.length<2?xn(zt[t])||xn(Wt[t]):zt[t]&&zt[t][e]||Wt[t]&&Wt[t][e]}});var An=u((Xh,wn)=>{"use strict";var Na=H();wn.exports=Na({}.isPrototypeOf)});var kn=u((Yh,Pn)=>{"use strict";var ja=G(),Rn=ja.navigator,On=Rn&&Rn.userAgent;Pn.exports=On?String(On):""});var _n=u((Zh,$n)=>{"use strict";var Ln=G(),Kt=kn(),Vn=Ln.process,Mn=Ln.Deno,Nn=Vn&&Vn.versions||Mn&&Mn.version,jn=Nn&&Nn.v8,U,et;jn&&(U=jn.split("."),et=U[0]>0&&U[0]<4?1:+(U[0]+U[1]));!et&&Kt&&(U=Kt.match(/Edge\/(\d+)/),(!U||U[1]>=74)&&(U=Kt.match(/Chrome\/(\d+)/),U&&(et=+U[1])));$n.exports=et});var Qt=u((Jh,qn)=>{"use strict";var Fn=_n(),La=_(),$a=G(),_a=$a.String;qn.exports=!!Object.getOwnPropertySymbols&&!La(function(){var t=Symbol("symbol detection");return!_a(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&Fn&&Fn<41})});var Xt=u((ed,Bn)=>{"use strict";var Fa=Qt();Bn.exports=Fa&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var Yt=u((td,Dn)=>{"use strict";var qa=Je(),Ba=F(),Da=An(),Ha=Xt(),Ua=Object;Dn.exports=Ha?function(t){return typeof t=="symbol"}:function(t){var e=qa("Symbol");return Ba(e)&&Da(e.prototype,Ua(t))}});var Un=u((rd,Hn)=>{"use strict";var Ga=String;Hn.exports=function(t){try{return Ga(t)}catch{return"Object"}}});var Zt=u((nd,Gn)=>{"use strict";var za=F(),Wa=Un(),Ka=TypeError;Gn.exports=function(t){if(za(t))return t;throw new Ka(Wa(t)+" is not a function")}});var Wn=u((id,zn)=>{"use strict";var Qa=Zt(),Xa=Ut();zn.exports=function(t,e){var r=t[e];return Xa(r)?void 0:Qa(r)}});var Qn=u((sd,Kn)=>{"use strict";var Jt=Ye(),er=F(),tr=oe(),Ya=TypeError;Kn.exports=function(t,e){var r,n;if(e==="string"&&er(r=t.toString)&&!tr(n=Jt(r,t))||er(r=t.valueOf)&&!tr(n=Jt(r,t))||e!=="string"&&er(r=t.toString)&&!tr(n=Jt(r,t)))return n;throw new Ya("Can't convert object to primitive value")}});var Yn=u((od,Xn)=>{"use strict";Xn.exports=!0});var ei=u((ad,Jn)=>{"use strict";var Zn=G(),Za=Object.defineProperty;Jn.exports=function(t,e){try{Za(Zn,t,{value:e,configurable:!0,writable:!0})}catch{Zn[t]=e}return e}});var tt=u((cd,ni)=>{"use strict";var Ja=Yn(),ec=G(),tc=ei(),ti="__core-js_shared__",ri=ni.exports=ec[ti]||tc(ti,{});(ri.versions||(ri.versions=[])).push({version:"3.38.0",mode:Ja?"pure":"global",copyright:"\xA9 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.38.0/LICENSE",source:"https://github.com/zloirock/core-js"})});var rr=u((ld,si)=>{"use strict";var ii=tt();si.exports=function(t,e){return ii[t]||(ii[t]=e||{})}});var Ce=u((pd,oi)=>{"use strict";var rc=Gt(),nc=Object;oi.exports=function(t){return nc(rc(t))}});var ae=u((ud,ai)=>{"use strict";var ic=H(),sc=Ce(),oc=ic({}.hasOwnProperty);ai.exports=Object.hasOwn||function(e,r){return oc(sc(e),r)}});var nr=u((hd,ci)=>{"use strict";var ac=H(),cc=0,lc=Math.random(),pc=ac(1 .toString);ci.exports=function(t){return"Symbol("+(t===void 0?"":t)+")_"+pc(++cc+lc,36)}});var ge=u((dd,pi)=>{"use strict";var uc=G(),hc=rr(),li=ae(),dc=nr(),mc=Qt(),fc=Xt(),ce=uc.Symbol,ir=hc("wks"),vc=fc?ce.for||ce:ce&&ce.withoutSetter||dc;pi.exports=function(t){return li(ir,t)||(ir[t]=mc&&li(ce,t)?ce[t]:vc("Symbol."+t)),ir[t]}});var mi=u((md,di)=>{"use strict";var yc=Ye(),ui=oe(),hi=Yt(),bc=Wn(),Cc=Qn(),gc=ge(),Ec=TypeError,Ic=gc("toPrimitive");di.exports=function(t,e){if(!ui(t)||hi(t))return t;var r=bc(t,Ic),n;if(r){if(e===void 0&&(e="default"),n=yc(r,t,e),!ui(n)||hi(n))return n;throw new Ec("Can't convert object to primitive value")}return e===void 0&&(e="number"),Cc(t,e)}});var sr=u((fd,fi)=>{"use strict";var Tc=mi(),xc=Yt();fi.exports=function(t){var e=Tc(t,"string");return xc(e)?e:e+""}});var bi=u((vd,yi)=>{"use strict";var Sc=G(),vi=oe(),or=Sc.document,wc=vi(or)&&vi(or.createElement);yi.exports=function(t){return wc?or.createElement(t):{}}});var ar=u((yd,Ci)=>{"use strict";var Ac=Y(),Rc=_(),Oc=bi();Ci.exports=!Ac&&!Rc(function(){return Object.defineProperty(Oc("div"),"a",{get:function(){return 7}}).a!==7})});var Ii=u(Ei=>{"use strict";var Pc=Y(),kc=Ye(),Vc=Bt(),Mc=Dt(),Nc=be(),jc=sr(),Lc=ae(),$c=ar(),gi=Object.getOwnPropertyDescriptor;Ei.f=Pc?gi:function(e,r){if(e=Nc(e),r=jc(r),$c)try{return gi(e,r)}catch{}if(Lc(e,r))return Mc(!kc(Vc.f,e,r),e[r])}});var xi=u((Cd,Ti)=>{"use strict";var _c=_(),Fc=F(),qc=/#|\.prototype\./,Ee=function(t,e){var r=Dc[Bc(t)];return r===Uc?!0:r===Hc?!1:Fc(e)?_c(e):!!e},Bc=Ee.normalize=function(t){return String(t).replace(qc,".").toLowerCase()},Dc=Ee.data={},Hc=Ee.NATIVE="N",Uc=Ee.POLYFILL="P";Ti.exports=Ee});var cr=u((gd,wi)=>{"use strict";var Si=Ft(),Gc=Zt(),zc=ve(),Wc=Si(Si.bind);wi.exports=function(t,e){return Gc(t),e===void 0?t:zc?Wc(t,e):function(){return t.apply(e,arguments)}}});var Ri=u((Ed,Ai)=>{"use strict";var Kc=Y(),Qc=_();Ai.exports=Kc&&Qc(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var Pi=u((Id,Oi)=>{"use strict";var Xc=oe(),Yc=String,Zc=TypeError;Oi.exports=function(t){if(Xc(t))return t;throw new Zc(Yc(t)+" is not an object")}});var Mi=u(Vi=>{"use strict";var Jc=Y(),el=ar(),tl=Ri(),rt=Pi(),ki=sr(),rl=TypeError,lr=Object.defineProperty,nl=Object.getOwnPropertyDescriptor,pr="enumerable",ur="configurable",hr="writable";Vi.f=Jc?tl?function(e,r,n){if(rt(e),r=ki(r),rt(n),typeof e=="function"&&r==="prototype"&&"value"in n&&hr in n&&!n[hr]){var i=nl(e,r);i&&i[hr]&&(e[r]=n.value,n={configurable:ur in n?n[ur]:i[ur],enumerable:pr in n?n[pr]:i[pr],writable:!1})}return lr(e,r,n)}:lr:function(e,r,n){if(rt(e),r=ki(r),rt(n),el)try{return lr(e,r,n)}catch{}if("get"in n||"set"in n)throw new rl("Accessors not supported");return"value"in n&&(e[r]=n.value),e}});var ji=u((xd,Ni)=>{"use strict";var il=Y(),sl=Mi(),ol=Dt();Ni.exports=il?function(t,e,r){return sl.f(t,e,ol(1,r))}:function(t,e,r){return t[e]=r,t}});var Te=u((Sd,$i)=>{"use strict";var Ie=G(),al=rn(),cl=Ft(),ll=F(),pl=Ii().f,ul=xi(),le=Ze(),hl=cr(),pe=ji(),Li=ae();tt();var dl=function(t){var e=function(r,n,i){if(this instanceof e){switch(arguments.length){case 0:return new t;case 1:return new t(r);case 2:return new t(r,n)}return new t(r,n,i)}return al(t,this,arguments)};return e.prototype=t.prototype,e};$i.exports=function(t,e){var r=t.target,n=t.global,i=t.stat,s=t.proto,c=n?Ie:i?Ie[r]:Ie[r]&&Ie[r].prototype,o=n?le:le[r]||pe(le,r,{})[r],a=o.prototype,l,d,m,f,y,R,E,C,I;for(f in e)l=ul(n?f:r+(i?".":"#")+f,t.forced),d=!l&&c&&Li(c,f),R=o[f],d&&(t.dontCallGetSet?(I=pl(c,f),E=I&&I.value):E=c[f]),y=d&&E?E:e[f],!(!l&&!s&&typeof R==typeof y)&&(t.bind&&d?C=hl(y,Ie):t.wrap&&d?C=dl(y):s&&ll(y)?C=cl(y):C=y,(t.sham||y&&y.sham||R&&R.sham)&&pe(C,"sham",!0),pe(o,f,C),s&&(m=r+"Prototype",Li(le,m)||pe(le,m,{}),pe(le[m],f,y),t.real&&a&&(l||!a[f])&&pe(a,f,y)))}});var Fi=u((wd,_i)=>{"use strict";var ml=Math.ceil,fl=Math.floor;_i.exports=Math.trunc||function(e){var r=+e;return(r>0?fl:ml)(r)}});var xe=u((Ad,qi)=>{"use strict";var vl=Fi();qi.exports=function(t){var e=+t;return e!==e||e===0?0:vl(e)}});var Di=u((Rd,Bi)=>{"use strict";var yl=xe(),bl=Math.min;Bi.exports=function(t){var e=yl(t);return e>0?bl(e,9007199254740991):0}});var Se=u((Od,Hi)=>{"use strict";var Cl=Di();Hi.exports=function(t){return Cl(t.length)}});var nt=u((Pd,Ui)=>{"use strict";Ui.exports=function(){}});var Gi=u(()=>{"use strict";var gl=Te(),El=Ce(),Il=Se(),Tl=xe(),xl=nt();gl({target:"Array",proto:!0},{at:function(e){var r=El(this),n=Il(r),i=Tl(e),s=i>=0?i:n+i;return s<0||s>=n?void 0:r[s]}});xl("at")});var it=u((Md,zi)=>{"use strict";var Sl=Je();zi.exports=Sl});var Ki=u((Nd,Wi)=>{"use strict";Gi();var wl=it();Wi.exports=wl("Array","at")});var Xi=u((jd,Qi)=>{"use strict";var Al=Ki();Qi.exports=Al});var dr=u((Ld,Yi)=>{"use strict";var Rl=Xi();Yi.exports=Rl});var ds=u((Wm,hs)=>{"use strict";var _l=rr(),Fl=nr(),us=_l("keys");hs.exports=function(t){return us[t]||(us[t]=Fl(t))}});var fs=u((Km,ms)=>{"use strict";var ql=_();ms.exports=!ql(function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype})});var bs=u((Qm,ys)=>{"use strict";var Bl=ae(),Dl=F(),Hl=Ce(),Ul=ds(),Gl=fs(),vs=Ul("IE_PROTO"),Tr=Object,zl=Tr.prototype;ys.exports=Gl?Tr.getPrototypeOf:function(t){var e=Hl(t);if(Bl(e,vs))return e[vs];var r=e.constructor;return Dl(r)&&e instanceof r?r.prototype:e instanceof Tr?zl:null}});var gs=u((Xm,Cs)=>{"use strict";var Wl=xe(),Kl=Math.max,Ql=Math.min;Cs.exports=function(t,e){var r=Wl(t);return r<0?Kl(r+e,0):Ql(r,e)}});var xr=u((Ym,Is)=>{"use strict";var Xl=be(),Yl=gs(),Zl=Se(),Es=function(t){return function(e,r,n){var i=Xl(e),s=Zl(i);if(s===0)return!t&&-1;var c=Yl(n,s),o;if(t&&r!==r){for(;s>c;)if(o=i[c++],o!==o)return!0}else for(;s>c;c++)if((t||c in i)&&i[c]===r)return t||c||0;return!t&&-1}};Is.exports={includes:Es(!0),indexOf:Es(!1)}});var xs=u((Zm,Ts)=>{"use strict";Ts.exports={}});var As=u((Jm,ws)=>{"use strict";var Jl=H(),Sr=ae(),ep=be(),tp=xr().indexOf,rp=xs(),Ss=Jl([].push);ws.exports=function(t,e){var r=ep(t),n=0,i=[],s;for(s in r)!Sr(rp,s)&&Sr(r,s)&&Ss(i,s);for(;e.length>n;)Sr(r,s=e[n++])&&(~tp(i,s)||Ss(i,s));return i}});var Os=u((ef,Rs)=>{"use strict";Rs.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var ks=u((tf,Ps)=>{"use strict";var np=As(),ip=Os();Ps.exports=Object.keys||function(e){return np(e,ip)}});var $s=u((rf,Ls)=>{"use strict";var Ms=Y(),sp=_(),Ns=H(),op=bs(),ap=ks(),cp=be(),lp=Bt().f,js=Ns(lp),pp=Ns([].push),up=Ms&&sp(function(){var t=Object.create(null);return t[2]=2,!js(t,2)}),Vs=function(t){return function(e){for(var r=cp(e),n=ap(r),i=up&&op(r)===null,s=n.length,c=0,o=[],a;s>c;)a=n[c++],(!Ms||(i?a in r:js(r,a)))&&pp(o,t?[a,r[a]]:r[a]);return o}};Ls.exports={entries:Vs(!0),values:Vs(!1)}});var _s=u(()=>{"use strict";var hp=Te(),dp=$s().values;hp({target:"Object",stat:!0},{values:function(e){return dp(e)}})});var qs=u((of,Fs)=>{"use strict";_s();var mp=Ze();Fs.exports=mp.Object.values});var Ds=u((af,Bs)=>{"use strict";var fp=qs();Bs.exports=fp});var gt=u((cf,Hs)=>{"use strict";var vp=Ds();Hs.exports=vp});var zs=u(()=>{"use strict";var yp=Te(),bp=xr().includes,Cp=_(),gp=nt(),Ep=Cp(function(){return!Array(1).includes()});yp({target:"Array",proto:!0,forced:Ep},{includes:function(e){return bp(this,e,arguments.length>1?arguments[1]:void 0)}});gp("includes")});var Ks=u((df,Ws)=>{"use strict";zs();var Ip=it();Ws.exports=Ip("Array","includes")});var Xs=u((mf,Qs)=>{"use strict";var Tp=Ks();Qs.exports=Tp});var Et=u((ff,Ys)=>{"use strict";var xp=Xs();Ys.exports=xp});var Pr=u((Mf,ro)=>{"use strict";var Pp=ye();ro.exports=Array.isArray||function(e){return Pp(e)==="Array"}});var io=u((Nf,no)=>{"use strict";var kp=TypeError,Vp=9007199254740991;no.exports=function(t){if(t>Vp)throw kp("Maximum allowed index exceeded");return t}});var ao=u((jf,oo)=>{"use strict";var Mp=Pr(),Np=Se(),jp=io(),Lp=cr(),so=function(t,e,r,n,i,s,c,o){for(var a=i,l=0,d=c?Lp(c,o):!1,m,f;l<n;)l in r&&(m=d?d(r[l],l,e):r[l],s>0&&Mp(m)?(f=Np(m),a=so(t,e,m,f,a,s-1)-1):(jp(a+1),t[a]=m),a++),l++;return a};oo.exports=so});var po=u((Lf,lo)=>{"use strict";var $p=ge(),_p=$p("toStringTag"),co={};co[_p]="z";lo.exports=String(co)==="[object z]"});var ho=u(($f,uo)=>{"use strict";var Fp=po(),qp=F(),Tt=ye(),Bp=ge(),Dp=Bp("toStringTag"),Hp=Object,Up=Tt(function(){return arguments}())==="Arguments",Gp=function(t,e){try{return t[e]}catch{}};uo.exports=Fp?Tt:function(t){var e,r,n;return t===void 0?"Undefined":t===null?"Null":typeof(r=Gp(e=Hp(t),Dp))=="string"?r:Up?Tt(e):(n=Tt(e))==="Object"&&qp(e.callee)?"Arguments":n}});var fo=u((_f,mo)=>{"use strict";var zp=H(),Wp=F(),kr=tt(),Kp=zp(Function.toString);Wp(kr.inspectSource)||(kr.inspectSource=function(t){return Kp(t)});mo.exports=kr.inspectSource});var Eo=u((Ff,go)=>{"use strict";var Qp=H(),Xp=_(),vo=F(),Yp=ho(),Zp=Je(),Jp=fo(),yo=function(){},bo=Zp("Reflect","construct"),Vr=/^\s*(?:class|function)\b/,eu=Qp(Vr.exec),tu=!Vr.test(yo),Le=function(e){if(!vo(e))return!1;try{return bo(yo,[],e),!0}catch{return!1}},Co=function(e){if(!vo(e))return!1;switch(Yp(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return tu||!!eu(Vr,Jp(e))}catch{return!0}};Co.sham=!0;go.exports=!bo||Xp(function(){var t;return Le(Le.call)||!Le(Object)||!Le(function(){t=!0})||t})?Co:Le});var So=u((qf,xo)=>{"use strict";var Io=Pr(),ru=Eo(),nu=oe(),iu=ge(),su=iu("species"),To=Array;xo.exports=function(t){var e;return Io(t)&&(e=t.constructor,ru(e)&&(e===To||Io(e.prototype))?e=void 0:nu(e)&&(e=e[su],e===null&&(e=void 0))),e===void 0?To:e}});var Ao=u((Bf,wo)=>{"use strict";var ou=So();wo.exports=function(t,e){return new(ou(t))(e===0?0:e)}});var Ro=u(()=>{"use strict";var au=Te(),cu=ao(),lu=Ce(),pu=Se(),uu=xe(),hu=Ao();au({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,r=lu(this),n=pu(r),i=hu(r,0);return i.length=cu(i,r,r,n,0,e===void 0?1:uu(e)),i}})});var Oo=u(()=>{"use strict";var du=nt();du("flat")});var ko=u((zf,Po)=>{"use strict";Ro();Oo();var mu=it();Po.exports=mu("Array","flat")});var Mo=u((Wf,Vo)=>{"use strict";var fu=ko();Vo.exports=fu});var jo=u((Kf,No)=>{"use strict";var vu=Mo();No.exports=vu});var Br="1.0.34-dev.d1ff213b.0";var Ot=class{constructor(e){this.layout=e}},Be=class extends Ot{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))`}};function Dr(t){return"features"in t}var ne=class{constructor(e,r){this.container=e,this.options=r,this.factories=new Map,this.controls=[],this.setControls()}featureIsEnabled(e){return this.options&&Dr(this.options)&&this.options.features[e]}addControlFactory(e,r){this.factories.set(e.trim().toLowerCase(),r),this.setControls()}removeControlFactory(e){this.factories.delete(e.trim().toLowerCase()),this.setControls()}setControls(){this.controls=this.chooseControls()}chooseControls(){return this.container.controls?.reduce((e,r)=>{let n=r.type.trim().toLowerCase(),i=this.factories.get(n);if(i){let s=i(r,this.options);if(s)return[...e,s]}return[...e]},[])||[]}};function Pt(t,e=1){let r="0",n="0",i="0";return t.length===4?(r="0x"+t[1]+t[1],n="0x"+t[2]+t[2],i="0x"+t[3]+t[3]):t.length===7&&(r="0x"+t[1]+t[2],n="0x"+t[3]+t[4],i="0x"+t[5]+t[6]),`rgba(${+r},${+n},${+i},${e})`}var Hr="interactive",N={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0},Ur=(n=>(n.top="flex-start",n.bottom="flex-end",n.center="center",n))(Ur||{}),Gr=(n=>(n.start="flex-start",n.end="flex-end",n.center="center",n))(Gr||{}),zr=(n=>(n.start="left",n.end="right",n.center="center",n))(zr||{}),De=({target:t,props:e})=>{t.style.alignItems=(e?.gravityVertical&&Ur[e.gravityVertical])??"center",t.style.justifyContent=(e?.gravityHorizontal&&Gr[e.gravityHorizontal])??"center",t.style.textAlign=(e?.alignment&&zr[e.alignment])??"center"},He=({target:t,props:e,fallback:r,dependsOn:n})=>{t.style.color=e?.text?.color??r.textColor,t.style.fontSize=`calc(${n.height} * ${e?.text?.size??r.textSize})`,t.textContent=e?.text?.value??r.textContent},Ue=({target:t,props:e,fallback:r})=>{t.style.backgroundColor=Pt(e?.background?.color??r.backgroundColor,e?.background?.alpha??r.backgroundAlpha)},Ge=({target:t,props:e,fallback:r,dependsOn:n})=>{t.style.border=`calc(${n.height} * ${e?.shape?.border?.width??r.borderWidth}) solid ${Pt(e?.shape?.border?.color??r.borderColor,e?.shape?.border?.alpha??r.borderAlpha)}`,t.style.borderRadius=`calc(${n.height} * ${e?.shape?.roundCorners??r.roundCorners})`},ie=({target:t,layoutParams:e,fallback:r})=>{let n=e.angle??r.angle;n=n&&n*-1,t.style.transform=`rotate(${n}rad)`};var kt="int",X=(n=>(n.AREA=`${kt}_area`,n.TEXT=`${kt}_text`,n.BUTTON=`${kt}_bttn`,n))(X||{});function Wr(t){return"features"in t}var se="interactive-control",P={common:se,wrapper:`${se}-wrapper`,disabled:`${se}-disabled`,button:`${se}-button`,area:`${se}-area`,text:`${se}-text`};var Q=class{constructor(e,r){this.control=e;this.options=r;this.container=null;this.controlElement=null;this.clickListener=null}createContainerElement(e){let r=document.createElement("div");r.classList.add(P.wrapper),e.setControlLayout(r,this.control.layoutParams);let n=(this.control.layoutParams.innerSizesDependOn??N.innerSizesDependOn)==="self"?{height:r.style.height,width:r.style.width}:{height:"var(--interactive-content-height)",width:"var(--interactive-content-width)"};this.container={element:r,dimensions:n}}createClickListener(e){return r=>{r.stopPropagation(),e()}}featureIsEnabled(e){return this.options&&Wr(this.options)&&this.options.features[e]}setEvents(e){!this.container||!this.control.events||this.control.events.forEach(r=>{switch(r.type.trim().toLowerCase()){case"onclick":this.clickListener=this.createClickListener(()=>e({action:r.action,controlId:this.control.id,controlType:this.control.type})),this.container?.element.addEventListener("click",this.clickListener);break;default:break}})}removeListeners(){this.container?.element&&this.clickListener&&this.container?.element.removeEventListener("click",this.clickListener)}};var ze=(t,e)=>{if(t.type.trim().toLowerCase()==="area")return new Vt(t,e)},Vt=class extends Q{constructor(e,r){super(e,r)}createView({parentElement:e,callbacks:r}){if(super.createContainerElement(r),!this.container)return;let n=document.createElement("button");n.type="button",n.classList.add(P.common,P.area),n.setAttribute("data-testid",X.AREA),Ue({target:n,props:this.control.props,fallback:{...N,backgroundColor:"transparent"}}),Ge({target:n,props:this.control.props,fallback:{...N,borderAlpha:0},dependsOn:this.container.dimensions}),ie({target:n,layoutParams:this.control.layoutParams,fallback:N}),this.container.element.append(n),e.append(this.container.element),this.controlElement=n}disable(){this.controlElement&&this.controlElement.classList.add(P.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(P.disabled)}getElement(){return this.controlElement}onProgress(){}onResize(){}};var We=t=>{let e=document.createElement("span");switch(t){case"Button":case"button":{let r=document.createElement("div"),n={overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center"};Object.assign(r.style,n),r.append(e);let i={display:"inline-block",whiteSpace:"pre",textOverflow:"ellipsis",maxWidth:"initial",maxHeight:"100%",wordBreak:"normal"};return Object.assign(e.style,i),r}default:{let r={display:"inline-block",whiteSpace:"break-spaces",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%",maxHeight:"100%",wordBreak:"break-all"};return Object.assign(e.style,r),e}}};var Ke=(t,e)=>{if(t.type.trim().toLowerCase()==="button")return new Mt(t,e)},Mt=class extends Q{constructor(e,r){super(e,r)}createView({parentElement:e,callbacks:r}){if(super.createContainerElement(r),!this.container)return;let n=document.createElement("button");n.type="button",n.classList.add(P.common,P.button),n.setAttribute("data-testid",X.BUTTON),ie({target:n,layoutParams:this.control.layoutParams,fallback:N}),Ue({target:n,props:this.control.props,fallback:N}),Ge({target:n,props:this.control.props,fallback:N,dependsOn:this.container.dimensions}),De({target:n,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let i=We(this.control.type.trim().toLowerCase()),s=i.firstElementChild??i;He({target:s,props:this.control.props,fallback:N,dependsOn:this.container.dimensions}),n.append(i),this.container.element.append(n),e.append(this.container.element),this.controlElement=n}disable(){this.controlElement&&this.controlElement.classList.add(P.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(P.disabled)}getElement(){return this.controlElement}onProgress(){}onResize(){}};var Kr=(t,e)=>{if(t.type.trim().toLowerCase()==="text")return new Nt(t,e)},Nt=class extends Q{constructor(e,r){super(e,r)}createView({parentElement:e,callbacks:r}){if(super.createContainerElement(r),!this.container)return;let n=document.createElement("div");n.classList.add(P.common,P.text),n.setAttribute("data-testid",X.TEXT),ie({target:n,layoutParams:this.control.layoutParams,fallback:N}),De({target:n,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let i=We(this.control.type.trim().toLowerCase()),s=i.firstElementChild??i;He({target:s,props:this.control.props,fallback:N,dependsOn:this.container.dimensions}),n.append(i),this.container.element.append(n),e.append(this.container.element),this.controlElement=n}getElement(){return this.controlElement}disable(){}enable(){}onProgress(){}onResize(){}};var jt="interactive-container",$={common:jt,hidden:`${jt}-hidden`,disabled:`${jt}-disabled`};var Qe=(t,e,r)=>{if(t.type.trim().toLowerCase()==="choice")return new Lt(t,e,r)},Lt=class extends ne{constructor(r,n,i){super(r,i);this.containerElement=null;this.rootElement=n,this.layout=new Be(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",Ke),this.addControlFactory("text",Kr),this.addControlFactory("area",ze)}createView({eventCallback:r}){let n=document.createElement("div");return n.classList.add($.common,$.disabled),requestAnimationFrame(()=>{n.classList.remove($.disabled)}),this.layout.setContainerLayout(n),this.controls.forEach(i=>{i.createView({parentElement:n,callbacks:{setControlLayout:this.layout.setControlLayout}}),i.setEvents(r)}),this.rootElement.append(n),this.isRemoved=!1,this.containerElement=n,n}hide(){let r=this.getElement();r&&r.classList.add($.hidden)}show(){let r=this.getElement();r&&r.classList.remove($.hidden)}enable(){let r=this.getElement();r&&(r.classList.remove($.disabled),this.controls.forEach(n=>n.enable()),this.isDisabled=!1)}disable(){let r=this.getElement();r&&(r.classList.add($.disabled),this.controls.forEach(n=>n.disable()),this.isDisabled=!0)}removeView(){let r=this.getElement();r&&(this.controls.forEach(n=>n.removeListeners()),r.remove(),this.isRemoved=!0,this.containerElement=null)}fakeRemove(){this.isRemoved||(this.isRemoved=!0)}getElement(){return this.containerElement}onProgress(r,n){n&&this.controls.forEach(i=>{i.onProgress(r)})}onResize(r){r&&this.controls.forEach(n=>{n.onResize()})}};var oa=K(dr(),1);import{combine as Ou,InterfaceLanguage as Pu,Observable as na,once as ku,Subject as j,Subscription as _r,ValueSubject as L,fromEvent as ia}from"@vkontakte/videoplayer-shared";import{InteractiveInterfaceClick as Fe}from"@vkontakte/videoplayer-statistics";import{loadVKLangPack as Ol}from"@vkontakte/videoplayer-shared";function we(t,e){let r;return(...n)=>{clearTimeout(r),r=setTimeout(()=>t(...n),e)}}var Z=(t,e)=>Object.prototype.toString.call(t)===`[object ${e}]`,Ae=t=>Z(t,"Object"),st=t=>Z(t,"String"),ot=t=>Z(t,"Array"),at=t=>Z(t,"Number"),Zi=t=>Z(t,"Function");var mr=t=>at(t)&&!isNaN(t);var J=t=>Ae(t)&&Object.keys(t).length===0,fr=t=>ot(t)&&!t.length;var Re=(t,e)=>st(t)&&(e?t.trim():t).length;var Ji="video_interactive",es="videoint";var ts=250,Oe=class{constructor(e){this.handleZoomChange=we(e=>{this.lastZoomInfo=e},ts);this.onResize=e=>{if(!this.isReady||this.isHidden||!e[0].contentRect.width||!e[0].contentRect.height)return;let r=this.getNextPoint();r&&this.ngEditor?.zoomTo(r),this.ngEditorSize={width:e[0].contentRect.width,height:e[0].contentRect.height}};this.handleChapterChange=e=>{if(this.manifest){if(this.isHidden||this.hide(),!e?.id){this.onError?.("Chapter 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=null}};this.handleManifestChange=(e,r=[])=>{if(this.isReady=!1,!at(e.graph.edit.chapters[0].x)){this.onError?.("Can't show graph");return}this.lastZoomInfo=null,this.manifest=e,this.visitedChapterIds=new Set(r),this.ngEditor&&(this.manifest.metadata.id!==this.currentManifestId?(this.ngEditor.update(e),this.currentManifestId=this.manifest.metadata.id):this.ngEditor.setVisitedChapters(Array.from(r)),this.isReady=!0)};this.init(e)}init({root:e,onOpenPreviewClick:r,onError:n,lang:i,visitedChapters:s=[]}){this.isReady=!1,this.isHidden=!0,this.manifest=null,this.visitedChapterIds=new Set(s),this.onOpenPreviewClick=r,this.onError=n,this.lang=i??"ru",this.zoom=.7,this.lastZoomInfo=null,this.currentManifestId=null,this.currentChapterId=null,this.ngEditor=null,this.ngEditorSize=null,this.graphWrapperElement=Pl(e),this.resizeObserver=new ResizeObserver(we(this.onResize,ts)),this.resizeObserver.observe(this.graphWrapperElement)}getNextPoint(e=this.ngEditorSize){return!this.lastZoomInfo||!e?null:[(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)}async show(){this.manifest&&(this.ngEditor||await this.initNgEditor(),this.graphWrapperElement.style.display="block",!this.lastZoomInfo&&this.currentChapterId&&this.ngEditor?.focusChapter(this.currentChapterId),this.isHidden=!1)}async initNgEditor(){if(!this.manifest)return;let e;try{e=await Ol(this.lang,Ji,es)}catch{this.onError?.("Unable to load graph language pack")}let{GraphEditor:r}=await import("@interactiveplatform/movika-graph-editor");this.ngEditor=new r(this.graphWrapperElement,{mode:"read",lang:this.lang==="ru"?"ru":"en",translation:e}),this.currentManifestId=this.manifest.metadata.id,this.ngEditor.update(this.manifest),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId&&this.ngEditor.selectChapter(this.currentChapterId),this.ngEditor.on("control",({name:n,...i})=>{n==="openPreview"&&"chapterId"in i&&this.onOpenPreviewClick?.(i.chapterId)}),this.ngEditor.on("zoom",this.handleZoomChange),this.isReady=!0}hide(){this.graphWrapperElement.style.display="none",this.isHidden=!0}destroy(){this.hide(),this.manifest=null,this.resizeObserver.disconnect(),this.ngEditor?.setVisitedChapters([]),this.onOpenPreviewClick=void 0,this.ngEditor?.dispose(),this.graphWrapperElement.remove(),this.isReady=!1}};function Pl(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 Pe=class{constructor(){this._containers=[];this._player=null;this.setPlayer=e=>{this._player=e};this.setContainers=e=>{this._containers=e};this.deleteContainer=e=>{this._containers=this._containers.filter(r=>r.id!==e)};this.getNextInteractiveTime=(e=3e3)=>{if(!this._containers.length||this._player===null)return null;let r=-1,n=!1,i=Math.round(this._player.info.position$.getValue()*1e3);for(let s of this._containers){let c=s.startTime-e;if(c<=i&&(s.endTime&&i<=s.endTime||s.endTime===null)){n=!0;break}i<c&&(r=r===-1?c:Math.min(r,c))}return!n&&r!==-1?r:null}}};import{isSupportedManifest as lt,ContainerTypes as am,ControlTypes as pt,EventActionTypes as w,EventTypes as cm,migrateManifestToLatestVersion as ss,compareVersions as lm}from"@interactiveplatform/movika-manifest";var rs={metadata:"Object",chapters:"Array"},ns=t=>{if(!Ae(t))return!1;for(let e in rs)if(!t[e]||!Z(t[e],rs[e]))return!1;return lt(t.metadata.version)},ct=t=>t.type===pt.Text,Jd=t=>t.type===pt.Button,em=t=>t.type===pt.Area,tm={Choice:"Choice",TextInput:"TextInput"},rm={Button:"Button",Area:"Area",Text:"Text"},nm={onClick:"onClick",onSuspense:"onSuspense"},is={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var M=class{constructor(e,r,...n){this.severity=e;this.category=r;this.data=n}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};var ut=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 n=()=>{r(),this.off(e,n)};return this.listeners[e].push(n),this}off(e,r){return this.removeListener(e,r)}reset(){this.listeners={}}removeListener(e,r){let n=this.listeners[e]||[];for(let i=n.length;i>0;i--)if(n[i]===r){n.splice(i,1);break}return this}emit(e,...r){let n=this.listeners[e];return n?(n.forEach(i=>{i(...r)}),!0):!1}listenerCount(e){return this.rawListeners(e).length}rawListeners(e){return this.listeners[e]||[]}};var ht=class{constructor(e){this.fns=[];this.addFn=(e,r=!1)=>{Zi(e)&&(this.fns.push(e),r&&this.updateFn())};this.removeFn=(e,r=!1)=>{this.fns=this.fns.filter(n=>n!==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=()=>{this.raf&&(cancelAnimationFrame(this.raf),this.raf=void 0)};e&&(this.fn=e,this.addFn(e))}release(){this.cancelAnimation(),this.fn=void 0,this.fns=[]}};import{ValueSubject as $l}from"@vkontakte/videoplayer-shared";var dt=class{constructor(e){this.loaders={chapterLoaders:e?.chapterLoaders??[],manifestLoaders:e?.manifestLoaders??[]}}async exec(e,r){return kl(...this.loaders[e])(r)}};function kl(...t){return async function(r){let n=[...t];for(;n.length>0;)r=await n.shift()(r);return r}}function ke(t,e,r){return t?{...t,[e]:t[e]?[r,...t[e]]:[r]}:{[e]:[r]}}function mt({actions:t,errors:e,chapterId:r,...n}){if(r){let i=t.getManifest();if(i){let s=t.getChapter(i.chapters,r);if(s){let c=t.getMedia(i.media,s.videoId),o=t.getGraph(i.graph,s.id);return c?{...n,actions:t,errors:e,result:{chapter:s,media:c,graph:o}}:{...n,errors:ke(e,mt.name,"Could not find media"),actions:t}}}}return{...n,errors:ke(e,mt.name,"Could not find chapter"),actions:t}}var ft=class{constructor(){Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}addEventListener(e,r,n){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:r,options:n})}removeEventListener(e,r){if(!(e in this.listeners))return;let n=this.listeners[e];for(let i=0,s=n.length;i<s;i++)if(n[i].callback===r){n.splice(i,1);return}}dispatchEvent(e){if(!(e.type in this.listeners))return;let n=this.listeners[e.type].slice();for(let i=0,s=n.length;i<s;i++){let c=n[i];try{c.callback.call(this,e)}catch(o){Promise.resolve().then(()=>{throw o})}c.options&&c.options.once&&this.removeEventListener(e.type,c.callback)}return!e.defaultPrevented}},ue=class extends ft{constructor(){super(),this.listeners||ft.call(this),Object.defineProperty(this,"aborted",{value:!1,writable:!0,configurable:!0}),Object.defineProperty(this,"onabort",{value:null,writable:!0,configurable:!0}),Object.defineProperty(this,"reason",{value:void 0,writable:!0,configurable:!0})}toString(){return"[object AbortSignal]"}dispatchEvent(e){e.type==="abort"&&(this.aborted=!0,typeof this.onabort=="function"&&this.onabort.call(this,e)),super.dispatchEvent(e)}},Ve=class{constructor(){Object.defineProperty(this,"signal",{value:new ue,writable:!0,configurable:!0})}abort(e){let r;try{r=new Event("abort")}catch{typeof document<"u"?document.createEvent?(r=document.createEvent("Event"),r.initEvent("abort",!1,!1)):(r=document.createEventObject(),r.type="abort"):r={type:"abort",bubbles:!1,cancelable:!1}}let n=e;if(n===void 0)if(typeof document>"u")n=new Error("This operation was aborted"),n.name="AbortError";else try{n=new DOMException("signal is aborted without reason")}catch{n=new Error("This operation was aborted"),n.name="AbortError"}this.signal.reason=n,this.signal.dispatchEvent(r)}toString(){return"[object AbortController]"}};typeof Symbol<"u"&&Symbol.toStringTag&&(Ve.prototype[Symbol.toStringTag]="AbortController",ue.prototype[Symbol.toStringTag]="AbortSignal");function vt(t){return t.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill"),!0):typeof t.Request=="function"&&!t.Request.prototype.hasOwnProperty("signal")||!t.AbortController}function vr(t){typeof t=="function"&&(t={fetch:t});let{fetch:e,Request:r=e.Request,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:i=!1}=t;if(!vt({fetch:e,Request:r,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:i}))return{fetch:e,Request:s};let s=r;(s&&!s.prototype.hasOwnProperty("signal")||i)&&(s=function(l,d){let m;d&&d.signal&&(m=d.signal,delete d.signal);let f=new r(l,d);return m&&Object.defineProperty(f,"signal",{writable:!1,enumerable:!1,configurable:!0,value:m}),f},s.prototype=r.prototype);let c=e;return{fetch:(a,l)=>{let d=s&&s.prototype.isPrototypeOf(a)?a.signal:l?l.signal:void 0;if(d){let m;try{m=new DOMException("Aborted","AbortError")}catch{m=new Error("Aborted"),m.name="AbortError"}if(d.aborted)return Promise.reject(m);let f=new Promise((y,R)=>{d.addEventListener("abort",()=>R(m),{once:!0})});return l&&l.signal&&delete l.signal,Promise.race([f,c(a,l)])}return c(a,l)},Request:s}}var Me=vt({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),os=Me?vr({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,yr=Me?os.fetch:window.fetch,Am=Me?os.Request:window.Request,Rm=Me?Ve:window.AbortController,Om=Me?ue:window.AbortSignal;var br=(t="",e="")=>{let r=t.split("."),n=e.split("."),i=0;for(let s=0;s<Math.max(r.length,n.length)&&!i;s++)r[s]>n[s]?i=1:r[s]<n[s]?i=-1:i=0;return i};var Vl=async t=>{try{let e={},r;if(st(t)){r=new URL(t).href;let i=await yr(r);if(!i.ok)return{};e=await i.json()}else if(Ae(t))e=t;else return{};if(!ns(e))return{};let n=e.metadata.media;if(st(n)&&!("media"in e))try{let i;r?i=new URL(n,r).href:(i=new URL(n).href,r=i);let s=await yr(i);if(!s.ok)throw new Error;e.metadata.media=await s.json()}catch{return jl(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:r}}catch{return{}}};async function as(t){let{manifest:e,manifestURL:r}=await Vl(t);if(!e)throw new Error("Failed on fetch");let n=ss(e);return n.media=Ml(n.media,r),delete n.metadata.media,n}function yt(t,e){if(e)return t.find(r=>r.id===e)}function Cr(t,e){return t.edit?.chapters?t.edit.chapters.find(r=>r.id===e):t.view?.chapters?t.view.chapters.find(r=>r.id===e):void 0}function gr(t,e){return t.videos.find(r=>r.id===e)}function Ml(t,e){return{...t,videos:t.videos.map(r=>({...r,variants:r.variants.map(n=>{let i="url"in n?n.url:"",s=Nl(i,e);return{...n,url:s||i}})}))}}function Nl(t="",e){try{return new URL(t,e).href}catch{return""}}function jl(t){return br(t,"3.2.0")>=0}var bt=t=>ot(t)&&!fr(t),z=t=>t.order==="end",Ct=t=>ot(t.containers)&&!fr(t.containers)&&z(t),cs=(t,e)=>{let r=t*1e3;return bt(e.controls)&&r<(e.startTime??0)},Er=(t,e)=>{let r=t*1e3;return bt(e.controls)&&r>=(e.startTime??0)&&r<=(e.endTime??1/0)};var ee=(t=[])=>t.some(e=>e.action.type==="expect"),Ir=(t=[])=>t.find(e=>e.action.type==="expect"),Ll=t=>t?.length===1,he=t=>Ll(t)&&ct(t[0]);function ls(t,...e){return r=>typeof e[0]=="object"&&typeof r=="object"?t({...e[0],...r}):t(...e,...r)}var ps=(t,e)=>{let r=E=>e.find(({container:I})=>I.container.id===E)?.container.isRemoved,n=ee(t.events)&&!r(t.id),i=(E,C=!1,I=!1)=>{let h=I?"every":"some";return E.controls[h](p=>{let v=C?E.endTime===t.endTime:!0;return p.events?.[h](b=>b.action?.type===is.openURI)&&v})},s=E=>E.some(({container:C})=>i(C.container,!0,!1)&&!C.isRemoved),c=E=>E.every(({container:C})=>C.isRemoved?!0:i(C.container,!0,!0)),o=e.filter(({container:E})=>E.container.id!==t.id&&ee(E.container.events)&&E.container.endTime===t.endTime&&!E.isRemoved).length,a=E=>E.controls.some(C=>C.events?.some(I=>I.action?.args?.shouldOpenNow)),l=n||o>0,d=s(e),m=i(t),f=c(e),y=n?!1:o>0,R=a(t);return{isExpectTime:l,hasOtherExpect:o>0,hasOpenURIEvent:d,hasOpenURIEventInCurrentContainer:m,isAllOpenURIEventsValid:f,isExpectEventForCurrentContainer:y,hasShouldOpenNowEvent:R}};var de=class extends dt{constructor(r,n){super(r);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new $l(null);this.onError=n,this.release()}release(){return this.manifest=null,this.chapter=null,this.media=null,this.graph=null,this.prevChapter$.next(null),this}async setManifest(r){this.release();let n=await this.exec("manifestLoaders",{actions:{addErrorMessage:ke},result:null,errors:null,source:r});return n.errors&&this.errorHandler(n.errors),this.manifest=await as(n.result??r),this}async setInitial(){return this.setNext()}async setNext(r=this.manifest?.metadata.initChapterId){if(!r)return this;this.prevChapter$.next(this.chapter);let n=await this.exec("chapterLoaders",mt({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:Cr,getChapter:yt,getMedia:gr,getByBranches:this.getByBranches.bind(this),addErrorMessage:ke},result:null,errors:null,chapterId:r}));return n.errors&&this.errorHandler(n.errors),n.result&&(this.chapter=n.result.chapter,this.media=n.result.media,this.graph=n.result.graph),this}errorHandler(r){this.onError(r),console.error("Something went wrong with loaders",{errors:r})}getInitial(){return this.getByChapterId(this.manifest?.metadata.initChapterId)||null}getByChapterId(r=this.manifest?.metadata.initChapterId){if(!r||!this.manifest)return null;let n=yt(this.manifest.chapters,r);if(n){let i=gr(this.manifest.media,n.videoId),s=Cr(this.manifest.graph,n.id);if(i)return{chapter:n,media:i,graph:s}}return null}getBranches(r=this.chapter?.id){if(r===this.chapter?.id)return this.getByBranches(this.chapter?.branches);{let n=yt(this.manifest?.chapters||[],r);return this.getByBranches(n?.branches)}}getByBranches(r=[]){return r.reduce((n,i)=>{let s=this.getByChapterId(i.chapterId);return s&&n.push(s),n},[])}getCurrent(){return{chapter:this.chapter,media:this.media,graph:this.graph}}isInitialChapter(){return this.chapter?.id===this.manifest?.metadata.initChapterId}isEndChapter(){return this.chapter?z(this.chapter):!1}};var Zs=K(gt(),1);import{Player as Sp}from"@vkontakte/videoplayer-core";import{Subscription as Rr,Tracer as wp,ValueSubject as Ap}from"@vkontakte/videoplayer-shared";var Us=t=>{let e=t.variants.find(r=>r.payload?.type==="vk");if(e&&e.payload){let[r,n]=e.payload.id.split("_");return[r,n]}return[]};var Gs=K(gt(),1);function wr(){let t=new Map;function e({listId:s=Math.random().toString(),itemId:c=Math.random().toString(),...o}){let a=t.get(s),l={...o};return a?a[c]=l:t.set(s,{[c]:l}),{listId:s,itemId:c,...o}}function r(s){s.player.destroy(),s.container.remove(),s.subscription.unsubscribe(),s.statistics?.oneStat.destroy(),s.statistics?.statSubscription.unsubscribe()}function n(s,c){let o=t.get(s);if(!o)throw Error("Can't remove. Not find.");if(c){let a=o[c];a&&r(a),delete o[c],Object.keys(o).length||t.delete(s)}else{for(let a of(0,Gs.default)(o))r(a);t.delete(s)}}function i(){for(let s of t)n(s[0])}return{createPlayer:e,removePlayer:n,map:t,removeAll:i}}var me=K(Et(),1);function Ar(t,e=[]){let r={},n,i=!e.length;for(let s of t.variants)if(!n&&"cover"in s&&(n=s.cover),"url"in s)switch(s.type.toLowerCase()){case"mp4":(i||(0,me.default)(e,"mp4"))&&(r.MPEG={...r.MPEG,[s.standard??"Invariant quality"]:s.url});break;case"mpeg":(i||(0,me.default)(e,"mpeg"))&&(r.MPEG={...r.MPEG,[s.standard??"Invariant quality"]:s.url});break;case"hls":(i||(0,me.default)(e,"hls"))&&(r={...r,HLS:{type:"url",url:s.url}});break;case"dash":(i||(0,me.default)(e,"dash"))&&(r={...r,DASH_SEP:{compatibilityMode:!0,type:"url",url:s.url}});break;default:break}return{sources:r,thumbUrl:n,title:t.title??""}}var Ne=(t,e)=>{let r=t.info.currentQuality$.getValue(),n=t.info.availableQualities$.getValue();r!==e&&(0,me.default)(n,e)&&(t.setQuality(e),t.setAutoQuality(!1))};var Rp=2;function Or(t){let e=wr(),r=new Rr,n={},i=null,s=!1,c,o=new Ap(null);t&&a(t);function a(C){i=C}function l(C,I,h){if(!i)throw Error("need to set interactive controller");if(!i.options)return;let v=(e.map.get(C)??{})[I];if(v){n={chapterId:h,listId:C,itemId:I,...v};let b=n.player;n.subscription.add(b.info.currentQuality$.subscribe(g=>{let T=b.info.position$.getValue(),A=b.info.isAutoQualityEnabled$.getValue();if(!(!g||!T||A))for(let k of e.map)(0,Zs.default)(k[1]).forEach(({player:S})=>{Ne(S,g)})})).add(b.events.started$.subscribe(()=>{d(I)})),v.container.remove(),i.setPlayer(v.player),s||(i.init(),s=!0),o.next({player:n.player,config:n.config,statistics:n.statistics});return}throw Error("Can't set. Not find.")}async function d(C){if(!i)throw Error("need to set interactive controller");if(J(n)||C!==n.itemId)return;let I=i.getChapterBranches(),h=new Set;for(let p of I)h.has(p.media.id)||(await f({media:p.media,chapterId:p.chapter.id,setAsActive:!1,title:p.chapter.label}),h.add(p.media.id))}async function m({chapter:{id:C},manifestVideo:I}){if(J(n)||!i)return;let h=n.player.info.muted$.getValue(),p=n.player.info.currentQuality$.getValue(),v=n.player.info.isAutoQualityEnabled$.getValue(),b=n.player.info.volume$.getValue(),g=n.player.info.currentPlaybackRate$.getValue(),T=!v,A=!1;for(let k of e.map)if(k[0]===I.id&&!i.state.isReplay$.getValue()){let S=Object.keys(k[1]);for(let V of S)V===n.itemId?(S.length<Rp||(A=!0),e.removePlayer(k[0],V)):(A=!0,l(k[0],V,C),T?Ne(n.player,p):n.player.setAutoQuality(!0),n.player.setVolume(b),n.player.setMuted(h),n.player.setPlaybackRate(g))}else e.removePlayer(k[0]);A||(await f({media:I,chapterId:C,setAsActive:!0,playbackRate:g}),T?Ne(n.player,p):n.player.setAutoQuality(!0),n.player.setVolume(b),n.player.setMuted(h))}async function f({media:C,chapterId:I,prefetch:h=!0,setAsActive:p=!0,autoplay:v=!1,preferredExt:b,title:g,playbackRate:T}){let A=Math.random().toString(),k=document.createElement("div");c.append(k);let S;if(i?.options?.vkVideoLoader){let qe=Us(C);qe.length&&(S=await i.options.vkVideoLoader(...qe))}let V=i?.options?.coreConfig||void 0,q={...V,configName:[...V?.configName??[],"interactive"]},B={container:k,...S?.videos?.[0]||{sources:Ar(C,b).sources},title:g,failoverHosts:S?.failoverHosts||[]},D=new Sp(q,wp.createRootTracer());D.initVideo(B);let W=null;if(S?.videos&&i?.options.createOneStat){let qe=S.videos[0],Rt=i.options.createOneStat(qe),Fr=new Rr;Rt&&(Fr.add(Rt.attachTo(D)),W={oneStat:Rt,statSubscription:Fr})}let te=new Rr,aa=n?.player?.info.isAutoQualityEnabled$.getValue();te.add(D.events.canplay$.subscribe(function(){aa||Ne(D,n.player.info.currentQuality$.getValue()),T&&D.setPlaybackRate(T)}));let re=e.createPlayer({listId:C.id,itemId:A,player:D,container:k,sources:Ar(C,b).sources,config:B,subscription:te,statistics:W});return p&&l(C.id,re.itemId,I),v&&re.player.play(),h&&!v&&re.player.prepare(),{player:re.player,config:re.config,statistics:re.statistics}}function y(){R(),i=null,c.remove()}function R(){r.unsubscribe(),e.removeAll(),n={},s=!1}async function E(){if(!i)throw Error("need to set interactive controller");R(),c=document.createElement("div");let{media:C,chapter:I}=i.getCurrentChapter();C&&I?(r.add(i.events.chapterChanged$.subscribe(m)),await f({media:C,chapterId:I.id,title:I.label})):console.error("not found")}return{...e,init:E,setInteractiveController:a,createPlayer:f,removeAll:y,getActivePlayer:function(){return n},activePlayerChanged:o}}var x={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},je={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},O={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};var eo=K(Et(),1);import{Subscription as Op}from"@vkontakte/videoplayer-shared";var It=class{constructor({player:e,container:r,branches:n,selectBranches:i,interactiveEvents:s,globalEvents:c,globalEventEmitter:o,getContainerEventState:a,permanentTextControls:l,interactiveTimeOpenUri:d,disabledControls$:m,onRemove:f}){this.hide=()=>{setTimeout(()=>{this.gameState!==4&&(ee(this.container.container.events)&&this.gameState===3||this.selectBranches.state.isExpect||(this.gameState!==2&&this.container.hide?.(),this.emitContainerVisibilityEvent(!1)))})};this.show=()=>{if(this.gameState!==2||this.isSelectedControlEvent)return;if(this.container.getElement()){let{hasOpenURIEventInCurrentContainer:r}=this.getContainerEventState();if(this.container.show?.(),this.interactiveTimeOpenUri&&r)return;this.emitContainerVisibilityEvent(!0,!1)}else{let r={isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.emitContainerVisibilityEvent(!1)},onEvent:(i,s)=>{let{isExpectTime:c,hasOtherExpect:o,hasOpenURIEvent:a,hasOpenURIEventInCurrentContainer:l,isAllOpenURIEventsValid:d,hasShouldOpenNowEvent:m}=this.getContainerEventState(),f=this.interactiveTimeOpenUri&&!l,y=this.interactiveTimeOpenUri&&l;if((!this.interactiveTimeOpenUri||f)&&(this.isSelectedControlEvent=!0),i!==!1){if(!this.selectBranches.state.isExpect&&(!this.interactiveTimeOpenUri||f)){if(this.interactiveTimeOpenUri){let R=!o&&!d&&l;R&&this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:R})}this.removeView()}this.emitContainerVisibilityEvent(!1)}if(this.gameState===4||this.gameState===3||this.selectBranches.state.isExpect||this.interactiveTimeOpenUri&&a&&this.gameState!==5){if(y){let E=((C,I,h,p)=>!C&&!I&&h||C&&!I&&h&&!p||C&&!I&&h&&p)(c,o,d,this.isSelectedContainerEvent);this.fakeRemoveView(E)}else this.removeView(),this.emitContainerVisibilityEvent(!1);(!c||!o||!m)&&(this.selectBranches.stopExpect(),s())}},isEOV:()=>this.gameState===4},n=ls(this.selectBranches.onControlEvent,r);this.container.createView({eventCallback:n}),this.emitContainerVisibilityEvent(!0,!0),this.disabledControls$.getValue()&&this.container.disable?.()}};this.onEndOfVideo=()=>{this.gameState=4,this.selectContainerEvent(!0)};this.whilePlaying=()=>{let e=this.player.experimental.element$.getValue(),n=e instanceof HTMLVideoElement?e.readyState:void 0,i=[6,5];if(!n||(0,eo.default)(i,this.gameState)&&!this.isPermanentText)return;let s=this.player.getExactTime();if(cs(s,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(Er(s,this.container.container))this.gameState!==2&&(this.gameState=2,this.onStartTime());else if(this.gameState!==3){let l=this.gameState;this.gameState=3,l===2&&this.onEndTime()}else{let{hasOpenURIEventInCurrentContainer:l}=this.getContainerEventState(),d=this.selectBranches.state.isExpect,m=this.interactiveTimeOpenUri&&l;if(m&&!d){let f=this.container.getElement();f&&(f.style.visibility!=="hidden"&&this.container.hide?.(),this.container.isRemoved||this.fakeRemoveView())}!this.isPermanentText&&!m&&this.removeView()}let c=Er(s,this.container.container),o=this.container.container.startTime?[this.container.container.startTime,this.container.container.endTime??1/0]:[],a={subjectId:this.container.container.id,subjectName:"container",range:o,currentTime:s,isInteractiveTime:c};this.container.onProgress(s*1e3,c),this.globalEventEmitter.emit(x.eachTick,a),this.globalEvents.eachTick$.next(a)};this.container=r,this.branches=n,this.selectBranches=i,this.subscription=new Op,this.player=e,this.interactiveEvents=s,this.getContainerEventState=a,this.isPermanentText=l&&he(r.container.controls),this.interactiveTimeOpenUri=d,this.disabledControls$=m,this.onRemove=f,this.globalEventEmitter=o,this.gameState=0,this.globalEvents=c,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}emitContainerVisibilityEvent(e,r=!1){e?(this.globalEventEmitter.emit(x.interactives,{subjectId:this.container.container.id,subjectName:"container",type:O.visibility,visibility:e,isFirst:r}),this.globalEvents.interactiveVisibilityChanged$.next({subjectId:this.container.container.id,subjectName:"container",type:"visibility",visibility:e,isFirst:r})):(this.globalEventEmitter.emit(x.interactives,{subjectId:this.container.container.id,subjectName:"container",type:O.visibility,visibility:!1}),this.globalEvents.interactiveVisibilityChanged$.next({subjectId:this.container.container.id,subjectName:"container",type:"visibility",visibility:e}))}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=>{e?this.container.disable?.():this.container.enable?.()}))}selectContainerEvent(e=!1){let{isExpectEventForCurrentContainer:r}=this.getContainerEventState();this.interactiveEvents.containersEventsCallState.setCalled({timestamp:e?1/0:this.container.container.endTime??1/0,id:this.container.container.id}),!(this.isSelectedControlEvent||this.isSelectedContainerEvent)&&(this.isSelectedContainerEvent=!0,!r&&!this.container.isRemoved&&this.selectBranches.setManifestContainerEvents({container:this.container.container,branches:this.branches,isEOV:e}),!e&&this.interactiveEvents.exec(this.container.container.endTime??1/0))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);let{isExpectTime:e,hasOpenURIEventInCurrentContainer:r}=this.getContainerEventState(),n=this.interactiveTimeOpenUri?e||r:ee(this.container.container.events)||e;(this.isSelectedControlEvent||!n)&&this.removeView()}onBeforeStartTime(){this.container.hide?.(),this.emitContainerVisibilityEvent(!1)}onResize(e){this.container.onResize(e)}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=1}removeView(){this.container.removeView(),this.globalEventEmitter.emit(x.interactives,{subjectId:this.container.container.id,subjectName:"container",type:O.containerRemoved,visibility:!1}),this.globalEvents.interactiveContainerRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-removed"}),this.gameState=5,this.onRemove?.()}fakeRemoveView(e=!1){this.container.isRemoved||this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:e}),this.container.fakeRemove()}destroy(){this.reset(),this.removeView(),this.gameState=6,this.subscription.unsubscribe(),this.branches=[],this.interactiveEvents.containersEventsCallState.setCalled({timestamp:this.container.container.endTime??1/0,id:this.container.container.id})}};var to=(t=[])=>t.reduce((e,r,n)=>{let i=(r?.controls??[]).filter(s=>!ct(s));if(bt(i)){let s=[r.startTime??0,r.endTime??1/0],c={id:r.id,isRemoved:!1};if(!n)e.push({subjects:[c],range:s});else{let o=[],a=-1/0,l=1/0,d=[],m=[];for(let f=0;f<e.length;f++){let y=e[f];if(m.push(...y.subjects),y.range[0]<l&&(l=y.range[0]),y.range[1]>a&&(a=y.range[1]),s[0]>=y.range[0]&&s[1]<=y.range[1])return e[f].subjects.push(c),e;s[0]<y.range[0]&&s[1]>y.range[0]&&(o.push(f),d=d.concat(y.subjects)),s[0]>=y.range[0]&&s[0]<=y.range[1]&&(o.push(f),d=d.concat(y.subjects),s[0]=y.range[0]),s[1]>=y.range[0]&&s[1]<=y.range[1]&&(o.push(f),d=d.concat(y.subjects),s[1]=y.range[1])}if(m.push(c),s[0]<=l&&s[1]>=a)return[{subjects:m,range:s}];o.length&&o.reverse().forEach(f=>{e.splice(f,1)}),e.push({subjects:d.concat([c]),range:s})}}return e},[]).sort((e,r)=>e.range[0]-r.range[0]);var $o=K(Et(),1),Mr=K(gt(),1),_o=K(jo(),1);function Lo(){let t={};function e(){for(let o in t)Object.prototype.hasOwnProperty.call(t,o)&&delete t[o]}function r(o){let a={};for(let l in t)+l<=o&&(a[l]=t[l]);return a}function n(o){let a={};for(let l in t)+l>=o&&(a[l]=t[l]);return a}function i({timestamp:o,priority:a,initiator:l}){if(mr(o)){let d=t[o]??null;if(d&&a&&Re(a,!0)){let m={},f=d[a];return f&&(m={...m,...f}),m=J(m)?null:m,m&&Re(l,!0)?m[l]??null:m}return d}return null}function s({timestamp:o,priority:a,initiator:l}){if(mr(o))if(t[o]){if(a&&Re(a,!0))if(t[o][a]){if(l&&Re(l,!0))if(t[o][a][l]){if(delete t[o][a][l],!J(t[o][a]))return!0}else return!1;if(delete t[o][a],!J(t[o]))return!0}else return!1;return delete t[o]}else return!1;return!1}function c({timestamp:o,priority:a,initiator:l,...d}){t[o]?.[a]?.[l]?t[o][a][l].push({...d}):t[o]?.[a]?t[o][a]={...t[o][a],[l]:[{...d}]}:t[o]?t[o]={...t[o],[a]:{[l]:[{...d}]}}:t[o]={[a]:{[l]:[{...d}]}}}return{map:t,remove:s,add:c,removeAll:e,get:i,getLte:r,getGte:n}}var yu=[w.expect,w.setNextBranch],bu=1/0;function Fo(t,e){let r=t,n,i=Cu(e),s=Lo(),c,o=()=>{y(),h()},a=p=>{s.add.call(void 0,p),E()},l=(p=[])=>{for(let v of p)if(v.action(),(0,$o.default)(yu,v.actionType))break},d=(p=1/0)=>{let v=xt(s.get({timestamp:p,priority:"control"})??{}),b=xt(s.get({timestamp:p,priority:"container"})??{}),g=xt(s.get({timestamp:p,priority:"chapter"})??{});return[...v,...b,...g]},m=p=>{i.isReady(p)&&l(d(p))},f=()=>{l([...xt(s.get({timestamp:1/0,priority:"chapter"})??{})])},y=()=>{n&&(c?.unsubscribe(),n=void 0)},R=p=>{},E=()=>{n||(n=()=>setTimeout(()=>{m(1/0)}),c=r.events.ended$.subscribe(n))},C=p=>{y(),r=p},I=p=>{p.priority==="container"&&i.resetCalled(p.timestamp),s.remove(p)},h=()=>{i.release(),s.removeAll()};return{setPlayer:C,add:a,remove:I,exec:m,execEndOfVideo:f,listen:E,unlisten:y,release:o,containersEventsCallState:i,getPreparedToExecActions:d}}function Cu(t){let e=new Map;return{setCalled:({timestamp:o,id:a})=>{let l=e.get(o);l&&l[a]!==void 0&&(l[a]=!0)},setData:(o=[])=>{for(let a of o){let l=a.endTime??bu,d=e.get(l);e.set(l,{...d,[a.id]:!1})}},resetCalled:o=>{let a=e.get(o);if(a)for(let l in a)a[l]=!1},isReady:o=>{let a=e.get(o);if(!a)return!0;let l=(0,Mr.default)(a);return t?l.some(m=>m):!l.some(m=>!m)},release:()=>e.clear()}}function xt(t){return(0,_o.default)((0,Mr.default)(t)).sort(e=>e.actionType===w.expect?-1:1)}var qo={videoContentHeight:0,videoContentWidth:0},Bo=t=>{let{height:e,width:r}=t.info.intrinsicVideoSize$.getValue()||{};if(!(e&&r))return qo;let{clientHeight:n,clientWidth:i}=t.experimental.element$.getValue()||{};if(!(n&&i))return qo;let s=e/r,c=n/i,o,a;return c>s?(a=i,o=i*s):c<s?(a=n/s,o=n):(a=i,o=n),{videoContentWidth:a,videoContentHeight:o}};var gu=250;function Do(t){let e,r=new ResizeObserver(o=>{s(o),e=s.bind(null,o)});function n(o){let{parentElement:a,player:l}=t();if(a&&l){let{videoContentWidth:d,videoContentHeight:m}=Bo(l);a.style.setProperty("--interactive-content-width",`${d}px`),a.style.setProperty("--interactive-content-height",`${m}px`),a.style.setProperty("--interactive-width",`${o[0].contentRect.width}px`),a.style.setProperty("--interactive-height",`${o[0].contentRect.height}px`)}}function i(){let{parentElement:o}=t();o.removeAttribute("style")}let s=we(o=>{let{fns:a=[]}=t();n(o);for(let l of a)l()},gu);function c(){e=void 0,r.disconnect(),i()}return{resizeObserver:r,calc:()=>{e?.()},release:c}}var Eu=t=>Math.floor(Math.random()*t),Uo=t=>{let e=t.length,r=1/0,n=null;for(;e--;){let i=t[e],s=i.weight??1;s<r&&(r=s,n=i)}return n},Go=t=>{let e=t.length,r=-1/0,n=null;for(;e--;){let i=t[e],s=i.weight??0;s>r&&(r=s,n=i)}return n};var zo=t=>{let e=t.length,r=Eu(e);return t[r]},Ho=1,Wo=t=>{let e=0;for(let n=0;n<t.length;++n)e+=t[n].weight??Ho;let r=Math.random()*e;e=0;for(let n=0;n<t.length-1;++n)if(e+=t[n].weight??Ho,e>=r)return t[n];return t[t.length-1]};var Ko={shouldOpenNow:!0,isDetachContainer:!0},Qo="after-expect";var Nr=(t,e=!1)=>({...t,args:e?{...t.args,...Ko}:{...Ko,...t.args}}),Zo=({globalEventEmitter:t,globalEvents:e,player:r,interactiveEvents:n})=>{let i={isExpect:!1},s=()=>{i.isExpect&&(i.isExpect=!1)},c=({action:h,controlType:p,controlId:v,containerId:b,branches:g=[],onEvent:T,isEOV:A=()=>!1,isDisabled:k=()=>!1})=>{let S=Nr(h,A()),V={timestamp:1/0,priority:"control",initiator:v,actionType:S.type},q=k(),B=t.emit.bind(t,x.interactives,{subjectId:v,subjectType:p,subjectName:"control",type:q?O.actionChoiceCanceled:O.actionChoice,actionType:h.type,payload:{invokeImmediately:S.args.shouldOpenNow,containerId:b,...S.args}}),D=()=>{e.interactiveActionChoice$.next({subjectId:v,subjectType:p,subjectName:"control",type:q?"action-choice-canceled":"action-choice",actionType:h.type,payload:{invokeImmediately:S.args.shouldOpenNow,containerId:b,...S.args}})};if(q){B(),D();return}switch(S.type.trim().toLowerCase()){case w.setNextBranch.trim().toLowerCase():{let W=g.find(te=>te.id===S.args.branchId);if(!W)return;T(S.args.isDetachContainer,y.bind(null,{subjectId:v,subjectName:"control"})),B(),D(),S.args.shouldOpenNow?E({subjectId:v,subjectName:"control",subjectType:p,action:S,payload:{chapterId:W.chapterId,autoSelect:!1}}):n.add({...V,action:E.bind(null,{subjectId:v,subjectName:"control",subjectType:p,action:S,payload:{chapterId:W.chapterId,autoSelect:!1}})});return}case w.continuePlayback.trim().toLowerCase():{T(S.args.isDetachContainer,y.bind(null,{subjectId:v,subjectName:"control"})),B(),D(),S.args.shouldOpenNow?R({subjectId:v,subjectName:"control",subjectType:p,action:h}):n.add({...V,action:R.bind(null,{subjectId:v,subjectName:"control",subjectType:p,action:h})});return}case w.openURI.trim().toLowerCase():{T(S.args.isDetachContainer,y.bind(null,{subjectId:v,subjectName:"control"})),B(),D(),S.args.shouldOpenNow?I({subjectId:v,subjectName:"control",subjectType:p,action:S,payload:{URI:h.args.uri}}):n.add({...V,action:I.bind(null,{subjectId:v,subjectName:"control",subjectType:p,action:S,payload:{URI:h.args.uri}})});return}default:{let W="Unexpected control event",te=new M(1,1,{message:W});d(te,W);return}}},o=({action:h,container:{id:p,endTime:v},branches:b=[],isEOV:g=!1,autoSelected:T=!1})=>{let A=Nr(h,g),k={timestamp:!A.args.shouldOpenNow||g?1/0:v??1/0,priority:"container",initiator:p,actionType:A.type},S=t.emit.bind(t,x.interactives,{subjectId:p,subjectName:"container",type:O.actionChoice,actionType:A.type,payload:{invokeImmediately:A.args.shouldOpenNow,...A.args}}),V=()=>{e.interactiveActionChoice$.next({subjectId:p,subjectName:"container",type:"action-choice",actionType:A.type,payload:{invokeImmediately:A.args.shouldOpenNow,...A.args}})};switch(A.type.trim().toLowerCase()){case w.setNextBranch.trim().toLowerCase():{let q=b.find(B=>B.id===A.args.branchId);if(!q)return;S(),V(),n.add({...k,action:E.bind(null,{subjectId:p,subjectName:"container",action:A,payload:{chapterId:q.chapterId,autoSelect:T}})});return}case w.setMaxWeightBranch.trim().toLowerCase():return;case w.setMinWeightBranch.trim().toLowerCase():return;case w.setRandomBranch.trim().toLowerCase():return;case w.setWeightlessRandomBranch.trim().toLowerCase():return;case w.continuePlayback.trim().toLowerCase():{S(),V(),n.add({...k,action:R.bind(null,{subjectId:p,subjectName:"container",action:A})});return}case w.openURI.trim().toLowerCase():{S(),V(),n.add({...k,action:I.bind(null,{subjectId:p,subjectName:"container",action:A,payload:{URI:h.args.uri}})});return}default:{let q="Unexpected container event",B=new M(1,1,{message:q});d(B,q);return}}};function a({container:h,branches:p,isEOV:v=!1}){let b=Ir(h.events);if(b){let g=Nr(b.action,v);t.emit(x.interactives,{subjectId:h.id,subjectName:"container",type:O.actionChoice,actionType:g.type,payload:{invokeImmediately:g.args.shouldOpenNow,...g.args}}),e.interactiveActionChoice$.next({subjectId:h.id,subjectName:"container",type:"action-choice",actionType:g.type,payload:{invokeImmediately:g.args.shouldOpenNow,...g.args}}),n.add({timestamp:v?1/0:h.endTime??1/0,priority:"container",initiator:h.id,actionType:w.expect,action:f.bind(null,{subjectId:h.id,subjectName:"container"})}),i.isExpect=!0}else for(let g of h.events??[])o({action:g.action,container:h,branches:p,isEOV:v})}let l=({chapterId:h,action:p,branches:v=[]})=>{let b=t.emit.bind(t,x.interactives,{subjectId:h,subjectName:"chapter",type:O.actionChoice,actionType:p.type,payload:p.args}),g=()=>{e.interactiveActionChoice$.next({subjectId:h,subjectName:"chapter",type:"action-choice",actionType:p.type,payload:p.args})};switch(p.type.trim().toLowerCase()){case w.setNextBranch.trim().toLowerCase():{let T=v.find(A=>A.id===p.args.branchId);return T?.chapterId?(b(),g(),E.bind(null,{subjectId:h,subjectName:"chapter",action:p,payload:{chapterId:T.chapterId,autoSelect:!0}})):void 0}case w.setWeightlessRandomBranch.trim().toLowerCase():{let T=zo(v);return T?.chapterId?(b(),g(),E.bind(null,{subjectId:h,subjectName:"chapter",action:p,payload:{chapterId:T.chapterId,autoSelect:!0}})):void 0}case w.setRandomBranch.trim().toLowerCase():{let T=Wo(v);return T?.chapterId?(b(),g(),E.bind(null,{subjectId:h,subjectName:"chapter",action:p,payload:{chapterId:T.chapterId,autoSelect:!0}})):void 0}case w.setMaxWeightBranch.trim().toLowerCase():{let T=Go(v);return T?.chapterId?(b(),g(),E.bind(null,{subjectId:h,subjectName:"chapter",action:p,payload:{chapterId:T.chapterId,autoSelect:!0}})):void 0}case w.setMinWeightBranch.trim().toLowerCase():{let T=Uo(v);return T?.chapterId?(b(),g(),E.bind(null,{subjectId:h,subjectName:"chapter",action:p,payload:{chapterId:T.chapterId,autoSelect:!0}})):void 0}case w.continuePlayback.trim().toLowerCase():return b(),g(),R.bind(null,{subjectId:h,subjectName:"chapter",action:p});case w.openURI.trim().toLowerCase():return b(),g(),I.bind(null,{subjectId:h,subjectName:"chapter",action:p,payload:{URI:p.args.uri}});default:{let T="Unexpected chapter event",A=new M(1,1,{message:T});d(A,T);return}}};function d(h,p){console.error(p),e.error$.next(h),t.emit(x.errors,h)}function m(h){let p=Ir(h.events);if(p){if(z(h))return;t.emit(x.interactives,{subjectId:h.id,subjectName:"chapter",type:O.actionChoice,actionType:p.action.type,payload:p.action.args}),e.interactiveActionChoice$.next({subjectId:h.id,subjectName:"chapter",type:"action-choice",actionType:p.action.type,payload:p.action.args}),n.add({timestamp:1/0,priority:"chapter",initiator:h.id,actionType:w.expect,action:f.bind(null,{subjectId:h.id,subjectName:"chapter"})})}else h.events?.forEach(v=>{let b=l({chapterId:h.id,action:v.action,branches:h.branches});b&&n.add({timestamp:1/0,priority:"chapter",initiator:h.id,actionType:v.action.type,action:b})})}let f=({subjectId:h,subjectName:p})=>{r.pause(),t.emit(x.interactives,{subjectId:h,subjectName:p,type:O.actionExecution,actionType:w.expect}),e.interactiveActionExecution$.next({subjectId:h,subjectName:p,type:"action-execution",actionType:w.expect})},y=({subjectId:h,subjectName:p})=>{r.info.isEnded$.getValue()?n.execEndOfVideo():r.play(),t.emit(x.interactives,{subjectId:h,subjectName:p,type:O.actionExecution,actionType:Qo}),e.interactiveActionExecution$.next({subjectId:h,subjectName:p,type:"action-execution",actionType:Qo})},R=({subjectId:h,subjectName:p,subjectType:v,action:b})=>{t.emit(x.interactives,{subjectId:h,subjectName:p,subjectType:v,type:O.actionExecution,actionType:b.type}),e.interactiveActionExecution$.next({subjectId:h,subjectName:p,subjectType:v,type:"action-execution",actionType:b.type})},E=({subjectId:h,subjectName:p,subjectType:v,action:b,payload:g})=>{g.behaviour="change-chapter",t.emit(x.interactives,{subjectId:h,subjectName:p,subjectType:v,type:O.actionExecution,actionType:b.type,payload:g}),e.interactiveActionExecution$.next({subjectId:h,subjectName:p,subjectType:v,type:"action-execution",actionType:b.type,payload:g})},C=({subjectId:h,subjectName:p,subjectType:v,action:b,payload:g})=>{g.behaviour="change-manifest",t.emit(x.interactives,{subjectId:h,subjectName:p,subjectType:v,type:O.actionExecution,actionType:b.type,payload:g}),e.interactiveActionExecution$.next({subjectId:h,subjectName:p,subjectType:v,type:"action-execution",actionType:b.type,payload:g})},I=({subjectId:h,subjectName:p,subjectType:v,action:b,payload:g})=>{if(!g.URI)return;let T=window.open(g.URI,"_blank","noopener,noreferrer");T&&(T.opener=null),t.emit(x.interactives,{subjectId:h,subjectName:p,subjectType:v,type:O.actionExecution,actionType:b.type}),e.interactiveActionExecution$.next({subjectId:h,subjectName:p,subjectType:v,type:"action-execution",actionType:b.type})};return{onControlEvent:c,onContainerEvent:o,onChapterEvent:l,onExpectEvent:f,expectEventHandler:y,setManifestChapterEvents:m,setManifestContainerEvents:a,stopExpect:s,state:i}};var $r=K(dr(),1);import{Subscription as wu,Subject as Lr,ValueSubject as $e}from"@vkontakte/videoplayer-shared";var jr=(t,e)=>{let r={};return t.map(n=>{if(!r[n]){let i=e.chapters.find(c=>c.id===n);if(!i)return null;let s=e.media.videos.find(c=>i.videoId===c.id);if(!s)return null;r[n]=Jo(s)}return r[n]}).filter(Boolean)},Tu=t=>{for(let e of t.variants)if(xu(e)&&e.payload)return e.payload.id},xu=t=>!!(t.type==="custom"&&t.payload&&t.payload.type==="vk"),Jo=t=>{let e=Tu(t);if(!e)return null;let r=e.split("_").pop();return r?parseInt(r,10):null},Su=(t,e)=>{for(let r of t.media.videos)if(e===Jo(r)){for(let n of t.chapters)if(n.videoId===r.id)return n.id;return}},ea=(t,e)=>t.reduce((r,n)=>{let i=Su(e,n);return i?[...r,i]:r},[]);var _e=class{constructor({globalEventEmitter:e,videoId:r,interactiveController:n,historyApi:i,settings:s}){this.state={history$:new $e([]),hasPrevChapter$:new $e(!1),prevChapter$:new $e(null),isInitialChapter$:new $e(!1),isGoBackLimited$:new $e(!1)};this.#r=null;this.#o=!1;this.#e=null;this.#p=null;this.events={inited$:new Lr,destroyed$:new Lr,error$:new Lr};this.#n=null;this.#i=null;this.#t=null;this.#a=new wu;this.#c=!1;this.#l=0;this.#n=r,this.#t=e,this.#i=n,this.#r=i,this.#s=s,this.state.history$&&this.#a&&this.#a?.add(this.state.history$.subscribe(c=>{this.state.prevChapter$.next((0,$r.default)(c,-2)||null),this.state.hasPrevChapter$.next(c.length>1),this.state.isInitialChapter$.next(this.getInitialChapterId()===this.#e?.metadata?.initChapterId),this.state.isGoBackLimited$.next(this.#l===this.#s.maxLength-1)}))}#r;#s;#o;#e;#p;#n;#i;#t;#a;#c;#l;async setManifest(e){if(!this.#i||!this.#t)return;this.#e=e,await this.getProjectHistory();let r=this.getInitialChapterId();await this.#i.setChapter({chapterId:r,pushToHistory:!1}),this.#o||(this.#o=!0,this.events.inited$.next({initChapterId:r}))}get inited(){return this.#o}async updateHistory(e,r=!0){if(!this.#e)return;this.#c?(this.#c=!1,this.#l++):this.#l=0;let n=this.#e,i=e.length-this.#s.maxLength,s=i>0?e.slice(i):e,c=jr(s,n);if(this.#p=c,this.state.history$.next(s),!(!r||!this.#r||!this.#n))try{await this.#r.save(this.#n,c)}catch{let a=new M(1,5,"Unable to save interactive history");this.events.error$.next(a),this.#t?.emit(x.errors,a)}}async goBack(){if(!this.state||!this.#i){let n=new M(1,5,"Unable to save interactive history");return this.events.error$.next(n),this.#t?.emit(x.errors,n)}this.#c=!0;let e=this.state.history$.getValue().slice(0,-1),r=e.pop();this.state.history$.next(e),await this.#i.setChapter({chapterId:r,playPrev:!0})}async getProjectHistory(){if(!this.#e||!this.#n)return;let e=this.#e,r=[this.getInitialVideoId()];if(this.#r)try{let i=await this.#r.get(this.#n);i.length&&(r=i)}catch{let s=new M(1,5,"Error while trying to fetch data");this.events.error$.next(s),this.#t?.emit(x.errors,s)}let n=ea(r,e);this.state.history$.next(n)}getInitialChapterId(){let e=this.state.history$.getValue();return(0,$r.default)(e,-1)||this.#s.initChapterId||this.#e?.metadata.initChapterId}getInitialVideoId(){if(this.#e){let e=this.getInitialChapterId();return jr([e],this.#e).pop()}return null}destroy(){this.#n=null,this.#r=null,this.#i=null,this.#a?.unsubscribe(),this.#a=null,this.#o=!1,this.#t?.emit(x.historyDestroyed),this.events.destroyed$.next(),this.#t=null}};var St=class{constructor(){this._prevSizeId=0;this.rootElement=document.createElement("canvas")}clear(){this.rootElement.getContext("2d")?.clearRect(0,0,this.rootElement.width,this.rootElement.height)}isImageDrawn(){let e=this.rootElement.getContext("2d")?.getImageData(0,0,this.rootElement.width,this.rootElement.height);if(!e)return!1;let r=e.data,n=r.length;for(let i=3;i<n;i+=40)if(r[i]!==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(){this.canvasImgSrc&&this.rootElement.getContext("2d")?.drawImage(this.canvasImgSrc,0,0,this.rootElement.width,this.rootElement.height)}async updateCanvasDimensions(e,r=!1){let n=e.width+e.height;if(this._prevSizeId===n)return;let i;r&&(i=await this.save()),this.rootElement.width=e.width,this.rootElement.height=e.height,r&&i&&this.restore(i),this._prevSizeId=n}async save(){let e=this.rootElement.toDataURL("image/jpeg",1),r=new Image;return r.crossOrigin="anonymous",r.src=e,await r.decode(),r}restore(e){this.rootElement&&this.rootElement.getContext("2d")?.drawImage(e,0,0,this.rootElement.width,this.rootElement.height)}};var wt=class{constructor({parentElement:e,endOffsetMs:r=250,onError:n}){this.currentVideoDurationMs=1/0;this._containerTimeFrameShouldReceived=!1;this._endTimeFrameReceived=!1;this._shouldCallSkip=!1;this.onEachTick=e=>{let r=e??this.lastFrameCanvas.canvasImgSrc.currentTime*1e3,n=this.isChapterEndTime(r);if(this.isContainerTime(r))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,78 +11,26 @@ var wa=Object.create;var Yr=Object.defineProperty;var Ra=Object.getOwnPropertyDe
|
|
|
11
11
|
height: var(--interactive-height);
|
|
12
12
|
background-color: var(--black);
|
|
13
13
|
visibility: hidden;
|
|
14
|
-
`,this.lastFrameCanvas=new
|
|
14
|
+
`,this.lastFrameCanvas=new St,this.endOffsetMs=r,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),e.prepend(this.rootElement)}destroy(){this.hide(),this.reset(),this._callbacks=void 0,this.lastFrameCanvas.destroy(),this.rootElement.remove()}setVideoDuration(e){this.currentVideoDurationMs=e}setVideoElement(e){this.lastFrameCanvas.setCanvasImageSource(e)}setCurrentChapter(e){this.currentChapter=e}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}async updateCanvasDimensions(e=!1){this._containerTimeFrameShouldReceived||this._endTimeFrameReceived||(e=!1);let r=getComputedStyle(this.rootElement),n={width:parseInt(r.getPropertyValue("--interactive-content-width"),10),height:parseInt(r.getPropertyValue("--interactive-content-height"),10)};try{this.lastFrameCanvas.updateCanvasDimensions(n,e)}catch(i){this._onError(i)}}draw(){(this._containerTimeFrameShouldReceived||!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived)&&this.lastFrameCanvas.draw()}isChapterEndTime(e){return this.currentVideoDurationMs&&e>=this.currentVideoDurationMs-this.endOffsetMs}isContainerTime(e){if(this.currentChapter)return this.currentChapter.containers.some(r=>r.controls?.length&&e>=(r.startTime??0)&&e<=Math.min(r.endTime??1/0,this.currentVideoDurationMs-this.endOffsetMs))}reset(){this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1}_onError(e){this._callbacks?.onError?.(e)}};function
|
|
20
|
-
.${
|
|
19
|
+
`,this.rootElement.prepend(this.lastFrameCanvas.rootElement),e.prepend(this.rootElement)}destroy(){this.hide(),this.reset(),this._callbacks=void 0,this.lastFrameCanvas.destroy(),this.rootElement.remove()}setVideoDuration(e){this.currentVideoDurationMs=e}setVideoElement(e){this.lastFrameCanvas.setCanvasImageSource(e)}setCurrentChapter(e){this.currentChapter=e}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}async updateCanvasDimensions(e=!1){this._containerTimeFrameShouldReceived||this._endTimeFrameReceived||(e=!1);let r=getComputedStyle(this.rootElement),n={width:parseInt(r.getPropertyValue("--interactive-content-width"),10),height:parseInt(r.getPropertyValue("--interactive-content-height"),10)};try{this.lastFrameCanvas.updateCanvasDimensions(n,e)}catch(i){this._onError(i)}}draw(){(this._containerTimeFrameShouldReceived||!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived)&&this.lastFrameCanvas.draw()}isChapterEndTime(e){return this.currentVideoDurationMs&&e>=this.currentVideoDurationMs-this.endOffsetMs}isContainerTime(e){if(this.currentChapter)return this.currentChapter.containers.some(r=>r.controls?.length&&e>=(r.startTime??0)&&e<=Math.min(r.endTime??1/0,this.currentVideoDurationMs-this.endOffsetMs))}reset(){this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1}_onError(e){this._callbacks?.onError?.(e)}};function ta(t=0){return new Promise(e=>{setTimeout(()=>{e(0)},t)})}var Au=`
|
|
20
|
+
.${$.common} {
|
|
21
21
|
opacity: 1;
|
|
22
22
|
visibility: visible;
|
|
23
23
|
transition: opacity var(--interactive-transition-1);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
.${
|
|
26
|
+
.${$.disabled} {
|
|
27
27
|
opacity: 0.5;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
.${
|
|
30
|
+
.${$.hidden} {
|
|
31
31
|
visibility: hidden;
|
|
32
32
|
}
|
|
33
|
-
`,
|
|
34
|
-
.${b.blinkAnim} {
|
|
35
|
-
animation-duration: 2001ms;
|
|
36
|
-
animation-iteration-count: infinite;
|
|
37
|
-
animation-timing-function: cubic-bezier(0.3, 0.3, 0.3, 1);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.${b.blinkAnimButton} {
|
|
41
|
-
animation-name: blinking-button;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.${b.blinkAnimArea} {
|
|
45
|
-
animation-name: blinking-area;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
@keyframes blinking-area {
|
|
49
|
-
0%, 100% {
|
|
50
|
-
opacity: 1;
|
|
51
|
-
}
|
|
52
|
-
50% {
|
|
53
|
-
opacity: var(--interactive-area-hover-opacity);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
@keyframes blinking-button {
|
|
58
|
-
0%, 100% {
|
|
59
|
-
opacity: 1;
|
|
60
|
-
}
|
|
61
|
-
50% {
|
|
62
|
-
opacity: var(--interactive-button-hover-opacity);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
`,Zu=`
|
|
66
|
-
.${V.common} {
|
|
67
|
-
position: absolute;
|
|
68
|
-
height: 0;
|
|
69
|
-
width: 0;
|
|
70
|
-
top: 0;
|
|
71
|
-
left: 0;
|
|
72
|
-
pointer-events: none;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
.${V.animation} {
|
|
76
|
-
animation-duration: 2001ms;
|
|
77
|
-
animation-iteration-count: infinite;
|
|
78
|
-
animation-timing-function: cubic-bezier(0.3, 0.3, 0.3, 1);
|
|
79
|
-
animation-name: blinking-button;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
.${V.disabled} {
|
|
83
|
-
animation: none;
|
|
84
|
-
}
|
|
85
|
-
`,Ju=`
|
|
33
|
+
`,Ru=`
|
|
86
34
|
.interactive-chapter {
|
|
87
35
|
position: absolute;
|
|
88
36
|
top: 0;
|
|
@@ -90,60 +38,23 @@ var wa=Object.create;var Yr=Object.defineProperty;var Ra=Object.getOwnPropertyDe
|
|
|
90
38
|
font-family: inherit;
|
|
91
39
|
|
|
92
40
|
--interactive-transition-1: 100ms ease-in-out;
|
|
93
|
-
--interactive-transition-2: 400ms cubic-bezier(0.4, 0, 0.2, 1);
|
|
94
|
-
--interactive-button-hover-opacity: 0.8;
|
|
95
|
-
--interactive-area-hover-opacity: 0;
|
|
96
41
|
}
|
|
97
42
|
|
|
98
|
-
${
|
|
43
|
+
${Au}
|
|
99
44
|
|
|
100
|
-
.${
|
|
45
|
+
.${P.common} {
|
|
101
46
|
display: flex;
|
|
102
47
|
width: 100%;
|
|
103
48
|
height: 100%;
|
|
104
49
|
font-family: inherit;
|
|
105
|
-
|
|
106
|
-
position: relative;
|
|
107
|
-
isolation: isolate;
|
|
108
|
-
opacity: 1;
|
|
109
|
-
|
|
110
|
-
box-shadow: none;
|
|
111
50
|
}
|
|
112
51
|
|
|
113
|
-
.${
|
|
52
|
+
.${P.disabled} {
|
|
114
53
|
cursor: default;
|
|
115
54
|
}
|
|
116
55
|
|
|
117
|
-
.${
|
|
118
|
-
.${
|
|
56
|
+
.${P.button},
|
|
57
|
+
.${P.area} {
|
|
119
58
|
cursor: pointer;
|
|
120
59
|
}
|
|
121
|
-
|
|
122
|
-
.${b.button} {
|
|
123
|
-
transition: opacity var(--interactive-transition-2);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
.${b.area} {
|
|
127
|
-
transition: border-color var(--interactive-transition-1), box-shadow var(--interactive-transition-1), opacity var(--interactive-transition-2);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
.${w.common}.${w.disabled} .${b.button},
|
|
131
|
-
.${w.common}.${w.disabled} .${b.area} {
|
|
132
|
-
animation: none;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
.${w.common}:not(.${w.disabled}) .${b.button}:not(.${b.selected}):not(.${b.blinkAnim}):hover,
|
|
136
|
-
.${w.common}:not(.${w.disabled}) .${b.button}:not(.${b.selected}):not(.${b.blinkAnim}):focus-visible {
|
|
137
|
-
opacity: var(--interactive-button-hover-opacity);
|
|
138
|
-
animation: none;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
.${w.common}:not(.${w.disabled}) .${b.area}:not(.${b.selected}):not(.${b.blinkAnim}):hover,
|
|
142
|
-
.${w.common}:not(.${w.disabled}) .${b.area}:not(.${b.selected}):not(.${b.blinkAnim}):focus-visible {
|
|
143
|
-
opacity: var(--interactive-area-hover-opacity);
|
|
144
|
-
animation: none;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
${Yu}
|
|
148
|
-
${Zu}
|
|
149
|
-
`,ba=t=>{let e=document.createElement("style");e.textContent=Ju,t.prepend(e)};var eh=typeof window>"u",th=typeof OffscreenCanvas<"u";function Ca(){return eh?th?new OffscreenCanvas(1,1):null:document.createElement("canvas")}function ga(t){return(t[0]*299+t[1]*587+t[2]*114)/1e3<128}var Wr=[0,0,0,0],Ea=1,rh="AverageColor: ";function $t(t){return Error(rh+t)}function Kr(t){let e=window.getComputedStyle(t),r=parseFloat(e.getPropertyValue("--interactive-content-width"))||0,n=parseFloat(e.getPropertyValue("--interactive-content-height"))||0;return{width:r,height:n}}var Ue=class{constructor(){this.canvas=null;this.ctx=null}getColorAsync(e,r){let n=this.getColor(e,r);return n.error?Promise.reject(n.error):Promise.resolve(n)}getColor(e,r){let n={...r,step:r.step||Ea,defaultColor:r.defaultColor??Wr,debug:r.debug??!1};if(!this.canvas&&(this.canvas=Ca(),!this.canvas))return this.prepareResult(n.defaultColor,$t("Failed to create canvas"));if(!this.ctx){if(this.ctx=this.canvas.getContext("2d",{willReadFrequently:!0}),!this.ctx)return this.prepareResult(n.defaultColor,$t("Failed to create context of the canvas"));this.ctx.imageSmoothingEnabled=!1}this.canvas.width=n.width,this.canvas.height=n.height;try{this.ctx.clearRect(0,0,n.width,n.height),this.ctx.drawImage(e,0,0,n.width,n.height);let i=this.ctx.getImageData(0,0,n.width,n.height).data,o=this.getColorFromArray(i,n);return this.prepareResult(o)}catch(i){return n.debug&&console.error(i),this.prepareResult(n.defaultColor,$t("Failed on getting average color"))}}getColorFromArray(e,r){let i=e.length;if(i<4)return Wr;let o=i-i%4,l=r.step*4;return this.sqrtAlgorithm(e,o,{defaultColor:r.defaultColor,step:l})}sqrtAlgorithm(e,r,n){let i=0,o=0,l=0,s=0,a=0,c=n.step;for(let d=0;d<r;d+=c){let m=e[d],f=e[d+1],y=e[d+2],k=e[d+3];i+=m*m*k,o+=f*f*k,l+=y*y*k,s+=k,a++}return s?[Math.round(Math.sqrt(i/s)),Math.round(Math.sqrt(o/s)),Math.round(Math.sqrt(l/s)),Math.round(s/a)]:n.defaultColor}prepareResult(e,r){let n=`rgba(${e[0]}, ${e[1]}, ${e[2]}, ${e[3]/255})`,i=ga(e);return{rgba:n,isDark:i,error:r}}destroy(){this.canvas&&(this.canvas.width=1,this.canvas.height=1,this.canvas=null),this.ctx=null}};var Ta=Object.freeze({lang:oh.RU,loaders:{},graph:!1,initSeamless:!1,lastFrame:!1,permanentTextControls:!0,interactiveTimeOpenUri:!1,config:{historyMaxLength:100,noInteractionEventTimeout:3e4},animationsFeatureToggles:{areaControlFrameBasedShadow:!1,controlsExpectTimeBlinkAnimation:!1}});function ah(){let t=document.createElement("div");return t.classList.add("interactive-chapter"),t}var Lt=class{constructor(e){this.playerSubscriptions=new Qr;this.subscriptions=new Qr;this.globalEventEmitter=new bt;this.animation=new Ct;this.seekToInteractiveController=new Me;this.endedRanges=new Set;this.gameControllers=[];this.rootElement=ah();this.factories=new Map([["choice",ot]]);this.isFirstChapterFetched=!1;this.player=null;this.interactiveEvents=null;this.selectBranches=null;this.seamlessController=null;this.seamlessControllerSubs=new Qr;this.graph=null;this.lastFrame=null;this.frameAverageColor=null;this.appState=0;this.state={prevChapter$:new j(null),isInitialChapter$:new j(!1),isFirstChapter$:new j(!0),isEndChapter$:new j(!1),isInteractiveExpectation$:new j(!1),isReplay$:new j(!1),calledByInteractive$:new j(!1),lastChapterChangeWasInitiatedByInteractive$:new j(!1),disabledControls$:new j(!1),interactiveRanges$:new j([]),isInteractiveTime$:new j(!1),statistics$:new j(null),isSeekable$:new j(!1)};this.events={noInteraction$:new F,graphVisibilityChanged$:new F,watchAgainIsClicked$:new F,chapterChanged$:new F,playerChanged$:new F,error$:new F,eachTick$:new F,manifestChanged$:new F,interactiveRangeEnded$:new F,interactiveContainerRemoved$:new F,interactiveContainerFakeRemoved$:new F,interactiveActionExecution$:new F,interactiveActionChoice$:new F,interactiveVisibilityChanged$:new F};this.emitErrorEvent=e=>{this.events.error$.next(e),this.globalEventEmitter.emit(T.errors,e)};this.clearHistoryIfEnded=()=>{let e=this.player?.info.isEnded$.getValue(),r=this.state.isInteractiveExpectation$.getValue(),{chapter:n}=this.getCurrentChapter();e&&n&&Q(n)&&!r&&this.historyController.updateHistory([]),window.removeEventListener("beforeunload",this.clearHistoryIfEnded)};this.handleSeamlessPlayerChanged=e=>{if(!e)return;let{statistics:r,...n}=e;if(r){let{statSubscription:i,oneStat:o}=r;i.add(o.attachToInteractive(this.getStatEvents())),this.state.statistics$.next(r)}this.state.isReplay$.getValue()&&this.state.isReplay$.next(!1),this.events.playerChanged$.next(n),this.globalEventEmitter.emit(T.playerChanged,n)};this.onPlaybackStarted=()=>{this.resizeManager?.calc(),this.animation.requestAnimation()};this.destroyGameControllers=(e=!0)=>{this.gameControllers.forEach(r=>{!e&&r.isPermanentText||(this.animation.removeFn(r.whilePlaying),r.destroy())})};this.completeInteractiveRange=e=>{let{interactiveRanges$:r}=this.state,i=r.getValue().map(o=>({...o,subjects:o.subjects.filter(l=>l.id!==e)}));r.next(i)};this.clearNoInteractionTimeout=()=>{this.noInteractionTimeout&&(clearTimeout(this.noInteractionTimeout),this.noInteractionTimeout=void 0)};this._options={...Ta,...e,config:{...Ta.config,...e.config}},this._options.animationsFeatureToggles?.controlsExpectTimeBlinkAnimation&&this.rootElement.append(cn()),this._options.parentElement.append(this.rootElement),this.historyController=new He({interactiveController:this,globalEventEmitter:this.globalEventEmitter,videoId:this._options.projectInfo?.videoId,historyApi:this._options.historyApi,settings:{maxLength:this._options.config.historyMaxLength,initChapterId:this._options.initChapterId}}),this._options.lastFrame&&(this.lastFrame=new Mt({parentElement:this._options.parentElement,onError:i=>{let o=new L(1,6,i);this.emitErrorEvent(o)}})),ba(this._options.parentElement),this.subscriptions.add(Ia(this.rootElement,"mousedown").subscribe(i=>i.stopPropagation())).add(Ia(this.rootElement,"mouseup").subscribe(i=>i.stopPropagation())),this.manifestController=new fe(this._options.loaders,i=>{let o=new L(1,3,i);this.emitErrorEvent(o)});let n=[];this._options.lastFrame&&n.push(()=>{this.lastFrame?.updateCanvasDimensions(!0)}),n.push(()=>{let i=this.state.isInteractiveTime$.getValue();for(let o of this.gameControllers)o.onResize(i)}),this.resizeManager=ia(()=>({player:this.player,parentElement:this._options.parentElement,fns:n})),this._options.graph&&(this.graph=new Ve({root:this._options.parentElement,lang:this._options.lang,onOpenPreviewClick:i=>{this.setChapter({chapterId:i}),this.globalEventEmitter.emit(T.graph,{type:_e.watchAgainClicked,chapterId:i}),this.events.watchAgainIsClicked$.next(i)},onError:i=>{let o=new L(1,2,{message:i});this.emitErrorEvent(o)}})),this._options.animationsFeatureToggles?.areaControlFrameBasedShadow&&(this.frameAverageColor=new Ue),this.initSubscriptions()}initSubscriptions(){this.playerSubscriptions.add(this.historyController.events.inited$.subscribe(async({videosInfo:e=[]})=>{this._options.initSeamless&&(await this.initSeamless(),this.updateGraphVideosInfo(e))})),this.subscriptions.add(this.events.interactiveContainerRemoved$.subscribe(({subjectId:e})=>{this.completeInteractiveRange(e)})).add(this.events.interactiveContainerFakeRemoved$.subscribe(({subjectId:e,removeAllOpenURI:r})=>{this.handleFakeRemoval(e,r)})).add(this.events.interactiveActionExecution$.subscribe(e=>{if(this.state.calledByInteractive$.next(!0),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!0),e.payload?.behaviour==="change-chapter"){let{chapterId:r}=e.payload;this.setChapter({chapterId:r}),this.state.isFirstChapter$.getValue()&&this.state.isFirstChapter$.next(!1)}else if(e.payload?.behaviour==="change-manifest"){let{manifestURL:r}=e.payload;r&&this.setManifest(r)}e.actionType==="expect"?(this.state.isInteractiveExpectation$.next(!0),this.updateControlsShadowStyles({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!0}),this.toggleBlinkAnimation({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!0})):e.actionType==="after-expect"&&(this.state.isInteractiveExpectation$.next(!1),this.updateControlsShadowStyles({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!1}),this.toggleBlinkAnimation({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!1}))})).add(this.events.manifestChanged$.subscribe(()=>{this.state.calledByInteractive$.next(!1),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)})).add(this.events.interactiveActionChoice$.subscribe(({type:e,subjectName:r,payload:n})=>{e!=="action-choice"||r==="chapter"||"invokeImmediately"in n&&n.invokeImmediately||this.destroyGameControllers(!1)}))}async initSeamless(){this.seamlessController=Fr(this),this.seamlessControllerSubs.add(this.seamlessController.activePlayerChanged.subscribe(this.handleSeamlessPlayerChanged)),await this.seamlessController.init()}handlePositionChange(e){(!this.graph||this.graph.isHidden)&&this.checkIfSeekable();let r=e*1e3,i=this.getInteractiveRanges().reverse().find(({range:o})=>r>=o[1]);if(i){let o=i.range.join("-");this.endedRanges.has(o)||(this.endedRanges.add(o),this.globalEventEmitter.emit(T.interactives,{type:P.rangeEnded,payload:i,visibility:!0}),this.events.interactiveRangeEnded$.next({type:"range-ended",payload:i}))}}registerVideoEvents(){this.player&&(window.removeEventListener("beforeunload",this.clearHistoryIfEnded),this.playerSubscriptions.unsubscribe(),window.addEventListener("beforeunload",this.clearHistoryIfEnded),this.playerSubscriptions.add(this.player.events.started$.pipe(sh()).subscribe(this.onPlaybackStarted)).add(this.player.events.playing$.subscribe(this.animation.requestAnimation)).add(this.player.events.willPause$.subscribe(this.animation.cancelAnimation)).add(this.player.info.position$.subscribe(this.handlePositionChange.bind(this))).add(this.manifestController.prevChapter$.subscribe(e=>this.state.prevChapter$.next(e))).add(ih({position:this.player.info.position$,interactiveRanges:this.state.interactiveRanges$,isInteractiveExpectation:this.state.isInteractiveExpectation$}).subscribe(({position:e,interactiveRanges:r,isInteractiveExpectation:n})=>{let i;if(n)i=!0;else{let a=e*1e3;i=!!r.find(({range:[d,m],subjects:f})=>d<a&&a<m&&f.some(y=>!y.isRemoved)&&f.length)}i!==this.state.isInteractiveTime$.getValue()&&this.state.isInteractiveTime$.next(i);let o=!!this.noInteractionTimeout,s=this.player?.info.playbackState$.getValue()==="playing"||n;i&&!o&&s?this.noInteractionTimeout=window.setTimeout(()=>{this.events.noInteraction$.next()},this._options.config.noInteractionEventTimeout):o&&!s&&this.clearNoInteractionTimeout()})),this.playerSubscriptions.add(this.historyController.events.error$.subscribe(this.events.error$)),this._options.lastFrame&&this.playerSubscriptions.add(this.player.info.duration$.subscribe(e=>{this.lastFrame?.setVideoDuration(e*1e3)})).add(this.player.experimental.element$.subscribe(e=>{e&&this.lastFrame?.setVideoElement(e)})).add(this.player.events.firstFrame$.subscribe(()=>{this.lastFrame?.reset(),setTimeout(()=>{this.lastFrame?.hide(),this.lastFrame?.lastFrameCanvas.clear()},50)})).add(this.player.events.seeked$.subscribe(this.lastFrame.onSeek)))}setGameControllers(){let e=this.manifestController.chapter;e&&this.appState===1&&(this.selectBranches?.setManifestChapterEvents(e),this.gameControllers=this.getGameControllers(e),this.interactiveEvents?.containersEventsCallState.setData(e.containers),this.seekToInteractiveController.setContainers(this.gameControllers.map(r=>r.container.container).filter(r=>!me(r.controls))),this._options.lastFrame&&this.animation.addFn(()=>{this.player&&this.lastFrame?.onEachTick(this.player.info.position$.getValue()*1e3)},!0),this.state.interactiveRanges$.next(this.getInteractiveRanges()),this.appState=2)}getGameControllers(e){let r=[];return e.containers.forEach(n=>{let i=n.type.trim().toLowerCase(),l=this.factories.get(i)?.(n,this.rootElement,{features:{areaControlFrameBasedShadow:this._options.animationsFeatureToggles?.areaControlFrameBasedShadow,controlsExpectTimeBlinkAnimation:this._options.animationsFeatureToggles?.controlsExpectTimeBlinkAnimation}});if(l&&this.selectBranches&&this.interactiveEvents&&this.player){let s=new Ot({player:this.player,container:l,branches:e.branches,selectBranches:this.selectBranches,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter,getContainerEventState:()=>Fo(n,this.gameControllers),permanentTextControls:this._options.permanentTextControls,interactiveTimeOpenUri:this._options.interactiveTimeOpenUri,disabledControls$:this.state.disabledControls$,onRemove:()=>{this.seekToInteractiveController.deleteContainer(n.id)}});this.animation.addFn(s.whilePlaying,!0),r.push(s)}}),r}checkIfSeekable(){if(this.state.isInteractiveExpectation$.getValue()){this.state.isSeekable$.next(!1);return}let r=this.state.isSeekable$.getValue(),n=!!this.seekToInteractiveController.getNextInteractiveTime();(n&&!r||!n&&r)&&this.state.isSeekable$.next(!r)}updateLastEventInfo(){this.state.calledByInteractive$.getValue()?this.state.calledByInteractive$.next(!1):this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)}pushChapterToHistory(e){if(this.updateLastEventInfo(),!this.historyController.inited)return;let r=this.state.lastChapterChangeWasInitiatedByInteractive$.getValue(),n=this.state.prevChapter$.getValue(),i=(n&&Q(n)&&At(n))??!1,o=this.manifestController.manifest?.metadata.initChapterId===e,l=this.historyController.state.history$.getValue();if(o||i&&r){this.historyController.updateHistory([e]);return}(0,Sa.default)(l,-1)!==e&&this.historyController.updateHistory([...l,e])}handleFakeRemoval(e,r){let{interactiveRanges$:n}=this.state,o=n.getValue().map(l=>{let s=l.subjects.some(c=>c.id===e),a=l.subjects.map(c=>r&&s||c.id===e?{...c,isRemoved:!0}:c);return{...l,subjects:a}});n.next(o)}reset(){this.appState===2&&(this.destroyGameControllers(),this.gameControllers=[],this.animation.release(),this.interactiveEvents?.release(),this.appState=1,this.state.isSeekable$.next(!1),this.clearNoInteractionTimeout())}toggleBlinkAnimation(e){if(!this._options.animationsFeatureToggles?.controlsExpectTimeBlinkAnimation)return;let n=(i,o)=>{i.toggleBlinkAnimation(o)};if(wt({...e,gameControllers:this.gameControllers,execFn:Be(jr(n),e.isExpect)}),e.isExpect){let i=this.rootElement.querySelector(`.${V.common}`);i&&pn(i)}}updateControlsShadowStyles(e){if(!this._options.animationsFeatureToggles?.areaControlFrameBasedShadow)return;let r=(n,i)=>{n.updateControlsShadowStyles(i)};e.isExpect?this.getVideoFrameAverageColorInfo().then(n=>{if(n&&("isDark"in n&&wt({...e,gameControllers:this.gameControllers,execFn:Be(jr(r),n.isDark)}),n.error)){let i=new L(1,1,n.error);this.emitErrorEvent(i)}}):wt({...e,gameControllers:this.gameControllers,execFn:r})}async getVideoFrameAverageColorInfo(){if(!this.frameAverageColor||!this.player)return;let e=this.player.experimental.element$.getValue();if(!e||!e.readyState)return;let r=Kr(this.rootElement);if(!(!r.width||!r.height))try{return await this.frameAverageColor.getColorAsync(e,{width:r.width,height:r.height})}catch(n){return{error:n}}}get options(){return this._options}init(){this.manifestController.chapter&&this._options.parentElement&&this.player&&this._options.fullscreenTargetElement&&this.appState===0&&(this.resizeManager?.resizeObserver.observe(this._options.fullscreenTargetElement),this.registerVideoEvents(),this.appState=1,this.setGameControllers())}async setManifest(e){this.reset(),this.isFirstChapterFetched=!1;let r=await this.manifestController.setManifest(e);if(r.manifest)return this.graph&&this.graph.handleManifestChange(r.manifest),await this.historyController.setManifest(r.manifest),this.events.manifestChanged$.next(r.manifest),this.globalEventEmitter.emit(T.manifestChanged,{manifest:r.manifest}),this.setGameControllers(),r.manifest}setPlayer(e){this.reset(),this.player=e,this.seekToInteractiveController.setPlayer(this.player),this.interactiveEvents?this.interactiveEvents.setPlayer(this.player):this.interactiveEvents=ta(this.player,this._options.interactiveTimeOpenUri),this.selectBranches=ma({player:this.player,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter}),this.appState===1&&(this.registerVideoEvents(),this.setGameControllers())}async setChapter({chapterId:e,pushToHistory:r=!0,playPrev:n=!1}={}){this.reset(),this.lastFrame&&this.isFirstChapterFetched&&(this.lastFrame.draw(),this.lastFrame.show()),this.lastFrame&&nh.isSafari&&await ya(35);let i=!n&&this.state.isEndChapter$.getValue()&&this.getCurrentManifest()?.metadata.initChapterId===e;this.state.isReplay$.next(i);let{chapter:o,media:l,graph:s}=await(e?this.manifestController.setNext(e):this.manifestController.setInitial());(!e||i)&&this.state.isFirstChapter$.next(!0),!(!o||!l)&&(r&&this.pushChapterToHistory(o.id),this.state.isInitialChapter$.next(this.manifestController.isInitialChapter()),this.state.isEndChapter$.next(this.manifestController.isEndChapter()),this.graph&&this.graph.handleChapterChange(o),this.lastFrame?.setCurrentChapter(o),this.events.chapterChanged$.next({chapter:o,manifestVideo:l}),this.globalEventEmitter.emit(T.chapterChanged,{chapter:o,media:l,graph:s}),this.setGameControllers(),this.endedRanges=new Set,this.isFirstChapterFetched=!0)}getStatEvents(){return{click$:new xa(e=>{this.subscriptions.add(this.events.graphVisibilityChanged$.subscribe(r=>{e.next(r?Ge.GRAPH_SHOW:Ge.GRAPH_HIDE)})).add(this.events.watchAgainIsClicked$.subscribe(()=>{e.next(Ge.WATCH_AGAIN)})).add(this.events.interactiveActionChoice$.subscribe(({type:r,subjectName:n,subjectType:i})=>{r!=="action-choice"||n!=="control"||(i==="Button"&&e.next(Ge.NEXT_BUTTON),i==="Area"&&e.next(Ge.NEXT_AREA))}))}),nextMovie$:new xa(e=>{this.events.playerChanged$.subscribe(({config:r})=>{r?.unitedVideoId&&!this.state.isFirstChapter$.getValue()&&e.next(r.unitedVideoId)})})}}async toggleGraphView(e=!0){this.graph&&(e?(await this.graph.show(),this.state.isSeekable$.next(!1)):(this.graph.hide(),this.checkIfSeekable()),this.globalEventEmitter.emit(T.graph,{type:_e.visibility,visibility:e}),this.events.graphVisibilityChanged$.next(e))}setVisitedChapters(e){Array.isArray(e)&&this.graph?.setVisitedChapters(e)}updateGraphVideosInfo(e){Array.isArray(e)&&this.graph?.updateVideosInfo(e)}deadEndCheck(){return!(this.interactiveEvents?.getPreparedToExecActions()||[]).some(n=>n.actionType===R.setNextBranch)}allControlsAreRemoved(){return!this.gameControllers.some(r=>!r.container.isRemoved)}isEndedExpectation(){if(!this.player||!this.gameControllers)return!1;let e=this.player.info.position$.getValue(),r=this.player.info.duration$.getValue();return e===r&&this.gameControllers.some(n=>{let i=n.container.container;return!n.container.isRemoved&&i.endTime===null&&ne(i.events)})}playPrevChapter(){this.historyController.goBack()}setDisabledControls(e){this.state.disabledControls$.next(e)}isSupport(e=this.manifestController.manifest){return!!e&&vt(e.metadata.version)}getInitialVideoInfo(){return{videoId:this.historyController.getInitialVideoId(),chapterId:this.historyController.getInitialChapterId()}}getHistoryState(){return this.historyController.state}getIsSeekable(){return this.state.isSeekable$}getInteractiveRanges(){return bs(this.manifestController.chapter?.containers)}getNextInteractiveStartTime(e){return this.seekToInteractiveController.getNextInteractiveTime(e)}getChapterBranches(e){return this.manifestController.getBranches(e)}getCurrentChapter(){return this.manifestController.getCurrent()}getCurrentManifest(){return this.manifestController.manifest}on(e,r){return this.globalEventEmitter.on(e,r),this}off(e,r){return this.globalEventEmitter.off(e,r),this}once(e,r){return this.globalEventEmitter.once(e,r),this}destroy(){this.clearHistoryIfEnded(),this.destroyGameControllers(),this.gameControllers=[],this.frameAverageColor?.destroy(),this.graph?.destroy(),this.seamlessControllerSubs.unsubscribe(),this.seamlessController?.removeAll(),this.resizeManager?.release(),this.animation.release(),this.interactiveEvents?.release(),this.manifestController.release(),this.playerSubscriptions.unsubscribe(),this.subscriptions.unsubscribe(),this.globalEventEmitter.reset(),this.lastFrame?.destroy(),this.rootElement.remove(),this.historyController.destroy(),this.isFirstChapterFetched=!1,this.appState=3}};var lh={Container:se,createChoiceContainer:ot,createAreaControl:tt,createButtonControl:it,classnamesPrefix:en};var rb={version:Zr};export{Um as ContainerTypes,yt as ControlTypes,L as CustomError,T as EVENT_NAMES,R as EventActionTypes,Gm as EventTypes,Lt as Interactives,fe as ManifestController,rb as SDKInfo,Ur as chapterIdsToVKVideoIds,Ar as compareVersions,jm as containerTypes,_m as controlTypes,go as eventActionTypes,Bm as eventTypes,Ku as getChapterIdByVkVideoId,fa as getVKVideoIdByMedia,zu as getVideoRawIdByMedia,_e as graphEventTypes,At as hasEndTemplate,P as interactivesEventTypes,Fm as isAreaControl,Nm as isButtonControl,Q as isLastChapter,me as isOneTextCtrlContainer,vt as isSupportedManifest,ft as isTextControl,Wu as isVKVariantItem,Co as isValidManifest,Eo as migrateManifestToLatestVersion,lh as utils,va as vkVideoIdsToChapterIds};
|
|
60
|
+
`,ra=t=>{let e=document.createElement("style");e.textContent=Ru,t.prepend(e)};import{clientChecker as Vu}from"@vkontakte/videoplayer-core";var sa=Object.freeze({lang:Pu.RU,loaders:{},graph:!1,initSeamless:!1,lastFrame:!1,permanentTextControls:!0,interactiveTimeOpenUri:!1,config:{historyMaxLength:100,noInteractionEventTimeout:3e4}});function Mu(){let t=document.createElement("div");return t.classList.add("interactive-chapter"),t}var At=class{constructor(e){this.playerSubscriptions=new _r;this.subscriptions=new _r;this.globalEventEmitter=new ut;this.animation=new ht;this.seekToInteractiveController=new Pe;this.endedRanges=new Set;this.gameControllers=[];this.rootElement=Mu();this.factories=new Map([["choice",Qe]]);this.isFirstChapterFetched=!1;this.player=null;this.interactiveEvents=null;this.selectBranches=null;this.seamlessController=null;this.seamlessControllerSubs=new _r;this.graph=null;this.lastFrame=null;this.appState=0;this.state={prevChapter$:new L(null),isInitialChapter$:new L(!1),isFirstChapter$:new L(!0),isEndChapter$:new L(!1),isInteractiveExpectation$:new L(!1),isReplay$:new L(!1),calledByInteractive$:new L(!1),lastChapterChangeWasInitiatedByInteractive$:new L(!1),disabledControls$:new L(!1),interactiveRanges$:new L([]),isInteractiveTime$:new L(!1),statistics$:new L(null),isSeekable$:new L(!1)};this.events={noInteraction$:new j,graphVisibilityChanged$:new j,watchAgainIsClicked$:new j,chapterChanged$:new j,playerChanged$:new j,error$:new j,eachTick$:new j,manifestChanged$:new j,interactiveRangeEnded$:new j,interactiveContainerRemoved$:new j,interactiveContainerFakeRemoved$:new j,interactiveActionExecution$:new j,interactiveActionChoice$:new j,interactiveVisibilityChanged$:new j};this.emitErrorEvent=e=>{this.events.error$.next(e),this.globalEventEmitter.emit(x.errors,e)};this.clearHistoryIfEnded=()=>{let e=this.player?.info.isEnded$.getValue(),r=this.state.isInteractiveExpectation$.getValue(),{chapter:n}=this.getCurrentChapter();e&&n&&z(n)&&!r&&this.historyController.updateHistory([]),window.removeEventListener("beforeunload",this.clearHistoryIfEnded)};this.handleSeamlessPlayerChanged=e=>{if(!e)return;let{statistics:r,...n}=e;if(r){let{statSubscription:i,oneStat:s}=r;i.add(s.attachToInteractive(this.getStatEvents())),this.state.statistics$.next(r)}this.state.isReplay$.getValue()&&this.state.isReplay$.next(!1),this.events.playerChanged$.next(n),this.globalEventEmitter.emit(x.playerChanged,n)};this.onPlaybackStarted=()=>{this.resizeManager?.calc(),this.animation.requestAnimation()};this.destroyGameControllers=(e=!0)=>{this.gameControllers.forEach(r=>{!e&&r.isPermanentText||(this.animation.removeFn(r.whilePlaying),r.destroy())})};this.completeInteractiveRange=e=>{let{interactiveRanges$:r}=this.state,i=r.getValue().map(s=>({...s,subjects:s.subjects.filter(c=>c.id!==e)}));r.next(i)};this.clearNoInteractionTimeout=()=>{this.noInteractionTimeout&&(clearTimeout(this.noInteractionTimeout),this.noInteractionTimeout=void 0)};this._options={...sa,...e,config:{...sa.config,...e.config}},this._options.parentElement.append(this.rootElement),this.historyController=new _e({interactiveController:this,globalEventEmitter:this.globalEventEmitter,videoId:this._options.projectInfo?.videoId,historyApi:this._options.historyApi,settings:{maxLength:this._options.config.historyMaxLength,initChapterId:this._options.initChapterId}}),this._options.lastFrame&&(this.lastFrame=new wt({parentElement:this._options.parentElement,onError:n=>{let i=new M(1,6,n);this.emitErrorEvent(i)}})),ra(this._options.parentElement),this.subscriptions.add(ia(this.rootElement,"mousedown").subscribe(n=>n.stopPropagation())).add(ia(this.rootElement,"mouseup").subscribe(n=>n.stopPropagation())),this.manifestController=new de(this._options.loaders,n=>{let i=new M(1,3,n);this.emitErrorEvent(i)});let r=[];this._options.lastFrame&&r.push(()=>{this.lastFrame?.updateCanvasDimensions(!0)}),r.push(()=>{let n=this.state.isInteractiveTime$.getValue();for(let i of this.gameControllers)i.onResize(n)}),this.resizeManager=Do(()=>({player:this.player,parentElement:this._options.parentElement,fns:r})),this._options.graph&&(this.graph=new Oe({root:this._options.parentElement,lang:this._options.lang,onOpenPreviewClick:n=>{this.setChapter({chapterId:n}),this.globalEventEmitter.emit(x.graph,{type:je.watchAgainClicked,chapterId:n}),this.events.watchAgainIsClicked$.next(n)},onError:n=>{let i=new M(1,2,{message:n});this.emitErrorEvent(i)}})),this.initSubscriptions()}initSubscriptions(){this.playerSubscriptions.add(this.historyController.events.inited$.subscribe(async({videosInfo:e=[]})=>{this._options.initSeamless&&(await this.initSeamless(),this.updateGraphVideosInfo(e))})),this.subscriptions.add(this.events.interactiveContainerRemoved$.subscribe(({subjectId:e})=>{this.completeInteractiveRange(e)})).add(this.events.interactiveContainerFakeRemoved$.subscribe(({subjectId:e,removeAllOpenURI:r})=>{this.handleFakeRemoval(e,r)})).add(this.events.interactiveActionExecution$.subscribe(e=>{if(this.state.calledByInteractive$.next(!0),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!0),e.payload?.behaviour==="change-chapter"){let{chapterId:r}=e.payload;this.setChapter({chapterId:r}),this.state.isFirstChapter$.getValue()&&this.state.isFirstChapter$.next(!1)}else if(e.payload?.behaviour==="change-manifest"){let{manifestURL:r}=e.payload;r&&this.setManifest(r)}e.actionType==="expect"?this.state.isInteractiveExpectation$.next(!0):e.actionType==="after-expect"&&this.state.isInteractiveExpectation$.next(!1)})).add(this.events.manifestChanged$.subscribe(()=>{this.state.calledByInteractive$.next(!1),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)})).add(this.events.interactiveActionChoice$.subscribe(({type:e,subjectName:r,payload:n})=>{e!=="action-choice"||r==="chapter"||"invokeImmediately"in n&&n.invokeImmediately||this.destroyGameControllers(!1)}))}async initSeamless(){this.seamlessController=Or(this),this.seamlessControllerSubs.add(this.seamlessController.activePlayerChanged.subscribe(this.handleSeamlessPlayerChanged)),await this.seamlessController.init()}handlePositionChange(e){(!this.graph||this.graph.isHidden)&&this.checkIfSeekable();let r=e*1e3,i=this.getInteractiveRanges().reverse().find(({range:s})=>r>=s[1]);if(i){let s=i.range.join("-");this.endedRanges.has(s)||(this.endedRanges.add(s),this.globalEventEmitter.emit(x.interactives,{type:O.rangeEnded,payload:i,visibility:!0}),this.events.interactiveRangeEnded$.next({type:"range-ended",payload:i}))}}registerVideoEvents(){this.player&&(window.removeEventListener("beforeunload",this.clearHistoryIfEnded),this.playerSubscriptions.unsubscribe(),window.addEventListener("beforeunload",this.clearHistoryIfEnded),this.playerSubscriptions.add(this.player.events.started$.pipe(ku()).subscribe(this.onPlaybackStarted)).add(this.player.events.playing$.subscribe(this.animation.requestAnimation)).add(this.player.events.willPause$.subscribe(this.animation.cancelAnimation)).add(this.player.info.position$.subscribe(this.handlePositionChange.bind(this))).add(this.manifestController.prevChapter$.subscribe(e=>this.state.prevChapter$.next(e))).add(Ou({position:this.player.info.position$,interactiveRanges:this.state.interactiveRanges$,isInteractiveExpectation:this.state.isInteractiveExpectation$}).subscribe(({position:e,interactiveRanges:r,isInteractiveExpectation:n})=>{let i;if(n)i=!0;else{let a=e*1e3;i=!!r.find(({range:[d,m],subjects:f})=>d<a&&a<m&&f.some(y=>!y.isRemoved)&&f.length)}i!==this.state.isInteractiveTime$.getValue()&&this.state.isInteractiveTime$.next(i);let s=!!this.noInteractionTimeout,o=this.player?.info.playbackState$.getValue()==="playing"||n;i&&!s&&o?this.noInteractionTimeout=window.setTimeout(()=>{this.events.noInteraction$.next()},this._options.config.noInteractionEventTimeout):s&&!o&&this.clearNoInteractionTimeout()})),this.playerSubscriptions.add(this.historyController.events.error$.subscribe(this.events.error$)),this._options.lastFrame&&this.playerSubscriptions.add(this.player.info.duration$.subscribe(e=>{this.lastFrame?.setVideoDuration(e*1e3)})).add(this.player.experimental.element$.subscribe(e=>{e&&this.lastFrame?.setVideoElement(e)})).add(this.player.events.firstFrame$.subscribe(()=>{this.lastFrame?.reset(),setTimeout(()=>{this.lastFrame?.hide(),this.lastFrame?.lastFrameCanvas.clear()},50)})).add(this.player.events.seeked$.subscribe(this.lastFrame.onSeek)))}setGameControllers(){let e=this.manifestController.chapter;e&&this.appState===1&&(this.selectBranches?.setManifestChapterEvents(e),this.gameControllers=this.getGameControllers(e),this.interactiveEvents?.containersEventsCallState.setData(e.containers),this.seekToInteractiveController.setContainers(this.gameControllers.map(r=>r.container.container).filter(r=>!he(r.controls))),this._options.lastFrame&&this.animation.addFn(()=>{this.player&&this.lastFrame?.onEachTick(this.player.info.position$.getValue()*1e3)},!0),this.state.interactiveRanges$.next(this.getInteractiveRanges()),this.appState=2)}getGameControllers(e){let r=[];return e.containers.forEach(n=>{let i=n.type.trim().toLowerCase(),c=this.factories.get(i)?.(n,this.rootElement);if(c&&this.selectBranches&&this.interactiveEvents&&this.player){let o=new It({player:this.player,container:c,branches:e.branches,selectBranches:this.selectBranches,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter,getContainerEventState:()=>ps(n,this.gameControllers),permanentTextControls:this._options.permanentTextControls,interactiveTimeOpenUri:this._options.interactiveTimeOpenUri,disabledControls$:this.state.disabledControls$,onRemove:()=>{this.seekToInteractiveController.deleteContainer(n.id)}});this.animation.addFn(o.whilePlaying,!0),r.push(o)}}),r}checkIfSeekable(){if(this.state.isInteractiveExpectation$.getValue()){this.state.isSeekable$.next(!1);return}let r=this.state.isSeekable$.getValue(),n=!!this.seekToInteractiveController.getNextInteractiveTime();(n&&!r||!n&&r)&&this.state.isSeekable$.next(!r)}updateLastEventInfo(){this.state.calledByInteractive$.getValue()?this.state.calledByInteractive$.next(!1):this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)}pushChapterToHistory(e){if(this.updateLastEventInfo(),!this.historyController.inited)return;let r=this.state.lastChapterChangeWasInitiatedByInteractive$.getValue(),n=this.state.prevChapter$.getValue(),i=(n&&z(n)&&Ct(n))??!1,s=this.manifestController.manifest?.metadata.initChapterId===e,c=this.historyController.state.history$.getValue();if(s||i&&r){this.historyController.updateHistory([e]);return}(0,oa.default)(c,-1)!==e&&this.historyController.updateHistory([...c,e])}handleFakeRemoval(e,r){let{interactiveRanges$:n}=this.state,s=n.getValue().map(c=>{let o=c.subjects.some(l=>l.id===e),a=c.subjects.map(l=>r&&o||l.id===e?{...l,isRemoved:!0}:l);return{...c,subjects:a}});n.next(s)}reset(){this.appState===2&&(this.destroyGameControllers(),this.gameControllers=[],this.animation.release(),this.interactiveEvents?.release(),this.appState=1,this.state.isSeekable$.next(!1),this.clearNoInteractionTimeout())}get options(){return this._options}init(){this.manifestController.chapter&&this._options.parentElement&&this.player&&this._options.fullscreenTargetElement&&this.appState===0&&(this.resizeManager?.resizeObserver.observe(this._options.fullscreenTargetElement),this.registerVideoEvents(),this.appState=1,this.setGameControllers())}async setManifest(e){this.reset(),this.isFirstChapterFetched=!1;let r=await this.manifestController.setManifest(e);if(r.manifest)return this.graph&&this.graph.handleManifestChange(r.manifest),await this.historyController.setManifest(r.manifest),this.events.manifestChanged$.next(r.manifest),this.globalEventEmitter.emit(x.manifestChanged,{manifest:r.manifest}),this.setGameControllers(),r.manifest}setPlayer(e){this.reset(),this.player=e,this.seekToInteractiveController.setPlayer(this.player),this.interactiveEvents?this.interactiveEvents.setPlayer(this.player):this.interactiveEvents=Fo(this.player,this._options.interactiveTimeOpenUri),this.selectBranches=Zo({player:this.player,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter}),this.appState===1&&(this.registerVideoEvents(),this.setGameControllers())}async setChapter({chapterId:e,pushToHistory:r=!0,playPrev:n=!1}={}){this.reset(),this.lastFrame&&this.isFirstChapterFetched&&(this.lastFrame.draw(),this.lastFrame.show()),this.lastFrame&&Vu.browser.isSafari&&await ta(35);let i=!n&&this.state.isEndChapter$.getValue()&&this.getCurrentManifest()?.metadata.initChapterId===e;this.state.isReplay$.next(i);let{chapter:s,media:c,graph:o}=await(e?this.manifestController.setNext(e):this.manifestController.setInitial());(!e||i)&&this.state.isFirstChapter$.next(!0),!(!s||!c)&&(r&&this.pushChapterToHistory(s.id),this.state.isInitialChapter$.next(this.manifestController.isInitialChapter()),this.state.isEndChapter$.next(this.manifestController.isEndChapter()),this.graph&&this.graph.handleChapterChange(s),this.lastFrame?.setCurrentChapter(s),this.events.chapterChanged$.next({chapter:s,manifestVideo:c}),this.globalEventEmitter.emit(x.chapterChanged,{chapter:s,media:c,graph:o}),this.setGameControllers(),this.endedRanges=new Set,this.isFirstChapterFetched=!0)}getStatEvents(){return{click$:new na(e=>{this.subscriptions.add(this.events.graphVisibilityChanged$.subscribe(r=>{e.next(r?Fe.GRAPH_SHOW:Fe.GRAPH_HIDE)})).add(this.events.watchAgainIsClicked$.subscribe(()=>{e.next(Fe.WATCH_AGAIN)})).add(this.events.interactiveActionChoice$.subscribe(({type:r,subjectName:n,subjectType:i})=>{r!=="action-choice"||n!=="control"||(i==="Button"&&e.next(Fe.NEXT_BUTTON),i==="Area"&&e.next(Fe.NEXT_AREA))}))}),nextMovie$:new na(e=>{this.events.playerChanged$.subscribe(({config:r})=>{r?.unitedVideoId&&!this.state.isFirstChapter$.getValue()&&e.next(r.unitedVideoId)})})}}async toggleGraphView(e=!0){this.graph&&(e?(await this.graph.show(),this.state.isSeekable$.next(!1)):(this.graph.hide(),this.checkIfSeekable()),this.globalEventEmitter.emit(x.graph,{type:je.visibility,visibility:e}),this.events.graphVisibilityChanged$.next(e))}setVisitedChapters(e){Array.isArray(e)&&this.graph?.setVisitedChapters(e)}updateGraphVideosInfo(e){Array.isArray(e)&&this.graph?.updateVideosInfo(e)}deadEndCheck(){return!(this.interactiveEvents?.getPreparedToExecActions()||[]).some(n=>n.actionType===w.setNextBranch)}allControlsAreRemoved(){return!this.gameControllers.some(r=>!r.container.isRemoved)}isEndedExpectation(){if(!this.player||!this.gameControllers)return!1;let e=this.player.info.position$.getValue(),r=this.player.info.duration$.getValue();return e===r&&this.gameControllers.some(n=>{let i=n.container.container;return!n.container.isRemoved&&i.endTime===null&&ee(i.events)})}playPrevChapter(){this.historyController.goBack()}setDisabledControls(e){this.state.disabledControls$.next(e)}isSupport(e=this.manifestController.manifest){return!!e&<(e.metadata.version)}getInitialVideoInfo(){return{videoId:this.historyController.getInitialVideoId(),chapterId:this.historyController.getInitialChapterId()}}getHistoryState(){return this.historyController.state}getIsSeekable(){return this.state.isSeekable$}getInteractiveRanges(){return to(this.manifestController.chapter?.containers)}getNextInteractiveStartTime(e){return this.seekToInteractiveController.getNextInteractiveTime(e)}getChapterBranches(e){return this.manifestController.getBranches(e)}getCurrentChapter(){return this.manifestController.getCurrent()}getCurrentManifest(){return this.manifestController.manifest}on(e,r){return this.globalEventEmitter.on(e,r),this}off(e,r){return this.globalEventEmitter.off(e,r),this}once(e,r){return this.globalEventEmitter.once(e,r),this}destroy(){this.clearHistoryIfEnded(),this.destroyGameControllers(),this.gameControllers=[],this.graph?.destroy(),this.seamlessControllerSubs.unsubscribe(),this.seamlessController?.removeAll(),this.resizeManager?.release(),this.animation.release(),this.interactiveEvents?.release(),this.manifestController.release(),this.playerSubscriptions.unsubscribe(),this.subscriptions.unsubscribe(),this.globalEventEmitter.reset(),this.lastFrame?.destroy(),this.rootElement.remove(),this.historyController.destroy(),this.isFirstChapterFetched=!1,this.appState=3}};var Nu={Container:ne,createChoiceContainer:Qe,createAreaControl:ze,createButtonControl:Ke,classnamesPrefix:Hr};var ay={version:Br};export{am as ContainerTypes,pt as ControlTypes,M as CustomError,x as EVENT_NAMES,w as EventActionTypes,cm as EventTypes,At as Interactives,de as ManifestController,ay as SDKInfo,jr as chapterIdsToVKVideoIds,br as compareVersions,tm as containerTypes,rm as controlTypes,is as eventActionTypes,nm as eventTypes,Su as getChapterIdByVkVideoId,Jo as getVKVideoIdByMedia,Tu as getVideoRawIdByMedia,je as graphEventTypes,Ct as hasEndTemplate,O as interactivesEventTypes,em as isAreaControl,Jd as isButtonControl,z as isLastChapter,he as isOneTextCtrlContainer,lt as isSupportedManifest,ct as isTextControl,xu as isVKVariantItem,ns as isValidManifest,ss as migrateManifestToLatestVersion,Nu as utils,ea as vkVideoIdsToChapterIds};
|