@vkontakte/videoplayer-interactive 1.0.30-dev.5ea97646.0 → 1.0.30-dev.7e0915d0.0

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