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