@vkontakte/videoplayer-interactive 1.0.26-beta.1 → 1.0.26-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es2015.cjs.js +3 -3
- package/es2015.esm.js +3 -3
- package/es2018.cjs.js +3 -3
- package/es2018.esm.js +3 -3
- package/esnext.cjs.js +3 -3
- package/esnext.esm.js +3 -3
- package/evergreen.esm.js +3 -3
- package/package.json +4 -4
package/es2015.esm.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-interactive v1.0.26-beta.
|
|
3
|
-
*
|
|
2
|
+
* @vkontakte/videoplayer-interactive v1.0.26-beta.3
|
|
3
|
+
* Thu, 28 Nov 2024 13:55:32 GMT
|
|
4
4
|
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-26/doc/
|
|
5
5
|
*/
|
|
6
|
-
var $o=Object.create;var Yt=Object.defineProperty,qo=Object.defineProperties,Bo=Object.getOwnPropertyDescriptor,Do=Object.getOwnPropertyDescriptors,Ho=Object.getOwnPropertyNames,nt=Object.getOwnPropertySymbols,Go=Object.getPrototypeOf,Zt=Object.prototype.hasOwnProperty,mi=Object.prototype.propertyIsEnumerable;var yi=r=>{throw TypeError(r)};var fi=(r,e,t)=>e in r?Yt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,d=(r,e)=>{for(var t in e||(e={}))Zt.call(e,t)&&fi(r,t,e[t]);if(nt)for(var t of nt(e))mi.call(e,t)&&fi(r,t,e[t]);return r},C=(r,e)=>qo(r,Do(e));var j=(r,e)=>{var t={};for(var i in r)Zt.call(r,i)&&e.indexOf(i)<0&&(t[i]=r[i]);if(r!=null&&nt)for(var i of nt(r))e.indexOf(i)<0&&mi.call(r,i)&&(t[i]=r[i]);return t};var p=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var Uo=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ho(e))!Zt.call(r,n)&&n!==t&&Yt(r,n,{get:()=>e[n],enumerable:!(i=Bo(e,n))||i.enumerable});return r};var X=(r,e,t)=>(t=r!=null?$o(Go(r)):{},Uo(e||!r||!r.__esModule?Yt(t,"default",{value:r,enumerable:!0}):t,r));var vi=(r,e,t)=>e.has(r)||yi("Cannot "+t);var S=(r,e,t)=>(vi(r,e,"read from private field"),t?t.call(r):e.get(r)),H=(r,e,t)=>e.has(r)?yi("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),V=(r,e,t,i)=>(vi(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t);var gi=(r,e,t,i)=>({set _(n){V(r,e,n,t)},get _(){return S(r,e,i)}});var w=(r,e,t)=>new Promise((i,n)=>{var a=s=>{try{l(t.next(s))}catch(c){n(c)}},o=s=>{try{l(t.throw(s))}catch(c){n(c)}},l=s=>s.done?i(s.value):Promise.resolve(s.value).then(a,o);l((t=t.apply(r,e)).next())});var Q=p((ar,Si)=>{"use strict";var Me=function(r){return r&&r.Math===Math&&r};Si.exports=Me(typeof globalThis=="object"&&globalThis)||Me(typeof window=="object"&&window)||Me(typeof self=="object"&&self)||Me(typeof global=="object"&&global)||Me(typeof ar=="object"&&ar)||function(){return this}()||Function("return this")()});var G=p((ld,wi)=>{"use strict";wi.exports=function(r){try{return!!r()}catch(e){return!0}}});var Re=p((cd,_i)=>{"use strict";var Wo=G();_i.exports=!Wo(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var Pi=p((pd,Ri)=>{"use strict";var Ko=Re(),Mi=Function.prototype,Ai=Mi.apply,Li=Mi.call;Ri.exports=typeof Reflect=="object"&&Reflect.apply||(Ko?Li.bind(Ai):function(){return Li.apply(Ai,arguments)})});var W=p((ud,Vi)=>{"use strict";var ki=Re(),Oi=Function.prototype,sr=Oi.call,Qo=ki&&Oi.bind.bind(sr,sr);Vi.exports=ki?Qo:function(r){return function(){return sr.apply(r,arguments)}}});var Pe=p((hd,Fi)=>{"use strict";var ji=W(),Yo=ji({}.toString),Zo=ji("".slice);Fi.exports=function(r){return Zo(Yo(r),8,-1)}});var or=p((dd,Ni)=>{"use strict";var Xo=Pe(),Jo=W();Ni.exports=function(r){if(Xo(r)==="Function")return Jo(r)}});var U=p((fd,$i)=>{"use strict";var lr=typeof document=="object"&&document.all;$i.exports=typeof lr=="undefined"&&lr!==void 0?function(r){return typeof r=="function"||r===lr}:function(r){return typeof r=="function"}});var se=p((md,qi)=>{"use strict";var el=G();qi.exports=!el(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var yt=p((yd,Bi)=>{"use strict";var tl=Re(),mt=Function.prototype.call;Bi.exports=tl?mt.bind(mt):function(){return mt.apply(mt,arguments)}});var cr=p(Gi=>{"use strict";var Di={}.propertyIsEnumerable,Hi=Object.getOwnPropertyDescriptor,rl=Hi&&!Di.call({1:2},1);Gi.f=rl?function(e){var t=Hi(this,e);return!!t&&t.enumerable}:Di});var pr=p((gd,Ui)=>{"use strict";Ui.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var Wi=p((bd,zi)=>{"use strict";var il=W(),nl=G(),al=Pe(),ur=Object,sl=il("".split);zi.exports=nl(function(){return!ur("z").propertyIsEnumerable(0)})?function(r){return al(r)==="String"?sl(r,""):ur(r)}:ur});var hr=p((Cd,Ki)=>{"use strict";Ki.exports=function(r){return r==null}});var dr=p((Ed,Qi)=>{"use strict";var ol=hr(),ll=TypeError;Qi.exports=function(r){if(ol(r))throw new ll("Can't call method on "+r);return r}});var ke=p((xd,Yi)=>{"use strict";var cl=Wi(),pl=dr();Yi.exports=function(r){return cl(pl(r))}});var ge=p((Id,Zi)=>{"use strict";var ul=U();Zi.exports=function(r){return typeof r=="object"?r!==null:ul(r)}});var vt=p((Td,Xi)=>{"use strict";Xi.exports={}});var gt=p((Sd,en)=>{"use strict";var fr=vt(),mr=Q(),hl=U(),Ji=function(r){return hl(r)?r:void 0};en.exports=function(r,e){return arguments.length<2?Ji(fr[r])||Ji(mr[r]):fr[r]&&fr[r][e]||mr[r]&&mr[r][e]}});var rn=p((wd,tn)=>{"use strict";var dl=W();tn.exports=dl({}.isPrototypeOf)});var on=p((_d,sn)=>{"use strict";var fl=Q(),nn=fl.navigator,an=nn&&nn.userAgent;sn.exports=an?String(an):""});var fn=p((Ad,dn)=>{"use strict";var hn=Q(),yr=on(),ln=hn.process,cn=hn.Deno,pn=ln&&ln.versions||cn&&cn.version,un=pn&&pn.v8,K,bt;un&&(K=un.split("."),bt=K[0]>0&&K[0]<4?1:+(K[0]+K[1]));!bt&&yr&&(K=yr.match(/Edge\/(\d+)/),(!K||K[1]>=74)&&(K=yr.match(/Chrome\/(\d+)/),K&&(bt=+K[1])));dn.exports=bt});var vr=p((Ld,yn)=>{"use strict";var mn=fn(),ml=G(),yl=Q(),vl=yl.String;yn.exports=!!Object.getOwnPropertySymbols&&!ml(function(){var r=Symbol("symbol detection");return!vl(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&mn&&mn<41})});var gr=p((Md,vn)=>{"use strict";var gl=vr();vn.exports=gl&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var br=p((Rd,gn)=>{"use strict";var bl=gt(),Cl=U(),El=rn(),xl=gr(),Il=Object;gn.exports=xl?function(r){return typeof r=="symbol"}:function(r){var e=bl("Symbol");return Cl(e)&&El(e.prototype,Il(r))}});var Cn=p((Pd,bn)=>{"use strict";var Tl=String;bn.exports=function(r){try{return Tl(r)}catch(e){return"Object"}}});var Cr=p((kd,En)=>{"use strict";var Sl=U(),wl=Cn(),_l=TypeError;En.exports=function(r){if(Sl(r))return r;throw new _l(wl(r)+" is not a function")}});var In=p((Od,xn)=>{"use strict";var Al=Cr(),Ll=hr();xn.exports=function(r,e){var t=r[e];return Ll(t)?void 0:Al(t)}});var Sn=p((Vd,Tn)=>{"use strict";var Er=yt(),xr=U(),Ir=ge(),Ml=TypeError;Tn.exports=function(r,e){var t,i;if(e==="string"&&xr(t=r.toString)&&!Ir(i=Er(t,r))||xr(t=r.valueOf)&&!Ir(i=Er(t,r))||e!=="string"&&xr(t=r.toString)&&!Ir(i=Er(t,r)))return i;throw new Ml("Can't convert object to primitive value")}});var _n=p((jd,wn)=>{"use strict";wn.exports=!0});var Mn=p((Fd,Ln)=>{"use strict";var An=Q(),Rl=Object.defineProperty;Ln.exports=function(r,e){try{Rl(An,r,{value:e,configurable:!0,writable:!0})}catch(t){An[r]=e}return e}});var Ct=p((Nd,kn)=>{"use strict";var Pl=_n(),kl=Q(),Ol=Mn(),Rn="__core-js_shared__",Pn=kn.exports=kl[Rn]||Ol(Rn,{});(Pn.versions||(Pn.versions=[])).push({version:"3.38.0",mode:Pl?"pure":"global",copyright:"\xA9 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.38.0/LICENSE",source:"https://github.com/zloirock/core-js"})});var Tr=p(($d,Vn)=>{"use strict";var On=Ct();Vn.exports=function(r,e){return On[r]||(On[r]=e||{})}});var Oe=p((qd,jn)=>{"use strict";var Vl=dr(),jl=Object;jn.exports=function(r){return jl(Vl(r))}});var be=p((Bd,Fn)=>{"use strict";var Fl=W(),Nl=Oe(),$l=Fl({}.hasOwnProperty);Fn.exports=Object.hasOwn||function(e,t){return $l(Nl(e),t)}});var Sr=p((Dd,Nn)=>{"use strict";var ql=W(),Bl=0,Dl=Math.random(),Hl=ql(1 .toString);Nn.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+Hl(++Bl+Dl,36)}});var Ve=p((Hd,qn)=>{"use strict";var Gl=Q(),Ul=Tr(),$n=be(),zl=Sr(),Wl=vr(),Kl=gr(),Ce=Gl.Symbol,wr=Ul("wks"),Ql=Kl?Ce.for||Ce:Ce&&Ce.withoutSetter||zl;qn.exports=function(r){return $n(wr,r)||(wr[r]=Wl&&$n(Ce,r)?Ce[r]:Ql("Symbol."+r)),wr[r]}});var Gn=p((Gd,Hn)=>{"use strict";var Yl=yt(),Bn=ge(),Dn=br(),Zl=In(),Xl=Sn(),Jl=Ve(),ec=TypeError,tc=Jl("toPrimitive");Hn.exports=function(r,e){if(!Bn(r)||Dn(r))return r;var t=Zl(r,tc),i;if(t){if(e===void 0&&(e="default"),i=Yl(t,r,e),!Bn(i)||Dn(i))return i;throw new ec("Can't convert object to primitive value")}return e===void 0&&(e="number"),Xl(r,e)}});var _r=p((Ud,Un)=>{"use strict";var rc=Gn(),ic=br();Un.exports=function(r){var e=rc(r,"string");return ic(e)?e:e+""}});var Kn=p((zd,Wn)=>{"use strict";var nc=Q(),zn=ge(),Ar=nc.document,ac=zn(Ar)&&zn(Ar.createElement);Wn.exports=function(r){return ac?Ar.createElement(r):{}}});var Lr=p((Wd,Qn)=>{"use strict";var sc=se(),oc=G(),lc=Kn();Qn.exports=!sc&&!oc(function(){return Object.defineProperty(lc("div"),"a",{get:function(){return 7}}).a!==7})});var Xn=p(Zn=>{"use strict";var cc=se(),pc=yt(),uc=cr(),hc=pr(),dc=ke(),fc=_r(),mc=be(),yc=Lr(),Yn=Object.getOwnPropertyDescriptor;Zn.f=cc?Yn:function(e,t){if(e=dc(e),t=fc(t),yc)try{return Yn(e,t)}catch(i){}if(mc(e,t))return hc(!pc(uc.f,e,t),e[t])}});var ea=p((Qd,Jn)=>{"use strict";var vc=G(),gc=U(),bc=/#|\.prototype\./,je=function(r,e){var t=Ec[Cc(r)];return t===Ic?!0:t===xc?!1:gc(e)?vc(e):!!e},Cc=je.normalize=function(r){return String(r).replace(bc,".").toLowerCase()},Ec=je.data={},xc=je.NATIVE="N",Ic=je.POLYFILL="P";Jn.exports=je});var Mr=p((Yd,ra)=>{"use strict";var ta=or(),Tc=Cr(),Sc=Re(),wc=ta(ta.bind);ra.exports=function(r,e){return Tc(r),e===void 0?r:Sc?wc(r,e):function(){return r.apply(e,arguments)}}});var na=p((Zd,ia)=>{"use strict";var _c=se(),Ac=G();ia.exports=_c&&Ac(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var sa=p((Xd,aa)=>{"use strict";var Lc=ge(),Mc=String,Rc=TypeError;aa.exports=function(r){if(Lc(r))return r;throw new Rc(Mc(r)+" is not an object")}});var ca=p(la=>{"use strict";var Pc=se(),kc=Lr(),Oc=na(),Et=sa(),oa=_r(),Vc=TypeError,Rr=Object.defineProperty,jc=Object.getOwnPropertyDescriptor,Pr="enumerable",kr="configurable",Or="writable";la.f=Pc?Oc?function(e,t,i){if(Et(e),t=oa(t),Et(i),typeof e=="function"&&t==="prototype"&&"value"in i&&Or in i&&!i[Or]){var n=jc(e,t);n&&n[Or]&&(e[t]=i.value,i={configurable:kr in i?i[kr]:n[kr],enumerable:Pr in i?i[Pr]:n[Pr],writable:!1})}return Rr(e,t,i)}:Rr:function(e,t,i){if(Et(e),t=oa(t),Et(i),kc)try{return Rr(e,t,i)}catch(n){}if("get"in i||"set"in i)throw new Vc("Accessors not supported");return"value"in i&&(e[t]=i.value),e}});var ua=p((ef,pa)=>{"use strict";var Fc=se(),Nc=ca(),$c=pr();pa.exports=Fc?function(r,e,t){return Nc.f(r,e,$c(1,t))}:function(r,e,t){return r[e]=t,r}});var Ne=p((tf,da)=>{"use strict";var Fe=Q(),qc=Pi(),Bc=or(),Dc=U(),Hc=Xn().f,Gc=ea(),Ee=vt(),Uc=Mr(),xe=ua(),ha=be();Ct();var zc=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 qc(r,this,arguments)};return e.prototype=r.prototype,e};da.exports=function(r,e){var t=r.target,i=r.global,n=r.stat,a=r.proto,o=i?Fe:n?Fe[t]:Fe[t]&&Fe[t].prototype,l=i?Ee:Ee[t]||xe(Ee,t,{})[t],s=l.prototype,c,y,m,f,E,I,_,b,u;for(f in e)c=Gc(i?f:t+(n?".":"#")+f,r.forced),y=!c&&o&&ha(o,f),I=l[f],y&&(r.dontCallGetSet?(u=Hc(o,f),_=u&&u.value):_=o[f]),E=y&&_?_:e[f],!(!c&&!a&&typeof I==typeof E)&&(r.bind&&y?b=Uc(E,Fe):r.wrap&&y?b=zc(E):a&&Dc(E)?b=Bc(E):b=E,(r.sham||E&&E.sham||I&&I.sham)&&xe(b,"sham",!0),xe(l,f,b),a&&(m=t+"Prototype",ha(Ee,m)||xe(Ee,m,{}),xe(Ee[m],f,E),r.real&&s&&(c||!s[f])&&xe(s,f,E)))}});var ma=p((rf,fa)=>{"use strict";var Wc=Math.ceil,Kc=Math.floor;fa.exports=Math.trunc||function(e){var t=+e;return(t>0?Kc:Wc)(t)}});var $e=p((nf,ya)=>{"use strict";var Qc=ma();ya.exports=function(r){var e=+r;return e!==e||e===0?0:Qc(e)}});var ga=p((af,va)=>{"use strict";var Yc=$e(),Zc=Math.min;va.exports=function(r){var e=Yc(r);return e>0?Zc(e,9007199254740991):0}});var qe=p((sf,ba)=>{"use strict";var Xc=ga();ba.exports=function(r){return Xc(r.length)}});var xt=p((of,Ca)=>{"use strict";Ca.exports=function(){}});var Ea=p(()=>{"use strict";var Jc=Ne(),ep=Oe(),tp=qe(),rp=$e(),ip=xt();Jc({target:"Array",proto:!0},{at:function(e){var t=ep(this),i=tp(t),n=rp(e),a=n>=0?n:i+n;return a<0||a>=i?void 0:t[a]}});ip("at")});var It=p((pf,xa)=>{"use strict";var np=gt();xa.exports=np});var Ta=p((uf,Ia)=>{"use strict";Ea();var ap=It();Ia.exports=ap("Array","at")});var wa=p((hf,Sa)=>{"use strict";var sp=Ta();Sa.exports=sp});var Vr=p((df,_a)=>{"use strict";var op=wa();_a.exports=op});var Wa=p((Nm,za)=>{"use strict";var wp=Tr(),_p=Sr(),Ua=wp("keys");za.exports=function(r){return Ua[r]||(Ua[r]=_p(r))}});var Qa=p(($m,Ka)=>{"use strict";var Ap=G();Ka.exports=!Ap(function(){function r(){}return r.prototype.constructor=null,Object.getPrototypeOf(new r)!==r.prototype})});var Xa=p((qm,Za)=>{"use strict";var Lp=be(),Mp=U(),Rp=Oe(),Pp=Wa(),kp=Qa(),Ya=Pp("IE_PROTO"),Ur=Object,Op=Ur.prototype;Za.exports=kp?Ur.getPrototypeOf:function(r){var e=Rp(r);if(Lp(e,Ya))return e[Ya];var t=e.constructor;return Mp(t)&&e instanceof t?t.prototype:e instanceof Ur?Op:null}});var es=p((Bm,Ja)=>{"use strict";var Vp=$e(),jp=Math.max,Fp=Math.min;Ja.exports=function(r,e){var t=Vp(r);return t<0?jp(t+e,0):Fp(t,e)}});var zr=p((Dm,rs)=>{"use strict";var Np=ke(),$p=es(),qp=qe(),ts=function(r){return function(e,t,i){var n=Np(e),a=qp(n);if(a===0)return!r&&-1;var o=$p(i,a),l;if(r&&t!==t){for(;a>o;)if(l=n[o++],l!==l)return!0}else for(;a>o;o++)if((r||o in n)&&n[o]===t)return r||o||0;return!r&&-1}};rs.exports={includes:ts(!0),indexOf:ts(!1)}});var ns=p((Hm,is)=>{"use strict";is.exports={}});var os=p((Gm,ss)=>{"use strict";var Bp=W(),Wr=be(),Dp=ke(),Hp=zr().indexOf,Gp=ns(),as=Bp([].push);ss.exports=function(r,e){var t=Dp(r),i=0,n=[],a;for(a in t)!Wr(Gp,a)&&Wr(t,a)&&as(n,a);for(;e.length>i;)Wr(t,a=e[i++])&&(~Hp(n,a)||as(n,a));return n}});var cs=p((Um,ls)=>{"use strict";ls.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var us=p((zm,ps)=>{"use strict";var Up=os(),zp=cs();ps.exports=Object.keys||function(e){return Up(e,zp)}});var vs=p((Wm,ys)=>{"use strict";var ds=se(),Wp=G(),fs=W(),Kp=Xa(),Qp=us(),Yp=ke(),Zp=cr().f,ms=fs(Zp),Xp=fs([].push),Jp=ds&&Wp(function(){var r=Object.create(null);return r[2]=2,!ms(r,2)}),hs=function(r){return function(e){for(var t=Yp(e),i=Qp(t),n=Jp&&Kp(t)===null,a=i.length,o=0,l=[],s;a>o;)s=i[o++],(!ds||(n?s in t:ms(t,s)))&&Xp(l,r?[s,t[s]]:t[s]);return l}};ys.exports={entries:hs(!0),values:hs(!1)}});var gs=p(()=>{"use strict";var eu=Ne(),tu=vs().values;eu({target:"Object",stat:!0},{values:function(e){return tu(e)}})});var Cs=p((Ym,bs)=>{"use strict";gs();var ru=vt();bs.exports=ru.Object.values});var xs=p((Zm,Es)=>{"use strict";var iu=Cs();Es.exports=iu});var Nt=p((Xm,Is)=>{"use strict";var nu=xs();Is.exports=nu});var ws=p(()=>{"use strict";var au=Ne(),su=zr().includes,ou=G(),lu=xt(),cu=ou(function(){return!Array(1).includes()});au({target:"Array",proto:!0,forced:cu},{includes:function(e){return su(this,e,arguments.length>1?arguments[1]:void 0)}});lu("includes")});var As=p((ny,_s)=>{"use strict";ws();var pu=It();_s.exports=pu("Array","includes")});var Ms=p((ay,Ls)=>{"use strict";var uu=As();Ls.exports=uu});var $t=p((sy,Rs)=>{"use strict";var hu=Ms();Rs.exports=hu});var Xr=p((wy,Vs)=>{"use strict";var gu=Pe();Vs.exports=Array.isArray||function(e){return gu(e)==="Array"}});var Fs=p((_y,js)=>{"use strict";var bu=TypeError,Cu=9007199254740991;js.exports=function(r){if(r>Cu)throw bu("Maximum allowed index exceeded");return r}});var qs=p((Ay,$s)=>{"use strict";var Eu=Xr(),xu=qe(),Iu=Fs(),Tu=Mr(),Ns=function(r,e,t,i,n,a,o,l){for(var s=n,c=0,y=o?Tu(o,l):!1,m,f;c<i;)c in t&&(m=y?y(t[c],c,e):t[c],a>0&&Eu(m)?(f=xu(m),s=Ns(r,e,m,f,s,a-1)-1):(Iu(s+1),r[s]=m),s++),c++;return s};$s.exports=Ns});var Hs=p((Ly,Ds)=>{"use strict";var Su=Ve(),wu=Su("toStringTag"),Bs={};Bs[wu]="z";Ds.exports=String(Bs)==="[object z]"});var Us=p((My,Gs)=>{"use strict";var _u=Hs(),Au=U(),Bt=Pe(),Lu=Ve(),Mu=Lu("toStringTag"),Ru=Object,Pu=Bt(function(){return arguments}())==="Arguments",ku=function(r,e){try{return r[e]}catch(t){}};Gs.exports=_u?Bt:function(r){var e,t,i;return r===void 0?"Undefined":r===null?"Null":typeof(t=ku(e=Ru(r),Mu))=="string"?t:Pu?Bt(e):(i=Bt(e))==="Object"&&Au(e.callee)?"Arguments":i}});var Ws=p((Ry,zs)=>{"use strict";var Ou=W(),Vu=U(),Jr=Ct(),ju=Ou(Function.toString);Vu(Jr.inspectSource)||(Jr.inspectSource=function(r){return ju(r)});zs.exports=Jr.inspectSource});var Js=p((Py,Xs)=>{"use strict";var Fu=W(),Nu=G(),Ks=U(),$u=Us(),qu=gt(),Bu=Ws(),Qs=function(){},Ys=qu("Reflect","construct"),ei=/^\s*(?:class|function)\b/,Du=Fu(ei.exec),Hu=!ei.test(Qs),Ze=function(e){if(!Ks(e))return!1;try{return Ys(Qs,[],e),!0}catch(t){return!1}},Zs=function(e){if(!Ks(e))return!1;switch($u(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Hu||!!Du(ei,Bu(e))}catch(t){return!0}};Zs.sham=!0;Xs.exports=!Ys||Nu(function(){var r;return Ze(Ze.call)||!Ze(Object)||!Ze(function(){r=!0})||r})?Zs:Ze});var io=p((ky,ro)=>{"use strict";var eo=Xr(),Gu=Js(),Uu=ge(),zu=Ve(),Wu=zu("species"),to=Array;ro.exports=function(r){var e;return eo(r)&&(e=r.constructor,Gu(e)&&(e===to||eo(e.prototype))?e=void 0:Uu(e)&&(e=e[Wu],e===null&&(e=void 0))),e===void 0?to:e}});var ao=p((Oy,no)=>{"use strict";var Ku=io();no.exports=function(r,e){return new(Ku(r))(e===0?0:e)}});var so=p(()=>{"use strict";var Qu=Ne(),Yu=qs(),Zu=Oe(),Xu=qe(),Ju=$e(),eh=ao();Qu({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=Zu(this),i=Xu(t),n=eh(t,0);return n.length=Yu(n,t,t,i,0,e===void 0?1:Ju(e)),n}})});var oo=p(()=>{"use strict";var th=xt();th("flat")});var co=p(($y,lo)=>{"use strict";so();oo();var rh=It();lo.exports=rh("Array","flat")});var uo=p((qy,po)=>{"use strict";var ih=co();po.exports=ih});var fo=p((By,ho)=>{"use strict";var nh=uo();ho.exports=nh});var bi="1.0.26-beta.1";function Xt(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 B="interactive",zo="interactive-controls-container",at=()=>document.querySelector(`.${zo}`),Ci=.4,$={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0},Ei=(i=>(i.top="flex-start",i.bottom="flex-end",i.center="center",i))(Ei||{}),xi=(i=>(i.start="flex-start",i.end="flex-end",i.center="center",i))(xi||{}),Ii=(i=>(i.start="left",i.end="right",i.center="center",i))(Ii||{}),st=({target:r,props:e})=>{var t,i,n,a,o,l;r.style.alignItems=(i=((t=e.text)==null?void 0:t.gravityVertical)&&Ei[e.text.gravityVertical])!=null?i:"center",r.style.justifyContent=(a=((n=e.text)==null?void 0:n.gravityHorizontal)&&xi[e.text.gravityHorizontal])!=null?a:"center",r.style.textAlign=(l=((o=e.text)==null?void 0:o.alignment)&&Ii[e.text.alignment])!=null?l:"left"},ot=({target:r,props:e,fallback:t,dependsOn:i})=>{var n,a,o,l,s,c;r.style.color=(a=(n=e==null?void 0:e.text)==null?void 0:n.color)!=null?a:t.textColor,r.style.fontSize=`calc(${i.height} * ${(l=(o=e==null?void 0:e.text)==null?void 0:o.size)!=null?l:t.textSize})`,r.textContent=(c=(s=e==null?void 0:e.text)==null?void 0:s.value)!=null?c:t.textContent},lt=({target:r,props:e,fallback:t})=>{var i,n,a,o;r.style.backgroundColor=Xt((n=(i=e==null?void 0:e.background)==null?void 0:i.color)!=null?n:t.backgroundColor,(o=(a=e==null?void 0:e.background)==null?void 0:a.alpha)!=null?o:t.backgroundAlpha)},ct=({target:r,props:e,fallback:t,dependsOn:i})=>{var n,a,o,l,s,c,y,m,f,E,I;r.style.border=`calc(${i.height} * ${(o=(a=(n=e==null?void 0:e.shape)==null?void 0:n.border)==null?void 0:a.width)!=null?o:t.borderWidth}) solid ${Xt((c=(s=(l=e==null?void 0:e.shape)==null?void 0:l.border)==null?void 0:s.color)!=null?c:t.borderColor,(f=(m=(y=e==null?void 0:e.shape)==null?void 0:y.border)==null?void 0:m.alpha)!=null?f:t.borderAlpha)}`,r.style.borderRadius=`calc(${i.height} * ${(I=(E=e==null?void 0:e.shape)==null?void 0:E.roundCorners)!=null?I:t.roundCorners})`},ye=({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 J=class{constructor(e){this.control=e;this.container=null;this.controlElement=null;this.clickListener=null}createContainerElement(e){var n;let t=document.createElement("div");t.classList.add(`${B}-control-container-${this.control.id}`),e(t,this.control.layoutParams);let i=((n=this.control.layoutParams.innerSizesDependOn)!=null?n:$.innerSizesDependOn)==="self"?{height:t.style.height,width:t.style.width}:{height:"var(--interactive-content-height)",width:"var(--interactive-content-width)"};this.container={element:t,dimensions:i}}createClickListener(e){return t=>{t.stopPropagation(),e()}}setEvents(e){!this.container||!this.control.events||this.control.events.forEach(t=>{var n;switch(t.type.trim().toLowerCase()){case"onclick":this.clickListener=this.createClickListener(()=>e({action:t.action,controlId:this.control.id,controlType:this.control.type})),(n=this.container)==null||n.element.addEventListener("click",this.clickListener);break;default:break}})}removeListeners(){var e,t;(e=this.container)!=null&&e.element&&this.clickListener&&((t=this.container)==null||t.element.removeEventListener("click",this.clickListener))}};var Jt="int",ae=(i=>(i.AREA=`${Jt}_area`,i.TEXT=`${Jt}_text`,i.BUTTON=`${Jt}_bttn`,i))(ae||{});var pt=r=>{if(r.type.trim().toLowerCase()==="area")return new er(r)},er=class extends J{constructor(e){super(e)}createView({parentElement:e,layoutCallback:t}){if(super.createContainerElement(t),!this.container)return;let i=document.createElement("button");i.type="button",i.classList.add(`${B}-${this.control.id}`),i.setAttribute("data-testid",ae.AREA),i.style.display="flex",i.style.width="100%",i.style.height="100%",i.style.cursor="pointer",lt({target:i,props:this.control.props,fallback:C(d({},$),{backgroundColor:"transparent"})}),ct({target:i,props:this.control.props,fallback:C(d({},$),{borderAlpha:0}),dependsOn:this.container.dimensions}),ye({target:i,layoutParams:this.control.layoutParams,fallback:$}),this.container.element.append(i),e.append(this.container.element),this.controlElement=i}disable(){this.controlElement&&(this.controlElement.style.cursor="default")}enable(){this.controlElement&&(this.controlElement.style.cursor="pointer")}getElement(){return this.controlElement}};var ut=()=>{let r=document.createElement("span");return r.style.display="inline-block",r.style.whiteSpace="pre",r.style.overflow="hidden",r.style.textOverflow="ellipsis",r.style.maxWidth="100%",r.style.maxHeight="100%",r};var ht=r=>{if(r.type.trim().toLowerCase()==="button")return new tr(r)},tr=class extends J{constructor(e){super(e)}createView({parentElement:e,layoutCallback:t}){if(super.createContainerElement(t),!this.container)return;let i=document.createElement("button");i.type="button",i.classList.add(`${B}-${this.control.id}`),i.setAttribute("data-testid",ae.BUTTON),i.style.display="flex",i.style.width="100%",i.style.height="100%",i.style.cursor="pointer",i.style.fontFamily="inherit",ye({target:i,layoutParams:this.control.layoutParams,fallback:$}),lt({target:i,props:this.control.props,fallback:$}),ct({target:i,props:this.control.props,fallback:$,dependsOn:this.container.dimensions}),st({target:i,props:this.control.props});let n=ut();ot({target:n,props:this.control.props,fallback:$,dependsOn:this.container.dimensions}),i.append(n),this.container.element.append(i),e.append(this.container.element),this.controlElement=i}disable(){this.controlElement&&(this.controlElement.style.cursor="default")}enable(){this.controlElement&&(this.controlElement.style.cursor="pointer")}getElement(){return this.controlElement}};var Ti=r=>{if(r.type.trim().toLowerCase()==="text")return new rr(r)},rr=class extends J{constructor(e){super(e)}createView({parentElement:e,layoutCallback:t}){if(super.createContainerElement(t),!this.container)return;let i=document.createElement("div");i.classList.add(`${B}-${this.control.id}`),i.setAttribute("data-testid",ae.TEXT),i.style.display="flex",i.style.width="100%",i.style.height="100%",i.style.fontFamily="inherit",ye({target:i,layoutParams:this.control.layoutParams,fallback:$}),st({target:i,props:this.control.props});let n=ut();ot({target:n,props:this.control.props,fallback:$,dependsOn:this.container.dimensions}),i.append(n),this.container.element.append(i),e.append(this.container.element),this.controlElement=i}disable(){}enable(){}getElement(){return this.controlElement}};var ir=class{constructor(e){this.layout=e}},dt=class extends ir{constructor(e){super(e)}setContainerLayout(e){e.style.position="relative"}setControlLayout(e,t){e.style.position="absolute",e.style.width=`calc(var(--interactive-content-width) * ${t.width})`,e.style.height=`calc(var(--interactive-content-height) * ${t.height})`,e.style.left=`calc(var(--interactive-content-width) * ${t.x} + ((var(--interactive-width) - var(--interactive-content-width)) / 2))`,e.style.top=`calc(var(--interactive-content-height) * ${t.y} + ((var(--interactive-height) - var(--interactive-content-height)) / 2))`}};var ve=class{constructor(e){this.container=e,this.factories=new Map,this.controls=[],this.setControls()}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(),a=this.factories.get(n);if(a){let o=a(i);if(o)return[...t,o]}return[...t]},[]))||[]}};var ft=(r,e)=>{if(r.type.trim().toLowerCase()==="choice")return new nr(r,e)},nr=class extends ve{constructor(e,t){super(e),this.rootElement=t!=null?t:at(),this.layout=new dt(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",ht),this.addControlFactory("text",Ti),this.addControlFactory("area",pt)}createView(e){let t=document.createElement("div");return t.classList.add(`${B}-${this.container.id}`),this.layout.setContainerLayout(t),this.controls.forEach(i=>{i.createView({parentElement:t,layoutCallback:this.layout.setControlLayout}),i.setEvents(e)}),this.rootElement.append(t),this.isRemoved=!1,t}hide(){let e=this.getElement();e&&(e.style.visibility="hidden")}show(){let e=this.getElement();e&&(e.style.visibility="visible")}enable(){let e=this.getElement();e&&(this.controls.forEach(t=>t.enable()),e.style.opacity="1",this.isDisabled=!1)}disable(){let e=this.getElement();e&&(this.controls.forEach(t=>t.disable()),e.style.opacity=`${Ci}`,this.isDisabled=!0)}removeView(){var e;this.isRemoved||(this.controls.forEach(t=>t.removeListeners()),(e=this.getElement())==null||e.remove(),this.isRemoved=!0)}getElement(){return this.rootElement.querySelector(`.${B}-${this.container.id}`)}};var Fo=X(Vr(),1);import{clientChecker as mh,combine as yh,InterfaceLanguage as vh,Observable as Oo,once as gh,Subject as ne,Subscription as Vo,ValueSubject as D}from"@vkontakte/videoplayer-shared/es2015";import{InteractiveInterfaceClick as tt}from"@vkontakte/videoplayer-statistics/es2015";import{loadVKLangPack as lp}from"@vkontakte/videoplayer-shared/es2015";function Be(r,e){let t;return(...i)=>{clearTimeout(t),t=setTimeout(()=>r(...i),e)}}var oe=(r,e)=>Object.prototype.toString.call(r)===`[object ${e}]`,De=r=>oe(r,"Object"),Tt=r=>oe(r,"String"),St=r=>oe(r,"Array"),wt=r=>oe(r,"Number"),Aa=r=>oe(r,"Function");var jr=r=>wt(r)&&!isNaN(r);var le=r=>De(r)&&Object.keys(r).length===0,Fr=r=>St(r)&&!r.length;var He=(r,e)=>Tt(r)&&(e?r.trim():r).length;var La="video_interactive",Ma="videoint";var Ra=250,Ge=class{constructor(e){this.handleZoomChange=Be(e=>{this.lastZoomInfo=e},Ra);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)),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,"Id is not found"),console.error("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,!wt(e.graph.edit.chapters[0].x)){(i=this.onError)==null||i.call(this,"Can't show graph"),console.error("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:a=[]}){this.isReady=!1,this.isHidden=!0,this.manifest=null,this.visitedChapterIds=new Set(a),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=cp(e),this.resizeObserver=new ResizeObserver(Be(this.onResize,Ra)),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)}show(){return w(this,null,function*(){var e;this.manifest&&(this.ngEditor||(yield this.initNgEditor()),this.graphWrapperElement.style.display="block",!this.lastZoomInfo&&this.currentChapterId&&((e=this.ngEditor)==null||e.focusChapter(this.currentChapterId)),this.isHidden=!1)})}initNgEditor(){return w(this,null,function*(){if(!this.manifest)return;let e;try{e=yield lp(this.lang,La,Ma)}catch(i){console.log("Unable to load graph language pack")}let{GraphEditor:t}=yield import("@interactiveplatform/movika-graph-editor");this.ngEditor=new t(this.graphWrapperElement,{mode:"read",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.ngEditor.on("control",a=>{var o=a,{name:i}=o,n=j(o,["name"]);var l;i==="openPreview"&&"chapterId"in n&&((l=this.onOpenPreviewClick)==null||l.call(this,n.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 cp(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 Ue=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 a of this._containers){let o=a.startTime-e;if(o<=n&&(a.endTime&&n<=a.endTime||a.endTime===null)){i=!0;break}n<o&&(t=t===-1?o:Math.min(t,o))}return!i&&t!==-1?t:null}}};var ie=(r="",e="")=>{let t=r.split("."),i=e.split("."),n=0;for(let a=0;a<Math.max(t.length,i.length)&&!n;a++)t[a]>i[a]?n=1:t[a]<i[a]?n=-1:n=0;return n};import{v4 as pp}from"uuid";var up="3.1",Pa={default:"setNextBranch",random:"setRandomBranch",weightlessRandom:"setWeightlessRandomBranch",max:"setMaxWeightBranch",min:"setMinWeightBranch"},hp={type:"onSuspense",action:{type:"continuePlayback",args:{shouldOpenNow:!0,isDetachContainer:!0}}},ka=r=>{let e=[];for(let o of r.chapters){let l,s=[];for(let t of o.branches){let i=t,{isDefault:m}=i,f=j(i,["isDefault"]);m&&(l=f.id),s.push(f)}let c=[],y=[];for(let n of o.containers){let a=n,{fallbackStrategy:m}=a,f=j(a,["fallbackStrategy"]);let E=!!f.endTime,I=[hp];switch(m){case"await":E?I=[]:c=[];break;case"default":{let _={type:"onSuspense",action:{type:Pa.default,args:{branchId:l,shouldOpenNow:!E,isDetachContainer:!0}}};E?I=[_]:c=[_];break}case"random":case"weightlessRandom":case"max":case"min":{let _={type:"onSuspense",action:{type:Pa[m],args:{}}};E?I=[_]:c=[_];break}}for(let _ of f.controls)y.push(C(d({},f),{controls:[d({},_)],id:pp(),events:I}))}e.push(C(d({},o),{containers:y,events:c,branches:s}))}return r.metadata.version=up,r.metadata.updated=new Date().toISOString(),C(d({},r),{chapters:e})};var dp="3.2",Oa=r=>{if(!r.media){let e=r.metadata,{media:t}=e,i=j(e,["media"]);return C(d({},r),{metadata:C(d({},i),{version:dp}),media:t})}return r};var fp="3.3",mp=(r=[])=>({edit:{chapters:r},view:{}}),Va={type:"onSuspense",action:{type:"expect",args:{shouldOpenNow:!0,isDetachContainer:!0}}},ja=r=>{var n;let e=[],t=[];for(let a of r.chapters){let i=a,{id:o,x:l,y:s}=i,c=j(i,["id","x","y"]),y=c.containers.map(m=>{var f;return C(d({},m),{controls:m.controls.map(b=>{var u=b,{subtype:E,type:I}=u,_=j(u,["subtype","type"]);return C(d({},_),{type:E!=null?E:I})}),events:(f=m.events)!=null&&f.length?m.events:[Va]})});e.push(C(d({id:o},c),{containers:y,events:(n=c.events)!=null&&n.length?c.events:[Va]})),t.push({id:o,x:l,y:s})}return C(d({},r),{chapters:e,graph:mp(t),metadata:C(d({},r.metadata),{version:fp})})};var yp=[{version:"3.0",migrate:ka},{version:"3.1",migrate:Oa},{version:"3.2",migrate:ja}],Nr=r=>yp.reduce((e,t)=>ie(e.metadata.version,t.version)?e:t.migrate(e),r);var Fa={Button:"Button",Area:"Area",Text:"Text"};var M={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var Na={metadata:"Object",chapters:"Array"},vp="3.0.0",gp="3.3.0",_t=r=>{let e=ie(r,vp);return e===-1?!1:e===0?!0:ie(r,gp)!==1},$a=r=>{if(!De(r))return!1;for(let e in Na)if(!r[e]||!oe(r[e],Na[e]))return!1;return _t(r.metadata.version)},At=r=>r.type===Fa.Text;var F=class{constructor(e,t,...i){this.severity=e;this.category=t;this.data=i}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};var Lt=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 Mt=class{constructor(e){this.fns=[];this.addFn=(e,t=!1)=>{Aa(e)&&(this.fns.push(e),t&&this.updateFn())};this.removeFn=(e,t=!1)=>{this.fns=this.fns.filter(i=>i!==e),t&&this.updateFn()};this.updateFn=()=>{this.fn=()=>{this.fns.forEach(e=>e()),this.raf&&this.forceRequestAnimation()}};this.forceRequestAnimation=()=>{this.fn&&(this.raf=requestAnimationFrame(this.fn))};this.requestAnimation=()=>{this.raf||this.forceRequestAnimation()};this.cancelAnimation=()=>{this.raf&&(cancelAnimationFrame(this.raf),this.raf=void 0)};e&&(this.fn=e,this.addFn(e))}release(){this.cancelAnimation(),this.fn=void 0,this.fns=[]}};import{ValueSubject as Sp}from"@vkontakte/videoplayer-shared/es2015";var Rt=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:[]}}exec(e,t){return w(this,null,function*(){return bp(...this.loaders[e])(t)})}};function bp(...r){return function(t){return w(this,null,function*(){let i=[...r];for(;i.length>0;)t=yield i.shift()(t);return t})}}function ze(r,e,t){return r?C(d({},r),{[e]:r[e]?[t,...r[e]]:[t]}):{[e]:[t]}}function Pt(n){var a=n,{actions:r,errors:e,chapterId:t}=a,i=j(a,["actions","errors","chapterId"]);if(t){let o=r.getManifest(),l=r.getChapter(o.chapters,t);if(l){let s=r.getMedia(o.media,l.videoId),c=r.getGraph(o.graph,l.id);return s?C(d({},i),{actions:r,errors:e,result:{chapter:l,media:s,graph:c}}):C(d({},i),{errors:ze(e,Pt.name,"Could not find media"),actions:r})}}return C(d({},i),{errors:ze(e,Pt.name,"Could not find chapter"),actions:r})}var kt=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,a=i.length;n<a;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,a=i.length;n<a;n++){let o=i[n];try{o.callback.call(this,e)}catch(l){Promise.resolve().then(()=>{throw l})}o.options&&o.options.once&&this.removeEventListener(e.type,o.callback)}return!e.defaultPrevented}},Ie=class extends kt{constructor(){super(),this.listeners||kt.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)}},We=class{constructor(){Object.defineProperty(this,"signal",{value:new Ie,writable:!0,configurable:!0})}abort(e){let t;try{t=new Event("abort")}catch(n){typeof document!="undefined"?document.createEvent?(t=document.createEvent("Event"),t.initEvent("abort",!1,!1)):(t=document.createEventObject(),t.type="abort"):t={type:"abort",bubbles:!1,cancelable:!1}}let i=e;if(i===void 0)if(typeof document=="undefined")i=new Error("This operation was aborted"),i.name="AbortError";else try{i=new DOMException("signal is aborted without reason")}catch(n){i=new Error("This operation was aborted"),i.name="AbortError"}this.signal.reason=i,this.signal.dispatchEvent(t)}toString(){return"[object AbortController]"}};typeof Symbol!="undefined"&&Symbol.toStringTag&&(We.prototype[Symbol.toStringTag]="AbortController",Ie.prototype[Symbol.toStringTag]="AbortSignal");function Ot(r){return r.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill"),!0):typeof r.Request=="function"&&!r.Request.prototype.hasOwnProperty("signal")||!r.AbortController}function $r(r){typeof r=="function"&&(r={fetch:r});let{fetch:e,Request:t=e.Request,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n=!1}=r;if(!Ot({fetch:e,Request:t,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n}))return{fetch:e,Request:a};let a=t;(a&&!a.prototype.hasOwnProperty("signal")||n)&&(a=function(c,y){let m;y&&y.signal&&(m=y.signal,delete y.signal);let f=new t(c,y);return m&&Object.defineProperty(f,"signal",{writable:!1,enumerable:!1,configurable:!0,value:m}),f},a.prototype=t.prototype);let o=e;return{fetch:(s,c)=>{let y=a&&a.prototype.isPrototypeOf(s)?s.signal:c?c.signal:void 0;if(y){let m;try{m=new DOMException("Aborted","AbortError")}catch(E){m=new Error("Aborted"),m.name="AbortError"}if(y.aborted)return Promise.reject(m);let f=new Promise((E,I)=>{y.addEventListener("abort",()=>I(m),{once:!0})});return c&&c.signal&&delete c.signal,Promise.race([f,o(s,c)])}return o(s,c)},Request:a}}var Ke=Ot({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),qa=Ke?$r({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,qr=Ke?qa.fetch:window.fetch,mm=Ke?qa.Request:window.Request,ym=Ke?We:window.AbortController,vm=Ke?Ie:window.AbortSignal;var Cp=r=>w(void 0,null,function*(){try{let e={},t;if(Tt(r)){t=new URL(r).href;let n=yield qr(t);if(!n.ok)return{};e=yield n.json()}else if(De(r))e=r;else return{};if(!$a(e))return{};let i=e.metadata.media;if(Tt(i)&&!e.media)try{let n;t?n=new URL(i,t).href:(n=new URL(i).href,t=n);let a=yield qr(n);if(!a.ok)throw new Error;e.metadata.media=yield a.json()}catch(n){return Ip(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch(e){return{}}});function Ba(r){return w(this,null,function*(){let{manifest:e,manifestURL:t}=yield Cp(r),i=Nr(e);return i.media=Ep(i.media,t),delete i.metadata.media,i})}function Vt(r,e){if(e)return r.find(t=>t.id===e)}function Br(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 Dr(r,e){return r.videos.find(t=>t.id===e)}function Ep(r,e){return C(d({},r),{videos:r.videos.map(t=>C(d({},t),{variants:t.variants.map(i=>{let n="url"in i?i.url:"",a=xp(n,e);return C(d({},i),{url:a||n})})}))})}function xp(r="",e){try{return new URL(r,e).href}catch(t){return""}}function Ip(r){return ie(r,"3.2.0")>=0}var jt=r=>St(r)&&!Fr(r),Y=r=>r.order==="end",Ft=r=>St(r.containers)&&!Fr(r.containers)&&Y(r),Da=(r,e)=>{var i;let t=r*1e3;return jt(e.controls)&&t<((i=e.startTime)!=null?i:0)},Hr=(r,e)=>{var i,n;let t=r*1e3;return jt(e.controls)&&t>=((i=e.startTime)!=null?i:0)&&t<=((n=e.endTime)!=null?n:1/0)};var ce=(r=[])=>r.some(e=>e.action.type==="expect"),Gr=(r=[])=>r.find(e=>e.action.type==="expect"),Tp=r=>(r==null?void 0:r.length)===1,Te=r=>Tp(r)&&At(r[0]);function Ha(r,...e){return t=>typeof e[0]=="object"&&typeof t=="object"?r(d(d({},e[0]),t)):r(...e,...t)}var Ga=(r,e)=>ce(r.events)?!1:e.some(({container:t})=>t.container.id!==r.id&&ce(t.container.events)&&t.container.endTime===r.endTime&&!t.isRemoved);var Se=class extends Rt{constructor(t,i){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new Sp(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}setManifest(t){return w(this,null,function*(){var n;this.release();let i=yield this.exec("manifestLoaders",{actions:{addErrorMessage:ze},result:null,errors:null,source:t});return i.errors&&this.errorHandler(i.errors),this.manifest=yield Ba((n=i.result)!=null?n:t),this})}setInitial(){return w(this,null,function*(){return this.setNext()})}setNext(){return w(this,arguments,function*(t=(i=>(i=this.manifest)==null?void 0:i.metadata.initChapterId)()){if(!t)return this;this.prevChapter$.next(this.chapter);let n=yield this.exec("chapterLoaders",Pt({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:Br,getChapter:Vt,getMedia:Dr,getByBranches:this.getByBranches.bind(this),addErrorMessage:ze},result:null,errors:null,chapterId:t}));return n.errors&&this.errorHandler(n.errors),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=Vt(this.manifest.chapters,t);if(n){let a=Dr(this.manifest.media,n.videoId),o=Br(this.manifest.graph,n.id);if(a)return{chapter:n,media:a,graph:o}}return null}getBranches(t=(i=>(i=this.chapter)==null?void 0:i.id)()){var n,a,o;if(t===((n=this.chapter)==null?void 0:n.id))return this.getByBranches((a=this.chapter)==null?void 0:a.branches);{let l=Vt(((o=this.manifest)==null?void 0:o.chapters)||[],t);return this.getByBranches(l==null?void 0:l.branches)}}getByBranches(t=[]){return t.reduce((i,n)=>{let a=this.getByChapterId(n.chapterId);return a&&i.push(a),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 Ps=X(Nt(),1);import{Player as du}from"@vkontakte/videoplayer-core/es2015";import{Subscription as Yr,Tracer as fu,ValueSubject as mu}from"@vkontakte/videoplayer-shared/es2015";var Ts=r=>{let e=r.variants.find(t=>{var i;return((i=t.payload)==null?void 0:i.type)==="vk"});if(e&&"payload"in e){let[t,i]=e.payload.id.split("_");return[t,i]}return[]};var Ss=X(Nt(),1);function Kr(){let r=new Map;function e(s){var c=s,{listId:a=Math.random().toString(),itemId:o=Math.random().toString()}=c,l=j(c,["listId","itemId"]);let y=r.get(a),m=d({},l);return y?y[o]=m:r.set(a,{[o]:m}),d({listId:a,itemId:o},l)}function t(a){var o,l;a.player.destroy(),a.container.remove(),a.subscription.unsubscribe(),(o=a.statistics)==null||o.oneStat.destroy(),(l=a.statistics)==null||l.statSubscription.unsubscribe()}function i(a,o){let l=r.get(a);if(!l)throw Error("Can't remove. Not find.");if(o){let s=l[o];s&&t(s),delete l[o],Object.keys(l).length||r.delete(a)}else{for(let s of(0,Ss.default)(l))t(s);r.delete(a)}}function n(){for(let a of r)i(a[0])}return{createPlayer:e,removePlayer:i,map:r,removeAll:n}}var we=X($t(),1);function Qr(r,e=[]){var a,o,l;let t={},i,n=!e.length;for(let s of r.variants)if(!i&&"cover"in s&&(i=s.cover),"url"in s)switch(s.type.toLowerCase()){case"mp4":(n||(0,we.default)(e,"mp4"))&&(t.MPEG=C(d({},t.MPEG),{[(a=s.standard)!=null?a:"Invariant quality"]:s.url}));break;case"mpeg":(n||(0,we.default)(e,"mpeg"))&&(t.MPEG=C(d({},t.MPEG),{[(o=s.standard)!=null?o:"Invariant quality"]:s.url}));break;case"hls":(n||(0,we.default)(e,"hls"))&&(t=C(d({},t),{HLS:{type:"url",url:s.url}}));break;case"dash":(n||(0,we.default)(e,"dash"))&&(t=C(d({},t),{DASH_SEP:{compatibilityMode:!0,type:"url",url:s.url}}));break;default:break}return{sources:t,thumbUrl:i,title:(l=r.title)!=null?l:""}}var Qe=(r,e)=>{let t=r.info.currentQuality$.getValue(),i=r.info.availableQualities$.getValue();t!==e&&(0,we.default)(i,e)&&(r.setQuality(e),r.setAutoQuality(!1))};var yu=2;function Zr(r){let e=Kr(),t=new Yr,i={},n=null,a=!1,o,l=new mu(null);r&&s(r);function s(b){n=b}function c(b,u,h){var v;if(!n)throw Error("need to set interactive controller");if(!n.options)return;let T=((v=e.map.get(b))!=null?v:{})[u];if(T){i=d({chapterId:h,listId:b,itemId:u},T);let R=i.player;i.subscription.add(R.info.currentQuality$.subscribe(A=>{let q=R.info.position$.getValue(),P=R.info.isAutoQualityEnabled$.getValue();if(!(!A||!q||P))for(let O of e.map)(0,Ps.default)(O[1]).forEach(({player:k})=>{Qe(k,A)})})).add(R.events.started$.subscribe(()=>{y(u)})),T.container.remove(),n.setPlayer(T.player),a||(n.init(),a=!0),l.next({player:i.player,config:i.config,statistics:i.statistics});return}throw Error("Can't set. Not find.")}function y(b){return w(this,null,function*(){if(!n)throw Error("need to set interactive controller");if(le(i)||b!==i.itemId)return;let u=n.getChapterBranches(),h=new Set;for(let g of u)h.has(g.media.id)||(yield f({media:g.media,chapterId:g.chapter.id,setAsActive:!1,title:g.chapter.label}),h.add(g.media.id))})}function m(h){return w(this,arguments,function*({chapter:{id:b},manifestVideo:u}){if(le(i)||!n)return;let g=i.player.info.muted$.getValue(),T=i.player.info.currentQuality$.getValue(),v=i.player.info.isAutoQualityEnabled$.getValue(),R=i.player.info.volume$.getValue(),A=i.player.info.currentPlaybackRate$.getValue(),q=!v,P=!1;for(let O of e.map)if(O[0]===u.id&&!n.state.isReplay$.getValue()){let k=Object.keys(O[1]);for(let N of k)N===i.itemId?(k.length<yu||(P=!0),e.removePlayer(O[0],N)):(P=!0,c(O[0],N,b),q?Qe(i.player,T):i.player.setAutoQuality(!0),i.player.setVolume(R),i.player.setMuted(g),i.player.setPlaybackRate(A))}else e.removePlayer(O[0]);P||(yield f({media:u,chapterId:b,setAsActive:!0,playbackRate:A}),q?Qe(i.player,T):i.player.setAutoQuality(!0),i.player.setVolume(R),i.player.setMuted(g))})}function f(q){return w(this,arguments,function*({media:b,chapterId:u,prefetch:h=!0,setAsActive:g=!0,autoplay:T=!1,preferredExt:v,title:R,playbackRate:A}){var li,ci,pi,ui,hi;let P=Math.random().toString(),O=document.createElement("div");o.append(O);let k;if((li=n==null?void 0:n.options)!=null&&li.vkVideoLoader){let it=Ts(b);it.length&&(k=yield n.options.vkVideoLoader(...it))}let N=((ci=n==null?void 0:n.options)==null?void 0:ci.coreConfig)||void 0,Le=C(d({},N),{configName:[...(pi=N==null?void 0:N.configName)!=null?pi:[],"interactive"]}),rt=C(d({container:O},((ui=k==null?void 0:k.videos)==null?void 0:ui[0])||{sources:Qr(b,v).sources}),{title:R,failoverHosts:(k==null?void 0:k.failoverHosts)||[]}),fe=new du(Le,fu.createRootTracer());fe.initVideo(rt);let si=null;if(k!=null&&k.videos&&(n!=null&&n.options.createOneStat)){let it=k.videos[0],Qt=n.options.createOneStat(it),di=new Yr;Qt&&(di.add(Qt.attachTo(fe)),si={oneStat:Qt,statSubscription:di})}let oi=new Yr,No=(hi=i==null?void 0:i.player)==null?void 0:hi.info.isAutoQualityEnabled$.getValue();oi.add(fe.events.canplay$.subscribe(function(){No||Qe(fe,i.player.info.currentQuality$.getValue()),A&&fe.setPlaybackRate(A)}));let me=e.createPlayer({listId:b.id,itemId:P,player:fe,container:O,sources:Qr(b,v).sources,config:rt,subscription:oi,statistics:si});return g&&c(b.id,me.itemId,u),T&&me.player.play(),h&&!T&&me.player.prepare(),{player:me.player,config:me.config,statistics:me.statistics}})}function E(){I(),n=null,o.remove()}function I(){t.unsubscribe(),e.removeAll(),i={},a=!1}function _(){return w(this,null,function*(){if(!n)throw Error("need to set interactive controller");I(),o=document.createElement("div");let{media:b,chapter:u}=n.getCurrentChapter();b&&u?(t.add(n.events.chapterChanged$.subscribe(m)),yield f({media:b,chapterId:u.id,title:u.label})):console.error("not found")})}return C(d({},e),{init:_,setInteractiveController:s,createPlayer:f,removeAll:E,getActivePlayer:function(){return i},activePlayerChanged:l})}var x={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},Ye={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},L={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};var ks=X($t(),1);import{Subscription as vu}from"@vkontakte/videoplayer-shared/es2015";var qt=class{constructor({player:e,container:t,branches:i,selectBranches:n,interactiveEvents:a,globalEvents:o,globalEventEmitter:l,ignoreContainerEvent:s,permanentTextControls:c,disabledControls$:y,onRemove:m}){this.hide=()=>{setTimeout(()=>{var e,t;this.gameState!==4&&(ce(this.container.container.events)&&this.gameState===3||this.selectBranches.state.isExpect||(this.gameState!==2&&((t=(e=this.container).hide)==null||t.call(e)),this.globalEventEmitter.emit(x.interactives,{subjectId:this.container.container.id,subjectName:"container",type:L.visibility,visibility:!1})))})};this.show=()=>{var e,t,i,n;if(this.gameState===2&&!this.isSelectedControlEvent)if(this.container.getElement())(n=(i=this.container).show)==null||n.call(i),this.globalEventEmitter.emit(x.interactives,{subjectId:this.container.container.id,subjectName:"container",type:L.visibility,visibility:!0,isFirst:!1});else{let o=Ha(this.selectBranches.onControlEvent,{isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.globalEventEmitter.emit(x.interactives,{subjectId:this.container.container.id,subjectName:"container",type:L.visibility,visibility:!1})},onEvent:(l,s)=>{this.isSelectedControlEvent=!0,l!==!1&&(this.removeView(),this.globalEventEmitter.emit(x.interactives,{subjectId:this.container.container.id,subjectName:"container",type:L.visibility,visibility:!1})),(this.gameState===4||this.gameState===3||this.selectBranches.state.isExpect)&&(this.selectBranches.stopExpect(),s(),this.removeView(),this.globalEventEmitter.emit(x.interactives,{subjectId:this.container.container.id,subjectName:"container",type:L.visibility,visibility:!1}))},isEOV:()=>this.gameState===4});this.container.createView(o),this.globalEventEmitter.emit(x.interactives,{subjectId:this.container.container.id,subjectName:"container",type:L.visibility,visibility:!0,isFirst:!0}),this.disabledControls$.getValue()&&((t=(e=this.container).disable)==null||t.call(e))}};this.onEndOfVideo=()=>{this.gameState=4,this.selectContainerEvent(!0)};this.whilePlaying=()=>{var c;let e=this.player.experimental.element$.getValue(),i=e instanceof HTMLVideoElement?e.readyState:void 0,n=[6,5];if(!i||(0,ks.default)(n,this.gameState)&&!this.isPermanentText)return;let a=this.player.getExactTime();if(Da(a,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(Hr(a,this.container.container))this.gameState!==2&&(this.gameState=2,this.onStartTime());else if(this.gameState!==3){let y=this.gameState;this.gameState=3,y===2&&this.onEndTime()}else this.isPermanentText||this.removeView();let o=Hr(a,this.container.container),l=this.container.container.startTime?[this.container.container.startTime,(c=this.container.container.endTime)!=null?c:1/0]:[],s={subjectId:this.container.container.id,subjectName:"container",range:l,currentTime:a,isInteractiveTime:o};this.globalEventEmitter.emit(x.eachTick,s),this.globalEvents.eachTick$.next(s)};this.container=t,this.branches=i,this.selectBranches=n,this.subscription=new vu,this.player=e,this.interactiveEvents=a,this.ignoreContainerEvent=s,this.isPermanentText=c&&Te(t.container.controls),this.disabledControls$=y,this.onRemove=m,this.globalEventEmitter=l,this.gameState=0,this.globalEvents=o,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}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,a;e?(i=(t=this.container).disable)==null||i.call(t):(a=(n=this.container).enable)==null||a.call(n)}))}selectContainerEvent(e=!1){var t;this.interactiveEvents.containersEventsCallState.setCalled({timestamp:e?1/0:this.container.container.endTime,id:this.container.container.id}),!(this.isSelectedControlEvent||this.isSelectedContainerEvent)&&(this.isSelectedContainerEvent=!0,this.ignoreContainerEvent()||this.selectBranches.setManifestContainerEvents({container:this.container.container,branches:this.branches,isEOV:e}),!e&&this.interactiveEvents.exec((t=this.container.container.endTime)!=null?t:1/0))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);let e=ce(this.container.container.events)||this.ignoreContainerEvent();(this.isSelectedControlEvent||!e)&&this.removeView()}onBeforeStartTime(){var e,t;(t=(e=this.container).hide)==null||t.call(e),this.globalEventEmitter.emit(x.interactives,{subjectId:this.container.container.id,subjectName:"container",type:L.visibility,visibility:!1})}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=1}removeView(){var e;this.container.removeView(),this.globalEventEmitter.emit(x.interactives,{subjectId:this.container.container.id,subjectName:"container",type:L.containerRemoved,visibility:!1}),this.gameState=5,(e=this.onRemove)==null||e.call(this)}destroy(){var e;this.reset(),this.removeView(),this.gameState=6,this.subscription.unsubscribe(),this.branches=[],this.interactiveEvents.containersEventsCallState.setCalled({timestamp:(e=this.container.container.endTime)!=null?e:1/0,id:this.container.container.id})}};var Os=(r=[])=>r.reduce((e,t,i)=>{var a,o,l;let n=((a=t==null?void 0:t.controls)!=null?a:[]).filter(s=>!At(s));if(jt(n)){let s=[(o=t.startTime)!=null?o:0,(l=t.endTime)!=null?l:1/0],c=t.id;if(!i)e.push({subjects:[c],range:s});else{let y=[],m=-1/0,f=1/0,E=[],I=[];for(let _=0;_<e.length;_++){let b=e[_];if(I.push(...b.subjects),b.range[0]<f&&(f=b.range[0]),b.range[1]>m&&(m=b.range[1]),s[0]>=b.range[0]&&s[1]<=b.range[1])return e[_].subjects.push(c),e;s[0]<b.range[0]&&s[1]>b.range[0]&&(y.push(_),E=E.concat(b.subjects)),s[0]>=b.range[0]&&s[0]<=b.range[1]&&(y.push(_),E=E.concat(b.subjects),s[0]=b.range[0]),s[1]>=b.range[0]&&s[1]<=b.range[1]&&(y.push(_),E=E.concat(b.subjects),s[1]=b.range[1])}if(I.push(c),s[0]<=f&&s[1]>=m)return[{subjects:I,range:s}];y.length&&y.reverse().forEach(_=>{e.splice(_,1)}),e.push({subjects:E.concat([c]),range:s})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);var yo=X($t(),1),ti=X(Nt(),1),vo=X(fo(),1);function mo(){let r={};function e(){for(let l in r)Object.prototype.hasOwnProperty.call(r,l)&&delete r[l]}function t(l){let s={};for(let c in r)+c<=l&&(s[c]=r[c]);return s}function i(l){let s={};for(let c in r)+c>=l&&(s[c]=r[c]);return s}function n({timestamp:l,priority:s,initiator:c}){var y;if(jr(l)){let m=(y=r[l])!=null?y:null;if(m&&s&&He(s,!0)){let f={},E=m[s];if(E&&(f=d(d({},f),E)),f=le(f)?null:f,f&&He(c,!0)){let I=f[c];return I!=null?I:null}return f}return m}return null}function a({timestamp:l,priority:s,initiator:c}){if(jr(l))if(r[l]){if(s&&He(s,!0))if(r[l][s]){if(c&&He(c,!0))if(r[l][s][c]){if(delete r[l][s][c],!le(r[l][s]))return!0}else return!1;if(delete r[l][s],!le(r[l]))return!0}else return!1;return delete r[l]}else return!1;return!1}function o(m){var f=m,{timestamp:l,priority:s,initiator:c}=f,y=j(f,["timestamp","priority","initiator"]);var E,I,_;(I=(E=r[l])==null?void 0:E[s])!=null&&I[c]?r[l][s][c].push(d({},y)):(_=r[l])!=null&&_[s]?r[l][s]=C(d({},r[l][s]),{[c]:[d({},y)]}):r[l]?r[l]=C(d({},r[l]),{[s]:{[c]:[d({},y)]}}):r[l]={[s]:{[c]:[d({},y)]}}}return{map:r,remove:a,add:o,removeAll:e,get:n,getLte:t,getGte:i}}var ah=[M.expect,M.setNextBranch],sh=1/0;function go(r){let e=r,t,i=oh(),n=mo(),a,o=()=>{f(),u()},l=h=>{n.add.call(void 0,h),I()},s=(h=[])=>{for(let g of h)if(g.action(),(0,yo.default)(ah,g.actionType))break},c=(h=1/0)=>{var R,A,q;let g=Dt((R=n.get({timestamp:h,priority:"control"}))!=null?R:{}),T=Dt((A=n.get({timestamp:h,priority:"container"}))!=null?A:{}),v=Dt((q=n.get({timestamp:h,priority:"chapter"}))!=null?q:{});return[...g,...T,...v]},y=h=>{i.isReady(h)&&s(c(h))},m=()=>{var h;s([...Dt((h=n.get({timestamp:1/0,priority:"chapter"}))!=null?h:{})])},f=()=>{t&&(a==null||a.unsubscribe(),t=void 0)},E=h=>{},I=()=>{t||(t=()=>setTimeout(()=>{y(1/0)}),a=e.events.ended$.subscribe(t))},_=h=>{f(),e=h},b=h=>{h.priority==="container"&&i.resetCalled(h.timestamp),n.remove(h)},u=()=>{i.release(),n.removeAll()};return{setPlayer:_,add:l,remove:b,exec:y,execEndOfVideo:m,listen:I,unlisten:f,release:o,containersEventsCallState:i,getPreparedToExecActions:c}}function oh(){let r=new Map;return{setCalled:({timestamp:o,id:l})=>{let s=r.get(o);s&&s[l]!==void 0&&(s[l]=!0)},setData:(o=[])=>{var l,s;for(let c of o){let y=(l=c.endTime)!=null?l:sh,m=(s=r.get(y))!=null?s:{};r.set(y,C(d({},m),{[c.id]:!1}))}},resetCalled:o=>{let l=r.get(o);if(l)for(let s in l)l[s]=!1},isReady:o=>{let l=r.get(o);return l?!(0,ti.default)(l).some(s=>!s):!0},release:()=>r.clear()}}function Dt(r){return(0,vo.default)((0,ti.default)(r)).sort(e=>e.actionType===M.expect?-1:1)}var bo={videoContentHeight:0,videoContentWidth:0},Co=(r,e)=>{let{height:t,width:i}=e.info.intrinsicVideoSize$.getValue()||{};if(!(t&&i))return bo;let{clientHeight:n,clientWidth:a}=e.experimental.element$.getValue()||{};if(!(n&&a))return bo;let o=t/i,l=n/a,s,c;return l>o?(c=a,s=a*o):l<o?(c=n/o,s=n):(c=a,s=n),{videoContentWidth:c,videoContentHeight:s}};var lh=250;function Eo(r){let e=()=>{},t=new ResizeObserver(l=>{a(l),e=a.bind(null,l)});function i(l){let{parentElement:s,player:c}=r();if(s&&c){let{videoContentWidth:y,videoContentHeight:m}=Co(s,c);s.style.setProperty("--interactive-content-width",`${y}px`),s.style.setProperty("--interactive-content-height",`${m}px`),s.style.setProperty("--interactive-width",`${l[0].contentRect.width}px`),s.style.setProperty("--interactive-height",`${l[0].contentRect.height}px`)}}function n(){let{parentElement:l}=r();l.removeAttribute("style")}let a=Be(l=>{let{fns:s=[]}=r();i(l);for(let c of s)c()},lh);function o(){e=void 0,t.disconnect(),n()}return{resizeObserver:t,calc:()=>{e==null||e()},release:o}}var Xe=class{constructor(){this.map={}}push(e,t){e in this.map?this.map[e].push(t):this.map[e]=[t]}get(e){let t=this.map[e];return t?t.slice():null}getAll(){let e=[];for(let t in this.map)e.concat(this.map[t]);return e}remove(e,t){e in this.map&&(this.map[e]=this.map[e].filter(i=>i!==t),this.map[e].length===0&&delete this.map[e])}clear(){this.map={}}keys(){return Object.keys(this.map)}size(){return this.keys().length}};var ch=r=>Math.floor(Math.random()*r),Io=r=>{var n;let e=r.length,t=1/0,i=null;for(;e--;){let a=r[e],o=(n=a.weight)!=null?n:1;o<t&&(t=o,i=a)}return i},To=r=>{var n;let e=r.length,t=-1/0,i=null;for(;e--;){let a=r[e],o=(n=a.weight)!=null?n:0;o>t&&(t=o,i=a)}return i};var So=r=>{let e=r.length,t=ch(e);return r[t]},xo=1,wo=r=>{var i,n;let e=0;for(let a=0;a<r.length;++a)e+=(i=r[a].weight)!=null?i:xo;let t=Math.random()*e;e=0;for(let a=0;a<r.length-1;++a)if(e+=(n=r[a].weight)!=null?n:xo,e>=t)return r[a];return r[r.length-1]};var _o={shouldOpenNow:!0,isDetachContainer:!0};var ri=(r,e=!1)=>C(d({},r),{args:e?d(d({},r.args),_o):d(d({},_o),r.args)}),Mo=({globalEventEmitter:r,player:e,interactiveEvents:t,removeControllers:i})=>{let n={isExpect:!1},a=()=>{n.isExpect&&(n.isExpect=!1)},o=({action:u,controlType:h,controlId:g,containerId:T,branches:v=[],onEvent:R,isEOV:A=()=>!1,isDisabled:q=()=>!1})=>{let P=ri(u,A()),O={timestamp:1/0,priority:"control",initiator:g,actionType:P.type},k=q(),N=r.emit.bind(r,x.interactives,{subjectId:g,subjectType:h,subjectName:"control",type:k?L.actionChoiceCanceled:L.actionChoice,actionType:u.type,payload:d({containerId:T},P.args)});if(k){N();return}switch(P.type.trim().toLowerCase()){case M.setNextBranch.trim().toLowerCase():{let Le=v.find(rt=>rt.id===P.args.branchId);if(!Le)return;R(P.args.isDetachContainer,f.bind(null,{subjectId:g,subjectName:"control"})),N(),P.args.shouldOpenNow?I({subjectId:g,subjectName:"control",subjectType:h,action:P,payload:{chapterId:Le.chapterId,autoSelect:!1}}):(t.add(C(d({},O),{action:I.bind(null,{subjectId:g,subjectName:"control",subjectType:h,action:P,payload:{chapterId:Le.chapterId,autoSelect:!1}})})),i==null||i());return}case M.continuePlayback.trim().toLowerCase():{R(P.args.isDetachContainer,f.bind(null,{subjectId:g,subjectName:"control"})),N(),P.args.shouldOpenNow?E({subjectId:g,subjectName:"control",subjectType:h,action:u}):t.add(C(d({},O),{action:E.bind(null,{subjectId:g,subjectName:"control",subjectType:h,action:u})}));return}case M.openURI.trim().toLowerCase():{R(P.args.isDetachContainer,f.bind(null,{subjectId:g,subjectName:"control"})),N(),P.args.shouldOpenNow?b({subjectId:g,subjectName:"control",subjectType:h,action:P,payload:{URI:u.args.uri}}):(t.add(C(d({},O),{action:b.bind(null,{subjectId:g,subjectName:"control",subjectType:h,action:P,payload:{URI:u.args.uri}})})),i==null||i());return}default:console.error("Unexpected control event"),r.emit(x.errors,new F(1,1,{message:"Unexpected control event"}));return}},l=({action:u,container:{id:h,endTime:g},branches:T=[],isEOV:v=!1,autoSelected:R=!1})=>{let A=ri(u,v),q={timestamp:!A.args.shouldOpenNow||v?1/0:g!=null?g:1/0,priority:"container",initiator:h,actionType:A.type},P=r.emit.bind(r,x.interactives,{subjectId:h,subjectName:"container",type:L.actionChoice,actionType:A.type,payload:A.args});switch(A.type.trim().toLowerCase()){case M.setNextBranch.trim().toLowerCase():{let O=T.find(k=>k.id===A.args.branchId);if(!O)return;P(),t.add(C(d({},q),{action:I.bind(null,{subjectId:h,subjectName:"container",action:A,payload:{chapterId:O.chapterId,autoSelect:R}})})),i==null||i();return}case M.setMaxWeightBranch.trim().toLowerCase():return;case M.setMinWeightBranch.trim().toLowerCase():return;case M.setRandomBranch.trim().toLowerCase():return;case M.setWeightlessRandomBranch.trim().toLowerCase():return;case M.continuePlayback.trim().toLowerCase():{P(),t.add(C(d({},q),{action:E.bind(null,{subjectId:h,subjectName:"container",action:A})}));return}case M.openURI.trim().toLowerCase():{P(),t.add(C(d({},q),{action:b.bind(null,{subjectId:h,subjectName:"container",action:A,payload:{URI:u.args.uri}})})),i==null||i();return}default:console.error("Unexpected container event"),r.emit(x.errors,new F(1,1,{message:"Unexpected container event"}));return}};function s({container:u,branches:h,isEOV:g=!1}){var v,R;let T=Gr(u.events);if(T){let A=ri(T.action,g);r.emit(x.interactives,{subjectId:u.id,subjectName:"container",type:L.actionChoice,actionType:A.type,payload:A.args}),t.add({timestamp:g?1/0:(v=u.endTime)!=null?v:1/0,priority:"container",initiator:u.id,actionType:M.expect,action:m.bind(null,{subjectId:u.id,subjectName:"container"})}),n.isExpect=!0}else for(let A of(R=u.events)!=null?R:[])l({action:A.action,container:u,branches:h,isEOV:g})}let c=({chapterId:u,action:h,branches:g=[]})=>{let T=r.emit.bind(r,x.interactives,{subjectId:u,subjectName:"chapter",type:L.actionChoice,actionType:h.type,payload:h.args});switch(h.type.trim().toLowerCase()){case M.setNextBranch.trim().toLowerCase():{let v=g.find(R=>R.id===h.args.branchId);return v!=null&&v.chapterId?(T(),I.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case M.setWeightlessRandomBranch.trim().toLowerCase():{let v=So(g);return v!=null&&v.chapterId?(T(),I.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case M.setRandomBranch.trim().toLowerCase():{let v=wo(g);return v!=null&&v.chapterId?(T(),I.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case M.setMaxWeightBranch.trim().toLowerCase():{let v=To(g);return v!=null&&v.chapterId?(T(),I.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case M.setMinWeightBranch.trim().toLowerCase():{let v=Io(g);return v!=null&&v.chapterId?(T(),I.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case M.continuePlayback.trim().toLowerCase():return T(),E.bind(null,{subjectId:u,subjectName:"chapter",action:h});case M.openURI.trim().toLowerCase():return T(),b.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{URI:h.args.uri}});default:console.error("Unexpected chapter event"),r.emit(x.errors,new F(1,1,{message:"Unexpected chapter event"}));return}};function y(u){var g;let h=Gr(u.events);if(h){if(Y(u))return;r.emit(x.interactives,{subjectId:u.id,subjectName:"chapter",type:L.actionChoice,actionType:h.action.type,payload:h.action.args}),t.add({timestamp:1/0,priority:"chapter",initiator:u.id,actionType:M.expect,action:m.bind(null,{subjectId:u.id,subjectName:"chapter"})})}else(g=u.events)==null||g.forEach(T=>{let v=c({chapterId:u.id,action:T.action,branches:u.branches});v&&t.add({timestamp:1/0,priority:"chapter",initiator:u.id,actionType:T.action.type,action:v})})}let m=({subjectId:u,subjectName:h})=>{e.pause(),r.emit(x.interactives,{subjectId:u,subjectName:h,type:L.actionExecution,actionType:M.expect})},f=({subjectId:u,subjectName:h})=>{e.info.isEnded$.getValue()?t.execEndOfVideo():e.play(),r.emit(x.interactives,{subjectId:u,subjectName:h,type:L.actionExecution,actionType:"after-expect"})},E=({subjectId:u,subjectName:h,subjectType:g,action:T})=>{r.emit(x.interactives,{subjectId:u,subjectName:h,subjectType:g,type:L.actionExecution,actionType:T.type})},I=({subjectId:u,subjectName:h,subjectType:g,action:T,payload:v})=>{v.behaviour="change-chapter",r.emit(x.interactives,{subjectId:u,subjectName:h,subjectType:g,type:L.actionExecution,actionType:T.type,payload:v})},_=({subjectId:u,subjectName:h,subjectType:g,action:T,payload:v})=>{v.behaviour="change-manifest",r.emit(x.interactives,{subjectId:u,subjectName:h,subjectType:g,type:L.actionExecution,actionType:T.type,payload:v})},b=({subjectId:u,subjectName:h,subjectType:g,action:T,payload:v})=>{if(!v.URI)return;let R=window.open(v.URI,"_blank","noopener,noreferrer");R&&(R.opener=null),r.emit(x.interactives,{subjectId:u,subjectName:h,subjectType:g,type:L.actionExecution,actionType:T.type})};return{onControlEvent:o,onContainerEvent:l,onChapterEvent:c,onExpectEvent:m,expectEventHandler:f,setManifestChapterEvents:y,setManifestContainerEvents:s,stopExpect:a,state:n}};var ai=X(Vr(),1);import{Subscription as fh,Subject as ni,ValueSubject as Je}from"@vkontakte/videoplayer-shared/es2015";var ii=(r,e)=>{let t={};return r.map(i=>{if(!t[i]){let n=e.chapters.find(o=>o.id===i);if(!n)return null;let a=e.media.videos.find(o=>n.videoId===o.id);if(!a)return null;t[i]=Ro(a)}return t[i]}).filter(Boolean)},uh=r=>{for(let e of r.variants)if(hh(e)&&"payload"in e)return e.payload.id},hh=r=>r.type==="custom"&&"payload"in r&&r.payload.type==="vk",Ro=r=>{let e=uh(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},dh=(r,e)=>{for(let t of r.media.videos)if(e===Ro(t)){for(let i of r.chapters)if(i.videoId===t.id)return i.id;return}},Po=(r,e)=>r.reduce((t,i)=>{let n=dh(e,i);return n?[...t,n]:t},[]);var ee,pe,ue,z,Ht,te,re,Z,he,_e,Ae,et=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:i,historyApi:n,settings:a}){this.state={history$:new Je([]),hasPrevChapter$:new Je(!1),prevChapter$:new Je(null),isInitialChapter$:new Je(!1),isGoBackLimited$:new Je(!1)};H(this,ee,null);H(this,pe);H(this,ue,!1);H(this,z,null);H(this,Ht,null);this.events={inited$:new ni,destroyed$:new ni,error$:new ni};H(this,te,null);H(this,re,null);H(this,Z,null);H(this,he,new fh);H(this,_e,!1);H(this,Ae,0);var o;V(this,te,t),V(this,Z,e),V(this,re,i),V(this,ee,n),V(this,pe,a),this.state.history$&&S(this,he)&&((o=S(this,he))==null||o.add(this.state.history$.subscribe(l=>{var s,c;this.state.prevChapter$.next((0,ai.default)(l,-2)||null),this.state.hasPrevChapter$.next(l.length>1),this.state.isInitialChapter$.next(this.getInitialChapterId()===((c=(s=S(this,z))==null?void 0:s.metadata)==null?void 0:c.initChapterId)),this.state.isGoBackLimited$.next(S(this,Ae)===S(this,pe).maxLength-1)})))}setManifest(e){return w(this,null,function*(){if(!S(this,re)||!S(this,Z))return;V(this,z,e),yield this.getProjectHistory();let t=this.getInitialChapterId();yield S(this,re).setChapter({chapterId:t,pushToHistory:!1}),S(this,ue)||(V(this,ue,!0),this.events.inited$.next({initChapterId:t}))})}get inited(){return S(this,ue)}updateHistory(e,t=!0){return w(this,null,function*(){var l;if(!S(this,z))return;S(this,_e)?(V(this,_e,!1),gi(this,Ae)._++):V(this,Ae,0);let i=S(this,z),n=e.length-S(this,pe).maxLength,a=n>0?e.slice(n):e,o=ii(a,i);if(V(this,Ht,o),this.state.history$.next(a),!(!t||!S(this,ee)||!S(this,te)))try{yield S(this,ee).save(S(this,te),o)}catch(s){let c=new F(1,5,"Unable to save interactive history");this.events.error$.next(c),(l=S(this,Z))==null||l.emit(x.errors,c)}})}goBack(){return w(this,null,function*(){var i;if(!this.state||!S(this,re)){let n=new F(1,5,"Unable to save interactive history");return this.events.error$.next(n),(i=S(this,Z))==null?void 0:i.emit(x.errors,n)}V(this,_e,!0);let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),yield S(this,re).setChapter({chapterId:t,playPrev:!0})})}getProjectHistory(){return w(this,null,function*(){var n;if(!S(this,z)||!S(this,te))return;let e=S(this,z),t=[this.getInitialVideoId()];if(S(this,ee))try{let a=yield S(this,ee).get(S(this,te));a.length&&(t=a)}catch(a){let o=new F(1,5,"Error while trying to fetch data");this.events.error$.next(o),(n=S(this,Z))==null||n.emit(x.errors,o)}let i=Po(t,e);this.state.history$.next(i)})}getInitialChapterId(){var t;let e=this.state.history$.getValue();return(0,ai.default)(e,-1)||S(this,pe).initChapterId||((t=S(this,z))==null?void 0:t.metadata.initChapterId)}getInitialVideoId(){if(S(this,z)){let e=this.getInitialChapterId();return ii([e],S(this,z)).pop()}return null}destroy(){var e,t;V(this,te,null),V(this,ee,null),V(this,re,null),(e=S(this,he))==null||e.unsubscribe(),V(this,he,null),V(this,ue,!1),(t=S(this,Z))==null||t.emit(x.historyDestroyed),this.events.destroyed$.next(),V(this,Z,null)}};ee=new WeakMap,pe=new WeakMap,ue=new WeakMap,z=new WeakMap,Ht=new WeakMap,te=new WeakMap,re=new WeakMap,Z=new WeakMap,he=new WeakMap,_e=new WeakMap,Ae=new WeakMap;var de=class de{constructor(e,t,i,n){this.target=e,this.type=t,this.listener=i,this.options=de._convertOptions(e,n),this.target.addEventListener(t,i,this.options)}unlisten(){var e;this.type&&this.listener&&this.options&&((e=this.target)==null||e.removeEventListener(this.type,this.listener,this.options)),this.target=null,this.type=null,this.listener=null,this.options=!1}static _convertOptions(e,t){if(t===void 0)return!1;if(typeof t=="boolean")return t;{let i=new Set(["passive","capture"]),n=Object.keys(t).filter(o=>!i.has(o));return n.length===0&&console.warn("Unsupported flag(s) to addEventListener: "+n.join(",")),de._doesSupportObject(e)?t:t.capture||!1}}static _doesSupportObject(e){let t=de._supportsObject;if(t===void 0){t=!1;try{let i={},n={get:()=>(t=!0,!1)};Object.defineProperty(i,"passive",n),Object.defineProperty(i,"capture",n);let a=()=>{};e.addEventListener("test",a,i),e.removeEventListener("test",a,i)}catch(i){t=!1}de._supportsObject=t}return t||!1}};de._supportsObject=void 0;var Gt=de;var Ut=class{constructor(){this.bindingMap=new Xe}release(){this.removeAll(),this.bindingMap=null}listen(e,t,i,n){if(!this.bindingMap)return;let a=new Gt(e,t,i,n);this.bindingMap.push(t,a)}listenOnce(e,t,i,n){let a=o=>{this.unlisten(e,t,a),i(o)};this.listen(e,t,a,n)}unlisten(e,t,i){if(!this.bindingMap)return;let n=this.bindingMap.get(t)||[];for(let a of n)a.target===e&&(i===a.listener||!i)&&(a.unlisten(),this.bindingMap.remove(t,a))}removeAll(){if(!this.bindingMap)return;let e=this.bindingMap.getAll();for(let t of e)t.unlisten();this.bindingMap.clear()}};var zt=class{constructor(){this._prevSizeId=0;this.rootElement=document.createElement("canvas")}clear(){var e;(e=this.rootElement.getContext("2d"))==null||e.clearRect(0,0,this.rootElement.width,this.rootElement.height)}isImageDrawn(){var n;let e=(n=this.rootElement.getContext("2d"))==null?void 0:n.getImageData(0,0,this.rootElement.width,this.rootElement.height);if(!e)return!1;let t=e.data,i=t.length;for(let a=3;a<i;a+=40)if(t[a]!==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))}updateCanvasDimensions(e,t=!1){return w(this,null,function*(){let i=e.width+e.height;if(this._prevSizeId===i)return;let n;t&&(n=yield this.save()),this.rootElement.width=e.width,this.rootElement.height=e.height,t&&n&&this.restore(n),this._prevSizeId=i})}save(){return w(this,null,function*(){let e=this.rootElement.toDataURL("image/jpeg",1),t=new Image;return t.crossOrigin="anonymous",t.src=e,yield 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 Wt=class{constructor({parentElement:e,endOffsetMs:t=250,onError:i}){this.currentVideoDurationMs=1/0;this._containerTimeFrameShouldReceived=!1;this._endTimeFrameReceived=!1;this._shouldCallSkip=!1;this.onEachTick=e=>{let t=e!=null?e:this.lastFrameCanvas.canvasImgSrc.currentTime*1e3,i=this.isChapterEndTime(t);if(this.isContainerTime(t))this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!0,this._shouldCallSkip=!0;else if(i)this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1,this._endTimeFrameReceived||(this.draw(),this._endTimeFrameReceived=!0,this.show());else{if(this._shouldCallSkip){this._shouldCallSkip=!1;return}this.reset()}};this.onSeek=()=>{this.onEachTick(),!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived&&(this.hide(),this.lastFrameCanvas.clear())};this.rootElement=document.createElement("div"),this.rootElement.style.cssText=`
|
|
6
|
+
var $o=Object.create;var Yt=Object.defineProperty,qo=Object.defineProperties,Bo=Object.getOwnPropertyDescriptor,Do=Object.getOwnPropertyDescriptors,Ho=Object.getOwnPropertyNames,nt=Object.getOwnPropertySymbols,Go=Object.getPrototypeOf,Zt=Object.prototype.hasOwnProperty,mi=Object.prototype.propertyIsEnumerable;var yi=r=>{throw TypeError(r)};var fi=(r,e,t)=>e in r?Yt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,d=(r,e)=>{for(var t in e||(e={}))Zt.call(e,t)&&fi(r,t,e[t]);if(nt)for(var t of nt(e))mi.call(e,t)&&fi(r,t,e[t]);return r},C=(r,e)=>qo(r,Do(e));var j=(r,e)=>{var t={};for(var i in r)Zt.call(r,i)&&e.indexOf(i)<0&&(t[i]=r[i]);if(r!=null&&nt)for(var i of nt(r))e.indexOf(i)<0&&mi.call(r,i)&&(t[i]=r[i]);return t};var p=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var Uo=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ho(e))!Zt.call(r,n)&&n!==t&&Yt(r,n,{get:()=>e[n],enumerable:!(i=Bo(e,n))||i.enumerable});return r};var X=(r,e,t)=>(t=r!=null?$o(Go(r)):{},Uo(e||!r||!r.__esModule?Yt(t,"default",{value:r,enumerable:!0}):t,r));var vi=(r,e,t)=>e.has(r)||yi("Cannot "+t);var S=(r,e,t)=>(vi(r,e,"read from private field"),t?t.call(r):e.get(r)),H=(r,e,t)=>e.has(r)?yi("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),V=(r,e,t,i)=>(vi(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t);var gi=(r,e,t,i)=>({set _(n){V(r,e,n,t)},get _(){return S(r,e,i)}});var w=(r,e,t)=>new Promise((i,n)=>{var a=s=>{try{l(t.next(s))}catch(c){n(c)}},o=s=>{try{l(t.throw(s))}catch(c){n(c)}},l=s=>s.done?i(s.value):Promise.resolve(s.value).then(a,o);l((t=t.apply(r,e)).next())});var Q=p((ar,Si)=>{"use strict";var Me=function(r){return r&&r.Math===Math&&r};Si.exports=Me(typeof globalThis=="object"&&globalThis)||Me(typeof window=="object"&&window)||Me(typeof self=="object"&&self)||Me(typeof global=="object"&&global)||Me(typeof ar=="object"&&ar)||function(){return this}()||Function("return this")()});var G=p((ld,wi)=>{"use strict";wi.exports=function(r){try{return!!r()}catch(e){return!0}}});var Re=p((cd,_i)=>{"use strict";var Wo=G();_i.exports=!Wo(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var Pi=p((pd,Ri)=>{"use strict";var Ko=Re(),Mi=Function.prototype,Ai=Mi.apply,Li=Mi.call;Ri.exports=typeof Reflect=="object"&&Reflect.apply||(Ko?Li.bind(Ai):function(){return Li.apply(Ai,arguments)})});var W=p((ud,Vi)=>{"use strict";var ki=Re(),Oi=Function.prototype,sr=Oi.call,Qo=ki&&Oi.bind.bind(sr,sr);Vi.exports=ki?Qo:function(r){return function(){return sr.apply(r,arguments)}}});var Pe=p((hd,Fi)=>{"use strict";var ji=W(),Yo=ji({}.toString),Zo=ji("".slice);Fi.exports=function(r){return Zo(Yo(r),8,-1)}});var or=p((dd,Ni)=>{"use strict";var Xo=Pe(),Jo=W();Ni.exports=function(r){if(Xo(r)==="Function")return Jo(r)}});var U=p((fd,$i)=>{"use strict";var lr=typeof document=="object"&&document.all;$i.exports=typeof lr=="undefined"&&lr!==void 0?function(r){return typeof r=="function"||r===lr}:function(r){return typeof r=="function"}});var se=p((md,qi)=>{"use strict";var el=G();qi.exports=!el(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var yt=p((yd,Bi)=>{"use strict";var tl=Re(),mt=Function.prototype.call;Bi.exports=tl?mt.bind(mt):function(){return mt.apply(mt,arguments)}});var cr=p(Gi=>{"use strict";var Di={}.propertyIsEnumerable,Hi=Object.getOwnPropertyDescriptor,rl=Hi&&!Di.call({1:2},1);Gi.f=rl?function(e){var t=Hi(this,e);return!!t&&t.enumerable}:Di});var pr=p((gd,Ui)=>{"use strict";Ui.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var Wi=p((bd,zi)=>{"use strict";var il=W(),nl=G(),al=Pe(),ur=Object,sl=il("".split);zi.exports=nl(function(){return!ur("z").propertyIsEnumerable(0)})?function(r){return al(r)==="String"?sl(r,""):ur(r)}:ur});var hr=p((Cd,Ki)=>{"use strict";Ki.exports=function(r){return r==null}});var dr=p((Ed,Qi)=>{"use strict";var ol=hr(),ll=TypeError;Qi.exports=function(r){if(ol(r))throw new ll("Can't call method on "+r);return r}});var ke=p((xd,Yi)=>{"use strict";var cl=Wi(),pl=dr();Yi.exports=function(r){return cl(pl(r))}});var ge=p((Id,Zi)=>{"use strict";var ul=U();Zi.exports=function(r){return typeof r=="object"?r!==null:ul(r)}});var vt=p((Td,Xi)=>{"use strict";Xi.exports={}});var gt=p((Sd,en)=>{"use strict";var fr=vt(),mr=Q(),hl=U(),Ji=function(r){return hl(r)?r:void 0};en.exports=function(r,e){return arguments.length<2?Ji(fr[r])||Ji(mr[r]):fr[r]&&fr[r][e]||mr[r]&&mr[r][e]}});var rn=p((wd,tn)=>{"use strict";var dl=W();tn.exports=dl({}.isPrototypeOf)});var on=p((_d,sn)=>{"use strict";var fl=Q(),nn=fl.navigator,an=nn&&nn.userAgent;sn.exports=an?String(an):""});var fn=p((Ad,dn)=>{"use strict";var hn=Q(),yr=on(),ln=hn.process,cn=hn.Deno,pn=ln&&ln.versions||cn&&cn.version,un=pn&&pn.v8,K,bt;un&&(K=un.split("."),bt=K[0]>0&&K[0]<4?1:+(K[0]+K[1]));!bt&&yr&&(K=yr.match(/Edge\/(\d+)/),(!K||K[1]>=74)&&(K=yr.match(/Chrome\/(\d+)/),K&&(bt=+K[1])));dn.exports=bt});var vr=p((Ld,yn)=>{"use strict";var mn=fn(),ml=G(),yl=Q(),vl=yl.String;yn.exports=!!Object.getOwnPropertySymbols&&!ml(function(){var r=Symbol("symbol detection");return!vl(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&mn&&mn<41})});var gr=p((Md,vn)=>{"use strict";var gl=vr();vn.exports=gl&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var br=p((Rd,gn)=>{"use strict";var bl=gt(),Cl=U(),El=rn(),xl=gr(),Il=Object;gn.exports=xl?function(r){return typeof r=="symbol"}:function(r){var e=bl("Symbol");return Cl(e)&&El(e.prototype,Il(r))}});var Cn=p((Pd,bn)=>{"use strict";var Tl=String;bn.exports=function(r){try{return Tl(r)}catch(e){return"Object"}}});var Cr=p((kd,En)=>{"use strict";var Sl=U(),wl=Cn(),_l=TypeError;En.exports=function(r){if(Sl(r))return r;throw new _l(wl(r)+" is not a function")}});var In=p((Od,xn)=>{"use strict";var Al=Cr(),Ll=hr();xn.exports=function(r,e){var t=r[e];return Ll(t)?void 0:Al(t)}});var Sn=p((Vd,Tn)=>{"use strict";var Er=yt(),xr=U(),Ir=ge(),Ml=TypeError;Tn.exports=function(r,e){var t,i;if(e==="string"&&xr(t=r.toString)&&!Ir(i=Er(t,r))||xr(t=r.valueOf)&&!Ir(i=Er(t,r))||e!=="string"&&xr(t=r.toString)&&!Ir(i=Er(t,r)))return i;throw new Ml("Can't convert object to primitive value")}});var _n=p((jd,wn)=>{"use strict";wn.exports=!0});var Mn=p((Fd,Ln)=>{"use strict";var An=Q(),Rl=Object.defineProperty;Ln.exports=function(r,e){try{Rl(An,r,{value:e,configurable:!0,writable:!0})}catch(t){An[r]=e}return e}});var Ct=p((Nd,kn)=>{"use strict";var Pl=_n(),kl=Q(),Ol=Mn(),Rn="__core-js_shared__",Pn=kn.exports=kl[Rn]||Ol(Rn,{});(Pn.versions||(Pn.versions=[])).push({version:"3.38.0",mode:Pl?"pure":"global",copyright:"\xA9 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.38.0/LICENSE",source:"https://github.com/zloirock/core-js"})});var Tr=p(($d,Vn)=>{"use strict";var On=Ct();Vn.exports=function(r,e){return On[r]||(On[r]=e||{})}});var Oe=p((qd,jn)=>{"use strict";var Vl=dr(),jl=Object;jn.exports=function(r){return jl(Vl(r))}});var be=p((Bd,Fn)=>{"use strict";var Fl=W(),Nl=Oe(),$l=Fl({}.hasOwnProperty);Fn.exports=Object.hasOwn||function(e,t){return $l(Nl(e),t)}});var Sr=p((Dd,Nn)=>{"use strict";var ql=W(),Bl=0,Dl=Math.random(),Hl=ql(1 .toString);Nn.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+Hl(++Bl+Dl,36)}});var Ve=p((Hd,qn)=>{"use strict";var Gl=Q(),Ul=Tr(),$n=be(),zl=Sr(),Wl=vr(),Kl=gr(),Ce=Gl.Symbol,wr=Ul("wks"),Ql=Kl?Ce.for||Ce:Ce&&Ce.withoutSetter||zl;qn.exports=function(r){return $n(wr,r)||(wr[r]=Wl&&$n(Ce,r)?Ce[r]:Ql("Symbol."+r)),wr[r]}});var Gn=p((Gd,Hn)=>{"use strict";var Yl=yt(),Bn=ge(),Dn=br(),Zl=In(),Xl=Sn(),Jl=Ve(),ec=TypeError,tc=Jl("toPrimitive");Hn.exports=function(r,e){if(!Bn(r)||Dn(r))return r;var t=Zl(r,tc),i;if(t){if(e===void 0&&(e="default"),i=Yl(t,r,e),!Bn(i)||Dn(i))return i;throw new ec("Can't convert object to primitive value")}return e===void 0&&(e="number"),Xl(r,e)}});var _r=p((Ud,Un)=>{"use strict";var rc=Gn(),ic=br();Un.exports=function(r){var e=rc(r,"string");return ic(e)?e:e+""}});var Kn=p((zd,Wn)=>{"use strict";var nc=Q(),zn=ge(),Ar=nc.document,ac=zn(Ar)&&zn(Ar.createElement);Wn.exports=function(r){return ac?Ar.createElement(r):{}}});var Lr=p((Wd,Qn)=>{"use strict";var sc=se(),oc=G(),lc=Kn();Qn.exports=!sc&&!oc(function(){return Object.defineProperty(lc("div"),"a",{get:function(){return 7}}).a!==7})});var Xn=p(Zn=>{"use strict";var cc=se(),pc=yt(),uc=cr(),hc=pr(),dc=ke(),fc=_r(),mc=be(),yc=Lr(),Yn=Object.getOwnPropertyDescriptor;Zn.f=cc?Yn:function(e,t){if(e=dc(e),t=fc(t),yc)try{return Yn(e,t)}catch(i){}if(mc(e,t))return hc(!pc(uc.f,e,t),e[t])}});var ea=p((Qd,Jn)=>{"use strict";var vc=G(),gc=U(),bc=/#|\.prototype\./,je=function(r,e){var t=Ec[Cc(r)];return t===Ic?!0:t===xc?!1:gc(e)?vc(e):!!e},Cc=je.normalize=function(r){return String(r).replace(bc,".").toLowerCase()},Ec=je.data={},xc=je.NATIVE="N",Ic=je.POLYFILL="P";Jn.exports=je});var Mr=p((Yd,ra)=>{"use strict";var ta=or(),Tc=Cr(),Sc=Re(),wc=ta(ta.bind);ra.exports=function(r,e){return Tc(r),e===void 0?r:Sc?wc(r,e):function(){return r.apply(e,arguments)}}});var na=p((Zd,ia)=>{"use strict";var _c=se(),Ac=G();ia.exports=_c&&Ac(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var sa=p((Xd,aa)=>{"use strict";var Lc=ge(),Mc=String,Rc=TypeError;aa.exports=function(r){if(Lc(r))return r;throw new Rc(Mc(r)+" is not an object")}});var ca=p(la=>{"use strict";var Pc=se(),kc=Lr(),Oc=na(),Et=sa(),oa=_r(),Vc=TypeError,Rr=Object.defineProperty,jc=Object.getOwnPropertyDescriptor,Pr="enumerable",kr="configurable",Or="writable";la.f=Pc?Oc?function(e,t,i){if(Et(e),t=oa(t),Et(i),typeof e=="function"&&t==="prototype"&&"value"in i&&Or in i&&!i[Or]){var n=jc(e,t);n&&n[Or]&&(e[t]=i.value,i={configurable:kr in i?i[kr]:n[kr],enumerable:Pr in i?i[Pr]:n[Pr],writable:!1})}return Rr(e,t,i)}:Rr:function(e,t,i){if(Et(e),t=oa(t),Et(i),kc)try{return Rr(e,t,i)}catch(n){}if("get"in i||"set"in i)throw new Vc("Accessors not supported");return"value"in i&&(e[t]=i.value),e}});var ua=p((ef,pa)=>{"use strict";var Fc=se(),Nc=ca(),$c=pr();pa.exports=Fc?function(r,e,t){return Nc.f(r,e,$c(1,t))}:function(r,e,t){return r[e]=t,r}});var Ne=p((tf,da)=>{"use strict";var Fe=Q(),qc=Pi(),Bc=or(),Dc=U(),Hc=Xn().f,Gc=ea(),Ee=vt(),Uc=Mr(),xe=ua(),ha=be();Ct();var zc=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 qc(r,this,arguments)};return e.prototype=r.prototype,e};da.exports=function(r,e){var t=r.target,i=r.global,n=r.stat,a=r.proto,o=i?Fe:n?Fe[t]:Fe[t]&&Fe[t].prototype,l=i?Ee:Ee[t]||xe(Ee,t,{})[t],s=l.prototype,c,y,m,f,E,I,_,b,u;for(f in e)c=Gc(i?f:t+(n?".":"#")+f,r.forced),y=!c&&o&&ha(o,f),I=l[f],y&&(r.dontCallGetSet?(u=Hc(o,f),_=u&&u.value):_=o[f]),E=y&&_?_:e[f],!(!c&&!a&&typeof I==typeof E)&&(r.bind&&y?b=Uc(E,Fe):r.wrap&&y?b=zc(E):a&&Dc(E)?b=Bc(E):b=E,(r.sham||E&&E.sham||I&&I.sham)&&xe(b,"sham",!0),xe(l,f,b),a&&(m=t+"Prototype",ha(Ee,m)||xe(Ee,m,{}),xe(Ee[m],f,E),r.real&&s&&(c||!s[f])&&xe(s,f,E)))}});var ma=p((rf,fa)=>{"use strict";var Wc=Math.ceil,Kc=Math.floor;fa.exports=Math.trunc||function(e){var t=+e;return(t>0?Kc:Wc)(t)}});var $e=p((nf,ya)=>{"use strict";var Qc=ma();ya.exports=function(r){var e=+r;return e!==e||e===0?0:Qc(e)}});var ga=p((af,va)=>{"use strict";var Yc=$e(),Zc=Math.min;va.exports=function(r){var e=Yc(r);return e>0?Zc(e,9007199254740991):0}});var qe=p((sf,ba)=>{"use strict";var Xc=ga();ba.exports=function(r){return Xc(r.length)}});var xt=p((of,Ca)=>{"use strict";Ca.exports=function(){}});var Ea=p(()=>{"use strict";var Jc=Ne(),ep=Oe(),tp=qe(),rp=$e(),ip=xt();Jc({target:"Array",proto:!0},{at:function(e){var t=ep(this),i=tp(t),n=rp(e),a=n>=0?n:i+n;return a<0||a>=i?void 0:t[a]}});ip("at")});var It=p((pf,xa)=>{"use strict";var np=gt();xa.exports=np});var Ta=p((uf,Ia)=>{"use strict";Ea();var ap=It();Ia.exports=ap("Array","at")});var wa=p((hf,Sa)=>{"use strict";var sp=Ta();Sa.exports=sp});var Vr=p((df,_a)=>{"use strict";var op=wa();_a.exports=op});var Wa=p((Nm,za)=>{"use strict";var wp=Tr(),_p=Sr(),Ua=wp("keys");za.exports=function(r){return Ua[r]||(Ua[r]=_p(r))}});var Qa=p(($m,Ka)=>{"use strict";var Ap=G();Ka.exports=!Ap(function(){function r(){}return r.prototype.constructor=null,Object.getPrototypeOf(new r)!==r.prototype})});var Xa=p((qm,Za)=>{"use strict";var Lp=be(),Mp=U(),Rp=Oe(),Pp=Wa(),kp=Qa(),Ya=Pp("IE_PROTO"),Ur=Object,Op=Ur.prototype;Za.exports=kp?Ur.getPrototypeOf:function(r){var e=Rp(r);if(Lp(e,Ya))return e[Ya];var t=e.constructor;return Mp(t)&&e instanceof t?t.prototype:e instanceof Ur?Op:null}});var es=p((Bm,Ja)=>{"use strict";var Vp=$e(),jp=Math.max,Fp=Math.min;Ja.exports=function(r,e){var t=Vp(r);return t<0?jp(t+e,0):Fp(t,e)}});var zr=p((Dm,rs)=>{"use strict";var Np=ke(),$p=es(),qp=qe(),ts=function(r){return function(e,t,i){var n=Np(e),a=qp(n);if(a===0)return!r&&-1;var o=$p(i,a),l;if(r&&t!==t){for(;a>o;)if(l=n[o++],l!==l)return!0}else for(;a>o;o++)if((r||o in n)&&n[o]===t)return r||o||0;return!r&&-1}};rs.exports={includes:ts(!0),indexOf:ts(!1)}});var ns=p((Hm,is)=>{"use strict";is.exports={}});var os=p((Gm,ss)=>{"use strict";var Bp=W(),Wr=be(),Dp=ke(),Hp=zr().indexOf,Gp=ns(),as=Bp([].push);ss.exports=function(r,e){var t=Dp(r),i=0,n=[],a;for(a in t)!Wr(Gp,a)&&Wr(t,a)&&as(n,a);for(;e.length>i;)Wr(t,a=e[i++])&&(~Hp(n,a)||as(n,a));return n}});var cs=p((Um,ls)=>{"use strict";ls.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var us=p((zm,ps)=>{"use strict";var Up=os(),zp=cs();ps.exports=Object.keys||function(e){return Up(e,zp)}});var vs=p((Wm,ys)=>{"use strict";var ds=se(),Wp=G(),fs=W(),Kp=Xa(),Qp=us(),Yp=ke(),Zp=cr().f,ms=fs(Zp),Xp=fs([].push),Jp=ds&&Wp(function(){var r=Object.create(null);return r[2]=2,!ms(r,2)}),hs=function(r){return function(e){for(var t=Yp(e),i=Qp(t),n=Jp&&Kp(t)===null,a=i.length,o=0,l=[],s;a>o;)s=i[o++],(!ds||(n?s in t:ms(t,s)))&&Xp(l,r?[s,t[s]]:t[s]);return l}};ys.exports={entries:hs(!0),values:hs(!1)}});var gs=p(()=>{"use strict";var eu=Ne(),tu=vs().values;eu({target:"Object",stat:!0},{values:function(e){return tu(e)}})});var Cs=p((Ym,bs)=>{"use strict";gs();var ru=vt();bs.exports=ru.Object.values});var xs=p((Zm,Es)=>{"use strict";var iu=Cs();Es.exports=iu});var Nt=p((Xm,Is)=>{"use strict";var nu=xs();Is.exports=nu});var ws=p(()=>{"use strict";var au=Ne(),su=zr().includes,ou=G(),lu=xt(),cu=ou(function(){return!Array(1).includes()});au({target:"Array",proto:!0,forced:cu},{includes:function(e){return su(this,e,arguments.length>1?arguments[1]:void 0)}});lu("includes")});var As=p((ny,_s)=>{"use strict";ws();var pu=It();_s.exports=pu("Array","includes")});var Ms=p((ay,Ls)=>{"use strict";var uu=As();Ls.exports=uu});var $t=p((sy,Rs)=>{"use strict";var hu=Ms();Rs.exports=hu});var Xr=p((wy,Vs)=>{"use strict";var gu=Pe();Vs.exports=Array.isArray||function(e){return gu(e)==="Array"}});var Fs=p((_y,js)=>{"use strict";var bu=TypeError,Cu=9007199254740991;js.exports=function(r){if(r>Cu)throw bu("Maximum allowed index exceeded");return r}});var qs=p((Ay,$s)=>{"use strict";var Eu=Xr(),xu=qe(),Iu=Fs(),Tu=Mr(),Ns=function(r,e,t,i,n,a,o,l){for(var s=n,c=0,y=o?Tu(o,l):!1,m,f;c<i;)c in t&&(m=y?y(t[c],c,e):t[c],a>0&&Eu(m)?(f=xu(m),s=Ns(r,e,m,f,s,a-1)-1):(Iu(s+1),r[s]=m),s++),c++;return s};$s.exports=Ns});var Hs=p((Ly,Ds)=>{"use strict";var Su=Ve(),wu=Su("toStringTag"),Bs={};Bs[wu]="z";Ds.exports=String(Bs)==="[object z]"});var Us=p((My,Gs)=>{"use strict";var _u=Hs(),Au=U(),Bt=Pe(),Lu=Ve(),Mu=Lu("toStringTag"),Ru=Object,Pu=Bt(function(){return arguments}())==="Arguments",ku=function(r,e){try{return r[e]}catch(t){}};Gs.exports=_u?Bt:function(r){var e,t,i;return r===void 0?"Undefined":r===null?"Null":typeof(t=ku(e=Ru(r),Mu))=="string"?t:Pu?Bt(e):(i=Bt(e))==="Object"&&Au(e.callee)?"Arguments":i}});var Ws=p((Ry,zs)=>{"use strict";var Ou=W(),Vu=U(),Jr=Ct(),ju=Ou(Function.toString);Vu(Jr.inspectSource)||(Jr.inspectSource=function(r){return ju(r)});zs.exports=Jr.inspectSource});var Js=p((Py,Xs)=>{"use strict";var Fu=W(),Nu=G(),Ks=U(),$u=Us(),qu=gt(),Bu=Ws(),Qs=function(){},Ys=qu("Reflect","construct"),ei=/^\s*(?:class|function)\b/,Du=Fu(ei.exec),Hu=!ei.test(Qs),Ze=function(e){if(!Ks(e))return!1;try{return Ys(Qs,[],e),!0}catch(t){return!1}},Zs=function(e){if(!Ks(e))return!1;switch($u(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Hu||!!Du(ei,Bu(e))}catch(t){return!0}};Zs.sham=!0;Xs.exports=!Ys||Nu(function(){var r;return Ze(Ze.call)||!Ze(Object)||!Ze(function(){r=!0})||r})?Zs:Ze});var io=p((ky,ro)=>{"use strict";var eo=Xr(),Gu=Js(),Uu=ge(),zu=Ve(),Wu=zu("species"),to=Array;ro.exports=function(r){var e;return eo(r)&&(e=r.constructor,Gu(e)&&(e===to||eo(e.prototype))?e=void 0:Uu(e)&&(e=e[Wu],e===null&&(e=void 0))),e===void 0?to:e}});var ao=p((Oy,no)=>{"use strict";var Ku=io();no.exports=function(r,e){return new(Ku(r))(e===0?0:e)}});var so=p(()=>{"use strict";var Qu=Ne(),Yu=qs(),Zu=Oe(),Xu=qe(),Ju=$e(),eh=ao();Qu({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=Zu(this),i=Xu(t),n=eh(t,0);return n.length=Yu(n,t,t,i,0,e===void 0?1:Ju(e)),n}})});var oo=p(()=>{"use strict";var th=xt();th("flat")});var co=p(($y,lo)=>{"use strict";so();oo();var rh=It();lo.exports=rh("Array","flat")});var uo=p((qy,po)=>{"use strict";var ih=co();po.exports=ih});var fo=p((By,ho)=>{"use strict";var nh=uo();ho.exports=nh});var bi="1.0.26-beta.3";function Xt(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 B="interactive",zo="interactive-controls-container",at=()=>document.querySelector(`.${zo}`),Ci=.4,$={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0},Ei=(i=>(i.top="flex-start",i.bottom="flex-end",i.center="center",i))(Ei||{}),xi=(i=>(i.start="flex-start",i.end="flex-end",i.center="center",i))(xi||{}),Ii=(i=>(i.start="left",i.end="right",i.center="center",i))(Ii||{}),st=({target:r,props:e})=>{var t,i,n,a,o,l;r.style.alignItems=(i=((t=e.text)==null?void 0:t.gravityVertical)&&Ei[e.text.gravityVertical])!=null?i:"center",r.style.justifyContent=(a=((n=e.text)==null?void 0:n.gravityHorizontal)&&xi[e.text.gravityHorizontal])!=null?a:"center",r.style.textAlign=(l=((o=e.text)==null?void 0:o.alignment)&&Ii[e.text.alignment])!=null?l:"left"},ot=({target:r,props:e,fallback:t,dependsOn:i})=>{var n,a,o,l,s,c;r.style.color=(a=(n=e==null?void 0:e.text)==null?void 0:n.color)!=null?a:t.textColor,r.style.fontSize=`calc(${i.height} * ${(l=(o=e==null?void 0:e.text)==null?void 0:o.size)!=null?l:t.textSize})`,r.textContent=(c=(s=e==null?void 0:e.text)==null?void 0:s.value)!=null?c:t.textContent},lt=({target:r,props:e,fallback:t})=>{var i,n,a,o;r.style.backgroundColor=Xt((n=(i=e==null?void 0:e.background)==null?void 0:i.color)!=null?n:t.backgroundColor,(o=(a=e==null?void 0:e.background)==null?void 0:a.alpha)!=null?o:t.backgroundAlpha)},ct=({target:r,props:e,fallback:t,dependsOn:i})=>{var n,a,o,l,s,c,y,m,f,E,I;r.style.border=`calc(${i.height} * ${(o=(a=(n=e==null?void 0:e.shape)==null?void 0:n.border)==null?void 0:a.width)!=null?o:t.borderWidth}) solid ${Xt((c=(s=(l=e==null?void 0:e.shape)==null?void 0:l.border)==null?void 0:s.color)!=null?c:t.borderColor,(f=(m=(y=e==null?void 0:e.shape)==null?void 0:y.border)==null?void 0:m.alpha)!=null?f:t.borderAlpha)}`,r.style.borderRadius=`calc(${i.height} * ${(I=(E=e==null?void 0:e.shape)==null?void 0:E.roundCorners)!=null?I:t.roundCorners})`},ye=({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 J=class{constructor(e){this.control=e;this.container=null;this.controlElement=null;this.clickListener=null}createContainerElement(e){var n;let t=document.createElement("div");t.classList.add(`${B}-control-container-${this.control.id}`),e(t,this.control.layoutParams);let i=((n=this.control.layoutParams.innerSizesDependOn)!=null?n:$.innerSizesDependOn)==="self"?{height:t.style.height,width:t.style.width}:{height:"var(--interactive-content-height)",width:"var(--interactive-content-width)"};this.container={element:t,dimensions:i}}createClickListener(e){return t=>{t.stopPropagation(),e()}}setEvents(e){!this.container||!this.control.events||this.control.events.forEach(t=>{var n;switch(t.type.trim().toLowerCase()){case"onclick":this.clickListener=this.createClickListener(()=>e({action:t.action,controlId:this.control.id,controlType:this.control.type})),(n=this.container)==null||n.element.addEventListener("click",this.clickListener);break;default:break}})}removeListeners(){var e,t;(e=this.container)!=null&&e.element&&this.clickListener&&((t=this.container)==null||t.element.removeEventListener("click",this.clickListener))}};var Jt="int",ae=(i=>(i.AREA=`${Jt}_area`,i.TEXT=`${Jt}_text`,i.BUTTON=`${Jt}_bttn`,i))(ae||{});var pt=r=>{if(r.type.trim().toLowerCase()==="area")return new er(r)},er=class extends J{constructor(e){super(e)}createView({parentElement:e,layoutCallback:t}){if(super.createContainerElement(t),!this.container)return;let i=document.createElement("button");i.type="button",i.classList.add(`${B}-${this.control.id}`),i.setAttribute("data-testid",ae.AREA),i.style.display="flex",i.style.width="100%",i.style.height="100%",i.style.cursor="pointer",lt({target:i,props:this.control.props,fallback:C(d({},$),{backgroundColor:"transparent"})}),ct({target:i,props:this.control.props,fallback:C(d({},$),{borderAlpha:0}),dependsOn:this.container.dimensions}),ye({target:i,layoutParams:this.control.layoutParams,fallback:$}),this.container.element.append(i),e.append(this.container.element),this.controlElement=i}disable(){this.controlElement&&(this.controlElement.style.cursor="default")}enable(){this.controlElement&&(this.controlElement.style.cursor="pointer")}getElement(){return this.controlElement}};var ut=()=>{let r=document.createElement("span");return r.style.display="inline-block",r.style.whiteSpace="pre",r.style.overflow="hidden",r.style.textOverflow="ellipsis",r.style.maxWidth="100%",r.style.maxHeight="100%",r};var ht=r=>{if(r.type.trim().toLowerCase()==="button")return new tr(r)},tr=class extends J{constructor(e){super(e)}createView({parentElement:e,layoutCallback:t}){if(super.createContainerElement(t),!this.container)return;let i=document.createElement("button");i.type="button",i.classList.add(`${B}-${this.control.id}`),i.setAttribute("data-testid",ae.BUTTON),i.style.display="flex",i.style.width="100%",i.style.height="100%",i.style.cursor="pointer",i.style.fontFamily="inherit",ye({target:i,layoutParams:this.control.layoutParams,fallback:$}),lt({target:i,props:this.control.props,fallback:$}),ct({target:i,props:this.control.props,fallback:$,dependsOn:this.container.dimensions}),st({target:i,props:this.control.props});let n=ut();ot({target:n,props:this.control.props,fallback:$,dependsOn:this.container.dimensions}),i.append(n),this.container.element.append(i),e.append(this.container.element),this.controlElement=i}disable(){this.controlElement&&(this.controlElement.style.cursor="default")}enable(){this.controlElement&&(this.controlElement.style.cursor="pointer")}getElement(){return this.controlElement}};var Ti=r=>{if(r.type.trim().toLowerCase()==="text")return new rr(r)},rr=class extends J{constructor(e){super(e)}createView({parentElement:e,layoutCallback:t}){if(super.createContainerElement(t),!this.container)return;let i=document.createElement("div");i.classList.add(`${B}-${this.control.id}`),i.setAttribute("data-testid",ae.TEXT),i.style.display="flex",i.style.width="100%",i.style.height="100%",i.style.fontFamily="inherit",ye({target:i,layoutParams:this.control.layoutParams,fallback:$}),st({target:i,props:this.control.props});let n=ut();ot({target:n,props:this.control.props,fallback:$,dependsOn:this.container.dimensions}),i.append(n),this.container.element.append(i),e.append(this.container.element),this.controlElement=i}disable(){}enable(){}getElement(){return this.controlElement}};var ir=class{constructor(e){this.layout=e}},dt=class extends ir{constructor(e){super(e)}setContainerLayout(e){e.style.position="relative"}setControlLayout(e,t){e.style.position="absolute",e.style.width=`calc(var(--interactive-content-width) * ${t.width})`,e.style.height=`calc(var(--interactive-content-height) * ${t.height})`,e.style.left=`calc(var(--interactive-content-width) * ${t.x} + ((var(--interactive-width) - var(--interactive-content-width)) / 2))`,e.style.top=`calc(var(--interactive-content-height) * ${t.y} + ((var(--interactive-height) - var(--interactive-content-height)) / 2))`}};var ve=class{constructor(e){this.container=e,this.factories=new Map,this.controls=[],this.setControls()}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(),a=this.factories.get(n);if(a){let o=a(i);if(o)return[...t,o]}return[...t]},[]))||[]}};var ft=(r,e)=>{if(r.type.trim().toLowerCase()==="choice")return new nr(r,e)},nr=class extends ve{constructor(e,t){super(e),this.rootElement=t!=null?t:at(),this.layout=new dt(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",ht),this.addControlFactory("text",Ti),this.addControlFactory("area",pt)}createView(e){let t=document.createElement("div");return t.classList.add(`${B}-${this.container.id}`),this.layout.setContainerLayout(t),this.controls.forEach(i=>{i.createView({parentElement:t,layoutCallback:this.layout.setControlLayout}),i.setEvents(e)}),this.rootElement.append(t),this.isRemoved=!1,t}hide(){let e=this.getElement();e&&(e.style.visibility="hidden")}show(){let e=this.getElement();e&&(e.style.visibility="visible")}enable(){let e=this.getElement();e&&(this.controls.forEach(t=>t.enable()),e.style.opacity="1",this.isDisabled=!1)}disable(){let e=this.getElement();e&&(this.controls.forEach(t=>t.disable()),e.style.opacity=`${Ci}`,this.isDisabled=!0)}removeView(){var e;this.isRemoved||(this.controls.forEach(t=>t.removeListeners()),(e=this.getElement())==null||e.remove(),this.isRemoved=!0)}getElement(){return this.rootElement.querySelector(`.${B}-${this.container.id}`)}};var Fo=X(Vr(),1);import{clientChecker as mh,combine as yh,InterfaceLanguage as vh,Observable as Oo,once as gh,Subject as ne,Subscription as Vo,ValueSubject as D}from"@vkontakte/videoplayer-shared/es2015";import{InteractiveInterfaceClick as tt}from"@vkontakte/videoplayer-statistics/es2015";import{loadVKLangPack as lp}from"@vkontakte/videoplayer-shared/es2015";function Be(r,e){let t;return(...i)=>{clearTimeout(t),t=setTimeout(()=>r(...i),e)}}var oe=(r,e)=>Object.prototype.toString.call(r)===`[object ${e}]`,De=r=>oe(r,"Object"),Tt=r=>oe(r,"String"),St=r=>oe(r,"Array"),wt=r=>oe(r,"Number"),Aa=r=>oe(r,"Function");var jr=r=>wt(r)&&!isNaN(r);var le=r=>De(r)&&Object.keys(r).length===0,Fr=r=>St(r)&&!r.length;var He=(r,e)=>Tt(r)&&(e?r.trim():r).length;var La="video_interactive",Ma="videoint";var Ra=250,Ge=class{constructor(e){this.handleZoomChange=Be(e=>{this.lastZoomInfo=e},Ra);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)),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,"Id is not found"),console.error("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,!wt(e.graph.edit.chapters[0].x)){(i=this.onError)==null||i.call(this,"Can't show graph"),console.error("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:a=[]}){this.isReady=!1,this.isHidden=!0,this.manifest=null,this.visitedChapterIds=new Set(a),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=cp(e),this.resizeObserver=new ResizeObserver(Be(this.onResize,Ra)),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)}show(){return w(this,null,function*(){var e;this.manifest&&(this.ngEditor||(yield this.initNgEditor()),this.graphWrapperElement.style.display="block",!this.lastZoomInfo&&this.currentChapterId&&((e=this.ngEditor)==null||e.focusChapter(this.currentChapterId)),this.isHidden=!1)})}initNgEditor(){return w(this,null,function*(){if(!this.manifest)return;let e;try{e=yield lp(this.lang,La,Ma)}catch(i){console.log("Unable to load graph language pack")}let{GraphEditor:t}=yield import("@interactiveplatform/movika-graph-editor");this.ngEditor=new t(this.graphWrapperElement,{mode:"read",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.ngEditor.on("control",a=>{var o=a,{name:i}=o,n=j(o,["name"]);var l;i==="openPreview"&&"chapterId"in n&&((l=this.onOpenPreviewClick)==null||l.call(this,n.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 cp(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 Ue=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 a of this._containers){let o=a.startTime-e;if(o<=n&&(a.endTime&&n<=a.endTime||a.endTime===null)){i=!0;break}n<o&&(t=t===-1?o:Math.min(t,o))}return!i&&t!==-1?t:null}}};var ie=(r="",e="")=>{let t=r.split("."),i=e.split("."),n=0;for(let a=0;a<Math.max(t.length,i.length)&&!n;a++)t[a]>i[a]?n=1:t[a]<i[a]?n=-1:n=0;return n};import{v4 as pp}from"uuid";var up="3.1",Pa={default:"setNextBranch",random:"setRandomBranch",weightlessRandom:"setWeightlessRandomBranch",max:"setMaxWeightBranch",min:"setMinWeightBranch"},hp={type:"onSuspense",action:{type:"continuePlayback",args:{shouldOpenNow:!0,isDetachContainer:!0}}},ka=r=>{let e=[];for(let o of r.chapters){let l,s=[];for(let t of o.branches){let i=t,{isDefault:m}=i,f=j(i,["isDefault"]);m&&(l=f.id),s.push(f)}let c=[],y=[];for(let n of o.containers){let a=n,{fallbackStrategy:m}=a,f=j(a,["fallbackStrategy"]);let E=!!f.endTime,I=[hp];switch(m){case"await":E?I=[]:c=[];break;case"default":{let _={type:"onSuspense",action:{type:Pa.default,args:{branchId:l,shouldOpenNow:!E,isDetachContainer:!0}}};E?I=[_]:c=[_];break}case"random":case"weightlessRandom":case"max":case"min":{let _={type:"onSuspense",action:{type:Pa[m],args:{}}};E?I=[_]:c=[_];break}}for(let _ of f.controls)y.push(C(d({},f),{controls:[d({},_)],id:pp(),events:I}))}e.push(C(d({},o),{containers:y,events:c,branches:s}))}return r.metadata.version=up,r.metadata.updated=new Date().toISOString(),C(d({},r),{chapters:e})};var dp="3.2",Oa=r=>{if(!r.media){let e=r.metadata,{media:t}=e,i=j(e,["media"]);return C(d({},r),{metadata:C(d({},i),{version:dp}),media:t})}return r};var fp="3.3",mp=(r=[])=>({edit:{chapters:r},view:{}}),Va={type:"onSuspense",action:{type:"expect",args:{shouldOpenNow:!0,isDetachContainer:!0}}},ja=r=>{var n;let e=[],t=[];for(let a of r.chapters){let i=a,{id:o,x:l,y:s}=i,c=j(i,["id","x","y"]),y=c.containers.map(m=>{var f;return C(d({},m),{controls:m.controls.map(b=>{var u=b,{subtype:E,type:I}=u,_=j(u,["subtype","type"]);return C(d({},_),{type:E!=null?E:I})}),events:(f=m.events)!=null&&f.length?m.events:[Va]})});e.push(C(d({id:o},c),{containers:y,events:(n=c.events)!=null&&n.length?c.events:[Va]})),t.push({id:o,x:l,y:s})}return C(d({},r),{chapters:e,graph:mp(t),metadata:C(d({},r.metadata),{version:fp})})};var yp=[{version:"3.0",migrate:ka},{version:"3.1",migrate:Oa},{version:"3.2",migrate:ja}],Nr=r=>yp.reduce((e,t)=>ie(e.metadata.version,t.version)?e:t.migrate(e),r);var Fa={Button:"Button",Area:"Area",Text:"Text"};var M={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var Na={metadata:"Object",chapters:"Array"},vp="3.0.0",gp="3.3.0",_t=r=>{let e=ie(r,vp);return e===-1?!1:e===0?!0:ie(r,gp)!==1},$a=r=>{if(!De(r))return!1;for(let e in Na)if(!r[e]||!oe(r[e],Na[e]))return!1;return _t(r.metadata.version)},At=r=>r.type===Fa.Text;var F=class{constructor(e,t,...i){this.severity=e;this.category=t;this.data=i}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};var Lt=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 Mt=class{constructor(e){this.fns=[];this.addFn=(e,t=!1)=>{Aa(e)&&(this.fns.push(e),t&&this.updateFn())};this.removeFn=(e,t=!1)=>{this.fns=this.fns.filter(i=>i!==e),t&&this.updateFn()};this.updateFn=()=>{this.fn=()=>{this.fns.forEach(e=>e()),this.raf&&this.forceRequestAnimation()}};this.forceRequestAnimation=()=>{this.fn&&(this.raf=requestAnimationFrame(this.fn))};this.requestAnimation=()=>{this.raf||this.forceRequestAnimation()};this.cancelAnimation=()=>{this.raf&&(cancelAnimationFrame(this.raf),this.raf=void 0)};e&&(this.fn=e,this.addFn(e))}release(){this.cancelAnimation(),this.fn=void 0,this.fns=[]}};import{ValueSubject as Sp}from"@vkontakte/videoplayer-shared/es2015";var Rt=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:[]}}exec(e,t){return w(this,null,function*(){return bp(...this.loaders[e])(t)})}};function bp(...r){return function(t){return w(this,null,function*(){let i=[...r];for(;i.length>0;)t=yield i.shift()(t);return t})}}function ze(r,e,t){return r?C(d({},r),{[e]:r[e]?[t,...r[e]]:[t]}):{[e]:[t]}}function Pt(n){var a=n,{actions:r,errors:e,chapterId:t}=a,i=j(a,["actions","errors","chapterId"]);if(t){let o=r.getManifest(),l=r.getChapter(o.chapters,t);if(l){let s=r.getMedia(o.media,l.videoId),c=r.getGraph(o.graph,l.id);return s?C(d({},i),{actions:r,errors:e,result:{chapter:l,media:s,graph:c}}):C(d({},i),{errors:ze(e,Pt.name,"Could not find media"),actions:r})}}return C(d({},i),{errors:ze(e,Pt.name,"Could not find chapter"),actions:r})}var kt=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,a=i.length;n<a;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,a=i.length;n<a;n++){let o=i[n];try{o.callback.call(this,e)}catch(l){Promise.resolve().then(()=>{throw l})}o.options&&o.options.once&&this.removeEventListener(e.type,o.callback)}return!e.defaultPrevented}},Ie=class extends kt{constructor(){super(),this.listeners||kt.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)}},We=class{constructor(){Object.defineProperty(this,"signal",{value:new Ie,writable:!0,configurable:!0})}abort(e){let t;try{t=new Event("abort")}catch(n){typeof document!="undefined"?document.createEvent?(t=document.createEvent("Event"),t.initEvent("abort",!1,!1)):(t=document.createEventObject(),t.type="abort"):t={type:"abort",bubbles:!1,cancelable:!1}}let i=e;if(i===void 0)if(typeof document=="undefined")i=new Error("This operation was aborted"),i.name="AbortError";else try{i=new DOMException("signal is aborted without reason")}catch(n){i=new Error("This operation was aborted"),i.name="AbortError"}this.signal.reason=i,this.signal.dispatchEvent(t)}toString(){return"[object AbortController]"}};typeof Symbol!="undefined"&&Symbol.toStringTag&&(We.prototype[Symbol.toStringTag]="AbortController",Ie.prototype[Symbol.toStringTag]="AbortSignal");function Ot(r){return r.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill"),!0):typeof r.Request=="function"&&!r.Request.prototype.hasOwnProperty("signal")||!r.AbortController}function $r(r){typeof r=="function"&&(r={fetch:r});let{fetch:e,Request:t=e.Request,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n=!1}=r;if(!Ot({fetch:e,Request:t,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n}))return{fetch:e,Request:a};let a=t;(a&&!a.prototype.hasOwnProperty("signal")||n)&&(a=function(c,y){let m;y&&y.signal&&(m=y.signal,delete y.signal);let f=new t(c,y);return m&&Object.defineProperty(f,"signal",{writable:!1,enumerable:!1,configurable:!0,value:m}),f},a.prototype=t.prototype);let o=e;return{fetch:(s,c)=>{let y=a&&a.prototype.isPrototypeOf(s)?s.signal:c?c.signal:void 0;if(y){let m;try{m=new DOMException("Aborted","AbortError")}catch(E){m=new Error("Aborted"),m.name="AbortError"}if(y.aborted)return Promise.reject(m);let f=new Promise((E,I)=>{y.addEventListener("abort",()=>I(m),{once:!0})});return c&&c.signal&&delete c.signal,Promise.race([f,o(s,c)])}return o(s,c)},Request:a}}var Ke=Ot({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),qa=Ke?$r({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,qr=Ke?qa.fetch:window.fetch,mm=Ke?qa.Request:window.Request,ym=Ke?We:window.AbortController,vm=Ke?Ie:window.AbortSignal;var Cp=r=>w(void 0,null,function*(){try{let e={},t;if(Tt(r)){t=new URL(r).href;let n=yield qr(t);if(!n.ok)return{};e=yield n.json()}else if(De(r))e=r;else return{};if(!$a(e))return{};let i=e.metadata.media;if(Tt(i)&&!e.media)try{let n;t?n=new URL(i,t).href:(n=new URL(i).href,t=n);let a=yield qr(n);if(!a.ok)throw new Error;e.metadata.media=yield a.json()}catch(n){return Ip(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch(e){return{}}});function Ba(r){return w(this,null,function*(){let{manifest:e,manifestURL:t}=yield Cp(r),i=Nr(e);return i.media=Ep(i.media,t),delete i.metadata.media,i})}function Vt(r,e){if(e)return r.find(t=>t.id===e)}function Br(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 Dr(r,e){return r.videos.find(t=>t.id===e)}function Ep(r,e){return C(d({},r),{videos:r.videos.map(t=>C(d({},t),{variants:t.variants.map(i=>{let n="url"in i?i.url:"",a=xp(n,e);return C(d({},i),{url:a||n})})}))})}function xp(r="",e){try{return new URL(r,e).href}catch(t){return""}}function Ip(r){return ie(r,"3.2.0")>=0}var jt=r=>St(r)&&!Fr(r),Y=r=>r.order==="end",Ft=r=>St(r.containers)&&!Fr(r.containers)&&Y(r),Da=(r,e)=>{var i;let t=r*1e3;return jt(e.controls)&&t<((i=e.startTime)!=null?i:0)},Hr=(r,e)=>{var i,n;let t=r*1e3;return jt(e.controls)&&t>=((i=e.startTime)!=null?i:0)&&t<=((n=e.endTime)!=null?n:1/0)};var ce=(r=[])=>r.some(e=>e.action.type==="expect"),Gr=(r=[])=>r.find(e=>e.action.type==="expect"),Tp=r=>(r==null?void 0:r.length)===1,Te=r=>Tp(r)&&At(r[0]);function Ha(r,...e){return t=>typeof e[0]=="object"&&typeof t=="object"?r(d(d({},e[0]),t)):r(...e,...t)}var Ga=(r,e)=>ce(r.events)?!1:e.some(({container:t})=>t.container.id!==r.id&&ce(t.container.events)&&t.container.endTime===r.endTime&&!t.isRemoved);var Se=class extends Rt{constructor(t,i){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new Sp(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}setManifest(t){return w(this,null,function*(){var n;this.release();let i=yield this.exec("manifestLoaders",{actions:{addErrorMessage:ze},result:null,errors:null,source:t});return i.errors&&this.errorHandler(i.errors),this.manifest=yield Ba((n=i.result)!=null?n:t),this})}setInitial(){return w(this,null,function*(){return this.setNext()})}setNext(){return w(this,arguments,function*(t=(i=>(i=this.manifest)==null?void 0:i.metadata.initChapterId)()){if(!t)return this;this.prevChapter$.next(this.chapter);let n=yield this.exec("chapterLoaders",Pt({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:Br,getChapter:Vt,getMedia:Dr,getByBranches:this.getByBranches.bind(this),addErrorMessage:ze},result:null,errors:null,chapterId:t}));return n.errors&&this.errorHandler(n.errors),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=Vt(this.manifest.chapters,t);if(n){let a=Dr(this.manifest.media,n.videoId),o=Br(this.manifest.graph,n.id);if(a)return{chapter:n,media:a,graph:o}}return null}getBranches(t=(i=>(i=this.chapter)==null?void 0:i.id)()){var n,a,o;if(t===((n=this.chapter)==null?void 0:n.id))return this.getByBranches((a=this.chapter)==null?void 0:a.branches);{let l=Vt(((o=this.manifest)==null?void 0:o.chapters)||[],t);return this.getByBranches(l==null?void 0:l.branches)}}getByBranches(t=[]){return t.reduce((i,n)=>{let a=this.getByChapterId(n.chapterId);return a&&i.push(a),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 Ps=X(Nt(),1);import{Player as du}from"@vkontakte/videoplayer-core/es2015";import{Subscription as Yr,Tracer as fu,ValueSubject as mu}from"@vkontakte/videoplayer-shared/es2015";var Ts=r=>{let e=r.variants.find(t=>{var i;return((i=t.payload)==null?void 0:i.type)==="vk"});if(e&&"payload"in e){let[t,i]=e.payload.id.split("_");return[t,i]}return[]};var Ss=X(Nt(),1);function Kr(){let r=new Map;function e(s){var c=s,{listId:a=Math.random().toString(),itemId:o=Math.random().toString()}=c,l=j(c,["listId","itemId"]);let y=r.get(a),m=d({},l);return y?y[o]=m:r.set(a,{[o]:m}),d({listId:a,itemId:o},l)}function t(a){var o,l;a.player.destroy(),a.container.remove(),a.subscription.unsubscribe(),(o=a.statistics)==null||o.oneStat.destroy(),(l=a.statistics)==null||l.statSubscription.unsubscribe()}function i(a,o){let l=r.get(a);if(!l)throw Error("Can't remove. Not find.");if(o){let s=l[o];s&&t(s),delete l[o],Object.keys(l).length||r.delete(a)}else{for(let s of(0,Ss.default)(l))t(s);r.delete(a)}}function n(){for(let a of r)i(a[0])}return{createPlayer:e,removePlayer:i,map:r,removeAll:n}}var we=X($t(),1);function Qr(r,e=[]){var a,o,l;let t={},i,n=!e.length;for(let s of r.variants)if(!i&&"cover"in s&&(i=s.cover),"url"in s)switch(s.type.toLowerCase()){case"mp4":(n||(0,we.default)(e,"mp4"))&&(t.MPEG=C(d({},t.MPEG),{[(a=s.standard)!=null?a:"Invariant quality"]:s.url}));break;case"mpeg":(n||(0,we.default)(e,"mpeg"))&&(t.MPEG=C(d({},t.MPEG),{[(o=s.standard)!=null?o:"Invariant quality"]:s.url}));break;case"hls":(n||(0,we.default)(e,"hls"))&&(t=C(d({},t),{HLS:{type:"url",url:s.url}}));break;case"dash":(n||(0,we.default)(e,"dash"))&&(t=C(d({},t),{DASH_SEP:{compatibilityMode:!0,type:"url",url:s.url}}));break;default:break}return{sources:t,thumbUrl:i,title:(l=r.title)!=null?l:""}}var Qe=(r,e)=>{let t=r.info.currentQuality$.getValue(),i=r.info.availableQualities$.getValue();t!==e&&(0,we.default)(i,e)&&(r.setQuality(e),r.setAutoQuality(!1))};var yu=2;function Zr(r){let e=Kr(),t=new Yr,i={},n=null,a=!1,o,l=new mu(null);r&&s(r);function s(b){n=b}function c(b,u,h){var v;if(!n)throw Error("need to set interactive controller");if(!n.options)return;let T=((v=e.map.get(b))!=null?v:{})[u];if(T){i=d({chapterId:h,listId:b,itemId:u},T);let R=i.player;i.subscription.add(R.info.currentQuality$.subscribe(A=>{let q=R.info.position$.getValue(),P=R.info.isAutoQualityEnabled$.getValue();if(!(!A||!q||P))for(let O of e.map)(0,Ps.default)(O[1]).forEach(({player:k})=>{Qe(k,A)})})).add(R.events.started$.subscribe(()=>{y(u)})),T.container.remove(),n.setPlayer(T.player),a||(n.init(),a=!0),l.next({player:i.player,config:i.config,statistics:i.statistics});return}throw Error("Can't set. Not find.")}function y(b){return w(this,null,function*(){if(!n)throw Error("need to set interactive controller");if(le(i)||b!==i.itemId)return;let u=n.getChapterBranches(),h=new Set;for(let g of u)h.has(g.media.id)||(yield f({media:g.media,chapterId:g.chapter.id,setAsActive:!1,title:g.chapter.label}),h.add(g.media.id))})}function m(h){return w(this,arguments,function*({chapter:{id:b},manifestVideo:u}){if(le(i)||!n)return;let g=i.player.info.muted$.getValue(),T=i.player.info.currentQuality$.getValue(),v=i.player.info.isAutoQualityEnabled$.getValue(),R=i.player.info.volume$.getValue(),A=i.player.info.currentPlaybackRate$.getValue(),q=!v,P=!1;for(let O of e.map)if(O[0]===u.id&&!n.state.isReplay$.getValue()){let k=Object.keys(O[1]);for(let N of k)N===i.itemId?(k.length<yu||(P=!0),e.removePlayer(O[0],N)):(P=!0,c(O[0],N,b),q?Qe(i.player,T):i.player.setAutoQuality(!0),i.player.setVolume(R),i.player.setMuted(g),i.player.setPlaybackRate(A))}else e.removePlayer(O[0]);P||(yield f({media:u,chapterId:b,setAsActive:!0,playbackRate:A}),q?Qe(i.player,T):i.player.setAutoQuality(!0),i.player.setVolume(R),i.player.setMuted(g))})}function f(q){return w(this,arguments,function*({media:b,chapterId:u,prefetch:h=!0,setAsActive:g=!0,autoplay:T=!1,preferredExt:v,title:R,playbackRate:A}){var li,ci,pi,ui,hi;let P=Math.random().toString(),O=document.createElement("div");o.append(O);let k;if((li=n==null?void 0:n.options)!=null&&li.vkVideoLoader){let it=Ts(b);it.length&&(k=yield n.options.vkVideoLoader(...it))}let N=((ci=n==null?void 0:n.options)==null?void 0:ci.coreConfig)||void 0,Le=C(d({},N),{configName:[...(pi=N==null?void 0:N.configName)!=null?pi:[],"interactive"]}),rt=C(d({container:O},((ui=k==null?void 0:k.videos)==null?void 0:ui[0])||{sources:Qr(b,v).sources}),{title:R,failoverHosts:(k==null?void 0:k.failoverHosts)||[]}),fe=new du(Le,fu.createRootTracer());fe.initVideo(rt);let si=null;if(k!=null&&k.videos&&(n!=null&&n.options.createOneStat)){let it=k.videos[0],Qt=n.options.createOneStat(it),di=new Yr;Qt&&(di.add(Qt.attachTo(fe)),si={oneStat:Qt,statSubscription:di})}let oi=new Yr,No=(hi=i==null?void 0:i.player)==null?void 0:hi.info.isAutoQualityEnabled$.getValue();oi.add(fe.events.canplay$.subscribe(function(){No||Qe(fe,i.player.info.currentQuality$.getValue()),A&&fe.setPlaybackRate(A)}));let me=e.createPlayer({listId:b.id,itemId:P,player:fe,container:O,sources:Qr(b,v).sources,config:rt,subscription:oi,statistics:si});return g&&c(b.id,me.itemId,u),T&&me.player.play(),h&&!T&&me.player.prepare(),{player:me.player,config:me.config,statistics:me.statistics}})}function E(){I(),n=null,o.remove()}function I(){t.unsubscribe(),e.removeAll(),i={},a=!1}function _(){return w(this,null,function*(){if(!n)throw Error("need to set interactive controller");I(),o=document.createElement("div");let{media:b,chapter:u}=n.getCurrentChapter();b&&u?(t.add(n.events.chapterChanged$.subscribe(m)),yield f({media:b,chapterId:u.id,title:u.label})):console.error("not found")})}return C(d({},e),{init:_,setInteractiveController:s,createPlayer:f,removeAll:E,getActivePlayer:function(){return i},activePlayerChanged:l})}var x={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},Ye={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},L={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};var ks=X($t(),1);import{Subscription as vu}from"@vkontakte/videoplayer-shared/es2015";var qt=class{constructor({player:e,container:t,branches:i,selectBranches:n,interactiveEvents:a,globalEvents:o,globalEventEmitter:l,ignoreContainerEvent:s,permanentTextControls:c,disabledControls$:y,onRemove:m}){this.hide=()=>{setTimeout(()=>{var e,t;this.gameState!==4&&(ce(this.container.container.events)&&this.gameState===3||this.selectBranches.state.isExpect||(this.gameState!==2&&((t=(e=this.container).hide)==null||t.call(e)),this.globalEventEmitter.emit(x.interactives,{subjectId:this.container.container.id,subjectName:"container",type:L.visibility,visibility:!1})))})};this.show=()=>{var e,t,i,n;if(this.gameState===2&&!this.isSelectedControlEvent)if(this.container.getElement())(n=(i=this.container).show)==null||n.call(i),this.globalEventEmitter.emit(x.interactives,{subjectId:this.container.container.id,subjectName:"container",type:L.visibility,visibility:!0,isFirst:!1});else{let o=Ha(this.selectBranches.onControlEvent,{isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.globalEventEmitter.emit(x.interactives,{subjectId:this.container.container.id,subjectName:"container",type:L.visibility,visibility:!1})},onEvent:(l,s)=>{this.isSelectedControlEvent=!0,l!==!1&&(this.removeView(),this.globalEventEmitter.emit(x.interactives,{subjectId:this.container.container.id,subjectName:"container",type:L.visibility,visibility:!1})),(this.gameState===4||this.gameState===3||this.selectBranches.state.isExpect)&&(this.selectBranches.stopExpect(),s(),this.removeView(),this.globalEventEmitter.emit(x.interactives,{subjectId:this.container.container.id,subjectName:"container",type:L.visibility,visibility:!1}))},isEOV:()=>this.gameState===4});this.container.createView(o),this.globalEventEmitter.emit(x.interactives,{subjectId:this.container.container.id,subjectName:"container",type:L.visibility,visibility:!0,isFirst:!0}),this.disabledControls$.getValue()&&((t=(e=this.container).disable)==null||t.call(e))}};this.onEndOfVideo=()=>{this.gameState=4,this.selectContainerEvent(!0)};this.whilePlaying=()=>{var c;let e=this.player.experimental.element$.getValue(),i=e instanceof HTMLVideoElement?e.readyState:void 0,n=[6,5];if(!i||(0,ks.default)(n,this.gameState)&&!this.isPermanentText)return;let a=this.player.getExactTime();if(Da(a,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(Hr(a,this.container.container))this.gameState!==2&&(this.gameState=2,this.onStartTime());else if(this.gameState!==3){let y=this.gameState;this.gameState=3,y===2&&this.onEndTime()}else this.isPermanentText||this.removeView();let o=Hr(a,this.container.container),l=this.container.container.startTime?[this.container.container.startTime,(c=this.container.container.endTime)!=null?c:1/0]:[],s={subjectId:this.container.container.id,subjectName:"container",range:l,currentTime:a,isInteractiveTime:o};this.globalEventEmitter.emit(x.eachTick,s),this.globalEvents.eachTick$.next(s)};this.container=t,this.branches=i,this.selectBranches=n,this.subscription=new vu,this.player=e,this.interactiveEvents=a,this.ignoreContainerEvent=s,this.isPermanentText=c&&Te(t.container.controls),this.disabledControls$=y,this.onRemove=m,this.globalEventEmitter=l,this.gameState=0,this.globalEvents=o,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}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,a;e?(i=(t=this.container).disable)==null||i.call(t):(a=(n=this.container).enable)==null||a.call(n)}))}selectContainerEvent(e=!1){var t;this.interactiveEvents.containersEventsCallState.setCalled({timestamp:e?1/0:this.container.container.endTime,id:this.container.container.id}),!(this.isSelectedControlEvent||this.isSelectedContainerEvent)&&(this.isSelectedContainerEvent=!0,this.ignoreContainerEvent()||this.selectBranches.setManifestContainerEvents({container:this.container.container,branches:this.branches,isEOV:e}),!e&&this.interactiveEvents.exec((t=this.container.container.endTime)!=null?t:1/0))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);let e=ce(this.container.container.events)||this.ignoreContainerEvent();(this.isSelectedControlEvent||!e)&&this.removeView()}onBeforeStartTime(){var e,t;(t=(e=this.container).hide)==null||t.call(e),this.globalEventEmitter.emit(x.interactives,{subjectId:this.container.container.id,subjectName:"container",type:L.visibility,visibility:!1})}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=1}removeView(){var e;this.container.removeView(),this.globalEventEmitter.emit(x.interactives,{subjectId:this.container.container.id,subjectName:"container",type:L.containerRemoved,visibility:!1}),this.gameState=5,(e=this.onRemove)==null||e.call(this)}destroy(){var e;this.reset(),this.removeView(),this.gameState=6,this.subscription.unsubscribe(),this.branches=[],this.interactiveEvents.containersEventsCallState.setCalled({timestamp:(e=this.container.container.endTime)!=null?e:1/0,id:this.container.container.id})}};var Os=(r=[])=>r.reduce((e,t,i)=>{var a,o,l;let n=((a=t==null?void 0:t.controls)!=null?a:[]).filter(s=>!At(s));if(jt(n)){let s=[(o=t.startTime)!=null?o:0,(l=t.endTime)!=null?l:1/0],c=t.id;if(!i)e.push({subjects:[c],range:s});else{let y=[],m=-1/0,f=1/0,E=[],I=[];for(let _=0;_<e.length;_++){let b=e[_];if(I.push(...b.subjects),b.range[0]<f&&(f=b.range[0]),b.range[1]>m&&(m=b.range[1]),s[0]>=b.range[0]&&s[1]<=b.range[1])return e[_].subjects.push(c),e;s[0]<b.range[0]&&s[1]>b.range[0]&&(y.push(_),E=E.concat(b.subjects)),s[0]>=b.range[0]&&s[0]<=b.range[1]&&(y.push(_),E=E.concat(b.subjects),s[0]=b.range[0]),s[1]>=b.range[0]&&s[1]<=b.range[1]&&(y.push(_),E=E.concat(b.subjects),s[1]=b.range[1])}if(I.push(c),s[0]<=f&&s[1]>=m)return[{subjects:I,range:s}];y.length&&y.reverse().forEach(_=>{e.splice(_,1)}),e.push({subjects:E.concat([c]),range:s})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);var yo=X($t(),1),ti=X(Nt(),1),vo=X(fo(),1);function mo(){let r={};function e(){for(let l in r)Object.prototype.hasOwnProperty.call(r,l)&&delete r[l]}function t(l){let s={};for(let c in r)+c<=l&&(s[c]=r[c]);return s}function i(l){let s={};for(let c in r)+c>=l&&(s[c]=r[c]);return s}function n({timestamp:l,priority:s,initiator:c}){var y;if(jr(l)){let m=(y=r[l])!=null?y:null;if(m&&s&&He(s,!0)){let f={},E=m[s];if(E&&(f=d(d({},f),E)),f=le(f)?null:f,f&&He(c,!0)){let I=f[c];return I!=null?I:null}return f}return m}return null}function a({timestamp:l,priority:s,initiator:c}){if(jr(l))if(r[l]){if(s&&He(s,!0))if(r[l][s]){if(c&&He(c,!0))if(r[l][s][c]){if(delete r[l][s][c],!le(r[l][s]))return!0}else return!1;if(delete r[l][s],!le(r[l]))return!0}else return!1;return delete r[l]}else return!1;return!1}function o(m){var f=m,{timestamp:l,priority:s,initiator:c}=f,y=j(f,["timestamp","priority","initiator"]);var E,I,_;(I=(E=r[l])==null?void 0:E[s])!=null&&I[c]?r[l][s][c].push(d({},y)):(_=r[l])!=null&&_[s]?r[l][s]=C(d({},r[l][s]),{[c]:[d({},y)]}):r[l]?r[l]=C(d({},r[l]),{[s]:{[c]:[d({},y)]}}):r[l]={[s]:{[c]:[d({},y)]}}}return{map:r,remove:a,add:o,removeAll:e,get:n,getLte:t,getGte:i}}var ah=[M.expect,M.setNextBranch],sh=1/0;function go(r){let e=r,t,i=oh(),n=mo(),a,o=()=>{f(),u()},l=h=>{n.add.call(void 0,h),I()},s=(h=[])=>{for(let g of h)if(g.action(),(0,yo.default)(ah,g.actionType))break},c=(h=1/0)=>{var R,A,q;let g=Dt((R=n.get({timestamp:h,priority:"control"}))!=null?R:{}),T=Dt((A=n.get({timestamp:h,priority:"container"}))!=null?A:{}),v=Dt((q=n.get({timestamp:h,priority:"chapter"}))!=null?q:{});return[...g,...T,...v]},y=h=>{i.isReady(h)&&s(c(h))},m=()=>{var h;s([...Dt((h=n.get({timestamp:1/0,priority:"chapter"}))!=null?h:{})])},f=()=>{t&&(a==null||a.unsubscribe(),t=void 0)},E=h=>{},I=()=>{t||(t=()=>setTimeout(()=>{y(1/0)}),a=e.events.ended$.subscribe(t))},_=h=>{f(),e=h},b=h=>{h.priority==="container"&&i.resetCalled(h.timestamp),n.remove(h)},u=()=>{i.release(),n.removeAll()};return{setPlayer:_,add:l,remove:b,exec:y,execEndOfVideo:m,listen:I,unlisten:f,release:o,containersEventsCallState:i,getPreparedToExecActions:c}}function oh(){let r=new Map;return{setCalled:({timestamp:o,id:l})=>{let s=r.get(o);s&&s[l]!==void 0&&(s[l]=!0)},setData:(o=[])=>{var l,s;for(let c of o){let y=(l=c.endTime)!=null?l:sh,m=(s=r.get(y))!=null?s:{};r.set(y,C(d({},m),{[c.id]:!1}))}},resetCalled:o=>{let l=r.get(o);if(l)for(let s in l)l[s]=!1},isReady:o=>{let l=r.get(o);return l?!(0,ti.default)(l).some(s=>!s):!0},release:()=>r.clear()}}function Dt(r){return(0,vo.default)((0,ti.default)(r)).sort(e=>e.actionType===M.expect?-1:1)}var bo={videoContentHeight:0,videoContentWidth:0},Co=(r,e)=>{let{height:t,width:i}=e.info.intrinsicVideoSize$.getValue()||{};if(!(t&&i))return bo;let{clientHeight:n,clientWidth:a}=e.experimental.element$.getValue()||{};if(!(n&&a))return bo;let o=t/i,l=n/a,s,c;return l>o?(c=a,s=a*o):l<o?(c=n/o,s=n):(c=a,s=n),{videoContentWidth:c,videoContentHeight:s}};var lh=250;function Eo(r){let e=()=>{},t=new ResizeObserver(l=>{a(l),e=a.bind(null,l)});function i(l){let{parentElement:s,player:c}=r();if(s&&c){let{videoContentWidth:y,videoContentHeight:m}=Co(s,c);s.style.setProperty("--interactive-content-width",`${y}px`),s.style.setProperty("--interactive-content-height",`${m}px`),s.style.setProperty("--interactive-width",`${l[0].contentRect.width}px`),s.style.setProperty("--interactive-height",`${l[0].contentRect.height}px`)}}function n(){let{parentElement:l}=r();l.removeAttribute("style")}let a=Be(l=>{let{fns:s=[]}=r();i(l);for(let c of s)c()},lh);function o(){e=void 0,t.disconnect(),n()}return{resizeObserver:t,calc:()=>{e==null||e()},release:o}}var Xe=class{constructor(){this.map={}}push(e,t){e in this.map?this.map[e].push(t):this.map[e]=[t]}get(e){let t=this.map[e];return t?t.slice():null}getAll(){let e=[];for(let t in this.map)e.concat(this.map[t]);return e}remove(e,t){e in this.map&&(this.map[e]=this.map[e].filter(i=>i!==t),this.map[e].length===0&&delete this.map[e])}clear(){this.map={}}keys(){return Object.keys(this.map)}size(){return this.keys().length}};var ch=r=>Math.floor(Math.random()*r),Io=r=>{var n;let e=r.length,t=1/0,i=null;for(;e--;){let a=r[e],o=(n=a.weight)!=null?n:1;o<t&&(t=o,i=a)}return i},To=r=>{var n;let e=r.length,t=-1/0,i=null;for(;e--;){let a=r[e],o=(n=a.weight)!=null?n:0;o>t&&(t=o,i=a)}return i};var So=r=>{let e=r.length,t=ch(e);return r[t]},xo=1,wo=r=>{var i,n;let e=0;for(let a=0;a<r.length;++a)e+=(i=r[a].weight)!=null?i:xo;let t=Math.random()*e;e=0;for(let a=0;a<r.length-1;++a)if(e+=(n=r[a].weight)!=null?n:xo,e>=t)return r[a];return r[r.length-1]};var _o={shouldOpenNow:!0,isDetachContainer:!0};var ri=(r,e=!1)=>C(d({},r),{args:e?d(d({},r.args),_o):d(d({},_o),r.args)}),Mo=({globalEventEmitter:r,player:e,interactiveEvents:t,removeControllers:i})=>{let n={isExpect:!1},a=()=>{n.isExpect&&(n.isExpect=!1)},o=({action:u,controlType:h,controlId:g,containerId:T,branches:v=[],onEvent:R,isEOV:A=()=>!1,isDisabled:q=()=>!1})=>{let P=ri(u,A()),O={timestamp:1/0,priority:"control",initiator:g,actionType:P.type},k=q(),N=r.emit.bind(r,x.interactives,{subjectId:g,subjectType:h,subjectName:"control",type:k?L.actionChoiceCanceled:L.actionChoice,actionType:u.type,payload:d({containerId:T},P.args)});if(k){N();return}switch(P.type.trim().toLowerCase()){case M.setNextBranch.trim().toLowerCase():{let Le=v.find(rt=>rt.id===P.args.branchId);if(!Le)return;R(P.args.isDetachContainer,f.bind(null,{subjectId:g,subjectName:"control"})),N(),P.args.shouldOpenNow?I({subjectId:g,subjectName:"control",subjectType:h,action:P,payload:{chapterId:Le.chapterId,autoSelect:!1}}):(t.add(C(d({},O),{action:I.bind(null,{subjectId:g,subjectName:"control",subjectType:h,action:P,payload:{chapterId:Le.chapterId,autoSelect:!1}})})),i==null||i());return}case M.continuePlayback.trim().toLowerCase():{R(P.args.isDetachContainer,f.bind(null,{subjectId:g,subjectName:"control"})),N(),P.args.shouldOpenNow?E({subjectId:g,subjectName:"control",subjectType:h,action:u}):t.add(C(d({},O),{action:E.bind(null,{subjectId:g,subjectName:"control",subjectType:h,action:u})}));return}case M.openURI.trim().toLowerCase():{R(P.args.isDetachContainer,f.bind(null,{subjectId:g,subjectName:"control"})),N(),P.args.shouldOpenNow?b({subjectId:g,subjectName:"control",subjectType:h,action:P,payload:{URI:u.args.uri}}):(t.add(C(d({},O),{action:b.bind(null,{subjectId:g,subjectName:"control",subjectType:h,action:P,payload:{URI:u.args.uri}})})),i==null||i());return}default:console.error("Unexpected control event"),r.emit(x.errors,new F(1,1,{message:"Unexpected control event"}));return}},l=({action:u,container:{id:h,endTime:g},branches:T=[],isEOV:v=!1,autoSelected:R=!1})=>{let A=ri(u,v),q={timestamp:!A.args.shouldOpenNow||v?1/0:g!=null?g:1/0,priority:"container",initiator:h,actionType:A.type},P=r.emit.bind(r,x.interactives,{subjectId:h,subjectName:"container",type:L.actionChoice,actionType:A.type,payload:A.args});switch(A.type.trim().toLowerCase()){case M.setNextBranch.trim().toLowerCase():{let O=T.find(k=>k.id===A.args.branchId);if(!O)return;P(),t.add(C(d({},q),{action:I.bind(null,{subjectId:h,subjectName:"container",action:A,payload:{chapterId:O.chapterId,autoSelect:R}})})),i==null||i();return}case M.setMaxWeightBranch.trim().toLowerCase():return;case M.setMinWeightBranch.trim().toLowerCase():return;case M.setRandomBranch.trim().toLowerCase():return;case M.setWeightlessRandomBranch.trim().toLowerCase():return;case M.continuePlayback.trim().toLowerCase():{P(),t.add(C(d({},q),{action:E.bind(null,{subjectId:h,subjectName:"container",action:A})}));return}case M.openURI.trim().toLowerCase():{P(),t.add(C(d({},q),{action:b.bind(null,{subjectId:h,subjectName:"container",action:A,payload:{URI:u.args.uri}})})),i==null||i();return}default:console.error("Unexpected container event"),r.emit(x.errors,new F(1,1,{message:"Unexpected container event"}));return}};function s({container:u,branches:h,isEOV:g=!1}){var v,R;let T=Gr(u.events);if(T){let A=ri(T.action,g);r.emit(x.interactives,{subjectId:u.id,subjectName:"container",type:L.actionChoice,actionType:A.type,payload:A.args}),t.add({timestamp:g?1/0:(v=u.endTime)!=null?v:1/0,priority:"container",initiator:u.id,actionType:M.expect,action:m.bind(null,{subjectId:u.id,subjectName:"container"})}),n.isExpect=!0}else for(let A of(R=u.events)!=null?R:[])l({action:A.action,container:u,branches:h,isEOV:g})}let c=({chapterId:u,action:h,branches:g=[]})=>{let T=r.emit.bind(r,x.interactives,{subjectId:u,subjectName:"chapter",type:L.actionChoice,actionType:h.type,payload:h.args});switch(h.type.trim().toLowerCase()){case M.setNextBranch.trim().toLowerCase():{let v=g.find(R=>R.id===h.args.branchId);return v!=null&&v.chapterId?(T(),I.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case M.setWeightlessRandomBranch.trim().toLowerCase():{let v=So(g);return v!=null&&v.chapterId?(T(),I.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case M.setRandomBranch.trim().toLowerCase():{let v=wo(g);return v!=null&&v.chapterId?(T(),I.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case M.setMaxWeightBranch.trim().toLowerCase():{let v=To(g);return v!=null&&v.chapterId?(T(),I.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case M.setMinWeightBranch.trim().toLowerCase():{let v=Io(g);return v!=null&&v.chapterId?(T(),I.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case M.continuePlayback.trim().toLowerCase():return T(),E.bind(null,{subjectId:u,subjectName:"chapter",action:h});case M.openURI.trim().toLowerCase():return T(),b.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{URI:h.args.uri}});default:console.error("Unexpected chapter event"),r.emit(x.errors,new F(1,1,{message:"Unexpected chapter event"}));return}};function y(u){var g;let h=Gr(u.events);if(h){if(Y(u))return;r.emit(x.interactives,{subjectId:u.id,subjectName:"chapter",type:L.actionChoice,actionType:h.action.type,payload:h.action.args}),t.add({timestamp:1/0,priority:"chapter",initiator:u.id,actionType:M.expect,action:m.bind(null,{subjectId:u.id,subjectName:"chapter"})})}else(g=u.events)==null||g.forEach(T=>{let v=c({chapterId:u.id,action:T.action,branches:u.branches});v&&t.add({timestamp:1/0,priority:"chapter",initiator:u.id,actionType:T.action.type,action:v})})}let m=({subjectId:u,subjectName:h})=>{e.pause(),r.emit(x.interactives,{subjectId:u,subjectName:h,type:L.actionExecution,actionType:M.expect})},f=({subjectId:u,subjectName:h})=>{e.info.isEnded$.getValue()?t.execEndOfVideo():e.play(),r.emit(x.interactives,{subjectId:u,subjectName:h,type:L.actionExecution,actionType:"after-expect"})},E=({subjectId:u,subjectName:h,subjectType:g,action:T})=>{r.emit(x.interactives,{subjectId:u,subjectName:h,subjectType:g,type:L.actionExecution,actionType:T.type})},I=({subjectId:u,subjectName:h,subjectType:g,action:T,payload:v})=>{v.behaviour="change-chapter",r.emit(x.interactives,{subjectId:u,subjectName:h,subjectType:g,type:L.actionExecution,actionType:T.type,payload:v})},_=({subjectId:u,subjectName:h,subjectType:g,action:T,payload:v})=>{v.behaviour="change-manifest",r.emit(x.interactives,{subjectId:u,subjectName:h,subjectType:g,type:L.actionExecution,actionType:T.type,payload:v})},b=({subjectId:u,subjectName:h,subjectType:g,action:T,payload:v})=>{if(!v.URI)return;let R=window.open(v.URI,"_blank","noopener,noreferrer");R&&(R.opener=null),r.emit(x.interactives,{subjectId:u,subjectName:h,subjectType:g,type:L.actionExecution,actionType:T.type})};return{onControlEvent:o,onContainerEvent:l,onChapterEvent:c,onExpectEvent:m,expectEventHandler:f,setManifestChapterEvents:y,setManifestContainerEvents:s,stopExpect:a,state:n}};var ai=X(Vr(),1);import{Subscription as fh,Subject as ni,ValueSubject as Je}from"@vkontakte/videoplayer-shared/es2015";var ii=(r,e)=>{let t={};return r.map(i=>{if(!t[i]){let n=e.chapters.find(o=>o.id===i);if(!n)return null;let a=e.media.videos.find(o=>n.videoId===o.id);if(!a)return null;t[i]=Ro(a)}return t[i]}).filter(Boolean)},uh=r=>{for(let e of r.variants)if(hh(e)&&"payload"in e)return e.payload.id},hh=r=>r.type==="custom"&&"payload"in r&&r.payload.type==="vk",Ro=r=>{let e=uh(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},dh=(r,e)=>{for(let t of r.media.videos)if(e===Ro(t)){for(let i of r.chapters)if(i.videoId===t.id)return i.id;return}},Po=(r,e)=>r.reduce((t,i)=>{let n=dh(e,i);return n?[...t,n]:t},[]);var ee,pe,ue,z,Ht,te,re,Z,he,_e,Ae,et=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:i,historyApi:n,settings:a}){this.state={history$:new Je([]),hasPrevChapter$:new Je(!1),prevChapter$:new Je(null),isInitialChapter$:new Je(!1),isGoBackLimited$:new Je(!1)};H(this,ee,null);H(this,pe);H(this,ue,!1);H(this,z,null);H(this,Ht,null);this.events={inited$:new ni,destroyed$:new ni,error$:new ni};H(this,te,null);H(this,re,null);H(this,Z,null);H(this,he,new fh);H(this,_e,!1);H(this,Ae,0);var o;V(this,te,t),V(this,Z,e),V(this,re,i),V(this,ee,n),V(this,pe,a),this.state.history$&&S(this,he)&&((o=S(this,he))==null||o.add(this.state.history$.subscribe(l=>{var s,c;this.state.prevChapter$.next((0,ai.default)(l,-2)||null),this.state.hasPrevChapter$.next(l.length>1),this.state.isInitialChapter$.next(this.getInitialChapterId()===((c=(s=S(this,z))==null?void 0:s.metadata)==null?void 0:c.initChapterId)),this.state.isGoBackLimited$.next(S(this,Ae)===S(this,pe).maxLength-1)})))}setManifest(e){return w(this,null,function*(){if(!S(this,re)||!S(this,Z))return;V(this,z,e),yield this.getProjectHistory();let t=this.getInitialChapterId();yield S(this,re).setChapter({chapterId:t,pushToHistory:!1}),S(this,ue)||(V(this,ue,!0),this.events.inited$.next({initChapterId:t}))})}get inited(){return S(this,ue)}updateHistory(e,t=!0){return w(this,null,function*(){var l;if(!S(this,z))return;S(this,_e)?(V(this,_e,!1),gi(this,Ae)._++):V(this,Ae,0);let i=S(this,z),n=e.length-S(this,pe).maxLength,a=n>0?e.slice(n):e,o=ii(a,i);if(V(this,Ht,o),this.state.history$.next(a),!(!t||!S(this,ee)||!S(this,te)))try{yield S(this,ee).save(S(this,te),o)}catch(s){let c=new F(1,5,"Unable to save interactive history");this.events.error$.next(c),(l=S(this,Z))==null||l.emit(x.errors,c)}})}goBack(){return w(this,null,function*(){var i;if(!this.state||!S(this,re)){let n=new F(1,5,"Unable to save interactive history");return this.events.error$.next(n),(i=S(this,Z))==null?void 0:i.emit(x.errors,n)}V(this,_e,!0);let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),yield S(this,re).setChapter({chapterId:t,playPrev:!0})})}getProjectHistory(){return w(this,null,function*(){var n;if(!S(this,z)||!S(this,te))return;let e=S(this,z),t=[this.getInitialVideoId()];if(S(this,ee))try{let a=yield S(this,ee).get(S(this,te));a.length&&(t=a)}catch(a){let o=new F(1,5,"Error while trying to fetch data");this.events.error$.next(o),(n=S(this,Z))==null||n.emit(x.errors,o)}let i=Po(t,e);this.state.history$.next(i)})}getInitialChapterId(){var t;let e=this.state.history$.getValue();return(0,ai.default)(e,-1)||S(this,pe).initChapterId||((t=S(this,z))==null?void 0:t.metadata.initChapterId)}getInitialVideoId(){if(S(this,z)){let e=this.getInitialChapterId();return ii([e],S(this,z)).pop()}return null}destroy(){var e,t;V(this,te,null),V(this,ee,null),V(this,re,null),(e=S(this,he))==null||e.unsubscribe(),V(this,he,null),V(this,ue,!1),(t=S(this,Z))==null||t.emit(x.historyDestroyed),this.events.destroyed$.next(),V(this,Z,null)}};ee=new WeakMap,pe=new WeakMap,ue=new WeakMap,z=new WeakMap,Ht=new WeakMap,te=new WeakMap,re=new WeakMap,Z=new WeakMap,he=new WeakMap,_e=new WeakMap,Ae=new WeakMap;var de=class de{constructor(e,t,i,n){this.target=e,this.type=t,this.listener=i,this.options=de._convertOptions(e,n),this.target.addEventListener(t,i,this.options)}unlisten(){var e;this.type&&this.listener&&this.options&&((e=this.target)==null||e.removeEventListener(this.type,this.listener,this.options)),this.target=null,this.type=null,this.listener=null,this.options=!1}static _convertOptions(e,t){if(t===void 0)return!1;if(typeof t=="boolean")return t;{let i=new Set(["passive","capture"]),n=Object.keys(t).filter(o=>!i.has(o));return n.length===0&&console.warn("Unsupported flag(s) to addEventListener: "+n.join(",")),de._doesSupportObject(e)?t:t.capture||!1}}static _doesSupportObject(e){let t=de._supportsObject;if(t===void 0){t=!1;try{let i={},n={get:()=>(t=!0,!1)};Object.defineProperty(i,"passive",n),Object.defineProperty(i,"capture",n);let a=()=>{};e.addEventListener("test",a,i),e.removeEventListener("test",a,i)}catch(i){t=!1}de._supportsObject=t}return t||!1}};de._supportsObject=void 0;var Gt=de;var Ut=class{constructor(){this.bindingMap=new Xe}release(){this.removeAll(),this.bindingMap=null}listen(e,t,i,n){if(!this.bindingMap)return;let a=new Gt(e,t,i,n);this.bindingMap.push(t,a)}listenOnce(e,t,i,n){let a=o=>{this.unlisten(e,t,a),i(o)};this.listen(e,t,a,n)}unlisten(e,t,i){if(!this.bindingMap)return;let n=this.bindingMap.get(t)||[];for(let a of n)a.target===e&&(i===a.listener||!i)&&(a.unlisten(),this.bindingMap.remove(t,a))}removeAll(){if(!this.bindingMap)return;let e=this.bindingMap.getAll();for(let t of e)t.unlisten();this.bindingMap.clear()}};var zt=class{constructor(){this._prevSizeId=0;this.rootElement=document.createElement("canvas")}clear(){var e;(e=this.rootElement.getContext("2d"))==null||e.clearRect(0,0,this.rootElement.width,this.rootElement.height)}isImageDrawn(){var n;let e=(n=this.rootElement.getContext("2d"))==null?void 0:n.getImageData(0,0,this.rootElement.width,this.rootElement.height);if(!e)return!1;let t=e.data,i=t.length;for(let a=3;a<i;a+=40)if(t[a]!==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))}updateCanvasDimensions(e,t=!1){return w(this,null,function*(){let i=e.width+e.height;if(this._prevSizeId===i)return;let n;t&&(n=yield this.save()),this.rootElement.width=e.width,this.rootElement.height=e.height,t&&n&&this.restore(n),this._prevSizeId=i})}save(){return w(this,null,function*(){let e=this.rootElement.toDataURL("image/jpeg",1),t=new Image;return t.crossOrigin="anonymous",t.src=e,yield 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 Wt=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;
|