@vkontakte/videoplayer-interactive 1.0.40-dev.64a00d86.0 → 1.0.40-dev.7807e4e6.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 +3 -3
- package/es2015.esm.js +3 -3
- package/es2018.cjs.js +3 -3
- package/es2018.esm.js +3 -3
- package/es2024.cjs.js +3 -3
- package/es2024.esm.js +3 -3
- package/esnext.cjs.js +3 -3
- package/esnext.esm.js +3 -3
- package/evergreen.esm.js +3 -3
- package/package.json +4 -4
package/es2018.esm.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-interactive v1.0.40-dev.
|
|
3
|
-
* Fri, 20 Jun 2025
|
|
2
|
+
* @vkontakte/videoplayer-interactive v1.0.40-dev.7807e4e6.0
|
|
3
|
+
* Fri, 20 Jun 2025 11:40:21 GMT
|
|
4
4
|
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-40/doc/
|
|
5
5
|
*/
|
|
6
|
-
var cl=Object.create;var Si=Object.defineProperty;var ul=Object.getOwnPropertyDescriptor;var pl=Object.getOwnPropertyNames;var hl=Object.getPrototypeOf,dl=Object.prototype.hasOwnProperty;var Ri=r=>{throw TypeError(r)};var h=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var ml=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of pl(e))!dl.call(r,n)&&n!==t&&Si(r,n,{get:()=>e[n],enumerable:!(i=ul(e,n))||i.enumerable});return r};var ee=(r,e,t)=>(t=r!=null?cl(hl(r)):{},ml(e||!r||!r.__esModule?Si(t,"default",{value:r,enumerable:!0}):t,r));var ki=(r,e,t)=>e.has(r)||Ri("Cannot "+t);var w=(r,e,t)=>(ki(r,e,"read from private field"),t?t.call(r):e.get(r)),H=(r,e,t)=>e.has(r)?Ri("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),M=(r,e,t,i)=>(ki(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t);var Oi=(r,e,t,i)=>({set _(n){M(r,e,n,t)},get _(){return w(r,e,i)}});var Y=h((hr,qi)=>{"use strict";var Me=function(r){return r&&r.Math===Math&&r};qi.exports=Me(typeof globalThis=="object"&&globalThis)||Me(typeof window=="object"&&window)||Me(typeof self=="object"&&self)||Me(typeof global=="object"&&global)||Me(typeof hr=="object"&&hr)||function(){return this}()||Function("return this")()});var U=h((yd,Di)=>{"use strict";Di.exports=function(r){try{return!!r()}catch(e){return!0}}});var Ne=h((gd,Hi)=>{"use strict";var yl=U();Hi.exports=!yl(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var Ki=h((Cd,Wi)=>{"use strict";var gl=Ne(),zi=Function.prototype,Ui=zi.apply,Gi=zi.call;Wi.exports=typeof Reflect=="object"&&Reflect.apply||(gl?Gi.bind(Ui):function(){return Gi.apply(Ui,arguments)})});var W=h((Ed,Yi)=>{"use strict";var Qi=Ne(),Xi=Function.prototype,dr=Xi.call,Cl=Qi&&Xi.bind.bind(dr,dr);Yi.exports=Qi?Cl:function(r){return function(){return dr.apply(r,arguments)}}});var $e=h((Td,Ji)=>{"use strict";var Zi=W(),El=Zi({}.toString),Tl=Zi("".slice);Ji.exports=function(r){return Tl(El(r),8,-1)}});var mr=h((Id,en)=>{"use strict";var Il=$e(),xl=W();en.exports=function(r){if(Il(r)==="Function")return xl(r)}});var G=h((xd,tn)=>{"use strict";var fr=typeof document=="object"&&document.all;tn.exports=typeof fr=="undefined"&&fr!==void 0?function(r){return typeof r=="function"||r===fr}:function(r){return typeof r=="function"}});var pe=h((Ad,rn)=>{"use strict";var Al=U();rn.exports=!Al(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var gt=h((wd,nn)=>{"use strict";var wl=Ne(),yt=Function.prototype.call;nn.exports=wl?yt.bind(yt):function(){return yt.apply(yt,arguments)}});var vr=h(sn=>{"use strict";var on={}.propertyIsEnumerable,an=Object.getOwnPropertyDescriptor,Sl=an&&!on.call({1:2},1);sn.f=Sl?function(e){var t=an(this,e);return!!t&&t.enumerable}:on});var br=h((Rd,ln)=>{"use strict";ln.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var un=h((kd,cn)=>{"use strict";var Rl=W(),kl=U(),Ol=$e(),yr=Object,Pl=Rl("".split);cn.exports=kl(function(){return!yr("z").propertyIsEnumerable(0)})?function(r){return Ol(r)==="String"?Pl(r,""):yr(r)}:yr});var gr=h((Od,pn)=>{"use strict";pn.exports=function(r){return r==null}});var Cr=h((Pd,hn)=>{"use strict";var Ll=gr(),Fl=TypeError;hn.exports=function(r){if(Ll(r))throw new Fl("Can't call method on "+r);return r}});var _e=h((Ld,dn)=>{"use strict";var Vl=un(),Ml=Cr();dn.exports=function(r){return Vl(Ml(r))}});var Ee=h((Fd,mn)=>{"use strict";var Nl=G();mn.exports=function(r){return typeof r=="object"?r!==null:Nl(r)}});var Ct=h((Vd,fn)=>{"use strict";fn.exports={}});var Et=h((Md,bn)=>{"use strict";var Er=Ct(),Tr=Y(),$l=G(),vn=function(r){return $l(r)?r:void 0};bn.exports=function(r,e){return arguments.length<2?vn(Er[r])||vn(Tr[r]):Er[r]&&Er[r][e]||Tr[r]&&Tr[r][e]}});var gn=h((Nd,yn)=>{"use strict";var _l=W();yn.exports=_l({}.isPrototypeOf)});var In=h(($d,Tn)=>{"use strict";var jl=Y(),Cn=jl.navigator,En=Cn&&Cn.userAgent;Tn.exports=En?String(En):""});var On=h((_d,kn)=>{"use strict";var Rn=Y(),Ir=In(),xn=Rn.process,An=Rn.Deno,wn=xn&&xn.versions||An&&An.version,Sn=wn&&wn.v8,K,Tt;Sn&&(K=Sn.split("."),Tt=K[0]>0&&K[0]<4?1:+(K[0]+K[1]));!Tt&&Ir&&(K=Ir.match(/Edge\/(\d+)/),(!K||K[1]>=74)&&(K=Ir.match(/Chrome\/(\d+)/),K&&(Tt=+K[1])));kn.exports=Tt});var xr=h((jd,Ln)=>{"use strict";var Pn=On(),Bl=U(),ql=Y(),Dl=ql.String;Ln.exports=!!Object.getOwnPropertySymbols&&!Bl(function(){var r=Symbol("symbol detection");return!Dl(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&Pn&&Pn<41})});var Ar=h((Bd,Fn)=>{"use strict";var Hl=xr();Fn.exports=Hl&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var wr=h((qd,Vn)=>{"use strict";var Ul=Et(),Gl=G(),zl=gn(),Wl=Ar(),Kl=Object;Vn.exports=Wl?function(r){return typeof r=="symbol"}:function(r){var e=Ul("Symbol");return Gl(e)&&zl(e.prototype,Kl(r))}});var Nn=h((Dd,Mn)=>{"use strict";var Ql=String;Mn.exports=function(r){try{return Ql(r)}catch(e){return"Object"}}});var Sr=h((Hd,$n)=>{"use strict";var Xl=G(),Yl=Nn(),Zl=TypeError;$n.exports=function(r){if(Xl(r))return r;throw new Zl(Yl(r)+" is not a function")}});var jn=h((Ud,_n)=>{"use strict";var Jl=Sr(),ec=gr();_n.exports=function(r,e){var t=r[e];return ec(t)?void 0:Jl(t)}});var qn=h((Gd,Bn)=>{"use strict";var Rr=gt(),kr=G(),Or=Ee(),tc=TypeError;Bn.exports=function(r,e){var t,i;if(e==="string"&&kr(t=r.toString)&&!Or(i=Rr(t,r))||kr(t=r.valueOf)&&!Or(i=Rr(t,r))||e!=="string"&&kr(t=r.toString)&&!Or(i=Rr(t,r)))return i;throw new tc("Can't convert object to primitive value")}});var Hn=h((zd,Dn)=>{"use strict";Dn.exports=!0});var zn=h((Wd,Gn)=>{"use strict";var Un=Y(),rc=Object.defineProperty;Gn.exports=function(r,e){try{rc(Un,r,{value:e,configurable:!0,writable:!0})}catch(t){Un[r]=e}return e}});var It=h((Kd,Qn)=>{"use strict";var ic=Hn(),nc=Y(),oc=zn(),Wn="__core-js_shared__",Kn=Qn.exports=nc[Wn]||oc(Wn,{});(Kn.versions||(Kn.versions=[])).push({version:"3.38.0",mode:ic?"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 Pr=h((Qd,Yn)=>{"use strict";var Xn=It();Yn.exports=function(r,e){return Xn[r]||(Xn[r]=e||{})}});var je=h((Xd,Zn)=>{"use strict";var ac=Cr(),sc=Object;Zn.exports=function(r){return sc(ac(r))}});var Te=h((Yd,Jn)=>{"use strict";var lc=W(),cc=je(),uc=lc({}.hasOwnProperty);Jn.exports=Object.hasOwn||function(e,t){return uc(cc(e),t)}});var Lr=h((Zd,eo)=>{"use strict";var pc=W(),hc=0,dc=Math.random(),mc=pc(1 .toString);eo.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+mc(++hc+dc,36)}});var Be=h((Jd,ro)=>{"use strict";var fc=Y(),vc=Pr(),to=Te(),bc=Lr(),yc=xr(),gc=Ar(),Ie=fc.Symbol,Fr=vc("wks"),Cc=gc?Ie.for||Ie:Ie&&Ie.withoutSetter||bc;ro.exports=function(r){return to(Fr,r)||(Fr[r]=yc&&to(Ie,r)?Ie[r]:Cc("Symbol."+r)),Fr[r]}});var ao=h((em,oo)=>{"use strict";var Ec=gt(),io=Ee(),no=wr(),Tc=jn(),Ic=qn(),xc=Be(),Ac=TypeError,wc=xc("toPrimitive");oo.exports=function(r,e){if(!io(r)||no(r))return r;var t=Tc(r,wc),i;if(t){if(e===void 0&&(e="default"),i=Ec(t,r,e),!io(i)||no(i))return i;throw new Ac("Can't convert object to primitive value")}return e===void 0&&(e="number"),Ic(r,e)}});var Vr=h((tm,so)=>{"use strict";var Sc=ao(),Rc=wr();so.exports=function(r){var e=Sc(r,"string");return Rc(e)?e:e+""}});var uo=h((rm,co)=>{"use strict";var kc=Y(),lo=Ee(),Mr=kc.document,Oc=lo(Mr)&&lo(Mr.createElement);co.exports=function(r){return Oc?Mr.createElement(r):{}}});var Nr=h((im,po)=>{"use strict";var Pc=pe(),Lc=U(),Fc=uo();po.exports=!Pc&&!Lc(function(){return Object.defineProperty(Fc("div"),"a",{get:function(){return 7}}).a!==7})});var fo=h(mo=>{"use strict";var Vc=pe(),Mc=gt(),Nc=vr(),$c=br(),_c=_e(),jc=Vr(),Bc=Te(),qc=Nr(),ho=Object.getOwnPropertyDescriptor;mo.f=Vc?ho:function(e,t){if(e=_c(e),t=jc(t),qc)try{return ho(e,t)}catch(i){}if(Bc(e,t))return $c(!Mc(Nc.f,e,t),e[t])}});var bo=h((om,vo)=>{"use strict";var Dc=U(),Hc=G(),Uc=/#|\.prototype\./,qe=function(r,e){var t=zc[Gc(r)];return t===Kc?!0:t===Wc?!1:Hc(e)?Dc(e):!!e},Gc=qe.normalize=function(r){return String(r).replace(Uc,".").toLowerCase()},zc=qe.data={},Wc=qe.NATIVE="N",Kc=qe.POLYFILL="P";vo.exports=qe});var $r=h((am,go)=>{"use strict";var yo=mr(),Qc=Sr(),Xc=Ne(),Yc=yo(yo.bind);go.exports=function(r,e){return Qc(r),e===void 0?r:Xc?Yc(r,e):function(){return r.apply(e,arguments)}}});var Eo=h((sm,Co)=>{"use strict";var Zc=pe(),Jc=U();Co.exports=Zc&&Jc(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var Io=h((lm,To)=>{"use strict";var eu=Ee(),tu=String,ru=TypeError;To.exports=function(r){if(eu(r))return r;throw new ru(tu(r)+" is not an object")}});var wo=h(Ao=>{"use strict";var iu=pe(),nu=Nr(),ou=Eo(),xt=Io(),xo=Vr(),au=TypeError,_r=Object.defineProperty,su=Object.getOwnPropertyDescriptor,jr="enumerable",Br="configurable",qr="writable";Ao.f=iu?ou?function(e,t,i){if(xt(e),t=xo(t),xt(i),typeof e=="function"&&t==="prototype"&&"value"in i&&qr in i&&!i[qr]){var n=su(e,t);n&&n[qr]&&(e[t]=i.value,i={configurable:Br in i?i[Br]:n[Br],enumerable:jr in i?i[jr]:n[jr],writable:!1})}return _r(e,t,i)}:_r:function(e,t,i){if(xt(e),t=xo(t),xt(i),nu)try{return _r(e,t,i)}catch(n){}if("get"in i||"set"in i)throw new au("Accessors not supported");return"value"in i&&(e[t]=i.value),e}});var Ro=h((um,So)=>{"use strict";var lu=pe(),cu=wo(),uu=br();So.exports=lu?function(r,e,t){return cu.f(r,e,uu(1,t))}:function(r,e,t){return r[e]=t,r}});var He=h((pm,Oo)=>{"use strict";var De=Y(),pu=Ki(),hu=mr(),du=G(),mu=fo().f,fu=bo(),xe=Ct(),vu=$r(),Ae=Ro(),ko=Te();It();var bu=function(r){var e=function(t,i,n){if(this instanceof e){switch(arguments.length){case 0:return new r;case 1:return new r(t);case 2:return new r(t,i)}return new r(t,i,n)}return pu(r,this,arguments)};return e.prototype=r.prototype,e};Oo.exports=function(r,e){var t=r.target,i=r.global,n=r.stat,o=r.proto,a=i?De:n?De[t]:De[t]&&De[t].prototype,l=i?xe:xe[t]||Ae(xe,t,{})[t],s=l.prototype,c,m,f,v,y,C,E,d,u;for(v in e)c=fu(i?v:t+(n?".":"#")+v,r.forced),m=!c&&a&&ko(a,v),C=l[v],m&&(r.dontCallGetSet?(u=mu(a,v),E=u&&u.value):E=a[v]),y=m&&E?E:e[v],!(!c&&!o&&typeof C==typeof y)&&(r.bind&&m?d=vu(y,De):r.wrap&&m?d=bu(y):o&&du(y)?d=hu(y):d=y,(r.sham||y&&y.sham||C&&C.sham)&&Ae(d,"sham",!0),Ae(l,v,d),o&&(f=t+"Prototype",ko(xe,f)||Ae(xe,f,{}),Ae(xe[f],v,y),r.real&&s&&(c||!s[v])&&Ae(s,v,y)))}});var Lo=h((hm,Po)=>{"use strict";var yu=Math.ceil,gu=Math.floor;Po.exports=Math.trunc||function(e){var t=+e;return(t>0?gu:yu)(t)}});var Ue=h((dm,Fo)=>{"use strict";var Cu=Lo();Fo.exports=function(r){var e=+r;return e!==e||e===0?0:Cu(e)}});var Mo=h((mm,Vo)=>{"use strict";var Eu=Ue(),Tu=Math.max,Iu=Math.min;Vo.exports=function(r,e){var t=Eu(r);return t<0?Tu(t+e,0):Iu(t,e)}});var $o=h((fm,No)=>{"use strict";var xu=Ue(),Au=Math.min;No.exports=function(r){var e=xu(r);return e>0?Au(e,9007199254740991):0}});var Ge=h((vm,_o)=>{"use strict";var wu=$o();_o.exports=function(r){return wu(r.length)}});var Dr=h((bm,Bo)=>{"use strict";var Su=_e(),Ru=Mo(),ku=Ge(),jo=function(r){return function(e,t,i){var n=Su(e),o=ku(n);if(o===0)return!r&&-1;var a=Ru(i,o),l;if(r&&t!==t){for(;o>a;)if(l=n[a++],l!==l)return!0}else for(;o>a;a++)if((r||a in n)&&n[a]===t)return r||a||0;return!r&&-1}};Bo.exports={includes:jo(!0),indexOf:jo(!1)}});var At=h((ym,qo)=>{"use strict";qo.exports=function(){}});var Do=h(()=>{"use strict";var Ou=He(),Pu=Dr().includes,Lu=U(),Fu=At(),Vu=Lu(function(){return!Array(1).includes()});Ou({target:"Array",proto:!0,forced:Vu},{includes:function(e){return Pu(this,e,arguments.length>1?arguments[1]:void 0)}});Fu("includes")});var wt=h((Em,Ho)=>{"use strict";var Mu=Et();Ho.exports=Mu});var Go=h((Tm,Uo)=>{"use strict";Do();var Nu=wt();Uo.exports=Nu("Array","includes")});var Wo=h((Im,zo)=>{"use strict";var $u=Go();zo.exports=$u});var St=h((xm,Ko)=>{"use strict";var _u=Wo();Ko.exports=_u});var ma=h(()=>{"use strict";var zu=He(),Wu=je(),Ku=Ge(),Qu=Ue(),Xu=At();zu({target:"Array",proto:!0},{at:function(e){var t=Wu(this),i=Ku(t),n=Qu(e),o=n>=0?n:i+n;return o<0||o>=i?void 0:t[o]}});Xu("at")});var va=h((tv,fa)=>{"use strict";ma();var Yu=wt();fa.exports=Yu("Array","at")});var ya=h((rv,ba)=>{"use strict";var Zu=va();ba.exports=Zu});var Zr=h((iv,ga)=>{"use strict";var Ju=ya();ga.exports=Ju});var Sa=h((Gv,wa)=>{"use strict";var cp=Pr(),up=Lr(),Aa=cp("keys");wa.exports=function(r){return Aa[r]||(Aa[r]=up(r))}});var ka=h((zv,Ra)=>{"use strict";var pp=U();Ra.exports=!pp(function(){function r(){}return r.prototype.constructor=null,Object.getPrototypeOf(new r)!==r.prototype})});var La=h((Wv,Pa)=>{"use strict";var hp=Te(),dp=G(),mp=je(),fp=Sa(),vp=ka(),Oa=fp("IE_PROTO"),ni=Object,bp=ni.prototype;Pa.exports=vp?ni.getPrototypeOf:function(r){var e=mp(r);if(hp(e,Oa))return e[Oa];var t=e.constructor;return dp(t)&&e instanceof t?t.prototype:e instanceof ni?bp:null}});var Va=h((Kv,Fa)=>{"use strict";Fa.exports={}});var $a=h((Qv,Na)=>{"use strict";var yp=W(),oi=Te(),gp=_e(),Cp=Dr().indexOf,Ep=Va(),Ma=yp([].push);Na.exports=function(r,e){var t=gp(r),i=0,n=[],o;for(o in t)!oi(Ep,o)&&oi(t,o)&&Ma(n,o);for(;e.length>i;)oi(t,o=e[i++])&&(~Cp(n,o)||Ma(n,o));return n}});var ja=h((Xv,_a)=>{"use strict";_a.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var qa=h((Yv,Ba)=>{"use strict";var Tp=$a(),Ip=ja();Ba.exports=Object.keys||function(e){return Tp(e,Ip)}});var Wa=h((Zv,za)=>{"use strict";var Ha=pe(),xp=U(),Ua=W(),Ap=La(),wp=qa(),Sp=_e(),Rp=vr().f,Ga=Ua(Rp),kp=Ua([].push),Op=Ha&&xp(function(){var r=Object.create(null);return r[2]=2,!Ga(r,2)}),Da=function(r){return function(e){for(var t=Sp(e),i=wp(t),n=Op&&Ap(t)===null,o=i.length,a=0,l=[],s;o>a;)s=i[a++],(!Ha||(n?s in t:Ga(t,s)))&&kp(l,r?[s,t[s]]:t[s]);return l}};za.exports={entries:Da(!0),values:Da(!1)}});var Ka=h(()=>{"use strict";var Pp=He(),Lp=Wa().values;Pp({target:"Object",stat:!0},{values:function(e){return Lp(e)}})});var Xa=h((tb,Qa)=>{"use strict";Ka();var Fp=Ct();Qa.exports=Fp.Object.values});var Za=h((rb,Ya)=>{"use strict";var Vp=Xa();Ya.exports=Vp});var Qt=h((ib,Ja)=>{"use strict";var Mp=Za();Ja.exports=Mp});var pi=h((Sb,os)=>{"use strict";var qp=$e();os.exports=Array.isArray||function(e){return qp(e)==="Array"}});var ss=h((Rb,as)=>{"use strict";var Dp=TypeError,Hp=9007199254740991;as.exports=function(r){if(r>Hp)throw Dp("Maximum allowed index exceeded");return r}});var us=h((kb,cs)=>{"use strict";var Up=pi(),Gp=Ge(),zp=ss(),Wp=$r(),ls=function(r,e,t,i,n,o,a,l){for(var s=n,c=0,m=a?Wp(a,l):!1,f,v;c<i;)c in t&&(f=m?m(t[c],c,e):t[c],o>0&&Up(f)?(v=Gp(f),s=ls(r,e,f,v,s,o-1)-1):(zp(s+1),r[s]=f),s++),c++;return s};cs.exports=ls});var ds=h((Ob,hs)=>{"use strict";var Kp=Be(),Qp=Kp("toStringTag"),ps={};ps[Qp]="z";hs.exports=String(ps)==="[object z]"});var fs=h((Pb,ms)=>{"use strict";var Xp=ds(),Yp=G(),Yt=$e(),Zp=Be(),Jp=Zp("toStringTag"),eh=Object,th=Yt(function(){return arguments}())==="Arguments",rh=function(r,e){try{return r[e]}catch(t){}};ms.exports=Xp?Yt:function(r){var e,t,i;return r===void 0?"Undefined":r===null?"Null":typeof(t=rh(e=eh(r),Jp))=="string"?t:th?Yt(e):(i=Yt(e))==="Object"&&Yp(e.callee)?"Arguments":i}});var bs=h((Lb,vs)=>{"use strict";var ih=W(),nh=G(),hi=It(),oh=ih(Function.toString);nh(hi.inspectSource)||(hi.inspectSource=function(r){return oh(r)});vs.exports=hi.inspectSource});var Is=h((Fb,Ts)=>{"use strict";var ah=W(),sh=U(),ys=G(),lh=fs(),ch=Et(),uh=bs(),gs=function(){},Cs=ch("Reflect","construct"),di=/^\s*(?:class|function)\b/,ph=ah(di.exec),hh=!di.test(gs),nt=function(e){if(!ys(e))return!1;try{return Cs(gs,[],e),!0}catch(t){return!1}},Es=function(e){if(!ys(e))return!1;switch(lh(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return hh||!!ph(di,uh(e))}catch(t){return!0}};Es.sham=!0;Ts.exports=!Cs||sh(function(){var r;return nt(nt.call)||!nt(Object)||!nt(function(){r=!0})||r})?Es:nt});var Ss=h((Vb,ws)=>{"use strict";var xs=pi(),dh=Is(),mh=Ee(),fh=Be(),vh=fh("species"),As=Array;ws.exports=function(r){var e;return xs(r)&&(e=r.constructor,dh(e)&&(e===As||xs(e.prototype))?e=void 0:mh(e)&&(e=e[vh],e===null&&(e=void 0))),e===void 0?As:e}});var ks=h((Mb,Rs)=>{"use strict";var bh=Ss();Rs.exports=function(r,e){return new(bh(r))(e===0?0:e)}});var Os=h(()=>{"use strict";var yh=He(),gh=us(),Ch=je(),Eh=Ge(),Th=Ue(),Ih=ks();yh({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=Ch(this),i=Eh(t),n=Ih(t,0);return n.length=gh(n,t,t,i,0,e===void 0?1:Th(e)),n}})});var Ps=h(()=>{"use strict";var xh=At();xh("flat")});var Fs=h((Bb,Ls)=>{"use strict";Os();Ps();var Ah=wt();Ls.exports=Ah("Array","flat")});var Ms=h((qb,Vs)=>{"use strict";var wh=Fs();Vs.exports=wh});var $s=h((Db,Ns)=>{"use strict";var Sh=Ms();Ns.exports=Sh});var Pi="1.0.40-dev.64a00d86.0";import{fromEvent as da,Subscription as Gu}from"@vkontakte/videoplayer-shared/es2018";var nr=class{constructor(e){this.layout=e}},ct=class extends nr{constructor(e){super(e)}setContainerLayout(e){e.style.position="relative"}setControlLayout(e,t){e.style.position="absolute",e.style.width=`calc(var(--interactive-content-width) * (${t.width} + ${2e-4}))`,e.style.height=`calc(var(--interactive-content-height) * ${t.height})`,e.style.left=`calc(var(--interactive-content-width) * ${t.x} + ((var(--interactive-width) - var(--interactive-content-width)) / 2))`,e.style.top=`calc(var(--interactive-content-height) * ${t.y} + ((var(--interactive-height) - var(--interactive-content-height)) / 2))`}};import{Subject as fl}from"@vkontakte/videoplayer-shared/es2018";function Li(r){return"features"in r}var N=class{constructor(e,t,...i){this.severity=e;this.category=t;this.data=i}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};function ut({emitter$:r,error:e,subjectId:t,message:i="",severity:n=1,category:o=1}){let a=new N(n,o,{message:i,error:e,details:{id:t}});r.next(a)}var ye=class{constructor(e,t){this.error$=new fl;this.container=e,this.options=t,this.factories=new Map,this.controls=[],this.setControls()}featureIsEnabled(e){return this.options&&Li(this.options)&&this.options.features[e]}onError(e="",t){ut({emitter$:this.error$,error:t,message:e,subjectId:this.container.id})}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(){var e;return((e=this.container.controls)==null?void 0:e.reduce((t,i)=>{let n=i.type.trim().toLowerCase(),o=this.factories.get(n);if(o){let a=o(i,this.options);if(a)return[...t,a]}return[...t]},[]))||[]}};import{fromEvent as We,once as ia}from"@vkontakte/videoplayer-shared/es2018";var oe=(r,e)=>Object.prototype.toString.call(r)===`[object ${e}]`,ae=r=>oe(r,"Object"),pt=r=>oe(r,"String"),ht=r=>oe(r,"Array"),dt=r=>oe(r,"Number"),Fi=r=>oe(r,"Function"),Vi=r=>oe(r,"Boolean"),sr=r=>dt(r)&&!isNaN(r);var ce=r=>ae(r)&&Object.keys(r).length===0,lr=r=>ht(r)&&!r.length;var Le=(r,e)=>pt(r)&&(e?r.trim():r).length;function Fe(r,e=1){let t="0",i="0",n="0";return r.length===4?(t="0x"+r[1]+r[1],i="0x"+r[2]+r[2],n="0x"+r[3]+r[3]):r.length===7&&(t="0x"+r[1]+r[2],i="0x"+r[3]+r[4],n="0x"+r[5]+r[6]),`rgba(${+t},${+i},${+n},${e})`}var Mi="interactive",L={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},Ni=(i=>(i.top="flex-start",i.bottom="flex-end",i.center="center",i))(Ni||{}),$i=(i=>(i.start="flex-start",i.end="flex-end",i.center="center",i))($i||{}),_i=(i=>(i.start="left",i.end="right",i.center="center",i))(_i||{}),mt=({target:r,props:e})=>{var t,i,n;r.style.alignItems=(t=(e==null?void 0:e.gravityVertical)&&Ni[e.gravityVertical])!=null?t:"center",r.style.justifyContent=(i=(e==null?void 0:e.gravityHorizontal)&&$i[e.gravityHorizontal])!=null?i:"center",r.style.textAlign=(n=(e==null?void 0:e.alignment)&&_i[e.alignment])!=null?n:"center"},ft=({target:r,props:e,fallback:t,dependsOn:i})=>{var n,o,a,l,s,c;r.style.color=(o=(n=e==null?void 0:e.text)==null?void 0:n.color)!=null?o:t.textColor,r.style.fontSize=`calc(${i.height} * ${(l=(a=e==null?void 0:e.text)==null?void 0:a.size)!=null?l:t.textSize})`,r.textContent=(c=(s=e==null?void 0:e.text)==null?void 0:s.value)!=null?c:t.textContent},vt=({target:r,props:e,fallback:t})=>{var i,n,o,a;r.style.backgroundColor=Fe((n=(i=e==null?void 0:e.background)==null?void 0:i.color)!=null?n:t.backgroundColor,(a=(o=e==null?void 0:e.background)==null?void 0:o.alpha)!=null?a:t.backgroundAlpha)},Ve=({target:r,props:e,fallback:t,dependsOn:i,useRawValues:n=!1})=>{var l,s,c,m,f,v,y,C,E,d,u;let o=n?t.borderWidthRawValue:`calc(${i.height} * ${(c=(s=(l=e==null?void 0:e.shape)==null?void 0:l.border)==null?void 0:s.width)!=null?c:t.borderWidth})`,a=n?t.roundCornersRawValue:`calc(${i.height} * ${(f=(m=e==null?void 0:e.shape)==null?void 0:m.roundCorners)!=null?f:t.roundCorners})`;r.style.borderWidth=o,r.style.borderStyle="solid",r.style.borderColor=Fe(n?t.borderColor:(C=(y=(v=e==null?void 0:e.shape)==null?void 0:v.border)==null?void 0:y.color)!=null?C:t.borderColor,n?t.borderAlpha:(u=(d=(E=e==null?void 0:e.shape)==null?void 0:E.border)==null?void 0:d.alpha)!=null?u:t.borderAlpha),r.style.borderRadius=a},ji=({target:r,isDark:e,baseDimension:t,fallback:i})=>{let a=Fe(i.shadowColorLight,i.shadowColorAlpha),l=Fe(i.shadowColorDark,i.shadowColorAlpha),s=`calc(${t} * ${.25})`,c=`calc(${t} * ${.11})`,m=`0px 0px ${s} ${c} ${e?l:a}`;r.style.boxShadow=m},ge=({target:r,layoutParams:e,fallback:t})=>{var n;let i=(n=e.angle)!=null?n:t.angle;i=i&&i*-1,r.style.transform=`rotate(${i}rad)`};import{fromEvent as ze,Subject as Bu,Subscription as qu}from"@vkontakte/videoplayer-shared/es2018";var cr="interactive-control-tap",Ce={common:cr,animation:`${cr}-animation`,visible:`${cr}-visible`};var vl=60,bt=class{constructor({controlRotateAngleRad:e,clickCancelCondition:t,circleDiameterPx:i=vl,useDimensionsBasedSize:n=!1}){this.onElementClick=e=>{if(!e.target||!e.currentTarget||this.clickCancelCondition())return;let t=e.currentTarget.parentElement;if(!t)return;let i=t.getBoundingClientRect(),n={width:this.useDimensionsBasedSize?t.offsetWidth:this.circleDiameterPx,height:this.useDimensionsBasedSize?t.offsetHeight:this.circleDiameterPx},o=Math.min(n.width,n.height),a=i.left+i.width/2,l=i.top+i.height/2,s=e.clientX-a,c=e.clientY-l,m=bl(s,c,this.controlRotateAngleRad);this.element.style.width=o+"px",this.element.style.left=m.x+i.width/2-o/2+"px",this.element.style.top=m.y+i.height/2-o/2+"px",this.element.classList.add(Ce.visible,Ce.animation)};this.onAnimationEnd=e=>{e.stopPropagation(),!(!e.target||!e.currentTarget)&&e.target===e.currentTarget&&this.element.classList.remove(Ce.visible,Ce.animation)};let o=document.createElement("div");o.classList.add(Ce.common),this.controlRotateAngleRad=e,this.element=o,this.clickCancelCondition=t,this.circleDiameterPx=i,this.useDimensionsBasedSize=n}};function bl(r,e,t){return{x:r*Math.cos(t)-e*Math.sin(t),y:r*Math.sin(t)+e*Math.cos(t)}}var ur="int",ue=(i=>(i.AREA=`${ur}_area`,i.TEXT=`${ur}_text`,i.BUTTON=`${ur}_bttn`,i))(ue||{});function pr(r){return"features"in r}var X="interactive-control",O={common:X,selected:`${X}-selected`,wrapper:`${X}-wrapper`,disabled:`${X}-disabled`,button:`${X}-button`,area:`${X}-area`,text:`${X}-text`,blinkAnim:`${X}-blink-anim`,blinkAnimButton:`${X}-blink-anim-button`,blinkAnimArea:`${X}-blink-anim-area`},Bi=40;var Zo=ee(St(),1);import{isSupportedManifest as kt,ContainerTypes as $m,ControlTypes as Ot,EventActionTypes as R,EventTypes as _m,migrateManifestToLatestVersion as Yo,compareVersions as jm}from"@interactiveplatform/movika-manifest";var Qo={metadata:"Object",chapters:"Array"},Xo=r=>{if(!ae(r))return!1;for(let e in Qo)if(!r[e]||!oe(r[e],Qo[e]))return!1;return kt(r.metadata.version)},Rt=r=>r.type===Ot.Text,Rm=r=>r.type===Ot.Button,km=r=>r.type===Ot.Area,Om={Choice:"Choice",TextInput:"TextInput"},Pm={Button:"Button",Area:"Area",Text:"Text"},Lm={onClick:"onClick",onSuspense:"onSuspense"},Fm={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var Pt=r=>ht(r)&&!lr(r),Z=r=>r.order==="end",Lt=r=>ht(r.containers)&&!lr(r.containers)&&Z(r),Jo=(r,e)=>{var i;let t=r*1e3;return Pt(e.controls)&&t<((i=e.startTime)!=null?i:0)},Hr=(r,e)=>{var i,n;let t=r*1e3;return Pt(e.controls)&&t>=((i=e.startTime)!=null?i:0)&&t<=((n=e.endTime)!=null?n:1/0)};var he=(r=[])=>r.some(e=>e.action.type==="expect"),Ur=(r=[])=>r.find(e=>e.action.type==="expect"),ju=r=>(r==null?void 0:r.length)===1,we=r=>ju(r)&&Rt(r[0]);function ea(r=[],e=1/0,t=[]){return r.filter(({container:i})=>!(0,Zo.default)(t,i.container.id)&&he(i.container.events)&&i.container.endTime===e&&!i.isRemoved&&!i.willRemoved)}function Ft({gameControllers:r=[],subjectName:e,subjectId:t,execFn:i}){for(let n of r)if(e==="container"&&n.container.container.id===t){i(n),ea(r,n.container.container.endTime,[n.container.container.id]).forEach(a=>{i(a)});break}}function ta(r){for(let e of r.events)if(e.action.type==="openURI")return!0;return!1}var ra=(r,e)=>{let t=E=>{let d=e.find(({container:u})=>u.container.id===E);return d==null?void 0:d.container.isRemoved},i=he(r.events)&&!t(r.id),n=(E,d=!1,u=!1)=>{let p=u?"every":"some";return E.controls[p](b=>{var x;let I=d?E.endTime===r.endTime:!0;return((x=b.events)==null?void 0:x[p](g=>{var T;return((T=g.action)==null?void 0:T.type)===R.openURI}))&&I})},o=E=>E.some(({container:d})=>n(d.container,!0,!1)&&!d.isRemoved),a=E=>E.every(({container:d})=>d.isRemoved||d.willRemoved?!0:n(d.container,!0,!0)),l=ea(e,r.endTime,[r.id]).length,s=E=>E.controls.some(d=>{var u;return(u=d.events)==null?void 0:u.some(p=>{var b,I;return(I=(b=p.action)==null?void 0:b.args)==null?void 0:I.shouldOpenNow})}),c=i||l>0,m=o(e),f=n(r),v=a(e),y=i?!1:l>0,C=s(r);return{isExpectTime:c,hasOtherExpect:l>0,hasOpenURIEvent:m,hasOpenURIEventInCurrentContainer:f,isAllOpenURIEventsValid:v,isExpectEventForCurrentContainer:y,hasShouldOpenNowEvent:C}};var se=class r{constructor(e,t){this.control=e;this.options=t;this.container=null;this.controlElement=null;this.subscriptions=new qu;this.error$=new Bu;this.isInteracted=!1;this.isRemoved=!1;this.onControlSelect=()=>{var e,t,i;(e=this.container)!=null&&e.isManifestContainerDisabled()||ta(this.control)||(i=(t=this.container)==null?void 0:t.element)==null||i.classList.add("interactive-control-wrapper-selected")};this.onTransitionEnd=e=>{e.stopPropagation(),!(!e.target||!e.currentTarget)&&e.target===e.currentTarget&&this.removeView()}}removeView(e=!1){let t=this.getElement();if(t){if(e){if(t.classList.contains("interactive-control-before-remove"))return;t.classList.add("interactive-control-before-remove"),this.subscriptions.add(ze(t,"transitionend").subscribe(this.onTransitionEnd,n=>this.onError(`${r.name} remove view transition error`,n))).add(ze(t,"transitioncancel").subscribe(this.onTransitionEnd,n=>this.onError(`${r.name} remove view transition error`,n)));return}this.removeListeners(),t.remove(),this.isRemoved=!0}}onError(e="",t){ut({emitter$:this.error$,error:t,message:e,subjectId:this.control.id})}addControlTap(e){var t;if(this.featureIsEnabled("controlsTapPlace")&&this.container){let i=(t=this.control.layoutParams.angle)!=null?t:L.angle;this.controlTap=new bt({controlRotateAngleRad:i,clickCancelCondition:this.container.isManifestContainerDisabled,circleDiameterPx:this.isTouch()?Bi:void 0}),this.subscriptions.add(ze(e,"click").subscribe(this.controlTap.onElementClick,n=>this.onError("Control click tap animation error",n))).add(ze(this.controlTap.element,"animationend").subscribe(this.controlTap.onAnimationEnd,n=>this.onError("Tap animationend error",n))),this.container.element.append(this.controlTap.element)}}createContainerElement(e){var o;let t=document.createElement("div");t.classList.add(O.wrapper),e.setControlLayout(t,this.control.layoutParams);let i=((o=this.control.layoutParams.innerSizesDependOn)!=null?o:L.innerSizesDependOn)==="self"?{height:t.style.height,width:t.style.width}:{height:"var(--interactive-content-height)",width:"var(--interactive-content-width)"},n=()=>{var a,l;return(l=(a=e.isContainerDisabled)==null?void 0:a.call(e))!=null?l:!1};this.container={element:t,dimensions:i,isManifestContainerDisabled:n}}createClickListener(e){return t=>{t.stopPropagation(),this.isInteracted=!0,e()}}featureIsEnabled(e){return this.options&&pr(this.options)&&this.options.features[e]}isTouch(){return this.options&&pr(this.options)&&this.options.isTouch}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(ze(this.container.element,"click").subscribe(this.createClickListener(()=>e({action:t.action,controlId:this.control.id,controlType:this.control.type})),n=>this.onError("Error happened on control interaction",n)));break}default:break}})}removeListeners(){this.subscriptions.unsubscribe()}};var Gr="interactive-blink-anim-reference",$={common:Gr,animation:`${Gr}-animation`,disabled:`${Gr}-disabled`},Vt=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($.common,$.animation),this._element=e}restart(){this._element&&(this._element.classList.add($.disabled),this.cleanupRAF(),this._RAFId=requestAnimationFrame(()=>{this._element&&(this._element.classList.remove($.disabled),this.cleanupRAF())}))}cleanupRAF(){this._RAFId&&(cancelAnimationFrame(this._RAFId),this._RAFId=0)}destroy(){this.cleanupRAF(),this._element=void 0}};var zr="interactive-container",_={common:zr,hidden:`${zr}-hidden`,disabled:`${zr}-disabled`};var Mt=(r,e)=>{if(r.type.trim().toLowerCase()==="area")return new Wr(r,e)},Wr=class extends se{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){if(super.createContainerElement(t),!this.container)return;this.isInteracted=!1,this.isRemoved=!1;let i=document.createElement("button");i.type="button",i.classList.add(O.common,O.area),i.setAttribute("data-testid",ue.AREA),vt({target:i,props:this.control.props,fallback:{...L,backgroundColor:"transparent"}}),ge({target:i,layoutParams:this.control.layoutParams,fallback:L}),this.addControlTap(i),this.subscriptions.add(We(this.container.element,"click").pipe(ia()).subscribe(this.onControlSelect,n=>this.onError("Control click handler error",n))),this.container.element.append(i),e.append(this.container.element),this.controlElement=i,this.updateShadowStyles(),this.registerBlinkAnimationEvents()}registerBlinkAnimationEvents(){var t;if(!this.featureIsEnabled("controlsExpectTimeBlinkAnimation"))return;let e=(t=this.container)==null?void 0:t.element.parentElement;!e||!this.controlElement||(this.subscriptions.add(We(this.controlElement,"mouseleave").subscribe(()=>{if(e.classList.contains(_.disabled))return;let i=e.parentElement;if(i){let n=i.querySelector(`.${$.common}`);n&&this.syncBlinkAnimation(n)}},i=>this.onError("Error happened in mouseleave callback",i))),this.subscriptions.add(We(this.controlElement,"mouseenter").subscribe(()=>{e.classList.contains(_.disabled)||this.onBlinkHovering()},i=>this.onError("Error happened in mouseenter callback",i))).add(We(this.controlElement,"mouseleave").subscribe(()=>{this.controlElement&&(this.controlElement.style.animation="")},i=>this.onError("Error happened in mouseleave callback",i))))}disable(){this.controlElement&&this.controlElement.classList.add(O.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(O.disabled)}getElement(){return this.controlElement}updateShadowStyles(e){var t,i,n;if(!(!this.container||!this.controlElement))if(Vi(e)){let o=Math.min(this.controlElement.offsetWidth,this.controlElement.offsetHeight)+"px";ji({target:this.controlElement,props:this.control.props,fallback:L,isDark:e,baseDimension:o}),Ve({target:this.controlElement,props:this.control.props,fallback:{...L,borderColor:e?L.shadowColorDark:L.shadowColorLight,borderAlpha:1,borderWidthRawValue:"0.1px",roundCornersRawValue:`calc(${this.container.dimensions.height} * ${(n=(i=(t=this.control.props)==null?void 0:t.shape)==null?void 0:i.roundCorners)!=null?n:L.roundCorners})`},dependsOn:this.container.dimensions,useRawValues:!0})}else Ve({target:this.controlElement,props:this.control.props,fallback:{...L,borderAlpha:0},dependsOn:this.container.dimensions})}toggleBlinkAnimation(e){var t,i;(t=this.controlElement)==null||t.classList.toggle(O.blinkAnim,e),(i=this.controlElement)==null||i.classList.toggle(O.blinkAnimArea,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${O.blinkAnimArea}`)||this.controlElement.classList.contains(O.selected)||this.controlElement.classList.contains($.disabled)||(this.controlElement.classList.add($.disabled),this.subscriptions.add(We(e,"animationiteration").pipe(ia()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove($.disabled)},t=>this.onError("Error happened in animationiteration callback",t)))))}onBlinkHovering(){if(!this.controlElement||!this.controlElement.classList.contains(`${O.blinkAnimArea}`)||this.controlElement.classList.contains(O.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)})}setShowTimeRange(){}updateFillAnimationDimensions(){}onProgress(){}onResize(){}};import{fromEvent as Ke,once as pa}from"@vkontakte/videoplayer-shared/es2018";var Nt=r=>{let e=document.createElement("span");switch(r){case"Button":case"button":{let t=document.createElement("div"),i={overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center"};Object.assign(t.style,i),t.append(e);let n={display:"inline-block",whiteSpace:"pre",textOverflow:"ellipsis",maxWidth:"initial",maxHeight:"100%",wordBreak:"normal"};return Object.assign(e.style,n),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 $t=Math.PI,Kr=2*$t,_t=$t/2,na=3*_t,Du=0,Hu=[Du,_t,$t,na];function oa(r){return r===_t}function aa(r){return r===$t}function sa(r){return r===na}function la(r){return(r%Kr+Kr)%Kr}function Uu(r){for(let e of Hu)if(r===e)return e}function ca(r){if(Uu(r))return null;let t=Math.floor(r/_t)+1;return[1,2,3,4][t-1]}function ua(r){return r*180/Math.PI}var te="interactive-control-fill-animation",j={common:te,fillerWrapper:`${te}-filler-wrapper`,filler:`${te}-filler`,fillHeight:`${te}-fill-height`,fillWidth:`${te}-fill-width`,fromTop:`${te}-from-top`,fromBottom:`${te}-from-bottom`,fromLeft:`${te}-from-left`,fromRight:`${te}-from-right`};var jt=class r{constructor(e){this.widthExpansionCoef=0;var d;let t=document.createElement("div");t.classList.add(j.common);let i=document.createElement("div");i.classList.add(j.fillerWrapper);let n=document.createElement("div");n.classList.add(j.filler),i.append(n),t.append(i);let o=la(e.rotateAngle),a=ca(o),l=a!==null,c=a===2||!l&&aa(o)||a===3,m=!l&&oa(o),f=!l&&sa(o),v=!c&&!m&&!f,y=m||f,C=l&&!y,E=C?o:0;t.style.borderRadius=e.borderRadius,i.style.transform=`skew(${E*-1}rad)`,y?(n.classList.add(j.fillHeight,m?j.fromTop:j.fromBottom),i.classList.add(j.fillHeight,m?j.fromTop:j.fromBottom)):(n.classList.add(j.fillWidth,v?j.fromLeft:j.fromRight),i.classList.add(j.fillWidth)),e.debug&&console.log(`[interactive ${r.name}]`,{widthExpansionCoef:this.widthExpansionCoef,opts:e,shouldFillHeight:y,rotateAngleRad:o,rotateAngelDeg:ua(o),rotateAngleRaw:e.rotateAngle,fromRight:c,fromTop:m,fromBottom:f,fromLeft:v}),this.useSkew=C,this.fromLeft=v,this.rotateAngle=o,this.fillAnimationElement=t,this.fillAnimationFillerElement=n,this.fillAnimationFillerWrapperElement=i,this.startTime=e.startTime,this.endTime=e.endTime,this.shouldFillHeight=y,this.isDebug=(d=e.debug)!=null?d:!1}updateDimension(e){this.fillAnimationElement.style.top=`${e.borderWidth*-1}px`,this.fillAnimationElement.style.left=`${e.borderWidth*-1}px`,this.fillAnimationElement.style.width=`${e.width}px`,this.fillAnimationElement.style.height=`${e.height}px`;let t=this.calcWidthExpansionCoef({rotateAngle:this.rotateAngle,isSkewed:this.useSkew,initWidth:e.width,initHeight:e.height});!this.shouldFillHeight&&(this.fillAnimationFillerWrapperElement.style.width=100*t+100+"%",this.fillAnimationFillerWrapperElement.style[`${this.fromLeft?"left":"right"}`]=`calc((${t} * 100%) / 2 * -1)`),this.widthExpansionCoef=t}updateAnimation(e){if((o=>o<this.startTime||o>this.endTime)(e))return;let i=this.endTime-this.startTime,n=Math.min(Math.max((e-this.startTime)/i,0),1);this.shouldFillHeight?this.fillAnimationFillerElement.style.transform=`scaleY(${n})`:this.fillAnimationFillerElement.style.transform=`scaleX(${n})`}calcWidthExpansionCoef({rotateAngle:e,isSkewed:t=!1,initWidth:i,initHeight:n}){return t?(i+n*Math.abs(Math.tan(e)))/i-1:0}};var Bt=(r,e)=>{if(r.type.trim().toLowerCase()==="button")return new Qr(r,e)},Qr=class extends se{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){var a,l,s,c,m,f;if(super.createContainerElement(t),!this.container)return;this.isInteracted=!1,this.isRemoved=!1;let i=document.createElement("button");i.type="button",i.classList.add(O.common,O.button),i.setAttribute("data-testid",ue.BUTTON),ge({target:i,layoutParams:this.control.layoutParams,fallback:L}),vt({target:i,props:this.control.props,fallback:L}),Ve({target:i,props:this.control.props,fallback:L,dependsOn:this.container.dimensions}),mt({target:i,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let n=Nt(this.control.type.trim().toLowerCase()),o=(a=n.firstElementChild)!=null?a:n;ft({target:o,props:this.control.props,fallback:L,dependsOn:this.container.dimensions}),this.addControlTap(i),this.startTime!==void 0&&this.endTime!==void 0&&this.featureIsEnabled("controlsFillAnimation")&&(this.controlFillAnimation=new jt({startTime:this.startTime,endTime:this.endTime,rotateAngle:(l=this.control.layoutParams.angle)!=null?l:L.angle,borderRadius:i.style.borderRadius})),this.subscriptions.add(Ke(i,"click").pipe(pa()).subscribe(this.onControlSelect,v=>this.onError("Control click handler error",v))),i.append(n,(c=(s=this.controlFillAnimation)==null?void 0:s.fillAnimationElement)!=null?c:""),this.container.element.append((f=(m=this.controlTap)==null?void 0:m.element)!=null?f:"",i),e.append(this.container.element),this.controlElement=i,this.registerBlinkAnimationEvents()}registerBlinkAnimationEvents(){var t;if(!this.featureIsEnabled("controlsExpectTimeBlinkAnimation"))return;let e=(t=this.container)==null?void 0:t.element.parentElement;!e||!this.controlElement||(this.subscriptions.add(Ke(this.controlElement,"mouseleave").subscribe(()=>{if(e.classList.contains(_.disabled))return;let i=e.parentElement;if(i){let n=i.querySelector(`.${$.common}`);n&&this.syncBlinkAnimation(n)}},i=>this.onError("Error happened in mouseleave callback",i))),this.subscriptions.add(Ke(this.controlElement,"mouseenter").subscribe(()=>{e.classList.contains(_.disabled)||this.onBlinkHovering()},i=>this.onError("Error happened in mouseenter callback",i))).add(Ke(this.controlElement,"mouseleave").subscribe(()=>{this.controlElement&&(this.controlElement.style.animation="")},i=>this.onError("Error happened in mouseleave callback",i))))}disable(){this.controlElement&&this.controlElement.classList.add(O.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(O.disabled)}getElement(){return this.controlElement}toggleBlinkAnimation(e){var t,i;(t=this.controlElement)==null||t.classList.toggle(O.blinkAnim,e),(i=this.controlElement)==null||i.classList.toggle(O.blinkAnimButton,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${O.blinkAnimButton}`)||this.controlElement.classList.contains(O.selected)||this.controlElement.classList.contains($.disabled)||(this.controlElement.classList.add($.disabled),this.subscriptions.add(Ke(e,"animationiteration").pipe(pa()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove($.disabled)},t=>this.onError("Error happened in animationiteration callback",t)))))}onBlinkHovering(){if(!this.controlElement||!this.controlElement.classList.contains(`${O.blinkAnimButton}`)||this.controlElement.classList.contains(O.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)})}updateFillAnimationDimensions(){if(!this.container||!this.controlElement||!this.controlFillAnimation)return;let e=getComputedStyle(this.controlElement),t={width:parseFloat(e.width),height:parseFloat(e.height),borderWidth:parseFloat(e.borderWidth)||0};this.controlFillAnimation.updateDimension(t)}setShowTimeRange(e,t){this.startTime=e,this.endTime=t}onProgress(e){var t;(t=this.controlFillAnimation)==null||t.updateAnimation(e)}onResize(){this.updateFillAnimationDimensions()}updateShadowStyles(){}};var ha=(r,e)=>{if(r.type.trim().toLowerCase()==="text")return new Xr(r,e)},Xr=class extends se{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){var a;if(super.createContainerElement(t),!this.container)return;this.isInteracted=!1,this.isRemoved=!1;let i=document.createElement("div");i.classList.add(O.common,O.text),i.setAttribute("data-testid",ue.TEXT),ge({target:i,layoutParams:this.control.layoutParams,fallback:L}),mt({target:i,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let n=Nt(this.control.type.trim().toLowerCase()),o=(a=n.firstElementChild)!=null?a:n;ft({target:o,props:this.control.props,fallback:L,dependsOn:this.container.dimensions}),i.append(n),this.container.element.append(i),e.append(this.container.element),this.controlElement=i}getElement(){return this.controlElement}disable(){}enable(){}onProgress(){}onResize(){}updateShadowStyles(){}toggleBlinkAnimation(){}setShowTimeRange(){}updateFillAnimationDimensions(){}};var qt=(r,e,t)=>{if(r.type.trim().toLowerCase()==="choice")return new Yr(r,e,t)},Yr=class r extends ye{constructor(t,i,n){super(t,n);this.containerElement=null;this.subscriptions=new Gu;this.onTransitionEnd=t=>{t.stopPropagation(),!(!t.target||!t.currentTarget)&&t.target===t.currentTarget&&this.removeView()};this.rootElement=i,this.layout=new ct(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",Bt),this.addControlFactory("text",ha),this.addControlFactory("area",Mt)}createView({eventCallback:t,videoDurationMs:i}){let n=document.createElement("div");return n.classList.add(_.common,_.disabled),requestAnimationFrame(()=>{n.classList.remove(_.disabled)}),this.layout.setContainerLayout(n),this.controls.forEach(o=>{var a;o.setShowTimeRange(this.container.startTime,(a=this.container.endTime)!=null?a:i),o.createView({parentElement:n,callbacks:{setControlLayout:this.layout.setControlLayout,isContainerDisabled:()=>this.isDisabled}}),o.setEvents(t),this.subscriptions.add(o.error$.subscribe(this.error$))}),this.rootElement.append(n),this.isRemoved=!1,this.willRemoved=!1,this.containerElement=n,this.updateControlsFillAnimationDimensions(),n}updateControlsFillAnimationDimensions(){for(let t of this.controls)t.updateFillAnimationDimensions()}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(i=>i.enable()),this.isDisabled=!1)}disable(){let t=this.getElement();t&&(t.classList.add(_.disabled),this.controls.forEach(i=>i.disable()),this.isDisabled=!0)}removeView(t=!1,i=!1){let n=this.getElement();if(n){if(t){if(this.willRemoved)return;this.willRemoved=!0,i&&n.classList.add("interactive-container-before-remove-delay"),n.classList.add("interactive-container-before-remove"),this.subscriptions.add(da(n,"transitionend").subscribe(this.onTransitionEnd,a=>this.onError(`${r.name} remove view transition error`,a))).add(da(n,"transitioncancel").subscribe(this.onTransitionEnd,a=>this.onError(`${r.name} remove view transition error`,a)));return}this.subscriptions.unsubscribe(),this.removeAllControls(),n.remove(),this.isRemoved=!0,this.willRemoved=!1,this.containerElement=null}}removeAllControls(t=!1){this.controls.forEach(i=>i.removeView(t))}removeNonInteractedControls(t=!1){this.controls.forEach(i=>{i.isInteracted||i.removeView(t)})}isInteracted(){return this.controls.some(t=>t.isInteracted)}fakeRemove(){this.isRemoved||(this.isRemoved=!0)}getElement(){return this.containerElement}onProgress(t,i){i&&this.controls.forEach(n=>{n.onProgress(t)})}onResize(t){t&&this.controls.forEach(i=>{i.onResize()})}updateControlsShadowStyles(t){this.controls.forEach(i=>i.updateShadowStyles(t))}toggleBlinkAnimation(t){this.controls.forEach(i=>i.toggleBlinkAnimation(t))}};var sl=ee(Zr(),1);import{combine as jh,InterfaceLanguage as Bh,Observable as nl,once as qh,Subject as B,Subscription as gi,ValueSubject as D,fromEvent as ol}from"@vkontakte/videoplayer-shared/es2018";import{InteractiveInterfaceClick as st}from"@vkontakte/videoplayer-statistics/es2018";import{loadVKLangPack as ep}from"@vkontakte/videoplayer-shared/es2018";function Qe(r,e){let t;return(...i)=>{clearTimeout(t),t=setTimeout(()=>r(...i),e)}}var Ca="video_interactive",Ea="videoint";var Ta=250,Xe=class{constructor(e){this.handleZoomChange=Qe(e=>{this.lastZoomInfo=e},Ta);this.onResize=e=>{var i;if(!this.isReady||this.isHidden||!e[0].contentRect.width||!e[0].contentRect.height)return;let t=this.getNextPoint();t&&((i=this.ngEditor)==null||i.zoomTo(t,void 0,{isFromCenter:!0})),this.ngEditorSize={width:e[0].contentRect.width,height:e[0].contentRect.height}};this.handleChapterChange=e=>{var t,i,n;if(this.manifest){if(this.isHidden||this.hide(),!(e!=null&&e.id)){(t=this.onError)==null||t.call(this,"Chapter id is not found");return}this.visitedChapterIds.add(e.id),(i=this.ngEditor)==null||i.selectChapter(e.id),(n=this.ngEditor)==null||n.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId=e.id,this.lastZoomInfo=null}};this.handleManifestChange=(e,t=[])=>{var i;if(this.isReady=!1,!dt(e.graph.edit.chapters[0].x)){(i=this.onError)==null||i.call(this,"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:i,lang:n,visitedChapters:o=[]}){this.isReady=!1,this.isHidden=!0,this.manifest=null,this.visitedChapterIds=new Set(o),this.onOpenPreviewClick=t,this.onError=i,this.lang=n!=null?n:"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(Qe(this.onResize,Ta)),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){var t;this.visitedChapterIds=new Set([...this.visitedChapterIds,...e]),(t=this.ngEditor)==null||t.setVisitedChapters(Array.from(this.visitedChapterIds))}updateVideosInfo(e){var t;(t=this.ngEditor)==null||t.updateVideosInfo(e)}async show(){var e;this.manifest&&(this.ngEditor||await this.initNgEditor(),this.graphWrapperElement.style.display="block",!this.lastZoomInfo&&this.currentChapterId&&((e=this.ngEditor)==null||e.focusChapter(this.currentChapterId)),this.isHidden=!1)}async initNgEditor(){var i;if(!this.manifest)return;let e;try{e=await ep(this.lang,Ca,Ea)}catch(n){(i=this.onError)==null||i.call(this,"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,...o})=>{var a;n==="openPreview"&&"chapterId"in o&&((a=this.onOpenPreviewClick)==null||a.call(this,o.chapterId))}),this.ngEditor.on("zoom",this.handleZoomChange),this.isReady=!0}hide(){this.graphWrapperElement.style.display="none",this.isHidden=!0}destroy(){var e,t;this.hide(),this.manifest=null,this.resizeObserver.disconnect(),(e=this.ngEditor)==null||e.setVisitedChapters([]),this.onOpenPreviewClick=void 0,(t=this.ngEditor)==null||t.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 Ye=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,i=!1,n=Math.round(this._player.info.position$.getValue()*1e3);for(let o of this._containers){let a=o.startTime-e;if(a<=n&&(o.endTime&&n<=o.endTime||o.endTime===null)){i=!0;break}n<a&&(t=t===-1?a:Math.min(t,a))}return!i&&t!==-1?t:null}}};var Dt=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 i=()=>{t(),this.off(e,i)};return this.listeners[e].push(i),this}off(e,t){return this.removeListener(e,t)}reset(){this.listeners={}}removeListener(e,t){let i=this.listeners[e]||[];for(let n=i.length;n>0;n--)if(i[n]===t){i.splice(n,1);break}return this}emit(e,...t){let i=this.listeners[e];return i?(i.forEach(n=>{n(...t)}),!0):!1}listenerCount(e){return this.rawListeners(e).length}rawListeners(e){return this.listeners[e]||[]}};var Ht=class{constructor(e){this.fns=[];this.addFn=(e,t=!1)=>{Fi(e)&&(this.fns.push(e),t&&this.updateFn())};this.removeFn=(e,t=!1)=>{this.fns=this.fns.filter(i=>i!==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=[]}};import{ValueSubject as lp}from"@vkontakte/videoplayer-shared/es2018";var Ut=class{constructor(e){var t,i;this.loaders={chapterLoaders:(t=e==null?void 0:e.chapterLoaders)!=null?t:[],manifestLoaders:(i=e==null?void 0:e.manifestLoaders)!=null?i:[]}}async exec(e,t){return rp(...this.loaders[e])(t)}};function rp(...r){return async function(t){let i=[...r];for(;i.length>0;)t=await i.shift()(t);return t}}function Ze(r,e,t){return r?{...r,[e]:r[e]?[t,...r[e]]:[t]}:{[e]:[t]}}function Gt({actions:r,errors:e,chapterId:t,...i}){if(t){let n=r.getManifest();if(n){let o=r.getChapter(n.chapters,t);if(o){let a=r.getMedia(n.media,o.videoId),l=r.getGraph(n.graph,o.id);return a?{...i,actions:r,errors:e,result:{chapter:o,media:a,graph:l}}:{...i,errors:Ze(e,Gt.name,"Could not find media"),actions:r}}}}return{...i,errors:Ze(e,Gt.name,"Could not find chapter"),actions:r}}var zt=class{constructor(){Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}addEventListener(e,t,i){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:t,options:i})}removeEventListener(e,t){if(!(e in this.listeners))return;let i=this.listeners[e];for(let n=0,o=i.length;n<o;n++)if(i[n].callback===t){i.splice(n,1);return}}dispatchEvent(e){if(!(e.type in this.listeners))return;let i=this.listeners[e.type].slice();for(let n=0,o=i.length;n<o;n++){let a=i[n];try{a.callback.call(this,e)}catch(l){Promise.resolve().then(()=>{throw l})}a.options&&a.options.once&&this.removeEventListener(e.type,a.callback)}return!e.defaultPrevented}},Se=class extends zt{constructor(){super(),this.listeners||zt.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)}},Je=class{constructor(){Object.defineProperty(this,"signal",{value:new Se,writable:!0,configurable:!0})}abort(e){let t;try{t=new Event("abort")}catch(n){typeof document!="undefined"?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 i=e;if(i===void 0)if(typeof document=="undefined")i=new Error("This operation was aborted"),i.name="AbortError";else try{i=new DOMException("signal is aborted without reason")}catch(n){i=new Error("This operation was aborted"),i.name="AbortError"}this.signal.reason=i,this.signal.dispatchEvent(t)}toString(){return"[object AbortController]"}};typeof Symbol!="undefined"&&Symbol.toStringTag&&(Je.prototype[Symbol.toStringTag]="AbortController",Se.prototype[Symbol.toStringTag]="AbortSignal");function Wt(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 Jr(r){typeof r=="function"&&(r={fetch:r});let{fetch:e,Request:t=e.Request,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n=!1}=r;if(!Wt({fetch:e,Request:t,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n}))return{fetch:e,Request:o};let o=t;(o&&!o.prototype.hasOwnProperty("signal")||n)&&(o=function(c,m){let f;m&&m.signal&&(f=m.signal,delete m.signal);let v=new t(c,m);return f&&Object.defineProperty(v,"signal",{writable:!1,enumerable:!1,configurable:!0,value:f}),v},o.prototype=t.prototype);let a=e;return{fetch:(s,c)=>{let m=o&&o.prototype.isPrototypeOf(s)?s.signal:c?c.signal:void 0;if(m){let f;try{f=new DOMException("Aborted","AbortError")}catch(y){f=new Error("Aborted"),f.name="AbortError"}if(m.aborted)return Promise.reject(f);let v=new Promise((y,C)=>{m.addEventListener("abort",()=>C(f),{once:!0})});return c&&c.signal&&delete c.signal,Promise.race([v,a(s,c)])}return a(s,c)},Request:o}}var ip=()=>"fetch"in window,et=ip()&&Wt({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),Ia=et?Jr({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,ei=et?Ia.fetch:window.fetch,Rv=et?Ia.Request:window.Request,kv=et?Je:window.AbortController,Ov=et?Se:window.AbortSignal;var ti=(r="",e="")=>{let t=r.split("."),i=e.split("."),n=0;for(let o=0;o<Math.max(t.length,i.length)&&!n;o++)t[o]>i[o]?n=1:t[o]<i[o]?n=-1:n=0;return n};var np=async r=>{try{let e={},t;if(pt(r)){t=new URL(r).href;let n=await ei(t);if(!n.ok)return{};e=await n.json()}else if(ae(r))e=r;else return{};if(!Xo(e))return{};let i=e.metadata.media;if(pt(i)&&!("media"in e))try{let n;t?n=new URL(i,t).href:(n=new URL(i).href,t=n);let o=await ei(n);if(!o.ok)throw new Error;e.metadata.media=await o.json()}catch(n){return sp(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch(e){return{}}};async function xa(r){let{manifest:e,manifestURL:t}=await np(r);if(!e)throw new Error("Failed on fetch");let i=Yo(e);return i.media=op(i.media,t),delete i.metadata.media,i}function Kt(r,e){if(e)return r.find(t=>t.id===e)}function ri(r,e){var t,i;return(t=r.edit)!=null&&t.chapters?r.edit.chapters.find(n=>n.id===e):(i=r.view)!=null&&i.chapters?r.view.chapters.find(n=>n.id===e):void 0}function ii(r,e){return r.videos.find(t=>t.id===e)}function op(r,e){return{...r,videos:r.videos.map(t=>({...t,variants:t.variants.map(i=>{let n="url"in i?i.url:"",o=ap(n,e);return{...i,url:o||n}})}))}}function ap(r="",e){try{return new URL(r,e).href}catch(t){return""}}function sp(r){return ti(r,"3.2.0")>=0}var Re=class extends Ut{constructor(t,i){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new lp(null);this.onError=i,this.release()}release(){return this.manifest=null,this.chapter=null,this.media=null,this.graph=null,this.prevChapter$.next(null),this}async setManifest(t){var n;this.release();let i=await this.exec("manifestLoaders",{actions:{addErrorMessage:Ze},result:null,errors:null,source:t});return i.errors&&this.errorHandler(i.errors),this.manifest=await xa((n=i.result)!=null?n:t),this}async setInitial(){return this.setNext()}async setNext(t=(i=>(i=this.manifest)==null?void 0:i.metadata.initChapterId)()){if(!t)return this;this.prevChapter$.next(this.chapter);let n=await this.exec("chapterLoaders",Gt({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:ri,getChapter:Kt,getMedia:ii,getByBranches:this.getByBranches.bind(this),addErrorMessage:Ze},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(){var i;return this.getByChapterId((i=this.manifest)==null?void 0:i.metadata.initChapterId)||null}getByChapterId(t=(i=>(i=this.manifest)==null?void 0:i.metadata.initChapterId)()){if(!t||!this.manifest)return null;let n=Kt(this.manifest.chapters,t);if(n){let o=ii(this.manifest.media,n.videoId),a=ri(this.manifest.graph,n.id);if(o)return{chapter:n,media:o,graph:a}}return null}getBranches(t=(i=>(i=this.chapter)==null?void 0:i.id)()){var n,o,a;if(t===((n=this.chapter)==null?void 0:n.id))return this.getByBranches((o=this.chapter)==null?void 0:o.branches);{let l=Kt(((a=this.manifest)==null?void 0:a.chapters)||[],t);return this.getByBranches(l==null?void 0:l.branches)}}getByBranches(t=[]){return t.reduce((i,n)=>{let o=this.getByChapterId(n.chapterId);return o&&i.push(o),i},[])}getCurrent(){return{chapter:this.chapter,media:this.media,graph:this.graph}}isInitialChapter(){var t,i;return((t=this.chapter)==null?void 0:t.id)===((i=this.manifest)==null?void 0:i.metadata.initChapterId)}isEndChapter(){return this.chapter?Z(this.chapter):!1}};var rs=ee(Qt(),1);import{Player as Np}from"@vkontakte/videoplayer-core/es2018";import{Subscription as li,TracerFactory as $p,ValueSubject as _p}from"@vkontakte/videoplayer-shared/es2018";var es=r=>{let e=r.variants.find(t=>{var i;return((i=t.payload)==null?void 0:i.type)==="vk"});if(e&&e.payload){let[t,i]=e.payload.id.split("_");return[t,i]}return[]};var ts=ee(Qt(),1);function ai(){let r=new Map;function e({listId:o=Math.random().toString(),itemId:a=Math.random().toString(),...l}){let s=r.get(o),c={...l};return s?s[a]=c:r.set(o,{[a]:c}),{listId:o,itemId:a,...l}}function t(o){var a,l;o.player.destroy(),o.container.remove(),o.subscription.unsubscribe(),(a=o.statistics)==null||a.oneStat.destroy(),(l=o.statistics)==null||l.statSubscription.unsubscribe()}function i(o,a){let l=r.get(o);if(!l)throw Error("Can't remove. Not find.");if(a){let s=l[a];s&&t(s),delete l[a],Object.keys(l).length||r.delete(o)}else{for(let s of(0,ts.default)(l))t(s);r.delete(o)}}function n(){for(let o of r)i(o[0])}return{createPlayer:e,removePlayer:i,map:r,removeAll:n}}var ke=ee(St(),1);function si(r,e=[]){var o,a,l;let t={},i,n=!e.length;for(let s of r.variants)if(!i&&"cover"in s&&(i=s.cover),"url"in s)switch(s.type.toLowerCase()){case"mp4":(n||(0,ke.default)(e,"mp4"))&&(t.MPEG={...t.MPEG,[(o=s.standard)!=null?o:"Invariant quality"]:s.url});break;case"mpeg":(n||(0,ke.default)(e,"mpeg"))&&(t.MPEG={...t.MPEG,[(a=s.standard)!=null?a:"Invariant quality"]:s.url});break;case"hls":(n||(0,ke.default)(e,"hls"))&&(t={...t,HLS:{type:"url",url:s.url}});break;case"dash":(n||(0,ke.default)(e,"dash"))&&(t={...t,DASH_SEP:{compatibilityMode:!0,type:"url",url:s.url}});break;default:break}return{sources:t,thumbUrl:i,title:(l=r.title)!=null?l:""}}var tt=(r,e)=>{let t=r.info.currentQuality$.getValue(),i=r.info.availableQualities$.getValue();t!==e&&(0,ke.default)(i,e)&&(r.setQuality(e),r.setAutoQuality(!1))};var jp=2;function ci(r){let e=ai(),t=new li,i={},n=null,o=!1,a,l=new _p(null);r&&s(r);function s(d){n=d}function c(d,u,p){var x;if(!n)throw Error("need to set interactive controller");if(!n.options)return;let I=((x=e.map.get(d))!=null?x:{})[u];if(I){i={chapterId:p,listId:d,itemId:u,...I};let g=i.player;i.subscription.add(g.info.currentQuality$.subscribe(T=>{let F=g.info.position$.getValue(),A=g.info.isAutoQualityEnabled$.getValue();if(!(!T||!F||A))for(let k of e.map)(0,rs.default)(k[1]).forEach(({player:P})=>{tt(P,T)})})).add(g.events.started$.subscribe(()=>{m(u)})),I.container.remove(),n.setPlayer(I.player),o||(n.init(),o=!0),l.next({player:i.player,config:i.config,statistics:i.statistics});return}throw Error("Can't set. Not find.")}async function m(d){if(!n)throw Error("need to set interactive controller");if(ce(i)||d!==i.itemId)return;let u=n.getChapterBranches(),p=new Set;for(let b of u)p.has(b.media.id)||(await v({media:b.media,chapterId:b.chapter.id,setAsActive:!1,title:b.chapter.label}),p.add(b.media.id))}async function f({chapter:{id:d},manifestVideo:u}){if(ce(i)||!n)return;let p=i.player.info.muted$.getValue(),b=i.player.info.currentQuality$.getValue(),I=i.player.info.isAutoQualityEnabled$.getValue(),x=i.player.info.volume$.getValue(),g=i.player.info.currentPlaybackRate$.getValue(),T=!I,F=!1;for(let A of e.map)if(A[0]===u.id&&!n.state.isReplay$.getValue()){let k=Object.keys(A[1]);for(let P of k)P===i.itemId?(k.length<jp||(F=!0),e.removePlayer(A[0],P)):(F=!0,c(A[0],P,d),T?tt(i.player,b):i.player.setAutoQuality(!0),i.player.setVolume(x),i.player.setMuted(p),i.player.setPlaybackRate(g))}else e.removePlayer(A[0]);F||(await v({media:u,chapterId:d,setAsActive:!0,playbackRate:g}),T?tt(i.player,b):i.player.setAutoQuality(!0),i.player.setVolume(x),i.player.setMuted(p))}async function v({media:d,chapterId:u,prefetch:p=!0,setAsActive:b=!0,autoplay:I=!1,preferredExt:x,title:g,playbackRate:T}){var Ei,Ti,Ii,xi,Ai;let F=Math.random().toString(),A=document.createElement("div");a.append(A);let k;if((Ei=n==null?void 0:n.options)!=null&&Ei.vkVideoLoader){let lt=es(d);lt.length&&(k=await n.options.vkVideoLoader(...lt))}let P=((Ti=n==null?void 0:n.options)==null?void 0:Ti.coreConfig)||void 0,Q={...P,configName:[...(Ii=P==null?void 0:P.configName)!=null?Ii:[],"interactive"]},le={container:A,...((xi=k==null?void 0:k.videos)==null?void 0:xi[0])||{sources:si(d,x).sources},title:g,failoverHosts:(k==null?void 0:k.failoverHosts)||[]},q=new Np(Q,$p.createRootTracer());q.initVideo(le);let ve=null;if(k!=null&&k.videos&&(n!=null&&n.options.createOneStat)){let lt=k.videos[0],ir=n.options.createOneStat(lt),wi=new li;ir&&(wi.add(ir.attachTo(q)),ve={oneStat:ir,statSubscription:wi})}let Ci=new li,ll=(Ai=i==null?void 0:i.player)==null?void 0:Ai.info.isAutoQualityEnabled$.getValue();Ci.add(q.events.canplay$.subscribe(function(){ll||tt(q,i.player.info.currentQuality$.getValue()),T&&q.setPlaybackRate(T)}));let be=e.createPlayer({listId:d.id,itemId:F,player:q,container:A,sources:si(d,x).sources,config:le,subscription:Ci,statistics:ve});return b&&c(d.id,be.itemId,u),I&&be.player.play(),p&&!I&&be.player.prepare(),{player:be.player,config:be.config,statistics:be.statistics}}function y(){C(),n=null,a.remove()}function C(){t.unsubscribe(),e.removeAll(),i={},o=!1}async function E(){if(!n)throw Error("need to set interactive controller");C(),a=document.createElement("div");let{media:d,chapter:u}=n.getCurrentChapter();d&&u?(t.add(n.events.chapterChanged$.subscribe(f)),await v({media:d,chapterId:u.id,title:u.label})):console.error("not found")}return{...e,init:E,setInteractiveController:s,createPlayer:v,removeAll:y,getActivePlayer:function(){return i},activePlayerChanged:l}}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"},rt={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},V={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};import{Subscription as Bp}from"@vkontakte/videoplayer-shared/es2018";function ui(r){return function(...t){return r(...t.reverse())}}function it(r,...e){return(...t)=>ae(e[0])&&ae(t[0])?r({...e[0],...t[0]}):r(...e,...t)}var Xt=class{constructor({player:e,container:t,branches:i,selectBranches:n,interactiveEvents:o,globalEvents:a,globalEventEmitter:l,getContainerEventState:s,permanentTextControls:c,interactiveTimeOpenUri:m,disabledControls$:f,onRemove:v,onError:y,disableTextControlContainerVisibilityEvents:C=!1,features:E}){this.hide=()=>{setTimeout(()=>{var e,t;this.gameState!==4&&(he(this.container.container.events)&&this.gameState===3||this.selectBranches.state.isExpect||(this.gameState!==2&&((t=(e=this.container).hide)==null||t.call(e)),this.emitContainerVisibilityEvent(!1)))})};this.show=()=>{var t,i,n,o,a,l;if(this.gameState!==2||this.isSelectedControlEvent)return;if(this.container.getElement()){let{hasOpenURIEventInCurrentContainer:s}=this.getContainerEventState();if((i=(t=this.container).show)==null||i.call(t),this.interactiveTimeOpenUri&&s||this.disableTextControlContainerVisibilityEvents)return;this.emitContainerVisibilityEvent(!0,!1)}else{let s={isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.emitContainerVisibilityEvent(!1)},onEvent:(f,v)=>{let{isExpectTime:y,hasOtherExpect:C,hasOpenURIEvent:E,hasOpenURIEventInCurrentContainer:d,isAllOpenURIEventsValid:u,hasShouldOpenNowEvent:p}=this.getContainerEventState(),b=this.interactiveTimeOpenUri&&!d,I=this.interactiveTimeOpenUri&&d;if((!this.interactiveTimeOpenUri||b)&&(this.isSelectedControlEvent=!0),f!==!1){if(!this.selectBranches.state.isExpect&&(!this.interactiveTimeOpenUri||b)){if(this.interactiveTimeOpenUri){let x=!C&&!u&&d;x&&this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:x})}this.removeView()}this.emitContainerVisibilityEvent(!1)}if(this.gameState===4||this.gameState===3||this.selectBranches.state.isExpect||this.interactiveTimeOpenUri&&E&&this.gameState!==5){if(I){let g=((T,F,A,k)=>!T&&!F&&A||T&&!F&&A&&!k||T&&!F&&A&&k)(y,C,u,this.isSelectedContainerEvent);this.fakeRemoveView(g)}else this.removeView(),this.emitContainerVisibilityEvent(!1);(!y||!C||!p)&&(this.selectBranches.stopExpect(),v())}},isEOV:()=>this.gameState===4},c=it(this.selectBranches.onControlEvent,s),m=((o=(n=this.player)==null?void 0:n.info.duration$.getValue())!=null?o:1/0)*1e3;this.container.createView({eventCallback:c,videoDurationMs:m}),this.disableTextControlContainerVisibilityEvents||this.emitContainerVisibilityEvent(!0,!0),this.disabledControls$.getValue()&&((l=(a=this.container).disable)==null||l.call(a))}};this.onEndOfVideo=()=>{this.gameState=4,this.selectContainerEvent(!0)};this.whilePlaying=()=>{var s,c,m;let e=this.player.experimental.element$.getValue();if(!(e instanceof HTMLVideoElement?e.readyState:void 0)||this.isRemovedOrDestroyed()&&!this.isPermanentText)return;let n=this.player.getExactTime();if(Jo(n,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(Hr(n,this.container.container))this.gameState!==2&&(this.gameState=2,this.onStartTime());else if(this.gameState!==3){let f=this.gameState;this.gameState=3,f===2&&this.onEndTime()}else{let{hasOpenURIEventInCurrentContainer:f}=this.getContainerEventState(),v=this.selectBranches.state.isExpect,y=this.interactiveTimeOpenUri&&f;if(y&&!v){let C=this.container.getElement();C&&(C.style.visibility!=="hidden"&&((c=(s=this.container).hide)==null||c.call(s)),this.container.isRemoved||this.fakeRemoveView())}!this.isPermanentText&&!y&&this.removeView()}let o=Hr(n,this.container.container),a=this.container.container.startTime?[this.container.container.startTime,(m=this.container.container.endTime)!=null?m:1/0]:[],l={subjectId:this.container.container.id,subjectName:"container",range:a,currentTime:n,isInteractiveTime:o};this.container.onProgress(n*1e3,o),this.globalEventEmitter.emit(S.eachTick,l),this.globalEvents.eachTick$.next(l)};this.container=t,this.branches=i,this.selectBranches=n,this.subscription=new Bp,this.player=e,this.interactiveEvents=o,this.getContainerEventState=s;let d=we(t.container.controls);this.isPermanentText=c&&d,this.disableTextControlContainerVisibilityEvents=C&&d,this.interactiveTimeOpenUri=m,this.disabledControls$=f,this.onRemove=v,this.globalEventEmitter=l,this.gameState=0,this.globalEvents=a,this.onError=y,this.features=E,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=>{var t,i,n,o;e?(i=(t=this.container).disable)==null||i.call(t):(o=(n=this.container).enable)==null||o.call(n)})),this.subscription.add(this.container.error$.subscribe(this.onError))}selectContainerEvent(e=!1){var i,n;let{isExpectEventForCurrentContainer:t}=this.getContainerEventState();this.interactiveEvents.containersEventsCallState.setCalled({timestamp:e?1/0:(i=this.container.container.endTime)!=null?i: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((n=this.container.container.endTime)!=null?n:1/0))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);let{isExpectTime:e,hasOpenURIEventInCurrentContainer:t}=this.getContainerEventState(),i=this.interactiveTimeOpenUri?e||t:he(this.container.container.events)||e;(this.isSelectedControlEvent||!i)&&this.removeView()}onBeforeStartTime(){var e,t;(t=(e=this.container).hide)==null||t.call(e),this.emitContainerVisibilityEvent(!1)}onResize(e){this.container.onResize(e)}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=1}removeView(e=this.features.controlsHideAnimation){var t;if(e){if(this.isRemovedOrDestroyed())return;this.container.removeNonInteractedControls(!0),this.container.removeView(!0,!0)}else 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,(t=this.onRemove)==null||t.call(this)}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)}isInteracted(){return this.container.isInteracted()}isRemovedOrDestroyed(e=!0){let t=e?this.container.willRemoved:!1;return this.gameState===5||t||this.gameState===6}destroy(e=!1){var t;this.reset(),this.removeView(e),this.gameState=6,this.subscription.unsubscribe(),this.branches=[],this.interactiveEvents.containersEventsCallState.setCalled({timestamp:(t=this.container.container.endTime)!=null?t:1/0,id:this.container.container.id})}};var ns=(r=[])=>r.reduce((e,t,i)=>{var o,a,l;let n=((o=t==null?void 0:t.controls)!=null?o:[]).filter(s=>!Rt(s));if(Pt(n)){let s=[(a=t.startTime)!=null?a:0,(l=t.endTime)!=null?l:1/0],c={id:t.id,isRemoved:!1};if(!i)e.push({subjects:[c],range:s});else{let m=[],f=-1/0,v=1/0,y=[],C=[];for(let E=0;E<e.length;E++){let d=e[E];if(C.push(...d.subjects),d.range[0]<v&&(v=d.range[0]),d.range[1]>f&&(f=d.range[1]),s[0]>=d.range[0]&&s[1]<=d.range[1])return e[E].subjects.push(c),e;s[0]<d.range[0]&&s[1]>d.range[0]&&(m.push(E),y=y.concat(d.subjects)),s[0]>=d.range[0]&&s[0]<=d.range[1]&&(m.push(E),y=y.concat(d.subjects),s[0]=d.range[0]),s[1]>=d.range[0]&&s[1]<=d.range[1]&&(m.push(E),y=y.concat(d.subjects),s[1]=d.range[1])}if(C.push(c),s[0]<=v&&s[1]>=f)return[{subjects:C,range:s}];m.length&&m.reverse().forEach(E=>{e.splice(E,1)}),e.push({subjects:y.concat([c]),range:s})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);var js=ee(St(),1),mi=ee(Qt(),1),Bs=ee($s(),1);function _s(){let r={};function e(){for(let l in r)Object.prototype.hasOwnProperty.call(r,l)&&delete r[l]}function t(l){let s={};for(let c in r)+c<=l&&(s[c]=r[c]);return s}function i(l){let s={};for(let c in r)+c>=l&&(s[c]=r[c]);return s}function n({timestamp:l,priority:s,initiator:c}){var m;if(sr(l)){let f=(m=r[l])!=null?m:null;if(f&&s&&Le(s,!0)){let v={},y=f[s];if(y&&(v={...v,...y}),v=ce(v)?null:v,v&&Le(c,!0)){let C=v[c];return C!=null?C:null}return v}return f}return null}function o({timestamp:l,priority:s,initiator:c}){if(sr(l))if(r[l]){if(s&&Le(s,!0))if(r[l][s]){if(c&&Le(c,!0))if(r[l][s][c]){if(delete r[l][s][c],!ce(r[l][s]))return!0}else return!1;if(delete r[l][s],!ce(r[l]))return!0}else return!1;return delete r[l]}else return!1;return!1}function a({timestamp:l,priority:s,initiator:c,...m}){var f,v,y;(v=(f=r[l])==null?void 0:f[s])!=null&&v[c]?r[l][s][c].push({...m}):(y=r[l])!=null&&y[s]?r[l][s]={...r[l][s],[c]:[{...m}]}:r[l]?r[l]={...r[l],[s]:{[c]:[{...m}]}}:r[l]={[s]:{[c]:[{...m}]}}}return{map:r,remove:o,add:a,removeAll:e,get:n,getLte:t,getGte:i}}var Rh=[R.expect,R.setNextBranch],kh=1/0;function qs(r,e){let t=r,i,n=Oh(e),o=_s(),a,l=()=>{y(),u()},s=p=>{o.add.call(void 0,p),C()},c=(p=[])=>{for(let b of p)if(b.action(),(0,js.default)(Rh,b.actionType))break},m=(p=1/0)=>{var g,T,F;let b=Zt((g=o.get({timestamp:p,priority:"control"}))!=null?g:{}),I=Zt((T=o.get({timestamp:p,priority:"container"}))!=null?T:{}),x=Zt((F=o.get({timestamp:p,priority:"chapter"}))!=null?F:{});return[...b,...I,...x]},f=p=>{n.isReady(p)&&c(m(p))},v=()=>{var p;c([...Zt((p=o.get({timestamp:1/0,priority:"chapter"}))!=null?p:{})])},y=()=>{i&&(a==null||a.unsubscribe(),i=void 0)},C=()=>{i||(i=()=>setTimeout(()=>{f(1/0)}),a=t.events.ended$.subscribe(i))},E=p=>{y(),t=p},d=p=>{p.priority==="container"&&n.resetCalled(p.timestamp),o.remove(p)},u=()=>{n.release(),o.removeAll()};return{setPlayer:E,add:s,remove:d,exec:f,execEndOfVideo:v,listen:C,unlisten:y,release:l,containersEventsCallState:n,getPreparedToExecActions:m}}function Oh(r){let e=new Map;return{setCalled:({timestamp:l,id:s})=>{let c=e.get(l);c&&c[s]!==void 0&&(c[s]=!0)},setData:(l=[])=>{var s;for(let c of l){let m=(s=c.endTime)!=null?s:kh,f=e.get(m);e.set(m,{...f,[c.id]:!1})}},resetCalled:l=>{let s=e.get(l);if(s)for(let c in s)s[c]=!1},isReady:l=>{let s=e.get(l);if(!s)return!0;let c=(0,mi.default)(s);return r?c.some(f=>f):!c.some(f=>!f)},release:()=>e.clear()}}function Zt(r){return(0,Bs.default)((0,mi.default)(r)).sort(e=>e.actionType===R.expect?-1:1)}var Ds={videoContentHeight:0,videoContentWidth:0},Hs=r=>{let{height:e,width:t}=r.info.intrinsicVideoSize$.getValue()||{};if(!(e&&t))return Ds;let{clientHeight:i,clientWidth:n}=r.experimental.element$.getValue()||{};if(!(i&&n))return Ds;let o=e/t,a=i/n,l,s;return a>o?(s=n,l=n*o):a<o?(s=i/o,l=i):(s=n,l=i),{videoContentWidth:s,videoContentHeight:l}};var Ph=250;function Us(r){let e,t=new ResizeObserver(l=>{o(l),e=o.bind(null,l)});function i(l){let{parentElement:s,player:c}=r();if(s&&c){let{videoContentWidth:m,videoContentHeight:f}=Hs(c);s.style.setProperty("--interactive-content-width",`${m}px`),s.style.setProperty("--interactive-content-height",`${f}px`),s.style.setProperty("--interactive-width",`${l[0].contentRect.width}px`),s.style.setProperty("--interactive-height",`${l[0].contentRect.height}px`)}}function n(){let{parentElement:l}=r();l.removeAttribute("style")}let o=Qe(l=>{let{fns:s=[]}=r();i(l);for(let c of s)c()},Ph);function a(){e=void 0,t.disconnect(),n()}return{resizeObserver:t,calc:()=>{e==null||e()},release:a}}var Lh=r=>Math.floor(Math.random()*r),zs=r=>{var n;let e=r.length,t=1/0,i=null;for(;e--;){let o=r[e],a=(n=o.weight)!=null?n:1;a<t&&(t=a,i=o)}return i},Ws=r=>{var n;let e=r.length,t=-1/0,i=null;for(;e--;){let o=r[e],a=(n=o.weight)!=null?n:0;a>t&&(t=a,i=o)}return i};var Ks=r=>{let e=r.length,t=Lh(e);return r[t]},Gs=1,Qs=r=>{var i,n;let e=0;for(let o=0;o<r.length;++o)e+=(i=r[o].weight)!=null?i:Gs;let t=Math.random()*e;e=0;for(let o=0;o<r.length-1;++o)if(e+=(n=r[o].weight)!=null?n:Gs,e>=t)return r[o];return r[r.length-1]};var Xs={shouldOpenNow:!0,isDetachContainer:!0},Ys="after-expect",fi=(r,e=!1)=>({...r,args:e?{...r.args,...Xs}:{...Xs,...r.args}}),Zs=({globalEventEmitter:r,globalEvents:e,player:t,interactiveEvents:i})=>{let n={isExpect:!1},o=()=>{n.isExpect&&(n.isExpect=!1)},a=({action:u,controlType:p,controlId:b,containerId:I,branches:x=[],onEvent:g,isEOV:T=()=>!1,isDisabled:F=()=>!1})=>{let A=fi(u,T()),k={timestamp:1/0,priority:"control",initiator:b,actionType:A.type},P=F(),Q=r.emit.bind(r,S.interactives,{subjectId:b,subjectType:p,subjectName:"control",type:P?V.actionChoiceCanceled:V.actionChoice,actionType:u.type,payload:{invokeImmediately:A.args.shouldOpenNow,containerId:I,...A.args}}),le=()=>{e.interactiveActionChoice$.next({subjectId:b,subjectType:p,subjectName:"control",type:P?"action-choice-canceled":"action-choice",actionType:u.type,payload:{invokeImmediately:A.args.shouldOpenNow,containerId:I,...A.args}})};if(P){Q(),le();return}switch(A.type.trim().toLowerCase()){case R.setNextBranch.trim().toLowerCase():{let q=x.find(ve=>ve.id===A.args.branchId);if(!q)return;g(A.args.isDetachContainer,y.bind(null,{subjectId:b,subjectName:"control"})),Q(),le(),A.args.shouldOpenNow?E({subjectId:b,subjectName:"control",subjectType:p,action:A,payload:{chapterId:q.chapterId,autoSelect:!1}}):i.add({...k,action:E.bind(null,{subjectId:b,subjectName:"control",subjectType:p,action:A,payload:{chapterId:q.chapterId,autoSelect:!1}})});return}case R.continuePlayback.trim().toLowerCase():{g(A.args.isDetachContainer,y.bind(null,{subjectId:b,subjectName:"control"})),Q(),le(),A.args.shouldOpenNow?C({subjectId:b,subjectName:"control",subjectType:p,action:u}):i.add({...k,action:C.bind(null,{subjectId:b,subjectName:"control",subjectType:p,action:u})});return}case R.openURI.trim().toLowerCase():{g(A.args.isDetachContainer,y.bind(null,{subjectId:b,subjectName:"control"})),Q(),le(),A.args.shouldOpenNow?d({subjectId:b,subjectName:"control",subjectType:p,action:A,payload:{URI:u.args.uri}}):i.add({...k,action:d.bind(null,{subjectId:b,subjectName:"control",subjectType:p,action:A,payload:{URI:u.args.uri}})});return}default:{let q="Unexpected control event",ve=new N(1,1,{message:q});m(ve,q);return}}},l=({action:u,container:{id:p,endTime:b},branches:I=[],isEOV:x=!1,autoSelected:g=!1})=>{let T=fi(u,x),F={timestamp:!T.args.shouldOpenNow||x?1/0:b!=null?b:1/0,priority:"container",initiator:p,actionType:T.type},A=r.emit.bind(r,S.interactives,{subjectId:p,subjectName:"container",type:V.actionChoice,actionType:T.type,payload:{invokeImmediately:T.args.shouldOpenNow,...T.args}}),k=()=>{e.interactiveActionChoice$.next({subjectId:p,subjectName:"container",type:"action-choice",actionType:T.type,payload:{invokeImmediately:T.args.shouldOpenNow,...T.args}})};switch(T.type.trim().toLowerCase()){case R.setNextBranch.trim().toLowerCase():{let P=I.find(Q=>Q.id===T.args.branchId);if(!P)return;A(),k(),i.add({...F,action:E.bind(null,{subjectId:p,subjectName:"container",action:T,payload:{chapterId:P.chapterId,autoSelect:g}})});return}case R.setMaxWeightBranch.trim().toLowerCase():return;case R.setMinWeightBranch.trim().toLowerCase():return;case R.setRandomBranch.trim().toLowerCase():return;case R.setWeightlessRandomBranch.trim().toLowerCase():return;case R.continuePlayback.trim().toLowerCase():{A(),k(),i.add({...F,action:C.bind(null,{subjectId:p,subjectName:"container",action:T})});return}case R.openURI.trim().toLowerCase():{A(),k(),i.add({...F,action:d.bind(null,{subjectId:p,subjectName:"container",action:T,payload:{URI:u.args.uri}})});return}default:{let P="Unexpected container event",Q=new N(1,1,{message:P});m(Q,P);return}}};function s({container:u,branches:p,isEOV:b=!1}){var x,g;let I=Ur(u.events);if(I){let T=fi(I.action,b);r.emit(S.interactives,{subjectId:u.id,subjectName:"container",type:V.actionChoice,actionType:T.type,payload:{invokeImmediately:T.args.shouldOpenNow,...T.args}}),e.interactiveActionChoice$.next({subjectId:u.id,subjectName:"container",type:"action-choice",actionType:T.type,payload:{invokeImmediately:T.args.shouldOpenNow,...T.args}}),i.add({timestamp:b?1/0:(x=u.endTime)!=null?x:1/0,priority:"container",initiator:u.id,actionType:R.expect,action:v.bind(null,{subjectId:u.id,subjectName:"container"})}),n.isExpect=!0}else for(let T of(g=u.events)!=null?g:[])l({action:T.action,container:u,branches:p,isEOV:b})}let c=({chapterId:u,action:p,branches:b=[]})=>{let I=r.emit.bind(r,S.interactives,{subjectId:u,subjectName:"chapter",type:V.actionChoice,actionType:p.type,payload:p.args}),x=()=>{e.interactiveActionChoice$.next({subjectId:u,subjectName:"chapter",type:"action-choice",actionType:p.type,payload:p.args})};switch(p.type.trim().toLowerCase()){case R.setNextBranch.trim().toLowerCase():{let g=b.find(T=>T.id===p.args.branchId);return g!=null&&g.chapterId?(I(),x(),E.bind(null,{subjectId:u,subjectName:"chapter",action:p,payload:{chapterId:g.chapterId,autoSelect:!0}})):void 0}case R.setWeightlessRandomBranch.trim().toLowerCase():{let g=Ks(b);return g!=null&&g.chapterId?(I(),x(),E.bind(null,{subjectId:u,subjectName:"chapter",action:p,payload:{chapterId:g.chapterId,autoSelect:!0}})):void 0}case R.setRandomBranch.trim().toLowerCase():{let g=Qs(b);return g!=null&&g.chapterId?(I(),x(),E.bind(null,{subjectId:u,subjectName:"chapter",action:p,payload:{chapterId:g.chapterId,autoSelect:!0}})):void 0}case R.setMaxWeightBranch.trim().toLowerCase():{let g=Ws(b);return g!=null&&g.chapterId?(I(),x(),E.bind(null,{subjectId:u,subjectName:"chapter",action:p,payload:{chapterId:g.chapterId,autoSelect:!0}})):void 0}case R.setMinWeightBranch.trim().toLowerCase():{let g=zs(b);return g!=null&&g.chapterId?(I(),x(),E.bind(null,{subjectId:u,subjectName:"chapter",action:p,payload:{chapterId:g.chapterId,autoSelect:!0}})):void 0}case R.continuePlayback.trim().toLowerCase():return I(),x(),C.bind(null,{subjectId:u,subjectName:"chapter",action:p});case R.openURI.trim().toLowerCase():return I(),x(),d.bind(null,{subjectId:u,subjectName:"chapter",action:p,payload:{URI:p.args.uri}});default:{let g="Unexpected chapter event",T=new N(1,1,{message:g});m(T,g);return}}};function m(u,p){console.error(p),e.error$.next(u),r.emit(S.errors,u)}function f(u){var b;let p=Ur(u.events);if(p){if(Z(u))return;r.emit(S.interactives,{subjectId:u.id,subjectName:"chapter",type:V.actionChoice,actionType:p.action.type,payload:p.action.args}),e.interactiveActionChoice$.next({subjectId:u.id,subjectName:"chapter",type:"action-choice",actionType:p.action.type,payload:p.action.args}),i.add({timestamp:1/0,priority:"chapter",initiator:u.id,actionType:R.expect,action:v.bind(null,{subjectId:u.id,subjectName:"chapter"})})}else(b=u.events)==null||b.forEach(I=>{let x=c({chapterId:u.id,action:I.action,branches:u.branches});x&&i.add({timestamp:1/0,priority:"chapter",initiator:u.id,actionType:I.action.type,action:x})})}let v=({subjectId:u,subjectName:p})=>{t.pause(),r.emit(S.interactives,{subjectId:u,subjectName:p,type:V.actionExecution,actionType:R.expect}),e.interactiveActionExecution$.next({subjectId:u,subjectName:p,type:"action-execution",actionType:R.expect})},y=({subjectId:u,subjectName:p})=>{t.info.isEnded$.getValue()?i.execEndOfVideo():t.play(),r.emit(S.interactives,{subjectId:u,subjectName:p,type:V.actionExecution,actionType:Ys}),e.interactiveActionExecution$.next({subjectId:u,subjectName:p,type:"action-execution",actionType:Ys})},C=({subjectId:u,subjectName:p,subjectType:b,action:I})=>{r.emit(S.interactives,{subjectId:u,subjectName:p,subjectType:b,type:V.actionExecution,actionType:I.type}),e.interactiveActionExecution$.next({subjectId:u,subjectName:p,subjectType:b,type:"action-execution",actionType:I.type})},E=({subjectId:u,subjectName:p,subjectType:b,action:I,payload:x})=>{x.behaviour="change-chapter",r.emit(S.interactives,{subjectId:u,subjectName:p,subjectType:b,type:V.actionExecution,actionType:I.type,payload:x}),e.interactiveActionExecution$.next({subjectId:u,subjectName:p,subjectType:b,type:"action-execution",actionType:I.type,payload:x})},d=({subjectId:u,subjectName:p,subjectType:b,action:I,payload:x})=>{if(!x.URI)return;let g=window.open(x.URI,"_blank","noopener,noreferrer");g&&(g.opener=null),r.emit(S.interactives,{subjectId:u,subjectName:p,subjectType:b,type:V.actionExecution,actionType:I.type}),e.interactiveActionExecution$.next({subjectId:u,subjectName:p,subjectType:b,type:"action-execution",actionType:I.type})};return{onControlEvent:a,onContainerEvent:l,onChapterEvent:c,onExpectEvent:v,expectEventHandler:y,setManifestChapterEvents:f,setManifestContainerEvents:s,stopExpect:o,state:n}};var yi=ee(Zr(),1);import{Subscription as $h,Subject as bi,ValueSubject as ot}from"@vkontakte/videoplayer-shared/es2018";var vi=(r,e)=>{let t={};return r.map(i=>{if(!t[i]){let n=e.chapters.find(a=>a.id===i);if(!n)return null;let o=e.media.videos.find(a=>n.videoId===a.id);if(!o)return null;t[i]=Js(o)}return t[i]}).filter(Boolean)},Vh=r=>{for(let e of r.variants)if(Mh(e)&&e.payload)return e.payload.id},Mh=r=>!!(r.type==="custom"&&r.payload&&r.payload.type==="vk"),Js=r=>{let e=Vh(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},Nh=(r,e)=>{for(let t of r.media.videos)if(e===Js(t)){for(let i of r.chapters)if(i.videoId===t.id)return i.id;return}},el=(r,e)=>r.reduce((t,i)=>{let n=Nh(e,i);return n?[...t,n]:t},[]);var re,de,me,z,Jt,ie,ne,J,fe,Oe,Pe,at=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:i,historyApi:n,settings:o}){this.state={history$:new ot([]),hasPrevChapter$:new ot(!1),prevChapter$:new ot(null),isInitialChapter$:new ot(!1),isGoBackLimited$:new ot(!1)};H(this,re,null);H(this,de);H(this,me,!1);H(this,z,null);H(this,Jt,null);this.events={inited$:new bi,destroyed$:new bi,error$:new bi};H(this,ie,null);H(this,ne,null);H(this,J,null);H(this,fe,new $h);H(this,Oe,!1);H(this,Pe,0);var a;M(this,ie,t),M(this,J,e),M(this,ne,i),M(this,re,n),M(this,de,o),this.state.history$&&w(this,fe)&&((a=w(this,fe))==null||a.add(this.state.history$.subscribe(l=>{var s,c;this.state.prevChapter$.next((0,yi.default)(l,-2)||null),this.state.hasPrevChapter$.next(l.length>1),this.state.isInitialChapter$.next(this.getInitialChapterId()===((c=(s=w(this,z))==null?void 0:s.metadata)==null?void 0:c.initChapterId)),this.state.isGoBackLimited$.next(w(this,Pe)===w(this,de).maxLength-1)})))}async setManifest(e){if(!w(this,ne)||!w(this,J))return;M(this,z,e),await this.getProjectHistory();let t=this.getInitialChapterId();await w(this,ne).setChapter({chapterId:t,pushToHistory:!1}),w(this,me)||(M(this,me,!0),this.events.inited$.next({initChapterId:t}))}get inited(){return w(this,me)}async updateHistory(e,t=!0){var l;if(!w(this,z))return;w(this,Oe)?(M(this,Oe,!1),Oi(this,Pe)._++):M(this,Pe,0);let i=w(this,z),n=e.length-w(this,de).maxLength,o=n>0?e.slice(n):e,a=vi(o,i);if(M(this,Jt,a),this.state.history$.next(o),!(!t||!w(this,re)||!w(this,ie)))try{await w(this,re).save(w(this,ie),a)}catch(s){let c=new N(1,5,"Unable to save interactive history");this.events.error$.next(c),(l=w(this,J))==null||l.emit(S.errors,c)}}async goBack(){var i;if(!this.state||!w(this,ne)){let n=new N(1,5,"Unable to save interactive history");return this.events.error$.next(n),(i=w(this,J))==null?void 0:i.emit(S.errors,n)}M(this,Oe,!0);let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),await w(this,ne).setChapter({chapterId:t,playPrev:!0})}async getProjectHistory(){var n;if(!w(this,z)||!w(this,ie))return;let e=w(this,z),t=[this.getInitialVideoId()];if(w(this,re))try{let o=await w(this,re).get(w(this,ie));o.length&&(t=o)}catch(o){let a=new N(1,5,"Error while trying to fetch data");this.events.error$.next(a),(n=w(this,J))==null||n.emit(S.errors,a)}let i=el(t,e);this.state.history$.next(i)}getInitialChapterId(){var t;let e=this.state.history$.getValue();return(0,yi.default)(e,-1)||w(this,de).initChapterId||((t=w(this,z))==null?void 0:t.metadata.initChapterId)}getInitialVideoId(){if(w(this,z)){let e=this.getInitialChapterId();return vi([e],w(this,z)).pop()}return null}destroy(){var e,t;M(this,ie,null),M(this,re,null),M(this,ne,null),(e=w(this,fe))==null||e.unsubscribe(),M(this,fe,null),M(this,me,!1),(t=w(this,J))==null||t.emit(S.historyDestroyed),this.events.destroyed$.next(),M(this,J,null)}};re=new WeakMap,de=new WeakMap,me=new WeakMap,z=new WeakMap,Jt=new WeakMap,ie=new WeakMap,ne=new WeakMap,J=new WeakMap,fe=new WeakMap,Oe=new WeakMap,Pe=new WeakMap;var er=class{constructor(){this._prevSizeId=0;this.rootElement=document.createElement("canvas")}clear(){var e;(e=this.rootElement.getContext("2d"))==null||e.clearRect(0,0,this.rootElement.width,this.rootElement.height)}isImageDrawn(){var n;let e=(n=this.rootElement.getContext("2d"))==null?void 0:n.getImageData(0,0,this.rootElement.width,this.rootElement.height);if(!e)return!1;let t=e.data,i=t.length;for(let o=3;o<i;o+=40)if(t[o]!==0)return!0;return!1}destroy(){this.rootElement.remove()}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}setCanvasImageSource(e){this.canvasImgSrc=e}draw(){var e;this.canvasImgSrc&&((e=this.rootElement.getContext("2d"))==null||e.drawImage(this.canvasImgSrc,0,0,this.rootElement.width,this.rootElement.height))}async updateCanvasDimensions(e,t=!1){let i=e.width+e.height;if(this._prevSizeId===i)return;let n;t&&(n=await this.save()),this.rootElement.width=e.width,this.rootElement.height=e.height,t&&n&&this.restore(n),this._prevSizeId=i}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){var t;this.rootElement&&((t=this.rootElement.getContext("2d"))==null||t.drawImage(e,0,0,this.rootElement.width,this.rootElement.height))}};var tr=class{constructor({parentElement:e,endOffsetMs:t=250,onError:i}){this.currentVideoDurationMs=1/0;this._containerTimeFrameShouldReceived=!1;this._endTimeFrameReceived=!1;this._shouldCallSkip=!1;this.onEachTick=e=>{let t=e!=null?e:this.lastFrameCanvas.canvasImgSrc.currentTime*1e3,i=this.isChapterEndTime(t);if(this.isContainerTime(t))this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!0,this._shouldCallSkip=!0;else if(i)this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1,this._endTimeFrameReceived||(this.draw(),this._endTimeFrameReceived=!0,this.show());else{if(this._shouldCallSkip){this._shouldCallSkip=!1;return}this.reset()}};this.onSeek=()=>{this.onEachTick(),!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived&&(this.hide(),this.lastFrameCanvas.clear())};this.rootElement=document.createElement("div"),this.rootElement.style.cssText=`
|
|
6
|
+
var cl=Object.create;var Si=Object.defineProperty;var ul=Object.getOwnPropertyDescriptor;var pl=Object.getOwnPropertyNames;var hl=Object.getPrototypeOf,dl=Object.prototype.hasOwnProperty;var Ri=r=>{throw TypeError(r)};var h=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var ml=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of pl(e))!dl.call(r,n)&&n!==t&&Si(r,n,{get:()=>e[n],enumerable:!(i=ul(e,n))||i.enumerable});return r};var ee=(r,e,t)=>(t=r!=null?cl(hl(r)):{},ml(e||!r||!r.__esModule?Si(t,"default",{value:r,enumerable:!0}):t,r));var ki=(r,e,t)=>e.has(r)||Ri("Cannot "+t);var w=(r,e,t)=>(ki(r,e,"read from private field"),t?t.call(r):e.get(r)),H=(r,e,t)=>e.has(r)?Ri("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),M=(r,e,t,i)=>(ki(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t);var Oi=(r,e,t,i)=>({set _(n){M(r,e,n,t)},get _(){return w(r,e,i)}});var Y=h((hr,qi)=>{"use strict";var Me=function(r){return r&&r.Math===Math&&r};qi.exports=Me(typeof globalThis=="object"&&globalThis)||Me(typeof window=="object"&&window)||Me(typeof self=="object"&&self)||Me(typeof global=="object"&&global)||Me(typeof hr=="object"&&hr)||function(){return this}()||Function("return this")()});var U=h((yd,Di)=>{"use strict";Di.exports=function(r){try{return!!r()}catch(e){return!0}}});var Ne=h((gd,Hi)=>{"use strict";var yl=U();Hi.exports=!yl(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var Ki=h((Cd,Wi)=>{"use strict";var gl=Ne(),zi=Function.prototype,Ui=zi.apply,Gi=zi.call;Wi.exports=typeof Reflect=="object"&&Reflect.apply||(gl?Gi.bind(Ui):function(){return Gi.apply(Ui,arguments)})});var W=h((Ed,Yi)=>{"use strict";var Qi=Ne(),Xi=Function.prototype,dr=Xi.call,Cl=Qi&&Xi.bind.bind(dr,dr);Yi.exports=Qi?Cl:function(r){return function(){return dr.apply(r,arguments)}}});var $e=h((Td,Ji)=>{"use strict";var Zi=W(),El=Zi({}.toString),Tl=Zi("".slice);Ji.exports=function(r){return Tl(El(r),8,-1)}});var mr=h((Id,en)=>{"use strict";var Il=$e(),xl=W();en.exports=function(r){if(Il(r)==="Function")return xl(r)}});var G=h((xd,tn)=>{"use strict";var fr=typeof document=="object"&&document.all;tn.exports=typeof fr=="undefined"&&fr!==void 0?function(r){return typeof r=="function"||r===fr}:function(r){return typeof r=="function"}});var pe=h((Ad,rn)=>{"use strict";var Al=U();rn.exports=!Al(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var gt=h((wd,nn)=>{"use strict";var wl=Ne(),yt=Function.prototype.call;nn.exports=wl?yt.bind(yt):function(){return yt.apply(yt,arguments)}});var vr=h(sn=>{"use strict";var on={}.propertyIsEnumerable,an=Object.getOwnPropertyDescriptor,Sl=an&&!on.call({1:2},1);sn.f=Sl?function(e){var t=an(this,e);return!!t&&t.enumerable}:on});var br=h((Rd,ln)=>{"use strict";ln.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var un=h((kd,cn)=>{"use strict";var Rl=W(),kl=U(),Ol=$e(),yr=Object,Pl=Rl("".split);cn.exports=kl(function(){return!yr("z").propertyIsEnumerable(0)})?function(r){return Ol(r)==="String"?Pl(r,""):yr(r)}:yr});var gr=h((Od,pn)=>{"use strict";pn.exports=function(r){return r==null}});var Cr=h((Pd,hn)=>{"use strict";var Ll=gr(),Fl=TypeError;hn.exports=function(r){if(Ll(r))throw new Fl("Can't call method on "+r);return r}});var _e=h((Ld,dn)=>{"use strict";var Vl=un(),Ml=Cr();dn.exports=function(r){return Vl(Ml(r))}});var Ee=h((Fd,mn)=>{"use strict";var Nl=G();mn.exports=function(r){return typeof r=="object"?r!==null:Nl(r)}});var Ct=h((Vd,fn)=>{"use strict";fn.exports={}});var Et=h((Md,bn)=>{"use strict";var Er=Ct(),Tr=Y(),$l=G(),vn=function(r){return $l(r)?r:void 0};bn.exports=function(r,e){return arguments.length<2?vn(Er[r])||vn(Tr[r]):Er[r]&&Er[r][e]||Tr[r]&&Tr[r][e]}});var gn=h((Nd,yn)=>{"use strict";var _l=W();yn.exports=_l({}.isPrototypeOf)});var In=h(($d,Tn)=>{"use strict";var jl=Y(),Cn=jl.navigator,En=Cn&&Cn.userAgent;Tn.exports=En?String(En):""});var On=h((_d,kn)=>{"use strict";var Rn=Y(),Ir=In(),xn=Rn.process,An=Rn.Deno,wn=xn&&xn.versions||An&&An.version,Sn=wn&&wn.v8,K,Tt;Sn&&(K=Sn.split("."),Tt=K[0]>0&&K[0]<4?1:+(K[0]+K[1]));!Tt&&Ir&&(K=Ir.match(/Edge\/(\d+)/),(!K||K[1]>=74)&&(K=Ir.match(/Chrome\/(\d+)/),K&&(Tt=+K[1])));kn.exports=Tt});var xr=h((jd,Ln)=>{"use strict";var Pn=On(),Bl=U(),ql=Y(),Dl=ql.String;Ln.exports=!!Object.getOwnPropertySymbols&&!Bl(function(){var r=Symbol("symbol detection");return!Dl(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&Pn&&Pn<41})});var Ar=h((Bd,Fn)=>{"use strict";var Hl=xr();Fn.exports=Hl&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var wr=h((qd,Vn)=>{"use strict";var Ul=Et(),Gl=G(),zl=gn(),Wl=Ar(),Kl=Object;Vn.exports=Wl?function(r){return typeof r=="symbol"}:function(r){var e=Ul("Symbol");return Gl(e)&&zl(e.prototype,Kl(r))}});var Nn=h((Dd,Mn)=>{"use strict";var Ql=String;Mn.exports=function(r){try{return Ql(r)}catch(e){return"Object"}}});var Sr=h((Hd,$n)=>{"use strict";var Xl=G(),Yl=Nn(),Zl=TypeError;$n.exports=function(r){if(Xl(r))return r;throw new Zl(Yl(r)+" is not a function")}});var jn=h((Ud,_n)=>{"use strict";var Jl=Sr(),ec=gr();_n.exports=function(r,e){var t=r[e];return ec(t)?void 0:Jl(t)}});var qn=h((Gd,Bn)=>{"use strict";var Rr=gt(),kr=G(),Or=Ee(),tc=TypeError;Bn.exports=function(r,e){var t,i;if(e==="string"&&kr(t=r.toString)&&!Or(i=Rr(t,r))||kr(t=r.valueOf)&&!Or(i=Rr(t,r))||e!=="string"&&kr(t=r.toString)&&!Or(i=Rr(t,r)))return i;throw new tc("Can't convert object to primitive value")}});var Hn=h((zd,Dn)=>{"use strict";Dn.exports=!0});var zn=h((Wd,Gn)=>{"use strict";var Un=Y(),rc=Object.defineProperty;Gn.exports=function(r,e){try{rc(Un,r,{value:e,configurable:!0,writable:!0})}catch(t){Un[r]=e}return e}});var It=h((Kd,Qn)=>{"use strict";var ic=Hn(),nc=Y(),oc=zn(),Wn="__core-js_shared__",Kn=Qn.exports=nc[Wn]||oc(Wn,{});(Kn.versions||(Kn.versions=[])).push({version:"3.38.0",mode:ic?"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 Pr=h((Qd,Yn)=>{"use strict";var Xn=It();Yn.exports=function(r,e){return Xn[r]||(Xn[r]=e||{})}});var je=h((Xd,Zn)=>{"use strict";var ac=Cr(),sc=Object;Zn.exports=function(r){return sc(ac(r))}});var Te=h((Yd,Jn)=>{"use strict";var lc=W(),cc=je(),uc=lc({}.hasOwnProperty);Jn.exports=Object.hasOwn||function(e,t){return uc(cc(e),t)}});var Lr=h((Zd,eo)=>{"use strict";var pc=W(),hc=0,dc=Math.random(),mc=pc(1 .toString);eo.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+mc(++hc+dc,36)}});var Be=h((Jd,ro)=>{"use strict";var fc=Y(),vc=Pr(),to=Te(),bc=Lr(),yc=xr(),gc=Ar(),Ie=fc.Symbol,Fr=vc("wks"),Cc=gc?Ie.for||Ie:Ie&&Ie.withoutSetter||bc;ro.exports=function(r){return to(Fr,r)||(Fr[r]=yc&&to(Ie,r)?Ie[r]:Cc("Symbol."+r)),Fr[r]}});var ao=h((em,oo)=>{"use strict";var Ec=gt(),io=Ee(),no=wr(),Tc=jn(),Ic=qn(),xc=Be(),Ac=TypeError,wc=xc("toPrimitive");oo.exports=function(r,e){if(!io(r)||no(r))return r;var t=Tc(r,wc),i;if(t){if(e===void 0&&(e="default"),i=Ec(t,r,e),!io(i)||no(i))return i;throw new Ac("Can't convert object to primitive value")}return e===void 0&&(e="number"),Ic(r,e)}});var Vr=h((tm,so)=>{"use strict";var Sc=ao(),Rc=wr();so.exports=function(r){var e=Sc(r,"string");return Rc(e)?e:e+""}});var uo=h((rm,co)=>{"use strict";var kc=Y(),lo=Ee(),Mr=kc.document,Oc=lo(Mr)&&lo(Mr.createElement);co.exports=function(r){return Oc?Mr.createElement(r):{}}});var Nr=h((im,po)=>{"use strict";var Pc=pe(),Lc=U(),Fc=uo();po.exports=!Pc&&!Lc(function(){return Object.defineProperty(Fc("div"),"a",{get:function(){return 7}}).a!==7})});var fo=h(mo=>{"use strict";var Vc=pe(),Mc=gt(),Nc=vr(),$c=br(),_c=_e(),jc=Vr(),Bc=Te(),qc=Nr(),ho=Object.getOwnPropertyDescriptor;mo.f=Vc?ho:function(e,t){if(e=_c(e),t=jc(t),qc)try{return ho(e,t)}catch(i){}if(Bc(e,t))return $c(!Mc(Nc.f,e,t),e[t])}});var bo=h((om,vo)=>{"use strict";var Dc=U(),Hc=G(),Uc=/#|\.prototype\./,qe=function(r,e){var t=zc[Gc(r)];return t===Kc?!0:t===Wc?!1:Hc(e)?Dc(e):!!e},Gc=qe.normalize=function(r){return String(r).replace(Uc,".").toLowerCase()},zc=qe.data={},Wc=qe.NATIVE="N",Kc=qe.POLYFILL="P";vo.exports=qe});var $r=h((am,go)=>{"use strict";var yo=mr(),Qc=Sr(),Xc=Ne(),Yc=yo(yo.bind);go.exports=function(r,e){return Qc(r),e===void 0?r:Xc?Yc(r,e):function(){return r.apply(e,arguments)}}});var Eo=h((sm,Co)=>{"use strict";var Zc=pe(),Jc=U();Co.exports=Zc&&Jc(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var Io=h((lm,To)=>{"use strict";var eu=Ee(),tu=String,ru=TypeError;To.exports=function(r){if(eu(r))return r;throw new ru(tu(r)+" is not an object")}});var wo=h(Ao=>{"use strict";var iu=pe(),nu=Nr(),ou=Eo(),xt=Io(),xo=Vr(),au=TypeError,_r=Object.defineProperty,su=Object.getOwnPropertyDescriptor,jr="enumerable",Br="configurable",qr="writable";Ao.f=iu?ou?function(e,t,i){if(xt(e),t=xo(t),xt(i),typeof e=="function"&&t==="prototype"&&"value"in i&&qr in i&&!i[qr]){var n=su(e,t);n&&n[qr]&&(e[t]=i.value,i={configurable:Br in i?i[Br]:n[Br],enumerable:jr in i?i[jr]:n[jr],writable:!1})}return _r(e,t,i)}:_r:function(e,t,i){if(xt(e),t=xo(t),xt(i),nu)try{return _r(e,t,i)}catch(n){}if("get"in i||"set"in i)throw new au("Accessors not supported");return"value"in i&&(e[t]=i.value),e}});var Ro=h((um,So)=>{"use strict";var lu=pe(),cu=wo(),uu=br();So.exports=lu?function(r,e,t){return cu.f(r,e,uu(1,t))}:function(r,e,t){return r[e]=t,r}});var He=h((pm,Oo)=>{"use strict";var De=Y(),pu=Ki(),hu=mr(),du=G(),mu=fo().f,fu=bo(),xe=Ct(),vu=$r(),Ae=Ro(),ko=Te();It();var bu=function(r){var e=function(t,i,n){if(this instanceof e){switch(arguments.length){case 0:return new r;case 1:return new r(t);case 2:return new r(t,i)}return new r(t,i,n)}return pu(r,this,arguments)};return e.prototype=r.prototype,e};Oo.exports=function(r,e){var t=r.target,i=r.global,n=r.stat,o=r.proto,a=i?De:n?De[t]:De[t]&&De[t].prototype,l=i?xe:xe[t]||Ae(xe,t,{})[t],s=l.prototype,c,m,f,v,y,C,E,d,u;for(v in e)c=fu(i?v:t+(n?".":"#")+v,r.forced),m=!c&&a&&ko(a,v),C=l[v],m&&(r.dontCallGetSet?(u=mu(a,v),E=u&&u.value):E=a[v]),y=m&&E?E:e[v],!(!c&&!o&&typeof C==typeof y)&&(r.bind&&m?d=vu(y,De):r.wrap&&m?d=bu(y):o&&du(y)?d=hu(y):d=y,(r.sham||y&&y.sham||C&&C.sham)&&Ae(d,"sham",!0),Ae(l,v,d),o&&(f=t+"Prototype",ko(xe,f)||Ae(xe,f,{}),Ae(xe[f],v,y),r.real&&s&&(c||!s[v])&&Ae(s,v,y)))}});var Lo=h((hm,Po)=>{"use strict";var yu=Math.ceil,gu=Math.floor;Po.exports=Math.trunc||function(e){var t=+e;return(t>0?gu:yu)(t)}});var Ue=h((dm,Fo)=>{"use strict";var Cu=Lo();Fo.exports=function(r){var e=+r;return e!==e||e===0?0:Cu(e)}});var Mo=h((mm,Vo)=>{"use strict";var Eu=Ue(),Tu=Math.max,Iu=Math.min;Vo.exports=function(r,e){var t=Eu(r);return t<0?Tu(t+e,0):Iu(t,e)}});var $o=h((fm,No)=>{"use strict";var xu=Ue(),Au=Math.min;No.exports=function(r){var e=xu(r);return e>0?Au(e,9007199254740991):0}});var Ge=h((vm,_o)=>{"use strict";var wu=$o();_o.exports=function(r){return wu(r.length)}});var Dr=h((bm,Bo)=>{"use strict";var Su=_e(),Ru=Mo(),ku=Ge(),jo=function(r){return function(e,t,i){var n=Su(e),o=ku(n);if(o===0)return!r&&-1;var a=Ru(i,o),l;if(r&&t!==t){for(;o>a;)if(l=n[a++],l!==l)return!0}else for(;o>a;a++)if((r||a in n)&&n[a]===t)return r||a||0;return!r&&-1}};Bo.exports={includes:jo(!0),indexOf:jo(!1)}});var At=h((ym,qo)=>{"use strict";qo.exports=function(){}});var Do=h(()=>{"use strict";var Ou=He(),Pu=Dr().includes,Lu=U(),Fu=At(),Vu=Lu(function(){return!Array(1).includes()});Ou({target:"Array",proto:!0,forced:Vu},{includes:function(e){return Pu(this,e,arguments.length>1?arguments[1]:void 0)}});Fu("includes")});var wt=h((Em,Ho)=>{"use strict";var Mu=Et();Ho.exports=Mu});var Go=h((Tm,Uo)=>{"use strict";Do();var Nu=wt();Uo.exports=Nu("Array","includes")});var Wo=h((Im,zo)=>{"use strict";var $u=Go();zo.exports=$u});var St=h((xm,Ko)=>{"use strict";var _u=Wo();Ko.exports=_u});var ma=h(()=>{"use strict";var zu=He(),Wu=je(),Ku=Ge(),Qu=Ue(),Xu=At();zu({target:"Array",proto:!0},{at:function(e){var t=Wu(this),i=Ku(t),n=Qu(e),o=n>=0?n:i+n;return o<0||o>=i?void 0:t[o]}});Xu("at")});var va=h((tv,fa)=>{"use strict";ma();var Yu=wt();fa.exports=Yu("Array","at")});var ya=h((rv,ba)=>{"use strict";var Zu=va();ba.exports=Zu});var Zr=h((iv,ga)=>{"use strict";var Ju=ya();ga.exports=Ju});var Sa=h((Gv,wa)=>{"use strict";var cp=Pr(),up=Lr(),Aa=cp("keys");wa.exports=function(r){return Aa[r]||(Aa[r]=up(r))}});var ka=h((zv,Ra)=>{"use strict";var pp=U();Ra.exports=!pp(function(){function r(){}return r.prototype.constructor=null,Object.getPrototypeOf(new r)!==r.prototype})});var La=h((Wv,Pa)=>{"use strict";var hp=Te(),dp=G(),mp=je(),fp=Sa(),vp=ka(),Oa=fp("IE_PROTO"),ni=Object,bp=ni.prototype;Pa.exports=vp?ni.getPrototypeOf:function(r){var e=mp(r);if(hp(e,Oa))return e[Oa];var t=e.constructor;return dp(t)&&e instanceof t?t.prototype:e instanceof ni?bp:null}});var Va=h((Kv,Fa)=>{"use strict";Fa.exports={}});var $a=h((Qv,Na)=>{"use strict";var yp=W(),oi=Te(),gp=_e(),Cp=Dr().indexOf,Ep=Va(),Ma=yp([].push);Na.exports=function(r,e){var t=gp(r),i=0,n=[],o;for(o in t)!oi(Ep,o)&&oi(t,o)&&Ma(n,o);for(;e.length>i;)oi(t,o=e[i++])&&(~Cp(n,o)||Ma(n,o));return n}});var ja=h((Xv,_a)=>{"use strict";_a.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var qa=h((Yv,Ba)=>{"use strict";var Tp=$a(),Ip=ja();Ba.exports=Object.keys||function(e){return Tp(e,Ip)}});var Wa=h((Zv,za)=>{"use strict";var Ha=pe(),xp=U(),Ua=W(),Ap=La(),wp=qa(),Sp=_e(),Rp=vr().f,Ga=Ua(Rp),kp=Ua([].push),Op=Ha&&xp(function(){var r=Object.create(null);return r[2]=2,!Ga(r,2)}),Da=function(r){return function(e){for(var t=Sp(e),i=wp(t),n=Op&&Ap(t)===null,o=i.length,a=0,l=[],s;o>a;)s=i[a++],(!Ha||(n?s in t:Ga(t,s)))&&kp(l,r?[s,t[s]]:t[s]);return l}};za.exports={entries:Da(!0),values:Da(!1)}});var Ka=h(()=>{"use strict";var Pp=He(),Lp=Wa().values;Pp({target:"Object",stat:!0},{values:function(e){return Lp(e)}})});var Xa=h((tb,Qa)=>{"use strict";Ka();var Fp=Ct();Qa.exports=Fp.Object.values});var Za=h((rb,Ya)=>{"use strict";var Vp=Xa();Ya.exports=Vp});var Qt=h((ib,Ja)=>{"use strict";var Mp=Za();Ja.exports=Mp});var pi=h((Sb,os)=>{"use strict";var qp=$e();os.exports=Array.isArray||function(e){return qp(e)==="Array"}});var ss=h((Rb,as)=>{"use strict";var Dp=TypeError,Hp=9007199254740991;as.exports=function(r){if(r>Hp)throw Dp("Maximum allowed index exceeded");return r}});var us=h((kb,cs)=>{"use strict";var Up=pi(),Gp=Ge(),zp=ss(),Wp=$r(),ls=function(r,e,t,i,n,o,a,l){for(var s=n,c=0,m=a?Wp(a,l):!1,f,v;c<i;)c in t&&(f=m?m(t[c],c,e):t[c],o>0&&Up(f)?(v=Gp(f),s=ls(r,e,f,v,s,o-1)-1):(zp(s+1),r[s]=f),s++),c++;return s};cs.exports=ls});var ds=h((Ob,hs)=>{"use strict";var Kp=Be(),Qp=Kp("toStringTag"),ps={};ps[Qp]="z";hs.exports=String(ps)==="[object z]"});var fs=h((Pb,ms)=>{"use strict";var Xp=ds(),Yp=G(),Yt=$e(),Zp=Be(),Jp=Zp("toStringTag"),eh=Object,th=Yt(function(){return arguments}())==="Arguments",rh=function(r,e){try{return r[e]}catch(t){}};ms.exports=Xp?Yt:function(r){var e,t,i;return r===void 0?"Undefined":r===null?"Null":typeof(t=rh(e=eh(r),Jp))=="string"?t:th?Yt(e):(i=Yt(e))==="Object"&&Yp(e.callee)?"Arguments":i}});var bs=h((Lb,vs)=>{"use strict";var ih=W(),nh=G(),hi=It(),oh=ih(Function.toString);nh(hi.inspectSource)||(hi.inspectSource=function(r){return oh(r)});vs.exports=hi.inspectSource});var Is=h((Fb,Ts)=>{"use strict";var ah=W(),sh=U(),ys=G(),lh=fs(),ch=Et(),uh=bs(),gs=function(){},Cs=ch("Reflect","construct"),di=/^\s*(?:class|function)\b/,ph=ah(di.exec),hh=!di.test(gs),nt=function(e){if(!ys(e))return!1;try{return Cs(gs,[],e),!0}catch(t){return!1}},Es=function(e){if(!ys(e))return!1;switch(lh(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return hh||!!ph(di,uh(e))}catch(t){return!0}};Es.sham=!0;Ts.exports=!Cs||sh(function(){var r;return nt(nt.call)||!nt(Object)||!nt(function(){r=!0})||r})?Es:nt});var Ss=h((Vb,ws)=>{"use strict";var xs=pi(),dh=Is(),mh=Ee(),fh=Be(),vh=fh("species"),As=Array;ws.exports=function(r){var e;return xs(r)&&(e=r.constructor,dh(e)&&(e===As||xs(e.prototype))?e=void 0:mh(e)&&(e=e[vh],e===null&&(e=void 0))),e===void 0?As:e}});var ks=h((Mb,Rs)=>{"use strict";var bh=Ss();Rs.exports=function(r,e){return new(bh(r))(e===0?0:e)}});var Os=h(()=>{"use strict";var yh=He(),gh=us(),Ch=je(),Eh=Ge(),Th=Ue(),Ih=ks();yh({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=Ch(this),i=Eh(t),n=Ih(t,0);return n.length=gh(n,t,t,i,0,e===void 0?1:Th(e)),n}})});var Ps=h(()=>{"use strict";var xh=At();xh("flat")});var Fs=h((Bb,Ls)=>{"use strict";Os();Ps();var Ah=wt();Ls.exports=Ah("Array","flat")});var Ms=h((qb,Vs)=>{"use strict";var wh=Fs();Vs.exports=wh});var $s=h((Db,Ns)=>{"use strict";var Sh=Ms();Ns.exports=Sh});var Pi="1.0.40-dev.7807e4e6.0";import{fromEvent as da,Subscription as Gu}from"@vkontakte/videoplayer-shared/es2018";var nr=class{constructor(e){this.layout=e}},ct=class extends nr{constructor(e){super(e)}setContainerLayout(e){e.style.position="relative"}setControlLayout(e,t){e.style.position="absolute",e.style.width=`calc(var(--interactive-content-width) * (${t.width} + ${2e-4}))`,e.style.height=`calc(var(--interactive-content-height) * ${t.height})`,e.style.left=`calc(var(--interactive-content-width) * ${t.x} + ((var(--interactive-width) - var(--interactive-content-width)) / 2))`,e.style.top=`calc(var(--interactive-content-height) * ${t.y} + ((var(--interactive-height) - var(--interactive-content-height)) / 2))`}};import{Subject as fl}from"@vkontakte/videoplayer-shared/es2018";function Li(r){return"features"in r}var N=class{constructor(e,t,...i){this.severity=e;this.category=t;this.data=i}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};function ut({emitter$:r,error:e,subjectId:t,message:i="",severity:n=1,category:o=1}){let a=new N(n,o,{message:i,error:e,details:{id:t}});r.next(a)}var ye=class{constructor(e,t){this.error$=new fl;this.container=e,this.options=t,this.factories=new Map,this.controls=[],this.setControls()}featureIsEnabled(e){return this.options&&Li(this.options)&&this.options.features[e]}onError(e="",t){ut({emitter$:this.error$,error:t,message:e,subjectId:this.container.id})}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(){var e;return((e=this.container.controls)==null?void 0:e.reduce((t,i)=>{let n=i.type.trim().toLowerCase(),o=this.factories.get(n);if(o){let a=o(i,this.options);if(a)return[...t,a]}return[...t]},[]))||[]}};import{fromEvent as We,once as ia}from"@vkontakte/videoplayer-shared/es2018";var oe=(r,e)=>Object.prototype.toString.call(r)===`[object ${e}]`,ae=r=>oe(r,"Object"),pt=r=>oe(r,"String"),ht=r=>oe(r,"Array"),dt=r=>oe(r,"Number"),Fi=r=>oe(r,"Function"),Vi=r=>oe(r,"Boolean"),sr=r=>dt(r)&&!isNaN(r);var ce=r=>ae(r)&&Object.keys(r).length===0,lr=r=>ht(r)&&!r.length;var Le=(r,e)=>pt(r)&&(e?r.trim():r).length;function Fe(r,e=1){let t="0",i="0",n="0";return r.length===4?(t="0x"+r[1]+r[1],i="0x"+r[2]+r[2],n="0x"+r[3]+r[3]):r.length===7&&(t="0x"+r[1]+r[2],i="0x"+r[3]+r[4],n="0x"+r[5]+r[6]),`rgba(${+t},${+i},${+n},${e})`}var Mi="interactive",L={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},Ni=(i=>(i.top="flex-start",i.bottom="flex-end",i.center="center",i))(Ni||{}),$i=(i=>(i.start="flex-start",i.end="flex-end",i.center="center",i))($i||{}),_i=(i=>(i.start="left",i.end="right",i.center="center",i))(_i||{}),mt=({target:r,props:e})=>{var t,i,n;r.style.alignItems=(t=(e==null?void 0:e.gravityVertical)&&Ni[e.gravityVertical])!=null?t:"center",r.style.justifyContent=(i=(e==null?void 0:e.gravityHorizontal)&&$i[e.gravityHorizontal])!=null?i:"center",r.style.textAlign=(n=(e==null?void 0:e.alignment)&&_i[e.alignment])!=null?n:"center"},ft=({target:r,props:e,fallback:t,dependsOn:i})=>{var n,o,a,l,s,c;r.style.color=(o=(n=e==null?void 0:e.text)==null?void 0:n.color)!=null?o:t.textColor,r.style.fontSize=`calc(${i.height} * ${(l=(a=e==null?void 0:e.text)==null?void 0:a.size)!=null?l:t.textSize})`,r.textContent=(c=(s=e==null?void 0:e.text)==null?void 0:s.value)!=null?c:t.textContent},vt=({target:r,props:e,fallback:t})=>{var i,n,o,a;r.style.backgroundColor=Fe((n=(i=e==null?void 0:e.background)==null?void 0:i.color)!=null?n:t.backgroundColor,(a=(o=e==null?void 0:e.background)==null?void 0:o.alpha)!=null?a:t.backgroundAlpha)},Ve=({target:r,props:e,fallback:t,dependsOn:i,useRawValues:n=!1})=>{var l,s,c,m,f,v,y,C,E,d,u;let o=n?t.borderWidthRawValue:`calc(${i.height} * ${(c=(s=(l=e==null?void 0:e.shape)==null?void 0:l.border)==null?void 0:s.width)!=null?c:t.borderWidth})`,a=n?t.roundCornersRawValue:`calc(${i.height} * ${(f=(m=e==null?void 0:e.shape)==null?void 0:m.roundCorners)!=null?f:t.roundCorners})`;r.style.borderWidth=o,r.style.borderStyle="solid",r.style.borderColor=Fe(n?t.borderColor:(C=(y=(v=e==null?void 0:e.shape)==null?void 0:v.border)==null?void 0:y.color)!=null?C:t.borderColor,n?t.borderAlpha:(u=(d=(E=e==null?void 0:e.shape)==null?void 0:E.border)==null?void 0:d.alpha)!=null?u:t.borderAlpha),r.style.borderRadius=a},ji=({target:r,isDark:e,baseDimension:t,fallback:i})=>{let a=Fe(i.shadowColorLight,i.shadowColorAlpha),l=Fe(i.shadowColorDark,i.shadowColorAlpha),s=`calc(${t} * ${.25})`,c=`calc(${t} * ${.11})`,m=`0px 0px ${s} ${c} ${e?l:a}`;r.style.boxShadow=m},ge=({target:r,layoutParams:e,fallback:t})=>{var n;let i=(n=e.angle)!=null?n:t.angle;i=i&&i*-1,r.style.transform=`rotate(${i}rad)`};import{fromEvent as ze,Subject as Bu,Subscription as qu}from"@vkontakte/videoplayer-shared/es2018";var cr="interactive-control-tap",Ce={common:cr,animation:`${cr}-animation`,visible:`${cr}-visible`};var vl=60,bt=class{constructor({controlRotateAngleRad:e,clickCancelCondition:t,circleDiameterPx:i=vl,useDimensionsBasedSize:n=!1}){this.onElementClick=e=>{if(!e.target||!e.currentTarget||this.clickCancelCondition())return;let t=e.currentTarget.parentElement;if(!t)return;let i=t.getBoundingClientRect(),n={width:this.useDimensionsBasedSize?t.offsetWidth:this.circleDiameterPx,height:this.useDimensionsBasedSize?t.offsetHeight:this.circleDiameterPx},o=Math.min(n.width,n.height),a=i.left+i.width/2,l=i.top+i.height/2,s=e.clientX-a,c=e.clientY-l,m=bl(s,c,this.controlRotateAngleRad);this.element.style.width=o+"px",this.element.style.left=m.x+i.width/2-o/2+"px",this.element.style.top=m.y+i.height/2-o/2+"px",this.element.classList.add(Ce.visible,Ce.animation)};this.onAnimationEnd=e=>{e.stopPropagation(),!(!e.target||!e.currentTarget)&&e.target===e.currentTarget&&this.element.classList.remove(Ce.visible,Ce.animation)};let o=document.createElement("div");o.classList.add(Ce.common),this.controlRotateAngleRad=e,this.element=o,this.clickCancelCondition=t,this.circleDiameterPx=i,this.useDimensionsBasedSize=n}};function bl(r,e,t){return{x:r*Math.cos(t)-e*Math.sin(t),y:r*Math.sin(t)+e*Math.cos(t)}}var ur="int",ue=(i=>(i.AREA=`${ur}_area`,i.TEXT=`${ur}_text`,i.BUTTON=`${ur}_bttn`,i))(ue||{});function pr(r){return"features"in r}var X="interactive-control",O={common:X,selected:`${X}-selected`,wrapper:`${X}-wrapper`,disabled:`${X}-disabled`,button:`${X}-button`,area:`${X}-area`,text:`${X}-text`,blinkAnim:`${X}-blink-anim`,blinkAnimButton:`${X}-blink-anim-button`,blinkAnimArea:`${X}-blink-anim-area`},Bi=40;var Zo=ee(St(),1);import{isSupportedManifest as kt,ContainerTypes as $m,ControlTypes as Ot,EventActionTypes as R,EventTypes as _m,migrateManifestToLatestVersion as Yo,compareVersions as jm}from"@interactiveplatform/movika-manifest";var Qo={metadata:"Object",chapters:"Array"},Xo=r=>{if(!ae(r))return!1;for(let e in Qo)if(!r[e]||!oe(r[e],Qo[e]))return!1;return kt(r.metadata.version)},Rt=r=>r.type===Ot.Text,Rm=r=>r.type===Ot.Button,km=r=>r.type===Ot.Area,Om={Choice:"Choice",TextInput:"TextInput"},Pm={Button:"Button",Area:"Area",Text:"Text"},Lm={onClick:"onClick",onSuspense:"onSuspense"},Fm={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var Pt=r=>ht(r)&&!lr(r),Z=r=>r.order==="end",Lt=r=>ht(r.containers)&&!lr(r.containers)&&Z(r),Jo=(r,e)=>{var i;let t=r*1e3;return Pt(e.controls)&&t<((i=e.startTime)!=null?i:0)},Hr=(r,e)=>{var i,n;let t=r*1e3;return Pt(e.controls)&&t>=((i=e.startTime)!=null?i:0)&&t<=((n=e.endTime)!=null?n:1/0)};var he=(r=[])=>r.some(e=>e.action.type==="expect"),Ur=(r=[])=>r.find(e=>e.action.type==="expect"),ju=r=>(r==null?void 0:r.length)===1,we=r=>ju(r)&&Rt(r[0]);function ea(r=[],e=1/0,t=[]){return r.filter(({container:i})=>!(0,Zo.default)(t,i.container.id)&&he(i.container.events)&&i.container.endTime===e&&!i.isRemoved&&!i.willRemoved)}function Ft({gameControllers:r=[],subjectName:e,subjectId:t,execFn:i}){for(let n of r)if(e==="container"&&n.container.container.id===t){i(n),ea(r,n.container.container.endTime,[n.container.container.id]).forEach(a=>{i(a)});break}}function ta(r){for(let e of r.events)if(e.action.type==="openURI")return!0;return!1}var ra=(r,e)=>{let t=E=>{let d=e.find(({container:u})=>u.container.id===E);return d==null?void 0:d.container.isRemoved},i=he(r.events)&&!t(r.id),n=(E,d=!1,u=!1)=>{let p=u?"every":"some";return E.controls[p](b=>{var x;let I=d?E.endTime===r.endTime:!0;return((x=b.events)==null?void 0:x[p](g=>{var T;return((T=g.action)==null?void 0:T.type)===R.openURI}))&&I})},o=E=>E.some(({container:d})=>n(d.container,!0,!1)&&!d.isRemoved),a=E=>E.every(({container:d})=>d.isRemoved||d.willRemoved?!0:n(d.container,!0,!0)),l=ea(e,r.endTime,[r.id]).length,s=E=>E.controls.some(d=>{var u;return(u=d.events)==null?void 0:u.some(p=>{var b,I;return(I=(b=p.action)==null?void 0:b.args)==null?void 0:I.shouldOpenNow})}),c=i||l>0,m=o(e),f=n(r),v=a(e),y=i?!1:l>0,C=s(r);return{isExpectTime:c,hasOtherExpect:l>0,hasOpenURIEvent:m,hasOpenURIEventInCurrentContainer:f,isAllOpenURIEventsValid:v,isExpectEventForCurrentContainer:y,hasShouldOpenNowEvent:C}};var se=class r{constructor(e,t){this.control=e;this.options=t;this.container=null;this.controlElement=null;this.subscriptions=new qu;this.error$=new Bu;this.isInteracted=!1;this.isRemoved=!1;this.onControlSelect=()=>{var e,t,i;(e=this.container)!=null&&e.isManifestContainerDisabled()||ta(this.control)||(i=(t=this.container)==null?void 0:t.element)==null||i.classList.add("interactive-control-wrapper-selected")};this.onTransitionEnd=e=>{e.stopPropagation(),!(!e.target||!e.currentTarget)&&e.target===e.currentTarget&&this.removeView()}}removeView(e=!1){let t=this.getElement();if(t){if(e){if(t.classList.contains("interactive-control-before-remove"))return;t.classList.add("interactive-control-before-remove"),this.subscriptions.add(ze(t,"transitionend").subscribe(this.onTransitionEnd,n=>this.onError(`${r.name} remove view transition error`,n))).add(ze(t,"transitioncancel").subscribe(this.onTransitionEnd,n=>this.onError(`${r.name} remove view transition error`,n)));return}this.removeListeners(),t.remove(),this.isRemoved=!0}}onError(e="",t){ut({emitter$:this.error$,error:t,message:e,subjectId:this.control.id})}addControlTap(e){var t;if(this.featureIsEnabled("controlsTapPlace")&&this.container){let i=(t=this.control.layoutParams.angle)!=null?t:L.angle;this.controlTap=new bt({controlRotateAngleRad:i,clickCancelCondition:this.container.isManifestContainerDisabled,circleDiameterPx:this.isTouch()?Bi:void 0}),this.subscriptions.add(ze(e,"click").subscribe(this.controlTap.onElementClick,n=>this.onError("Control click tap animation error",n))).add(ze(this.controlTap.element,"animationend").subscribe(this.controlTap.onAnimationEnd,n=>this.onError("Tap animationend error",n))),this.container.element.append(this.controlTap.element)}}createContainerElement(e){var o;let t=document.createElement("div");t.classList.add(O.wrapper),e.setControlLayout(t,this.control.layoutParams);let i=((o=this.control.layoutParams.innerSizesDependOn)!=null?o:L.innerSizesDependOn)==="self"?{height:t.style.height,width:t.style.width}:{height:"var(--interactive-content-height)",width:"var(--interactive-content-width)"},n=()=>{var a,l;return(l=(a=e.isContainerDisabled)==null?void 0:a.call(e))!=null?l:!1};this.container={element:t,dimensions:i,isManifestContainerDisabled:n}}createClickListener(e){return t=>{t.stopPropagation(),this.isInteracted=!0,e()}}featureIsEnabled(e){return this.options&&pr(this.options)&&this.options.features[e]}isTouch(){return this.options&&pr(this.options)&&this.options.isTouch}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(ze(this.container.element,"click").subscribe(this.createClickListener(()=>e({action:t.action,controlId:this.control.id,controlType:this.control.type})),n=>this.onError("Error happened on control interaction",n)));break}default:break}})}removeListeners(){this.subscriptions.unsubscribe()}};var Gr="interactive-blink-anim-reference",$={common:Gr,animation:`${Gr}-animation`,disabled:`${Gr}-disabled`},Vt=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($.common,$.animation),this._element=e}restart(){this._element&&(this._element.classList.add($.disabled),this.cleanupRAF(),this._RAFId=requestAnimationFrame(()=>{this._element&&(this._element.classList.remove($.disabled),this.cleanupRAF())}))}cleanupRAF(){this._RAFId&&(cancelAnimationFrame(this._RAFId),this._RAFId=0)}destroy(){this.cleanupRAF(),this._element=void 0}};var zr="interactive-container",_={common:zr,hidden:`${zr}-hidden`,disabled:`${zr}-disabled`};var Mt=(r,e)=>{if(r.type.trim().toLowerCase()==="area")return new Wr(r,e)},Wr=class extends se{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){if(super.createContainerElement(t),!this.container)return;this.isInteracted=!1,this.isRemoved=!1;let i=document.createElement("button");i.type="button",i.classList.add(O.common,O.area),i.setAttribute("data-testid",ue.AREA),vt({target:i,props:this.control.props,fallback:{...L,backgroundColor:"transparent"}}),ge({target:i,layoutParams:this.control.layoutParams,fallback:L}),this.addControlTap(i),this.subscriptions.add(We(this.container.element,"click").pipe(ia()).subscribe(this.onControlSelect,n=>this.onError("Control click handler error",n))),this.container.element.append(i),e.append(this.container.element),this.controlElement=i,this.updateShadowStyles(),this.registerBlinkAnimationEvents()}registerBlinkAnimationEvents(){var t;if(!this.featureIsEnabled("controlsExpectTimeBlinkAnimation"))return;let e=(t=this.container)==null?void 0:t.element.parentElement;!e||!this.controlElement||(this.subscriptions.add(We(this.controlElement,"mouseleave").subscribe(()=>{if(e.classList.contains(_.disabled))return;let i=e.parentElement;if(i){let n=i.querySelector(`.${$.common}`);n&&this.syncBlinkAnimation(n)}},i=>this.onError("Error happened in mouseleave callback",i))),this.subscriptions.add(We(this.controlElement,"mouseenter").subscribe(()=>{e.classList.contains(_.disabled)||this.onBlinkHovering()},i=>this.onError("Error happened in mouseenter callback",i))).add(We(this.controlElement,"mouseleave").subscribe(()=>{this.controlElement&&(this.controlElement.style.animation="")},i=>this.onError("Error happened in mouseleave callback",i))))}disable(){this.controlElement&&this.controlElement.classList.add(O.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(O.disabled)}getElement(){return this.controlElement}updateShadowStyles(e){var t,i,n;if(!(!this.container||!this.controlElement))if(Vi(e)){let o=Math.min(this.controlElement.offsetWidth,this.controlElement.offsetHeight)+"px";ji({target:this.controlElement,props:this.control.props,fallback:L,isDark:e,baseDimension:o}),Ve({target:this.controlElement,props:this.control.props,fallback:{...L,borderColor:e?L.shadowColorDark:L.shadowColorLight,borderAlpha:1,borderWidthRawValue:"0.1px",roundCornersRawValue:`calc(${this.container.dimensions.height} * ${(n=(i=(t=this.control.props)==null?void 0:t.shape)==null?void 0:i.roundCorners)!=null?n:L.roundCorners})`},dependsOn:this.container.dimensions,useRawValues:!0})}else Ve({target:this.controlElement,props:this.control.props,fallback:{...L,borderAlpha:0},dependsOn:this.container.dimensions})}toggleBlinkAnimation(e){var t,i;(t=this.controlElement)==null||t.classList.toggle(O.blinkAnim,e),(i=this.controlElement)==null||i.classList.toggle(O.blinkAnimArea,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${O.blinkAnimArea}`)||this.controlElement.classList.contains(O.selected)||this.controlElement.classList.contains($.disabled)||(this.controlElement.classList.add($.disabled),this.subscriptions.add(We(e,"animationiteration").pipe(ia()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove($.disabled)},t=>this.onError("Error happened in animationiteration callback",t)))))}onBlinkHovering(){if(!this.controlElement||!this.controlElement.classList.contains(`${O.blinkAnimArea}`)||this.controlElement.classList.contains(O.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)})}setShowTimeRange(){}updateFillAnimationDimensions(){}onProgress(){}onResize(){}};import{fromEvent as Ke,once as pa}from"@vkontakte/videoplayer-shared/es2018";var Nt=r=>{let e=document.createElement("span");switch(r){case"Button":case"button":{let t=document.createElement("div"),i={overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center"};Object.assign(t.style,i),t.append(e);let n={display:"inline-block",whiteSpace:"pre",textOverflow:"ellipsis",maxWidth:"initial",maxHeight:"100%",wordBreak:"normal"};return Object.assign(e.style,n),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 $t=Math.PI,Kr=2*$t,_t=$t/2,na=3*_t,Du=0,Hu=[Du,_t,$t,na];function oa(r){return r===_t}function aa(r){return r===$t}function sa(r){return r===na}function la(r){return(r%Kr+Kr)%Kr}function Uu(r){for(let e of Hu)if(r===e)return e}function ca(r){if(Uu(r))return null;let t=Math.floor(r/_t)+1;return[1,2,3,4][t-1]}function ua(r){return r*180/Math.PI}var te="interactive-control-fill-animation",j={common:te,fillerWrapper:`${te}-filler-wrapper`,filler:`${te}-filler`,fillHeight:`${te}-fill-height`,fillWidth:`${te}-fill-width`,fromTop:`${te}-from-top`,fromBottom:`${te}-from-bottom`,fromLeft:`${te}-from-left`,fromRight:`${te}-from-right`};var jt=class r{constructor(e){this.widthExpansionCoef=0;var d;let t=document.createElement("div");t.classList.add(j.common);let i=document.createElement("div");i.classList.add(j.fillerWrapper);let n=document.createElement("div");n.classList.add(j.filler),i.append(n),t.append(i);let o=la(e.rotateAngle),a=ca(o),l=a!==null,c=a===2||!l&&aa(o)||a===3,m=!l&&oa(o),f=!l&&sa(o),v=!c&&!m&&!f,y=m||f,C=l&&!y,E=C?o:0;t.style.borderRadius=e.borderRadius,i.style.transform=`skew(${E*-1}rad)`,y?(n.classList.add(j.fillHeight,m?j.fromTop:j.fromBottom),i.classList.add(j.fillHeight,m?j.fromTop:j.fromBottom)):(n.classList.add(j.fillWidth,v?j.fromLeft:j.fromRight),i.classList.add(j.fillWidth)),e.debug&&console.log(`[interactive ${r.name}]`,{widthExpansionCoef:this.widthExpansionCoef,opts:e,shouldFillHeight:y,rotateAngleRad:o,rotateAngelDeg:ua(o),rotateAngleRaw:e.rotateAngle,fromRight:c,fromTop:m,fromBottom:f,fromLeft:v}),this.useSkew=C,this.fromLeft=v,this.rotateAngle=o,this.fillAnimationElement=t,this.fillAnimationFillerElement=n,this.fillAnimationFillerWrapperElement=i,this.startTime=e.startTime,this.endTime=e.endTime,this.shouldFillHeight=y,this.isDebug=(d=e.debug)!=null?d:!1}updateDimension(e){this.fillAnimationElement.style.top=`${e.borderWidth*-1}px`,this.fillAnimationElement.style.left=`${e.borderWidth*-1}px`,this.fillAnimationElement.style.width=`${e.width}px`,this.fillAnimationElement.style.height=`${e.height}px`;let t=this.calcWidthExpansionCoef({rotateAngle:this.rotateAngle,isSkewed:this.useSkew,initWidth:e.width,initHeight:e.height});!this.shouldFillHeight&&(this.fillAnimationFillerWrapperElement.style.width=100*t+100+"%",this.fillAnimationFillerWrapperElement.style[`${this.fromLeft?"left":"right"}`]=`calc((${t} * 100%) / 2 * -1)`),this.widthExpansionCoef=t}updateAnimation(e){if((o=>o<this.startTime||o>this.endTime)(e))return;let i=this.endTime-this.startTime,n=Math.min(Math.max((e-this.startTime)/i,0),1);this.shouldFillHeight?this.fillAnimationFillerElement.style.transform=`scaleY(${n})`:this.fillAnimationFillerElement.style.transform=`scaleX(${n})`}calcWidthExpansionCoef({rotateAngle:e,isSkewed:t=!1,initWidth:i,initHeight:n}){return t?(i+n*Math.abs(Math.tan(e)))/i-1:0}};var Bt=(r,e)=>{if(r.type.trim().toLowerCase()==="button")return new Qr(r,e)},Qr=class extends se{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){var a,l,s,c,m,f;if(super.createContainerElement(t),!this.container)return;this.isInteracted=!1,this.isRemoved=!1;let i=document.createElement("button");i.type="button",i.classList.add(O.common,O.button),i.setAttribute("data-testid",ue.BUTTON),ge({target:i,layoutParams:this.control.layoutParams,fallback:L}),vt({target:i,props:this.control.props,fallback:L}),Ve({target:i,props:this.control.props,fallback:L,dependsOn:this.container.dimensions}),mt({target:i,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let n=Nt(this.control.type.trim().toLowerCase()),o=(a=n.firstElementChild)!=null?a:n;ft({target:o,props:this.control.props,fallback:L,dependsOn:this.container.dimensions}),this.addControlTap(i),this.startTime!==void 0&&this.endTime!==void 0&&this.featureIsEnabled("controlsFillAnimation")&&(this.controlFillAnimation=new jt({startTime:this.startTime,endTime:this.endTime,rotateAngle:(l=this.control.layoutParams.angle)!=null?l:L.angle,borderRadius:i.style.borderRadius})),this.subscriptions.add(Ke(i,"click").pipe(pa()).subscribe(this.onControlSelect,v=>this.onError("Control click handler error",v))),i.append(n,(c=(s=this.controlFillAnimation)==null?void 0:s.fillAnimationElement)!=null?c:""),this.container.element.append((f=(m=this.controlTap)==null?void 0:m.element)!=null?f:"",i),e.append(this.container.element),this.controlElement=i,this.registerBlinkAnimationEvents()}registerBlinkAnimationEvents(){var t;if(!this.featureIsEnabled("controlsExpectTimeBlinkAnimation"))return;let e=(t=this.container)==null?void 0:t.element.parentElement;!e||!this.controlElement||(this.subscriptions.add(Ke(this.controlElement,"mouseleave").subscribe(()=>{if(e.classList.contains(_.disabled))return;let i=e.parentElement;if(i){let n=i.querySelector(`.${$.common}`);n&&this.syncBlinkAnimation(n)}},i=>this.onError("Error happened in mouseleave callback",i))),this.subscriptions.add(Ke(this.controlElement,"mouseenter").subscribe(()=>{e.classList.contains(_.disabled)||this.onBlinkHovering()},i=>this.onError("Error happened in mouseenter callback",i))).add(Ke(this.controlElement,"mouseleave").subscribe(()=>{this.controlElement&&(this.controlElement.style.animation="")},i=>this.onError("Error happened in mouseleave callback",i))))}disable(){this.controlElement&&this.controlElement.classList.add(O.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(O.disabled)}getElement(){return this.controlElement}toggleBlinkAnimation(e){var t,i;(t=this.controlElement)==null||t.classList.toggle(O.blinkAnim,e),(i=this.controlElement)==null||i.classList.toggle(O.blinkAnimButton,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${O.blinkAnimButton}`)||this.controlElement.classList.contains(O.selected)||this.controlElement.classList.contains($.disabled)||(this.controlElement.classList.add($.disabled),this.subscriptions.add(Ke(e,"animationiteration").pipe(pa()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove($.disabled)},t=>this.onError("Error happened in animationiteration callback",t)))))}onBlinkHovering(){if(!this.controlElement||!this.controlElement.classList.contains(`${O.blinkAnimButton}`)||this.controlElement.classList.contains(O.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)})}updateFillAnimationDimensions(){if(!this.container||!this.controlElement||!this.controlFillAnimation)return;let e=getComputedStyle(this.controlElement),t={width:parseFloat(e.width),height:parseFloat(e.height),borderWidth:parseFloat(e.borderWidth)||0};this.controlFillAnimation.updateDimension(t)}setShowTimeRange(e,t){this.startTime=e,this.endTime=t}onProgress(e){var t;(t=this.controlFillAnimation)==null||t.updateAnimation(e)}onResize(){this.updateFillAnimationDimensions()}updateShadowStyles(){}};var ha=(r,e)=>{if(r.type.trim().toLowerCase()==="text")return new Xr(r,e)},Xr=class extends se{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){var a;if(super.createContainerElement(t),!this.container)return;this.isInteracted=!1,this.isRemoved=!1;let i=document.createElement("div");i.classList.add(O.common,O.text),i.setAttribute("data-testid",ue.TEXT),ge({target:i,layoutParams:this.control.layoutParams,fallback:L}),mt({target:i,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let n=Nt(this.control.type.trim().toLowerCase()),o=(a=n.firstElementChild)!=null?a:n;ft({target:o,props:this.control.props,fallback:L,dependsOn:this.container.dimensions}),i.append(n),this.container.element.append(i),e.append(this.container.element),this.controlElement=i}getElement(){return this.controlElement}disable(){}enable(){}onProgress(){}onResize(){}updateShadowStyles(){}toggleBlinkAnimation(){}setShowTimeRange(){}updateFillAnimationDimensions(){}};var qt=(r,e,t)=>{if(r.type.trim().toLowerCase()==="choice")return new Yr(r,e,t)},Yr=class r extends ye{constructor(t,i,n){super(t,n);this.containerElement=null;this.subscriptions=new Gu;this.onTransitionEnd=t=>{t.stopPropagation(),!(!t.target||!t.currentTarget)&&t.target===t.currentTarget&&this.removeView()};this.rootElement=i,this.layout=new ct(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",Bt),this.addControlFactory("text",ha),this.addControlFactory("area",Mt)}createView({eventCallback:t,videoDurationMs:i}){let n=document.createElement("div");return n.classList.add(_.common,_.disabled),requestAnimationFrame(()=>{n.classList.remove(_.disabled)}),this.layout.setContainerLayout(n),this.controls.forEach(o=>{var a;o.setShowTimeRange(this.container.startTime,(a=this.container.endTime)!=null?a:i),o.createView({parentElement:n,callbacks:{setControlLayout:this.layout.setControlLayout,isContainerDisabled:()=>this.isDisabled}}),o.setEvents(t),this.subscriptions.add(o.error$.subscribe(this.error$))}),this.rootElement.append(n),this.isRemoved=!1,this.willRemoved=!1,this.containerElement=n,this.updateControlsFillAnimationDimensions(),n}updateControlsFillAnimationDimensions(){for(let t of this.controls)t.updateFillAnimationDimensions()}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(i=>i.enable()),this.isDisabled=!1)}disable(){let t=this.getElement();t&&(t.classList.add(_.disabled),this.controls.forEach(i=>i.disable()),this.isDisabled=!0)}removeView(t=!1,i=!1){let n=this.getElement();if(n){if(t){if(this.willRemoved)return;this.willRemoved=!0,i&&n.classList.add("interactive-container-before-remove-delay"),n.classList.add("interactive-container-before-remove"),this.subscriptions.add(da(n,"transitionend").subscribe(this.onTransitionEnd,a=>this.onError(`${r.name} remove view transition error`,a))).add(da(n,"transitioncancel").subscribe(this.onTransitionEnd,a=>this.onError(`${r.name} remove view transition error`,a)));return}this.subscriptions.unsubscribe(),this.removeAllControls(),n.remove(),this.isRemoved=!0,this.willRemoved=!1,this.containerElement=null}}removeAllControls(t=!1){this.controls.forEach(i=>i.removeView(t))}removeNonInteractedControls(t=!1){this.controls.forEach(i=>{i.isInteracted||i.removeView(t)})}isInteracted(){return this.controls.some(t=>t.isInteracted)}fakeRemove(){this.isRemoved||(this.isRemoved=!0)}getElement(){return this.containerElement}onProgress(t,i){i&&this.controls.forEach(n=>{n.onProgress(t)})}onResize(t){t&&this.controls.forEach(i=>{i.onResize()})}updateControlsShadowStyles(t){this.controls.forEach(i=>i.updateShadowStyles(t))}toggleBlinkAnimation(t){this.controls.forEach(i=>i.toggleBlinkAnimation(t))}};var sl=ee(Zr(),1);import{combine as jh,InterfaceLanguage as Bh,Observable as nl,once as qh,Subject as B,Subscription as gi,ValueSubject as D,fromEvent as ol}from"@vkontakte/videoplayer-shared/es2018";import{InteractiveInterfaceClick as st}from"@vkontakte/videoplayer-statistics/es2018";import{loadVKLangPack as ep}from"@vkontakte/videoplayer-shared/es2018";function Qe(r,e){let t;return(...i)=>{clearTimeout(t),t=setTimeout(()=>r(...i),e)}}var Ca="video_interactive",Ea="videoint";var Ta=250,Xe=class{constructor(e){this.handleZoomChange=Qe(e=>{this.lastZoomInfo=e},Ta);this.onResize=e=>{var i;if(!this.isReady||this.isHidden||!e[0].contentRect.width||!e[0].contentRect.height)return;let t=this.getNextPoint();t&&((i=this.ngEditor)==null||i.zoomTo(t,void 0,{isFromCenter:!0})),this.ngEditorSize={width:e[0].contentRect.width,height:e[0].contentRect.height}};this.handleChapterChange=e=>{var t,i,n;if(this.manifest){if(this.isHidden||this.hide(),!(e!=null&&e.id)){(t=this.onError)==null||t.call(this,"Chapter id is not found");return}this.visitedChapterIds.add(e.id),(i=this.ngEditor)==null||i.selectChapter(e.id),(n=this.ngEditor)==null||n.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId=e.id,this.lastZoomInfo=null}};this.handleManifestChange=(e,t=[])=>{var i;if(this.isReady=!1,!dt(e.graph.edit.chapters[0].x)){(i=this.onError)==null||i.call(this,"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:i,lang:n,visitedChapters:o=[]}){this.isReady=!1,this.isHidden=!0,this.manifest=null,this.visitedChapterIds=new Set(o),this.onOpenPreviewClick=t,this.onError=i,this.lang=n!=null?n:"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(Qe(this.onResize,Ta)),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){var t;this.visitedChapterIds=new Set([...this.visitedChapterIds,...e]),(t=this.ngEditor)==null||t.setVisitedChapters(Array.from(this.visitedChapterIds))}updateVideosInfo(e){var t;(t=this.ngEditor)==null||t.updateVideosInfo(e)}async show(){var e;this.manifest&&(this.ngEditor||await this.initNgEditor(),this.graphWrapperElement.style.display="block",!this.lastZoomInfo&&this.currentChapterId&&((e=this.ngEditor)==null||e.focusChapter(this.currentChapterId)),this.isHidden=!1)}async initNgEditor(){var i;if(!this.manifest)return;let e;try{e=await ep(this.lang,Ca,Ea)}catch(n){(i=this.onError)==null||i.call(this,"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,...o})=>{var a;n==="openPreview"&&"chapterId"in o&&((a=this.onOpenPreviewClick)==null||a.call(this,o.chapterId))}),this.ngEditor.on("zoom",this.handleZoomChange),this.isReady=!0}hide(){this.graphWrapperElement.style.display="none",this.isHidden=!0}destroy(){var e,t;this.hide(),this.manifest=null,this.resizeObserver.disconnect(),(e=this.ngEditor)==null||e.setVisitedChapters([]),this.onOpenPreviewClick=void 0,(t=this.ngEditor)==null||t.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 Ye=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,i=!1,n=Math.round(this._player.info.position$.getValue()*1e3);for(let o of this._containers){let a=o.startTime-e;if(a<=n&&(o.endTime&&n<=o.endTime||o.endTime===null)){i=!0;break}n<a&&(t=t===-1?a:Math.min(t,a))}return!i&&t!==-1?t:null}}};var Dt=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 i=()=>{t(),this.off(e,i)};return this.listeners[e].push(i),this}off(e,t){return this.removeListener(e,t)}reset(){this.listeners={}}removeListener(e,t){let i=this.listeners[e]||[];for(let n=i.length;n>0;n--)if(i[n]===t){i.splice(n,1);break}return this}emit(e,...t){let i=this.listeners[e];return i?(i.forEach(n=>{n(...t)}),!0):!1}listenerCount(e){return this.rawListeners(e).length}rawListeners(e){return this.listeners[e]||[]}};var Ht=class{constructor(e){this.fns=[];this.addFn=(e,t=!1)=>{Fi(e)&&(this.fns.push(e),t&&this.updateFn())};this.removeFn=(e,t=!1)=>{this.fns=this.fns.filter(i=>i!==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=[]}};import{ValueSubject as lp}from"@vkontakte/videoplayer-shared/es2018";var Ut=class{constructor(e){var t,i;this.loaders={chapterLoaders:(t=e==null?void 0:e.chapterLoaders)!=null?t:[],manifestLoaders:(i=e==null?void 0:e.manifestLoaders)!=null?i:[]}}async exec(e,t){return rp(...this.loaders[e])(t)}};function rp(...r){return async function(t){let i=[...r];for(;i.length>0;)t=await i.shift()(t);return t}}function Ze(r,e,t){return r?{...r,[e]:r[e]?[t,...r[e]]:[t]}:{[e]:[t]}}function Gt({actions:r,errors:e,chapterId:t,...i}){if(t){let n=r.getManifest();if(n){let o=r.getChapter(n.chapters,t);if(o){let a=r.getMedia(n.media,o.videoId),l=r.getGraph(n.graph,o.id);return a?{...i,actions:r,errors:e,result:{chapter:o,media:a,graph:l}}:{...i,errors:Ze(e,Gt.name,"Could not find media"),actions:r}}}}return{...i,errors:Ze(e,Gt.name,"Could not find chapter"),actions:r}}var zt=class{constructor(){Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}addEventListener(e,t,i){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:t,options:i})}removeEventListener(e,t){if(!(e in this.listeners))return;let i=this.listeners[e];for(let n=0,o=i.length;n<o;n++)if(i[n].callback===t){i.splice(n,1);return}}dispatchEvent(e){if(!(e.type in this.listeners))return;let i=this.listeners[e.type].slice();for(let n=0,o=i.length;n<o;n++){let a=i[n];try{a.callback.call(this,e)}catch(l){Promise.resolve().then(()=>{throw l})}a.options&&a.options.once&&this.removeEventListener(e.type,a.callback)}return!e.defaultPrevented}},Se=class extends zt{constructor(){super(),this.listeners||zt.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)}},Je=class{constructor(){Object.defineProperty(this,"signal",{value:new Se,writable:!0,configurable:!0})}abort(e){let t;try{t=new Event("abort")}catch(n){typeof document!="undefined"?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 i=e;if(i===void 0)if(typeof document=="undefined")i=new Error("This operation was aborted"),i.name="AbortError";else try{i=new DOMException("signal is aborted without reason")}catch(n){i=new Error("This operation was aborted"),i.name="AbortError"}this.signal.reason=i,this.signal.dispatchEvent(t)}toString(){return"[object AbortController]"}};typeof Symbol!="undefined"&&Symbol.toStringTag&&(Je.prototype[Symbol.toStringTag]="AbortController",Se.prototype[Symbol.toStringTag]="AbortSignal");function Wt(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 Jr(r){typeof r=="function"&&(r={fetch:r});let{fetch:e,Request:t=e.Request,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n=!1}=r;if(!Wt({fetch:e,Request:t,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n}))return{fetch:e,Request:o};let o=t;(o&&!o.prototype.hasOwnProperty("signal")||n)&&(o=function(c,m){let f;m&&m.signal&&(f=m.signal,delete m.signal);let v=new t(c,m);return f&&Object.defineProperty(v,"signal",{writable:!1,enumerable:!1,configurable:!0,value:f}),v},o.prototype=t.prototype);let a=e;return{fetch:(s,c)=>{let m=o&&o.prototype.isPrototypeOf(s)?s.signal:c?c.signal:void 0;if(m){let f;try{f=new DOMException("Aborted","AbortError")}catch(y){f=new Error("Aborted"),f.name="AbortError"}if(m.aborted)return Promise.reject(f);let v=new Promise((y,C)=>{m.addEventListener("abort",()=>C(f),{once:!0})});return c&&c.signal&&delete c.signal,Promise.race([v,a(s,c)])}return a(s,c)},Request:o}}var ip=()=>"fetch"in window,et=ip()&&Wt({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),Ia=et?Jr({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,ei=et?Ia.fetch:window.fetch,Rv=et?Ia.Request:window.Request,kv=et?Je:window.AbortController,Ov=et?Se:window.AbortSignal;var ti=(r="",e="")=>{let t=r.split("."),i=e.split("."),n=0;for(let o=0;o<Math.max(t.length,i.length)&&!n;o++)t[o]>i[o]?n=1:t[o]<i[o]?n=-1:n=0;return n};var np=async r=>{try{let e={},t;if(pt(r)){t=new URL(r).href;let n=await ei(t);if(!n.ok)return{};e=await n.json()}else if(ae(r))e=r;else return{};if(!Xo(e))return{};let i=e.metadata.media;if(pt(i)&&!("media"in e))try{let n;t?n=new URL(i,t).href:(n=new URL(i).href,t=n);let o=await ei(n);if(!o.ok)throw new Error;e.metadata.media=await o.json()}catch(n){return sp(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch(e){return{}}};async function xa(r){let{manifest:e,manifestURL:t}=await np(r);if(!e)throw new Error("Failed on fetch");let i=Yo(e);return i.media=op(i.media,t),delete i.metadata.media,i}function Kt(r,e){if(e)return r.find(t=>t.id===e)}function ri(r,e){var t,i;return(t=r.edit)!=null&&t.chapters?r.edit.chapters.find(n=>n.id===e):(i=r.view)!=null&&i.chapters?r.view.chapters.find(n=>n.id===e):void 0}function ii(r,e){return r.videos.find(t=>t.id===e)}function op(r,e){return{...r,videos:r.videos.map(t=>({...t,variants:t.variants.map(i=>{let n="url"in i?i.url:"",o=ap(n,e);return{...i,url:o||n}})}))}}function ap(r="",e){try{return new URL(r,e).href}catch(t){return""}}function sp(r){return ti(r,"3.2.0")>=0}var Re=class extends Ut{constructor(t,i){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new lp(null);this.onError=i,this.release()}release(){return this.manifest=null,this.chapter=null,this.media=null,this.graph=null,this.prevChapter$.next(null),this}async setManifest(t){var n;this.release();let i=await this.exec("manifestLoaders",{actions:{addErrorMessage:Ze},result:null,errors:null,source:t});return i.errors&&this.errorHandler(i.errors),this.manifest=await xa((n=i.result)!=null?n:t),this}async setInitial(){return this.setNext()}async setNext(t=(i=>(i=this.manifest)==null?void 0:i.metadata.initChapterId)()){if(!t)return this;this.prevChapter$.next(this.chapter);let n=await this.exec("chapterLoaders",Gt({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:ri,getChapter:Kt,getMedia:ii,getByBranches:this.getByBranches.bind(this),addErrorMessage:Ze},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(){var i;return this.getByChapterId((i=this.manifest)==null?void 0:i.metadata.initChapterId)||null}getByChapterId(t=(i=>(i=this.manifest)==null?void 0:i.metadata.initChapterId)()){if(!t||!this.manifest)return null;let n=Kt(this.manifest.chapters,t);if(n){let o=ii(this.manifest.media,n.videoId),a=ri(this.manifest.graph,n.id);if(o)return{chapter:n,media:o,graph:a}}return null}getBranches(t=(i=>(i=this.chapter)==null?void 0:i.id)()){var n,o,a;if(t===((n=this.chapter)==null?void 0:n.id))return this.getByBranches((o=this.chapter)==null?void 0:o.branches);{let l=Kt(((a=this.manifest)==null?void 0:a.chapters)||[],t);return this.getByBranches(l==null?void 0:l.branches)}}getByBranches(t=[]){return t.reduce((i,n)=>{let o=this.getByChapterId(n.chapterId);return o&&i.push(o),i},[])}getCurrent(){return{chapter:this.chapter,media:this.media,graph:this.graph}}isInitialChapter(){var t,i;return((t=this.chapter)==null?void 0:t.id)===((i=this.manifest)==null?void 0:i.metadata.initChapterId)}isEndChapter(){return this.chapter?Z(this.chapter):!1}};var rs=ee(Qt(),1);import{Player as Np}from"@vkontakte/videoplayer-core/es2018";import{Subscription as li,TracerFactory as $p,ValueSubject as _p}from"@vkontakte/videoplayer-shared/es2018";var es=r=>{let e=r.variants.find(t=>{var i;return((i=t.payload)==null?void 0:i.type)==="vk"});if(e&&e.payload){let[t,i]=e.payload.id.split("_");return[t,i]}return[]};var ts=ee(Qt(),1);function ai(){let r=new Map;function e({listId:o=Math.random().toString(),itemId:a=Math.random().toString(),...l}){let s=r.get(o),c={...l};return s?s[a]=c:r.set(o,{[a]:c}),{listId:o,itemId:a,...l}}function t(o){var a,l;o.player.destroy(),o.container.remove(),o.subscription.unsubscribe(),(a=o.statistics)==null||a.oneStat.destroy(),(l=o.statistics)==null||l.statSubscription.unsubscribe()}function i(o,a){let l=r.get(o);if(!l)throw Error("Can't remove. Not find.");if(a){let s=l[a];s&&t(s),delete l[a],Object.keys(l).length||r.delete(o)}else{for(let s of(0,ts.default)(l))t(s);r.delete(o)}}function n(){for(let o of r)i(o[0])}return{createPlayer:e,removePlayer:i,map:r,removeAll:n}}var ke=ee(St(),1);function si(r,e=[]){var o,a,l;let t={},i,n=!e.length;for(let s of r.variants)if(!i&&"cover"in s&&(i=s.cover),"url"in s)switch(s.type.toLowerCase()){case"mp4":(n||(0,ke.default)(e,"mp4"))&&(t.MPEG={...t.MPEG,[(o=s.standard)!=null?o:"Invariant quality"]:s.url});break;case"mpeg":(n||(0,ke.default)(e,"mpeg"))&&(t.MPEG={...t.MPEG,[(a=s.standard)!=null?a:"Invariant quality"]:s.url});break;case"hls":(n||(0,ke.default)(e,"hls"))&&(t={...t,HLS:{type:"url",url:s.url}});break;case"dash":(n||(0,ke.default)(e,"dash"))&&(t={...t,DASH_SEP:{compatibilityMode:!0,type:"url",url:s.url}});break;default:break}return{sources:t,thumbUrl:i,title:(l=r.title)!=null?l:""}}var tt=(r,e)=>{let t=r.info.currentQuality$.getValue(),i=r.info.availableQualities$.getValue();t!==e&&(0,ke.default)(i,e)&&(r.setQuality(e),r.setAutoQuality(!1))};var jp=2;function ci(r){let e=ai(),t=new li,i={},n=null,o=!1,a,l=new _p(null);r&&s(r);function s(d){n=d}function c(d,u,p){var x;if(!n)throw Error("need to set interactive controller");if(!n.options)return;let I=((x=e.map.get(d))!=null?x:{})[u];if(I){i={chapterId:p,listId:d,itemId:u,...I};let g=i.player;i.subscription.add(g.info.currentQuality$.subscribe(T=>{let F=g.info.position$.getValue(),A=g.info.isAutoQualityEnabled$.getValue();if(!(!T||!F||A))for(let k of e.map)(0,rs.default)(k[1]).forEach(({player:P})=>{tt(P,T)})})).add(g.events.started$.subscribe(()=>{m(u)})),I.container.remove(),n.setPlayer(I.player),o||(n.init(),o=!0),l.next({player:i.player,config:i.config,statistics:i.statistics});return}throw Error("Can't set. Not find.")}async function m(d){if(!n)throw Error("need to set interactive controller");if(ce(i)||d!==i.itemId)return;let u=n.getChapterBranches(),p=new Set;for(let b of u)p.has(b.media.id)||(await v({media:b.media,chapterId:b.chapter.id,setAsActive:!1,title:b.chapter.label}),p.add(b.media.id))}async function f({chapter:{id:d},manifestVideo:u}){if(ce(i)||!n)return;let p=i.player.info.muted$.getValue(),b=i.player.info.currentQuality$.getValue(),I=i.player.info.isAutoQualityEnabled$.getValue(),x=i.player.info.volume$.getValue(),g=i.player.info.currentPlaybackRate$.getValue(),T=!I,F=!1;for(let A of e.map)if(A[0]===u.id&&!n.state.isReplay$.getValue()){let k=Object.keys(A[1]);for(let P of k)P===i.itemId?(k.length<jp||(F=!0),e.removePlayer(A[0],P)):(F=!0,c(A[0],P,d),T?tt(i.player,b):i.player.setAutoQuality(!0),i.player.setVolume(x),i.player.setMuted(p),i.player.setPlaybackRate(g))}else e.removePlayer(A[0]);F||(await v({media:u,chapterId:d,setAsActive:!0,playbackRate:g}),T?tt(i.player,b):i.player.setAutoQuality(!0),i.player.setVolume(x),i.player.setMuted(p))}async function v({media:d,chapterId:u,prefetch:p=!0,setAsActive:b=!0,autoplay:I=!1,preferredExt:x,title:g,playbackRate:T}){var Ei,Ti,Ii,xi,Ai;let F=Math.random().toString(),A=document.createElement("div");a.append(A);let k;if((Ei=n==null?void 0:n.options)!=null&&Ei.vkVideoLoader){let lt=es(d);lt.length&&(k=await n.options.vkVideoLoader(...lt))}let P=((Ti=n==null?void 0:n.options)==null?void 0:Ti.coreConfig)||void 0,Q={...P,configName:[...(Ii=P==null?void 0:P.configName)!=null?Ii:[],"interactive"]},le={container:A,...((xi=k==null?void 0:k.videos)==null?void 0:xi[0])||{sources:si(d,x).sources},title:g,failoverHosts:(k==null?void 0:k.failoverHosts)||[]},q=new Np(Q,$p.createRootTracer());q.initVideo(le);let ve=null;if(k!=null&&k.videos&&(n!=null&&n.options.createOneStat)){let lt=k.videos[0],ir=n.options.createOneStat(lt),wi=new li;ir&&(wi.add(ir.attachTo(q)),ve={oneStat:ir,statSubscription:wi})}let Ci=new li,ll=(Ai=i==null?void 0:i.player)==null?void 0:Ai.info.isAutoQualityEnabled$.getValue();Ci.add(q.events.canplay$.subscribe(function(){ll||tt(q,i.player.info.currentQuality$.getValue()),T&&q.setPlaybackRate(T)}));let be=e.createPlayer({listId:d.id,itemId:F,player:q,container:A,sources:si(d,x).sources,config:le,subscription:Ci,statistics:ve});return b&&c(d.id,be.itemId,u),I&&be.player.play(),p&&!I&&be.player.prepare(),{player:be.player,config:be.config,statistics:be.statistics}}function y(){C(),n=null,a.remove()}function C(){t.unsubscribe(),e.removeAll(),i={},o=!1}async function E(){if(!n)throw Error("need to set interactive controller");C(),a=document.createElement("div");let{media:d,chapter:u}=n.getCurrentChapter();d&&u?(t.add(n.events.chapterChanged$.subscribe(f)),await v({media:d,chapterId:u.id,title:u.label})):console.error("not found")}return{...e,init:E,setInteractiveController:s,createPlayer:v,removeAll:y,getActivePlayer:function(){return i},activePlayerChanged:l}}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"},rt={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},V={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};import{Subscription as Bp}from"@vkontakte/videoplayer-shared/es2018";function ui(r){return function(...t){return r(...t.reverse())}}function it(r,...e){return(...t)=>ae(e[0])&&ae(t[0])?r({...e[0],...t[0]}):r(...e,...t)}var Xt=class{constructor({player:e,container:t,branches:i,selectBranches:n,interactiveEvents:o,globalEvents:a,globalEventEmitter:l,getContainerEventState:s,permanentTextControls:c,interactiveTimeOpenUri:m,disabledControls$:f,onRemove:v,onError:y,disableTextControlContainerVisibilityEvents:C=!1,features:E}){this.hide=()=>{setTimeout(()=>{var e,t;this.gameState!==4&&(he(this.container.container.events)&&this.gameState===3||this.selectBranches.state.isExpect||(this.gameState!==2&&((t=(e=this.container).hide)==null||t.call(e)),this.emitContainerVisibilityEvent(!1)))})};this.show=()=>{var t,i,n,o,a,l;if(this.gameState!==2||this.isSelectedControlEvent)return;if(this.container.getElement()){let{hasOpenURIEventInCurrentContainer:s}=this.getContainerEventState();if((i=(t=this.container).show)==null||i.call(t),this.interactiveTimeOpenUri&&s||this.disableTextControlContainerVisibilityEvents)return;this.emitContainerVisibilityEvent(!0,!1)}else{let s={isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.emitContainerVisibilityEvent(!1)},onEvent:(f,v)=>{let{isExpectTime:y,hasOtherExpect:C,hasOpenURIEvent:E,hasOpenURIEventInCurrentContainer:d,isAllOpenURIEventsValid:u,hasShouldOpenNowEvent:p}=this.getContainerEventState(),b=this.interactiveTimeOpenUri&&!d,I=this.interactiveTimeOpenUri&&d;if((!this.interactiveTimeOpenUri||b)&&(this.isSelectedControlEvent=!0),f!==!1){if(!this.selectBranches.state.isExpect&&(!this.interactiveTimeOpenUri||b)){if(this.interactiveTimeOpenUri){let x=!C&&!u&&d;x&&this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:x})}this.removeView()}this.emitContainerVisibilityEvent(!1)}if(this.gameState===4||this.gameState===3||this.selectBranches.state.isExpect||this.interactiveTimeOpenUri&&E&&this.gameState!==5){if(I){let g=((T,F,A,k)=>!T&&!F&&A||T&&!F&&A&&!k||T&&!F&&A&&k)(y,C,u,this.isSelectedContainerEvent);this.fakeRemoveView(g)}else this.removeView(),this.emitContainerVisibilityEvent(!1);(!y||!C||!p)&&(this.selectBranches.stopExpect(),v())}},isEOV:()=>this.gameState===4},c=it(this.selectBranches.onControlEvent,s),m=((o=(n=this.player)==null?void 0:n.info.duration$.getValue())!=null?o:1/0)*1e3;this.container.createView({eventCallback:c,videoDurationMs:m}),this.disableTextControlContainerVisibilityEvents||this.emitContainerVisibilityEvent(!0,!0),this.disabledControls$.getValue()&&((l=(a=this.container).disable)==null||l.call(a))}};this.onEndOfVideo=()=>{this.gameState=4,this.selectContainerEvent(!0)};this.whilePlaying=()=>{var s,c,m;let e=this.player.experimental.element$.getValue();if(!(e instanceof HTMLVideoElement?e.readyState:void 0)||this.isRemovedOrDestroyed()&&!this.isPermanentText)return;let n=this.player.getExactTime();if(Jo(n,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(Hr(n,this.container.container))this.gameState!==2&&(this.gameState=2,this.onStartTime());else if(this.gameState!==3){let f=this.gameState;this.gameState=3,f===2&&this.onEndTime()}else{let{hasOpenURIEventInCurrentContainer:f}=this.getContainerEventState(),v=this.selectBranches.state.isExpect,y=this.interactiveTimeOpenUri&&f;if(y&&!v){let C=this.container.getElement();C&&(C.style.visibility!=="hidden"&&((c=(s=this.container).hide)==null||c.call(s)),this.container.isRemoved||this.fakeRemoveView())}!this.isPermanentText&&!y&&this.removeView()}let o=Hr(n,this.container.container),a=this.container.container.startTime?[this.container.container.startTime,(m=this.container.container.endTime)!=null?m:1/0]:[],l={subjectId:this.container.container.id,subjectName:"container",range:a,currentTime:n,isInteractiveTime:o};this.container.onProgress(n*1e3,o),this.globalEventEmitter.emit(S.eachTick,l),this.globalEvents.eachTick$.next(l)};this.container=t,this.branches=i,this.selectBranches=n,this.subscription=new Bp,this.player=e,this.interactiveEvents=o,this.getContainerEventState=s;let d=we(t.container.controls);this.isPermanentText=c&&d,this.disableTextControlContainerVisibilityEvents=C&&d,this.interactiveTimeOpenUri=m,this.disabledControls$=f,this.onRemove=v,this.globalEventEmitter=l,this.gameState=0,this.globalEvents=a,this.onError=y,this.features=E,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=>{var t,i,n,o;e?(i=(t=this.container).disable)==null||i.call(t):(o=(n=this.container).enable)==null||o.call(n)})),this.subscription.add(this.container.error$.subscribe(this.onError))}selectContainerEvent(e=!1){var i,n;let{isExpectEventForCurrentContainer:t}=this.getContainerEventState();this.interactiveEvents.containersEventsCallState.setCalled({timestamp:e?1/0:(i=this.container.container.endTime)!=null?i: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((n=this.container.container.endTime)!=null?n:1/0))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);let{isExpectTime:e,hasOpenURIEventInCurrentContainer:t}=this.getContainerEventState(),i=this.interactiveTimeOpenUri?e||t:he(this.container.container.events)||e;(this.isSelectedControlEvent||!i)&&this.removeView()}onBeforeStartTime(){var e,t;(t=(e=this.container).hide)==null||t.call(e),this.emitContainerVisibilityEvent(!1)}onResize(e){this.container.onResize(e)}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=1}removeView(e=this.features.controlsHideAnimation){var t;if(e){if(this.isRemovedOrDestroyed())return;this.container.removeNonInteractedControls(!0),this.container.removeView(!0,!0)}else 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,(t=this.onRemove)==null||t.call(this)}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)}isInteracted(){return this.container.isInteracted()}isRemovedOrDestroyed(e=!0){let t=e?this.container.willRemoved:!1;return this.gameState===5||t||this.gameState===6}destroy(e=!1){var t;this.reset(),this.removeView(e),this.gameState=6,this.subscription.unsubscribe(),this.branches=[],this.interactiveEvents.containersEventsCallState.setCalled({timestamp:(t=this.container.container.endTime)!=null?t:1/0,id:this.container.container.id})}};var ns=(r=[])=>r.reduce((e,t,i)=>{var o,a,l;let n=((o=t==null?void 0:t.controls)!=null?o:[]).filter(s=>!Rt(s));if(Pt(n)){let s=[(a=t.startTime)!=null?a:0,(l=t.endTime)!=null?l:1/0],c={id:t.id,isRemoved:!1};if(!i)e.push({subjects:[c],range:s});else{let m=[],f=-1/0,v=1/0,y=[],C=[];for(let E=0;E<e.length;E++){let d=e[E];if(C.push(...d.subjects),d.range[0]<v&&(v=d.range[0]),d.range[1]>f&&(f=d.range[1]),s[0]>=d.range[0]&&s[1]<=d.range[1])return e[E].subjects.push(c),e;s[0]<d.range[0]&&s[1]>d.range[0]&&(m.push(E),y=y.concat(d.subjects)),s[0]>=d.range[0]&&s[0]<=d.range[1]&&(m.push(E),y=y.concat(d.subjects),s[0]=d.range[0]),s[1]>=d.range[0]&&s[1]<=d.range[1]&&(m.push(E),y=y.concat(d.subjects),s[1]=d.range[1])}if(C.push(c),s[0]<=v&&s[1]>=f)return[{subjects:C,range:s}];m.length&&m.reverse().forEach(E=>{e.splice(E,1)}),e.push({subjects:y.concat([c]),range:s})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);var js=ee(St(),1),mi=ee(Qt(),1),Bs=ee($s(),1);function _s(){let r={};function e(){for(let l in r)Object.prototype.hasOwnProperty.call(r,l)&&delete r[l]}function t(l){let s={};for(let c in r)+c<=l&&(s[c]=r[c]);return s}function i(l){let s={};for(let c in r)+c>=l&&(s[c]=r[c]);return s}function n({timestamp:l,priority:s,initiator:c}){var m;if(sr(l)){let f=(m=r[l])!=null?m:null;if(f&&s&&Le(s,!0)){let v={},y=f[s];if(y&&(v={...v,...y}),v=ce(v)?null:v,v&&Le(c,!0)){let C=v[c];return C!=null?C:null}return v}return f}return null}function o({timestamp:l,priority:s,initiator:c}){if(sr(l))if(r[l]){if(s&&Le(s,!0))if(r[l][s]){if(c&&Le(c,!0))if(r[l][s][c]){if(delete r[l][s][c],!ce(r[l][s]))return!0}else return!1;if(delete r[l][s],!ce(r[l]))return!0}else return!1;return delete r[l]}else return!1;return!1}function a({timestamp:l,priority:s,initiator:c,...m}){var f,v,y;(v=(f=r[l])==null?void 0:f[s])!=null&&v[c]?r[l][s][c].push({...m}):(y=r[l])!=null&&y[s]?r[l][s]={...r[l][s],[c]:[{...m}]}:r[l]?r[l]={...r[l],[s]:{[c]:[{...m}]}}:r[l]={[s]:{[c]:[{...m}]}}}return{map:r,remove:o,add:a,removeAll:e,get:n,getLte:t,getGte:i}}var Rh=[R.expect,R.setNextBranch],kh=1/0;function qs(r,e){let t=r,i,n=Oh(e),o=_s(),a,l=()=>{y(),u()},s=p=>{o.add.call(void 0,p),C()},c=(p=[])=>{for(let b of p)if(b.action(),(0,js.default)(Rh,b.actionType))break},m=(p=1/0)=>{var g,T,F;let b=Zt((g=o.get({timestamp:p,priority:"control"}))!=null?g:{}),I=Zt((T=o.get({timestamp:p,priority:"container"}))!=null?T:{}),x=Zt((F=o.get({timestamp:p,priority:"chapter"}))!=null?F:{});return[...b,...I,...x]},f=p=>{n.isReady(p)&&c(m(p))},v=()=>{var p;c([...Zt((p=o.get({timestamp:1/0,priority:"chapter"}))!=null?p:{})])},y=()=>{i&&(a==null||a.unsubscribe(),i=void 0)},C=()=>{i||(i=()=>setTimeout(()=>{f(1/0)}),a=t.events.ended$.subscribe(i))},E=p=>{y(),t=p},d=p=>{p.priority==="container"&&n.resetCalled(p.timestamp),o.remove(p)},u=()=>{n.release(),o.removeAll()};return{setPlayer:E,add:s,remove:d,exec:f,execEndOfVideo:v,listen:C,unlisten:y,release:l,containersEventsCallState:n,getPreparedToExecActions:m}}function Oh(r){let e=new Map;return{setCalled:({timestamp:l,id:s})=>{let c=e.get(l);c&&c[s]!==void 0&&(c[s]=!0)},setData:(l=[])=>{var s;for(let c of l){let m=(s=c.endTime)!=null?s:kh,f=e.get(m);e.set(m,{...f,[c.id]:!1})}},resetCalled:l=>{let s=e.get(l);if(s)for(let c in s)s[c]=!1},isReady:l=>{let s=e.get(l);if(!s)return!0;let c=(0,mi.default)(s);return r?c.some(f=>f):!c.some(f=>!f)},release:()=>e.clear()}}function Zt(r){return(0,Bs.default)((0,mi.default)(r)).sort(e=>e.actionType===R.expect?-1:1)}var Ds={videoContentHeight:0,videoContentWidth:0},Hs=r=>{let{height:e,width:t}=r.info.intrinsicVideoSize$.getValue()||{};if(!(e&&t))return Ds;let{clientHeight:i,clientWidth:n}=r.experimental.element$.getValue()||{};if(!(i&&n))return Ds;let o=e/t,a=i/n,l,s;return a>o?(s=n,l=n*o):a<o?(s=i/o,l=i):(s=n,l=i),{videoContentWidth:s,videoContentHeight:l}};var Ph=250;function Us(r){let e,t=new ResizeObserver(l=>{o(l),e=o.bind(null,l)});function i(l){let{parentElement:s,player:c}=r();if(s&&c){let{videoContentWidth:m,videoContentHeight:f}=Hs(c);s.style.setProperty("--interactive-content-width",`${m}px`),s.style.setProperty("--interactive-content-height",`${f}px`),s.style.setProperty("--interactive-width",`${l[0].contentRect.width}px`),s.style.setProperty("--interactive-height",`${l[0].contentRect.height}px`)}}function n(){let{parentElement:l}=r();l.removeAttribute("style")}let o=Qe(l=>{let{fns:s=[]}=r();i(l);for(let c of s)c()},Ph);function a(){e=void 0,t.disconnect(),n()}return{resizeObserver:t,calc:()=>{e==null||e()},release:a}}var Lh=r=>Math.floor(Math.random()*r),zs=r=>{var n;let e=r.length,t=1/0,i=null;for(;e--;){let o=r[e],a=(n=o.weight)!=null?n:1;a<t&&(t=a,i=o)}return i},Ws=r=>{var n;let e=r.length,t=-1/0,i=null;for(;e--;){let o=r[e],a=(n=o.weight)!=null?n:0;a>t&&(t=a,i=o)}return i};var Ks=r=>{let e=r.length,t=Lh(e);return r[t]},Gs=1,Qs=r=>{var i,n;let e=0;for(let o=0;o<r.length;++o)e+=(i=r[o].weight)!=null?i:Gs;let t=Math.random()*e;e=0;for(let o=0;o<r.length-1;++o)if(e+=(n=r[o].weight)!=null?n:Gs,e>=t)return r[o];return r[r.length-1]};var Xs={shouldOpenNow:!0,isDetachContainer:!0},Ys="after-expect",fi=(r,e=!1)=>({...r,args:e?{...r.args,...Xs}:{...Xs,...r.args}}),Zs=({globalEventEmitter:r,globalEvents:e,player:t,interactiveEvents:i})=>{let n={isExpect:!1},o=()=>{n.isExpect&&(n.isExpect=!1)},a=({action:u,controlType:p,controlId:b,containerId:I,branches:x=[],onEvent:g,isEOV:T=()=>!1,isDisabled:F=()=>!1})=>{let A=fi(u,T()),k={timestamp:1/0,priority:"control",initiator:b,actionType:A.type},P=F(),Q=r.emit.bind(r,S.interactives,{subjectId:b,subjectType:p,subjectName:"control",type:P?V.actionChoiceCanceled:V.actionChoice,actionType:u.type,payload:{invokeImmediately:A.args.shouldOpenNow,containerId:I,...A.args}}),le=()=>{e.interactiveActionChoice$.next({subjectId:b,subjectType:p,subjectName:"control",type:P?"action-choice-canceled":"action-choice",actionType:u.type,payload:{invokeImmediately:A.args.shouldOpenNow,containerId:I,...A.args}})};if(P){Q(),le();return}switch(A.type.trim().toLowerCase()){case R.setNextBranch.trim().toLowerCase():{let q=x.find(ve=>ve.id===A.args.branchId);if(!q)return;g(A.args.isDetachContainer,y.bind(null,{subjectId:b,subjectName:"control"})),Q(),le(),A.args.shouldOpenNow?E({subjectId:b,subjectName:"control",subjectType:p,action:A,payload:{chapterId:q.chapterId,autoSelect:!1}}):i.add({...k,action:E.bind(null,{subjectId:b,subjectName:"control",subjectType:p,action:A,payload:{chapterId:q.chapterId,autoSelect:!1}})});return}case R.continuePlayback.trim().toLowerCase():{g(A.args.isDetachContainer,y.bind(null,{subjectId:b,subjectName:"control"})),Q(),le(),A.args.shouldOpenNow?C({subjectId:b,subjectName:"control",subjectType:p,action:u}):i.add({...k,action:C.bind(null,{subjectId:b,subjectName:"control",subjectType:p,action:u})});return}case R.openURI.trim().toLowerCase():{g(A.args.isDetachContainer,y.bind(null,{subjectId:b,subjectName:"control"})),Q(),le(),A.args.shouldOpenNow?d({subjectId:b,subjectName:"control",subjectType:p,action:A,payload:{URI:u.args.uri}}):i.add({...k,action:d.bind(null,{subjectId:b,subjectName:"control",subjectType:p,action:A,payload:{URI:u.args.uri}})});return}default:{let q="Unexpected control event",ve=new N(1,1,{message:q});m(ve,q);return}}},l=({action:u,container:{id:p,endTime:b},branches:I=[],isEOV:x=!1,autoSelected:g=!1})=>{let T=fi(u,x),F={timestamp:!T.args.shouldOpenNow||x?1/0:b!=null?b:1/0,priority:"container",initiator:p,actionType:T.type},A=r.emit.bind(r,S.interactives,{subjectId:p,subjectName:"container",type:V.actionChoice,actionType:T.type,payload:{invokeImmediately:T.args.shouldOpenNow,...T.args}}),k=()=>{e.interactiveActionChoice$.next({subjectId:p,subjectName:"container",type:"action-choice",actionType:T.type,payload:{invokeImmediately:T.args.shouldOpenNow,...T.args}})};switch(T.type.trim().toLowerCase()){case R.setNextBranch.trim().toLowerCase():{let P=I.find(Q=>Q.id===T.args.branchId);if(!P)return;A(),k(),i.add({...F,action:E.bind(null,{subjectId:p,subjectName:"container",action:T,payload:{chapterId:P.chapterId,autoSelect:g}})});return}case R.setMaxWeightBranch.trim().toLowerCase():return;case R.setMinWeightBranch.trim().toLowerCase():return;case R.setRandomBranch.trim().toLowerCase():return;case R.setWeightlessRandomBranch.trim().toLowerCase():return;case R.continuePlayback.trim().toLowerCase():{A(),k(),i.add({...F,action:C.bind(null,{subjectId:p,subjectName:"container",action:T})});return}case R.openURI.trim().toLowerCase():{A(),k(),i.add({...F,action:d.bind(null,{subjectId:p,subjectName:"container",action:T,payload:{URI:u.args.uri}})});return}default:{let P="Unexpected container event",Q=new N(1,1,{message:P});m(Q,P);return}}};function s({container:u,branches:p,isEOV:b=!1}){var x,g;let I=Ur(u.events);if(I){let T=fi(I.action,b);r.emit(S.interactives,{subjectId:u.id,subjectName:"container",type:V.actionChoice,actionType:T.type,payload:{invokeImmediately:T.args.shouldOpenNow,...T.args}}),e.interactiveActionChoice$.next({subjectId:u.id,subjectName:"container",type:"action-choice",actionType:T.type,payload:{invokeImmediately:T.args.shouldOpenNow,...T.args}}),i.add({timestamp:b?1/0:(x=u.endTime)!=null?x:1/0,priority:"container",initiator:u.id,actionType:R.expect,action:v.bind(null,{subjectId:u.id,subjectName:"container"})}),n.isExpect=!0}else for(let T of(g=u.events)!=null?g:[])l({action:T.action,container:u,branches:p,isEOV:b})}let c=({chapterId:u,action:p,branches:b=[]})=>{let I=r.emit.bind(r,S.interactives,{subjectId:u,subjectName:"chapter",type:V.actionChoice,actionType:p.type,payload:p.args}),x=()=>{e.interactiveActionChoice$.next({subjectId:u,subjectName:"chapter",type:"action-choice",actionType:p.type,payload:p.args})};switch(p.type.trim().toLowerCase()){case R.setNextBranch.trim().toLowerCase():{let g=b.find(T=>T.id===p.args.branchId);return g!=null&&g.chapterId?(I(),x(),E.bind(null,{subjectId:u,subjectName:"chapter",action:p,payload:{chapterId:g.chapterId,autoSelect:!0}})):void 0}case R.setWeightlessRandomBranch.trim().toLowerCase():{let g=Ks(b);return g!=null&&g.chapterId?(I(),x(),E.bind(null,{subjectId:u,subjectName:"chapter",action:p,payload:{chapterId:g.chapterId,autoSelect:!0}})):void 0}case R.setRandomBranch.trim().toLowerCase():{let g=Qs(b);return g!=null&&g.chapterId?(I(),x(),E.bind(null,{subjectId:u,subjectName:"chapter",action:p,payload:{chapterId:g.chapterId,autoSelect:!0}})):void 0}case R.setMaxWeightBranch.trim().toLowerCase():{let g=Ws(b);return g!=null&&g.chapterId?(I(),x(),E.bind(null,{subjectId:u,subjectName:"chapter",action:p,payload:{chapterId:g.chapterId,autoSelect:!0}})):void 0}case R.setMinWeightBranch.trim().toLowerCase():{let g=zs(b);return g!=null&&g.chapterId?(I(),x(),E.bind(null,{subjectId:u,subjectName:"chapter",action:p,payload:{chapterId:g.chapterId,autoSelect:!0}})):void 0}case R.continuePlayback.trim().toLowerCase():return I(),x(),C.bind(null,{subjectId:u,subjectName:"chapter",action:p});case R.openURI.trim().toLowerCase():return I(),x(),d.bind(null,{subjectId:u,subjectName:"chapter",action:p,payload:{URI:p.args.uri}});default:{let g="Unexpected chapter event",T=new N(1,1,{message:g});m(T,g);return}}};function m(u,p){console.error(p),e.error$.next(u),r.emit(S.errors,u)}function f(u){var b;let p=Ur(u.events);if(p){if(Z(u))return;r.emit(S.interactives,{subjectId:u.id,subjectName:"chapter",type:V.actionChoice,actionType:p.action.type,payload:p.action.args}),e.interactiveActionChoice$.next({subjectId:u.id,subjectName:"chapter",type:"action-choice",actionType:p.action.type,payload:p.action.args}),i.add({timestamp:1/0,priority:"chapter",initiator:u.id,actionType:R.expect,action:v.bind(null,{subjectId:u.id,subjectName:"chapter"})})}else(b=u.events)==null||b.forEach(I=>{let x=c({chapterId:u.id,action:I.action,branches:u.branches});x&&i.add({timestamp:1/0,priority:"chapter",initiator:u.id,actionType:I.action.type,action:x})})}let v=({subjectId:u,subjectName:p})=>{t.pause(),r.emit(S.interactives,{subjectId:u,subjectName:p,type:V.actionExecution,actionType:R.expect}),e.interactiveActionExecution$.next({subjectId:u,subjectName:p,type:"action-execution",actionType:R.expect})},y=({subjectId:u,subjectName:p})=>{t.info.isEnded$.getValue()?i.execEndOfVideo():t.play(),r.emit(S.interactives,{subjectId:u,subjectName:p,type:V.actionExecution,actionType:Ys}),e.interactiveActionExecution$.next({subjectId:u,subjectName:p,type:"action-execution",actionType:Ys})},C=({subjectId:u,subjectName:p,subjectType:b,action:I})=>{r.emit(S.interactives,{subjectId:u,subjectName:p,subjectType:b,type:V.actionExecution,actionType:I.type}),e.interactiveActionExecution$.next({subjectId:u,subjectName:p,subjectType:b,type:"action-execution",actionType:I.type})},E=({subjectId:u,subjectName:p,subjectType:b,action:I,payload:x})=>{x.behaviour="change-chapter",r.emit(S.interactives,{subjectId:u,subjectName:p,subjectType:b,type:V.actionExecution,actionType:I.type,payload:x}),e.interactiveActionExecution$.next({subjectId:u,subjectName:p,subjectType:b,type:"action-execution",actionType:I.type,payload:x})},d=({subjectId:u,subjectName:p,subjectType:b,action:I,payload:x})=>{if(!x.URI)return;let g=window.open(x.URI,"_blank","noopener,noreferrer");g&&(g.opener=null),r.emit(S.interactives,{subjectId:u,subjectName:p,subjectType:b,type:V.actionExecution,actionType:I.type}),e.interactiveActionExecution$.next({subjectId:u,subjectName:p,subjectType:b,type:"action-execution",actionType:I.type})};return{onControlEvent:a,onContainerEvent:l,onChapterEvent:c,onExpectEvent:v,expectEventHandler:y,setManifestChapterEvents:f,setManifestContainerEvents:s,stopExpect:o,state:n}};var yi=ee(Zr(),1);import{Subscription as $h,Subject as bi,ValueSubject as ot}from"@vkontakte/videoplayer-shared/es2018";var vi=(r,e)=>{let t={};return r.map(i=>{if(!t[i]){let n=e.chapters.find(a=>a.id===i);if(!n)return null;let o=e.media.videos.find(a=>n.videoId===a.id);if(!o)return null;t[i]=Js(o)}return t[i]}).filter(Boolean)},Vh=r=>{for(let e of r.variants)if(Mh(e)&&e.payload)return e.payload.id},Mh=r=>!!(r.type==="custom"&&r.payload&&r.payload.type==="vk"),Js=r=>{let e=Vh(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},Nh=(r,e)=>{for(let t of r.media.videos)if(e===Js(t)){for(let i of r.chapters)if(i.videoId===t.id)return i.id;return}},el=(r,e)=>r.reduce((t,i)=>{let n=Nh(e,i);return n?[...t,n]:t},[]);var re,de,me,z,Jt,ie,ne,J,fe,Oe,Pe,at=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:i,historyApi:n,settings:o}){this.state={history$:new ot([]),hasPrevChapter$:new ot(!1),prevChapter$:new ot(null),isInitialChapter$:new ot(!1),isGoBackLimited$:new ot(!1)};H(this,re,null);H(this,de);H(this,me,!1);H(this,z,null);H(this,Jt,null);this.events={inited$:new bi,destroyed$:new bi,error$:new bi};H(this,ie,null);H(this,ne,null);H(this,J,null);H(this,fe,new $h);H(this,Oe,!1);H(this,Pe,0);var a;M(this,ie,t),M(this,J,e),M(this,ne,i),M(this,re,n),M(this,de,o),this.state.history$&&w(this,fe)&&((a=w(this,fe))==null||a.add(this.state.history$.subscribe(l=>{var s,c;this.state.prevChapter$.next((0,yi.default)(l,-2)||null),this.state.hasPrevChapter$.next(l.length>1),this.state.isInitialChapter$.next(this.getInitialChapterId()===((c=(s=w(this,z))==null?void 0:s.metadata)==null?void 0:c.initChapterId)),this.state.isGoBackLimited$.next(w(this,Pe)===w(this,de).maxLength-1)})))}async setManifest(e){if(!w(this,ne)||!w(this,J))return;M(this,z,e),await this.getProjectHistory();let t=this.getInitialChapterId();await w(this,ne).setChapter({chapterId:t,pushToHistory:!1}),w(this,me)||(M(this,me,!0),this.events.inited$.next({initChapterId:t}))}get inited(){return w(this,me)}async updateHistory(e,t=!0){var l;if(!w(this,z))return;w(this,Oe)?(M(this,Oe,!1),Oi(this,Pe)._++):M(this,Pe,0);let i=w(this,z),n=e.length-w(this,de).maxLength,o=n>0?e.slice(n):e,a=vi(o,i);if(M(this,Jt,a),this.state.history$.next(o),!(!t||!w(this,re)||!w(this,ie)))try{await w(this,re).save(w(this,ie),a)}catch(s){let c=new N(1,5,"Unable to save interactive history");this.events.error$.next(c),(l=w(this,J))==null||l.emit(S.errors,c)}}async goBack(){var i;if(!this.state||!w(this,ne)){let n=new N(1,5,"Unable to save interactive history");return this.events.error$.next(n),(i=w(this,J))==null?void 0:i.emit(S.errors,n)}M(this,Oe,!0);let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),await w(this,ne).setChapter({chapterId:t,playPrev:!0})}async getProjectHistory(){var n;if(!w(this,z)||!w(this,ie))return;let e=w(this,z),t=[this.getInitialVideoId()];if(w(this,re))try{let o=await w(this,re).get(w(this,ie));o.length&&(t=o)}catch(o){let a=new N(1,5,"Error while trying to fetch data");this.events.error$.next(a),(n=w(this,J))==null||n.emit(S.errors,a)}let i=el(t,e);this.state.history$.next(i)}getInitialChapterId(){var t;let e=this.state.history$.getValue();return(0,yi.default)(e,-1)||w(this,de).initChapterId||((t=w(this,z))==null?void 0:t.metadata.initChapterId)}getInitialVideoId(){if(w(this,z)){let e=this.getInitialChapterId();return vi([e],w(this,z)).pop()}return null}destroy(){var e,t;M(this,ie,null),M(this,re,null),M(this,ne,null),(e=w(this,fe))==null||e.unsubscribe(),M(this,fe,null),M(this,me,!1),(t=w(this,J))==null||t.emit(S.historyDestroyed),this.events.destroyed$.next(),M(this,J,null)}};re=new WeakMap,de=new WeakMap,me=new WeakMap,z=new WeakMap,Jt=new WeakMap,ie=new WeakMap,ne=new WeakMap,J=new WeakMap,fe=new WeakMap,Oe=new WeakMap,Pe=new WeakMap;var er=class{constructor(){this._prevSizeId=0;this.rootElement=document.createElement("canvas")}clear(){var e;(e=this.rootElement.getContext("2d"))==null||e.clearRect(0,0,this.rootElement.width,this.rootElement.height)}isImageDrawn(){var n;let e=(n=this.rootElement.getContext("2d"))==null?void 0:n.getImageData(0,0,this.rootElement.width,this.rootElement.height);if(!e)return!1;let t=e.data,i=t.length;for(let o=3;o<i;o+=40)if(t[o]!==0)return!0;return!1}destroy(){this.rootElement.remove()}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}setCanvasImageSource(e){this.canvasImgSrc=e}draw(){var e;this.canvasImgSrc&&((e=this.rootElement.getContext("2d"))==null||e.drawImage(this.canvasImgSrc,0,0,this.rootElement.width,this.rootElement.height))}async updateCanvasDimensions(e,t=!1){let i=e.width+e.height;if(this._prevSizeId===i)return;let n;t&&(n=await this.save()),this.rootElement.width=e.width,this.rootElement.height=e.height,t&&n&&this.restore(n),this._prevSizeId=i}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){var t;this.rootElement&&((t=this.rootElement.getContext("2d"))==null||t.drawImage(e,0,0,this.rootElement.width,this.rootElement.height))}};var tr=class{constructor({parentElement:e,endOffsetMs:t=250,onError:i}){this.currentVideoDurationMs=1/0;this._containerTimeFrameShouldReceived=!1;this._endTimeFrameReceived=!1;this._shouldCallSkip=!1;this.onEachTick=e=>{let t=e!=null?e:this.lastFrameCanvas.canvasImgSrc.currentTime*1e3,i=this.isChapterEndTime(t);if(this.isContainerTime(t))this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!0,this._shouldCallSkip=!0;else if(i)this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1,this._endTimeFrameReceived||(this.draw(),this._endTimeFrameReceived=!0,this.show());else{if(this._shouldCallSkip){this._shouldCallSkip=!1;return}this.reset()}};this.onSeek=()=>{this.onEachTick(),!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived&&(this.hide(),this.lastFrameCanvas.clear())};this.rootElement=document.createElement("div"),this.rootElement.style.cssText=`
|
|
7
7
|
position: absolute;
|
|
8
8
|
top: 0;
|
|
9
9
|
left: 0;
|