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