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