@vkontakte/videoplayer-interactive 1.0.41-dev.c6edef47.0 → 1.0.41-dev.d6af6ca9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es2015.cjs.js +6 -6
- package/es2015.esm.js +6 -6
- package/es2018.cjs.js +6 -6
- package/es2018.esm.js +6 -6
- package/es2024.cjs.js +6 -6
- package/es2024.esm.js +6 -6
- package/esnext.cjs.js +6 -6
- package/esnext.esm.js +6 -6
- package/evergreen.esm.js +6 -6
- package/package.json +4 -4
- package/types/modules/Interactives/Interactives.d.ts +1 -0
- package/types/modules/Interactives/Layout.d.ts +5 -2
- package/types/modules/Interactives/containers/ChoiceContainer.d.ts +4 -2
- package/types/modules/Interactives/containers/Container.d.ts +4 -2
- package/types/modules/Interactives/controls/Control.d.ts +3 -0
- package/types/modules/Interactives/controls/types.d.ts +1 -1
- package/types/modules/Interactives/index.d.ts +5 -1
- package/types/modules/Interactives/utils/ResizeManager.d.ts +2 -0
- package/types/utils/CssVarsManager.d.ts +23 -0
package/es2018.esm.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-interactive v1.0.41-dev.
|
|
3
|
-
*
|
|
2
|
+
* @vkontakte/videoplayer-interactive v1.0.41-dev.d6af6ca9.0
|
|
3
|
+
* Thu, 10 Jul 2025 10:08:50 GMT
|
|
4
4
|
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-41/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.41-dev.c6edef47.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 yl=Object.create;var ki=Object.defineProperty;var gl=Object.getOwnPropertyDescriptor;var Cl=Object.getOwnPropertyNames;var El=Object.getPrototypeOf,Tl=Object.prototype.hasOwnProperty;var Oi=r=>{throw TypeError(r)};var u=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var Il=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Cl(e))!Tl.call(r,n)&&n!==t&&ki(r,n,{get:()=>e[n],enumerable:!(i=gl(e,n))||i.enumerable});return r};var X=(r,e,t)=>(t=r!=null?yl(El(r)):{},Il(e||!r||!r.__esModule?ki(t,"default",{value:r,enumerable:!0}):t,r));var Pi=(r,e,t)=>e.has(r)||Oi("Cannot "+t);var S=(r,e,t)=>(Pi(r,e,"read from private field"),t?t.call(r):e.get(r)),H=(r,e,t)=>e.has(r)?Oi("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),F=(r,e,t,i)=>(Pi(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t);var Vi=(r,e,t,i)=>({set _(n){F(r,e,n,t)},get _(){return S(r,e,i)}});var Z=u((dr,Hi)=>{"use strict";var $e=function(r){return r&&r.Math===Math&&r};Hi.exports=$e(typeof globalThis=="object"&&globalThis)||$e(typeof window=="object"&&window)||$e(typeof self=="object"&&self)||$e(typeof global=="object"&&global)||$e(typeof dr=="object"&&dr)||function(){return this}()||Function("return this")()});var U=u((Vd,Ui)=>{"use strict";Ui.exports=function(r){try{return!!r()}catch(e){return!0}}});var Ne=u((Md,Gi)=>{"use strict";var wl=U();Gi.exports=!wl(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var Xi=u((Ld,Qi)=>{"use strict";var Rl=Ne(),Ki=Function.prototype,Wi=Ki.apply,zi=Ki.call;Qi.exports=typeof Reflect=="object"&&Reflect.apply||(Rl?zi.bind(Wi):function(){return zi.apply(Wi,arguments)})});var z=u((Fd,Ji)=>{"use strict";var Yi=Ne(),Zi=Function.prototype,mr=Zi.call,kl=Yi&&Zi.bind.bind(mr,mr);Ji.exports=Yi?kl:function(r){return function(){return mr.apply(r,arguments)}}});var _e=u(($d,tn)=>{"use strict";var en=z(),Ol=en({}.toString),Pl=en("".slice);tn.exports=function(r){return Pl(Ol(r),8,-1)}});var fr=u((Nd,rn)=>{"use strict";var Vl=_e(),Ml=z();rn.exports=function(r){if(Vl(r)==="Function")return Ml(r)}});var G=u((_d,nn)=>{"use strict";var vr=typeof document=="object"&&document.all;nn.exports=typeof vr=="undefined"&&vr!==void 0?function(r){return typeof r=="function"||r===vr}:function(r){return typeof r=="function"}});var pe=u((jd,on)=>{"use strict";var Ll=U();on.exports=!Ll(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var Ct=u((Bd,sn)=>{"use strict";var Fl=Ne(),gt=Function.prototype.call;sn.exports=Fl?gt.bind(gt):function(){return gt.apply(gt,arguments)}});var br=u(cn=>{"use strict";var an={}.propertyIsEnumerable,ln=Object.getOwnPropertyDescriptor,$l=ln&&!an.call({1:2},1);cn.f=$l?function(e){var t=ln(this,e);return!!t&&t.enumerable}:an});var yr=u((Dd,un)=>{"use strict";un.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var hn=u((Hd,pn)=>{"use strict";var Nl=z(),_l=U(),jl=_e(),gr=Object,Bl=Nl("".split);pn.exports=_l(function(){return!gr("z").propertyIsEnumerable(0)})?function(r){return jl(r)==="String"?Bl(r,""):gr(r)}:gr});var Cr=u((Ud,dn)=>{"use strict";dn.exports=function(r){return r==null}});var Er=u((Gd,mn)=>{"use strict";var ql=Cr(),Dl=TypeError;mn.exports=function(r){if(ql(r))throw new Dl("Can't call method on "+r);return r}});var je=u((Wd,fn)=>{"use strict";var Hl=hn(),Ul=Er();fn.exports=function(r){return Hl(Ul(r))}});var Ee=u((zd,vn)=>{"use strict";var Gl=G();vn.exports=function(r){return typeof r=="object"?r!==null:Gl(r)}});var Be=u((Kd,bn)=>{"use strict";bn.exports={}});var Et=u((Qd,gn)=>{"use strict";var Tr=Be(),Ir=Z(),Wl=G(),yn=function(r){return Wl(r)?r:void 0};gn.exports=function(r,e){return arguments.length<2?yn(Tr[r])||yn(Ir[r]):Tr[r]&&Tr[r][e]||Ir[r]&&Ir[r][e]}});var En=u((Xd,Cn)=>{"use strict";var zl=z();Cn.exports=zl({}.isPrototypeOf)});var An=u((Yd,xn)=>{"use strict";var Kl=Z(),Tn=Kl.navigator,In=Tn&&Tn.userAgent;xn.exports=In?String(In):""});var Vn=u((Zd,Pn)=>{"use strict";var On=Z(),xr=An(),Sn=On.process,wn=On.Deno,Rn=Sn&&Sn.versions||wn&&wn.version,kn=Rn&&Rn.v8,K,Tt;kn&&(K=kn.split("."),Tt=K[0]>0&&K[0]<4?1:+(K[0]+K[1]));!Tt&&xr&&(K=xr.match(/Edge\/(\d+)/),(!K||K[1]>=74)&&(K=xr.match(/Chrome\/(\d+)/),K&&(Tt=+K[1])));Pn.exports=Tt});var Ar=u((Jd,Ln)=>{"use strict";var Mn=Vn(),Ql=U(),Xl=Z(),Yl=Xl.String;Ln.exports=!!Object.getOwnPropertySymbols&&!Ql(function(){var r=Symbol("symbol detection");return!Yl(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&Mn&&Mn<41})});var Sr=u((em,Fn)=>{"use strict";var Zl=Ar();Fn.exports=Zl&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var wr=u((tm,$n)=>{"use strict";var Jl=Et(),ec=G(),tc=En(),rc=Sr(),ic=Object;$n.exports=rc?function(r){return typeof r=="symbol"}:function(r){var e=Jl("Symbol");return ec(e)&&tc(e.prototype,ic(r))}});var _n=u((rm,Nn)=>{"use strict";var nc=String;Nn.exports=function(r){try{return nc(r)}catch(e){return"Object"}}});var Rr=u((im,jn)=>{"use strict";var oc=G(),sc=_n(),ac=TypeError;jn.exports=function(r){if(oc(r))return r;throw new ac(sc(r)+" is not a function")}});var qn=u((nm,Bn)=>{"use strict";var lc=Rr(),cc=Cr();Bn.exports=function(r,e){var t=r[e];return cc(t)?void 0:lc(t)}});var Hn=u((om,Dn)=>{"use strict";var kr=Ct(),Or=G(),Pr=Ee(),uc=TypeError;Dn.exports=function(r,e){var t,i;if(e==="string"&&Or(t=r.toString)&&!Pr(i=kr(t,r))||Or(t=r.valueOf)&&!Pr(i=kr(t,r))||e!=="string"&&Or(t=r.toString)&&!Pr(i=kr(t,r)))return i;throw new uc("Can't convert object to primitive value")}});var Gn=u((sm,Un)=>{"use strict";Un.exports=!0});var Kn=u((am,zn)=>{"use strict";var Wn=Z(),pc=Object.defineProperty;zn.exports=function(r,e){try{pc(Wn,r,{value:e,configurable:!0,writable:!0})}catch(t){Wn[r]=e}return e}});var It=u((lm,Yn)=>{"use strict";var hc=Gn(),dc=Z(),mc=Kn(),Qn="__core-js_shared__",Xn=Yn.exports=dc[Qn]||mc(Qn,{});(Xn.versions||(Xn.versions=[])).push({version:"3.38.0",mode:hc?"pure":"global",copyright:"\xA9 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.38.0/LICENSE",source:"https://github.com/zloirock/core-js"})});var Vr=u((cm,Jn)=>{"use strict";var Zn=It();Jn.exports=function(r,e){return Zn[r]||(Zn[r]=e||{})}});var qe=u((um,eo)=>{"use strict";var fc=Er(),vc=Object;eo.exports=function(r){return vc(fc(r))}});var Te=u((pm,to)=>{"use strict";var bc=z(),yc=qe(),gc=bc({}.hasOwnProperty);to.exports=Object.hasOwn||function(e,t){return gc(yc(e),t)}});var Mr=u((hm,ro)=>{"use strict";var Cc=z(),Ec=0,Tc=Math.random(),Ic=Cc(1 .toString);ro.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+Ic(++Ec+Tc,36)}});var De=u((dm,no)=>{"use strict";var xc=Z(),Ac=Vr(),io=Te(),Sc=Mr(),wc=Ar(),Rc=Sr(),Ie=xc.Symbol,Lr=Ac("wks"),kc=Rc?Ie.for||Ie:Ie&&Ie.withoutSetter||Sc;no.exports=function(r){return io(Lr,r)||(Lr[r]=wc&&io(Ie,r)?Ie[r]:kc("Symbol."+r)),Lr[r]}});var lo=u((mm,ao)=>{"use strict";var Oc=Ct(),oo=Ee(),so=wr(),Pc=qn(),Vc=Hn(),Mc=De(),Lc=TypeError,Fc=Mc("toPrimitive");ao.exports=function(r,e){if(!oo(r)||so(r))return r;var t=Pc(r,Fc),i;if(t){if(e===void 0&&(e="default"),i=Oc(t,r,e),!oo(i)||so(i))return i;throw new Lc("Can't convert object to primitive value")}return e===void 0&&(e="number"),Vc(r,e)}});var Fr=u((fm,co)=>{"use strict";var $c=lo(),Nc=wr();co.exports=function(r){var e=$c(r,"string");return Nc(e)?e:e+""}});var ho=u((vm,po)=>{"use strict";var _c=Z(),uo=Ee(),$r=_c.document,jc=uo($r)&&uo($r.createElement);po.exports=function(r){return jc?$r.createElement(r):{}}});var Nr=u((bm,mo)=>{"use strict";var Bc=pe(),qc=U(),Dc=ho();mo.exports=!Bc&&!qc(function(){return Object.defineProperty(Dc("div"),"a",{get:function(){return 7}}).a!==7})});var bo=u(vo=>{"use strict";var Hc=pe(),Uc=Ct(),Gc=br(),Wc=yr(),zc=je(),Kc=Fr(),Qc=Te(),Xc=Nr(),fo=Object.getOwnPropertyDescriptor;vo.f=Hc?fo:function(e,t){if(e=zc(e),t=Kc(t),Xc)try{return fo(e,t)}catch(i){}if(Qc(e,t))return Wc(!Uc(Gc.f,e,t),e[t])}});var go=u((gm,yo)=>{"use strict";var Yc=U(),Zc=G(),Jc=/#|\.prototype\./,He=function(r,e){var t=tu[eu(r)];return t===iu?!0:t===ru?!1:Zc(e)?Yc(e):!!e},eu=He.normalize=function(r){return String(r).replace(Jc,".").toLowerCase()},tu=He.data={},ru=He.NATIVE="N",iu=He.POLYFILL="P";yo.exports=He});var _r=u((Cm,Eo)=>{"use strict";var Co=fr(),nu=Rr(),ou=Ne(),su=Co(Co.bind);Eo.exports=function(r,e){return nu(r),e===void 0?r:ou?su(r,e):function(){return r.apply(e,arguments)}}});var Io=u((Em,To)=>{"use strict";var au=pe(),lu=U();To.exports=au&&lu(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var Ao=u((Tm,xo)=>{"use strict";var cu=Ee(),uu=String,pu=TypeError;xo.exports=function(r){if(cu(r))return r;throw new pu(uu(r)+" is not an object")}});var Ro=u(wo=>{"use strict";var hu=pe(),du=Nr(),mu=Io(),xt=Ao(),So=Fr(),fu=TypeError,jr=Object.defineProperty,vu=Object.getOwnPropertyDescriptor,Br="enumerable",qr="configurable",Dr="writable";wo.f=hu?mu?function(e,t,i){if(xt(e),t=So(t),xt(i),typeof e=="function"&&t==="prototype"&&"value"in i&&Dr in i&&!i[Dr]){var n=vu(e,t);n&&n[Dr]&&(e[t]=i.value,i={configurable:qr in i?i[qr]:n[qr],enumerable:Br in i?i[Br]:n[Br],writable:!1})}return jr(e,t,i)}:jr:function(e,t,i){if(xt(e),t=So(t),xt(i),du)try{return jr(e,t,i)}catch(n){}if("get"in i||"set"in i)throw new fu("Accessors not supported");return"value"in i&&(e[t]=i.value),e}});var Oo=u((xm,ko)=>{"use strict";var bu=pe(),yu=Ro(),gu=yr();ko.exports=bu?function(r,e,t){return yu.f(r,e,gu(1,t))}:function(r,e,t){return r[e]=t,r}});var Se=u((Am,Vo)=>{"use strict";var Ue=Z(),Cu=Xi(),Eu=fr(),Tu=G(),Iu=bo().f,xu=go(),xe=Be(),Au=_r(),Ae=Oo(),Po=Te();It();var Su=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 Cu(r,this,arguments)};return e.prototype=r.prototype,e};Vo.exports=function(r,e){var t=r.target,i=r.global,n=r.stat,o=r.proto,a=i?Ue:n?Ue[t]:Ue[t]&&Ue[t].prototype,s=i?xe:xe[t]||Ae(xe,t,{})[t],l=s.prototype,c,d,f,v,y,C,E,m,p;for(v in e)c=xu(i?v:t+(n?".":"#")+v,r.forced),d=!c&&a&&Po(a,v),C=s[v],d&&(r.dontCallGetSet?(p=Iu(a,v),E=p&&p.value):E=a[v]),y=d&&E?E:e[v],!(!c&&!o&&typeof C==typeof y)&&(r.bind&&d?m=Au(y,Ue):r.wrap&&d?m=Su(y):o&&Tu(y)?m=Eu(y):m=y,(r.sham||y&&y.sham||C&&C.sham)&&Ae(m,"sham",!0),Ae(s,v,m),o&&(f=t+"Prototype",Po(xe,f)||Ae(xe,f,{}),Ae(xe[f],v,y),r.real&&l&&(c||!l[v])&&Ae(l,v,y)))}});var Lo=u((Sm,Mo)=>{"use strict";var wu=Math.ceil,Ru=Math.floor;Mo.exports=Math.trunc||function(e){var t=+e;return(t>0?Ru:wu)(t)}});var Ge=u((wm,Fo)=>{"use strict";var ku=Lo();Fo.exports=function(r){var e=+r;return e!==e||e===0?0:ku(e)}});var No=u((Rm,$o)=>{"use strict";var Ou=Ge(),Pu=Math.max,Vu=Math.min;$o.exports=function(r,e){var t=Ou(r);return t<0?Pu(t+e,0):Vu(t,e)}});var jo=u((km,_o)=>{"use strict";var Mu=Ge(),Lu=Math.min;_o.exports=function(r){var e=Mu(r);return e>0?Lu(e,9007199254740991):0}});var We=u((Om,Bo)=>{"use strict";var Fu=jo();Bo.exports=function(r){return Fu(r.length)}});var Hr=u((Pm,Do)=>{"use strict";var $u=je(),Nu=No(),_u=We(),qo=function(r){return function(e,t,i){var n=$u(e),o=_u(n);if(o===0)return!r&&-1;var a=Nu(i,o),s;if(r&&t!==t){for(;o>a;)if(s=n[a++],s!==s)return!0}else for(;o>a;a++)if((r||a in n)&&n[a]===t)return r||a||0;return!r&&-1}};Do.exports={includes:qo(!0),indexOf:qo(!1)}});var At=u((Vm,Ho)=>{"use strict";Ho.exports=function(){}});var Uo=u(()=>{"use strict";var ju=Se(),Bu=Hr().includes,qu=U(),Du=At(),Hu=qu(function(){return!Array(1).includes()});ju({target:"Array",proto:!0,forced:Hu},{includes:function(e){return Bu(this,e,arguments.length>1?arguments[1]:void 0)}});Du("includes")});var St=u((Fm,Go)=>{"use strict";var Uu=Et();Go.exports=Uu});var zo=u(($m,Wo)=>{"use strict";Uo();var Gu=St();Wo.exports=Gu("Array","includes")});var Qo=u((Nm,Ko)=>{"use strict";var Wu=zo();Ko.exports=Wu});var wt=u((_m,Xo)=>{"use strict";var zu=Qo();Xo.exports=zu});var vs=u(()=>{"use strict";var tp=Se(),rp=qe(),ip=We(),np=Ge(),op=At();tp({target:"Array",proto:!0},{at:function(e){var t=rp(this),i=ip(t),n=np(e),o=n>=0?n:i+n;return o<0||o>=i?void 0:t[o]}});op("at")});var ys=u((fv,bs)=>{"use strict";vs();var sp=St();bs.exports=sp("Array","at")});var Cs=u((vv,gs)=>{"use strict";var ap=ys();gs.exports=ap});var Jr=u((bv,Es)=>{"use strict";var lp=Cs();Es.exports=lp});var ws=u((Lv,Ss)=>{"use strict";var pp=Vr(),hp=Mr(),As=pp("keys");Ss.exports=function(r){return As[r]||(As[r]=hp(r))}});var ks=u((Fv,Rs)=>{"use strict";var dp=U();Rs.exports=!dp(function(){function r(){}return r.prototype.constructor=null,Object.getPrototypeOf(new r)!==r.prototype})});var Vs=u(($v,Ps)=>{"use strict";var mp=Te(),fp=G(),vp=qe(),bp=ws(),yp=ks(),Os=bp("IE_PROTO"),ei=Object,gp=ei.prototype;Ps.exports=yp?ei.getPrototypeOf:function(r){var e=vp(r);if(mp(e,Os))return e[Os];var t=e.constructor;return fp(t)&&e instanceof t?t.prototype:e instanceof ei?gp:null}});var Ls=u((Nv,Ms)=>{"use strict";Ms.exports={}});var Ns=u((_v,$s)=>{"use strict";var Cp=z(),ti=Te(),Ep=je(),Tp=Hr().indexOf,Ip=Ls(),Fs=Cp([].push);$s.exports=function(r,e){var t=Ep(r),i=0,n=[],o;for(o in t)!ti(Ip,o)&&ti(t,o)&&Fs(n,o);for(;e.length>i;)ti(t,o=e[i++])&&(~Tp(n,o)||Fs(n,o));return n}});var js=u((jv,_s)=>{"use strict";_s.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var qs=u((Bv,Bs)=>{"use strict";var xp=Ns(),Ap=js();Bs.exports=Object.keys||function(e){return xp(e,Ap)}});var ri=u((qv,Ws)=>{"use strict";var Hs=pe(),Sp=U(),Us=z(),wp=Vs(),Rp=qs(),kp=je(),Op=br().f,Gs=Us(Op),Pp=Us([].push),Vp=Hs&&Sp(function(){var r=Object.create(null);return r[2]=2,!Gs(r,2)}),Ds=function(r){return function(e){for(var t=kp(e),i=Rp(t),n=Vp&&wp(t)===null,o=i.length,a=0,s=[],l;o>a;)l=i[a++],(!Hs||(n?l in t:Gs(t,l)))&&Pp(s,r?[l,t[l]]:t[l]);return s}};Ws.exports={entries:Ds(!0),values:Ds(!1)}});var zs=u(()=>{"use strict";var Mp=Se(),Lp=ri().entries;Mp({target:"Object",stat:!0},{entries:function(e){return Lp(e)}})});var Qs=u((Uv,Ks)=>{"use strict";zs();var Fp=Be();Ks.exports=Fp.Object.entries});var Ys=u((Gv,Xs)=>{"use strict";var $p=Qs();Xs.exports=$p});var Js=u((Wv,Zs)=>{"use strict";var Np=Ys();Zs.exports=Np});var ia=u(()=>{"use strict";var Gp=Se(),Wp=ri().values;Gp({target:"Object",stat:!0},{values:function(e){return Wp(e)}})});var oa=u((Eb,na)=>{"use strict";ia();var zp=Be();na.exports=zp.Object.values});var aa=u((Tb,sa)=>{"use strict";var Kp=oa();sa.exports=Kp});var Xt=u((Ib,la)=>{"use strict";var Qp=aa();la.exports=Qp});var di=u((zb,ma)=>{"use strict";var th=_e();ma.exports=Array.isArray||function(e){return th(e)==="Array"}});var va=u((Kb,fa)=>{"use strict";var rh=TypeError,ih=9007199254740991;fa.exports=function(r){if(r>ih)throw rh("Maximum allowed index exceeded");return r}});var ga=u((Qb,ya)=>{"use strict";var nh=di(),oh=We(),sh=va(),ah=_r(),ba=function(r,e,t,i,n,o,a,s){for(var l=n,c=0,d=a?ah(a,s):!1,f,v;c<i;)c in t&&(f=d?d(t[c],c,e):t[c],o>0&&nh(f)?(v=oh(f),l=ba(r,e,f,v,l,o-1)-1):(sh(l+1),r[l]=f),l++),c++;return l};ya.exports=ba});var Ta=u((Xb,Ea)=>{"use strict";var lh=De(),ch=lh("toStringTag"),Ca={};Ca[ch]="z";Ea.exports=String(Ca)==="[object z]"});var xa=u((Yb,Ia)=>{"use strict";var uh=Ta(),ph=G(),Zt=_e(),hh=De(),dh=hh("toStringTag"),mh=Object,fh=Zt(function(){return arguments}())==="Arguments",vh=function(r,e){try{return r[e]}catch(t){}};Ia.exports=uh?Zt:function(r){var e,t,i;return r===void 0?"Undefined":r===null?"Null":typeof(t=vh(e=mh(r),dh))=="string"?t:fh?Zt(e):(i=Zt(e))==="Object"&&ph(e.callee)?"Arguments":i}});var Sa=u((Zb,Aa)=>{"use strict";var bh=z(),yh=G(),mi=It(),gh=bh(Function.toString);yh(mi.inspectSource)||(mi.inspectSource=function(r){return gh(r)});Aa.exports=mi.inspectSource});var Va=u((Jb,Pa)=>{"use strict";var Ch=z(),Eh=U(),wa=G(),Th=xa(),Ih=Et(),xh=Sa(),Ra=function(){},ka=Ih("Reflect","construct"),fi=/^\s*(?:class|function)\b/,Ah=Ch(fi.exec),Sh=!fi.test(Ra),ot=function(e){if(!wa(e))return!1;try{return ka(Ra,[],e),!0}catch(t){return!1}},Oa=function(e){if(!wa(e))return!1;switch(Th(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Sh||!!Ah(fi,xh(e))}catch(t){return!0}};Oa.sham=!0;Pa.exports=!ka||Eh(function(){var r;return ot(ot.call)||!ot(Object)||!ot(function(){r=!0})||r})?Oa:ot});var $a=u((ey,Fa)=>{"use strict";var Ma=di(),wh=Va(),Rh=Ee(),kh=De(),Oh=kh("species"),La=Array;Fa.exports=function(r){var e;return Ma(r)&&(e=r.constructor,wh(e)&&(e===La||Ma(e.prototype))?e=void 0:Rh(e)&&(e=e[Oh],e===null&&(e=void 0))),e===void 0?La:e}});var _a=u((ty,Na)=>{"use strict";var Ph=$a();Na.exports=function(r,e){return new(Ph(r))(e===0?0:e)}});var ja=u(()=>{"use strict";var Vh=Se(),Mh=ga(),Lh=qe(),Fh=We(),$h=Ge(),Nh=_a();Vh({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=Lh(this),i=Fh(t),n=Nh(t,0);return n.length=Mh(n,t,t,i,0,e===void 0?1:$h(e)),n}})});var Ba=u(()=>{"use strict";var _h=At();_h("flat")});var Da=u((sy,qa)=>{"use strict";ja();Ba();var jh=St();qa.exports=jh("Array","flat")});var Ua=u((ay,Ha)=>{"use strict";var Bh=Da();Ha.exports=Bh});var Wa=u((ly,Ga)=>{"use strict";var qh=Ua();Ga.exports=qh});var Mi="1.0.41-dev.d6af6ca9.0";import{fromEvent as fs,Subscription as ep}from"@vkontakte/videoplayer-shared/es2018";var or=class{constructor(e,t){this.layout=e;this.cssVarsManager=t}},ut=class extends or{constructor(t,i){super(t,i);this.cssVarsManager=i;this.cssVarsManager=i}setContainerLayout(t){t.style.position="relative"}setControlLayout(t,i){let n=this.cssVarsManager.getPropValue("--interactive-content-width"),o=this.cssVarsManager.getPropValue("--interactive-content-height"),a=this.cssVarsManager.getPropValue("--interactive-width"),s=this.cssVarsManager.getPropValue("--interactive-height"),l=2e-4;t.style.position="absolute",t.style.width=`calc(${n} * (${i.width} + ${l}))`,t.style.height=`calc(${o} * ${i.height})`,t.style.left=`calc(${n} * ${i.x} + ((${a} - ${n}) / 2))`,t.style.top=`calc(${o} * ${i.y} + ((${s} - ${o}) / 2))`}};import{Subject as xl}from"@vkontakte/videoplayer-shared/es2018";function Li(r){return"features"in r}var $=class{constructor(e,t,...i){this.severity=e;this.category=t;this.data=i}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};function pt({emitter$:r,error:e,subjectId:t,message:i="",severity:n=1,category:o=1}){let a=new $(n,o,{message:i,error:e,details:{id:t}});r.next(a)}var ye=class{constructor(e,t,i){this.error$=new xl;this.container=e,this.options=i,this.factories=new Map,this.controls=[],this.setControls(),this.cssVarsManager=t}featureIsEnabled(e){return this.options&&this.options.features&&Li(this.options)&&this.options.features[e]}onError(e="",t){pt({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 Ke,once as os}from"@vkontakte/videoplayer-shared/es2018";var oe=(r,e)=>Object.prototype.toString.call(r)===`[object ${e}]`,se=r=>oe(r,"Object"),ht=r=>oe(r,"String"),dt=r=>oe(r,"Array"),mt=r=>oe(r,"Number"),Fi=r=>oe(r,"Function"),$i=r=>oe(r,"Boolean"),lr=r=>mt(r)&&!isNaN(r);var ce=r=>se(r)&&Object.keys(r).length===0,cr=r=>dt(r)&&!r.length;var Me=(r,e)=>ht(r)&&(e?r.trim():r).length;function Le(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 Ni="interactive",V={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},_i=(i=>(i.top="flex-start",i.bottom="flex-end",i.center="center",i))(_i||{}),ji=(i=>(i.start="flex-start",i.end="flex-end",i.center="center",i))(ji||{}),Bi=(i=>(i.start="left",i.end="right",i.center="center",i))(Bi||{}),ft=({target:r,props:e})=>{var t,i,n;r.style.alignItems=(t=(e==null?void 0:e.gravityVertical)&&_i[e.gravityVertical])!=null?t:"center",r.style.justifyContent=(i=(e==null?void 0:e.gravityHorizontal)&&ji[e.gravityHorizontal])!=null?i:"center",r.style.textAlign=(n=(e==null?void 0:e.alignment)&&Bi[e.alignment])!=null?n:"center"},vt=({target:r,props:e,fallback:t,dependsOn:i})=>{var n,o,a,s,l,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} * ${(s=(a=e==null?void 0:e.text)==null?void 0:a.size)!=null?s:t.textSize})`,r.textContent=(c=(l=e==null?void 0:e.text)==null?void 0:l.value)!=null?c:t.textContent},bt=({target:r,props:e,fallback:t})=>{var i,n,o,a;r.style.backgroundColor=Le((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)},Fe=({target:r,props:e,fallback:t,dependsOn:i,useRawValues:n=!1})=>{var s,l,c,d,f,v,y,C,E,m,p;let o=n?t.borderWidthRawValue:`calc(${i.height} * ${(c=(l=(s=e==null?void 0:e.shape)==null?void 0:s.border)==null?void 0:l.width)!=null?c:t.borderWidth})`,a=n?t.roundCornersRawValue:`calc(${i.height} * ${(f=(d=e==null?void 0:e.shape)==null?void 0:d.roundCorners)!=null?f:t.roundCorners})`;r.style.borderWidth=o,r.style.borderStyle="solid",r.style.borderColor=Le(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:(p=(m=(E=e==null?void 0:e.shape)==null?void 0:E.border)==null?void 0:m.alpha)!=null?p:t.borderAlpha),r.style.borderRadius=a},qi=({target:r,isDark:e,baseDimension:t,fallback:i})=>{let a=Le(i.shadowColorLight,i.shadowColorAlpha),s=Le(i.shadowColorDark,i.shadowColorAlpha),l=`calc(${t} * ${.25})`,c=`calc(${t} * ${.11})`,d=`0px 0px ${l} ${c} ${e?s:a}`;r.style.boxShadow=d},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 Qu,Subscription as Xu}from"@vkontakte/videoplayer-shared/es2018";var ur="interactive-control-tap",Ce={common:ur,animation:`${ur}-animation`,visible:`${ur}-visible`};var Al=60,yt=class{constructor({controlRotateAngleRad:e,clickCancelCondition:t,circleDiameterPx:i=Al,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,s=i.top+i.height/2,l=e.clientX-a,c=e.clientY-s,d=Sl(l,c,this.controlRotateAngleRad);this.element.style.width=o+"px",this.element.style.left=d.x+i.width/2-o/2+"px",this.element.style.top=d.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 Sl(r,e,t){return{x:r*Math.cos(t)-e*Math.sin(t),y:r*Math.sin(t)+e*Math.cos(t)}}var pr="int",ue=(i=>(i.AREA=`${pr}_area`,i.TEXT=`${pr}_text`,i.BUTTON=`${pr}_bttn`,i))(ue||{});function hr(r){return"features"in r}var Y="interactive-control",O={common:Y,selected:`${Y}-selected`,wrapper:`${Y}-wrapper`,disabled:`${Y}-disabled`,button:`${Y}-button`,area:`${Y}-area`,text:`${Y}-text`,blinkAnim:`${Y}-blink-anim`,blinkAnimButton:`${Y}-blink-anim-button`,blinkAnimArea:`${Y}-blink-anim-area`},Di=40;var es=X(wt(),1);import{isSupportedManifest as kt,ContainerTypes as Ym,ControlTypes as Ot,EventActionTypes as R,EventTypes as Zm,migrateManifestToLatestVersion as Jo,compareVersions as Jm}from"@interactiveplatform/movika-manifest";var Yo={metadata:"Object",chapters:"Array"},Zo=r=>{if(!se(r))return!1;for(let e in Yo)if(!r[e]||!oe(r[e],Yo[e]))return!1;return kt(r.metadata.version)},Rt=r=>r.type===Ot.Text,Dm=r=>r.type===Ot.Button,Hm=r=>r.type===Ot.Area,Um={Choice:"Choice",TextInput:"TextInput"},Gm={Button:"Button",Area:"Area",Text:"Text"},Wm={onClick:"onClick",onSuspense:"onSuspense"},zm={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var Pt=r=>dt(r)&&!cr(r),J=r=>r.order==="end",Vt=r=>dt(r.containers)&&!cr(r.containers)&&J(r),ts=(r,e)=>{var i;let t=r*1e3;return Pt(e.controls)&&t<((i=e.startTime)!=null?i:0)},Ur=(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"),Gr=(r=[])=>r.find(e=>e.action.type==="expect"),Ku=r=>(r==null?void 0:r.length)===1,we=r=>Ku(r)&&Rt(r[0]);function rs(r=[],e=1/0,t=[]){return r.filter(({container:i})=>!(0,es.default)(t,i.container.id)&&he(i.container.events)&&i.container.endTime===e&&!i.isRemoved&&!i.willRemoved)}function Mt({gameControllers:r=[],subjectName:e,subjectId:t,execFn:i}){for(let n of r)if(e==="container"&&n.container.container.id===t){i(n),rs(r,n.container.container.endTime,[n.container.container.id]).forEach(a=>{i(a)});break}}function is(r){for(let e of r.events)if(e.action.type==="openURI")return!0;return!1}var ns=(r,e)=>{let t=E=>{let m=e.find(({container:p})=>p.container.id===E);return m==null?void 0:m.container.isRemoved},i=he(r.events)&&!t(r.id),n=(E,m=!1,p=!1)=>{let h=p?"every":"some";return E.controls[h](b=>{var x;let I=m?E.endTime===r.endTime:!0;return((x=b.events)==null?void 0:x[h](g=>{var T;return((T=g.action)==null?void 0:T.type)===R.openURI}))&&I})},o=E=>E.some(({container:m})=>n(m.container,!0,!1)&&!m.isRemoved),a=E=>E.every(({container:m})=>m.isRemoved||m.willRemoved?!0:n(m.container,!0,!0)),s=rs(e,r.endTime,[r.id]).length,l=E=>E.controls.some(m=>{var p;return(p=m.events)==null?void 0:p.some(h=>{var b,I;return(I=(b=h.action)==null?void 0:b.args)==null?void 0:I.shouldOpenNow})}),c=i||s>0,d=o(e),f=n(r),v=a(e),y=i?!1:s>0,C=l(r);return{isExpectTime:c,hasOtherExpect:s>0,hasOpenURIEvent:d,hasOpenURIEventInCurrentContainer:f,isAllOpenURIEventsValid:v,isExpectEventForCurrentContainer:y,hasShouldOpenNowEvent:C}};var ae=class r{constructor(e,t){this.control=e;this.options=t;this.container=null;this.controlElement=null;this.subscriptions=new Xu;this.error$=new Qu;this.isInteracted=!1;this.isRemoved=!1;this.cssVarsManager=null;this.onControlSelect=()=>{var e,t,i;(e=this.container)!=null&&e.isManifestContainerDisabled()||is(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()}}setCssVarsManager(e){this.cssVarsManager=e}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){pt({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:V.angle;this.controlTap=new yt({controlRotateAngleRad:i,clickCancelCondition:this.container.isManifestContainerDisabled,circleDiameterPx:this.isTouch()?Di: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,a,s,l,c;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:V.innerSizesDependOn)==="self"?{height:t.style.height,width:t.style.width}:{height:(s=(a=this.cssVarsManager)==null?void 0:a.getPropValue("--interactive-content-height)"))!=null?s:0,width:(c=(l=this.cssVarsManager)==null?void 0:l.getPropValue("--interactive-content-width"))!=null?c:0},n=()=>{var d,f;return(f=(d=e.isContainerDisabled)==null?void 0:d.call(e))!=null?f:!1};this.container={element:t,dimensions:i,isManifestContainerDisabled:n}}createClickListener(e){return t=>{t.stopPropagation(),this.isInteracted=!0,e()}}featureIsEnabled(e){return this.options&&hr(this.options)&&this.options.features[e]}isTouch(){return this.options&&hr(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 Wr="interactive-blink-anim-reference",N={common:Wr,animation:`${Wr}-animation`,disabled:`${Wr}-disabled`},Lt=class{constructor(){this._RAFId=0;this._element=void 0}get element(){return this._element}create(){if(this._element)return;let e=document.createElement("div");e.classList.add(N.common,N.animation),this._element=e}restart(){this._element&&(this._element.classList.add(N.disabled),this.cleanupRAF(),this._RAFId=requestAnimationFrame(()=>{this._element&&(this._element.classList.remove(N.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 Ft=(r,e)=>{if(r.type.trim().toLowerCase()==="area")return new Kr(r,e)},Kr=class extends ae{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),bt({target:i,props:this.control.props,fallback:{...V,backgroundColor:"transparent"}}),ge({target:i,layoutParams:this.control.layoutParams,fallback:V}),this.addControlTap(i),this.subscriptions.add(Ke(this.container.element,"click").pipe(os()).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(Ke(this.controlElement,"mouseleave").subscribe(()=>{if(e.classList.contains(_.disabled))return;let i=e.parentElement;if(i){let n=i.querySelector(`.${N.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}updateShadowStyles(e){var t,i,n;if(!(!this.container||!this.controlElement))if($i(e)){let o=Math.min(this.controlElement.offsetWidth,this.controlElement.offsetHeight)+"px";qi({target:this.controlElement,props:this.control.props,fallback:V,isDark:e,baseDimension:o}),Fe({target:this.controlElement,props:this.control.props,fallback:{...V,borderColor:e?V.shadowColorDark:V.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:V.roundCorners})`},dependsOn:this.container.dimensions,useRawValues:!0})}else Fe({target:this.controlElement,props:this.control.props,fallback:{...V,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(N.disabled)||(this.controlElement.classList.add(N.disabled),this.subscriptions.add(Ke(e,"animationiteration").pipe(os()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(N.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 Qe,once as ds}from"@vkontakte/videoplayer-shared/es2018";var $t=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 Nt=Math.PI,Qr=2*Nt,_t=Nt/2,ss=3*_t,Yu=0,Zu=[Yu,_t,Nt,ss];function as(r){return r===_t}function ls(r){return r===Nt}function cs(r){return r===ss}function us(r){return(r%Qr+Qr)%Qr}function Ju(r){for(let e of Zu)if(r===e)return e}function ps(r){if(Ju(r))return null;let t=Math.floor(r/_t)+1;return[1,2,3,4][t-1]}function hs(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 m;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=us(e.rotateAngle),a=ps(o),s=a!==null,c=a===2||!s&&ls(o)||a===3,d=!s&&as(o),f=!s&&cs(o),v=!c&&!d&&!f,y=d||f,C=s&&!y,E=C?o:0;t.style.borderRadius=e.borderRadius,i.style.transform=`skew(${E*-1}rad)`,y?(n.classList.add(j.fillHeight,d?j.fromTop:j.fromBottom),i.classList.add(j.fillHeight,d?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:hs(o),rotateAngleRaw:e.rotateAngle,fromRight:c,fromTop:d,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=(m=e.debug)!=null?m:!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 Xr(r,e)},Xr=class extends ae{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){var a,s,l,c,d,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:V}),bt({target:i,props:this.control.props,fallback:V}),Fe({target:i,props:this.control.props,fallback:V,dependsOn:this.container.dimensions}),ft({target:i,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let n=$t(this.control.type.trim().toLowerCase()),o=(a=n.firstElementChild)!=null?a:n;vt({target:o,props:this.control.props,fallback:V,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:(s=this.control.layoutParams.angle)!=null?s:V.angle,borderRadius:i.style.borderRadius})),this.subscriptions.add(Qe(i,"click").pipe(ds()).subscribe(this.onControlSelect,v=>this.onError("Control click handler error",v))),i.append(n,(c=(l=this.controlFillAnimation)==null?void 0:l.fillAnimationElement)!=null?c:""),this.container.element.append((f=(d=this.controlTap)==null?void 0:d.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(Qe(this.controlElement,"mouseleave").subscribe(()=>{if(e.classList.contains(_.disabled))return;let i=e.parentElement;if(i){let n=i.querySelector(`.${N.common}`);n&&this.syncBlinkAnimation(n)}},i=>this.onError("Error happened in mouseleave callback",i))),this.subscriptions.add(Qe(this.controlElement,"mouseenter").subscribe(()=>{e.classList.contains(_.disabled)||this.onBlinkHovering()},i=>this.onError("Error happened in mouseenter callback",i))).add(Qe(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(N.disabled)||(this.controlElement.classList.add(N.disabled),this.subscriptions.add(Qe(e,"animationiteration").pipe(ds()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(N.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 ms=(r,e)=>{if(r.type.trim().toLowerCase()==="text")return new Yr(r,e)},Yr=class extends ae{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:V}),ft({target:i,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let n=$t(this.control.type.trim().toLowerCase()),o=(a=n.firstElementChild)!=null?a:n;vt({target:o,props:this.control.props,fallback:V,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,i)=>{if(r.type.trim().toLowerCase()==="choice")return new Zr(r,e,t,i)},Zr=class r extends ye{constructor(t,i,n,o){super(t,n,o);this.containerElement=null;this.subscriptions=new ep;this.onTransitionEnd=t=>{t.stopPropagation(),!(!t.target||!t.currentTarget)&&t.target===t.currentTarget&&this.removeView()};this.rootElement=i,this.layout=new ut(this.container.layout,n),this.cssVarsManager=n,this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",Bt),this.addControlFactory("text",ms),this.addControlFactory("area",Ft)}createView({eventCallback:t,videoDurationMs:i}){let n=document.createElement("div");return n.classList.add(_.common,_.disabled),n.setAttribute("data-subjectId",this.container.id),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:(s,l)=>this.layout.setControlLayout(s,l),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(fs(n,"transitionend").subscribe(this.onTransitionEnd,a=>this.onError(`${r.name} remove view transition error`,a))).add(fs(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 vl=X(Jr(),1);import{combine as Jh,InterfaceLanguage as ed,Observable as dl,once as td,Subject as B,Subscription as Ei,ValueSubject as D,fromEvent as ml}from"@vkontakte/videoplayer-shared/es2018";import{InteractiveInterfaceClick as lt}from"@vkontakte/videoplayer-statistics/es2018";import{loadVKLangPack as cp}from"@vkontakte/videoplayer-shared/es2018";function Xe(r,e){let t;return(...i)=>{clearTimeout(t),t=setTimeout(()=>r(...i),e)}}var Ts="video_interactive",Is="videoint";var xs=250,Ye=class{constructor(e){this.handleZoomChange=Xe(e=>{this.lastZoomInfo=e},xs);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,!mt(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=up(e),this.resizeObserver=new ResizeObserver(Xe(this.onResize,xs)),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 cp(this.lang,Ts,Is)}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 up(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 Ze=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=[]}};var ea=X(Js(),1),Ut=class r{constructor(e){this.rootElement=e;this.rootElementProps={};this.isCssVarsSupported=r.checkCssVarsSupport(e)}static checkCssVarsSupport(e){let t="--test-key",i="test";e.style.setProperty(t,i);let n=e.style.getPropertyValue(t)===i;return n&&e.style.removeProperty(t),n}getPropValue(e){var t;return this.isCssVarsSupported?`var(${e})`:(t=this.rootElementProps[e])!=null?t:""}setup(e){if(this.rootElementProps={...this.rootElementProps,...e},this.isCssVarsSupported)for(let[t,i]of(0,ea.default)(e))this.rootElement.style.setProperty(t,i)}cleanup(){for(let e in this.rootElementProps)this.rootElement.style.removeProperty(e);this.rootElementProps={}}setProp(e,t){this.rootElementProps[e]=t,this.isCssVarsSupported&&this.rootElement.style.setProperty(e,t)}};import{ValueSubject as Up}from"@vkontakte/videoplayer-shared/es2018";var Gt=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 _p(...this.loaders[e])(t)}};function _p(...r){return async function(t){let i=[...r];for(;i.length>0;)t=await i.shift()(t);return t}}function Je(r,e,t){return r?{...r,[e]:r[e]?[t,...r[e]]:[t]}:{[e]:[t]}}function Wt({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),s=r.getGraph(n.graph,o.id);return a?{...i,actions:r,errors:e,result:{chapter:o,media:a,graph:s}}:{...i,errors:Je(e,Wt.name,"Could not find media"),actions:r}}}}return{...i,errors:Je(e,Wt.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(s){Promise.resolve().then(()=>{throw s})}a.options&&a.options.once&&this.removeEventListener(e.type,a.callback)}return!e.defaultPrevented}},Re=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)}},et=class{constructor(){Object.defineProperty(this,"signal",{value:new Re,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&&(et.prototype[Symbol.toStringTag]="AbortController",Re.prototype[Symbol.toStringTag]="AbortSignal");function Kt(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 ii(r){typeof r=="function"&&(r={fetch:r});let{fetch:e,Request:t=e.Request,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n=!1}=r;if(!Kt({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,d){let f;d&&d.signal&&(f=d.signal,delete d.signal);let v=new t(c,d);return f&&Object.defineProperty(v,"signal",{writable:!1,enumerable:!1,configurable:!0,value:f}),v},o.prototype=t.prototype);let a=e;return{fetch:(l,c)=>{let d=o&&o.prototype.isPrototypeOf(l)?l.signal:c?c.signal:void 0;if(d){let f;try{f=new DOMException("Aborted","AbortError")}catch(y){f=new Error("Aborted"),f.name="AbortError"}if(d.aborted)return Promise.reject(f);let v=new Promise((y,C)=>{d.addEventListener("abort",()=>C(f),{once:!0})});return c&&c.signal&&delete c.signal,Promise.race([v,a(l,c)])}return a(l,c)},Request:o}}var jp=()=>"fetch"in window,tt=jp()&&Kt({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),ta=tt?ii({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,ni=tt?ta.fetch:window.fetch,rb=tt?ta.Request:window.Request,ib=tt?et:window.AbortController,nb=tt?Re:window.AbortSignal;var oi=(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 Bp=async r=>{try{let e={},t;if(ht(r)){t=new URL(r).href;let n=await ni(t);if(!n.ok)return{};e=await n.json()}else if(se(r))e=r;else return{};if(!Zo(e))return{};let i=e.metadata.media;if(ht(i)&&!("media"in e))try{let n;t?n=new URL(i,t).href:(n=new URL(i).href,t=n);let o=await ni(n);if(!o.ok)throw new Error;e.metadata.media=await o.json()}catch(n){return Hp(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch(e){return{}}};async function ra(r){let{manifest:e,manifestURL:t}=await Bp(r);if(!e)throw new Error("Failed on fetch");let i=Jo(e);return i.media=qp(i.media,t),delete i.metadata.media,i}function Qt(r,e){if(e)return r.find(t=>t.id===e)}function si(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 ai(r,e){return r.videos.find(t=>t.id===e)}function qp(r,e){return{...r,videos:r.videos.map(t=>({...t,variants:t.variants.map(i=>{let n="url"in i?i.url:"",o=Dp(n,e);return{...i,url:o||n}})}))}}function Dp(r="",e){try{return new URL(r,e).href}catch(t){return""}}function Hp(r){return oi(r,"3.2.0")>=0}var ke=class extends Gt{constructor(t,i){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new Up(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:Je},result:null,errors:null,source:t});return i.errors&&this.errorHandler(i.errors),this.manifest=await ra((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",Wt({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:si,getChapter:Qt,getMedia:ai,getByBranches:this.getByBranches.bind(this),addErrorMessage:Je},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=Qt(this.manifest.chapters,t);if(n){let o=ai(this.manifest.media,n.videoId),a=si(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 s=Qt(((a=this.manifest)==null?void 0:a.chapters)||[],t);return this.getByBranches(s==null?void 0:s.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?J(this.chapter):!1}};var pa=X(Xt(),1);import{Player as Xp}from"@vkontakte/videoplayer-core/es2018";import{Subscription as ui,TracerFactory as Yp,ValueSubject as Zp}from"@vkontakte/videoplayer-shared/es2018";var ca=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 ua=X(Xt(),1);function li(){let r=new Map;function e({listId:o=Math.random().toString(),itemId:a=Math.random().toString(),...s}){let l=r.get(o),c={...s};return l?l[a]=c:r.set(o,{[a]:c}),{listId:o,itemId:a,...s}}function t(o){var a,s;o.player.destroy(),o.container.remove(),o.subscription.unsubscribe(),(a=o.statistics)==null||a.oneStat.destroy(),(s=o.statistics)==null||s.statSubscription.unsubscribe()}function i(o,a){let s=r.get(o);if(!s)throw Error("Can't remove. Not find.");if(a){let l=s[a];l&&t(l),delete s[a],Object.keys(s).length||r.delete(o)}else{for(let l of(0,ua.default)(s))t(l);r.delete(o)}}function n(){for(let o of r)i(o[0])}return{createPlayer:e,removePlayer:i,map:r,removeAll:n}}var Oe=X(wt(),1);function ci(r,e=[]){var o,a,s;let t={},i,n=!e.length;for(let l of r.variants)if(!i&&"cover"in l&&(i=l.cover),"url"in l)switch(l.type.toLowerCase()){case"mp4":(n||(0,Oe.default)(e,"mp4"))&&(t.MPEG={...t.MPEG,[(o=l.standard)!=null?o:"Invariant quality"]:l.url});break;case"mpeg":(n||(0,Oe.default)(e,"mpeg"))&&(t.MPEG={...t.MPEG,[(a=l.standard)!=null?a:"Invariant quality"]:l.url});break;case"hls":(n||(0,Oe.default)(e,"hls"))&&(t={...t,HLS:{type:"url",url:l.url}});break;case"dash":(n||(0,Oe.default)(e,"dash"))&&(t={...t,DASH_SEP:{compatibilityMode:!0,type:"url",url:l.url}});break;default:break}return{sources:t,thumbUrl:i,title:(s=r.title)!=null?s:""}}var rt=(r,e)=>{let t=r.info.currentQuality$.getValue(),i=r.info.availableQualities$.getValue();t!==e&&(0,Oe.default)(i,e)&&(r.setQuality(e),r.setAutoQuality(!1))};var Jp=2;function pi(r){let e=li(),t=new ui,i={},n=null,o=!1,a,s=new Zp(null);r&&l(r);function l(m){n=m}function c(m,p,h){var x;if(!n)throw Error("need to set interactive controller");if(!n.options)return;let I=((x=e.map.get(m))!=null?x:{})[p];if(I){i={chapterId:h,listId:m,itemId:p,...I};let g=i.player;i.subscription.add(g.info.currentQuality$.subscribe(T=>{let M=g.info.position$.getValue(),A=g.info.isAutoQualityEnabled$.getValue();if(!(!T||!M||A))for(let k of e.map)(0,pa.default)(k[1]).forEach(({player:P})=>{rt(P,T)})})).add(g.events.started$.subscribe(()=>{d(p)})),I.container.remove(),n.setPlayer(I.player),o||(n.init(),o=!0),s.next({player:i.player,config:i.config,statistics:i.statistics});return}throw Error("Can't set. Not find.")}async function d(m){if(!n)throw Error("need to set interactive controller");if(ce(i)||m!==i.itemId)return;let p=n.getChapterBranches(),h=new Set;for(let b of p)h.has(b.media.id)||(await v({media:b.media,chapterId:b.chapter.id,setAsActive:!1,title:b.chapter.label}),h.add(b.media.id))}async function f({chapter:{id:m},manifestVideo:p}){if(ce(i)||!n)return;let h=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,M=!1;for(let A of e.map)if(A[0]===p.id&&!n.state.isReplay$.getValue()){let k=Object.keys(A[1]);for(let P of k)P===i.itemId?(k.length<Jp||(M=!0),e.removePlayer(A[0],P)):(M=!0,c(A[0],P,m),T?rt(i.player,b):i.player.setAutoQuality(!0),i.player.setVolume(x),i.player.setMuted(h),i.player.setPlaybackRate(g))}else e.removePlayer(A[0]);M||(await v({media:p,chapterId:m,setAsActive:!0,playbackRate:g}),T?rt(i.player,b):i.player.setAutoQuality(!0),i.player.setVolume(x),i.player.setMuted(h))}async function v({media:m,chapterId:p,prefetch:h=!0,setAsActive:b=!0,autoplay:I=!1,preferredExt:x,title:g,playbackRate:T}){var Ii,xi,Ai,Si,wi;let M=Math.random().toString(),A=document.createElement("div");a.append(A);let k;if((Ii=n==null?void 0:n.options)!=null&&Ii.vkVideoLoader){let ct=ca(m);ct.length&&(k=await n.options.vkVideoLoader(...ct))}let P=((xi=n==null?void 0:n.options)==null?void 0:xi.coreConfig)||void 0,Q={...P,configName:[...(Ai=P==null?void 0:P.configName)!=null?Ai:[],"interactive"]},le={container:A,...((Si=k==null?void 0:k.videos)==null?void 0:Si[0])||{sources:ci(m,x).sources},title:g,failoverHosts:(k==null?void 0:k.failoverHosts)||[]},q=new Xp(Q,Yp.createRootTracer());q.initVideo(le);let ve=null;if(k!=null&&k.videos&&(n!=null&&n.options.createOneStat)){let ct=k.videos[0],nr=n.options.createOneStat(ct),Ri=new ui;nr&&(Ri.add(nr.attachTo(q)),ve={oneStat:nr,statSubscription:Ri})}let Ti=new ui,bl=(wi=i==null?void 0:i.player)==null?void 0:wi.info.isAutoQualityEnabled$.getValue();Ti.add(q.events.canplay$.subscribe(function(){bl||rt(q,i.player.info.currentQuality$.getValue()),T&&q.setPlaybackRate(T)}));let be=e.createPlayer({listId:m.id,itemId:M,player:q,container:A,sources:ci(m,x).sources,config:le,subscription:Ti,statistics:ve});return b&&c(m.id,be.itemId,p),I&&be.player.play(),h&&!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:m,chapter:p}=n.getCurrentChapter();m&&p?(t.add(n.events.chapterChanged$.subscribe(f)),await v({media:m,chapterId:p.id,title:p.label})):console.error("not found")}return{...e,init:E,setInteractiveController:l,createPlayer:v,removeAll:y,getActivePlayer:function(){return i},activePlayerChanged:s}}var w={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},it={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},L={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};import{Subscription as eh}from"@vkontakte/videoplayer-shared/es2018";function hi(r){return function(...t){return r(...t.reverse())}}function nt(r,...e){return(...t)=>se(e[0])&&se(t[0])?r({...e[0],...t[0]}):r(...e,...t)}var Yt=class{constructor({player:e,container:t,branches:i,selectBranches:n,interactiveEvents:o,globalEvents:a,globalEventEmitter:s,getContainerEventState:l,permanentTextControls:c,interactiveTimeOpenUri:d,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,s;if(this.gameState!==2||this.isSelectedControlEvent)return;if(this.container.getElement()){let{hasOpenURIEventInCurrentContainer:l}=this.getContainerEventState();if((i=(t=this.container).show)==null||i.call(t),this.interactiveTimeOpenUri&&l||this.disableTextControlContainerVisibilityEvents)return;this.emitContainerVisibilityEvent(!0,!1)}else{let l={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:m,isAllOpenURIEventsValid:p,hasShouldOpenNowEvent:h}=this.getContainerEventState(),b=this.interactiveTimeOpenUri&&!m,I=this.interactiveTimeOpenUri&&m;if((!this.interactiveTimeOpenUri||b)&&(this.isSelectedControlEvent=!0),f!==!1){if(!this.selectBranches.state.isExpect&&(!this.interactiveTimeOpenUri||b)){if(this.interactiveTimeOpenUri){let x=!C&&!p&&m;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,M,A,k)=>!T&&!M&&A||T&&!M&&A&&!k||T&&!M&&A&&k)(y,C,p,this.isSelectedContainerEvent);this.fakeRemoveView(g)}else this.removeView(),this.emitContainerVisibilityEvent(!1);(!y||!C||!h)&&(this.selectBranches.stopExpect(),v())}},isEOV:()=>this.gameState===4},c=nt(this.selectBranches.onControlEvent,l),d=((o=(n=this.player)==null?void 0:n.info.duration$.getValue())!=null?o:1/0)*1e3;this.container.createView({eventCallback:c,videoDurationMs:d}),this.disableTextControlContainerVisibilityEvents||this.emitContainerVisibilityEvent(!0,!0),this.disabledControls$.getValue()&&((s=(a=this.container).disable)==null||s.call(a))}};this.onEndOfVideo=()=>{this.gameState=4,this.selectContainerEvent(!0)};this.whilePlaying=()=>{var l,c,d;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(ts(n,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(Ur(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=(l=this.container).hide)==null||c.call(l)),this.container.isRemoved||this.fakeRemoveView())}!this.isPermanentText&&!y&&this.removeView()}let o=Ur(n,this.container.container),a=this.container.container.startTime?[this.container.container.startTime,(d=this.container.container.endTime)!=null?d:1/0]:[],s={subjectId:this.container.container.id,subjectName:"container",range:a,currentTime:n,isInteractiveTime:o};this.container.onProgress(n*1e3,o),this.globalEventEmitter.emit(w.eachTick,s),this.globalEvents.eachTick$.next(s)};this.container=t,this.branches=i,this.selectBranches=n,this.subscription=new eh,this.player=e,this.interactiveEvents=o,this.getContainerEventState=l;let m=we(t.container.controls);this.isPermanentText=c&&m,this.disableTextControlContainerVisibilityEvents=C&&m,this.interactiveTimeOpenUri=d,this.disabledControls$=f,this.onRemove=v,this.globalEventEmitter=s,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(w.interactives,{subjectId:this.container.container.id,subjectName:"container",type:L.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(w.interactives,{subjectId:this.container.container.id,subjectName:"container",type:L.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(w.interactives,{subjectId:this.container.container.id,subjectName:"container",type:L.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 da=(r=[])=>r.reduce((e,t,i)=>{var o,a,s;let n=((o=t==null?void 0:t.controls)!=null?o:[]).filter(l=>!Rt(l));if(Pt(n)){let l=[(a=t.startTime)!=null?a:0,(s=t.endTime)!=null?s:1/0],c={id:t.id,isRemoved:!1};if(!i)e.push({subjects:[c],range:l});else{let d=[],f=-1/0,v=1/0,y=[],C=[];for(let E=0;E<e.length;E++){let m=e[E];if(C.push(...m.subjects),m.range[0]<v&&(v=m.range[0]),m.range[1]>f&&(f=m.range[1]),l[0]>=m.range[0]&&l[1]<=m.range[1])return e[E].subjects.push(c),e;l[0]<m.range[0]&&l[1]>m.range[0]&&(d.push(E),y=y.concat(m.subjects)),l[0]>=m.range[0]&&l[0]<=m.range[1]&&(d.push(E),y=y.concat(m.subjects),l[0]=m.range[0]),l[1]>=m.range[0]&&l[1]<=m.range[1]&&(d.push(E),y=y.concat(m.subjects),l[1]=m.range[1])}if(C.push(c),l[0]<=v&&l[1]>=f)return[{subjects:C,range:l}];d.length&&d.reverse().forEach(E=>{e.splice(E,1)}),e.push({subjects:y.concat([c]),range:l})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);var Ka=X(wt(),1),vi=X(Xt(),1),Qa=X(Wa(),1);function za(){let r={};function e(){for(let s in r)Object.prototype.hasOwnProperty.call(r,s)&&delete r[s]}function t(s){let l={};for(let c in r)+c<=s&&(l[c]=r[c]);return l}function i(s){let l={};for(let c in r)+c>=s&&(l[c]=r[c]);return l}function n({timestamp:s,priority:l,initiator:c}){var d;if(lr(s)){let f=(d=r[s])!=null?d:null;if(f&&l&&Me(l,!0)){let v={},y=f[l];if(y&&(v={...v,...y}),v=ce(v)?null:v,v&&Me(c,!0)){let C=v[c];return C!=null?C:null}return v}return f}return null}function o({timestamp:s,priority:l,initiator:c}){if(lr(s))if(r[s]){if(l&&Me(l,!0))if(r[s][l]){if(c&&Me(c,!0))if(r[s][l][c]){if(delete r[s][l][c],!ce(r[s][l]))return!0}else return!1;if(delete r[s][l],!ce(r[s]))return!0}else return!1;return delete r[s]}else return!1;return!1}function a({timestamp:s,priority:l,initiator:c,...d}){var f,v,y;(v=(f=r[s])==null?void 0:f[l])!=null&&v[c]?r[s][l][c].push({...d}):(y=r[s])!=null&&y[l]?r[s][l]={...r[s][l],[c]:[{...d}]}:r[s]?r[s]={...r[s],[l]:{[c]:[{...d}]}}:r[s]={[l]:{[c]:[{...d}]}}}return{map:r,remove:o,add:a,removeAll:e,get:n,getLte:t,getGte:i}}var Dh=[R.expect,R.setNextBranch],Hh=1/0;function Xa(r,e){let t=r,i,n=Uh(e),o=za(),a,s=()=>{y(),p()},l=h=>{o.add.call(void 0,h),C()},c=(h=[])=>{for(let b of h)if(b.action(),(0,Ka.default)(Dh,b.actionType))break},d=(h=1/0)=>{var g,T,M;let b=Jt((g=o.get({timestamp:h,priority:"control"}))!=null?g:{}),I=Jt((T=o.get({timestamp:h,priority:"container"}))!=null?T:{}),x=Jt((M=o.get({timestamp:h,priority:"chapter"}))!=null?M:{});return[...b,...I,...x]},f=h=>{n.isReady(h)&&c(d(h))},v=()=>{var h;c([...Jt((h=o.get({timestamp:1/0,priority:"chapter"}))!=null?h:{})])},y=()=>{i&&(a==null||a.unsubscribe(),i=void 0)},C=()=>{i||(i=()=>setTimeout(()=>{f(1/0)}),a=t.events.ended$.subscribe(i))},E=h=>{y(),t=h},m=h=>{h.priority==="container"&&n.resetCalled(h.timestamp),o.remove(h)},p=()=>{n.release(),o.removeAll()};return{setPlayer:E,add:l,remove:m,exec:f,execEndOfVideo:v,listen:C,unlisten:y,release:s,containersEventsCallState:n,getPreparedToExecActions:d}}function Uh(r){let e=new Map;return{setCalled:({timestamp:s,id:l})=>{let c=e.get(s);c&&c[l]!==void 0&&(c[l]=!0)},setData:(s=[])=>{var l;for(let c of s){let d=(l=c.endTime)!=null?l:Hh,f=e.get(d);e.set(d,{...f,[c.id]:!1})}},resetCalled:s=>{let l=e.get(s);if(l)for(let c in l)l[c]=!1},isReady:s=>{let l=e.get(s);if(!l)return!0;let c=(0,vi.default)(l);return r?c.some(f=>f):!c.some(f=>!f)},release:()=>e.clear()}}function Jt(r){return(0,Qa.default)((0,vi.default)(r)).sort(e=>e.actionType===R.expect?-1:1)}var Ya={videoContentHeight:0,videoContentWidth:0},Za=r=>{let{height:e,width:t}=r.info.intrinsicVideoSize$.getValue()||{};if(!(e&&t))return Ya;let{clientHeight:i,clientWidth:n}=r.experimental.element$.getValue()||{};if(!(i&&n))return Ya;let o=e/t,a=i/n,s,l;return a>o?(l=n,s=n*o):a<o?(l=i/o,s=i):(l=n,s=i),{videoContentWidth:l,videoContentHeight:s}};var Gh=250;function Ja(r){let e,t=new ResizeObserver(s=>{o(s),e=o.bind(null,s)});function i(s){let{parentElement:l,player:c,cssVarsManager:d}=r();if(!l||!c)return;let{videoContentWidth:f,videoContentHeight:v}=Za(c);d.setup({"--interactive-content-width":`${f}px`,"--interactive-content-height":`${v}px`,"--interactive-width":`${s[0].contentRect.width}px`,"--interactive-height":`${s[0].contentRect.height}px`})}function n(){let{parentElement:s}=r();s.removeAttribute("style")}let o=Xe(s=>{let{fns:l=[]}=r();i(s);for(let c of l)c()},Gh);function a(){e=void 0,t.disconnect(),n()}return{resizeObserver:t,calc:()=>{e==null||e()},release:a}}var Wh=r=>Math.floor(Math.random()*r),tl=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},rl=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 il=r=>{let e=r.length,t=Wh(e);return r[t]},el=1,nl=r=>{var i,n;let e=0;for(let o=0;o<r.length;++o)e+=(i=r[o].weight)!=null?i:el;let t=Math.random()*e;e=0;for(let o=0;o<r.length-1;++o)if(e+=(n=r[o].weight)!=null?n:el,e>=t)return r[o];return r[r.length-1]};var ol={shouldOpenNow:!0,isDetachContainer:!0},sl="after-expect",bi=(r,e=!1)=>({...r,args:e?{...r.args,...ol}:{...ol,...r.args}}),al=({globalEventEmitter:r,globalEvents:e,player:t,interactiveEvents:i})=>{let n={isExpect:!1},o=()=>{n.isExpect&&(n.isExpect=!1)},a=({action:p,controlType:h,controlId:b,containerId:I,branches:x=[],onEvent:g,isEOV:T=()=>!1,isDisabled:M=()=>!1})=>{let A=bi(p,T()),k={timestamp:1/0,priority:"control",initiator:b,actionType:A.type},P=M(),Q=r.emit.bind(r,w.interactives,{subjectId:b,subjectType:h,subjectName:"control",type:P?L.actionChoiceCanceled:L.actionChoice,actionType:p.type,payload:{invokeImmediately:A.args.shouldOpenNow,containerId:I,...A.args}}),le=()=>{e.interactiveActionChoice$.next({subjectId:b,subjectType:h,subjectName:"control",type:P?"action-choice-canceled":"action-choice",actionType:p.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:h,action:A,payload:{chapterId:q.chapterId,autoSelect:!1}}):i.add({...k,action:E.bind(null,{subjectId:b,subjectName:"control",subjectType:h,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:h,action:p}):i.add({...k,action:C.bind(null,{subjectId:b,subjectName:"control",subjectType:h,action:p})});return}case R.openURI.trim().toLowerCase():{g(A.args.isDetachContainer,y.bind(null,{subjectId:b,subjectName:"control"})),Q(),le(),A.args.shouldOpenNow?m({subjectId:b,subjectName:"control",subjectType:h,action:A,payload:{URI:p.args.uri}}):i.add({...k,action:m.bind(null,{subjectId:b,subjectName:"control",subjectType:h,action:A,payload:{URI:p.args.uri}})});return}default:{let q="Unexpected control event",ve=new $(1,1,{message:q});d(ve,q);return}}},s=({action:p,container:{id:h,endTime:b},branches:I=[],isEOV:x=!1,autoSelected:g=!1})=>{let T=bi(p,x),M={timestamp:!T.args.shouldOpenNow||x?1/0:b!=null?b:1/0,priority:"container",initiator:h,actionType:T.type},A=r.emit.bind(r,w.interactives,{subjectId:h,subjectName:"container",type:L.actionChoice,actionType:T.type,payload:{invokeImmediately:T.args.shouldOpenNow,...T.args}}),k=()=>{e.interactiveActionChoice$.next({subjectId:h,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({...M,action:E.bind(null,{subjectId:h,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({...M,action:C.bind(null,{subjectId:h,subjectName:"container",action:T})});return}case R.openURI.trim().toLowerCase():{A(),k(),i.add({...M,action:m.bind(null,{subjectId:h,subjectName:"container",action:T,payload:{URI:p.args.uri}})});return}default:{let P="Unexpected container event",Q=new $(1,1,{message:P});d(Q,P);return}}};function l({container:p,branches:h,isEOV:b=!1}){var x,g;let I=Gr(p.events);if(I){let T=bi(I.action,b);r.emit(w.interactives,{subjectId:p.id,subjectName:"container",type:L.actionChoice,actionType:T.type,payload:{invokeImmediately:T.args.shouldOpenNow,...T.args}}),e.interactiveActionChoice$.next({subjectId:p.id,subjectName:"container",type:"action-choice",actionType:T.type,payload:{invokeImmediately:T.args.shouldOpenNow,...T.args}}),i.add({timestamp:b?1/0:(x=p.endTime)!=null?x:1/0,priority:"container",initiator:p.id,actionType:R.expect,action:v.bind(null,{subjectId:p.id,subjectName:"container"})}),n.isExpect=!0}else for(let T of(g=p.events)!=null?g:[])s({action:T.action,container:p,branches:h,isEOV:b})}let c=({chapterId:p,action:h,branches:b=[]})=>{let I=r.emit.bind(r,w.interactives,{subjectId:p,subjectName:"chapter",type:L.actionChoice,actionType:h.type,payload:h.args}),x=()=>{e.interactiveActionChoice$.next({subjectId:p,subjectName:"chapter",type:"action-choice",actionType:h.type,payload:h.args})};switch(h.type.trim().toLowerCase()){case R.setNextBranch.trim().toLowerCase():{let g=b.find(T=>T.id===h.args.branchId);return g!=null&&g.chapterId?(I(),x(),E.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:g.chapterId,autoSelect:!0}})):void 0}case R.setWeightlessRandomBranch.trim().toLowerCase():{let g=il(b);return g!=null&&g.chapterId?(I(),x(),E.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:g.chapterId,autoSelect:!0}})):void 0}case R.setRandomBranch.trim().toLowerCase():{let g=nl(b);return g!=null&&g.chapterId?(I(),x(),E.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:g.chapterId,autoSelect:!0}})):void 0}case R.setMaxWeightBranch.trim().toLowerCase():{let g=rl(b);return g!=null&&g.chapterId?(I(),x(),E.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:g.chapterId,autoSelect:!0}})):void 0}case R.setMinWeightBranch.trim().toLowerCase():{let g=tl(b);return g!=null&&g.chapterId?(I(),x(),E.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:g.chapterId,autoSelect:!0}})):void 0}case R.continuePlayback.trim().toLowerCase():return I(),x(),C.bind(null,{subjectId:p,subjectName:"chapter",action:h});case R.openURI.trim().toLowerCase():return I(),x(),m.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{URI:h.args.uri}});default:{let g="Unexpected chapter event",T=new $(1,1,{message:g});d(T,g);return}}};function d(p,h){console.error(h),e.error$.next(p),r.emit(w.errors,p)}function f(p){var b;let h=Gr(p.events);if(h){if(J(p))return;r.emit(w.interactives,{subjectId:p.id,subjectName:"chapter",type:L.actionChoice,actionType:h.action.type,payload:h.action.args}),e.interactiveActionChoice$.next({subjectId:p.id,subjectName:"chapter",type:"action-choice",actionType:h.action.type,payload:h.action.args}),i.add({timestamp:1/0,priority:"chapter",initiator:p.id,actionType:R.expect,action:v.bind(null,{subjectId:p.id,subjectName:"chapter"})})}else(b=p.events)==null||b.forEach(I=>{let x=c({chapterId:p.id,action:I.action,branches:p.branches});x&&i.add({timestamp:1/0,priority:"chapter",initiator:p.id,actionType:I.action.type,action:x})})}let v=({subjectId:p,subjectName:h})=>{t.pause(),r.emit(w.interactives,{subjectId:p,subjectName:h,type:L.actionExecution,actionType:R.expect}),e.interactiveActionExecution$.next({subjectId:p,subjectName:h,type:"action-execution",actionType:R.expect})},y=({subjectId:p,subjectName:h})=>{t.info.isEnded$.getValue()?i.execEndOfVideo():t.play(),r.emit(w.interactives,{subjectId:p,subjectName:h,type:L.actionExecution,actionType:sl}),e.interactiveActionExecution$.next({subjectId:p,subjectName:h,type:"action-execution",actionType:sl})},C=({subjectId:p,subjectName:h,subjectType:b,action:I})=>{r.emit(w.interactives,{subjectId:p,subjectName:h,subjectType:b,type:L.actionExecution,actionType:I.type}),e.interactiveActionExecution$.next({subjectId:p,subjectName:h,subjectType:b,type:"action-execution",actionType:I.type})},E=({subjectId:p,subjectName:h,subjectType:b,action:I,payload:x})=>{x.behaviour="change-chapter",r.emit(w.interactives,{subjectId:p,subjectName:h,subjectType:b,type:L.actionExecution,actionType:I.type,payload:x}),e.interactiveActionExecution$.next({subjectId:p,subjectName:h,subjectType:b,type:"action-execution",actionType:I.type,payload:x})},m=({subjectId:p,subjectName:h,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(w.interactives,{subjectId:p,subjectName:h,subjectType:b,type:L.actionExecution,actionType:I.type}),e.interactiveActionExecution$.next({subjectId:p,subjectName:h,subjectType:b,type:"action-execution",actionType:I.type})};return{onControlEvent:a,onContainerEvent:s,onChapterEvent:c,onExpectEvent:v,expectEventHandler:y,setManifestChapterEvents:f,setManifestContainerEvents:l,stopExpect:o,state:n}};var Ci=X(Jr(),1);import{Subscription as Yh,Subject as gi,ValueSubject as st}from"@vkontakte/videoplayer-shared/es2018";var yi=(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]=ll(o)}return t[i]}).filter(Boolean)},Kh=r=>{for(let e of r.variants)if(Qh(e)&&e.payload)return e.payload.id},Qh=r=>!!(r.type==="custom"&&r.payload&&r.payload.type==="vk"),ll=r=>{let e=Kh(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},Xh=(r,e)=>{for(let t of r.media.videos)if(e===ll(t)){for(let i of r.chapters)if(i.videoId===t.id)return i.id;return}},cl=(r,e)=>r.reduce((t,i)=>{let n=Xh(e,i);return n?[...t,n]:t},[]);var re,de,me,W,er,ie,ne,ee,fe,Pe,Ve,at=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:i,historyApi:n,settings:o}){this.state={history$:new st([]),hasPrevChapter$:new st(!1),prevChapter$:new st(null),isInitialChapter$:new st(!1),isGoBackLimited$:new st(!1)};H(this,re,null);H(this,de);H(this,me,!1);H(this,W,null);H(this,er,null);this.events={inited$:new gi,destroyed$:new gi,error$:new gi};H(this,ie,null);H(this,ne,null);H(this,ee,null);H(this,fe,new Yh);H(this,Pe,!1);H(this,Ve,0);var a;F(this,ie,t),F(this,ee,e),F(this,ne,i),F(this,re,n),F(this,de,o),this.state.history$&&S(this,fe)&&((a=S(this,fe))==null||a.add(this.state.history$.subscribe(s=>{var l,c;this.state.prevChapter$.next((0,Ci.default)(s,-2)||null),this.state.hasPrevChapter$.next(s.length>1),this.state.isInitialChapter$.next(this.getInitialChapterId()===((c=(l=S(this,W))==null?void 0:l.metadata)==null?void 0:c.initChapterId)),this.state.isGoBackLimited$.next(S(this,Ve)===S(this,de).maxLength-1)})))}async setManifest(e){if(!S(this,ne)||!S(this,ee))return;F(this,W,e),await this.getProjectHistory();let t=this.getInitialChapterId();await S(this,ne).setChapter({chapterId:t,pushToHistory:!1}),S(this,me)||(F(this,me,!0),this.events.inited$.next({initChapterId:t}))}get inited(){return S(this,me)}async updateHistory(e,t=!0){var s;if(!S(this,W))return;S(this,Pe)?(F(this,Pe,!1),Vi(this,Ve)._++):F(this,Ve,0);let i=S(this,W),n=e.length-S(this,de).maxLength,o=n>0?e.slice(n):e,a=yi(o,i);if(F(this,er,a),this.state.history$.next(o),!(!t||!S(this,re)||!S(this,ie)))try{await S(this,re).save(S(this,ie),a)}catch(l){let c=new $(1,5,"Unable to save interactive history");this.events.error$.next(c),(s=S(this,ee))==null||s.emit(w.errors,c)}}async goBack(){var i;if(!this.state||!S(this,ne)){let n=new $(1,5,"Unable to save interactive history");return this.events.error$.next(n),(i=S(this,ee))==null?void 0:i.emit(w.errors,n)}F(this,Pe,!0);let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),await S(this,ne).setChapter({chapterId:t,playPrev:!0})}async getProjectHistory(){var n;if(!S(this,W)||!S(this,ie))return;let e=S(this,W),t=[this.getInitialVideoId()];if(S(this,re))try{let o=await S(this,re).get(S(this,ie));o.length&&(t=o)}catch(o){let a=new $(1,5,"Error while trying to fetch data");this.events.error$.next(a),(n=S(this,ee))==null||n.emit(w.errors,a)}let i=cl(t,e);this.state.history$.next(i)}getInitialChapterId(){var t;let e=this.state.history$.getValue();return(0,Ci.default)(e,-1)||S(this,de).initChapterId||((t=S(this,W))==null?void 0:t.metadata.initChapterId)}getInitialVideoId(){if(S(this,W)){let e=this.getInitialChapterId();return yi([e],S(this,W)).pop()}return null}destroy(){var e,t;F(this,ie,null),F(this,re,null),F(this,ne,null),(e=S(this,fe))==null||e.unsubscribe(),F(this,fe,null),F(this,me,!1),(t=S(this,ee))==null||t.emit(w.historyDestroyed),this.events.destroyed$.next(),F(this,ee,null)}};re=new WeakMap,de=new WeakMap,me=new WeakMap,W=new WeakMap,er=new WeakMap,ie=new WeakMap,ne=new WeakMap,ee=new WeakMap,fe=new WeakMap,Pe=new WeakMap,Ve=new WeakMap;var tr=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 rr=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;
|
|
@@ -11,12 +11,12 @@ var cl=Object.create;var Si=Object.defineProperty;var ul=Object.getOwnPropertyDe
|
|
|
11
11
|
height: var(--interactive-height);
|
|
12
12
|
background-color: var(--black);
|
|
13
13
|
visibility: hidden;
|
|
14
|
-
`,this.lastFrameCanvas=new
|
|
14
|
+
`,this.lastFrameCanvas=new tr,this.endOffsetMs=t,this._callbacks={onError:i},this.lastFrameCanvas.rootElement.style.cssText=`
|
|
15
15
|
position: absolute;
|
|
16
16
|
top: 50%;
|
|
17
17
|
left: 50%;
|
|
18
18
|
transform: translate(-50%, -50%);
|
|
19
|
-
`,this.rootElement.prepend(this.lastFrameCanvas.rootElement),e.prepend(this.rootElement)}destroy(){this.hide(),this.reset(),this._callbacks=void 0,this.lastFrameCanvas.destroy(),this.rootElement.remove()}setVideoDuration(e){this.currentVideoDurationMs=e}setVideoElement(e){this.lastFrameCanvas.setCanvasImageSource(e)}setCurrentChapter(e){this.currentChapter=e}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}async updateCanvasDimensions(e=!1){this._containerTimeFrameShouldReceived||this._endTimeFrameReceived||(e=!1);let t=getComputedStyle(this.rootElement),i={width:parseInt(t.getPropertyValue("--interactive-content-width"),10),height:parseInt(t.getPropertyValue("--interactive-content-height"),10)};try{this.lastFrameCanvas.updateCanvasDimensions(i,e)}catch(n){this._onError(n)}}draw(){(this._containerTimeFrameShouldReceived||!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived)&&this.lastFrameCanvas.draw()}isChapterEndTime(e){return this.currentVideoDurationMs&&e>=this.currentVideoDurationMs-this.endOffsetMs}isContainerTime(e){if(this.currentChapter)return this.currentChapter.containers.some(t=>{var i,n,o;return((i=t.controls)==null?void 0:i.length)&&e>=((n=t.startTime)!=null?n:0)&&e<=Math.min((o=t.endTime)!=null?o:1/0,this.currentVideoDurationMs-this.endOffsetMs)})}reset(){this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1}_onError(e){var t,i;(i=(t=this._callbacks)==null?void 0:t.onError)==null||i.call(t,e)}};function
|
|
19
|
+
`,this.rootElement.prepend(this.lastFrameCanvas.rootElement),e.prepend(this.rootElement)}destroy(){this.hide(),this.reset(),this._callbacks=void 0,this.lastFrameCanvas.destroy(),this.rootElement.remove()}setVideoDuration(e){this.currentVideoDurationMs=e}setVideoElement(e){this.lastFrameCanvas.setCanvasImageSource(e)}setCurrentChapter(e){this.currentChapter=e}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}async updateCanvasDimensions(e=!1){this._containerTimeFrameShouldReceived||this._endTimeFrameReceived||(e=!1);let t=getComputedStyle(this.rootElement),i={width:parseInt(t.getPropertyValue("--interactive-content-width"),10),height:parseInt(t.getPropertyValue("--interactive-content-height"),10)};try{this.lastFrameCanvas.updateCanvasDimensions(i,e)}catch(n){this._onError(n)}}draw(){(this._containerTimeFrameShouldReceived||!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived)&&this.lastFrameCanvas.draw()}isChapterEndTime(e){return this.currentVideoDurationMs&&e>=this.currentVideoDurationMs-this.endOffsetMs}isContainerTime(e){if(this.currentChapter)return this.currentChapter.containers.some(t=>{var i,n,o;return((i=t.controls)==null?void 0:i.length)&&e>=((n=t.startTime)!=null?n:0)&&e<=Math.min((o=t.endTime)!=null?o:1/0,this.currentVideoDurationMs-this.endOffsetMs)})}reset(){this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1}_onError(e){var t,i;(i=(t=this._callbacks)==null?void 0:t.onError)==null||i.call(t,e)}};function ul(r=0){return new Promise(e=>{setTimeout(()=>{e(0)},r)})}var pl=`/* interactive-container */
|
|
20
20
|
.interactive-container {
|
|
21
21
|
opacity: 1;
|
|
22
22
|
visibility: visible;
|
|
@@ -282,4 +282,4 @@ var cl=Object.create;var Si=Object.defineProperty;var ul=Object.getOwnPropertyDe
|
|
|
282
282
|
.interactive-control-fill-animation-filler.interactive-control-fill-animation-from-bottom {
|
|
283
283
|
transform-origin: bottom;
|
|
284
284
|
}
|
|
285
|
-
`;var il=r=>{let e=document.createElement("style");e.textContent=rl,r.prepend(e)};import{clientChecker as Dh}from"@vkontakte/videoplayer-core/es2018";var al=Object.freeze({lang:Bh.RU,loaders:{},graph:!1,initSeamless:!1,lastFrame:!1,permanentTextControls:!0,interactiveTimeOpenUri:!1,config:{historyMaxLength:100,noInteractionEventTimeout:3e4},isTouch:!1,disableTextControlContainerVisibilityEvents:!1,animationsFeatureToggles:{areaControlShadow:!1,controlsExpectTimeBlinkAnimation:!1,controlsTapPlace:!1,controlsFillAnimation:!1,controlsHideAnimation:!1}});function Hh(){let r=document.createElement("div");return r.classList.add("interactive-chapter"),r}var rr=class{constructor(e){this.playerSubscriptions=new gi;this.subscriptions=new gi;this.globalEventEmitter=new Dt;this.animation=new Ht;this.seekToInteractiveController=new Ye;this.endedRanges=new Set;this.gameControllers=[];this.rootElement=Hh();this.factories=new Map([["choice",qt]]);this.isFirstChapterFetched=!1;this.player=null;this.interactiveEvents=null;this.selectBranches=null;this.seamlessController=null;this.seamlessControllerSubs=new gi;this.graph=null;this.lastFrame=null;this.blinkAnimationRef=null;this.appState=0;this.state={prevChapter$:new D(null),isInitialChapter$:new D(!1),isFirstChapter$:new D(!0),isEndChapter$:new D(!1),isInteractiveExpectation$:new D(!1),isReplay$:new D(!1),calledByInteractive$:new D(!1),lastChapterChangeWasInitiatedByInteractive$:new D(!1),disabledControls$:new D(!1),interactiveRanges$:new D([]),isInteractiveTime$:new D(!1),statistics$:new D(null),isSeekable$:new D(!1)};this.events={noInteraction$:new B,graphVisibilityChanged$:new B,watchAgainIsClicked$:new B,chapterChanged$:new B,playerChanged$:new B,error$:new B,eachTick$:new B,manifestChanged$:new B,interactiveRangeEnded$:new B,interactiveContainerRemoved$:new B,interactiveContainerFakeRemoved$:new B,interactiveActionExecution$:new B,interactiveActionChoice$:new B,interactiveVisibilityChanged$:new B};this.emitErrorEvent=e=>{this.events.error$.next(e),this.globalEventEmitter.emit(S.errors,e)};this.clearHistoryIfEnded=()=>{var n;let e=(n=this.player)==null?void 0:n.info.isEnded$.getValue(),t=this.state.isInteractiveExpectation$.getValue(),{chapter:i}=this.getCurrentChapter();e&&i&&Z(i)&&!t&&this.historyController.updateHistory([]),window.removeEventListener("beforeunload",this.clearHistoryIfEnded)};this.handleSeamlessPlayerChanged=e=>{if(!e)return;let{statistics:t,...i}=e;if(t){let{statSubscription:n,oneStat:o}=t;n.add(o.attachToInteractive(this.getStatEvents())),this.state.statistics$.next(t)}this.state.isReplay$.getValue()&&this.state.isReplay$.next(!1),this.events.playerChanged$.next(i),this.globalEventEmitter.emit(S.playerChanged,i)};this.onPlaybackStarted=()=>{var e;(e=this.resizeManager)==null||e.calc(),this.animation.requestAnimation()};this.destroyGameControllers=({removeTextControls:e=!0,withTransition:t=!1}={})=>{for(let i of this.gameControllers)!e&&i.isPermanentText||(this.animation.removeFn(i.whilePlaying),i.destroy(t))};this.completeInteractiveRange=e=>{let{interactiveRanges$:t}=this.state,n=t.getValue().map(o=>({...o,subjects:o.subjects.filter(a=>a.id!==e)}));t.next(n)};this.clearNoInteractionTimeout=()=>{this.noInteractionTimeout&&(clearTimeout(this.noInteractionTimeout),this.noInteractionTimeout=void 0)};var n,o;if(this._options={...al,...e,config:{...al.config,...e.config}},(n=this._options.animationsFeatureToggles)==null?void 0:n.controlsExpectTimeBlinkAnimation){this.blinkAnimationRef=new Vt,this.blinkAnimationRef.create();let a=this.blinkAnimationRef.element;a&&this.rootElement.append(a)}this._options.parentElement.append(this.rootElement),this.historyController=new at({interactiveController:this,globalEventEmitter:this.globalEventEmitter,videoId:(o=this._options.projectInfo)==null?void 0:o.videoId,historyApi:this._options.historyApi,settings:{maxLength:this._options.config.historyMaxLength,initChapterId:this._options.initChapterId}}),this._options.lastFrame&&(this.lastFrame=new tr({parentElement:this._options.parentElement,onError:a=>{let l=new N(1,6,a);this.emitErrorEvent(l)}})),il(this._options.parentElement),this.subscriptions.add(ol(this.rootElement,"mousedown").subscribe(a=>a.stopPropagation())).add(ol(this.rootElement,"mouseup").subscribe(a=>a.stopPropagation())),this.manifestController=new Re(this._options.loaders,a=>{let l=new N(1,3,a);this.emitErrorEvent(l)});let i=[];this._options.lastFrame&&i.push(()=>{var a;(a=this.lastFrame)==null||a.updateCanvasDimensions(!0)}),i.push(()=>{let a=this.state.isInteractiveTime$.getValue();for(let l of this.gameControllers)l.onResize(a)}),this.resizeManager=Us(()=>({player:this.player,parentElement:this._options.parentElement,fns:i})),this._options.graph&&(this.graph=new Xe({root:this._options.parentElement,lang:this._options.lang,onOpenPreviewClick:a=>{this.setChapter({chapterId:a}),this.globalEventEmitter.emit(S.graph,{type:rt.watchAgainClicked,chapterId:a}),this.events.watchAgainIsClicked$.next(a)},onError:a=>{let l=new N(1,2,{message:a});this.emitErrorEvent(l)}})),this.initSubscriptions()}initSubscriptions(){this.playerSubscriptions.add(this.historyController.events.inited$.subscribe(async({videosInfo:e=[]})=>{this._options.initSeamless&&(await this.initSeamless(),this.updateGraphVideosInfo(e))})),this.subscriptions.add(this.events.interactiveContainerRemoved$.subscribe(({subjectId:e})=>{this.completeInteractiveRange(e)})).add(this.events.interactiveContainerFakeRemoved$.subscribe(({subjectId:e,removeAllOpenURI:t})=>{this.handleFakeRemoval(e,t)})).add(this.events.interactiveActionExecution$.subscribe(e=>{var t,i;if(this.state.calledByInteractive$.next(!0),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!0),((t=e.payload)==null?void 0:t.behaviour)==="change-chapter"){let{chapterId:n}=e.payload;this.setChapter({chapterId:n}),this.state.isFirstChapter$.getValue()&&this.state.isFirstChapter$.next(!1)}else if(((i=e.payload)==null?void 0:i.behaviour)==="change-manifest"){let{manifestURL:n}=e.payload;n&&this.setManifest(n)}e.actionType==="expect"?(this.state.isInteractiveExpectation$.next(!0),this.updateControlsShadowStyles({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!0}),this.toggleBlinkAnimation({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!0})):e.actionType==="after-expect"&&(this.state.isInteractiveExpectation$.next(!1),this.updateControlsShadowStyles({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!1}),this.toggleBlinkAnimation({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!1}))})).add(this.events.manifestChanged$.subscribe(()=>{this.state.calledByInteractive$.next(!1),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)})).add(this.events.interactiveActionChoice$.subscribe(({type:e,subjectName:t,payload:i})=>{var n;e!=="action-choice"||t==="chapter"||"invokeImmediately"in i&&i.invokeImmediately||this.destroyGameControllers({removeTextControls:!1,withTransition:(n=this._options.animationsFeatureToggles)==null?void 0:n.controlsHideAnimation})}))}async initSeamless(){this.seamlessController=ci(this),this.seamlessControllerSubs.add(this.seamlessController.activePlayerChanged.subscribe(this.handleSeamlessPlayerChanged)),await this.seamlessController.init()}handlePositionChange(e){(!this.graph||this.graph.isHidden)&&this.checkIfSeekable();let t=e*1e3,n=this.getInteractiveRanges().reverse().find(({range:o})=>t>=o[1]);if(n){let o=n.range.join("-");this.endedRanges.has(o)||(this.endedRanges.add(o),this.globalEventEmitter.emit(S.interactives,{type:V.rangeEnded,payload:n,visibility:!0}),this.events.interactiveRangeEnded$.next({type:"range-ended",payload:n}))}}registerVideoEvents(){this.player&&(window.removeEventListener("beforeunload",this.clearHistoryIfEnded),this.playerSubscriptions.unsubscribe(),window.addEventListener("beforeunload",this.clearHistoryIfEnded),this.playerSubscriptions.add(this.player.events.started$.pipe(qh()).subscribe(this.onPlaybackStarted)).add(this.player.events.playing$.subscribe(this.animation.requestAnimation)).add(this.player.events.willPause$.subscribe(this.animation.cancelAnimation)).add(this.player.info.position$.subscribe(this.handlePositionChange.bind(this))).add(this.manifestController.prevChapter$.subscribe(e=>this.state.prevChapter$.next(e))).add(jh({position:this.player.info.position$,interactiveRanges:this.state.interactiveRanges$,isInteractiveExpectation:this.state.isInteractiveExpectation$}).subscribe(({position:e,interactiveRanges:t,isInteractiveExpectation:i})=>{var s;let n;if(i)n=!0;else{let c=e*1e3;n=!!t.find(({range:[f,v],subjects:y})=>f<c&&c<v&&y.some(C=>!C.isRemoved)&&y.length)}n!==this.state.isInteractiveTime$.getValue()&&this.state.isInteractiveTime$.next(n);let o=!!this.noInteractionTimeout,l=((s=this.player)==null?void 0:s.info.playbackState$.getValue())==="playing"||i;n&&!o&&l?this.noInteractionTimeout=window.setTimeout(()=>{this.events.noInteraction$.next()},this._options.config.noInteractionEventTimeout):o&&!l&&this.clearNoInteractionTimeout()})),this.playerSubscriptions.add(this.historyController.events.error$.subscribe(this.events.error$)),this._options.lastFrame&&this.playerSubscriptions.add(this.player.info.duration$.subscribe(e=>{var t;(t=this.lastFrame)==null||t.setVideoDuration(e*1e3)})).add(this.player.experimental.element$.subscribe(e=>{var t;e&&((t=this.lastFrame)==null||t.setVideoElement(e))})).add(this.player.events.firstFrame$.subscribe(()=>{var e;(e=this.lastFrame)==null||e.reset(),setTimeout(()=>{var t,i;(t=this.lastFrame)==null||t.hide(),(i=this.lastFrame)==null||i.lastFrameCanvas.clear()},50)})).add(this.player.events.seeked$.subscribe(this.lastFrame.onSeek)))}setGameControllers(){var t,i;let e=this.manifestController.chapter;e&&this.appState===1&&((t=this.selectBranches)==null||t.setManifestChapterEvents(e),this.gameControllers=this.getGameControllers(e),(i=this.interactiveEvents)==null||i.containersEventsCallState.setData(e.containers),this.seekToInteractiveController.setContainers(this.gameControllers.map(n=>n.container.container).filter(n=>!we(n.controls))),this._options.lastFrame&&this.animation.addFn(()=>{var n;this.player&&((n=this.lastFrame)==null||n.onEachTick(this.player.info.position$.getValue()*1e3))},!0),this.state.interactiveRanges$.next(this.getInteractiveRanges()),this.appState=2)}getGameControllers(e){let t=[];return e.containers.forEach(i=>{var l,s,c,m,f,v,y;let n=i.type.trim().toLowerCase(),o=this.factories.get(n),a=o==null?void 0:o(i,this.rootElement,{isTouch:(s=(l=this._options)==null?void 0:l.isTouch)!=null?s:!1,features:{controlsExpectTimeBlinkAnimation:(c=this._options.animationsFeatureToggles)==null?void 0:c.controlsExpectTimeBlinkAnimation,controlsTapPlace:(m=this._options.animationsFeatureToggles)==null?void 0:m.controlsTapPlace,controlsFillAnimation:(f=this._options.animationsFeatureToggles)==null?void 0:f.controlsFillAnimation}});if(a&&this.selectBranches&&this.interactiveEvents&&this.player){let C=new Xt({player:this.player,container:a,branches:e.branches,selectBranches:this.selectBranches,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter,getContainerEventState:()=>ra(i,this.gameControllers),permanentTextControls:this._options.permanentTextControls,interactiveTimeOpenUri:this._options.interactiveTimeOpenUri,disabledControls$:this.state.disabledControls$,onRemove:()=>{this.seekToInteractiveController.deleteContainer(i.id)},onError:this.emitErrorEvent,disableTextControlContainerVisibilityEvents:(v=this.options.disableTextControlContainerVisibilityEvents)!=null?v:!1,features:{controlsHideAnimation:(y=this._options.animationsFeatureToggles)==null?void 0:y.controlsHideAnimation}});this.animation.addFn(C.whilePlaying,!0),t.push(C)}}),t}checkIfSeekable(){if(this.state.isInteractiveExpectation$.getValue()){this.state.isSeekable$.next(!1);return}let t=this.state.isSeekable$.getValue(),i=!!this.seekToInteractiveController.getNextInteractiveTime();(i&&!t||!i&&t)&&this.state.isSeekable$.next(!t)}updateLastEventInfo(){this.state.calledByInteractive$.getValue()?this.state.calledByInteractive$.next(!1):this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)}pushChapterToHistory(e){var l,s;if(this.updateLastEventInfo(),!this.historyController.inited)return;let t=this.state.lastChapterChangeWasInitiatedByInteractive$.getValue(),i=this.state.prevChapter$.getValue(),n=(l=i&&Z(i)&&Lt(i))!=null?l:!1,o=((s=this.manifestController.manifest)==null?void 0:s.metadata.initChapterId)===e,a=this.historyController.state.history$.getValue();if(o||n&&t){this.historyController.updateHistory([e]);return}(0,sl.default)(a,-1)!==e&&this.historyController.updateHistory([...a,e])}handleFakeRemoval(e,t){let{interactiveRanges$:i}=this.state,o=i.getValue().map(a=>{let l=a.subjects.some(c=>c.id===e),s=a.subjects.map(c=>t&&l||c.id===e?{...c,isRemoved:!0}:c);return{...a,subjects:s}});i.next(o)}reset(){var e;this.appState===2&&(this.destroyGameControllers(),this.gameControllers=[],this.animation.release(),(e=this.interactiveEvents)==null||e.release(),this.appState=1,this.state.isSeekable$.next(!1),this.clearNoInteractionTimeout())}toggleBlinkAnimation(e){var i,n;if(!((i=this._options.animationsFeatureToggles)!=null&&i.controlsExpectTimeBlinkAnimation))return;let t=(o,a)=>{o.toggleBlinkAnimation(a)};Ft({...e,gameControllers:this.gameControllers,execFn:it(ui(t),e.isExpect)}),e.isExpect&&((n=this.blinkAnimationRef)==null||n.restart())}updateControlsShadowStyles(e){var i;if(!((i=this._options.animationsFeatureToggles)!=null&&i.areaControlShadow))return;let t=(n,o)=>{n.updateControlsShadowStyles(o)};e.isExpect?Ft({...e,gameControllers:this.gameControllers,execFn:it(ui(t),!1)}):Ft({...e,gameControllers:this.gameControllers,execFn:t})}get options(){return this._options}init(){var e;this.manifestController.chapter&&this._options.parentElement&&this.player&&this._options.fullscreenTargetElement&&this.appState===0&&((e=this.resizeManager)==null||e.resizeObserver.observe(this._options.fullscreenTargetElement),this.registerVideoEvents(),this.appState=1,this.setGameControllers())}async setManifest(e){this.reset(),this.isFirstChapterFetched=!1;let t=await this.manifestController.setManifest(e);if(t.manifest)return this.graph&&this.graph.handleManifestChange(t.manifest),await this.historyController.setManifest(t.manifest),this.events.manifestChanged$.next(t.manifest),this.globalEventEmitter.emit(S.manifestChanged,{manifest:t.manifest}),this.setGameControllers(),t.manifest}setPlayer(e){this.reset(),this.player=e,this.seekToInteractiveController.setPlayer(this.player),this.interactiveEvents?this.interactiveEvents.setPlayer(this.player):this.interactiveEvents=qs(this.player,this._options.interactiveTimeOpenUri),this.selectBranches=Zs({player:this.player,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter}),this.appState===1&&(this.registerVideoEvents(),this.setGameControllers())}async setChapter({chapterId:e,pushToHistory:t=!0,playPrev:i=!1}={}){var s,c;this.reset(),this.lastFrame&&this.isFirstChapterFetched&&(this.lastFrame.draw(),this.lastFrame.show()),this.lastFrame&&Dh.browser.isSafari&&await tl(35);let n=!i&&this.state.isEndChapter$.getValue()&&((s=this.getCurrentManifest())==null?void 0:s.metadata.initChapterId)===e;this.state.isReplay$.next(n);let{chapter:o,media:a,graph:l}=await(e?this.manifestController.setNext(e):this.manifestController.setInitial());(!e||n)&&this.state.isFirstChapter$.next(!0),!(!o||!a)&&(t&&this.pushChapterToHistory(o.id),this.state.isInitialChapter$.next(this.manifestController.isInitialChapter()),this.state.isEndChapter$.next(this.manifestController.isEndChapter()),this.graph&&this.graph.handleChapterChange(o),this.state.isInteractiveTime$.next(!1),this.state.isInteractiveExpectation$.next(!1),(c=this.lastFrame)==null||c.setCurrentChapter(o),this.events.chapterChanged$.next({chapter:o,manifestVideo:a}),this.globalEventEmitter.emit(S.chapterChanged,{chapter:o,media:a,graph:l}),this.setGameControllers(),this.endedRanges=new Set,this.isFirstChapterFetched=!0)}getStatEvents(){return{click$:new nl(e=>{this.subscriptions.add(this.events.graphVisibilityChanged$.subscribe(t=>{e.next(t?st.GRAPH_SHOW:st.GRAPH_HIDE)})).add(this.events.watchAgainIsClicked$.subscribe(()=>{e.next(st.WATCH_AGAIN)})).add(this.events.interactiveActionChoice$.subscribe(({type:t,subjectName:i,subjectType:n})=>{t!=="action-choice"||i!=="control"||(n==="Button"&&e.next(st.NEXT_BUTTON),n==="Area"&&e.next(st.NEXT_AREA))}))}),nextMovie$:new nl(e=>{this.events.playerChanged$.subscribe(({config:t})=>{t!=null&&t.unitedVideoId&&!this.state.isFirstChapter$.getValue()&&e.next(t.unitedVideoId)})})}}async toggleGraphView(e=!0){this.graph&&(e?(await this.graph.show(),this.state.isSeekable$.next(!1)):(this.graph.hide(),this.checkIfSeekable()),this.globalEventEmitter.emit(S.graph,{type:rt.visibility,visibility:e}),this.events.graphVisibilityChanged$.next(e))}setVisitedChapters(e){var t;Array.isArray(e)&&((t=this.graph)==null||t.setVisitedChapters(e))}updateGraphVideosInfo(e){var t;Array.isArray(e)&&((t=this.graph)==null||t.updateVideosInfo(e))}deadEndCheck(){var i;return!(((i=this.interactiveEvents)==null?void 0:i.getPreparedToExecActions())||[]).some(n=>n.actionType===R.setNextBranch)}allControlsAreRemoved(e=!0){return!this.gameControllers.some(i=>{var o;let n=e&&((o=this._options.animationsFeatureToggles)!=null&&o.controlsHideAnimation)?i.container.willRemoved:!0;return!i.container.isRemoved||!n})}isEndedExpectation(){if(!this.player||!this.gameControllers)return!1;let e=this.player.info.position$.getValue(),t=this.player.info.duration$.getValue();return e===t&&this.gameControllers.some(i=>{let n=i.container.container;return!i.container.isRemoved&&!i.container.willRemoved&&n.endTime===null&&he(n.events)})}playPrevChapter(){this.historyController.goBack()}setDisabledControls(e){this.state.disabledControls$.next(e)}isSupport(e=this.manifestController.manifest){return!!e&&kt(e.metadata.version)}getInitialVideoInfo(){return{videoId:this.historyController.getInitialVideoId(),chapterId:this.historyController.getInitialChapterId()}}getHistoryState(){return this.historyController.state}getIsSeekable(){return this.state.isSeekable$}getInteractiveRanges(){var e;return ns((e=this.manifestController.chapter)==null?void 0:e.containers)}getNextInteractiveStartTime(e){return this.seekToInteractiveController.getNextInteractiveTime(e)}getChapterBranches(e){return this.manifestController.getBranches(e)}getCurrentChapter(){return this.manifestController.getCurrent()}getCurrentManifest(){return this.manifestController.manifest}on(e,t){return this.globalEventEmitter.on(e,t),this}off(e,t){return this.globalEventEmitter.off(e,t),this}once(e,t){return this.globalEventEmitter.once(e,t),this}destroy(){var e,t,i,n,o,a;this.clearHistoryIfEnded(),(e=this.blinkAnimationRef)==null||e.destroy(),this.destroyGameControllers(),this.gameControllers=[],(t=this.graph)==null||t.destroy(),this.seamlessControllerSubs.unsubscribe(),(i=this.seamlessController)==null||i.removeAll(),(n=this.resizeManager)==null||n.release(),this.animation.release(),(o=this.interactiveEvents)==null||o.release(),this.manifestController.release(),this.playerSubscriptions.unsubscribe(),this.subscriptions.unsubscribe(),this.globalEventEmitter.reset(),(a=this.lastFrame)==null||a.destroy(),this.rootElement.remove(),this.historyController.destroy(),this.isFirstChapterFetched=!1,this.appState=3}};var Uh={Container:ye,createChoiceContainer:qt,createAreaControl:Mt,createButtonControl:Bt,classnamesPrefix:Mi};var ng={version:Pi};export{$m as ContainerTypes,Ot as ControlTypes,N as CustomError,S as EVENT_NAMES,R as EventActionTypes,_m as EventTypes,rr as Interactives,Re as ManifestController,ng as SDKInfo,vi as chapterIdsToVKVideoIds,ti as compareVersions,Om as containerTypes,Pm as controlTypes,Fm as eventActionTypes,Lm as eventTypes,Nh as getChapterIdByVkVideoId,Js as getVKVideoIdByMedia,Vh as getVideoRawIdByMedia,rt as graphEventTypes,Lt as hasEndTemplate,V as interactivesEventTypes,km as isAreaControl,Rm as isButtonControl,Z as isLastChapter,we as isOneTextCtrlContainer,kt as isSupportedManifest,Rt as isTextControl,Mh as isVKVariantItem,Xo as isValidManifest,Yo as migrateManifestToLatestVersion,Uh as utils,el as vkVideoIdsToChapterIds};
|
|
285
|
+
`;var hl=r=>{let e=document.createElement("style");e.textContent=pl,r.prepend(e)};import{clientChecker as rd}from"@vkontakte/videoplayer-core/es2018";var fl=Object.freeze({lang:ed.RU,loaders:{},graph:!1,initSeamless:!1,lastFrame:!1,permanentTextControls:!0,interactiveTimeOpenUri:!1,config:{historyMaxLength:100,noInteractionEventTimeout:3e4},isTouch:!1,disableTextControlContainerVisibilityEvents:!1,animationsFeatureToggles:{areaControlShadow:!1,controlsExpectTimeBlinkAnimation:!1,controlsTapPlace:!1,controlsFillAnimation:!1,controlsHideAnimation:!1}});function id(){let r=document.createElement("div");return r.classList.add("interactive-chapter"),r}var ir=class{constructor(e){this.playerSubscriptions=new Ei;this.subscriptions=new Ei;this.globalEventEmitter=new Dt;this.animation=new Ht;this.seekToInteractiveController=new Ze;this.endedRanges=new Set;this.gameControllers=[];this.rootElement=id();this.factories=new Map([["choice",qt]]);this.isFirstChapterFetched=!1;this.player=null;this.interactiveEvents=null;this.selectBranches=null;this.seamlessController=null;this.seamlessControllerSubs=new Ei;this.graph=null;this.lastFrame=null;this.blinkAnimationRef=null;this.appState=0;this.state={prevChapter$:new D(null),isInitialChapter$:new D(!1),isFirstChapter$:new D(!0),isEndChapter$:new D(!1),isInteractiveExpectation$:new D(!1),isReplay$:new D(!1),calledByInteractive$:new D(!1),lastChapterChangeWasInitiatedByInteractive$:new D(!1),disabledControls$:new D(!1),interactiveRanges$:new D([]),isInteractiveTime$:new D(!1),statistics$:new D(null),isSeekable$:new D(!1)};this.events={noInteraction$:new B,graphVisibilityChanged$:new B,watchAgainIsClicked$:new B,chapterChanged$:new B,playerChanged$:new B,error$:new B,eachTick$:new B,manifestChanged$:new B,interactiveRangeEnded$:new B,interactiveContainerRemoved$:new B,interactiveContainerFakeRemoved$:new B,interactiveActionExecution$:new B,interactiveActionChoice$:new B,interactiveVisibilityChanged$:new B};this.emitErrorEvent=e=>{this.events.error$.next(e),this.globalEventEmitter.emit(w.errors,e)};this.clearHistoryIfEnded=()=>{var n;let e=(n=this.player)==null?void 0:n.info.isEnded$.getValue(),t=this.state.isInteractiveExpectation$.getValue(),{chapter:i}=this.getCurrentChapter();e&&i&&J(i)&&!t&&this.historyController.updateHistory([]),window.removeEventListener("beforeunload",this.clearHistoryIfEnded)};this.handleSeamlessPlayerChanged=e=>{if(!e)return;let{statistics:t,...i}=e;if(t){let{statSubscription:n,oneStat:o}=t;n.add(o.attachToInteractive(this.getStatEvents())),this.state.statistics$.next(t)}this.state.isReplay$.getValue()&&this.state.isReplay$.next(!1),this.events.playerChanged$.next(i),this.globalEventEmitter.emit(w.playerChanged,i)};this.onPlaybackStarted=()=>{var e;(e=this.resizeManager)==null||e.calc(),this.animation.requestAnimation()};this.destroyGameControllers=({removeTextControls:e=!0,withTransition:t=!1}={})=>{for(let i of this.gameControllers)!e&&i.isPermanentText||(this.animation.removeFn(i.whilePlaying),i.destroy(t))};this.completeInteractiveRange=e=>{let{interactiveRanges$:t}=this.state,n=t.getValue().map(o=>({...o,subjects:o.subjects.filter(a=>a.id!==e)}));t.next(n)};this.clearNoInteractionTimeout=()=>{this.noInteractionTimeout&&(clearTimeout(this.noInteractionTimeout),this.noInteractionTimeout=void 0)};var n,o,a;if(this._options={...fl,...e,config:{...fl.config,...e.config}},(n=this._options.animationsFeatureToggles)==null?void 0:n.controlsExpectTimeBlinkAnimation){this.blinkAnimationRef=new Lt,this.blinkAnimationRef.create();let s=this.blinkAnimationRef.element;s&&this.rootElement.append(s)}this._options.parentElement.append(this.rootElement),this.historyController=new at({interactiveController:this,globalEventEmitter:this.globalEventEmitter,videoId:(o=this._options.projectInfo)==null?void 0:o.videoId,historyApi:this._options.historyApi,settings:{maxLength:this._options.config.historyMaxLength,initChapterId:this._options.initChapterId}}),this._options.lastFrame&&(this.lastFrame=new rr({parentElement:this._options.parentElement,onError:s=>{let l=new $(1,6,s);this.emitErrorEvent(l)}})),hl(this._options.parentElement),this.subscriptions.add(ml(this.rootElement,"mousedown").subscribe(s=>s.stopPropagation())).add(ml(this.rootElement,"mouseup").subscribe(s=>s.stopPropagation())),this.manifestController=new ke(this._options.loaders,s=>{let l=new $(1,3,s);this.emitErrorEvent(l)});let i=[];this._options.lastFrame&&i.push(()=>{var s;(s=this.lastFrame)==null||s.updateCanvasDimensions(!0)}),i.push(()=>{let s=this.state.isInteractiveTime$.getValue();for(let l of this.gameControllers)l.onResize(s)}),this.cssVarsManager=new Ut((a=this._options)==null?void 0:a.parentElement),this.resizeManager=Ja(()=>({player:this.player,cssVarsManager:this.cssVarsManager,parentElement:this._options.parentElement,fns:i})),this._options.graph&&(this.graph=new Ye({root:this._options.parentElement,lang:this._options.lang,onOpenPreviewClick:s=>{this.setChapter({chapterId:s}),this.globalEventEmitter.emit(w.graph,{type:it.watchAgainClicked,chapterId:s}),this.events.watchAgainIsClicked$.next(s)},onError:s=>{let l=new $(1,2,{message:s});this.emitErrorEvent(l)}})),this.initSubscriptions()}initSubscriptions(){this.playerSubscriptions.add(this.historyController.events.inited$.subscribe(async({videosInfo:e=[]})=>{this._options.initSeamless&&(await this.initSeamless(),this.updateGraphVideosInfo(e))})),this.subscriptions.add(this.events.interactiveContainerRemoved$.subscribe(({subjectId:e})=>{this.completeInteractiveRange(e)})).add(this.events.interactiveContainerFakeRemoved$.subscribe(({subjectId:e,removeAllOpenURI:t})=>{this.handleFakeRemoval(e,t)})).add(this.events.interactiveActionExecution$.subscribe(e=>{var t,i;if(this.state.calledByInteractive$.next(!0),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!0),((t=e.payload)==null?void 0:t.behaviour)==="change-chapter"){let{chapterId:n}=e.payload;this.setChapter({chapterId:n}),this.state.isFirstChapter$.getValue()&&this.state.isFirstChapter$.next(!1)}else if(((i=e.payload)==null?void 0:i.behaviour)==="change-manifest"){let{manifestURL:n}=e.payload;n&&this.setManifest(n)}e.actionType==="expect"?(this.state.isInteractiveExpectation$.next(!0),this.updateControlsShadowStyles({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!0}),this.toggleBlinkAnimation({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!0})):e.actionType==="after-expect"&&(this.state.isInteractiveExpectation$.next(!1),this.updateControlsShadowStyles({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!1}),this.toggleBlinkAnimation({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!1}))})).add(this.events.manifestChanged$.subscribe(()=>{this.state.calledByInteractive$.next(!1),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)})).add(this.events.interactiveActionChoice$.subscribe(({type:e,subjectName:t,payload:i})=>{var n;e!=="action-choice"||t==="chapter"||"invokeImmediately"in i&&i.invokeImmediately||this.destroyGameControllers({removeTextControls:!1,withTransition:(n=this._options.animationsFeatureToggles)==null?void 0:n.controlsHideAnimation})}))}async initSeamless(){this.seamlessController=pi(this),this.seamlessControllerSubs.add(this.seamlessController.activePlayerChanged.subscribe(this.handleSeamlessPlayerChanged)),await this.seamlessController.init()}handlePositionChange(e){(!this.graph||this.graph.isHidden)&&this.checkIfSeekable();let t=e*1e3,n=this.getInteractiveRanges().reverse().find(({range:o})=>t>=o[1]);if(n){let o=n.range.join("-");this.endedRanges.has(o)||(this.endedRanges.add(o),this.globalEventEmitter.emit(w.interactives,{type:L.rangeEnded,payload:n,visibility:!0}),this.events.interactiveRangeEnded$.next({type:"range-ended",payload:n}))}}registerVideoEvents(){this.player&&(window.removeEventListener("beforeunload",this.clearHistoryIfEnded),this.playerSubscriptions.unsubscribe(),window.addEventListener("beforeunload",this.clearHistoryIfEnded),this.playerSubscriptions.add(this.player.events.started$.pipe(td()).subscribe(this.onPlaybackStarted)).add(this.player.events.playing$.subscribe(this.animation.requestAnimation)).add(this.player.events.willPause$.subscribe(this.animation.cancelAnimation)).add(this.player.info.position$.subscribe(this.handlePositionChange.bind(this))).add(this.manifestController.prevChapter$.subscribe(e=>this.state.prevChapter$.next(e))).add(Jh({position:this.player.info.position$,interactiveRanges:this.state.interactiveRanges$,isInteractiveExpectation:this.state.isInteractiveExpectation$}).subscribe(({position:e,interactiveRanges:t,isInteractiveExpectation:i})=>{var l;let n;if(i)n=!0;else{let c=e*1e3;n=!!t.find(({range:[f,v],subjects:y})=>f<c&&c<v&&y.some(C=>!C.isRemoved)&&y.length)}n!==this.state.isInteractiveTime$.getValue()&&this.state.isInteractiveTime$.next(n);let o=!!this.noInteractionTimeout,s=((l=this.player)==null?void 0:l.info.playbackState$.getValue())==="playing"||i;n&&!o&&s?this.noInteractionTimeout=window.setTimeout(()=>{this.events.noInteraction$.next()},this._options.config.noInteractionEventTimeout):o&&!s&&this.clearNoInteractionTimeout()})),this.playerSubscriptions.add(this.historyController.events.error$.subscribe(this.events.error$)),this._options.lastFrame&&this.playerSubscriptions.add(this.player.info.duration$.subscribe(e=>{var t;(t=this.lastFrame)==null||t.setVideoDuration(e*1e3)})).add(this.player.experimental.element$.subscribe(e=>{var t;e&&((t=this.lastFrame)==null||t.setVideoElement(e))})).add(this.player.events.firstFrame$.subscribe(()=>{var e;(e=this.lastFrame)==null||e.reset(),setTimeout(()=>{var t,i;(t=this.lastFrame)==null||t.hide(),(i=this.lastFrame)==null||i.lastFrameCanvas.clear()},50)})).add(this.player.events.seeked$.subscribe(this.lastFrame.onSeek)))}setGameControllers(){var t,i;let e=this.manifestController.chapter;e&&this.appState===1&&((t=this.selectBranches)==null||t.setManifestChapterEvents(e),this.gameControllers=this.getGameControllers(e),(i=this.interactiveEvents)==null||i.containersEventsCallState.setData(e.containers),this.seekToInteractiveController.setContainers(this.gameControllers.map(n=>n.container.container).filter(n=>!we(n.controls))),this._options.lastFrame&&this.animation.addFn(()=>{var n;this.player&&((n=this.lastFrame)==null||n.onEachTick(this.player.info.position$.getValue()*1e3))},!0),this.state.interactiveRanges$.next(this.getInteractiveRanges()),this.appState=2)}getGameControllers(e){let t=[];return e.containers.forEach(i=>{var s,l,c,d,f,v,y;let n=i.type.trim().toLowerCase(),o=this.factories.get(n),a=o==null?void 0:o(i,this.rootElement,this.cssVarsManager,{isTouch:(l=(s=this._options)==null?void 0:s.isTouch)!=null?l:!1,features:{controlsExpectTimeBlinkAnimation:(c=this._options.animationsFeatureToggles)==null?void 0:c.controlsExpectTimeBlinkAnimation,controlsTapPlace:(d=this._options.animationsFeatureToggles)==null?void 0:d.controlsTapPlace,controlsFillAnimation:(f=this._options.animationsFeatureToggles)==null?void 0:f.controlsFillAnimation}});if(a&&this.selectBranches&&this.interactiveEvents&&this.player){let C=new Yt({player:this.player,container:a,branches:e.branches,selectBranches:this.selectBranches,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter,getContainerEventState:()=>ns(i,this.gameControllers),permanentTextControls:this._options.permanentTextControls,interactiveTimeOpenUri:this._options.interactiveTimeOpenUri,disabledControls$:this.state.disabledControls$,onRemove:()=>{this.seekToInteractiveController.deleteContainer(i.id)},onError:this.emitErrorEvent,disableTextControlContainerVisibilityEvents:(v=this.options.disableTextControlContainerVisibilityEvents)!=null?v:!1,features:{controlsHideAnimation:(y=this._options.animationsFeatureToggles)==null?void 0:y.controlsHideAnimation}});this.animation.addFn(C.whilePlaying,!0),t.push(C)}}),t}checkIfSeekable(){if(this.state.isInteractiveExpectation$.getValue()){this.state.isSeekable$.next(!1);return}let t=this.state.isSeekable$.getValue(),i=!!this.seekToInteractiveController.getNextInteractiveTime();(i&&!t||!i&&t)&&this.state.isSeekable$.next(!t)}updateLastEventInfo(){this.state.calledByInteractive$.getValue()?this.state.calledByInteractive$.next(!1):this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)}pushChapterToHistory(e){var s,l;if(this.updateLastEventInfo(),!this.historyController.inited)return;let t=this.state.lastChapterChangeWasInitiatedByInteractive$.getValue(),i=this.state.prevChapter$.getValue(),n=(s=i&&J(i)&&Vt(i))!=null?s:!1,o=((l=this.manifestController.manifest)==null?void 0:l.metadata.initChapterId)===e,a=this.historyController.state.history$.getValue();if(o||n&&t){this.historyController.updateHistory([e]);return}(0,vl.default)(a,-1)!==e&&this.historyController.updateHistory([...a,e])}handleFakeRemoval(e,t){let{interactiveRanges$:i}=this.state,o=i.getValue().map(a=>{let s=a.subjects.some(c=>c.id===e),l=a.subjects.map(c=>t&&s||c.id===e?{...c,isRemoved:!0}:c);return{...a,subjects:l}});i.next(o)}reset(){var e;this.appState===2&&(this.destroyGameControllers(),this.gameControllers=[],this.animation.release(),(e=this.interactiveEvents)==null||e.release(),this.appState=1,this.state.isSeekable$.next(!1),this.clearNoInteractionTimeout())}toggleBlinkAnimation(e){var i,n;if(!((i=this._options.animationsFeatureToggles)!=null&&i.controlsExpectTimeBlinkAnimation))return;let t=(o,a)=>{o.toggleBlinkAnimation(a)};Mt({...e,gameControllers:this.gameControllers,execFn:nt(hi(t),e.isExpect)}),e.isExpect&&((n=this.blinkAnimationRef)==null||n.restart())}updateControlsShadowStyles(e){var i;if(!((i=this._options.animationsFeatureToggles)!=null&&i.areaControlShadow))return;let t=(n,o)=>{n.updateControlsShadowStyles(o)};e.isExpect?Mt({...e,gameControllers:this.gameControllers,execFn:nt(hi(t),!1)}):Mt({...e,gameControllers:this.gameControllers,execFn:t})}get options(){return this._options}init(){var e;this.manifestController.chapter&&this._options.parentElement&&this.player&&this._options.fullscreenTargetElement&&this.appState===0&&((e=this.resizeManager)==null||e.resizeObserver.observe(this._options.fullscreenTargetElement),this.registerVideoEvents(),this.appState=1,this.setGameControllers())}async setManifest(e){this.reset(),this.isFirstChapterFetched=!1;let t=await this.manifestController.setManifest(e);if(t.manifest)return this.graph&&this.graph.handleManifestChange(t.manifest),await this.historyController.setManifest(t.manifest),this.events.manifestChanged$.next(t.manifest),this.globalEventEmitter.emit(w.manifestChanged,{manifest:t.manifest}),this.setGameControllers(),t.manifest}setPlayer(e){this.reset(),this.player=e,this.seekToInteractiveController.setPlayer(this.player),this.interactiveEvents?this.interactiveEvents.setPlayer(this.player):this.interactiveEvents=Xa(this.player,this._options.interactiveTimeOpenUri),this.selectBranches=al({player:this.player,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter}),this.appState===1&&(this.registerVideoEvents(),this.setGameControllers())}async setChapter({chapterId:e,pushToHistory:t=!0,playPrev:i=!1}={}){var l,c;this.reset(),this.lastFrame&&this.isFirstChapterFetched&&(this.lastFrame.draw(),this.lastFrame.show()),this.lastFrame&&rd.browser.isSafari&&await ul(35);let n=!i&&this.state.isEndChapter$.getValue()&&((l=this.getCurrentManifest())==null?void 0:l.metadata.initChapterId)===e;this.state.isReplay$.next(n);let{chapter:o,media:a,graph:s}=await(e?this.manifestController.setNext(e):this.manifestController.setInitial());(!e||n)&&this.state.isFirstChapter$.next(!0),!(!o||!a)&&(t&&this.pushChapterToHistory(o.id),this.state.isInitialChapter$.next(this.manifestController.isInitialChapter()),this.state.isEndChapter$.next(this.manifestController.isEndChapter()),this.graph&&this.graph.handleChapterChange(o),this.state.isInteractiveTime$.next(!1),this.state.isInteractiveExpectation$.next(!1),(c=this.lastFrame)==null||c.setCurrentChapter(o),this.events.chapterChanged$.next({chapter:o,manifestVideo:a}),this.globalEventEmitter.emit(w.chapterChanged,{chapter:o,media:a,graph:s}),this.setGameControllers(),this.endedRanges=new Set,this.isFirstChapterFetched=!0)}getStatEvents(){return{click$:new dl(e=>{this.subscriptions.add(this.events.graphVisibilityChanged$.subscribe(t=>{e.next(t?lt.GRAPH_SHOW:lt.GRAPH_HIDE)})).add(this.events.watchAgainIsClicked$.subscribe(()=>{e.next(lt.WATCH_AGAIN)})).add(this.events.interactiveActionChoice$.subscribe(({type:t,subjectName:i,subjectType:n})=>{t!=="action-choice"||i!=="control"||(n==="Button"&&e.next(lt.NEXT_BUTTON),n==="Area"&&e.next(lt.NEXT_AREA))}))}),nextMovie$:new dl(e=>{this.events.playerChanged$.subscribe(({config:t})=>{t!=null&&t.unitedVideoId&&!this.state.isFirstChapter$.getValue()&&e.next(t.unitedVideoId)})})}}async toggleGraphView(e=!0){this.graph&&(e?(await this.graph.show(),this.state.isSeekable$.next(!1)):(this.graph.hide(),this.checkIfSeekable()),this.globalEventEmitter.emit(w.graph,{type:it.visibility,visibility:e}),this.events.graphVisibilityChanged$.next(e))}setVisitedChapters(e){var t;Array.isArray(e)&&((t=this.graph)==null||t.setVisitedChapters(e))}updateGraphVideosInfo(e){var t;Array.isArray(e)&&((t=this.graph)==null||t.updateVideosInfo(e))}deadEndCheck(){var i;return!(((i=this.interactiveEvents)==null?void 0:i.getPreparedToExecActions())||[]).some(n=>n.actionType===R.setNextBranch)}allControlsAreRemoved(e=!0){return!this.gameControllers.some(i=>{var o;let n=e&&((o=this._options.animationsFeatureToggles)!=null&&o.controlsHideAnimation)?i.container.willRemoved:!0;return!i.container.isRemoved||!n})}isEndedExpectation(){if(!this.player||!this.gameControllers)return!1;let e=this.player.info.position$.getValue(),t=this.player.info.duration$.getValue();return e===t&&this.gameControllers.some(i=>{let n=i.container.container;return!i.container.isRemoved&&!i.container.willRemoved&&n.endTime===null&&he(n.events)})}playPrevChapter(){this.historyController.goBack()}setDisabledControls(e){this.state.disabledControls$.next(e)}isSupport(e=this.manifestController.manifest){return!!e&&kt(e.metadata.version)}getInitialVideoInfo(){return{videoId:this.historyController.getInitialVideoId(),chapterId:this.historyController.getInitialChapterId()}}getHistoryState(){return this.historyController.state}getIsSeekable(){return this.state.isSeekable$}getInteractiveRanges(){var e;return da((e=this.manifestController.chapter)==null?void 0:e.containers)}getNextInteractiveStartTime(e){return this.seekToInteractiveController.getNextInteractiveTime(e)}getChapterBranches(e){return this.manifestController.getBranches(e)}getCurrentChapter(){return this.manifestController.getCurrent()}getCurrentManifest(){return this.manifestController.manifest}on(e,t){return this.globalEventEmitter.on(e,t),this}off(e,t){return this.globalEventEmitter.off(e,t),this}once(e,t){return this.globalEventEmitter.once(e,t),this}destroy(){var e,t,i,n,o,a;this.clearHistoryIfEnded(),(e=this.blinkAnimationRef)==null||e.destroy(),this.destroyGameControllers(),this.gameControllers=[],(t=this.graph)==null||t.destroy(),this.seamlessControllerSubs.unsubscribe(),(i=this.seamlessController)==null||i.removeAll(),(n=this.resizeManager)==null||n.release(),this.animation.release(),(o=this.interactiveEvents)==null||o.release(),this.manifestController.release(),this.playerSubscriptions.unsubscribe(),this.subscriptions.unsubscribe(),this.globalEventEmitter.reset(),(a=this.lastFrame)==null||a.destroy(),this.rootElement.remove(),this.historyController.destroy(),this.isFirstChapterFetched=!1,this.appState=3}};var nd={Container:ye,createChoiceContainer:qt,createAreaControl:Ft,createButtonControl:Bt,classnamesPrefix:Ni};var Ag={version:Mi};export{Ym as ContainerTypes,Ot as ControlTypes,$ as CustomError,w as EVENT_NAMES,R as EventActionTypes,Zm as EventTypes,ir as Interactives,ke as ManifestController,Ag as SDKInfo,yi as chapterIdsToVKVideoIds,oi as compareVersions,Um as containerTypes,Gm as controlTypes,zm as eventActionTypes,Wm as eventTypes,Xh as getChapterIdByVkVideoId,ll as getVKVideoIdByMedia,Kh as getVideoRawIdByMedia,it as graphEventTypes,Vt as hasEndTemplate,L as interactivesEventTypes,Hm as isAreaControl,Dm as isButtonControl,J as isLastChapter,we as isOneTextCtrlContainer,kt as isSupportedManifest,Rt as isTextControl,Qh as isVKVariantItem,Zo as isValidManifest,Jo as migrateManifestToLatestVersion,nd as utils,cl as vkVideoIdsToChapterIds};
|