@vkontakte/videoplayer-interactive 1.0.37-dev.a47f72c3.0 → 1.0.37-dev.dd02dc3e.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 +5 -5
- package/es2015.esm.js +4 -4
- package/es2018.cjs.js +4 -4
- package/es2018.esm.js +4 -4
- package/es2024.cjs.js +4 -4
- package/es2024.esm.js +4 -4
- package/esnext.cjs.js +4 -4
- package/esnext.esm.js +4 -4
- package/evergreen.esm.js +3 -3
- package/package.json +4 -4
package/es2024.cjs.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-interactive v1.0.37-dev.
|
|
3
|
-
* Tue, 03 Jun 2025 05:
|
|
2
|
+
* @vkontakte/videoplayer-interactive v1.0.37-dev.dd02dc3e.0
|
|
3
|
+
* Tue, 03 Jun 2025 05:32:11 GMT
|
|
4
4
|
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-37/doc/
|
|
5
5
|
*/
|
|
6
|
-
"use strict";var Ma=Object.create;var et=Object.defineProperty;var Na=Object.getOwnPropertyDescriptor;var La=Object.getOwnPropertyNames;var ja=Object.getPrototypeOf,$a=Object.prototype.hasOwnProperty;var p=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),_a=(r,e)=>{for(var t in e)et(r,t,{get:e[t],enumerable:!0})},en=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of La(e))!$a.call(r,i)&&i!==t&&et(r,i,{get:()=>e[i],enumerable:!(n=Na(e,i))||n.enumerable});return r};var F=(r,e,t)=>(t=r!=null?Ma(ja(r)):{},en(e||!r||!r.__esModule?et(t,"default",{value:r,enumerable:!0}):t,r)),Fa=r=>en(et({},"__esModule",{value:!0}),r);var K=p((Yt,dn)=>{"use strict";var Re=function(r){return r&&r.Math===Math&&r};dn.exports=Re(typeof globalThis=="object"&&globalThis)||Re(typeof window=="object"&&window)||Re(typeof self=="object"&&self)||Re(typeof global=="object"&&global)||Re(typeof Yt=="object"&&Yt)||function(){return this}()||Function("return this")()});var B=p((bd,mn)=>{"use strict";mn.exports=function(r){try{return!!r()}catch{return!0}}});var Oe=p((Cd,fn)=>{"use strict";var Ba=B();fn.exports=!Ba(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var gn=p((gd,Cn)=>{"use strict";var qa=Oe(),bn=Function.prototype,vn=bn.apply,yn=bn.call;Cn.exports=typeof Reflect=="object"&&Reflect.apply||(qa?yn.bind(vn):function(){return yn.apply(vn,arguments)})});var H=p((Ed,xn)=>{"use strict";var En=Oe(),In=Function.prototype,Zt=In.call,Da=En&&In.bind.bind(Zt,Zt);xn.exports=En?Da:function(r){return function(){return Zt.apply(r,arguments)}}});var ke=p((Id,Sn)=>{"use strict";var Tn=H(),Ha=Tn({}.toString),Ua=Tn("".slice);Sn.exports=function(r){return Ua(Ha(r),8,-1)}});var Jt=p((xd,An)=>{"use strict";var Ga=ke(),za=H();An.exports=function(r){if(Ga(r)==="Function")return za(r)}});var q=p((Td,wn)=>{"use strict";var er=typeof document=="object"&&document.all;wn.exports=typeof er>"u"&&er!==void 0?function(r){return typeof r=="function"||r===er}:function(r){return typeof r=="function"}});var ie=p((Sd,Rn)=>{"use strict";var Wa=B();Rn.exports=!Wa(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var ft=p((Ad,On)=>{"use strict";var Ka=Oe(),mt=Function.prototype.call;On.exports=Ka?mt.bind(mt):function(){return mt.apply(mt,arguments)}});var tr=p(Pn=>{"use strict";var kn={}.propertyIsEnumerable,Vn=Object.getOwnPropertyDescriptor,Qa=Vn&&!kn.call({1:2},1);Pn.f=Qa?function(e){var t=Vn(this,e);return!!t&&t.enumerable}:kn});var rr=p((Rd,Mn)=>{"use strict";Mn.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var Ln=p((Od,Nn)=>{"use strict";var Xa=H(),Ya=B(),Za=ke(),nr=Object,Ja=Xa("".split);Nn.exports=Ya(function(){return!nr("z").propertyIsEnumerable(0)})?function(r){return Za(r)==="String"?Ja(r,""):nr(r)}:nr});var ir=p((kd,jn)=>{"use strict";jn.exports=function(r){return r==null}});var or=p((Vd,$n)=>{"use strict";var el=ir(),tl=TypeError;$n.exports=function(r){if(el(r))throw new tl("Can't call method on "+r);return r}});var Ve=p((Pd,_n)=>{"use strict";var rl=Ln(),nl=or();_n.exports=function(r){return rl(nl(r))}});var de=p((Md,Fn)=>{"use strict";var il=q();Fn.exports=function(r){return typeof r=="object"?r!==null:il(r)}});var Pe=p((Nd,Bn)=>{"use strict";Bn.exports={}});var vt=p((Ld,Dn)=>{"use strict";var sr=Pe(),ar=K(),ol=q(),qn=function(r){return ol(r)?r:void 0};Dn.exports=function(r,e){return arguments.length<2?qn(sr[r])||qn(ar[r]):sr[r]&&sr[r][e]||ar[r]&&ar[r][e]}});var Un=p((jd,Hn)=>{"use strict";var sl=H();Hn.exports=sl({}.isPrototypeOf)});var Kn=p(($d,Wn)=>{"use strict";var al=K(),Gn=al.navigator,zn=Gn&&Gn.userAgent;Wn.exports=zn?String(zn):""});var ti=p((_d,ei)=>{"use strict";var Jn=K(),lr=Kn(),Qn=Jn.process,Xn=Jn.Deno,Yn=Qn&&Qn.versions||Xn&&Xn.version,Zn=Yn&&Yn.v8,U,yt;Zn&&(U=Zn.split("."),yt=U[0]>0&&U[0]<4?1:+(U[0]+U[1]));!yt&&lr&&(U=lr.match(/Edge\/(\d+)/),(!U||U[1]>=74)&&(U=lr.match(/Chrome\/(\d+)/),U&&(yt=+U[1])));ei.exports=yt});var cr=p((Fd,ni)=>{"use strict";var ri=ti(),ll=B(),cl=K(),pl=cl.String;ni.exports=!!Object.getOwnPropertySymbols&&!ll(function(){var r=Symbol("symbol detection");return!pl(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&ri&&ri<41})});var pr=p((Bd,ii)=>{"use strict";var ul=cr();ii.exports=ul&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var ur=p((qd,oi)=>{"use strict";var hl=vt(),dl=q(),ml=Un(),fl=pr(),vl=Object;oi.exports=fl?function(r){return typeof r=="symbol"}:function(r){var e=hl("Symbol");return dl(e)&&ml(e.prototype,vl(r))}});var ai=p((Dd,si)=>{"use strict";var yl=String;si.exports=function(r){try{return yl(r)}catch{return"Object"}}});var hr=p((Hd,li)=>{"use strict";var bl=q(),Cl=ai(),gl=TypeError;li.exports=function(r){if(bl(r))return r;throw new gl(Cl(r)+" is not a function")}});var pi=p((Ud,ci)=>{"use strict";var El=hr(),Il=ir();ci.exports=function(r,e){var t=r[e];return Il(t)?void 0:El(t)}});var hi=p((Gd,ui)=>{"use strict";var dr=ft(),mr=q(),fr=de(),xl=TypeError;ui.exports=function(r,e){var t,n;if(e==="string"&&mr(t=r.toString)&&!fr(n=dr(t,r))||mr(t=r.valueOf)&&!fr(n=dr(t,r))||e!=="string"&&mr(t=r.toString)&&!fr(n=dr(t,r)))return n;throw new xl("Can't convert object to primitive value")}});var mi=p((zd,di)=>{"use strict";di.exports=!0});var yi=p((Wd,vi)=>{"use strict";var fi=K(),Tl=Object.defineProperty;vi.exports=function(r,e){try{Tl(fi,r,{value:e,configurable:!0,writable:!0})}catch{fi[r]=e}return e}});var bt=p((Kd,gi)=>{"use strict";var Sl=mi(),Al=K(),wl=yi(),bi="__core-js_shared__",Ci=gi.exports=Al[bi]||wl(bi,{});(Ci.versions||(Ci.versions=[])).push({version:"3.38.0",mode:Sl?"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 vr=p((Qd,Ii)=>{"use strict";var Ei=bt();Ii.exports=function(r,e){return Ei[r]||(Ei[r]=e||{})}});var Me=p((Xd,xi)=>{"use strict";var Rl=or(),Ol=Object;xi.exports=function(r){return Ol(Rl(r))}});var me=p((Yd,Ti)=>{"use strict";var kl=H(),Vl=Me(),Pl=kl({}.hasOwnProperty);Ti.exports=Object.hasOwn||function(e,t){return Pl(Vl(e),t)}});var yr=p((Zd,Si)=>{"use strict";var Ml=H(),Nl=0,Ll=Math.random(),jl=Ml(1 .toString);Si.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+jl(++Nl+Ll,36)}});var Ne=p((Jd,wi)=>{"use strict";var $l=K(),_l=vr(),Ai=me(),Fl=yr(),Bl=cr(),ql=pr(),fe=$l.Symbol,br=_l("wks"),Dl=ql?fe.for||fe:fe&&fe.withoutSetter||Fl;wi.exports=function(r){return Ai(br,r)||(br[r]=Bl&&Ai(fe,r)?fe[r]:Dl("Symbol."+r)),br[r]}});var Vi=p((em,ki)=>{"use strict";var Hl=ft(),Ri=de(),Oi=ur(),Ul=pi(),Gl=hi(),zl=Ne(),Wl=TypeError,Kl=zl("toPrimitive");ki.exports=function(r,e){if(!Ri(r)||Oi(r))return r;var t=Ul(r,Kl),n;if(t){if(e===void 0&&(e="default"),n=Hl(t,r,e),!Ri(n)||Oi(n))return n;throw new Wl("Can't convert object to primitive value")}return e===void 0&&(e="number"),Gl(r,e)}});var Cr=p((tm,Pi)=>{"use strict";var Ql=Vi(),Xl=ur();Pi.exports=function(r){var e=Ql(r,"string");return Xl(e)?e:e+""}});var Li=p((rm,Ni)=>{"use strict";var Yl=K(),Mi=de(),gr=Yl.document,Zl=Mi(gr)&&Mi(gr.createElement);Ni.exports=function(r){return Zl?gr.createElement(r):{}}});var Er=p((nm,ji)=>{"use strict";var Jl=ie(),ec=B(),tc=Li();ji.exports=!Jl&&!ec(function(){return Object.defineProperty(tc("div"),"a",{get:function(){return 7}}).a!==7})});var Fi=p(_i=>{"use strict";var rc=ie(),nc=ft(),ic=tr(),oc=rr(),sc=Ve(),ac=Cr(),lc=me(),cc=Er(),$i=Object.getOwnPropertyDescriptor;_i.f=rc?$i:function(e,t){if(e=sc(e),t=ac(t),cc)try{return $i(e,t)}catch{}if(lc(e,t))return oc(!nc(ic.f,e,t),e[t])}});var qi=p((om,Bi)=>{"use strict";var pc=B(),uc=q(),hc=/#|\.prototype\./,Le=function(r,e){var t=mc[dc(r)];return t===vc?!0:t===fc?!1:uc(e)?pc(e):!!e},dc=Le.normalize=function(r){return String(r).replace(hc,".").toLowerCase()},mc=Le.data={},fc=Le.NATIVE="N",vc=Le.POLYFILL="P";Bi.exports=Le});var Ir=p((sm,Hi)=>{"use strict";var Di=Jt(),yc=hr(),bc=Oe(),Cc=Di(Di.bind);Hi.exports=function(r,e){return yc(r),e===void 0?r:bc?Cc(r,e):function(){return r.apply(e,arguments)}}});var Gi=p((am,Ui)=>{"use strict";var gc=ie(),Ec=B();Ui.exports=gc&&Ec(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var Wi=p((lm,zi)=>{"use strict";var Ic=de(),xc=String,Tc=TypeError;zi.exports=function(r){if(Ic(r))return r;throw new Tc(xc(r)+" is not an object")}});var Xi=p(Qi=>{"use strict";var Sc=ie(),Ac=Er(),wc=Gi(),Ct=Wi(),Ki=Cr(),Rc=TypeError,xr=Object.defineProperty,Oc=Object.getOwnPropertyDescriptor,Tr="enumerable",Sr="configurable",Ar="writable";Qi.f=Sc?wc?function(e,t,n){if(Ct(e),t=Ki(t),Ct(n),typeof e=="function"&&t==="prototype"&&"value"in n&&Ar in n&&!n[Ar]){var i=Oc(e,t);i&&i[Ar]&&(e[t]=n.value,n={configurable:Sr in n?n[Sr]:i[Sr],enumerable:Tr in n?n[Tr]:i[Tr],writable:!1})}return xr(e,t,n)}:xr:function(e,t,n){if(Ct(e),t=Ki(t),Ct(n),Ac)try{return xr(e,t,n)}catch{}if("get"in n||"set"in n)throw new Rc("Accessors not supported");return"value"in n&&(e[t]=n.value),e}});var Zi=p((pm,Yi)=>{"use strict";var kc=ie(),Vc=Xi(),Pc=rr();Yi.exports=kc?function(r,e,t){return Vc.f(r,e,Pc(1,t))}:function(r,e,t){return r[e]=t,r}});var be=p((um,eo)=>{"use strict";var je=K(),Mc=gn(),Nc=Jt(),Lc=q(),jc=Fi().f,$c=qi(),ve=Pe(),_c=Ir(),ye=Zi(),Ji=me();bt();var Fc=function(r){var e=function(t,n,i){if(this instanceof e){switch(arguments.length){case 0:return new r;case 1:return new r(t);case 2:return new r(t,n)}return new r(t,n,i)}return Mc(r,this,arguments)};return e.prototype=r.prototype,e};eo.exports=function(r,e){var t=r.target,n=r.global,i=r.stat,o=r.proto,a=n?je:i?je[t]:je[t]&&je[t].prototype,s=n?ve:ve[t]||ye(ve,t,{})[t],l=s.prototype,c,d,v,m,y,O,A,C,u;for(m in e)c=$c(n?m:t+(i?".":"#")+m,r.forced),d=!c&&a&&Ji(a,m),O=s[m],d&&(r.dontCallGetSet?(u=jc(a,m),A=u&&u.value):A=a[m]),y=d&&A?A:e[m],!(!c&&!o&&typeof O==typeof y)&&(r.bind&&d?C=_c(y,je):r.wrap&&d?C=Fc(y):o&&Lc(y)?C=Nc(y):C=y,(r.sham||y&&y.sham||O&&O.sham)&&ye(C,"sham",!0),ye(s,m,C),o&&(v=t+"Prototype",Ji(ve,v)||ye(ve,v,{}),ye(ve[v],m,y),r.real&&l&&(c||!l[m])&&ye(l,m,y)))}});var ro=p((hm,to)=>{"use strict";var Bc=Math.ceil,qc=Math.floor;to.exports=Math.trunc||function(e){var t=+e;return(t>0?qc:Bc)(t)}});var $e=p((dm,no)=>{"use strict";var Dc=ro();no.exports=function(r){var e=+r;return e!==e||e===0?0:Dc(e)}});var oo=p((mm,io)=>{"use strict";var Hc=$e(),Uc=Math.min;io.exports=function(r){var e=Hc(r);return e>0?Uc(e,9007199254740991):0}});var _e=p((fm,so)=>{"use strict";var Gc=oo();so.exports=function(r){return Gc(r.length)}});var gt=p((vm,ao)=>{"use strict";ao.exports=function(){}});var lo=p(()=>{"use strict";var zc=be(),Wc=Me(),Kc=_e(),Qc=$e(),Xc=gt();zc({target:"Array",proto:!0},{at:function(e){var t=Wc(this),n=Kc(t),i=Qc(e),o=i>=0?i:n+i;return o<0||o>=n?void 0:t[o]}});Xc("at")});var Et=p((Cm,co)=>{"use strict";var Yc=vt();co.exports=Yc});var uo=p((gm,po)=>{"use strict";lo();var Zc=Et();po.exports=Zc("Array","at")});var mo=p((Em,ho)=>{"use strict";var Jc=uo();ho.exports=Jc});var wr=p((Im,fo)=>{"use strict";var ep=mo();fo.exports=ep});var xo=p((Um,Io)=>{"use strict";var ap=vr(),lp=yr(),Eo=ap("keys");Io.exports=function(r){return Eo[r]||(Eo[r]=lp(r))}});var So=p((Gm,To)=>{"use strict";var cp=B();To.exports=!cp(function(){function r(){}return r.prototype.constructor=null,Object.getPrototypeOf(new r)!==r.prototype})});var Ro=p((zm,wo)=>{"use strict";var pp=me(),up=q(),hp=Me(),dp=xo(),mp=So(),Ao=dp("IE_PROTO"),kr=Object,fp=kr.prototype;wo.exports=mp?kr.getPrototypeOf:function(r){var e=hp(r);if(pp(e,Ao))return e[Ao];var t=e.constructor;return up(t)&&e instanceof t?t.prototype:e instanceof kr?fp:null}});var ko=p((Wm,Oo)=>{"use strict";var vp=$e(),yp=Math.max,bp=Math.min;Oo.exports=function(r,e){var t=vp(r);return t<0?yp(t+e,0):bp(t,e)}});var Vr=p((Km,Po)=>{"use strict";var Cp=Ve(),gp=ko(),Ep=_e(),Vo=function(r){return function(e,t,n){var i=Cp(e),o=Ep(i);if(o===0)return!r&&-1;var a=gp(n,o),s;if(r&&t!==t){for(;o>a;)if(s=i[a++],s!==s)return!0}else for(;o>a;a++)if((r||a in i)&&i[a]===t)return r||a||0;return!r&&-1}};Po.exports={includes:Vo(!0),indexOf:Vo(!1)}});var No=p((Qm,Mo)=>{"use strict";Mo.exports={}});var $o=p((Xm,jo)=>{"use strict";var Ip=H(),Pr=me(),xp=Ve(),Tp=Vr().indexOf,Sp=No(),Lo=Ip([].push);jo.exports=function(r,e){var t=xp(r),n=0,i=[],o;for(o in t)!Pr(Sp,o)&&Pr(t,o)&&Lo(i,o);for(;e.length>n;)Pr(t,o=e[n++])&&(~Tp(i,o)||Lo(i,o));return i}});var Fo=p((Ym,_o)=>{"use strict";_o.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var qo=p((Zm,Bo)=>{"use strict";var Ap=$o(),wp=Fo();Bo.exports=Object.keys||function(e){return Ap(e,wp)}});var Mr=p((Jm,zo)=>{"use strict";var Ho=ie(),Rp=B(),Uo=H(),Op=Ro(),kp=qo(),Vp=Ve(),Pp=tr().f,Go=Uo(Pp),Mp=Uo([].push),Np=Ho&&Rp(function(){var r=Object.create(null);return r[2]=2,!Go(r,2)}),Do=function(r){return function(e){for(var t=Vp(e),n=kp(t),i=Np&&Op(t)===null,o=n.length,a=0,s=[],l;o>a;)l=n[a++],(!Ho||(i?l in t:Go(t,l)))&&Mp(s,r?[l,t[l]]:t[l]);return s}};zo.exports={entries:Do(!0),values:Do(!1)}});var Wo=p(()=>{"use strict";var Lp=be(),jp=Mr().entries;Lp({target:"Object",stat:!0},{entries:function(e){return jp(e)}})});var Qo=p((rf,Ko)=>{"use strict";Wo();var $p=Pe();Ko.exports=$p.Object.entries});var Yo=p((nf,Xo)=>{"use strict";var _p=Qo();Xo.exports=_p});var Jo=p((of,Zo)=>{"use strict";var Fp=Yo();Zo.exports=Fp});var ns=p(()=>{"use strict";var Gp=be(),zp=Vr().includes,Wp=B(),Kp=gt(),Qp=Wp(function(){return!Array(1).includes()});Gp({target:"Array",proto:!0,forced:Qp},{includes:function(e){return zp(this,e,arguments.length>1?arguments[1]:void 0)}});Kp("includes")});var os=p((wf,is)=>{"use strict";ns();var Xp=Et();is.exports=Xp("Array","includes")});var as=p((Rf,ss)=>{"use strict";var Yp=os();ss.exports=Yp});var ze=p((Of,ls)=>{"use strict";var Zp=as();ls.exports=Zp});var ms=p(()=>{"use strict";var eu=be(),tu=Mr().values;eu({target:"Object",stat:!0},{values:function(e){return tu(e)}})});var vs=p((qf,fs)=>{"use strict";ms();var ru=Pe();fs.exports=ru.Object.values});var bs=p((Df,ys)=>{"use strict";var nu=vs();ys.exports=nu});var Mt=p((Hf,Cs)=>{"use strict";var iu=bs();Cs.exports=iu});var Ur=p((pv,Rs)=>{"use strict";var su=ke();Rs.exports=Array.isArray||function(e){return su(e)==="Array"}});var ks=p((uv,Os)=>{"use strict";var au=TypeError,lu=9007199254740991;Os.exports=function(r){if(r>lu)throw au("Maximum allowed index exceeded");return r}});var Ms=p((hv,Ps)=>{"use strict";var cu=Ur(),pu=_e(),uu=ks(),hu=Ir(),Vs=function(r,e,t,n,i,o,a,s){for(var l=i,c=0,d=a?hu(a,s):!1,v,m;c<n;)c in t&&(v=d?d(t[c],c,e):t[c],o>0&&cu(v)?(m=pu(v),l=Vs(r,e,v,m,l,o-1)-1):(uu(l+1),r[l]=v),l++),c++;return l};Ps.exports=Vs});var js=p((dv,Ls)=>{"use strict";var du=Ne(),mu=du("toStringTag"),Ns={};Ns[mu]="z";Ls.exports=String(Ns)==="[object z]"});var _s=p((mv,$s)=>{"use strict";var fu=js(),vu=q(),Lt=ke(),yu=Ne(),bu=yu("toStringTag"),Cu=Object,gu=Lt(function(){return arguments}())==="Arguments",Eu=function(r,e){try{return r[e]}catch{}};$s.exports=fu?Lt:function(r){var e,t,n;return r===void 0?"Undefined":r===null?"Null":typeof(t=Eu(e=Cu(r),bu))=="string"?t:gu?Lt(e):(n=Lt(e))==="Object"&&vu(e.callee)?"Arguments":n}});var Bs=p((fv,Fs)=>{"use strict";var Iu=H(),xu=q(),Gr=bt(),Tu=Iu(Function.toString);xu(Gr.inspectSource)||(Gr.inspectSource=function(r){return Tu(r)});Fs.exports=Gr.inspectSource});var zs=p((vv,Gs)=>{"use strict";var Su=H(),Au=B(),qs=q(),wu=_s(),Ru=vt(),Ou=Bs(),Ds=function(){},Hs=Ru("Reflect","construct"),zr=/^\s*(?:class|function)\b/,ku=Su(zr.exec),Vu=!zr.test(Ds),Xe=function(e){if(!qs(e))return!1;try{return Hs(Ds,[],e),!0}catch{return!1}},Us=function(e){if(!qs(e))return!1;switch(wu(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Vu||!!ku(zr,Ou(e))}catch{return!0}};Us.sham=!0;Gs.exports=!Hs||Au(function(){var r;return Xe(Xe.call)||!Xe(Object)||!Xe(function(){r=!0})||r})?Us:Xe});var Xs=p((yv,Qs)=>{"use strict";var Ws=Ur(),Pu=zs(),Mu=de(),Nu=Ne(),Lu=Nu("species"),Ks=Array;Qs.exports=function(r){var e;return Ws(r)&&(e=r.constructor,Pu(e)&&(e===Ks||Ws(e.prototype))?e=void 0:Mu(e)&&(e=e[Lu],e===null&&(e=void 0))),e===void 0?Ks:e}});var Zs=p((bv,Ys)=>{"use strict";var ju=Xs();Ys.exports=function(r,e){return new(ju(r))(e===0?0:e)}});var Js=p(()=>{"use strict";var $u=be(),_u=Ms(),Fu=Me(),Bu=_e(),qu=$e(),Du=Zs();$u({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=Fu(this),n=Bu(t),i=Du(t,0);return i.length=_u(i,t,t,n,0,e===void 0?1:qu(e)),i}})});var ea=p(()=>{"use strict";var Hu=gt();Hu("flat")});var ra=p((xv,ta)=>{"use strict";Js();ea();var Uu=Et();ta.exports=Uu("Array","flat")});var ia=p((Tv,na)=>{"use strict";var Gu=ra();na.exports=Gu});var sa=p((Sv,oa)=>{"use strict";var zu=ia();oa.exports=zu});var rh={};_a(rh,{ContainerTypes:()=>b.ContainerTypes,ControlTypes:()=>b.ControlTypes,CustomError:()=>k,EVENT_NAMES:()=>S,EventActionTypes:()=>b.EventActionTypes,EventTypes:()=>b.EventTypes,Interactives:()=>Ze,ManifestController:()=>ae,SDKInfo:()=>th,chapterIdsToVKVideoIds:()=>$t,compareVersions:()=>Ot,containerTypes:()=>ip,controlTypes:()=>op,eventActionTypes:()=>Or,eventTypes:()=>sp,getChapterIdByVkVideoId:()=>Ta,getVKVideoIdByMedia:()=>Qr,getVideoRawIdByMedia:()=>Ia,graphEventTypes:()=>Ee,hasEndTemplate:()=>We,interactivesEventTypes:()=>V,isAreaControl:()=>np,isButtonControl:()=>rp,isLastChapter:()=>G,isOneTextCtrlContainer:()=>se,isSupportedManifest:()=>b.isSupportedManifest,isTextControl:()=>De,isVKVariantItem:()=>xa,isValidManifest:()=>Rr,migrateManifestToLatestVersion:()=>b.migrateManifestToLatestVersion,utils:()=>Va,vkVideoIdsToChapterIds:()=>Xr});module.exports=Fa(rh);var tn="1.0.37-dev.a47f72c3.0";var ht=require("@vkontakte/videoplayer-shared/es2024");var qt=class{constructor(e,t){this.layout=e;this.cssVarsManager=t}},tt=class extends qt{constructor(e,t){super(e,t),this.cssVarsManager=t}setContainerLayout(e){e.style.position="relative"}setControlLayout(e,t){let n=this.cssVarsManager.getPropValue("--interactive-content-width"),i=this.cssVarsManager.getPropValue("--interactive-content-height"),o=this.cssVarsManager.getPropValue("--interactive-width"),a=this.cssVarsManager.getPropValue("--interactive-height");e.style.position="absolute",e.style.width=`calc(${n} * ${t.width})`,e.style.height=`calc(${i} * ${t.height})`,e.style.left=`calc(${n} * ${t.x} + ((${o} - ${n}) / 2))`,e.style.top=`calc(${i} * ${t.y} + ((${a} - ${i}) / 2))`}};function rn(r){return"features"in r}var pe=class{constructor(e,t,n){this.container=e,this.options=n,this.factories=new Map,this.controls=[],this.setControls(),this.cssVarsManager=t}featureIsEnabled(e){return this.options&&rn(this.options)&&this.options.features[e]}addControlFactory(e,t){this.factories.set(e.trim().toLowerCase(),t),this.setControls()}removeControlFactory(e){this.factories.delete(e.trim().toLowerCase()),this.setControls()}setControls(){this.controls=this.chooseControls()}chooseControls(){return this.container.controls?.reduce((e,t)=>{let n=t.type.trim().toLowerCase(),i=this.factories.get(n);if(i){let o=i(t,this.options);if(o)return[...e,o]}return[...e]},[])||[]}};var re=require("@vkontakte/videoplayer-shared/es2024");function xe(r,e=1){let t="0",n="0",i="0";return r.length===4?(t="0x"+r[1]+r[1],n="0x"+r[2]+r[2],i="0x"+r[3]+r[3]):r.length===7&&(t="0x"+r[1]+r[2],n="0x"+r[3]+r[4],i="0x"+r[5]+r[6]),`rgba(${+t},${+n},${+i},${e})`}var nn="interactive",P={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},on=(n=>(n.top="flex-start",n.bottom="flex-end",n.center="center",n))(on||{}),sn=(n=>(n.start="flex-start",n.end="flex-end",n.center="center",n))(sn||{}),an=(n=>(n.start="left",n.end="right",n.center="center",n))(an||{}),rt=({target:r,props:e})=>{r.style.alignItems=(e?.gravityVertical&&on[e.gravityVertical])??"center",r.style.justifyContent=(e?.gravityHorizontal&&sn[e.gravityHorizontal])??"center",r.style.textAlign=(e?.alignment&&an[e.alignment])??"center"},nt=({target:r,props:e,fallback:t,dependsOn:n})=>{r.style.color=e?.text?.color??t.textColor,r.style.fontSize=`calc(${n.height} * ${e?.text?.size??t.textSize})`,r.textContent=e?.text?.value??t.textContent},it=({target:r,props:e,fallback:t})=>{r.style.backgroundColor=xe(e?.background?.color??t.backgroundColor,e?.background?.alpha??t.backgroundAlpha)},Te=({target:r,props:e,fallback:t,dependsOn:n,useRawValues:i=!1})=>{let o=i?t.borderWidthRawValue:`calc(${n.height} * ${e?.shape?.border?.width??t.borderWidth})`,a=i?t.roundCornersRawValue:`calc(${n.height} * ${e?.shape?.roundCorners??t.roundCorners})`;r.style.borderWidth=o,r.style.borderStyle="solid",r.style.borderColor=xe(i?t.borderColor:e?.shape?.border?.color??t.borderColor,i?t.borderAlpha:e?.shape?.border?.alpha??t.borderAlpha),r.style.borderRadius=a},ln=({target:r,isDark:e,baseDimension:t,fallback:n})=>{let a=xe(n.shadowColorLight,n.shadowColorAlpha),s=xe(n.shadowColorDark,n.shadowColorAlpha),l=`calc(${t} * ${.25})`,c=`calc(${t} * ${.11})`,d=`0px 0px ${l} ${c} ${e?s:a}`;r.style.boxShadow=d},ue=({target:r,layoutParams:e,fallback:t})=>{let n=e.angle??t.angle;n=n&&n*-1,r.style.transform=`rotate(${n}rad)`};var he=require("@vkontakte/videoplayer-shared/es2024");var Dt="int",ee=(n=>(n.AREA=`${Dt}_area`,n.TEXT=`${Dt}_text`,n.BUTTON=`${Dt}_bttn`,n))(ee||{});function cn(r){return"features"in r}var W="interactive-control",R={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 k=class{constructor(e,t,...n){this.severity=e;this.category=t;this.data=n}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};var Q=class{constructor(e,t){this.control=e;this.options=t;this.container=null;this.controlElement=null;this.subscriptions=new he.Subscription;this.error$=new he.Subject;this.cssVarsManager=null}setCssVarsManager(e){this.cssVarsManager=e}createContainerElement(e){let t=document.createElement("div");t.classList.add(R.wrapper),e.setControlLayout(t,this.control.layoutParams);let n=(this.control.layoutParams.innerSizesDependOn??P.innerSizesDependOn)==="self"?{height:t.style.height,width:t.style.width}:{height:this.cssVarsManager?.getPropValue("--interactive-content-height)")??0,width:this.cssVarsManager?.getPropValue("--interactive-content-width")??0};this.container={element:t,dimensions:n}}createClickListener(e){return t=>{t.stopPropagation(),e()}}featureIsEnabled(e){return this.options&&cn(this.options)&&this.options.features[e]}setEvents(e){!this.container||!this.control.events||this.control.events.forEach(t=>{switch(t.type.trim().toLowerCase()){case"onclick":{if(!this.container)break;this.subscriptions.add((0,he.fromEvent)(this.container.element,"click").subscribe(this.createClickListener(()=>e({action:t.action,controlId:this.control.id,controlType:this.control.type})),i=>{let o=new k(1,1,{message:"Error happened on control interaction",error:i});this.error$.next(o)}));break}default:break}})}removeListeners(){this.subscriptions.unsubscribe()}};var X=(r,e)=>Object.prototype.toString.call(r)===`[object ${e}]`,Y=r=>X(r,"Object"),ot=r=>X(r,"String"),st=r=>X(r,"Array"),at=r=>X(r,"Number"),pn=r=>X(r,"Function"),un=r=>X(r,"Boolean"),Ht=r=>at(r)&&!isNaN(r);var te=r=>Y(r)&&Object.keys(r).length===0,Ut=r=>st(r)&&!r.length;var we=(r,e)=>ot(r)&&(e?r.trim():r).length;var Gt="interactive-blink-anim-reference",L={common:Gt,animation:`${Gt}-animation`,disabled:`${Gt}-disabled`},lt=class{constructor(){this._RAFId=0;this._element=void 0}get element(){return this._element}create(){if(this._element)return;let e=document.createElement("div");e.classList.add(L.common,L.animation),this._element=e}restart(){this._element&&(this._element.classList.add(L.disabled),this.cleanupRAF(),this._RAFId=requestAnimationFrame(()=>{this._element&&(this._element.classList.remove(L.disabled),this.cleanupRAF())}))}cleanupRAF(){this._RAFId&&(cancelAnimationFrame(this._RAFId),this._RAFId=0)}destroy(){this.cleanupRAF(),this._element=void 0}};var zt="interactive-container",j={common:zt,hidden:`${zt}-hidden`,disabled:`${zt}-disabled`};var ct=(r,e)=>{if(r.type.trim().toLowerCase()==="area")return new Wt(r,e)},Wt=class extends Q{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){if(super.createContainerElement(t),!this.container)return;let n=document.createElement("button");n.type="button",n.classList.add(R.common,R.area),n.setAttribute("data-testid",ee.AREA),it({target:n,props:this.control.props,fallback:{...P,backgroundColor:"transparent"}}),ue({target:n,layoutParams:this.control.layoutParams,fallback:P}),this.container.element.append(n),e.append(this.container.element),this.controlElement=n,this.updateShadowStyles(),this.registerEvents()}registerEvents(){if(!this.featureIsEnabled("controlsExpectTimeBlinkAnimation"))return;let e=this.container?.element.parentElement;!e||!this.controlElement||(this.subscriptions.add((0,re.fromEvent)(this.controlElement,"mouseleave").subscribe(()=>{if(e.classList.contains(j.disabled))return;let t=e.parentElement;if(t){let n=t.querySelector(`.${L.common}`);n&&this.syncBlinkAnimation(n)}},t=>this.onError("Error happened in mouseleave callback",t))),this.subscriptions.add((0,re.fromEvent)(this.controlElement,"mouseenter").subscribe(()=>{e.classList.contains(j.disabled)||this.onBlinkHovering()},t=>this.onError("Error happened in mouseenter callback",t))).add((0,re.fromEvent)(this.controlElement,"mouseleave").subscribe(()=>{this.controlElement&&(this.controlElement.style.animation="")},t=>this.onError("Error happened in mouseleave callback",t))))}disable(){this.controlElement&&this.controlElement.classList.add(R.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(R.disabled)}getElement(){return this.controlElement}updateShadowStyles(e){if(!(!this.container||!this.controlElement))if(un(e)){let t=Math.min(this.controlElement.offsetWidth,this.controlElement.offsetHeight)+"px";ln({target:this.controlElement,props:this.control.props,fallback:P,isDark:e,baseDimension:t}),Te({target:this.controlElement,props:this.control.props,fallback:{...P,borderColor:e?P.shadowColorDark:P.shadowColorLight,borderAlpha:1,borderWidthRawValue:"0.1px",roundCornersRawValue:`calc(${this.container.dimensions.height} * ${this.control.props?.shape?.roundCorners??P.roundCorners})`},dependsOn:this.container.dimensions,useRawValues:!0})}else Te({target:this.controlElement,props:this.control.props,fallback:{...P,borderAlpha:0},dependsOn:this.container.dimensions})}toggleBlinkAnimation(e){this.controlElement?.classList.toggle(R.blinkAnim,e),this.controlElement?.classList.toggle(R.blinkAnimArea,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${R.blinkAnimArea}`)||this.controlElement.classList.contains(R.selected)||this.controlElement.classList.contains(L.disabled)||(this.controlElement.classList.add(L.disabled),this.subscriptions.add((0,re.fromEvent)(e,"animationiteration").pipe((0,re.once)()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(L.disabled)},t=>this.onError("Error happened in animationiteration callback",t)))))}onBlinkHovering(){if(!this.controlElement||!this.controlElement.classList.contains(`${R.blinkAnimArea}`)||this.controlElement.classList.contains(R.selected))return;let e=window.getComputedStyle(this.controlElement),t=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=t)})}onError(e="",t){let n=new k(1,1,{message:e,error:t,details:{id:this.control.id}});this.error$.next(n)}onProgress(){}onResize(){}};var ne=require("@vkontakte/videoplayer-shared/es2024");var pt=r=>{let e=document.createElement("span");switch(r){case"Button":case"button":{let t=document.createElement("div"),n={overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center"};Object.assign(t.style,n),t.append(e);let i={display:"inline-block",whiteSpace:"pre",textOverflow:"ellipsis",maxWidth:"initial",maxHeight:"100%",wordBreak:"normal"};return Object.assign(e.style,i),t}default:{let t={display:"inline-block",whiteSpace:"break-spaces",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%",maxHeight:"100%",wordBreak:"break-all"};return Object.assign(e.style,t),e}}};var ut=(r,e)=>{if(r.type.trim().toLowerCase()==="button")return new Kt(r,e)},Kt=class extends Q{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){if(super.createContainerElement(t),!this.container)return;let n=document.createElement("button");n.type="button",n.classList.add(R.common,R.button),n.setAttribute("data-testid",ee.BUTTON),ue({target:n,layoutParams:this.control.layoutParams,fallback:P}),it({target:n,props:this.control.props,fallback:P}),Te({target:n,props:this.control.props,fallback:P,dependsOn:this.container.dimensions}),rt({target:n,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let i=pt(this.control.type.trim().toLowerCase()),o=i.firstElementChild??i;nt({target:o,props:this.control.props,fallback:P,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"))return;let e=this.container?.element.parentElement;!e||!this.controlElement||(this.subscriptions.add((0,ne.fromEvent)(this.controlElement,"mouseleave").subscribe(()=>{if(e.classList.contains(j.disabled))return;let t=e.parentElement;if(t){let n=t.querySelector(`.${L.common}`);n&&this.syncBlinkAnimation(n)}},t=>this.onError("Error happened in mouseleave callback",t))),this.subscriptions.add((0,ne.fromEvent)(this.controlElement,"mouseenter").subscribe(()=>{e.classList.contains(j.disabled)||this.onBlinkHovering()},t=>this.onError("Error happened in mouseenter callback",t))).add((0,ne.fromEvent)(this.controlElement,"mouseleave").subscribe(()=>{this.controlElement&&(this.controlElement.style.animation="")},t=>this.onError("Error happened in mouseleave callback",t))))}disable(){this.controlElement&&this.controlElement.classList.add(R.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(R.disabled)}getElement(){return this.controlElement}toggleBlinkAnimation(e){this.controlElement?.classList.toggle(R.blinkAnim,e),this.controlElement?.classList.toggle(R.blinkAnimButton,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${R.blinkAnimButton}`)||this.controlElement.classList.contains(R.selected)||this.controlElement.classList.contains(L.disabled)||(this.controlElement.classList.add(L.disabled),this.subscriptions.add((0,ne.fromEvent)(e,"animationiteration").pipe((0,ne.once)()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(L.disabled)},t=>this.onError("Error happened in animationiteration callback",t)))))}onBlinkHovering(){if(!this.controlElement||!this.controlElement.classList.contains(`${R.blinkAnimButton}`)||this.controlElement.classList.contains(R.selected))return;let e=window.getComputedStyle(this.controlElement),t=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=t)})}onError(e="",t){let n=new k(1,1,{message:e,error:t,details:{id:this.control.id}});this.error$.next(n)}onProgress(){}onResize(){}updateShadowStyles(){}};var hn=(r,e)=>{if(r.type.trim().toLowerCase()==="text")return new Qt(r,e)},Qt=class extends Q{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){if(super.createContainerElement(t),!this.container)return;let n=document.createElement("div");n.classList.add(R.common,R.text),n.setAttribute("data-testid",ee.TEXT),ue({target:n,layoutParams:this.control.layoutParams,fallback:P}),rt({target:n,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let i=pt(this.control.type.trim().toLowerCase()),o=i.firstElementChild??i;nt({target:o,props:this.control.props,fallback:P,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(){}onError(){}};var dt=(r,e,t,n)=>{if(r.type.trim().toLowerCase()==="choice")return new Xt(r,e,t,n)},Xt=class extends pe{constructor(t,n,i,o){super(t,i,o);this.containerElement=null;this.controlSubscriptions=new ht.Subscription;this.error$=new ht.Subject;this.rootElement=n,this.layout=new tt(this.container.layout,i),this.cssVarsManager=i,this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",ut),this.addControlFactory("text",hn),this.addControlFactory("area",ct)}createView({eventCallback:t}){let n=document.createElement("div");return n.classList.add(j.common,j.disabled),requestAnimationFrame(()=>{n.classList.remove(j.disabled)}),this.layout.setContainerLayout(n),this.controls.forEach(i=>{i.setCssVarsManager(this.cssVarsManager),i.createView({parentElement:n,callbacks:{setControlLayout:this.layout.setControlLayout}}),i.setEvents(t),this.controlSubscriptions.add(i.error$.subscribe(this.error$))}),this.rootElement.append(n),this.isRemoved=!1,this.containerElement=n,n}hide(){let t=this.getElement();t&&t.classList.add(j.hidden)}show(){let t=this.getElement();t&&t.classList.remove(j.hidden)}enable(){let t=this.getElement();t&&(t.classList.remove(j.disabled),this.controls.forEach(n=>n.enable()),this.isDisabled=!1)}disable(){let t=this.getElement();t&&(t.classList.add(j.disabled),this.controls.forEach(n=>n.disable()),this.isDisabled=!0)}removeView(){let t=this.getElement();t&&(this.controlSubscriptions.unsubscribe(),this.controls.forEach(n=>n.removeListeners()),t.remove(),this.isRemoved=!0,this.containerElement=null)}fakeRemove(){this.isRemoved||(this.isRemoved=!0)}getElement(){return this.containerElement}onProgress(t,n){n&&this.controls.forEach(i=>{i.onProgress(t)})}onResize(t){t&&this.controls.forEach(n=>{n.onResize()})}updateControlsShadowStyles(t){this.controls.forEach(n=>n.updateShadowStyles(t))}toggleBlinkAnimation(t){this.controls.forEach(n=>n.toggleBlinkAnimation(t))}};var Oa=F(wr(),1),g=require("@vkontakte/videoplayer-shared/es2024"),Ie=require("@vkontakte/videoplayer-statistics/es2024");var Co=require("@vkontakte/videoplayer-shared/es2024");function Fe(r,e){let t;return(...n)=>{clearTimeout(t),t=setTimeout(()=>r(...n),e)}}var vo="video_interactive",yo="videoint";var bo=250,Be=class{constructor(e){this.handleZoomChange=Fe(e=>{this.lastZoomInfo=e},bo);this.onResize=e=>{if(!this.isReady||this.isHidden||!e[0].contentRect.width||!e[0].contentRect.height)return;let t=this.getNextPoint();t&&this.ngEditor?.zoomTo(t,void 0,{isFromCenter:!0}),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,t=[])=>{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(t),this.ngEditor&&(this.manifest.metadata.id!==this.currentManifestId?(this.ngEditor.update(e),this.currentManifestId=this.manifest.metadata.id):this.ngEditor.setVisitedChapters(Array.from(t)),this.isReady=!0)};this.init(e)}init({root:e,onOpenPreviewClick:t,onError:n,lang:i,visitedChapters:o=[]}){this.isReady=!1,this.isHidden=!0,this.manifest=null,this.visitedChapterIds=new Set(o),this.onOpenPreviewClick=t,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=tp(e),this.resizeObserver=new ResizeObserver(Fe(this.onResize,bo)),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(0,Co.loadVKLangPack)(this.lang,vo,yo)}catch{this.onError?.("Unable to load graph language pack")}let{GraphEditor:t}=await import("@interactiveplatform/movika-graph-editor");this.ngEditor=new t(this.graphWrapperElement,{mode:"view",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 tp(r){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",r.append(e),e}var qe=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(t=>t.id!==e)};this.getNextInteractiveTime=(e=3e3)=>{if(!this._containers.length||this._player===null)return null;let t=-1,n=!1,i=Math.round(this._player.info.position$.getValue()*1e3);for(let o of this._containers){let a=o.startTime-e;if(a<=i&&(o.endTime&&i<=o.endTime||o.endTime===null)){n=!0;break}i<a&&(t=t===-1?a:Math.min(t,a))}return!n&&t!==-1?t:null}}};var b=require("@interactiveplatform/movika-manifest");var go={metadata:"Object",chapters:"Array"},Rr=r=>{if(!Y(r))return!1;for(let e in go)if(!r[e]||!X(r[e],go[e]))return!1;return(0,b.isSupportedManifest)(r.metadata.version)},De=r=>r.type===b.ControlTypes.Text,rp=r=>r.type===b.ControlTypes.Button,np=r=>r.type===b.ControlTypes.Area,ip={Choice:"Choice",TextInput:"TextInput"},op={Button:"Button",Area:"Area",Text:"Text"},sp={onClick:"onClick",onSuspense:"onSuspense"},Or={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var It=class{constructor(){this.listeners={}}addListener(e,t){return this.listeners[e]=this.listeners[e]||[],this.listeners[e].push(t),this}on(e,t){return this.addListener(e,t)}once(e,t){this.listeners[e]=this.listeners[e]||[];let n=()=>{t(),this.off(e,n)};return this.listeners[e].push(n),this}off(e,t){return this.removeListener(e,t)}reset(){this.listeners={}}removeListener(e,t){let n=this.listeners[e]||[];for(let i=n.length;i>0;i--)if(n[i]===t){n.splice(i,1);break}return this}emit(e,...t){let n=this.listeners[e];return n?(n.forEach(i=>{i(...t)}),!0):!1}listenerCount(e){return this.rawListeners(e).length}rawListeners(e){return this.listeners[e]||[]}};var xt=class{constructor(e){this.fns=[];this.addFn=(e,t=!1)=>{pn(e)&&(this.fns.push(e),t&&this.updateFn())};this.removeFn=(e,t=!1)=>{this.fns=this.fns.filter(n=>n!==e),t&&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=[]}};var es=F(Jo(),1),Tt=class r{constructor(e){this.rootElement=e;this.rootElementProps={};this.isCssVarsSupported=r.checkCssVarsSupport(e)}static checkCssVarsSupport(e){let t="--test-key",n="test";e.style.setProperty(t,n);let i=e.style.getPropertyValue(t)===n;return i&&e.style.removeProperty(t),i}getPropValue(e){return this.isCssVarsSupported?`var(${e})`:this.rootElementProps[e]??""}setup(e){if(this.rootElementProps={...this.rootElementProps,...e},this.isCssVarsSupported)for(let[t,n]of(0,es.default)(e))this.rootElement.style.setProperty(t,n)}cleanup(){for(let e in this.rootElementProps)this.rootElement.style.removeProperty(e);this.rootElementProps={}}setProp(e,t){this.rootElementProps[e]=t,this.isCssVarsSupported&&this.rootElement.style.setProperty(e,t)}};var ds=require("@vkontakte/videoplayer-shared/es2024");var St=class{constructor(e){this.loaders={chapterLoaders:e?.chapterLoaders??[],manifestLoaders:e?.manifestLoaders??[]}}async exec(e,t){return Bp(...this.loaders[e])(t)}};function Bp(...r){return async function(t){let n=[...r];for(;n.length>0;)t=await n.shift()(t);return t}}function He(r,e,t){return r?{...r,[e]:r[e]?[t,...r[e]]:[t]}:{[e]:[t]}}function At({actions:r,errors:e,chapterId:t,...n}){if(t){let i=r.getManifest();if(i){let o=r.getChapter(i.chapters,t);if(o){let a=r.getMedia(i.media,o.videoId),s=r.getGraph(i.graph,o.id);return a?{...n,actions:r,errors:e,result:{chapter:o,media:a,graph:s}}:{...n,errors:He(e,At.name,"Could not find media"),actions:r}}}}return{...n,errors:He(e,At.name,"Could not find chapter"),actions:r}}var wt=class{constructor(){Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}addEventListener(e,t,n){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:t,options:n})}removeEventListener(e,t){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===t){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 a=n[i];try{a.callback.call(this,e)}catch(s){Promise.resolve().then(()=>{throw s})}a.options&&a.options.once&&this.removeEventListener(e.type,a.callback)}return!e.defaultPrevented}},Ce=class extends wt{constructor(){super(),this.listeners||wt.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)}},Ue=class{constructor(){Object.defineProperty(this,"signal",{value:new Ce,writable:!0,configurable:!0})}abort(e){let t;try{t=new Event("abort")}catch{typeof document<"u"?document.createEvent?(t=document.createEvent("Event"),t.initEvent("abort",!1,!1)):(t=document.createEventObject(),t.type="abort"):t={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(t)}toString(){return"[object AbortController]"}};typeof Symbol<"u"&&Symbol.toStringTag&&(Ue.prototype[Symbol.toStringTag]="AbortController",Ce.prototype[Symbol.toStringTag]="AbortSignal");function Rt(r){return r.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill"),!0):typeof r.Request=="function"&&!r.Request.prototype.hasOwnProperty("signal")||!r.AbortController}function Nr(r){typeof r=="function"&&(r={fetch:r});let{fetch:e,Request:t=e.Request,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:i=!1}=r;if(!Rt({fetch:e,Request:t,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:i}))return{fetch:e,Request:o};let o=t;(o&&!o.prototype.hasOwnProperty("signal")||i)&&(o=function(c,d){let v;d&&d.signal&&(v=d.signal,delete d.signal);let m=new t(c,d);return v&&Object.defineProperty(m,"signal",{writable:!1,enumerable:!1,configurable:!0,value:v}),m},o.prototype=t.prototype);let a=e;return{fetch:(l,c)=>{let d=o&&o.prototype.isPrototypeOf(l)?l.signal:c?c.signal:void 0;if(d){let v;try{v=new DOMException("Aborted","AbortError")}catch{v=new Error("Aborted"),v.name="AbortError"}if(d.aborted)return Promise.reject(v);let m=new Promise((y,O)=>{d.addEventListener("abort",()=>O(v),{once:!0})});return c&&c.signal&&delete c.signal,Promise.race([m,a(l,c)])}return a(l,c)},Request:o}}var Ge=Rt({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),ts=Ge?Nr({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,Lr=Ge?ts.fetch:window.fetch,ff=Ge?ts.Request:window.Request,vf=Ge?Ue:window.AbortController,yf=Ge?Ce:window.AbortSignal;var Ot=(r="",e="")=>{let t=r.split("."),n=e.split("."),i=0;for(let o=0;o<Math.max(t.length,n.length)&&!i;o++)t[o]>n[o]?i=1:t[o]<n[o]?i=-1:i=0;return i};var qp=async r=>{try{let e={},t;if(ot(r)){t=new URL(r).href;let i=await Lr(t);if(!i.ok)return{};e=await i.json()}else if(Y(r))e=r;else return{};if(!Rr(e))return{};let n=e.metadata.media;if(ot(n)&&!("media"in e))try{let i;t?i=new URL(n,t).href:(i=new URL(n).href,t=i);let o=await Lr(i);if(!o.ok)throw new Error;e.metadata.media=await o.json()}catch{return Up(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch{return{}}};async function rs(r){let{manifest:e,manifestURL:t}=await qp(r);if(!e)throw new Error("Failed on fetch");let n=(0,b.migrateManifestToLatestVersion)(e);return n.media=Dp(n.media,t),delete n.metadata.media,n}function kt(r,e){if(e)return r.find(t=>t.id===e)}function jr(r,e){return r.edit?.chapters?r.edit.chapters.find(t=>t.id===e):r.view?.chapters?r.view.chapters.find(t=>t.id===e):void 0}function $r(r,e){return r.videos.find(t=>t.id===e)}function Dp(r,e){return{...r,videos:r.videos.map(t=>({...t,variants:t.variants.map(n=>{let i="url"in n?n.url:"",o=Hp(i,e);return{...n,url:o||i}})}))}}function Hp(r="",e){try{return new URL(r,e).href}catch{return""}}function Up(r){return Ot(r,"3.2.0")>=0}var cs=F(ze(),1);var Vt=r=>st(r)&&!Ut(r),G=r=>r.order==="end",We=r=>st(r.containers)&&!Ut(r.containers)&&G(r),ps=(r,e)=>{let t=r*1e3;return Vt(e.controls)&&t<(e.startTime??0)},_r=(r,e)=>{let t=r*1e3;return Vt(e.controls)&&t>=(e.startTime??0)&&t<=(e.endTime??1/0)};var oe=(r=[])=>r.some(e=>e.action.type==="expect"),Fr=(r=[])=>r.find(e=>e.action.type==="expect"),Jp=r=>r?.length===1,se=r=>Jp(r)&&De(r[0]);function us(r=[],e=1/0,t=[]){return r.filter(({container:n})=>!(0,cs.default)(t,n.container.id)&&oe(n.container.events)&&n.container.endTime===e&&!n.isRemoved)}function Pt({gameControllers:r=[],subjectName:e,subjectId:t,execFn:n}){for(let i of r)if(e==="container"&&i.container.container.id===t){n(i),us(r,i.container.container.endTime,[i.container.container.id]).forEach(a=>{n(a)});break}}var hs=(r,e)=>{let t=A=>e.find(({container:u})=>u.container.id===A)?.container.isRemoved,n=oe(r.events)&&!t(r.id),i=(A,C=!1,u=!1)=>{let h=u?"every":"some";return A.controls[h](f=>{let I=C?A.endTime===r.endTime:!0;return f.events?.[h](E=>E.action?.type===Or.openURI)&&I})},o=A=>A.some(({container:C})=>i(C.container,!0,!1)&&!C.isRemoved),a=A=>A.every(({container:C})=>C.isRemoved?!0:i(C.container,!0,!0)),s=us(e,r.endTime,[r.id]).length,l=A=>A.controls.some(C=>C.events?.some(u=>u.action?.args?.shouldOpenNow)),c=n||s>0,d=o(e),v=i(r),m=a(e),y=n?!1:s>0,O=l(r);return{isExpectTime:c,hasOtherExpect:s>0,hasOpenURIEvent:d,hasOpenURIEventInCurrentContainer:v,isAllOpenURIEventsValid:m,isExpectEventForCurrentContainer:y,hasShouldOpenNowEvent:O}};var ae=class extends St{constructor(t,n){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new ds.ValueSubject(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(t){this.release();let n=await this.exec("manifestLoaders",{actions:{addErrorMessage:He},result:null,errors:null,source:t});return n.errors&&this.errorHandler(n.errors),this.manifest=await rs(n.result??t),this}async setInitial(){return this.setNext()}async setNext(t=this.manifest?.metadata.initChapterId){if(!t)return this;this.prevChapter$.next(this.chapter);let n=await this.exec("chapterLoaders",At({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:jr,getChapter:kt,getMedia:$r,getByBranches:this.getByBranches.bind(this),addErrorMessage:He},result:null,errors:null,chapterId:t}));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(t){this.onError(t),console.error("Something went wrong with loaders",{errors:t})}getInitial(){return this.getByChapterId(this.manifest?.metadata.initChapterId)||null}getByChapterId(t=this.manifest?.metadata.initChapterId){if(!t||!this.manifest)return null;let n=kt(this.manifest.chapters,t);if(n){let i=$r(this.manifest.media,n.videoId),o=jr(this.manifest.graph,n.id);if(i)return{chapter:n,media:i,graph:o}}return null}getBranches(t=this.chapter?.id){if(t===this.chapter?.id)return this.getByBranches(this.chapter?.branches);{let n=kt(this.manifest?.chapters||[],t);return this.getByBranches(n?.branches)}}getByBranches(t=[]){return t.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?G(this.chapter):!1}};var Is=F(Mt(),1),xs=require("@vkontakte/videoplayer-core/es2024"),Z=require("@vkontakte/videoplayer-shared/es2024");var gs=r=>{let e=r.variants.find(t=>t.payload?.type==="vk");if(e&&e.payload){let[t,n]=e.payload.id.split("_");return[t,n]}return[]};var Es=F(Mt(),1);function Br(){let r=new Map;function e({listId:o=Math.random().toString(),itemId:a=Math.random().toString(),...s}){let l=r.get(o),c={...s};return l?l[a]=c:r.set(o,{[a]:c}),{listId:o,itemId:a,...s}}function t(o){o.player.destroy(),o.container.remove(),o.subscription.unsubscribe(),o.statistics?.oneStat.destroy(),o.statistics?.statSubscription.unsubscribe()}function n(o,a){let s=r.get(o);if(!s)throw Error("Can't remove. Not find.");if(a){let l=s[a];l&&t(l),delete s[a],Object.keys(s).length||r.delete(o)}else{for(let l of(0,Es.default)(s))t(l);r.delete(o)}}function i(){for(let o of r)n(o[0])}return{createPlayer:e,removePlayer:n,map:r,removeAll:i}}var ge=F(ze(),1);function qr(r,e=[]){let t={},n,i=!e.length;for(let o of r.variants)if(!n&&"cover"in o&&(n=o.cover),"url"in o)switch(o.type.toLowerCase()){case"mp4":(i||(0,ge.default)(e,"mp4"))&&(t.MPEG={...t.MPEG,[o.standard??"Invariant quality"]:o.url});break;case"mpeg":(i||(0,ge.default)(e,"mpeg"))&&(t.MPEG={...t.MPEG,[o.standard??"Invariant quality"]:o.url});break;case"hls":(i||(0,ge.default)(e,"hls"))&&(t={...t,HLS:{type:"url",url:o.url}});break;case"dash":(i||(0,ge.default)(e,"dash"))&&(t={...t,DASH_SEP:{compatibilityMode:!0,type:"url",url:o.url}});break;default:break}return{sources:t,thumbUrl:n,title:r.title??""}}var Ke=(r,e)=>{let t=r.info.currentQuality$.getValue(),n=r.info.availableQualities$.getValue();t!==e&&(0,ge.default)(n,e)&&(r.setQuality(e),r.setAutoQuality(!1))};var ou=2;function Dr(r){let e=Br(),t=new Z.Subscription,n={},i=null,o=!1,a,s=new Z.ValueSubject(null);r&&l(r);function l(C){i=C}function c(C,u,h){if(!i)throw Error("need to set interactive controller");if(!i.options)return;let I=(e.map.get(C)??{})[u];if(I){n={chapterId:h,listId:C,itemId:u,...I};let E=n.player;n.subscription.add(E.info.currentQuality$.subscribe(x=>{let w=E.info.position$.getValue(),$=E.info.isAutoQualityEnabled$.getValue();if(!(!x||!w||$))for(let T of e.map)(0,Is.default)(T[1]).forEach(({player:M})=>{Ke(M,x)})})).add(E.events.started$.subscribe(()=>{d(u)})),I.container.remove(),i.setPlayer(I.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(C){if(!i)throw Error("need to set interactive controller");if(te(n)||C!==n.itemId)return;let u=i.getChapterBranches(),h=new Set;for(let f of u)h.has(f.media.id)||(await m({media:f.media,chapterId:f.chapter.id,setAsActive:!1,title:f.chapter.label}),h.add(f.media.id))}async function v({chapter:{id:C},manifestVideo:u}){if(te(n)||!i)return;let h=n.player.info.muted$.getValue(),f=n.player.info.currentQuality$.getValue(),I=n.player.info.isAutoQualityEnabled$.getValue(),E=n.player.info.volume$.getValue(),x=n.player.info.currentPlaybackRate$.getValue(),w=!I,$=!1;for(let T of e.map)if(T[0]===u.id&&!i.state.isReplay$.getValue()){let M=Object.keys(T[1]);for(let N of M)N===n.itemId?(M.length<ou||($=!0),e.removePlayer(T[0],N)):($=!0,c(T[0],N,C),w?Ke(n.player,f):n.player.setAutoQuality(!0),n.player.setVolume(E),n.player.setMuted(h),n.player.setPlaybackRate(x))}else e.removePlayer(T[0]);$||(await m({media:u,chapterId:C,setAsActive:!0,playbackRate:x}),w?Ke(n.player,f):n.player.setAutoQuality(!0),n.player.setVolume(E),n.player.setMuted(h))}async function m({media:C,chapterId:u,prefetch:h=!0,setAsActive:f=!0,autoplay:I=!1,preferredExt:E,title:x,playbackRate:w}){let $=Math.random().toString(),T=document.createElement("div");a.append(T);let M;if(i?.options?.vkVideoLoader){let Je=gs(C);Je.length&&(M=await i.options.vkVideoLoader(...Je))}let N=i?.options?.coreConfig||void 0,z={...N,configName:[...N?.configName??[],"interactive"]},J={container:T,...M?.videos?.[0]||{sources:qr(C,E).sources},title:x,failoverHosts:M?.failoverHosts||[]},_=new xs.Player(z,Z.Tracer.createRootTracer());_.initVideo(J);let le=null;if(M?.videos&&i?.options.createOneStat){let Je=M.videos[0],Bt=i.options.createOneStat(Je),Jr=new Z.Subscription;Bt&&(Jr.add(Bt.attachTo(_)),le={oneStat:Bt,statSubscription:Jr})}let Zr=new Z.Subscription,Pa=n?.player?.info.isAutoQualityEnabled$.getValue();Zr.add(_.events.canplay$.subscribe(function(){Pa||Ke(_,n.player.info.currentQuality$.getValue()),w&&_.setPlaybackRate(w)}));let ce=e.createPlayer({listId:C.id,itemId:$,player:_,container:T,sources:qr(C,E).sources,config:J,subscription:Zr,statistics:le});return f&&c(C.id,ce.itemId,u),I&&ce.player.play(),h&&!I&&ce.player.prepare(),{player:ce.player,config:ce.config,statistics:ce.statistics}}function y(){O(),i=null,a.remove()}function O(){t.unsubscribe(),e.removeAll(),n={},o=!1}async function A(){if(!i)throw Error("need to set interactive controller");O(),a=document.createElement("div");let{media:C,chapter:u}=i.getCurrentChapter();C&&u?(t.add(i.events.chapterChanged$.subscribe(v)),await m({media:C,chapterId:u.id,title:u.label})):console.error("not found")}return{...e,init:A,setInteractiveController:l,createPlayer:m,removeAll:y,getActivePlayer:function(){return n},activePlayerChanged:s}}var S={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},Ee={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},V={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};var Ss=F(ze(),1),As=require("@vkontakte/videoplayer-shared/es2024");function Hr(r){return function(...t){return r(...t.reverse())}}function Qe(r,...e){return(...t)=>Y(e[0])&&Y(t[0])?r({...e[0],...t[0]}):r(...e,...t)}var Nt=class{constructor({player:e,container:t,branches:n,selectBranches:i,interactiveEvents:o,globalEvents:a,globalEventEmitter:s,getContainerEventState:l,permanentTextControls:c,interactiveTimeOpenUri:d,disabledControls$:v,onRemove:m,onError:y}){this.hide=()=>{setTimeout(()=>{this.gameState!==4&&(oe(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:t}=this.getContainerEventState();if(this.container.show?.(),this.interactiveTimeOpenUri&&t)return;this.emitContainerVisibilityEvent(!0,!1)}else{let t={isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.emitContainerVisibilityEvent(!1)},onEvent:(i,o)=>{let{isExpectTime:a,hasOtherExpect:s,hasOpenURIEvent:l,hasOpenURIEventInCurrentContainer:c,isAllOpenURIEventsValid:d,hasShouldOpenNowEvent:v}=this.getContainerEventState(),m=this.interactiveTimeOpenUri&&!c,y=this.interactiveTimeOpenUri&&c;if((!this.interactiveTimeOpenUri||m)&&(this.isSelectedControlEvent=!0),i!==!1){if(!this.selectBranches.state.isExpect&&(!this.interactiveTimeOpenUri||m)){if(this.interactiveTimeOpenUri){let O=!s&&!d&&c;O&&this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:O})}this.removeView()}this.emitContainerVisibilityEvent(!1)}if(this.gameState===4||this.gameState===3||this.selectBranches.state.isExpect||this.interactiveTimeOpenUri&&l&&this.gameState!==5){if(y){let A=((C,u,h,f)=>!C&&!u&&h||C&&!u&&h&&!f||C&&!u&&h&&f)(a,s,d,this.isSelectedContainerEvent);this.fakeRemoveView(A)}else this.removeView(),this.emitContainerVisibilityEvent(!1);(!a||!s||!v)&&(this.selectBranches.stopExpect(),o())}},isEOV:()=>this.gameState===4},n=Qe(this.selectBranches.onControlEvent,t);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,Ss.default)(i,this.gameState)&&!this.isPermanentText)return;let o=this.player.getExactTime();if(ps(o,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(_r(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,v=this.interactiveTimeOpenUri&&c;if(v&&!d){let m=this.container.getElement();m&&(m.style.visibility!=="hidden"&&this.container.hide?.(),this.container.isRemoved||this.fakeRemoveView())}!this.isPermanentText&&!v&&this.removeView()}let a=_r(o,this.container.container),s=this.container.container.startTime?[this.container.container.startTime,this.container.container.endTime??1/0]:[],l={subjectId:this.container.container.id,subjectName:"container",range:s,currentTime:o,isInteractiveTime:a};this.container.onProgress(o*1e3,a),this.globalEventEmitter.emit(S.eachTick,l),this.globalEvents.eachTick$.next(l)};this.container=t,this.branches=n,this.selectBranches=i,this.subscription=new As.Subscription,this.player=e,this.interactiveEvents=o,this.getContainerEventState=l,this.isPermanentText=c&&se(t.container.controls),this.interactiveTimeOpenUri=d,this.disabledControls$=v,this.onRemove=m,this.globalEventEmitter=s,this.gameState=0,this.globalEvents=a,this.onError=y,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}emitContainerVisibilityEvent(e,t=!1){e?(this.globalEventEmitter.emit(S.interactives,{subjectId:this.container.container.id,subjectName:"container",type:V.visibility,visibility:e,isFirst:t}),this.globalEvents.interactiveVisibilityChanged$.next({subjectId:this.container.container.id,subjectName:"container",type:"visibility",visibility:e,isFirst:t})):(this.globalEventEmitter.emit(S.interactives,{subjectId:this.container.container.id,subjectName:"container",type:V.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?.()})),this.subscription.add(this.container.error$.subscribe(this.onError))}selectContainerEvent(e=!1){let{isExpectEventForCurrentContainer:t}=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,!t&&!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:t}=this.getContainerEventState(),n=this.interactiveTimeOpenUri?e||t:oe(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(S.interactives,{subjectId:this.container.container.id,subjectName:"container",type:V.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 ws=(r=[])=>r.reduce((e,t,n)=>{let i=(t?.controls??[]).filter(o=>!De(o));if(Vt(i)){let o=[t.startTime??0,t.endTime??1/0],a={id:t.id,isRemoved:!1};if(!n)e.push({subjects:[a],range:o});else{let s=[],l=-1/0,c=1/0,d=[],v=[];for(let m=0;m<e.length;m++){let y=e[m];if(v.push(...y.subjects),y.range[0]<c&&(c=y.range[0]),y.range[1]>l&&(l=y.range[1]),o[0]>=y.range[0]&&o[1]<=y.range[1])return e[m].subjects.push(a),e;o[0]<y.range[0]&&o[1]>y.range[0]&&(s.push(m),d=d.concat(y.subjects)),o[0]>=y.range[0]&&o[0]<=y.range[1]&&(s.push(m),d=d.concat(y.subjects),o[0]=y.range[0]),o[1]>=y.range[0]&&o[1]<=y.range[1]&&(s.push(m),d=d.concat(y.subjects),o[1]=y.range[1])}if(v.push(a),o[0]<=c&&o[1]>=l)return[{subjects:v,range:o}];s.length&&s.reverse().forEach(m=>{e.splice(m,1)}),e.push({subjects:d.concat([a]),range:o})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);var la=F(ze(),1),Wr=F(Mt(),1),ca=F(sa(),1);function aa(){let r={};function e(){for(let s in r)Object.prototype.hasOwnProperty.call(r,s)&&delete r[s]}function t(s){let l={};for(let c in r)+c<=s&&(l[c]=r[c]);return l}function n(s){let l={};for(let c in r)+c>=s&&(l[c]=r[c]);return l}function i({timestamp:s,priority:l,initiator:c}){if(Ht(s)){let d=r[s]??null;if(d&&l&&we(l,!0)){let v={},m=d[l];return m&&(v={...v,...m}),v=te(v)?null:v,v&&we(c,!0)?v[c]??null:v}return d}return null}function o({timestamp:s,priority:l,initiator:c}){if(Ht(s))if(r[s]){if(l&&we(l,!0))if(r[s][l]){if(c&&we(c,!0))if(r[s][l][c]){if(delete r[s][l][c],!te(r[s][l]))return!0}else return!1;if(delete r[s][l],!te(r[s]))return!0}else return!1;return delete r[s]}else return!1;return!1}function a({timestamp:s,priority:l,initiator:c,...d}){r[s]?.[l]?.[c]?r[s][l][c].push({...d}):r[s]?.[l]?r[s][l]={...r[s][l],[c]:[{...d}]}:r[s]?r[s]={...r[s],[l]:{[c]:[{...d}]}}:r[s]={[l]:{[c]:[{...d}]}}}return{map:r,remove:o,add:a,removeAll:e,get:i,getLte:t,getGte:n}}var Wu=[b.EventActionTypes.expect,b.EventActionTypes.setNextBranch],Ku=1/0;function pa(r,e){let t=r,n,i=Qu(e),o=aa(),a,s=()=>{y(),u()},l=h=>{o.add.call(void 0,h),O()},c=(h=[])=>{for(let f of h)if(f.action(),(0,la.default)(Wu,f.actionType))break},d=(h=1/0)=>{let f=jt(o.get({timestamp:h,priority:"control"})??{}),I=jt(o.get({timestamp:h,priority:"container"})??{}),E=jt(o.get({timestamp:h,priority:"chapter"})??{});return[...f,...I,...E]},v=h=>{i.isReady(h)&&c(d(h))},m=()=>{c([...jt(o.get({timestamp:1/0,priority:"chapter"})??{})])},y=()=>{n&&(a?.unsubscribe(),n=void 0)},O=()=>{n||(n=()=>setTimeout(()=>{v(1/0)}),a=t.events.ended$.subscribe(n))},A=h=>{y(),t=h},C=h=>{h.priority==="container"&&i.resetCalled(h.timestamp),o.remove(h)},u=()=>{i.release(),o.removeAll()};return{setPlayer:A,add:l,remove:C,exec:v,execEndOfVideo:m,listen:O,unlisten:y,release:s,containersEventsCallState:i,getPreparedToExecActions:d}}function Qu(r){let e=new Map;return{setCalled:({timestamp:s,id:l})=>{let c=e.get(s);c&&c[l]!==void 0&&(c[l]=!0)},setData:(s=[])=>{for(let l of s){let c=l.endTime??Ku,d=e.get(c);e.set(c,{...d,[l.id]:!1})}},resetCalled:s=>{let l=e.get(s);if(l)for(let c in l)l[c]=!1},isReady:s=>{let l=e.get(s);if(!l)return!0;let c=(0,Wr.default)(l);return r?c.some(v=>v):!c.some(v=>!v)},release:()=>e.clear()}}function jt(r){return(0,ca.default)((0,Wr.default)(r)).sort(e=>e.actionType===b.EventActionTypes.expect?-1:1)}var ua={videoContentHeight:0,videoContentWidth:0},ha=r=>{let{height:e,width:t}=r.info.intrinsicVideoSize$.getValue()||{};if(!(e&&t))return ua;let{clientHeight:n,clientWidth:i}=r.experimental.element$.getValue()||{};if(!(n&&i))return ua;let o=e/t,a=n/i,s,l;return a>o?(l=i,s=i*o):a<o?(l=n/o,s=n):(l=i,s=n),{videoContentWidth:l,videoContentHeight:s}};var Xu=250;function da(r){let e,t=new ResizeObserver(s=>{o(s),e=o.bind(null,s)});function n(s){let{parentElement:l,player:c,cssVarsManager:d}=r();if(!l||!c)return;let{videoContentWidth:v,videoContentHeight:m}=ha(c);d.setup({"--interactive-content-width":`${v}px`,"--interactive-content-height":`${m}px`,"--interactive-width":`${s[0].contentRect.width}px`,"--interactive-height":`${s[0].contentRect.height}px`})}function i(){let{parentElement:s}=r();s.removeAttribute("style")}let o=Fe(s=>{let{fns:l=[]}=r();n(s);for(let c of l)c()},Xu);function a(){e=void 0,t.disconnect(),i()}return{resizeObserver:t,calc:()=>{e?.()},release:a}}var Yu=r=>Math.floor(Math.random()*r),fa=r=>{let e=r.length,t=1/0,n=null;for(;e--;){let i=r[e],o=i.weight??1;o<t&&(t=o,n=i)}return n},va=r=>{let e=r.length,t=-1/0,n=null;for(;e--;){let i=r[e],o=i.weight??0;o>t&&(t=o,n=i)}return n};var ya=r=>{let e=r.length,t=Yu(e);return r[t]},ma=1,ba=r=>{let e=0;for(let n=0;n<r.length;++n)e+=r[n].weight??ma;let t=Math.random()*e;e=0;for(let n=0;n<r.length-1;++n)if(e+=r[n].weight??ma,e>=t)return r[n];return r[r.length-1]};var Ca={shouldOpenNow:!0,isDetachContainer:!0},ga="after-expect",Kr=(r,e=!1)=>({...r,args:e?{...r.args,...Ca}:{...Ca,...r.args}}),Ea=({globalEventEmitter:r,globalEvents:e,player:t,interactiveEvents:n})=>{let i={isExpect:!1},o=()=>{i.isExpect&&(i.isExpect=!1)},a=({action:u,controlType:h,controlId:f,containerId:I,branches:E=[],onEvent:x,isEOV:w=()=>!1,isDisabled:$=()=>!1})=>{let T=Kr(u,w()),M={timestamp:1/0,priority:"control",initiator:f,actionType:T.type},N=$(),z=r.emit.bind(r,S.interactives,{subjectId:f,subjectType:h,subjectName:"control",type:N?V.actionChoiceCanceled:V.actionChoice,actionType:u.type,payload:{invokeImmediately:T.args.shouldOpenNow,containerId:I,...T.args}}),J=()=>{e.interactiveActionChoice$.next({subjectId:f,subjectType:h,subjectName:"control",type:N?"action-choice-canceled":"action-choice",actionType:u.type,payload:{invokeImmediately:T.args.shouldOpenNow,containerId:I,...T.args}})};if(N){z(),J();return}switch(T.type.trim().toLowerCase()){case b.EventActionTypes.setNextBranch.trim().toLowerCase():{let _=E.find(le=>le.id===T.args.branchId);if(!_)return;x(T.args.isDetachContainer,y.bind(null,{subjectId:f,subjectName:"control"})),z(),J(),T.args.shouldOpenNow?A({subjectId:f,subjectName:"control",subjectType:h,action:T,payload:{chapterId:_.chapterId,autoSelect:!1}}):n.add({...M,action:A.bind(null,{subjectId:f,subjectName:"control",subjectType:h,action:T,payload:{chapterId:_.chapterId,autoSelect:!1}})});return}case b.EventActionTypes.continuePlayback.trim().toLowerCase():{x(T.args.isDetachContainer,y.bind(null,{subjectId:f,subjectName:"control"})),z(),J(),T.args.shouldOpenNow?O({subjectId:f,subjectName:"control",subjectType:h,action:u}):n.add({...M,action:O.bind(null,{subjectId:f,subjectName:"control",subjectType:h,action:u})});return}case b.EventActionTypes.openURI.trim().toLowerCase():{x(T.args.isDetachContainer,y.bind(null,{subjectId:f,subjectName:"control"})),z(),J(),T.args.shouldOpenNow?C({subjectId:f,subjectName:"control",subjectType:h,action:T,payload:{URI:u.args.uri}}):n.add({...M,action:C.bind(null,{subjectId:f,subjectName:"control",subjectType:h,action:T,payload:{URI:u.args.uri}})});return}default:{let _="Unexpected control event",le=new k(1,1,{message:_});d(le,_);return}}},s=({action:u,container:{id:h,endTime:f},branches:I=[],isEOV:E=!1,autoSelected:x=!1})=>{let w=Kr(u,E),$={timestamp:!w.args.shouldOpenNow||E?1/0:f??1/0,priority:"container",initiator:h,actionType:w.type},T=r.emit.bind(r,S.interactives,{subjectId:h,subjectName:"container",type:V.actionChoice,actionType:w.type,payload:{invokeImmediately:w.args.shouldOpenNow,...w.args}}),M=()=>{e.interactiveActionChoice$.next({subjectId:h,subjectName:"container",type:"action-choice",actionType:w.type,payload:{invokeImmediately:w.args.shouldOpenNow,...w.args}})};switch(w.type.trim().toLowerCase()){case b.EventActionTypes.setNextBranch.trim().toLowerCase():{let N=I.find(z=>z.id===w.args.branchId);if(!N)return;T(),M(),n.add({...$,action:A.bind(null,{subjectId:h,subjectName:"container",action:w,payload:{chapterId:N.chapterId,autoSelect:x}})});return}case b.EventActionTypes.setMaxWeightBranch.trim().toLowerCase():return;case b.EventActionTypes.setMinWeightBranch.trim().toLowerCase():return;case b.EventActionTypes.setRandomBranch.trim().toLowerCase():return;case b.EventActionTypes.setWeightlessRandomBranch.trim().toLowerCase():return;case b.EventActionTypes.continuePlayback.trim().toLowerCase():{T(),M(),n.add({...$,action:O.bind(null,{subjectId:h,subjectName:"container",action:w})});return}case b.EventActionTypes.openURI.trim().toLowerCase():{T(),M(),n.add({...$,action:C.bind(null,{subjectId:h,subjectName:"container",action:w,payload:{URI:u.args.uri}})});return}default:{let N="Unexpected container event",z=new k(1,1,{message:N});d(z,N);return}}};function l({container:u,branches:h,isEOV:f=!1}){let I=Fr(u.events);if(I){let E=Kr(I.action,f);r.emit(S.interactives,{subjectId:u.id,subjectName:"container",type:V.actionChoice,actionType:E.type,payload:{invokeImmediately:E.args.shouldOpenNow,...E.args}}),e.interactiveActionChoice$.next({subjectId:u.id,subjectName:"container",type:"action-choice",actionType:E.type,payload:{invokeImmediately:E.args.shouldOpenNow,...E.args}}),n.add({timestamp:f?1/0:u.endTime??1/0,priority:"container",initiator:u.id,actionType:b.EventActionTypes.expect,action:m.bind(null,{subjectId:u.id,subjectName:"container"})}),i.isExpect=!0}else for(let E of u.events??[])s({action:E.action,container:u,branches:h,isEOV:f})}let c=({chapterId:u,action:h,branches:f=[]})=>{let I=r.emit.bind(r,S.interactives,{subjectId:u,subjectName:"chapter",type:V.actionChoice,actionType:h.type,payload:h.args}),E=()=>{e.interactiveActionChoice$.next({subjectId:u,subjectName:"chapter",type:"action-choice",actionType:h.type,payload:h.args})};switch(h.type.trim().toLowerCase()){case b.EventActionTypes.setNextBranch.trim().toLowerCase():{let x=f.find(w=>w.id===h.args.branchId);return x?.chapterId?(I(),E(),A.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:x.chapterId,autoSelect:!0}})):void 0}case b.EventActionTypes.setWeightlessRandomBranch.trim().toLowerCase():{let x=ya(f);return x?.chapterId?(I(),E(),A.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:x.chapterId,autoSelect:!0}})):void 0}case b.EventActionTypes.setRandomBranch.trim().toLowerCase():{let x=ba(f);return x?.chapterId?(I(),E(),A.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:x.chapterId,autoSelect:!0}})):void 0}case b.EventActionTypes.setMaxWeightBranch.trim().toLowerCase():{let x=va(f);return x?.chapterId?(I(),E(),A.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:x.chapterId,autoSelect:!0}})):void 0}case b.EventActionTypes.setMinWeightBranch.trim().toLowerCase():{let x=fa(f);return x?.chapterId?(I(),E(),A.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:x.chapterId,autoSelect:!0}})):void 0}case b.EventActionTypes.continuePlayback.trim().toLowerCase():return I(),E(),O.bind(null,{subjectId:u,subjectName:"chapter",action:h});case b.EventActionTypes.openURI.trim().toLowerCase():return I(),E(),C.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{URI:h.args.uri}});default:{let x="Unexpected chapter event",w=new k(1,1,{message:x});d(w,x);return}}};function d(u,h){console.error(h),e.error$.next(u),r.emit(S.errors,u)}function v(u){let h=Fr(u.events);if(h){if(G(u))return;r.emit(S.interactives,{subjectId:u.id,subjectName:"chapter",type:V.actionChoice,actionType:h.action.type,payload:h.action.args}),e.interactiveActionChoice$.next({subjectId:u.id,subjectName:"chapter",type:"action-choice",actionType:h.action.type,payload:h.action.args}),n.add({timestamp:1/0,priority:"chapter",initiator:u.id,actionType:b.EventActionTypes.expect,action:m.bind(null,{subjectId:u.id,subjectName:"chapter"})})}else u.events?.forEach(f=>{let I=c({chapterId:u.id,action:f.action,branches:u.branches});I&&n.add({timestamp:1/0,priority:"chapter",initiator:u.id,actionType:f.action.type,action:I})})}let m=({subjectId:u,subjectName:h})=>{t.pause(),r.emit(S.interactives,{subjectId:u,subjectName:h,type:V.actionExecution,actionType:b.EventActionTypes.expect}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,type:"action-execution",actionType:b.EventActionTypes.expect})},y=({subjectId:u,subjectName:h})=>{t.info.isEnded$.getValue()?n.execEndOfVideo():t.play(),r.emit(S.interactives,{subjectId:u,subjectName:h,type:V.actionExecution,actionType:ga}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,type:"action-execution",actionType:ga})},O=({subjectId:u,subjectName:h,subjectType:f,action:I})=>{r.emit(S.interactives,{subjectId:u,subjectName:h,subjectType:f,type:V.actionExecution,actionType:I.type}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:f,type:"action-execution",actionType:I.type})},A=({subjectId:u,subjectName:h,subjectType:f,action:I,payload:E})=>{E.behaviour="change-chapter",r.emit(S.interactives,{subjectId:u,subjectName:h,subjectType:f,type:V.actionExecution,actionType:I.type,payload:E}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:f,type:"action-execution",actionType:I.type,payload:E})},C=({subjectId:u,subjectName:h,subjectType:f,action:I,payload:E})=>{if(!E.URI)return;let x=window.open(E.URI,"_blank","noopener,noreferrer");x&&(x.opener=null),r.emit(S.interactives,{subjectId:u,subjectName:h,subjectType:f,type:V.actionExecution,actionType:I.type}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:f,type:"action-execution",actionType:I.type})};return{onControlEvent:a,onContainerEvent:s,onChapterEvent:c,onExpectEvent:m,expectEventHandler:y,setManifestChapterEvents:v,setManifestContainerEvents:l,stopExpect:o,state:i}};var Yr=F(wr(),1),D=require("@vkontakte/videoplayer-shared/es2024");var $t=(r,e)=>{let t={};return r.map(n=>{if(!t[n]){let i=e.chapters.find(a=>a.id===n);if(!i)return null;let o=e.media.videos.find(a=>i.videoId===a.id);if(!o)return null;t[n]=Qr(o)}return t[n]}).filter(Boolean)},Ia=r=>{for(let e of r.variants)if(xa(e)&&e.payload)return e.payload.id},xa=r=>!!(r.type==="custom"&&r.payload&&r.payload.type==="vk"),Qr=r=>{let e=Ia(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},Ta=(r,e)=>{for(let t of r.media.videos)if(e===Qr(t)){for(let n of r.chapters)if(n.videoId===t.id)return n.id;return}},Xr=(r,e)=>r.reduce((t,n)=>{let i=Ta(e,n);return i?[...t,i]:t},[]);var Ye=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:n,historyApi:i,settings:o}){this.state={history$:new D.ValueSubject([]),hasPrevChapter$:new D.ValueSubject(!1),prevChapter$:new D.ValueSubject(null),isInitialChapter$:new D.ValueSubject(!1),isGoBackLimited$:new D.ValueSubject(!1)};this.#r=null;this.#s=!1;this.#e=null;this.#p=null;this.events={inited$:new D.Subject,destroyed$:new D.Subject,error$:new D.Subject};this.#n=null;this.#i=null;this.#t=null;this.#a=new D.Subscription;this.#l=!1;this.#c=0;this.#n=t,this.#t=e,this.#i=n,this.#r=i,this.#o=o,this.state.history$&&this.#a&&this.#a?.add(this.state.history$.subscribe(a=>{this.state.prevChapter$.next((0,Yr.default)(a,-2)||null),this.state.hasPrevChapter$.next(a.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 t=this.getInitialChapterId();await this.#i.setChapter({chapterId:t,pushToHistory:!1}),this.#s||(this.#s=!0,this.events.inited$.next({initChapterId:t}))}get inited(){return this.#s}async updateHistory(e,t=!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,a=$t(o,n);if(this.#p=a,this.state.history$.next(o),!(!t||!this.#r||!this.#n))try{await this.#r.save(this.#n,a)}catch{let l=new k(1,5,"Unable to save interactive history");this.events.error$.next(l),this.#t?.emit(S.errors,l)}}async goBack(){if(!this.state||!this.#i){let n=new k(1,5,"Unable to save interactive history");return this.events.error$.next(n),this.#t?.emit(S.errors,n)}this.#l=!0;let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),await this.#i.setChapter({chapterId:t,playPrev:!0})}async getProjectHistory(){if(!this.#e||!this.#n)return;let e=this.#e,t=[this.getInitialVideoId()];if(this.#r)try{let i=await this.#r.get(this.#n);i.length&&(t=i)}catch{let o=new k(1,5,"Error while trying to fetch data");this.events.error$.next(o),this.#t?.emit(S.errors,o)}let n=Xr(t,e);this.state.history$.next(n)}getInitialChapterId(){let e=this.state.history$.getValue();return(0,Yr.default)(e,-1)||this.#o.initChapterId||this.#e?.metadata.initChapterId}getInitialVideoId(){if(this.#e){let e=this.getInitialChapterId();return $t([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(S.historyDestroyed),this.events.destroyed$.next(),this.#t=null}};var _t=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 t=e.data,n=t.length;for(let i=3;i<n;i+=40)if(t[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,t=!1){let n=e.width+e.height;if(this._prevSizeId===n)return;let i;t&&(i=await this.save()),this.rootElement.width=e.width,this.rootElement.height=e.height,t&&i&&this.restore(i),this._prevSizeId=n}async save(){let e=this.rootElement.toDataURL("image/jpeg",1),t=new Image;return t.crossOrigin="anonymous",t.src=e,await t.decode(),t}restore(e){this.rootElement&&this.rootElement.getContext("2d")?.drawImage(e,0,0,this.rootElement.width,this.rootElement.height)}};var Ft=class{constructor({parentElement:e,endOffsetMs:t=250,onError:n}){this.currentVideoDurationMs=1/0;this._containerTimeFrameShouldReceived=!1;this._endTimeFrameReceived=!1;this._shouldCallSkip=!1;this.onEachTick=e=>{let t=e??this.lastFrameCanvas.canvasImgSrc.currentTime*1e3,n=this.isChapterEndTime(t);if(this.isContainerTime(t))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
|
+
"use strict";var Ma=Object.create;var et=Object.defineProperty;var Na=Object.getOwnPropertyDescriptor;var La=Object.getOwnPropertyNames;var $a=Object.getPrototypeOf,ja=Object.prototype.hasOwnProperty;var p=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),_a=(r,e)=>{for(var t in e)et(r,t,{get:e[t],enumerable:!0})},en=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of La(e))!ja.call(r,i)&&i!==t&&et(r,i,{get:()=>e[i],enumerable:!(n=Na(e,i))||n.enumerable});return r};var F=(r,e,t)=>(t=r!=null?Ma($a(r)):{},en(e||!r||!r.__esModule?et(t,"default",{value:r,enumerable:!0}):t,r)),Fa=r=>en(et({},"__esModule",{value:!0}),r);var K=p((Yt,dn)=>{"use strict";var Re=function(r){return r&&r.Math===Math&&r};dn.exports=Re(typeof globalThis=="object"&&globalThis)||Re(typeof window=="object"&&window)||Re(typeof self=="object"&&self)||Re(typeof global=="object"&&global)||Re(typeof Yt=="object"&&Yt)||function(){return this}()||Function("return this")()});var B=p((bd,mn)=>{"use strict";mn.exports=function(r){try{return!!r()}catch{return!0}}});var ke=p((Cd,fn)=>{"use strict";var Ba=B();fn.exports=!Ba(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var gn=p((gd,Cn)=>{"use strict";var qa=ke(),bn=Function.prototype,vn=bn.apply,yn=bn.call;Cn.exports=typeof Reflect=="object"&&Reflect.apply||(qa?yn.bind(vn):function(){return yn.apply(vn,arguments)})});var H=p((Ed,xn)=>{"use strict";var En=ke(),In=Function.prototype,Zt=In.call,Da=En&&In.bind.bind(Zt,Zt);xn.exports=En?Da:function(r){return function(){return Zt.apply(r,arguments)}}});var Oe=p((Id,Sn)=>{"use strict";var Tn=H(),Ha=Tn({}.toString),Ua=Tn("".slice);Sn.exports=function(r){return Ua(Ha(r),8,-1)}});var Jt=p((xd,An)=>{"use strict";var Ga=Oe(),za=H();An.exports=function(r){if(Ga(r)==="Function")return za(r)}});var q=p((Td,wn)=>{"use strict";var er=typeof document=="object"&&document.all;wn.exports=typeof er>"u"&&er!==void 0?function(r){return typeof r=="function"||r===er}:function(r){return typeof r=="function"}});var ie=p((Sd,Rn)=>{"use strict";var Wa=B();Rn.exports=!Wa(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var ft=p((Ad,kn)=>{"use strict";var Ka=ke(),mt=Function.prototype.call;kn.exports=Ka?mt.bind(mt):function(){return mt.apply(mt,arguments)}});var tr=p(Pn=>{"use strict";var On={}.propertyIsEnumerable,Vn=Object.getOwnPropertyDescriptor,Qa=Vn&&!On.call({1:2},1);Pn.f=Qa?function(e){var t=Vn(this,e);return!!t&&t.enumerable}:On});var rr=p((Rd,Mn)=>{"use strict";Mn.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var Ln=p((kd,Nn)=>{"use strict";var Xa=H(),Ya=B(),Za=Oe(),nr=Object,Ja=Xa("".split);Nn.exports=Ya(function(){return!nr("z").propertyIsEnumerable(0)})?function(r){return Za(r)==="String"?Ja(r,""):nr(r)}:nr});var ir=p((Od,$n)=>{"use strict";$n.exports=function(r){return r==null}});var or=p((Vd,jn)=>{"use strict";var el=ir(),tl=TypeError;jn.exports=function(r){if(el(r))throw new tl("Can't call method on "+r);return r}});var Ve=p((Pd,_n)=>{"use strict";var rl=Ln(),nl=or();_n.exports=function(r){return rl(nl(r))}});var de=p((Md,Fn)=>{"use strict";var il=q();Fn.exports=function(r){return typeof r=="object"?r!==null:il(r)}});var Pe=p((Nd,Bn)=>{"use strict";Bn.exports={}});var vt=p((Ld,Dn)=>{"use strict";var sr=Pe(),ar=K(),ol=q(),qn=function(r){return ol(r)?r:void 0};Dn.exports=function(r,e){return arguments.length<2?qn(sr[r])||qn(ar[r]):sr[r]&&sr[r][e]||ar[r]&&ar[r][e]}});var Un=p(($d,Hn)=>{"use strict";var sl=H();Hn.exports=sl({}.isPrototypeOf)});var Kn=p((jd,Wn)=>{"use strict";var al=K(),Gn=al.navigator,zn=Gn&&Gn.userAgent;Wn.exports=zn?String(zn):""});var ti=p((_d,ei)=>{"use strict";var Jn=K(),lr=Kn(),Qn=Jn.process,Xn=Jn.Deno,Yn=Qn&&Qn.versions||Xn&&Xn.version,Zn=Yn&&Yn.v8,U,yt;Zn&&(U=Zn.split("."),yt=U[0]>0&&U[0]<4?1:+(U[0]+U[1]));!yt&&lr&&(U=lr.match(/Edge\/(\d+)/),(!U||U[1]>=74)&&(U=lr.match(/Chrome\/(\d+)/),U&&(yt=+U[1])));ei.exports=yt});var cr=p((Fd,ni)=>{"use strict";var ri=ti(),ll=B(),cl=K(),pl=cl.String;ni.exports=!!Object.getOwnPropertySymbols&&!ll(function(){var r=Symbol("symbol detection");return!pl(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&ri&&ri<41})});var pr=p((Bd,ii)=>{"use strict";var ul=cr();ii.exports=ul&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var ur=p((qd,oi)=>{"use strict";var hl=vt(),dl=q(),ml=Un(),fl=pr(),vl=Object;oi.exports=fl?function(r){return typeof r=="symbol"}:function(r){var e=hl("Symbol");return dl(e)&&ml(e.prototype,vl(r))}});var ai=p((Dd,si)=>{"use strict";var yl=String;si.exports=function(r){try{return yl(r)}catch{return"Object"}}});var hr=p((Hd,li)=>{"use strict";var bl=q(),Cl=ai(),gl=TypeError;li.exports=function(r){if(bl(r))return r;throw new gl(Cl(r)+" is not a function")}});var pi=p((Ud,ci)=>{"use strict";var El=hr(),Il=ir();ci.exports=function(r,e){var t=r[e];return Il(t)?void 0:El(t)}});var hi=p((Gd,ui)=>{"use strict";var dr=ft(),mr=q(),fr=de(),xl=TypeError;ui.exports=function(r,e){var t,n;if(e==="string"&&mr(t=r.toString)&&!fr(n=dr(t,r))||mr(t=r.valueOf)&&!fr(n=dr(t,r))||e!=="string"&&mr(t=r.toString)&&!fr(n=dr(t,r)))return n;throw new xl("Can't convert object to primitive value")}});var mi=p((zd,di)=>{"use strict";di.exports=!0});var yi=p((Wd,vi)=>{"use strict";var fi=K(),Tl=Object.defineProperty;vi.exports=function(r,e){try{Tl(fi,r,{value:e,configurable:!0,writable:!0})}catch{fi[r]=e}return e}});var bt=p((Kd,gi)=>{"use strict";var Sl=mi(),Al=K(),wl=yi(),bi="__core-js_shared__",Ci=gi.exports=Al[bi]||wl(bi,{});(Ci.versions||(Ci.versions=[])).push({version:"3.38.0",mode:Sl?"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 vr=p((Qd,Ii)=>{"use strict";var Ei=bt();Ii.exports=function(r,e){return Ei[r]||(Ei[r]=e||{})}});var Me=p((Xd,xi)=>{"use strict";var Rl=or(),kl=Object;xi.exports=function(r){return kl(Rl(r))}});var me=p((Yd,Ti)=>{"use strict";var Ol=H(),Vl=Me(),Pl=Ol({}.hasOwnProperty);Ti.exports=Object.hasOwn||function(e,t){return Pl(Vl(e),t)}});var yr=p((Zd,Si)=>{"use strict";var Ml=H(),Nl=0,Ll=Math.random(),$l=Ml(1 .toString);Si.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+$l(++Nl+Ll,36)}});var Ne=p((Jd,wi)=>{"use strict";var jl=K(),_l=vr(),Ai=me(),Fl=yr(),Bl=cr(),ql=pr(),fe=jl.Symbol,br=_l("wks"),Dl=ql?fe.for||fe:fe&&fe.withoutSetter||Fl;wi.exports=function(r){return Ai(br,r)||(br[r]=Bl&&Ai(fe,r)?fe[r]:Dl("Symbol."+r)),br[r]}});var Vi=p((em,Oi)=>{"use strict";var Hl=ft(),Ri=de(),ki=ur(),Ul=pi(),Gl=hi(),zl=Ne(),Wl=TypeError,Kl=zl("toPrimitive");Oi.exports=function(r,e){if(!Ri(r)||ki(r))return r;var t=Ul(r,Kl),n;if(t){if(e===void 0&&(e="default"),n=Hl(t,r,e),!Ri(n)||ki(n))return n;throw new Wl("Can't convert object to primitive value")}return e===void 0&&(e="number"),Gl(r,e)}});var Cr=p((tm,Pi)=>{"use strict";var Ql=Vi(),Xl=ur();Pi.exports=function(r){var e=Ql(r,"string");return Xl(e)?e:e+""}});var Li=p((rm,Ni)=>{"use strict";var Yl=K(),Mi=de(),gr=Yl.document,Zl=Mi(gr)&&Mi(gr.createElement);Ni.exports=function(r){return Zl?gr.createElement(r):{}}});var Er=p((nm,$i)=>{"use strict";var Jl=ie(),ec=B(),tc=Li();$i.exports=!Jl&&!ec(function(){return Object.defineProperty(tc("div"),"a",{get:function(){return 7}}).a!==7})});var Fi=p(_i=>{"use strict";var rc=ie(),nc=ft(),ic=tr(),oc=rr(),sc=Ve(),ac=Cr(),lc=me(),cc=Er(),ji=Object.getOwnPropertyDescriptor;_i.f=rc?ji:function(e,t){if(e=sc(e),t=ac(t),cc)try{return ji(e,t)}catch{}if(lc(e,t))return oc(!nc(ic.f,e,t),e[t])}});var qi=p((om,Bi)=>{"use strict";var pc=B(),uc=q(),hc=/#|\.prototype\./,Le=function(r,e){var t=mc[dc(r)];return t===vc?!0:t===fc?!1:uc(e)?pc(e):!!e},dc=Le.normalize=function(r){return String(r).replace(hc,".").toLowerCase()},mc=Le.data={},fc=Le.NATIVE="N",vc=Le.POLYFILL="P";Bi.exports=Le});var Ir=p((sm,Hi)=>{"use strict";var Di=Jt(),yc=hr(),bc=ke(),Cc=Di(Di.bind);Hi.exports=function(r,e){return yc(r),e===void 0?r:bc?Cc(r,e):function(){return r.apply(e,arguments)}}});var Gi=p((am,Ui)=>{"use strict";var gc=ie(),Ec=B();Ui.exports=gc&&Ec(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var Wi=p((lm,zi)=>{"use strict";var Ic=de(),xc=String,Tc=TypeError;zi.exports=function(r){if(Ic(r))return r;throw new Tc(xc(r)+" is not an object")}});var Xi=p(Qi=>{"use strict";var Sc=ie(),Ac=Er(),wc=Gi(),Ct=Wi(),Ki=Cr(),Rc=TypeError,xr=Object.defineProperty,kc=Object.getOwnPropertyDescriptor,Tr="enumerable",Sr="configurable",Ar="writable";Qi.f=Sc?wc?function(e,t,n){if(Ct(e),t=Ki(t),Ct(n),typeof e=="function"&&t==="prototype"&&"value"in n&&Ar in n&&!n[Ar]){var i=kc(e,t);i&&i[Ar]&&(e[t]=n.value,n={configurable:Sr in n?n[Sr]:i[Sr],enumerable:Tr in n?n[Tr]:i[Tr],writable:!1})}return xr(e,t,n)}:xr:function(e,t,n){if(Ct(e),t=Ki(t),Ct(n),Ac)try{return xr(e,t,n)}catch{}if("get"in n||"set"in n)throw new Rc("Accessors not supported");return"value"in n&&(e[t]=n.value),e}});var Zi=p((pm,Yi)=>{"use strict";var Oc=ie(),Vc=Xi(),Pc=rr();Yi.exports=Oc?function(r,e,t){return Vc.f(r,e,Pc(1,t))}:function(r,e,t){return r[e]=t,r}});var be=p((um,eo)=>{"use strict";var $e=K(),Mc=gn(),Nc=Jt(),Lc=q(),$c=Fi().f,jc=qi(),ve=Pe(),_c=Ir(),ye=Zi(),Ji=me();bt();var Fc=function(r){var e=function(t,n,i){if(this instanceof e){switch(arguments.length){case 0:return new r;case 1:return new r(t);case 2:return new r(t,n)}return new r(t,n,i)}return Mc(r,this,arguments)};return e.prototype=r.prototype,e};eo.exports=function(r,e){var t=r.target,n=r.global,i=r.stat,o=r.proto,a=n?$e:i?$e[t]:$e[t]&&$e[t].prototype,s=n?ve:ve[t]||ye(ve,t,{})[t],l=s.prototype,c,d,v,m,y,k,A,C,u;for(m in e)c=jc(n?m:t+(i?".":"#")+m,r.forced),d=!c&&a&&Ji(a,m),k=s[m],d&&(r.dontCallGetSet?(u=$c(a,m),A=u&&u.value):A=a[m]),y=d&&A?A:e[m],!(!c&&!o&&typeof k==typeof y)&&(r.bind&&d?C=_c(y,$e):r.wrap&&d?C=Fc(y):o&&Lc(y)?C=Nc(y):C=y,(r.sham||y&&y.sham||k&&k.sham)&&ye(C,"sham",!0),ye(s,m,C),o&&(v=t+"Prototype",Ji(ve,v)||ye(ve,v,{}),ye(ve[v],m,y),r.real&&l&&(c||!l[m])&&ye(l,m,y)))}});var ro=p((hm,to)=>{"use strict";var Bc=Math.ceil,qc=Math.floor;to.exports=Math.trunc||function(e){var t=+e;return(t>0?qc:Bc)(t)}});var je=p((dm,no)=>{"use strict";var Dc=ro();no.exports=function(r){var e=+r;return e!==e||e===0?0:Dc(e)}});var oo=p((mm,io)=>{"use strict";var Hc=je(),Uc=Math.min;io.exports=function(r){var e=Hc(r);return e>0?Uc(e,9007199254740991):0}});var _e=p((fm,so)=>{"use strict";var Gc=oo();so.exports=function(r){return Gc(r.length)}});var gt=p((vm,ao)=>{"use strict";ao.exports=function(){}});var lo=p(()=>{"use strict";var zc=be(),Wc=Me(),Kc=_e(),Qc=je(),Xc=gt();zc({target:"Array",proto:!0},{at:function(e){var t=Wc(this),n=Kc(t),i=Qc(e),o=i>=0?i:n+i;return o<0||o>=n?void 0:t[o]}});Xc("at")});var Et=p((Cm,co)=>{"use strict";var Yc=vt();co.exports=Yc});var uo=p((gm,po)=>{"use strict";lo();var Zc=Et();po.exports=Zc("Array","at")});var mo=p((Em,ho)=>{"use strict";var Jc=uo();ho.exports=Jc});var wr=p((Im,fo)=>{"use strict";var ep=mo();fo.exports=ep});var xo=p((Um,Io)=>{"use strict";var ap=vr(),lp=yr(),Eo=ap("keys");Io.exports=function(r){return Eo[r]||(Eo[r]=lp(r))}});var So=p((Gm,To)=>{"use strict";var cp=B();To.exports=!cp(function(){function r(){}return r.prototype.constructor=null,Object.getPrototypeOf(new r)!==r.prototype})});var Ro=p((zm,wo)=>{"use strict";var pp=me(),up=q(),hp=Me(),dp=xo(),mp=So(),Ao=dp("IE_PROTO"),Or=Object,fp=Or.prototype;wo.exports=mp?Or.getPrototypeOf:function(r){var e=hp(r);if(pp(e,Ao))return e[Ao];var t=e.constructor;return up(t)&&e instanceof t?t.prototype:e instanceof Or?fp:null}});var Oo=p((Wm,ko)=>{"use strict";var vp=je(),yp=Math.max,bp=Math.min;ko.exports=function(r,e){var t=vp(r);return t<0?yp(t+e,0):bp(t,e)}});var Vr=p((Km,Po)=>{"use strict";var Cp=Ve(),gp=Oo(),Ep=_e(),Vo=function(r){return function(e,t,n){var i=Cp(e),o=Ep(i);if(o===0)return!r&&-1;var a=gp(n,o),s;if(r&&t!==t){for(;o>a;)if(s=i[a++],s!==s)return!0}else for(;o>a;a++)if((r||a in i)&&i[a]===t)return r||a||0;return!r&&-1}};Po.exports={includes:Vo(!0),indexOf:Vo(!1)}});var No=p((Qm,Mo)=>{"use strict";Mo.exports={}});var jo=p((Xm,$o)=>{"use strict";var Ip=H(),Pr=me(),xp=Ve(),Tp=Vr().indexOf,Sp=No(),Lo=Ip([].push);$o.exports=function(r,e){var t=xp(r),n=0,i=[],o;for(o in t)!Pr(Sp,o)&&Pr(t,o)&&Lo(i,o);for(;e.length>n;)Pr(t,o=e[n++])&&(~Tp(i,o)||Lo(i,o));return i}});var Fo=p((Ym,_o)=>{"use strict";_o.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var qo=p((Zm,Bo)=>{"use strict";var Ap=jo(),wp=Fo();Bo.exports=Object.keys||function(e){return Ap(e,wp)}});var Mr=p((Jm,zo)=>{"use strict";var Ho=ie(),Rp=B(),Uo=H(),kp=Ro(),Op=qo(),Vp=Ve(),Pp=tr().f,Go=Uo(Pp),Mp=Uo([].push),Np=Ho&&Rp(function(){var r=Object.create(null);return r[2]=2,!Go(r,2)}),Do=function(r){return function(e){for(var t=Vp(e),n=Op(t),i=Np&&kp(t)===null,o=n.length,a=0,s=[],l;o>a;)l=n[a++],(!Ho||(i?l in t:Go(t,l)))&&Mp(s,r?[l,t[l]]:t[l]);return s}};zo.exports={entries:Do(!0),values:Do(!1)}});var Wo=p(()=>{"use strict";var Lp=be(),$p=Mr().entries;Lp({target:"Object",stat:!0},{entries:function(e){return $p(e)}})});var Qo=p((rf,Ko)=>{"use strict";Wo();var jp=Pe();Ko.exports=jp.Object.entries});var Yo=p((nf,Xo)=>{"use strict";var _p=Qo();Xo.exports=_p});var Jo=p((of,Zo)=>{"use strict";var Fp=Yo();Zo.exports=Fp});var ns=p(()=>{"use strict";var Gp=be(),zp=Vr().includes,Wp=B(),Kp=gt(),Qp=Wp(function(){return!Array(1).includes()});Gp({target:"Array",proto:!0,forced:Qp},{includes:function(e){return zp(this,e,arguments.length>1?arguments[1]:void 0)}});Kp("includes")});var os=p((wf,is)=>{"use strict";ns();var Xp=Et();is.exports=Xp("Array","includes")});var as=p((Rf,ss)=>{"use strict";var Yp=os();ss.exports=Yp});var ze=p((kf,ls)=>{"use strict";var Zp=as();ls.exports=Zp});var ms=p(()=>{"use strict";var eu=be(),tu=Mr().values;eu({target:"Object",stat:!0},{values:function(e){return tu(e)}})});var vs=p((qf,fs)=>{"use strict";ms();var ru=Pe();fs.exports=ru.Object.values});var bs=p((Df,ys)=>{"use strict";var nu=vs();ys.exports=nu});var Mt=p((Hf,Cs)=>{"use strict";var iu=bs();Cs.exports=iu});var Ur=p((pv,Rs)=>{"use strict";var su=Oe();Rs.exports=Array.isArray||function(e){return su(e)==="Array"}});var Os=p((uv,ks)=>{"use strict";var au=TypeError,lu=9007199254740991;ks.exports=function(r){if(r>lu)throw au("Maximum allowed index exceeded");return r}});var Ms=p((hv,Ps)=>{"use strict";var cu=Ur(),pu=_e(),uu=Os(),hu=Ir(),Vs=function(r,e,t,n,i,o,a,s){for(var l=i,c=0,d=a?hu(a,s):!1,v,m;c<n;)c in t&&(v=d?d(t[c],c,e):t[c],o>0&&cu(v)?(m=pu(v),l=Vs(r,e,v,m,l,o-1)-1):(uu(l+1),r[l]=v),l++),c++;return l};Ps.exports=Vs});var $s=p((dv,Ls)=>{"use strict";var du=Ne(),mu=du("toStringTag"),Ns={};Ns[mu]="z";Ls.exports=String(Ns)==="[object z]"});var _s=p((mv,js)=>{"use strict";var fu=$s(),vu=q(),Lt=Oe(),yu=Ne(),bu=yu("toStringTag"),Cu=Object,gu=Lt(function(){return arguments}())==="Arguments",Eu=function(r,e){try{return r[e]}catch{}};js.exports=fu?Lt:function(r){var e,t,n;return r===void 0?"Undefined":r===null?"Null":typeof(t=Eu(e=Cu(r),bu))=="string"?t:gu?Lt(e):(n=Lt(e))==="Object"&&vu(e.callee)?"Arguments":n}});var Bs=p((fv,Fs)=>{"use strict";var Iu=H(),xu=q(),Gr=bt(),Tu=Iu(Function.toString);xu(Gr.inspectSource)||(Gr.inspectSource=function(r){return Tu(r)});Fs.exports=Gr.inspectSource});var zs=p((vv,Gs)=>{"use strict";var Su=H(),Au=B(),qs=q(),wu=_s(),Ru=vt(),ku=Bs(),Ds=function(){},Hs=Ru("Reflect","construct"),zr=/^\s*(?:class|function)\b/,Ou=Su(zr.exec),Vu=!zr.test(Ds),Xe=function(e){if(!qs(e))return!1;try{return Hs(Ds,[],e),!0}catch{return!1}},Us=function(e){if(!qs(e))return!1;switch(wu(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Vu||!!Ou(zr,ku(e))}catch{return!0}};Us.sham=!0;Gs.exports=!Hs||Au(function(){var r;return Xe(Xe.call)||!Xe(Object)||!Xe(function(){r=!0})||r})?Us:Xe});var Xs=p((yv,Qs)=>{"use strict";var Ws=Ur(),Pu=zs(),Mu=de(),Nu=Ne(),Lu=Nu("species"),Ks=Array;Qs.exports=function(r){var e;return Ws(r)&&(e=r.constructor,Pu(e)&&(e===Ks||Ws(e.prototype))?e=void 0:Mu(e)&&(e=e[Lu],e===null&&(e=void 0))),e===void 0?Ks:e}});var Zs=p((bv,Ys)=>{"use strict";var $u=Xs();Ys.exports=function(r,e){return new($u(r))(e===0?0:e)}});var Js=p(()=>{"use strict";var ju=be(),_u=Ms(),Fu=Me(),Bu=_e(),qu=je(),Du=Zs();ju({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=Fu(this),n=Bu(t),i=Du(t,0);return i.length=_u(i,t,t,n,0,e===void 0?1:qu(e)),i}})});var ea=p(()=>{"use strict";var Hu=gt();Hu("flat")});var ra=p((xv,ta)=>{"use strict";Js();ea();var Uu=Et();ta.exports=Uu("Array","flat")});var ia=p((Tv,na)=>{"use strict";var Gu=ra();na.exports=Gu});var sa=p((Sv,oa)=>{"use strict";var zu=ia();oa.exports=zu});var rh={};_a(rh,{ContainerTypes:()=>b.ContainerTypes,ControlTypes:()=>b.ControlTypes,CustomError:()=>O,EVENT_NAMES:()=>S,EventActionTypes:()=>b.EventActionTypes,EventTypes:()=>b.EventTypes,Interactives:()=>Ze,ManifestController:()=>ae,SDKInfo:()=>th,chapterIdsToVKVideoIds:()=>jt,compareVersions:()=>kt,containerTypes:()=>ip,controlTypes:()=>op,eventActionTypes:()=>kr,eventTypes:()=>sp,getChapterIdByVkVideoId:()=>Ta,getVKVideoIdByMedia:()=>Qr,getVideoRawIdByMedia:()=>Ia,graphEventTypes:()=>Ee,hasEndTemplate:()=>We,interactivesEventTypes:()=>V,isAreaControl:()=>np,isButtonControl:()=>rp,isLastChapter:()=>G,isOneTextCtrlContainer:()=>se,isSupportedManifest:()=>b.isSupportedManifest,isTextControl:()=>De,isVKVariantItem:()=>xa,isValidManifest:()=>Rr,migrateManifestToLatestVersion:()=>b.migrateManifestToLatestVersion,utils:()=>Va,vkVideoIdsToChapterIds:()=>Xr});module.exports=Fa(rh);var tn="1.0.37-dev.dd02dc3e.0";var ht=require("@vkontakte/videoplayer-shared/es2024");var qt=class{constructor(e,t){this.layout=e;this.cssVarsManager=t}},tt=class extends qt{constructor(e,t){super(e,t)}setContainerLayout(e){e.style.position="relative"}setControlLayout(e,t){console.log("@@@THIS",this);let n=this.cssVarsManager.getPropValue("--interactive-content-width"),i=this.cssVarsManager.getPropValue("--interactive-content-height"),o=this.cssVarsManager.getPropValue("--interactive-width"),a=this.cssVarsManager.getPropValue("--interactive-height");e.style.position="absolute",e.style.width=`calc(${n} * ${t.width})`,e.style.height=`calc(${i} * ${t.height})`,e.style.left=`calc(${n} * ${t.x} + ((${o} - ${n}) / 2))`,e.style.top=`calc(${i} * ${t.y} + ((${a} - ${i}) / 2))`}};function rn(r){return"features"in r}var pe=class{constructor(e,t,n){this.container=e,this.options=n,this.factories=new Map,this.controls=[],this.setControls(),this.cssVarsManager=t}featureIsEnabled(e){return this.options&&rn(this.options)&&this.options.features[e]}addControlFactory(e,t){this.factories.set(e.trim().toLowerCase(),t),this.setControls()}removeControlFactory(e){this.factories.delete(e.trim().toLowerCase()),this.setControls()}setControls(){this.controls=this.chooseControls()}chooseControls(){return this.container.controls?.reduce((e,t)=>{let n=t.type.trim().toLowerCase(),i=this.factories.get(n);if(i){let o=i(t,this.options);if(o)return[...e,o]}return[...e]},[])||[]}};var re=require("@vkontakte/videoplayer-shared/es2024");function xe(r,e=1){let t="0",n="0",i="0";return r.length===4?(t="0x"+r[1]+r[1],n="0x"+r[2]+r[2],i="0x"+r[3]+r[3]):r.length===7&&(t="0x"+r[1]+r[2],n="0x"+r[3]+r[4],i="0x"+r[5]+r[6]),`rgba(${+t},${+n},${+i},${e})`}var nn="interactive",P={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},on=(n=>(n.top="flex-start",n.bottom="flex-end",n.center="center",n))(on||{}),sn=(n=>(n.start="flex-start",n.end="flex-end",n.center="center",n))(sn||{}),an=(n=>(n.start="left",n.end="right",n.center="center",n))(an||{}),rt=({target:r,props:e})=>{r.style.alignItems=(e?.gravityVertical&&on[e.gravityVertical])??"center",r.style.justifyContent=(e?.gravityHorizontal&&sn[e.gravityHorizontal])??"center",r.style.textAlign=(e?.alignment&&an[e.alignment])??"center"},nt=({target:r,props:e,fallback:t,dependsOn:n})=>{r.style.color=e?.text?.color??t.textColor,r.style.fontSize=`calc(${n.height} * ${e?.text?.size??t.textSize})`,r.textContent=e?.text?.value??t.textContent},it=({target:r,props:e,fallback:t})=>{r.style.backgroundColor=xe(e?.background?.color??t.backgroundColor,e?.background?.alpha??t.backgroundAlpha)},Te=({target:r,props:e,fallback:t,dependsOn:n,useRawValues:i=!1})=>{let o=i?t.borderWidthRawValue:`calc(${n.height} * ${e?.shape?.border?.width??t.borderWidth})`,a=i?t.roundCornersRawValue:`calc(${n.height} * ${e?.shape?.roundCorners??t.roundCorners})`;r.style.borderWidth=o,r.style.borderStyle="solid",r.style.borderColor=xe(i?t.borderColor:e?.shape?.border?.color??t.borderColor,i?t.borderAlpha:e?.shape?.border?.alpha??t.borderAlpha),r.style.borderRadius=a},ln=({target:r,isDark:e,baseDimension:t,fallback:n})=>{let a=xe(n.shadowColorLight,n.shadowColorAlpha),s=xe(n.shadowColorDark,n.shadowColorAlpha),l=`calc(${t} * ${.25})`,c=`calc(${t} * ${.11})`,d=`0px 0px ${l} ${c} ${e?s:a}`;r.style.boxShadow=d},ue=({target:r,layoutParams:e,fallback:t})=>{let n=e.angle??t.angle;n=n&&n*-1,r.style.transform=`rotate(${n}rad)`};var he=require("@vkontakte/videoplayer-shared/es2024");var Dt="int",ee=(n=>(n.AREA=`${Dt}_area`,n.TEXT=`${Dt}_text`,n.BUTTON=`${Dt}_bttn`,n))(ee||{});function cn(r){return"features"in r}var W="interactive-control",R={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 O=class{constructor(e,t,...n){this.severity=e;this.category=t;this.data=n}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};var Q=class{constructor(e,t){this.control=e;this.options=t;this.container=null;this.controlElement=null;this.subscriptions=new he.Subscription;this.error$=new he.Subject;this.cssVarsManager=null}setCssVarsManager(e){this.cssVarsManager=e}createContainerElement(e){let t=document.createElement("div");t.classList.add(R.wrapper),e.setControlLayout(t,this.control.layoutParams);let n=(this.control.layoutParams.innerSizesDependOn??P.innerSizesDependOn)==="self"?{height:t.style.height,width:t.style.width}:{height:this.cssVarsManager?.getPropValue("--interactive-content-height)")??0,width:this.cssVarsManager?.getPropValue("--interactive-content-width")??0};this.container={element:t,dimensions:n}}createClickListener(e){return t=>{t.stopPropagation(),e()}}featureIsEnabled(e){return this.options&&cn(this.options)&&this.options.features[e]}setEvents(e){!this.container||!this.control.events||this.control.events.forEach(t=>{switch(t.type.trim().toLowerCase()){case"onclick":{if(!this.container)break;this.subscriptions.add((0,he.fromEvent)(this.container.element,"click").subscribe(this.createClickListener(()=>e({action:t.action,controlId:this.control.id,controlType:this.control.type})),i=>{let o=new O(1,1,{message:"Error happened on control interaction",error:i});this.error$.next(o)}));break}default:break}})}removeListeners(){this.subscriptions.unsubscribe()}};var X=(r,e)=>Object.prototype.toString.call(r)===`[object ${e}]`,Y=r=>X(r,"Object"),ot=r=>X(r,"String"),st=r=>X(r,"Array"),at=r=>X(r,"Number"),pn=r=>X(r,"Function"),un=r=>X(r,"Boolean"),Ht=r=>at(r)&&!isNaN(r);var te=r=>Y(r)&&Object.keys(r).length===0,Ut=r=>st(r)&&!r.length;var we=(r,e)=>ot(r)&&(e?r.trim():r).length;var Gt="interactive-blink-anim-reference",L={common:Gt,animation:`${Gt}-animation`,disabled:`${Gt}-disabled`},lt=class{constructor(){this._RAFId=0;this._element=void 0}get element(){return this._element}create(){if(this._element)return;let e=document.createElement("div");e.classList.add(L.common,L.animation),this._element=e}restart(){this._element&&(this._element.classList.add(L.disabled),this.cleanupRAF(),this._RAFId=requestAnimationFrame(()=>{this._element&&(this._element.classList.remove(L.disabled),this.cleanupRAF())}))}cleanupRAF(){this._RAFId&&(cancelAnimationFrame(this._RAFId),this._RAFId=0)}destroy(){this.cleanupRAF(),this._element=void 0}};var zt="interactive-container",$={common:zt,hidden:`${zt}-hidden`,disabled:`${zt}-disabled`};var ct=(r,e)=>{if(r.type.trim().toLowerCase()==="area")return new Wt(r,e)},Wt=class extends Q{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){if(super.createContainerElement(t),!this.container)return;let n=document.createElement("button");n.type="button",n.classList.add(R.common,R.area),n.setAttribute("data-testid",ee.AREA),it({target:n,props:this.control.props,fallback:{...P,backgroundColor:"transparent"}}),ue({target:n,layoutParams:this.control.layoutParams,fallback:P}),this.container.element.append(n),e.append(this.container.element),this.controlElement=n,this.updateShadowStyles(),this.registerEvents()}registerEvents(){if(!this.featureIsEnabled("controlsExpectTimeBlinkAnimation"))return;let e=this.container?.element.parentElement;!e||!this.controlElement||(this.subscriptions.add((0,re.fromEvent)(this.controlElement,"mouseleave").subscribe(()=>{if(e.classList.contains($.disabled))return;let t=e.parentElement;if(t){let n=t.querySelector(`.${L.common}`);n&&this.syncBlinkAnimation(n)}},t=>this.onError("Error happened in mouseleave callback",t))),this.subscriptions.add((0,re.fromEvent)(this.controlElement,"mouseenter").subscribe(()=>{e.classList.contains($.disabled)||this.onBlinkHovering()},t=>this.onError("Error happened in mouseenter callback",t))).add((0,re.fromEvent)(this.controlElement,"mouseleave").subscribe(()=>{this.controlElement&&(this.controlElement.style.animation="")},t=>this.onError("Error happened in mouseleave callback",t))))}disable(){this.controlElement&&this.controlElement.classList.add(R.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(R.disabled)}getElement(){return this.controlElement}updateShadowStyles(e){if(!(!this.container||!this.controlElement))if(un(e)){let t=Math.min(this.controlElement.offsetWidth,this.controlElement.offsetHeight)+"px";ln({target:this.controlElement,props:this.control.props,fallback:P,isDark:e,baseDimension:t}),Te({target:this.controlElement,props:this.control.props,fallback:{...P,borderColor:e?P.shadowColorDark:P.shadowColorLight,borderAlpha:1,borderWidthRawValue:"0.1px",roundCornersRawValue:`calc(${this.container.dimensions.height} * ${this.control.props?.shape?.roundCorners??P.roundCorners})`},dependsOn:this.container.dimensions,useRawValues:!0})}else Te({target:this.controlElement,props:this.control.props,fallback:{...P,borderAlpha:0},dependsOn:this.container.dimensions})}toggleBlinkAnimation(e){this.controlElement?.classList.toggle(R.blinkAnim,e),this.controlElement?.classList.toggle(R.blinkAnimArea,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${R.blinkAnimArea}`)||this.controlElement.classList.contains(R.selected)||this.controlElement.classList.contains(L.disabled)||(this.controlElement.classList.add(L.disabled),this.subscriptions.add((0,re.fromEvent)(e,"animationiteration").pipe((0,re.once)()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(L.disabled)},t=>this.onError("Error happened in animationiteration callback",t)))))}onBlinkHovering(){if(!this.controlElement||!this.controlElement.classList.contains(`${R.blinkAnimArea}`)||this.controlElement.classList.contains(R.selected))return;let e=window.getComputedStyle(this.controlElement),t=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=t)})}onError(e="",t){let n=new O(1,1,{message:e,error:t,details:{id:this.control.id}});this.error$.next(n)}onProgress(){}onResize(){}};var ne=require("@vkontakte/videoplayer-shared/es2024");var pt=r=>{let e=document.createElement("span");switch(r){case"Button":case"button":{let t=document.createElement("div"),n={overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center"};Object.assign(t.style,n),t.append(e);let i={display:"inline-block",whiteSpace:"pre",textOverflow:"ellipsis",maxWidth:"initial",maxHeight:"100%",wordBreak:"normal"};return Object.assign(e.style,i),t}default:{let t={display:"inline-block",whiteSpace:"break-spaces",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%",maxHeight:"100%",wordBreak:"break-all"};return Object.assign(e.style,t),e}}};var ut=(r,e)=>{if(r.type.trim().toLowerCase()==="button")return new Kt(r,e)},Kt=class extends Q{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){if(super.createContainerElement(t),!this.container)return;let n=document.createElement("button");n.type="button",n.classList.add(R.common,R.button),n.setAttribute("data-testid",ee.BUTTON),ue({target:n,layoutParams:this.control.layoutParams,fallback:P}),it({target:n,props:this.control.props,fallback:P}),Te({target:n,props:this.control.props,fallback:P,dependsOn:this.container.dimensions}),rt({target:n,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let i=pt(this.control.type.trim().toLowerCase()),o=i.firstElementChild??i;nt({target:o,props:this.control.props,fallback:P,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"))return;let e=this.container?.element.parentElement;!e||!this.controlElement||(this.subscriptions.add((0,ne.fromEvent)(this.controlElement,"mouseleave").subscribe(()=>{if(e.classList.contains($.disabled))return;let t=e.parentElement;if(t){let n=t.querySelector(`.${L.common}`);n&&this.syncBlinkAnimation(n)}},t=>this.onError("Error happened in mouseleave callback",t))),this.subscriptions.add((0,ne.fromEvent)(this.controlElement,"mouseenter").subscribe(()=>{e.classList.contains($.disabled)||this.onBlinkHovering()},t=>this.onError("Error happened in mouseenter callback",t))).add((0,ne.fromEvent)(this.controlElement,"mouseleave").subscribe(()=>{this.controlElement&&(this.controlElement.style.animation="")},t=>this.onError("Error happened in mouseleave callback",t))))}disable(){this.controlElement&&this.controlElement.classList.add(R.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(R.disabled)}getElement(){return this.controlElement}toggleBlinkAnimation(e){this.controlElement?.classList.toggle(R.blinkAnim,e),this.controlElement?.classList.toggle(R.blinkAnimButton,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${R.blinkAnimButton}`)||this.controlElement.classList.contains(R.selected)||this.controlElement.classList.contains(L.disabled)||(this.controlElement.classList.add(L.disabled),this.subscriptions.add((0,ne.fromEvent)(e,"animationiteration").pipe((0,ne.once)()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(L.disabled)},t=>this.onError("Error happened in animationiteration callback",t)))))}onBlinkHovering(){if(!this.controlElement||!this.controlElement.classList.contains(`${R.blinkAnimButton}`)||this.controlElement.classList.contains(R.selected))return;let e=window.getComputedStyle(this.controlElement),t=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=t)})}onError(e="",t){let n=new O(1,1,{message:e,error:t,details:{id:this.control.id}});this.error$.next(n)}onProgress(){}onResize(){}updateShadowStyles(){}};var hn=(r,e)=>{if(r.type.trim().toLowerCase()==="text")return new Qt(r,e)},Qt=class extends Q{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){if(super.createContainerElement(t),!this.container)return;let n=document.createElement("div");n.classList.add(R.common,R.text),n.setAttribute("data-testid",ee.TEXT),ue({target:n,layoutParams:this.control.layoutParams,fallback:P}),rt({target:n,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let i=pt(this.control.type.trim().toLowerCase()),o=i.firstElementChild??i;nt({target:o,props:this.control.props,fallback:P,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(){}onError(){}};var dt=(r,e,t,n)=>{if(r.type.trim().toLowerCase()==="choice")return new Xt(r,e,t,n)},Xt=class extends pe{constructor(t,n,i,o){super(t,i,o);this.containerElement=null;this.controlSubscriptions=new ht.Subscription;this.error$=new ht.Subject;this.rootElement=n,this.layout=new tt(this.container.layout,i),this.cssVarsManager=i,this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",ut),this.addControlFactory("text",hn),this.addControlFactory("area",ct)}createView({eventCallback:t}){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.setCssVarsManager(this.cssVarsManager),i.createView({parentElement:n,callbacks:{setControlLayout:this.layout.setControlLayout}}),i.setEvents(t),this.controlSubscriptions.add(i.error$.subscribe(this.error$))}),this.rootElement.append(n),this.isRemoved=!1,this.containerElement=n,n}hide(){let t=this.getElement();t&&t.classList.add($.hidden)}show(){let t=this.getElement();t&&t.classList.remove($.hidden)}enable(){let t=this.getElement();t&&(t.classList.remove($.disabled),this.controls.forEach(n=>n.enable()),this.isDisabled=!1)}disable(){let t=this.getElement();t&&(t.classList.add($.disabled),this.controls.forEach(n=>n.disable()),this.isDisabled=!0)}removeView(){let t=this.getElement();t&&(this.controlSubscriptions.unsubscribe(),this.controls.forEach(n=>n.removeListeners()),t.remove(),this.isRemoved=!0,this.containerElement=null)}fakeRemove(){this.isRemoved||(this.isRemoved=!0)}getElement(){return this.containerElement}onProgress(t,n){n&&this.controls.forEach(i=>{i.onProgress(t)})}onResize(t){t&&this.controls.forEach(n=>{n.onResize()})}updateControlsShadowStyles(t){this.controls.forEach(n=>n.updateShadowStyles(t))}toggleBlinkAnimation(t){this.controls.forEach(n=>n.toggleBlinkAnimation(t))}};var ka=F(wr(),1),g=require("@vkontakte/videoplayer-shared/es2024"),Ie=require("@vkontakte/videoplayer-statistics/es2024");var Co=require("@vkontakte/videoplayer-shared/es2024");function Fe(r,e){let t;return(...n)=>{clearTimeout(t),t=setTimeout(()=>r(...n),e)}}var vo="video_interactive",yo="videoint";var bo=250,Be=class{constructor(e){this.handleZoomChange=Fe(e=>{this.lastZoomInfo=e},bo);this.onResize=e=>{if(!this.isReady||this.isHidden||!e[0].contentRect.width||!e[0].contentRect.height)return;let t=this.getNextPoint();t&&this.ngEditor?.zoomTo(t,void 0,{isFromCenter:!0}),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,t=[])=>{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(t),this.ngEditor&&(this.manifest.metadata.id!==this.currentManifestId?(this.ngEditor.update(e),this.currentManifestId=this.manifest.metadata.id):this.ngEditor.setVisitedChapters(Array.from(t)),this.isReady=!0)};this.init(e)}init({root:e,onOpenPreviewClick:t,onError:n,lang:i,visitedChapters:o=[]}){this.isReady=!1,this.isHidden=!0,this.manifest=null,this.visitedChapterIds=new Set(o),this.onOpenPreviewClick=t,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=tp(e),this.resizeObserver=new ResizeObserver(Fe(this.onResize,bo)),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(0,Co.loadVKLangPack)(this.lang,vo,yo)}catch{this.onError?.("Unable to load graph language pack")}let{GraphEditor:t}=await import("@interactiveplatform/movika-graph-editor");this.ngEditor=new t(this.graphWrapperElement,{mode:"view",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 tp(r){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",r.append(e),e}var qe=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(t=>t.id!==e)};this.getNextInteractiveTime=(e=3e3)=>{if(!this._containers.length||this._player===null)return null;let t=-1,n=!1,i=Math.round(this._player.info.position$.getValue()*1e3);for(let o of this._containers){let a=o.startTime-e;if(a<=i&&(o.endTime&&i<=o.endTime||o.endTime===null)){n=!0;break}i<a&&(t=t===-1?a:Math.min(t,a))}return!n&&t!==-1?t:null}}};var b=require("@interactiveplatform/movika-manifest");var go={metadata:"Object",chapters:"Array"},Rr=r=>{if(!Y(r))return!1;for(let e in go)if(!r[e]||!X(r[e],go[e]))return!1;return(0,b.isSupportedManifest)(r.metadata.version)},De=r=>r.type===b.ControlTypes.Text,rp=r=>r.type===b.ControlTypes.Button,np=r=>r.type===b.ControlTypes.Area,ip={Choice:"Choice",TextInput:"TextInput"},op={Button:"Button",Area:"Area",Text:"Text"},sp={onClick:"onClick",onSuspense:"onSuspense"},kr={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var It=class{constructor(){this.listeners={}}addListener(e,t){return this.listeners[e]=this.listeners[e]||[],this.listeners[e].push(t),this}on(e,t){return this.addListener(e,t)}once(e,t){this.listeners[e]=this.listeners[e]||[];let n=()=>{t(),this.off(e,n)};return this.listeners[e].push(n),this}off(e,t){return this.removeListener(e,t)}reset(){this.listeners={}}removeListener(e,t){let n=this.listeners[e]||[];for(let i=n.length;i>0;i--)if(n[i]===t){n.splice(i,1);break}return this}emit(e,...t){let n=this.listeners[e];return n?(n.forEach(i=>{i(...t)}),!0):!1}listenerCount(e){return this.rawListeners(e).length}rawListeners(e){return this.listeners[e]||[]}};var xt=class{constructor(e){this.fns=[];this.addFn=(e,t=!1)=>{pn(e)&&(this.fns.push(e),t&&this.updateFn())};this.removeFn=(e,t=!1)=>{this.fns=this.fns.filter(n=>n!==e),t&&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=[]}};var es=F(Jo(),1),Tt=class r{constructor(e){this.rootElement=e;this.rootElementProps={};this.isCssVarsSupported=r.checkCssVarsSupport(e)}static checkCssVarsSupport(e){let t="--test-key",n="test";e.style.setProperty(t,n);let i=e.style.getPropertyValue(t)===n;return i&&e.style.removeProperty(t),i}getPropValue(e){return this.isCssVarsSupported?`var(${e})`:this.rootElementProps[e]??""}setup(e){if(this.rootElementProps={...this.rootElementProps,...e},this.isCssVarsSupported)for(let[t,n]of(0,es.default)(e))this.rootElement.style.setProperty(t,n)}cleanup(){for(let e in this.rootElementProps)this.rootElement.style.removeProperty(e);this.rootElementProps={}}setProp(e,t){this.rootElementProps[e]=t,this.isCssVarsSupported&&this.rootElement.style.setProperty(e,t)}};var ds=require("@vkontakte/videoplayer-shared/es2024");var St=class{constructor(e){this.loaders={chapterLoaders:e?.chapterLoaders??[],manifestLoaders:e?.manifestLoaders??[]}}async exec(e,t){return Bp(...this.loaders[e])(t)}};function Bp(...r){return async function(t){let n=[...r];for(;n.length>0;)t=await n.shift()(t);return t}}function He(r,e,t){return r?{...r,[e]:r[e]?[t,...r[e]]:[t]}:{[e]:[t]}}function At({actions:r,errors:e,chapterId:t,...n}){if(t){let i=r.getManifest();if(i){let o=r.getChapter(i.chapters,t);if(o){let a=r.getMedia(i.media,o.videoId),s=r.getGraph(i.graph,o.id);return a?{...n,actions:r,errors:e,result:{chapter:o,media:a,graph:s}}:{...n,errors:He(e,At.name,"Could not find media"),actions:r}}}}return{...n,errors:He(e,At.name,"Could not find chapter"),actions:r}}var wt=class{constructor(){Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}addEventListener(e,t,n){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:t,options:n})}removeEventListener(e,t){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===t){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 a=n[i];try{a.callback.call(this,e)}catch(s){Promise.resolve().then(()=>{throw s})}a.options&&a.options.once&&this.removeEventListener(e.type,a.callback)}return!e.defaultPrevented}},Ce=class extends wt{constructor(){super(),this.listeners||wt.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)}},Ue=class{constructor(){Object.defineProperty(this,"signal",{value:new Ce,writable:!0,configurable:!0})}abort(e){let t;try{t=new Event("abort")}catch{typeof document<"u"?document.createEvent?(t=document.createEvent("Event"),t.initEvent("abort",!1,!1)):(t=document.createEventObject(),t.type="abort"):t={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(t)}toString(){return"[object AbortController]"}};typeof Symbol<"u"&&Symbol.toStringTag&&(Ue.prototype[Symbol.toStringTag]="AbortController",Ce.prototype[Symbol.toStringTag]="AbortSignal");function Rt(r){return r.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill"),!0):typeof r.Request=="function"&&!r.Request.prototype.hasOwnProperty("signal")||!r.AbortController}function Nr(r){typeof r=="function"&&(r={fetch:r});let{fetch:e,Request:t=e.Request,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:i=!1}=r;if(!Rt({fetch:e,Request:t,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:i}))return{fetch:e,Request:o};let o=t;(o&&!o.prototype.hasOwnProperty("signal")||i)&&(o=function(c,d){let v;d&&d.signal&&(v=d.signal,delete d.signal);let m=new t(c,d);return v&&Object.defineProperty(m,"signal",{writable:!1,enumerable:!1,configurable:!0,value:v}),m},o.prototype=t.prototype);let a=e;return{fetch:(l,c)=>{let d=o&&o.prototype.isPrototypeOf(l)?l.signal:c?c.signal:void 0;if(d){let v;try{v=new DOMException("Aborted","AbortError")}catch{v=new Error("Aborted"),v.name="AbortError"}if(d.aborted)return Promise.reject(v);let m=new Promise((y,k)=>{d.addEventListener("abort",()=>k(v),{once:!0})});return c&&c.signal&&delete c.signal,Promise.race([m,a(l,c)])}return a(l,c)},Request:o}}var Ge=Rt({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),ts=Ge?Nr({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,Lr=Ge?ts.fetch:window.fetch,ff=Ge?ts.Request:window.Request,vf=Ge?Ue:window.AbortController,yf=Ge?Ce:window.AbortSignal;var kt=(r="",e="")=>{let t=r.split("."),n=e.split("."),i=0;for(let o=0;o<Math.max(t.length,n.length)&&!i;o++)t[o]>n[o]?i=1:t[o]<n[o]?i=-1:i=0;return i};var qp=async r=>{try{let e={},t;if(ot(r)){t=new URL(r).href;let i=await Lr(t);if(!i.ok)return{};e=await i.json()}else if(Y(r))e=r;else return{};if(!Rr(e))return{};let n=e.metadata.media;if(ot(n)&&!("media"in e))try{let i;t?i=new URL(n,t).href:(i=new URL(n).href,t=i);let o=await Lr(i);if(!o.ok)throw new Error;e.metadata.media=await o.json()}catch{return Up(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch{return{}}};async function rs(r){let{manifest:e,manifestURL:t}=await qp(r);if(!e)throw new Error("Failed on fetch");let n=(0,b.migrateManifestToLatestVersion)(e);return n.media=Dp(n.media,t),delete n.metadata.media,n}function Ot(r,e){if(e)return r.find(t=>t.id===e)}function $r(r,e){return r.edit?.chapters?r.edit.chapters.find(t=>t.id===e):r.view?.chapters?r.view.chapters.find(t=>t.id===e):void 0}function jr(r,e){return r.videos.find(t=>t.id===e)}function Dp(r,e){return{...r,videos:r.videos.map(t=>({...t,variants:t.variants.map(n=>{let i="url"in n?n.url:"",o=Hp(i,e);return{...n,url:o||i}})}))}}function Hp(r="",e){try{return new URL(r,e).href}catch{return""}}function Up(r){return kt(r,"3.2.0")>=0}var cs=F(ze(),1);var Vt=r=>st(r)&&!Ut(r),G=r=>r.order==="end",We=r=>st(r.containers)&&!Ut(r.containers)&&G(r),ps=(r,e)=>{let t=r*1e3;return Vt(e.controls)&&t<(e.startTime??0)},_r=(r,e)=>{let t=r*1e3;return Vt(e.controls)&&t>=(e.startTime??0)&&t<=(e.endTime??1/0)};var oe=(r=[])=>r.some(e=>e.action.type==="expect"),Fr=(r=[])=>r.find(e=>e.action.type==="expect"),Jp=r=>r?.length===1,se=r=>Jp(r)&&De(r[0]);function us(r=[],e=1/0,t=[]){return r.filter(({container:n})=>!(0,cs.default)(t,n.container.id)&&oe(n.container.events)&&n.container.endTime===e&&!n.isRemoved)}function Pt({gameControllers:r=[],subjectName:e,subjectId:t,execFn:n}){for(let i of r)if(e==="container"&&i.container.container.id===t){n(i),us(r,i.container.container.endTime,[i.container.container.id]).forEach(a=>{n(a)});break}}var hs=(r,e)=>{let t=A=>e.find(({container:u})=>u.container.id===A)?.container.isRemoved,n=oe(r.events)&&!t(r.id),i=(A,C=!1,u=!1)=>{let h=u?"every":"some";return A.controls[h](f=>{let I=C?A.endTime===r.endTime:!0;return f.events?.[h](E=>E.action?.type===kr.openURI)&&I})},o=A=>A.some(({container:C})=>i(C.container,!0,!1)&&!C.isRemoved),a=A=>A.every(({container:C})=>C.isRemoved?!0:i(C.container,!0,!0)),s=us(e,r.endTime,[r.id]).length,l=A=>A.controls.some(C=>C.events?.some(u=>u.action?.args?.shouldOpenNow)),c=n||s>0,d=o(e),v=i(r),m=a(e),y=n?!1:s>0,k=l(r);return{isExpectTime:c,hasOtherExpect:s>0,hasOpenURIEvent:d,hasOpenURIEventInCurrentContainer:v,isAllOpenURIEventsValid:m,isExpectEventForCurrentContainer:y,hasShouldOpenNowEvent:k}};var ae=class extends St{constructor(t,n){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new ds.ValueSubject(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(t){this.release();let n=await this.exec("manifestLoaders",{actions:{addErrorMessage:He},result:null,errors:null,source:t});return n.errors&&this.errorHandler(n.errors),this.manifest=await rs(n.result??t),this}async setInitial(){return this.setNext()}async setNext(t=this.manifest?.metadata.initChapterId){if(!t)return this;this.prevChapter$.next(this.chapter);let n=await this.exec("chapterLoaders",At({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:$r,getChapter:Ot,getMedia:jr,getByBranches:this.getByBranches.bind(this),addErrorMessage:He},result:null,errors:null,chapterId:t}));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(t){this.onError(t),console.error("Something went wrong with loaders",{errors:t})}getInitial(){return this.getByChapterId(this.manifest?.metadata.initChapterId)||null}getByChapterId(t=this.manifest?.metadata.initChapterId){if(!t||!this.manifest)return null;let n=Ot(this.manifest.chapters,t);if(n){let i=jr(this.manifest.media,n.videoId),o=$r(this.manifest.graph,n.id);if(i)return{chapter:n,media:i,graph:o}}return null}getBranches(t=this.chapter?.id){if(t===this.chapter?.id)return this.getByBranches(this.chapter?.branches);{let n=Ot(this.manifest?.chapters||[],t);return this.getByBranches(n?.branches)}}getByBranches(t=[]){return t.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?G(this.chapter):!1}};var Is=F(Mt(),1),xs=require("@vkontakte/videoplayer-core/es2024"),Z=require("@vkontakte/videoplayer-shared/es2024");var gs=r=>{let e=r.variants.find(t=>t.payload?.type==="vk");if(e&&e.payload){let[t,n]=e.payload.id.split("_");return[t,n]}return[]};var Es=F(Mt(),1);function Br(){let r=new Map;function e({listId:o=Math.random().toString(),itemId:a=Math.random().toString(),...s}){let l=r.get(o),c={...s};return l?l[a]=c:r.set(o,{[a]:c}),{listId:o,itemId:a,...s}}function t(o){o.player.destroy(),o.container.remove(),o.subscription.unsubscribe(),o.statistics?.oneStat.destroy(),o.statistics?.statSubscription.unsubscribe()}function n(o,a){let s=r.get(o);if(!s)throw Error("Can't remove. Not find.");if(a){let l=s[a];l&&t(l),delete s[a],Object.keys(s).length||r.delete(o)}else{for(let l of(0,Es.default)(s))t(l);r.delete(o)}}function i(){for(let o of r)n(o[0])}return{createPlayer:e,removePlayer:n,map:r,removeAll:i}}var ge=F(ze(),1);function qr(r,e=[]){let t={},n,i=!e.length;for(let o of r.variants)if(!n&&"cover"in o&&(n=o.cover),"url"in o)switch(o.type.toLowerCase()){case"mp4":(i||(0,ge.default)(e,"mp4"))&&(t.MPEG={...t.MPEG,[o.standard??"Invariant quality"]:o.url});break;case"mpeg":(i||(0,ge.default)(e,"mpeg"))&&(t.MPEG={...t.MPEG,[o.standard??"Invariant quality"]:o.url});break;case"hls":(i||(0,ge.default)(e,"hls"))&&(t={...t,HLS:{type:"url",url:o.url}});break;case"dash":(i||(0,ge.default)(e,"dash"))&&(t={...t,DASH_SEP:{compatibilityMode:!0,type:"url",url:o.url}});break;default:break}return{sources:t,thumbUrl:n,title:r.title??""}}var Ke=(r,e)=>{let t=r.info.currentQuality$.getValue(),n=r.info.availableQualities$.getValue();t!==e&&(0,ge.default)(n,e)&&(r.setQuality(e),r.setAutoQuality(!1))};var ou=2;function Dr(r){let e=Br(),t=new Z.Subscription,n={},i=null,o=!1,a,s=new Z.ValueSubject(null);r&&l(r);function l(C){i=C}function c(C,u,h){if(!i)throw Error("need to set interactive controller");if(!i.options)return;let I=(e.map.get(C)??{})[u];if(I){n={chapterId:h,listId:C,itemId:u,...I};let E=n.player;n.subscription.add(E.info.currentQuality$.subscribe(x=>{let w=E.info.position$.getValue(),j=E.info.isAutoQualityEnabled$.getValue();if(!(!x||!w||j))for(let T of e.map)(0,Is.default)(T[1]).forEach(({player:M})=>{Ke(M,x)})})).add(E.events.started$.subscribe(()=>{d(u)})),I.container.remove(),i.setPlayer(I.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(C){if(!i)throw Error("need to set interactive controller");if(te(n)||C!==n.itemId)return;let u=i.getChapterBranches(),h=new Set;for(let f of u)h.has(f.media.id)||(await m({media:f.media,chapterId:f.chapter.id,setAsActive:!1,title:f.chapter.label}),h.add(f.media.id))}async function v({chapter:{id:C},manifestVideo:u}){if(te(n)||!i)return;let h=n.player.info.muted$.getValue(),f=n.player.info.currentQuality$.getValue(),I=n.player.info.isAutoQualityEnabled$.getValue(),E=n.player.info.volume$.getValue(),x=n.player.info.currentPlaybackRate$.getValue(),w=!I,j=!1;for(let T of e.map)if(T[0]===u.id&&!i.state.isReplay$.getValue()){let M=Object.keys(T[1]);for(let N of M)N===n.itemId?(M.length<ou||(j=!0),e.removePlayer(T[0],N)):(j=!0,c(T[0],N,C),w?Ke(n.player,f):n.player.setAutoQuality(!0),n.player.setVolume(E),n.player.setMuted(h),n.player.setPlaybackRate(x))}else e.removePlayer(T[0]);j||(await m({media:u,chapterId:C,setAsActive:!0,playbackRate:x}),w?Ke(n.player,f):n.player.setAutoQuality(!0),n.player.setVolume(E),n.player.setMuted(h))}async function m({media:C,chapterId:u,prefetch:h=!0,setAsActive:f=!0,autoplay:I=!1,preferredExt:E,title:x,playbackRate:w}){let j=Math.random().toString(),T=document.createElement("div");a.append(T);let M;if(i?.options?.vkVideoLoader){let Je=gs(C);Je.length&&(M=await i.options.vkVideoLoader(...Je))}let N=i?.options?.coreConfig||void 0,z={...N,configName:[...N?.configName??[],"interactive"]},J={container:T,...M?.videos?.[0]||{sources:qr(C,E).sources},title:x,failoverHosts:M?.failoverHosts||[]},_=new xs.Player(z,Z.Tracer.createRootTracer());_.initVideo(J);let le=null;if(M?.videos&&i?.options.createOneStat){let Je=M.videos[0],Bt=i.options.createOneStat(Je),Jr=new Z.Subscription;Bt&&(Jr.add(Bt.attachTo(_)),le={oneStat:Bt,statSubscription:Jr})}let Zr=new Z.Subscription,Pa=n?.player?.info.isAutoQualityEnabled$.getValue();Zr.add(_.events.canplay$.subscribe(function(){Pa||Ke(_,n.player.info.currentQuality$.getValue()),w&&_.setPlaybackRate(w)}));let ce=e.createPlayer({listId:C.id,itemId:j,player:_,container:T,sources:qr(C,E).sources,config:J,subscription:Zr,statistics:le});return f&&c(C.id,ce.itemId,u),I&&ce.player.play(),h&&!I&&ce.player.prepare(),{player:ce.player,config:ce.config,statistics:ce.statistics}}function y(){k(),i=null,a.remove()}function k(){t.unsubscribe(),e.removeAll(),n={},o=!1}async function A(){if(!i)throw Error("need to set interactive controller");k(),a=document.createElement("div");let{media:C,chapter:u}=i.getCurrentChapter();C&&u?(t.add(i.events.chapterChanged$.subscribe(v)),await m({media:C,chapterId:u.id,title:u.label})):console.error("not found")}return{...e,init:A,setInteractiveController:l,createPlayer:m,removeAll:y,getActivePlayer:function(){return n},activePlayerChanged:s}}var S={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},Ee={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},V={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};var Ss=F(ze(),1),As=require("@vkontakte/videoplayer-shared/es2024");function Hr(r){return function(...t){return r(...t.reverse())}}function Qe(r,...e){return(...t)=>Y(e[0])&&Y(t[0])?r({...e[0],...t[0]}):r(...e,...t)}var Nt=class{constructor({player:e,container:t,branches:n,selectBranches:i,interactiveEvents:o,globalEvents:a,globalEventEmitter:s,getContainerEventState:l,permanentTextControls:c,interactiveTimeOpenUri:d,disabledControls$:v,onRemove:m,onError:y}){this.hide=()=>{setTimeout(()=>{this.gameState!==4&&(oe(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:t}=this.getContainerEventState();if(this.container.show?.(),this.interactiveTimeOpenUri&&t)return;this.emitContainerVisibilityEvent(!0,!1)}else{let t={isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.emitContainerVisibilityEvent(!1)},onEvent:(i,o)=>{let{isExpectTime:a,hasOtherExpect:s,hasOpenURIEvent:l,hasOpenURIEventInCurrentContainer:c,isAllOpenURIEventsValid:d,hasShouldOpenNowEvent:v}=this.getContainerEventState(),m=this.interactiveTimeOpenUri&&!c,y=this.interactiveTimeOpenUri&&c;if((!this.interactiveTimeOpenUri||m)&&(this.isSelectedControlEvent=!0),i!==!1){if(!this.selectBranches.state.isExpect&&(!this.interactiveTimeOpenUri||m)){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&&l&&this.gameState!==5){if(y){let A=((C,u,h,f)=>!C&&!u&&h||C&&!u&&h&&!f||C&&!u&&h&&f)(a,s,d,this.isSelectedContainerEvent);this.fakeRemoveView(A)}else this.removeView(),this.emitContainerVisibilityEvent(!1);(!a||!s||!v)&&(this.selectBranches.stopExpect(),o())}},isEOV:()=>this.gameState===4},n=Qe(this.selectBranches.onControlEvent,t);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,Ss.default)(i,this.gameState)&&!this.isPermanentText)return;let o=this.player.getExactTime();if(ps(o,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(_r(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,v=this.interactiveTimeOpenUri&&c;if(v&&!d){let m=this.container.getElement();m&&(m.style.visibility!=="hidden"&&this.container.hide?.(),this.container.isRemoved||this.fakeRemoveView())}!this.isPermanentText&&!v&&this.removeView()}let a=_r(o,this.container.container),s=this.container.container.startTime?[this.container.container.startTime,this.container.container.endTime??1/0]:[],l={subjectId:this.container.container.id,subjectName:"container",range:s,currentTime:o,isInteractiveTime:a};this.container.onProgress(o*1e3,a),this.globalEventEmitter.emit(S.eachTick,l),this.globalEvents.eachTick$.next(l)};this.container=t,this.branches=n,this.selectBranches=i,this.subscription=new As.Subscription,this.player=e,this.interactiveEvents=o,this.getContainerEventState=l,this.isPermanentText=c&&se(t.container.controls),this.interactiveTimeOpenUri=d,this.disabledControls$=v,this.onRemove=m,this.globalEventEmitter=s,this.gameState=0,this.globalEvents=a,this.onError=y,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}emitContainerVisibilityEvent(e,t=!1){e?(this.globalEventEmitter.emit(S.interactives,{subjectId:this.container.container.id,subjectName:"container",type:V.visibility,visibility:e,isFirst:t}),this.globalEvents.interactiveVisibilityChanged$.next({subjectId:this.container.container.id,subjectName:"container",type:"visibility",visibility:e,isFirst:t})):(this.globalEventEmitter.emit(S.interactives,{subjectId:this.container.container.id,subjectName:"container",type:V.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?.()})),this.subscription.add(this.container.error$.subscribe(this.onError))}selectContainerEvent(e=!1){let{isExpectEventForCurrentContainer:t}=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,!t&&!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:t}=this.getContainerEventState(),n=this.interactiveTimeOpenUri?e||t:oe(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(S.interactives,{subjectId:this.container.container.id,subjectName:"container",type:V.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 ws=(r=[])=>r.reduce((e,t,n)=>{let i=(t?.controls??[]).filter(o=>!De(o));if(Vt(i)){let o=[t.startTime??0,t.endTime??1/0],a={id:t.id,isRemoved:!1};if(!n)e.push({subjects:[a],range:o});else{let s=[],l=-1/0,c=1/0,d=[],v=[];for(let m=0;m<e.length;m++){let y=e[m];if(v.push(...y.subjects),y.range[0]<c&&(c=y.range[0]),y.range[1]>l&&(l=y.range[1]),o[0]>=y.range[0]&&o[1]<=y.range[1])return e[m].subjects.push(a),e;o[0]<y.range[0]&&o[1]>y.range[0]&&(s.push(m),d=d.concat(y.subjects)),o[0]>=y.range[0]&&o[0]<=y.range[1]&&(s.push(m),d=d.concat(y.subjects),o[0]=y.range[0]),o[1]>=y.range[0]&&o[1]<=y.range[1]&&(s.push(m),d=d.concat(y.subjects),o[1]=y.range[1])}if(v.push(a),o[0]<=c&&o[1]>=l)return[{subjects:v,range:o}];s.length&&s.reverse().forEach(m=>{e.splice(m,1)}),e.push({subjects:d.concat([a]),range:o})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);var la=F(ze(),1),Wr=F(Mt(),1),ca=F(sa(),1);function aa(){let r={};function e(){for(let s in r)Object.prototype.hasOwnProperty.call(r,s)&&delete r[s]}function t(s){let l={};for(let c in r)+c<=s&&(l[c]=r[c]);return l}function n(s){let l={};for(let c in r)+c>=s&&(l[c]=r[c]);return l}function i({timestamp:s,priority:l,initiator:c}){if(Ht(s)){let d=r[s]??null;if(d&&l&&we(l,!0)){let v={},m=d[l];return m&&(v={...v,...m}),v=te(v)?null:v,v&&we(c,!0)?v[c]??null:v}return d}return null}function o({timestamp:s,priority:l,initiator:c}){if(Ht(s))if(r[s]){if(l&&we(l,!0))if(r[s][l]){if(c&&we(c,!0))if(r[s][l][c]){if(delete r[s][l][c],!te(r[s][l]))return!0}else return!1;if(delete r[s][l],!te(r[s]))return!0}else return!1;return delete r[s]}else return!1;return!1}function a({timestamp:s,priority:l,initiator:c,...d}){r[s]?.[l]?.[c]?r[s][l][c].push({...d}):r[s]?.[l]?r[s][l]={...r[s][l],[c]:[{...d}]}:r[s]?r[s]={...r[s],[l]:{[c]:[{...d}]}}:r[s]={[l]:{[c]:[{...d}]}}}return{map:r,remove:o,add:a,removeAll:e,get:i,getLte:t,getGte:n}}var Wu=[b.EventActionTypes.expect,b.EventActionTypes.setNextBranch],Ku=1/0;function pa(r,e){let t=r,n,i=Qu(e),o=aa(),a,s=()=>{y(),u()},l=h=>{o.add.call(void 0,h),k()},c=(h=[])=>{for(let f of h)if(f.action(),(0,la.default)(Wu,f.actionType))break},d=(h=1/0)=>{let f=$t(o.get({timestamp:h,priority:"control"})??{}),I=$t(o.get({timestamp:h,priority:"container"})??{}),E=$t(o.get({timestamp:h,priority:"chapter"})??{});return[...f,...I,...E]},v=h=>{i.isReady(h)&&c(d(h))},m=()=>{c([...$t(o.get({timestamp:1/0,priority:"chapter"})??{})])},y=()=>{n&&(a?.unsubscribe(),n=void 0)},k=()=>{n||(n=()=>setTimeout(()=>{v(1/0)}),a=t.events.ended$.subscribe(n))},A=h=>{y(),t=h},C=h=>{h.priority==="container"&&i.resetCalled(h.timestamp),o.remove(h)},u=()=>{i.release(),o.removeAll()};return{setPlayer:A,add:l,remove:C,exec:v,execEndOfVideo:m,listen:k,unlisten:y,release:s,containersEventsCallState:i,getPreparedToExecActions:d}}function Qu(r){let e=new Map;return{setCalled:({timestamp:s,id:l})=>{let c=e.get(s);c&&c[l]!==void 0&&(c[l]=!0)},setData:(s=[])=>{for(let l of s){let c=l.endTime??Ku,d=e.get(c);e.set(c,{...d,[l.id]:!1})}},resetCalled:s=>{let l=e.get(s);if(l)for(let c in l)l[c]=!1},isReady:s=>{let l=e.get(s);if(!l)return!0;let c=(0,Wr.default)(l);return r?c.some(v=>v):!c.some(v=>!v)},release:()=>e.clear()}}function $t(r){return(0,ca.default)((0,Wr.default)(r)).sort(e=>e.actionType===b.EventActionTypes.expect?-1:1)}var ua={videoContentHeight:0,videoContentWidth:0},ha=r=>{let{height:e,width:t}=r.info.intrinsicVideoSize$.getValue()||{};if(!(e&&t))return ua;let{clientHeight:n,clientWidth:i}=r.experimental.element$.getValue()||{};if(!(n&&i))return ua;let o=e/t,a=n/i,s,l;return a>o?(l=i,s=i*o):a<o?(l=n/o,s=n):(l=i,s=n),{videoContentWidth:l,videoContentHeight:s}};var Xu=250;function da(r){let e,t=new ResizeObserver(s=>{o(s),e=o.bind(null,s)});function n(s){let{parentElement:l,player:c,cssVarsManager:d}=r();if(!l||!c)return;let{videoContentWidth:v,videoContentHeight:m}=ha(c);d.setup({"--interactive-content-width":`${v}px`,"--interactive-content-height":`${m}px`,"--interactive-width":`${s[0].contentRect.width}px`,"--interactive-height":`${s[0].contentRect.height}px`})}function i(){let{parentElement:s}=r();s.removeAttribute("style")}let o=Fe(s=>{let{fns:l=[]}=r();n(s);for(let c of l)c()},Xu);function a(){e=void 0,t.disconnect(),i()}return{resizeObserver:t,calc:()=>{e?.()},release:a}}var Yu=r=>Math.floor(Math.random()*r),fa=r=>{let e=r.length,t=1/0,n=null;for(;e--;){let i=r[e],o=i.weight??1;o<t&&(t=o,n=i)}return n},va=r=>{let e=r.length,t=-1/0,n=null;for(;e--;){let i=r[e],o=i.weight??0;o>t&&(t=o,n=i)}return n};var ya=r=>{let e=r.length,t=Yu(e);return r[t]},ma=1,ba=r=>{let e=0;for(let n=0;n<r.length;++n)e+=r[n].weight??ma;let t=Math.random()*e;e=0;for(let n=0;n<r.length-1;++n)if(e+=r[n].weight??ma,e>=t)return r[n];return r[r.length-1]};var Ca={shouldOpenNow:!0,isDetachContainer:!0},ga="after-expect",Kr=(r,e=!1)=>({...r,args:e?{...r.args,...Ca}:{...Ca,...r.args}}),Ea=({globalEventEmitter:r,globalEvents:e,player:t,interactiveEvents:n})=>{let i={isExpect:!1},o=()=>{i.isExpect&&(i.isExpect=!1)},a=({action:u,controlType:h,controlId:f,containerId:I,branches:E=[],onEvent:x,isEOV:w=()=>!1,isDisabled:j=()=>!1})=>{let T=Kr(u,w()),M={timestamp:1/0,priority:"control",initiator:f,actionType:T.type},N=j(),z=r.emit.bind(r,S.interactives,{subjectId:f,subjectType:h,subjectName:"control",type:N?V.actionChoiceCanceled:V.actionChoice,actionType:u.type,payload:{invokeImmediately:T.args.shouldOpenNow,containerId:I,...T.args}}),J=()=>{e.interactiveActionChoice$.next({subjectId:f,subjectType:h,subjectName:"control",type:N?"action-choice-canceled":"action-choice",actionType:u.type,payload:{invokeImmediately:T.args.shouldOpenNow,containerId:I,...T.args}})};if(N){z(),J();return}switch(T.type.trim().toLowerCase()){case b.EventActionTypes.setNextBranch.trim().toLowerCase():{let _=E.find(le=>le.id===T.args.branchId);if(!_)return;x(T.args.isDetachContainer,y.bind(null,{subjectId:f,subjectName:"control"})),z(),J(),T.args.shouldOpenNow?A({subjectId:f,subjectName:"control",subjectType:h,action:T,payload:{chapterId:_.chapterId,autoSelect:!1}}):n.add({...M,action:A.bind(null,{subjectId:f,subjectName:"control",subjectType:h,action:T,payload:{chapterId:_.chapterId,autoSelect:!1}})});return}case b.EventActionTypes.continuePlayback.trim().toLowerCase():{x(T.args.isDetachContainer,y.bind(null,{subjectId:f,subjectName:"control"})),z(),J(),T.args.shouldOpenNow?k({subjectId:f,subjectName:"control",subjectType:h,action:u}):n.add({...M,action:k.bind(null,{subjectId:f,subjectName:"control",subjectType:h,action:u})});return}case b.EventActionTypes.openURI.trim().toLowerCase():{x(T.args.isDetachContainer,y.bind(null,{subjectId:f,subjectName:"control"})),z(),J(),T.args.shouldOpenNow?C({subjectId:f,subjectName:"control",subjectType:h,action:T,payload:{URI:u.args.uri}}):n.add({...M,action:C.bind(null,{subjectId:f,subjectName:"control",subjectType:h,action:T,payload:{URI:u.args.uri}})});return}default:{let _="Unexpected control event",le=new O(1,1,{message:_});d(le,_);return}}},s=({action:u,container:{id:h,endTime:f},branches:I=[],isEOV:E=!1,autoSelected:x=!1})=>{let w=Kr(u,E),j={timestamp:!w.args.shouldOpenNow||E?1/0:f??1/0,priority:"container",initiator:h,actionType:w.type},T=r.emit.bind(r,S.interactives,{subjectId:h,subjectName:"container",type:V.actionChoice,actionType:w.type,payload:{invokeImmediately:w.args.shouldOpenNow,...w.args}}),M=()=>{e.interactiveActionChoice$.next({subjectId:h,subjectName:"container",type:"action-choice",actionType:w.type,payload:{invokeImmediately:w.args.shouldOpenNow,...w.args}})};switch(w.type.trim().toLowerCase()){case b.EventActionTypes.setNextBranch.trim().toLowerCase():{let N=I.find(z=>z.id===w.args.branchId);if(!N)return;T(),M(),n.add({...j,action:A.bind(null,{subjectId:h,subjectName:"container",action:w,payload:{chapterId:N.chapterId,autoSelect:x}})});return}case b.EventActionTypes.setMaxWeightBranch.trim().toLowerCase():return;case b.EventActionTypes.setMinWeightBranch.trim().toLowerCase():return;case b.EventActionTypes.setRandomBranch.trim().toLowerCase():return;case b.EventActionTypes.setWeightlessRandomBranch.trim().toLowerCase():return;case b.EventActionTypes.continuePlayback.trim().toLowerCase():{T(),M(),n.add({...j,action:k.bind(null,{subjectId:h,subjectName:"container",action:w})});return}case b.EventActionTypes.openURI.trim().toLowerCase():{T(),M(),n.add({...j,action:C.bind(null,{subjectId:h,subjectName:"container",action:w,payload:{URI:u.args.uri}})});return}default:{let N="Unexpected container event",z=new O(1,1,{message:N});d(z,N);return}}};function l({container:u,branches:h,isEOV:f=!1}){let I=Fr(u.events);if(I){let E=Kr(I.action,f);r.emit(S.interactives,{subjectId:u.id,subjectName:"container",type:V.actionChoice,actionType:E.type,payload:{invokeImmediately:E.args.shouldOpenNow,...E.args}}),e.interactiveActionChoice$.next({subjectId:u.id,subjectName:"container",type:"action-choice",actionType:E.type,payload:{invokeImmediately:E.args.shouldOpenNow,...E.args}}),n.add({timestamp:f?1/0:u.endTime??1/0,priority:"container",initiator:u.id,actionType:b.EventActionTypes.expect,action:m.bind(null,{subjectId:u.id,subjectName:"container"})}),i.isExpect=!0}else for(let E of u.events??[])s({action:E.action,container:u,branches:h,isEOV:f})}let c=({chapterId:u,action:h,branches:f=[]})=>{let I=r.emit.bind(r,S.interactives,{subjectId:u,subjectName:"chapter",type:V.actionChoice,actionType:h.type,payload:h.args}),E=()=>{e.interactiveActionChoice$.next({subjectId:u,subjectName:"chapter",type:"action-choice",actionType:h.type,payload:h.args})};switch(h.type.trim().toLowerCase()){case b.EventActionTypes.setNextBranch.trim().toLowerCase():{let x=f.find(w=>w.id===h.args.branchId);return x?.chapterId?(I(),E(),A.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:x.chapterId,autoSelect:!0}})):void 0}case b.EventActionTypes.setWeightlessRandomBranch.trim().toLowerCase():{let x=ya(f);return x?.chapterId?(I(),E(),A.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:x.chapterId,autoSelect:!0}})):void 0}case b.EventActionTypes.setRandomBranch.trim().toLowerCase():{let x=ba(f);return x?.chapterId?(I(),E(),A.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:x.chapterId,autoSelect:!0}})):void 0}case b.EventActionTypes.setMaxWeightBranch.trim().toLowerCase():{let x=va(f);return x?.chapterId?(I(),E(),A.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:x.chapterId,autoSelect:!0}})):void 0}case b.EventActionTypes.setMinWeightBranch.trim().toLowerCase():{let x=fa(f);return x?.chapterId?(I(),E(),A.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:x.chapterId,autoSelect:!0}})):void 0}case b.EventActionTypes.continuePlayback.trim().toLowerCase():return I(),E(),k.bind(null,{subjectId:u,subjectName:"chapter",action:h});case b.EventActionTypes.openURI.trim().toLowerCase():return I(),E(),C.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{URI:h.args.uri}});default:{let x="Unexpected chapter event",w=new O(1,1,{message:x});d(w,x);return}}};function d(u,h){console.error(h),e.error$.next(u),r.emit(S.errors,u)}function v(u){let h=Fr(u.events);if(h){if(G(u))return;r.emit(S.interactives,{subjectId:u.id,subjectName:"chapter",type:V.actionChoice,actionType:h.action.type,payload:h.action.args}),e.interactiveActionChoice$.next({subjectId:u.id,subjectName:"chapter",type:"action-choice",actionType:h.action.type,payload:h.action.args}),n.add({timestamp:1/0,priority:"chapter",initiator:u.id,actionType:b.EventActionTypes.expect,action:m.bind(null,{subjectId:u.id,subjectName:"chapter"})})}else u.events?.forEach(f=>{let I=c({chapterId:u.id,action:f.action,branches:u.branches});I&&n.add({timestamp:1/0,priority:"chapter",initiator:u.id,actionType:f.action.type,action:I})})}let m=({subjectId:u,subjectName:h})=>{t.pause(),r.emit(S.interactives,{subjectId:u,subjectName:h,type:V.actionExecution,actionType:b.EventActionTypes.expect}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,type:"action-execution",actionType:b.EventActionTypes.expect})},y=({subjectId:u,subjectName:h})=>{t.info.isEnded$.getValue()?n.execEndOfVideo():t.play(),r.emit(S.interactives,{subjectId:u,subjectName:h,type:V.actionExecution,actionType:ga}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,type:"action-execution",actionType:ga})},k=({subjectId:u,subjectName:h,subjectType:f,action:I})=>{r.emit(S.interactives,{subjectId:u,subjectName:h,subjectType:f,type:V.actionExecution,actionType:I.type}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:f,type:"action-execution",actionType:I.type})},A=({subjectId:u,subjectName:h,subjectType:f,action:I,payload:E})=>{E.behaviour="change-chapter",r.emit(S.interactives,{subjectId:u,subjectName:h,subjectType:f,type:V.actionExecution,actionType:I.type,payload:E}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:f,type:"action-execution",actionType:I.type,payload:E})},C=({subjectId:u,subjectName:h,subjectType:f,action:I,payload:E})=>{if(!E.URI)return;let x=window.open(E.URI,"_blank","noopener,noreferrer");x&&(x.opener=null),r.emit(S.interactives,{subjectId:u,subjectName:h,subjectType:f,type:V.actionExecution,actionType:I.type}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:f,type:"action-execution",actionType:I.type})};return{onControlEvent:a,onContainerEvent:s,onChapterEvent:c,onExpectEvent:m,expectEventHandler:y,setManifestChapterEvents:v,setManifestContainerEvents:l,stopExpect:o,state:i}};var Yr=F(wr(),1),D=require("@vkontakte/videoplayer-shared/es2024");var jt=(r,e)=>{let t={};return r.map(n=>{if(!t[n]){let i=e.chapters.find(a=>a.id===n);if(!i)return null;let o=e.media.videos.find(a=>i.videoId===a.id);if(!o)return null;t[n]=Qr(o)}return t[n]}).filter(Boolean)},Ia=r=>{for(let e of r.variants)if(xa(e)&&e.payload)return e.payload.id},xa=r=>!!(r.type==="custom"&&r.payload&&r.payload.type==="vk"),Qr=r=>{let e=Ia(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},Ta=(r,e)=>{for(let t of r.media.videos)if(e===Qr(t)){for(let n of r.chapters)if(n.videoId===t.id)return n.id;return}},Xr=(r,e)=>r.reduce((t,n)=>{let i=Ta(e,n);return i?[...t,i]:t},[]);var Ye=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:n,historyApi:i,settings:o}){this.state={history$:new D.ValueSubject([]),hasPrevChapter$:new D.ValueSubject(!1),prevChapter$:new D.ValueSubject(null),isInitialChapter$:new D.ValueSubject(!1),isGoBackLimited$:new D.ValueSubject(!1)};this.#r=null;this.#s=!1;this.#e=null;this.#p=null;this.events={inited$:new D.Subject,destroyed$:new D.Subject,error$:new D.Subject};this.#n=null;this.#i=null;this.#t=null;this.#a=new D.Subscription;this.#l=!1;this.#c=0;this.#n=t,this.#t=e,this.#i=n,this.#r=i,this.#o=o,this.state.history$&&this.#a&&this.#a?.add(this.state.history$.subscribe(a=>{this.state.prevChapter$.next((0,Yr.default)(a,-2)||null),this.state.hasPrevChapter$.next(a.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 t=this.getInitialChapterId();await this.#i.setChapter({chapterId:t,pushToHistory:!1}),this.#s||(this.#s=!0,this.events.inited$.next({initChapterId:t}))}get inited(){return this.#s}async updateHistory(e,t=!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,a=jt(o,n);if(this.#p=a,this.state.history$.next(o),!(!t||!this.#r||!this.#n))try{await this.#r.save(this.#n,a)}catch{let l=new O(1,5,"Unable to save interactive history");this.events.error$.next(l),this.#t?.emit(S.errors,l)}}async goBack(){if(!this.state||!this.#i){let n=new O(1,5,"Unable to save interactive history");return this.events.error$.next(n),this.#t?.emit(S.errors,n)}this.#l=!0;let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),await this.#i.setChapter({chapterId:t,playPrev:!0})}async getProjectHistory(){if(!this.#e||!this.#n)return;let e=this.#e,t=[this.getInitialVideoId()];if(this.#r)try{let i=await this.#r.get(this.#n);i.length&&(t=i)}catch{let o=new O(1,5,"Error while trying to fetch data");this.events.error$.next(o),this.#t?.emit(S.errors,o)}let n=Xr(t,e);this.state.history$.next(n)}getInitialChapterId(){let e=this.state.history$.getValue();return(0,Yr.default)(e,-1)||this.#o.initChapterId||this.#e?.metadata.initChapterId}getInitialVideoId(){if(this.#e){let e=this.getInitialChapterId();return jt([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(S.historyDestroyed),this.events.destroyed$.next(),this.#t=null}};var _t=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 t=e.data,n=t.length;for(let i=3;i<n;i+=40)if(t[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,t=!1){let n=e.width+e.height;if(this._prevSizeId===n)return;let i;t&&(i=await this.save()),this.rootElement.width=e.width,this.rootElement.height=e.height,t&&i&&this.restore(i),this._prevSizeId=n}async save(){let e=this.rootElement.toDataURL("image/jpeg",1),t=new Image;return t.crossOrigin="anonymous",t.src=e,await t.decode(),t}restore(e){this.rootElement&&this.rootElement.getContext("2d")?.drawImage(e,0,0,this.rootElement.width,this.rootElement.height)}};var Ft=class{constructor({parentElement:e,endOffsetMs:t=250,onError:n}){this.currentVideoDurationMs=1/0;this._containerTimeFrameShouldReceived=!1;this._endTimeFrameReceived=!1;this._shouldCallSkip=!1;this.onEachTick=e=>{let t=e??this.lastFrameCanvas.canvasImgSrc.currentTime*1e3,n=this.isChapterEndTime(t);if(this.isContainerTime(t))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;
|
|
@@ -146,4 +146,4 @@
|
|
|
146
146
|
opacity: var(--interactive-area-hover-opacity);
|
|
147
147
|
animation: none;
|
|
148
148
|
}
|
|
149
|
-
`;var wa=r=>{let e=document.createElement("style");e.textContent=Aa,r.prepend(e)};var ka=require("@vkontakte/videoplayer-core/es2024");var Ra=Object.freeze({lang:g.InterfaceLanguage.RU,loaders:{},graph:!1,initSeamless:!1,lastFrame:!1,permanentTextControls:!0,interactiveTimeOpenUri:!1,config:{historyMaxLength:100,noInteractionEventTimeout:3e4},animationsFeatureToggles:{areaControlShadow:!1,controlsExpectTimeBlinkAnimation:!1}});function eh(){let r=document.createElement("div");return r.classList.add("interactive-chapter"),r}var Ze=class{constructor(e){this.playerSubscriptions=new g.Subscription;this.subscriptions=new g.Subscription;this.globalEventEmitter=new It;this.animation=new xt;this.seekToInteractiveController=new qe;this.endedRanges=new Set;this.gameControllers=[];this.rootElement=eh();this.factories=new Map([["choice",dt]]);this.isFirstChapterFetched=!1;this.player=null;this.interactiveEvents=null;this.selectBranches=null;this.seamlessController=null;this.seamlessControllerSubs=new g.Subscription;this.graph=null;this.lastFrame=null;this.blinkAnimationRef=null;this.appState=0;this.state={prevChapter$:new g.ValueSubject(null),isInitialChapter$:new g.ValueSubject(!1),isFirstChapter$:new g.ValueSubject(!0),isEndChapter$:new g.ValueSubject(!1),isInteractiveExpectation$:new g.ValueSubject(!1),isReplay$:new g.ValueSubject(!1),calledByInteractive$:new g.ValueSubject(!1),lastChapterChangeWasInitiatedByInteractive$:new g.ValueSubject(!1),disabledControls$:new g.ValueSubject(!1),interactiveRanges$:new g.ValueSubject([]),isInteractiveTime$:new g.ValueSubject(!1),statistics$:new g.ValueSubject(null),isSeekable$:new g.ValueSubject(!1)};this.events={noInteraction$:new g.Subject,graphVisibilityChanged$:new g.Subject,watchAgainIsClicked$:new g.Subject,chapterChanged$:new g.Subject,playerChanged$:new g.Subject,error$:new g.Subject,eachTick$:new g.Subject,manifestChanged$:new g.Subject,interactiveRangeEnded$:new g.Subject,interactiveContainerRemoved$:new g.Subject,interactiveContainerFakeRemoved$:new g.Subject,interactiveActionExecution$:new g.Subject,interactiveActionChoice$:new g.Subject,interactiveVisibilityChanged$:new g.Subject};this.emitErrorEvent=e=>{this.events.error$.next(e),this.globalEventEmitter.emit(S.errors,e)};this.clearHistoryIfEnded=()=>{let e=this.player?.info.isEnded$.getValue(),t=this.state.isInteractiveExpectation$.getValue(),{chapter:n}=this.getCurrentChapter();e&&n&&G(n)&&!t&&this.historyController.updateHistory([]),window.removeEventListener("beforeunload",this.clearHistoryIfEnded)};this.handleSeamlessPlayerChanged=e=>{if(!e)return;let{statistics:t,...n}=e;if(t){let{statSubscription:i,oneStat:o}=t;i.add(o.attachToInteractive(this.getStatEvents())),this.state.statistics$.next(t)}this.state.isReplay$.getValue()&&this.state.isReplay$.next(!1),this.events.playerChanged$.next(n),this.globalEventEmitter.emit(S.playerChanged,n)};this.onPlaybackStarted=()=>{this.resizeManager?.calc(),this.animation.requestAnimation()};this.destroyGameControllers=(e=!0)=>{this.gameControllers.forEach(t=>{!e&&t.isPermanentText||(this.animation.removeFn(t.whilePlaying),t.destroy())})};this.completeInteractiveRange=e=>{let{interactiveRanges$:t}=this.state,i=t.getValue().map(o=>({...o,subjects:o.subjects.filter(a=>a.id!==e)}));t.next(i)};this.clearNoInteractionTimeout=()=>{this.noInteractionTimeout&&(clearTimeout(this.noInteractionTimeout),this.noInteractionTimeout=void 0)};if(this._options={...Ra,...e,config:{...Ra.config,...e.config}},this._options.animationsFeatureToggles?.controlsExpectTimeBlinkAnimation){this.blinkAnimationRef=new lt,this.blinkAnimationRef.create();let i=this.blinkAnimationRef.element;i&&this.rootElement.append(i)}this._options.parentElement.append(this.rootElement),this.historyController=new Ye({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 Ft({parentElement:this._options.parentElement,onError:i=>{let o=new k(1,6,i);this.emitErrorEvent(o)}})),wa(this._options.parentElement),this.subscriptions.add((0,g.fromEvent)(this.rootElement,"mousedown").subscribe(i=>i.stopPropagation())).add((0,g.fromEvent)(this.rootElement,"mouseup").subscribe(i=>i.stopPropagation())),this.manifestController=new ae(this._options.loaders,i=>{let o=new k(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.cssVarsManager=new Tt(this._options?.parentElement),this.resizeManager=da(()=>({player:this.player,cssVarsManager:this.cssVarsManager,parentElement:this._options.parentElement,fns:n})),this._options.graph&&(this.graph=new Be({root:this._options.parentElement,lang:this._options.lang,onOpenPreviewClick:i=>{this.setChapter({chapterId:i}),this.globalEventEmitter.emit(S.graph,{type:Ee.watchAgainClicked,chapterId:i}),this.events.watchAgainIsClicked$.next(i)},onError:i=>{let o=new k(1,2,{message:i});this.emitErrorEvent(o)}})),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:t})=>{this.handleFakeRemoval(e,t)})).add(this.events.interactiveActionExecution$.subscribe(e=>{if(this.state.calledByInteractive$.next(!0),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!0),e.payload?.behaviour==="change-chapter"){let{chapterId:t}=e.payload;this.setChapter({chapterId:t}),this.state.isFirstChapter$.getValue()&&this.state.isFirstChapter$.next(!1)}else if(e.payload?.behaviour==="change-manifest"){let{manifestURL:t}=e.payload;t&&this.setManifest(t)}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:t,payload:n})=>{e!=="action-choice"||t==="chapter"||"invokeImmediately"in n&&n.invokeImmediately||this.destroyGameControllers(!1)}))}async initSeamless(){this.seamlessController=Dr(this),this.seamlessControllerSubs.add(this.seamlessController.activePlayerChanged.subscribe(this.handleSeamlessPlayerChanged)),await this.seamlessController.init()}handlePositionChange(e){(!this.graph||this.graph.isHidden)&&this.checkIfSeekable();let t=e*1e3,i=this.getInteractiveRanges().reverse().find(({range:o})=>t>=o[1]);if(i){let o=i.range.join("-");this.endedRanges.has(o)||(this.endedRanges.add(o),this.globalEventEmitter.emit(S.interactives,{type:V.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((0,g.once)()).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((0,g.combine)({position:this.player.info.position$,interactiveRanges:this.state.interactiveRanges$,isInteractiveExpectation:this.state.isInteractiveExpectation$}).subscribe(({position:e,interactiveRanges:t,isInteractiveExpectation:n})=>{let i;if(n)i=!0;else{let l=e*1e3;i=!!t.find(({range:[d,v],subjects:m})=>d<l&&l<v&&m.some(y=>!y.isRemoved)&&m.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(t=>t.container.container).filter(t=>!se(t.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 t=[];return e.containers.forEach(n=>{let i=n.type.trim().toLowerCase(),a=this.factories.get(i)?.(n,this.rootElement,this.cssVarsManager);if(a&&this.selectBranches&&this.interactiveEvents&&this.player){let s=new Nt({player:this.player,container:a,branches:e.branches,selectBranches:this.selectBranches,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter,getContainerEventState:()=>hs(n,this.gameControllers),permanentTextControls:this._options.permanentTextControls,interactiveTimeOpenUri:this._options.interactiveTimeOpenUri,disabledControls$:this.state.disabledControls$,onRemove:()=>{this.seekToInteractiveController.deleteContainer(n.id)},onError:this.emitErrorEvent});this.animation.addFn(s.whilePlaying,!0),t.push(s)}}),t}checkIfSeekable(){if(this.state.isInteractiveExpectation$.getValue()){this.state.isSeekable$.next(!1);return}let t=this.state.isSeekable$.getValue(),n=!!this.seekToInteractiveController.getNextInteractiveTime();(n&&!t||!n&&t)&&this.state.isSeekable$.next(!t)}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 t=this.state.lastChapterChangeWasInitiatedByInteractive$.getValue(),n=this.state.prevChapter$.getValue(),i=(n&&G(n)&&We(n))??!1,o=this.manifestController.manifest?.metadata.initChapterId===e,a=this.historyController.state.history$.getValue();if(o||i&&t){this.historyController.updateHistory([e]);return}(0,Oa.default)(a,-1)!==e&&this.historyController.updateHistory([...a,e])}handleFakeRemoval(e,t){let{interactiveRanges$:n}=this.state,o=n.getValue().map(a=>{let s=a.subjects.some(c=>c.id===e),l=a.subjects.map(c=>t&&s||c.id===e?{...c,isRemoved:!0}:c);return{...a,subjects:l}});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 t=(n,i)=>{n.toggleBlinkAnimation(i)};Pt({...e,gameControllers:this.gameControllers,execFn:Qe(Hr(t),e.isExpect)}),e.isExpect&&this.blinkAnimationRef?.restart()}updateControlsShadowStyles(e){if(!this._options.animationsFeatureToggles?.areaControlShadow)return;let t=(n,i)=>{n.updateControlsShadowStyles(i)};e.isExpect?Pt({...e,gameControllers:this.gameControllers,execFn:Qe(Hr(t),!1)}):Pt({...e,gameControllers:this.gameControllers,execFn:t})}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 t=await this.manifestController.setManifest(e);if(t.manifest)return this.graph&&this.graph.handleManifestChange(t.manifest),await this.historyController.setManifest(t.manifest),this.events.manifestChanged$.next(t.manifest),this.globalEventEmitter.emit(S.manifestChanged,{manifest:t.manifest}),this.setGameControllers(),t.manifest}setPlayer(e){this.reset(),this.player=e,this.seekToInteractiveController.setPlayer(this.player),this.interactiveEvents?this.interactiveEvents.setPlayer(this.player):this.interactiveEvents=pa(this.player,this._options.interactiveTimeOpenUri),this.selectBranches=Ea({player:this.player,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter}),this.appState===1&&(this.registerVideoEvents(),this.setGameControllers())}async setChapter({chapterId:e,pushToHistory:t=!0,playPrev:n=!1}={}){this.reset(),this.lastFrame&&this.isFirstChapterFetched&&(this.lastFrame.draw(),this.lastFrame.show()),this.lastFrame&&ka.clientChecker.browser.isSafari&&await Sa(35);let i=!n&&this.state.isEndChapter$.getValue()&&this.getCurrentManifest()?.metadata.initChapterId===e;this.state.isReplay$.next(i);let{chapter:o,media:a,graph:s}=await(e?this.manifestController.setNext(e):this.manifestController.setInitial());(!e||i)&&this.state.isFirstChapter$.next(!0),!(!o||!a)&&(t&&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:a}),this.globalEventEmitter.emit(S.chapterChanged,{chapter:o,media:a,graph:s}),this.setGameControllers(),this.endedRanges=new Set,this.isFirstChapterFetched=!0)}getStatEvents(){return{click$:new g.Observable(e=>{this.subscriptions.add(this.events.graphVisibilityChanged$.subscribe(t=>{e.next(t?Ie.InteractiveInterfaceClick.GRAPH_SHOW:Ie.InteractiveInterfaceClick.GRAPH_HIDE)})).add(this.events.watchAgainIsClicked$.subscribe(()=>{e.next(Ie.InteractiveInterfaceClick.WATCH_AGAIN)})).add(this.events.interactiveActionChoice$.subscribe(({type:t,subjectName:n,subjectType:i})=>{t!=="action-choice"||n!=="control"||(i==="Button"&&e.next(Ie.InteractiveInterfaceClick.NEXT_BUTTON),i==="Area"&&e.next(Ie.InteractiveInterfaceClick.NEXT_AREA))}))}),nextMovie$:new g.Observable(e=>{this.events.playerChanged$.subscribe(({config:t})=>{t?.unitedVideoId&&!this.state.isFirstChapter$.getValue()&&e.next(t.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(S.graph,{type:Ee.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===b.EventActionTypes.setNextBranch)}allControlsAreRemoved(){return!this.gameControllers.some(t=>!t.container.isRemoved)}isEndedExpectation(){if(!this.player||!this.gameControllers)return!1;let e=this.player.info.position$.getValue(),t=this.player.info.duration$.getValue();return e===t&&this.gameControllers.some(n=>{let i=n.container.container;return!n.container.isRemoved&&i.endTime===null&&oe(i.events)})}playPrevChapter(){this.historyController.goBack()}setDisabledControls(e){this.state.disabledControls$.next(e)}isSupport(e=this.manifestController.manifest){return!!e&&(0,b.isSupportedManifest)(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 ws(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,t){return this.globalEventEmitter.on(e,t),this}off(e,t){return this.globalEventEmitter.off(e,t),this}once(e,t){return this.globalEventEmitter.once(e,t),this}destroy(){this.clearHistoryIfEnded(),this.blinkAnimationRef?.destroy(),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 Va={Container:pe,createChoiceContainer:dt,createAreaControl:ct,createButtonControl:ut,classnamesPrefix:nn};var th={version:tn};
|
|
149
|
+
`;var wa=r=>{let e=document.createElement("style");e.textContent=Aa,r.prepend(e)};var Oa=require("@vkontakte/videoplayer-core/es2024");var Ra=Object.freeze({lang:g.InterfaceLanguage.RU,loaders:{},graph:!1,initSeamless:!1,lastFrame:!1,permanentTextControls:!0,interactiveTimeOpenUri:!1,config:{historyMaxLength:100,noInteractionEventTimeout:3e4},animationsFeatureToggles:{areaControlShadow:!1,controlsExpectTimeBlinkAnimation:!1}});function eh(){let r=document.createElement("div");return r.classList.add("interactive-chapter"),r}var Ze=class{constructor(e){this.playerSubscriptions=new g.Subscription;this.subscriptions=new g.Subscription;this.globalEventEmitter=new It;this.animation=new xt;this.seekToInteractiveController=new qe;this.endedRanges=new Set;this.gameControllers=[];this.rootElement=eh();this.factories=new Map([["choice",dt]]);this.isFirstChapterFetched=!1;this.player=null;this.interactiveEvents=null;this.selectBranches=null;this.seamlessController=null;this.seamlessControllerSubs=new g.Subscription;this.graph=null;this.lastFrame=null;this.blinkAnimationRef=null;this.appState=0;this.state={prevChapter$:new g.ValueSubject(null),isInitialChapter$:new g.ValueSubject(!1),isFirstChapter$:new g.ValueSubject(!0),isEndChapter$:new g.ValueSubject(!1),isInteractiveExpectation$:new g.ValueSubject(!1),isReplay$:new g.ValueSubject(!1),calledByInteractive$:new g.ValueSubject(!1),lastChapterChangeWasInitiatedByInteractive$:new g.ValueSubject(!1),disabledControls$:new g.ValueSubject(!1),interactiveRanges$:new g.ValueSubject([]),isInteractiveTime$:new g.ValueSubject(!1),statistics$:new g.ValueSubject(null),isSeekable$:new g.ValueSubject(!1)};this.events={noInteraction$:new g.Subject,graphVisibilityChanged$:new g.Subject,watchAgainIsClicked$:new g.Subject,chapterChanged$:new g.Subject,playerChanged$:new g.Subject,error$:new g.Subject,eachTick$:new g.Subject,manifestChanged$:new g.Subject,interactiveRangeEnded$:new g.Subject,interactiveContainerRemoved$:new g.Subject,interactiveContainerFakeRemoved$:new g.Subject,interactiveActionExecution$:new g.Subject,interactiveActionChoice$:new g.Subject,interactiveVisibilityChanged$:new g.Subject};this.emitErrorEvent=e=>{this.events.error$.next(e),this.globalEventEmitter.emit(S.errors,e)};this.clearHistoryIfEnded=()=>{let e=this.player?.info.isEnded$.getValue(),t=this.state.isInteractiveExpectation$.getValue(),{chapter:n}=this.getCurrentChapter();e&&n&&G(n)&&!t&&this.historyController.updateHistory([]),window.removeEventListener("beforeunload",this.clearHistoryIfEnded)};this.handleSeamlessPlayerChanged=e=>{if(!e)return;let{statistics:t,...n}=e;if(t){let{statSubscription:i,oneStat:o}=t;i.add(o.attachToInteractive(this.getStatEvents())),this.state.statistics$.next(t)}this.state.isReplay$.getValue()&&this.state.isReplay$.next(!1),this.events.playerChanged$.next(n),this.globalEventEmitter.emit(S.playerChanged,n)};this.onPlaybackStarted=()=>{this.resizeManager?.calc(),this.animation.requestAnimation()};this.destroyGameControllers=(e=!0)=>{this.gameControllers.forEach(t=>{!e&&t.isPermanentText||(this.animation.removeFn(t.whilePlaying),t.destroy())})};this.completeInteractiveRange=e=>{let{interactiveRanges$:t}=this.state,i=t.getValue().map(o=>({...o,subjects:o.subjects.filter(a=>a.id!==e)}));t.next(i)};this.clearNoInteractionTimeout=()=>{this.noInteractionTimeout&&(clearTimeout(this.noInteractionTimeout),this.noInteractionTimeout=void 0)};if(this._options={...Ra,...e,config:{...Ra.config,...e.config}},this._options.animationsFeatureToggles?.controlsExpectTimeBlinkAnimation){this.blinkAnimationRef=new lt,this.blinkAnimationRef.create();let i=this.blinkAnimationRef.element;i&&this.rootElement.append(i)}this._options.parentElement.append(this.rootElement),this.historyController=new Ye({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 Ft({parentElement:this._options.parentElement,onError:i=>{let o=new O(1,6,i);this.emitErrorEvent(o)}})),wa(this._options.parentElement),this.subscriptions.add((0,g.fromEvent)(this.rootElement,"mousedown").subscribe(i=>i.stopPropagation())).add((0,g.fromEvent)(this.rootElement,"mouseup").subscribe(i=>i.stopPropagation())),this.manifestController=new ae(this._options.loaders,i=>{let o=new O(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.cssVarsManager=new Tt(this._options?.parentElement),this.resizeManager=da(()=>({player:this.player,cssVarsManager:this.cssVarsManager,parentElement:this._options.parentElement,fns:n})),this._options.graph&&(this.graph=new Be({root:this._options.parentElement,lang:this._options.lang,onOpenPreviewClick:i=>{this.setChapter({chapterId:i}),this.globalEventEmitter.emit(S.graph,{type:Ee.watchAgainClicked,chapterId:i}),this.events.watchAgainIsClicked$.next(i)},onError:i=>{let o=new O(1,2,{message:i});this.emitErrorEvent(o)}})),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:t})=>{this.handleFakeRemoval(e,t)})).add(this.events.interactiveActionExecution$.subscribe(e=>{if(this.state.calledByInteractive$.next(!0),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!0),e.payload?.behaviour==="change-chapter"){let{chapterId:t}=e.payload;this.setChapter({chapterId:t}),this.state.isFirstChapter$.getValue()&&this.state.isFirstChapter$.next(!1)}else if(e.payload?.behaviour==="change-manifest"){let{manifestURL:t}=e.payload;t&&this.setManifest(t)}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:t,payload:n})=>{e!=="action-choice"||t==="chapter"||"invokeImmediately"in n&&n.invokeImmediately||this.destroyGameControllers(!1)}))}async initSeamless(){this.seamlessController=Dr(this),this.seamlessControllerSubs.add(this.seamlessController.activePlayerChanged.subscribe(this.handleSeamlessPlayerChanged)),await this.seamlessController.init()}handlePositionChange(e){(!this.graph||this.graph.isHidden)&&this.checkIfSeekable();let t=e*1e3,i=this.getInteractiveRanges().reverse().find(({range:o})=>t>=o[1]);if(i){let o=i.range.join("-");this.endedRanges.has(o)||(this.endedRanges.add(o),this.globalEventEmitter.emit(S.interactives,{type:V.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((0,g.once)()).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((0,g.combine)({position:this.player.info.position$,interactiveRanges:this.state.interactiveRanges$,isInteractiveExpectation:this.state.isInteractiveExpectation$}).subscribe(({position:e,interactiveRanges:t,isInteractiveExpectation:n})=>{let i;if(n)i=!0;else{let l=e*1e3;i=!!t.find(({range:[d,v],subjects:m})=>d<l&&l<v&&m.some(y=>!y.isRemoved)&&m.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(t=>t.container.container).filter(t=>!se(t.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 t=[];return e.containers.forEach(n=>{let i=n.type.trim().toLowerCase(),a=this.factories.get(i)?.(n,this.rootElement,this.cssVarsManager);if(a&&this.selectBranches&&this.interactiveEvents&&this.player){let s=new Nt({player:this.player,container:a,branches:e.branches,selectBranches:this.selectBranches,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter,getContainerEventState:()=>hs(n,this.gameControllers),permanentTextControls:this._options.permanentTextControls,interactiveTimeOpenUri:this._options.interactiveTimeOpenUri,disabledControls$:this.state.disabledControls$,onRemove:()=>{this.seekToInteractiveController.deleteContainer(n.id)},onError:this.emitErrorEvent});this.animation.addFn(s.whilePlaying,!0),t.push(s)}}),t}checkIfSeekable(){if(this.state.isInteractiveExpectation$.getValue()){this.state.isSeekable$.next(!1);return}let t=this.state.isSeekable$.getValue(),n=!!this.seekToInteractiveController.getNextInteractiveTime();(n&&!t||!n&&t)&&this.state.isSeekable$.next(!t)}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 t=this.state.lastChapterChangeWasInitiatedByInteractive$.getValue(),n=this.state.prevChapter$.getValue(),i=(n&&G(n)&&We(n))??!1,o=this.manifestController.manifest?.metadata.initChapterId===e,a=this.historyController.state.history$.getValue();if(o||i&&t){this.historyController.updateHistory([e]);return}(0,ka.default)(a,-1)!==e&&this.historyController.updateHistory([...a,e])}handleFakeRemoval(e,t){let{interactiveRanges$:n}=this.state,o=n.getValue().map(a=>{let s=a.subjects.some(c=>c.id===e),l=a.subjects.map(c=>t&&s||c.id===e?{...c,isRemoved:!0}:c);return{...a,subjects:l}});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 t=(n,i)=>{n.toggleBlinkAnimation(i)};Pt({...e,gameControllers:this.gameControllers,execFn:Qe(Hr(t),e.isExpect)}),e.isExpect&&this.blinkAnimationRef?.restart()}updateControlsShadowStyles(e){if(!this._options.animationsFeatureToggles?.areaControlShadow)return;let t=(n,i)=>{n.updateControlsShadowStyles(i)};e.isExpect?Pt({...e,gameControllers:this.gameControllers,execFn:Qe(Hr(t),!1)}):Pt({...e,gameControllers:this.gameControllers,execFn:t})}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 t=await this.manifestController.setManifest(e);if(t.manifest)return this.graph&&this.graph.handleManifestChange(t.manifest),await this.historyController.setManifest(t.manifest),this.events.manifestChanged$.next(t.manifest),this.globalEventEmitter.emit(S.manifestChanged,{manifest:t.manifest}),this.setGameControllers(),t.manifest}setPlayer(e){this.reset(),this.player=e,this.seekToInteractiveController.setPlayer(this.player),this.interactiveEvents?this.interactiveEvents.setPlayer(this.player):this.interactiveEvents=pa(this.player,this._options.interactiveTimeOpenUri),this.selectBranches=Ea({player:this.player,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter}),this.appState===1&&(this.registerVideoEvents(),this.setGameControllers())}async setChapter({chapterId:e,pushToHistory:t=!0,playPrev:n=!1}={}){this.reset(),this.lastFrame&&this.isFirstChapterFetched&&(this.lastFrame.draw(),this.lastFrame.show()),this.lastFrame&&Oa.clientChecker.browser.isSafari&&await Sa(35);let i=!n&&this.state.isEndChapter$.getValue()&&this.getCurrentManifest()?.metadata.initChapterId===e;this.state.isReplay$.next(i);let{chapter:o,media:a,graph:s}=await(e?this.manifestController.setNext(e):this.manifestController.setInitial());(!e||i)&&this.state.isFirstChapter$.next(!0),!(!o||!a)&&(t&&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:a}),this.globalEventEmitter.emit(S.chapterChanged,{chapter:o,media:a,graph:s}),this.setGameControllers(),this.endedRanges=new Set,this.isFirstChapterFetched=!0)}getStatEvents(){return{click$:new g.Observable(e=>{this.subscriptions.add(this.events.graphVisibilityChanged$.subscribe(t=>{e.next(t?Ie.InteractiveInterfaceClick.GRAPH_SHOW:Ie.InteractiveInterfaceClick.GRAPH_HIDE)})).add(this.events.watchAgainIsClicked$.subscribe(()=>{e.next(Ie.InteractiveInterfaceClick.WATCH_AGAIN)})).add(this.events.interactiveActionChoice$.subscribe(({type:t,subjectName:n,subjectType:i})=>{t!=="action-choice"||n!=="control"||(i==="Button"&&e.next(Ie.InteractiveInterfaceClick.NEXT_BUTTON),i==="Area"&&e.next(Ie.InteractiveInterfaceClick.NEXT_AREA))}))}),nextMovie$:new g.Observable(e=>{this.events.playerChanged$.subscribe(({config:t})=>{t?.unitedVideoId&&!this.state.isFirstChapter$.getValue()&&e.next(t.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(S.graph,{type:Ee.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===b.EventActionTypes.setNextBranch)}allControlsAreRemoved(){return!this.gameControllers.some(t=>!t.container.isRemoved)}isEndedExpectation(){if(!this.player||!this.gameControllers)return!1;let e=this.player.info.position$.getValue(),t=this.player.info.duration$.getValue();return e===t&&this.gameControllers.some(n=>{let i=n.container.container;return!n.container.isRemoved&&i.endTime===null&&oe(i.events)})}playPrevChapter(){this.historyController.goBack()}setDisabledControls(e){this.state.disabledControls$.next(e)}isSupport(e=this.manifestController.manifest){return!!e&&(0,b.isSupportedManifest)(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 ws(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,t){return this.globalEventEmitter.on(e,t),this}off(e,t){return this.globalEventEmitter.off(e,t),this}once(e,t){return this.globalEventEmitter.once(e,t),this}destroy(){this.clearHistoryIfEnded(),this.blinkAnimationRef?.destroy(),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 Va={Container:pe,createChoiceContainer:dt,createAreaControl:ct,createButtonControl:ut,classnamesPrefix:nn};var th={version:tn};
|