@vkontakte/videoplayer-interactive 1.0.37-dev.cffc5829.0 → 1.0.37-dev.dd02dc3e.0

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